コード例 #1
0
#python

import k3d
import testing

setup = testing.setup_mesh_modifier_test("PolyGrid", "CollapseFaces")

selection = k3d.selection.set()
primitive_selection = k3d.geometry.primitive_selection.create(selection, k3d.selection.type.FACE)
k3d.geometry.primitive_selection.append(primitive_selection, 0, 1, 1)
k3d.geometry.primitive_selection.append(primitive_selection, 13, 14, 1)
k3d.geometry.primitive_selection.append(primitive_selection, 17, 18, 1)
k3d.geometry.primitive_selection.append(primitive_selection, 19, 20, 1)
k3d.geometry.primitive_selection.append(primitive_selection, 23, 24, 1)

setup.modifier.mesh_selection = selection

testing.require_valid_mesh(setup.document, setup.modifier.get_property("output_mesh"))
testing.require_similar_mesh(setup.document, setup.modifier.get_property("output_mesh"), "mesh.modifier.CollapseFaces", 2)

コード例 #2
0
#python

import k3d
import testing

document = k3d.new_document()

grid = k3d.plugin.create("PolyGrid", document)
scale = k3d.plugin.create("ScalePoints", document)
select = k3d.plugin.create("SelectDegenerateFaces", document)

selection = k3d.geometry.selection.create(0)
point_selection = k3d.geometry.point_selection.create(selection)
k3d.geometry.point_selection.append(point_selection, 0, 10000, 0.)
k3d.geometry.point_selection.append(point_selection, 0, 12, 1.)

scale.mesh_selection = selection
scale.x = 0.

k3d.property.connect(document, grid.get_property("output_mesh"),
                     scale.get_property("input_mesh"))
k3d.property.connect(document, scale.get_property("output_mesh"),
                     select.get_property("input_mesh"))

testing.require_valid_mesh(document, select.get_property("output_mesh"))
testing.require_similar_mesh(document, select.get_property("output_mesh"),
                             "mesh.selection.SelectDegenerateFaces", 1)
#python

import k3d
import testing

script_path = k3d.share_path() / k3d.filesystem.generic_path("scripts/MeshSourceScript/bezier_triangle_patches.py")
script_file = file(str(script_path), "r")

setup = testing.setup_mesh_source_test("MeshSourceScript")
setup.source.script = script_file.read()


testing.require_valid_mesh(setup.document, setup.source.get_property("output_mesh"))
testing.require_similar_mesh(setup.document, setup.source.get_property("output_mesh"), "mesh.source.MeshSourceScript.bezier_triangle_patches", 2)

コード例 #4
0
#python

import k3d
import testing
import benchmarking

document = k3d.new_document()

sphere = k3d.plugin.create("PolySphere", document)
torus = k3d.plugin.create("PolyTorus", document)

carve_boolean = k3d.plugin.create("CARVEBoolean", document)
k3d.property.create(carve_boolean, "k3d::mesh*", "input_1", "Input 1", "")
k3d.property.create(carve_boolean, "k3d::mesh*", "input_2", "Input 2", "")

k3d.property.connect(document, sphere.get_property("output_mesh"), carve_boolean.get_property("input_1"))
k3d.property.connect(document, torus.get_property("output_mesh"), carve_boolean.get_property("input_2"))

profiler = k3d.plugin.create("PipelineProfiler", document)

testing.require_valid_mesh(document, carve_boolean.get_property("output_mesh"))
testing.require_similar_mesh(document, carve_boolean.get_property("output_mesh"), "mesh.modifier.CARVEBoolean.benchmark", 1)
benchmarking.print_profiler_records(profiler.records)
print """<DartMeasurement name="Total Boolean Time" type="numeric/float">""" + str(benchmarking.total_profiler_time(profiler.records)) + """</DartMeasurement>"""
コード例 #5
0
import testing
import k3d

document = k3d.new_document()

patch = k3d.plugin.create("NurbsGrid", document)
curve = k3d.plugin.create("NurbsCircle", document)
merge_mesh = k3d.plugin.create("MergeMesh", document)
modifier = k3d.plugin.create("NurbsAddTrimCurve", document)
extract_trim = k3d.plugin.create("NurbsExtractTrimCurves", document)

k3d.property.create(merge_mesh, "k3d::mesh*", "input_mesh1", "Input Mesh 1", "")
k3d.property.create(merge_mesh, "k3d::mesh*", "input_mesh2", "Input Mesh 2", "")

modifier.mesh_selection = k3d.geometry.selection.create(1)
modifier.offset_u = 0.5
modifier.offset_v = 0.5
modifier.delete_curve = True

extract_trim.mesh_selection = k3d.geometry.selection.create(1)

k3d.property.connect(document, patch.get_property("output_mesh"), merge_mesh.get_property("input_mesh1"))
k3d.property.connect(document, curve.get_property("output_mesh"), merge_mesh.get_property("input_mesh2"))
k3d.property.connect(document, merge_mesh.get_property("output_mesh"), modifier.get_property("input_mesh"))
k3d.property.connect(document, modifier.get_property("output_mesh"), extract_trim.get_property("input_mesh"))

testing.require_valid_mesh(document, extract_trim.get_property("output_mesh"))
testing.require_similar_mesh(document, extract_trim.get_property("output_mesh"), "mesh.modifier.NurbsExtractTrimCurves", 10)

コード例 #6
0
#python

import k3d
import testing

document = k3d.new_document()

source1 = k3d.plugin.create("PolyCube", document)
source2 = k3d.plugin.create("PolyCube", document)

merge = k3d.plugin.create("MergeMesh", document)
k3d.property.create(merge, "k3d::mesh*", "input_mesh1", "Input Mesh 1", "")
k3d.property.create(merge, "k3d::mesh*", "input_mesh2", "Input Mesh 2", "")
k3d.property.connect(document, source1.get_property("output_mesh"), merge.get_property("input_mesh1"))
k3d.property.connect(document, source1.get_property("output_mesh"), merge.get_property("input_mesh2"))

weld = k3d.plugin.create("WeldPoints", document)
weld.distance = 0.5
k3d.property.connect(document, merge.get_property("output_mesh"), weld.get_property("input_mesh"))

testing.require_valid_mesh(document, weld.get_property("output_mesh"))
testing.require_similar_mesh(document, weld.get_property("output_mesh"), "mesh.modifier.WeldPoints", 1)

コード例 #7
0
#python

import k3d
import testing

script_path = k3d.share_path() / k3d.filesystem.generic_path(
    "scripts/MeshSourceScript/hyperboloids.py")
script_file = file(str(script_path), "r")

setup = testing.setup_mesh_source_test("MeshSourceScript")
setup.source.script = script_file.read()

testing.require_valid_mesh(setup.document,
                           setup.source.get_property("output_mesh"))
testing.require_similar_mesh(setup.document,
                             setup.source.get_property("output_mesh"),
                             "mesh.source.MeshSourceScript.hyperboloids", 2)
コード例 #8
0
#python

import k3d
import testing
import benchmarking

document = k3d.new_document()

sphere = k3d.plugin.create("PolySphere", document)
torus = k3d.plugin.create("PolyTorus", document)

cgal_boolean = k3d.plugin.create("CGALBoolean", document)
k3d.property.create(cgal_boolean, "k3d::mesh*", "input_1", "Input 1", "")
k3d.property.create(cgal_boolean, "k3d::mesh*", "input_2", "Input 2", "")

k3d.property.connect(document, sphere.get_property("output_mesh"),
                     cgal_boolean.get_property("input_1"))
k3d.property.connect(document, torus.get_property("output_mesh"),
                     cgal_boolean.get_property("input_2"))

profiler = k3d.plugin.create("PipelineProfiler", document)

testing.require_valid_mesh(document, cgal_boolean.get_property("output_mesh"))
testing.require_similar_mesh(document,
                             cgal_boolean.get_property("output_mesh"),
                             "mesh.modifier.CGALBoolean.benchmark", 1)
benchmarking.print_profiler_records(profiler.records)
print """<DartMeasurement name="Total Boolean Time" type="numeric/float">""" + str(
    benchmarking.total_profiler_time(
        profiler.records)) + """</DartMeasurement>"""
コード例 #9
0
source2 = k3d.plugin.create("PolyCube", document)
source2.width = 4.0
source2.height = 4.0
source2.depth = 4.0

modifier1 = k3d.plugin.create("PointsToParticles", document)
modifier1.width = 2.0

modifier2 = k3d.plugin.create("PointsToParticles", document)
modifier2.width = 3.0

k3d.property.connect(document, source1.get_property("output_mesh"),
                     modifier1.get_property("input_mesh"))
k3d.property.connect(document, source2.get_property("output_mesh"),
                     modifier2.get_property("input_mesh"))

merge_mesh = k3d.plugin.create("MergeMesh", document)
k3d.property.create(merge_mesh, "k3d::mesh*", "input_mesh1", "Input Mesh 1",
                    "")
k3d.property.create(merge_mesh, "k3d::mesh*", "input_mesh2", "Input Mesh 2",
                    "")

k3d.property.connect(document, modifier1.get_property("output_mesh"),
                     merge_mesh.get_property("input_mesh1"))
k3d.property.connect(document, modifier2.get_property("output_mesh"),
                     merge_mesh.get_property("input_mesh2"))

testing.require_valid_mesh(document, merge_mesh.get_property("output_mesh"))
testing.require_similar_mesh(document, merge_mesh.get_property("output_mesh"),
                             "mesh.modifier.MergeMesh.generic", 2)
コード例 #10
0
curve = k3d.plugin.create("NurbsCircle", document)
merge_mesh = k3d.plugin.create("MergeMesh", document)
modifier = k3d.plugin.create("NurbsAddTrimCurve", document)
extract_trim = k3d.plugin.create("NurbsExtractTrimCurves", document)

k3d.property.create(merge_mesh, "k3d::mesh*", "input_mesh1", "Input Mesh 1",
                    "")
k3d.property.create(merge_mesh, "k3d::mesh*", "input_mesh2", "Input Mesh 2",
                    "")

modifier.mesh_selection = k3d.geometry.selection.create(1)
modifier.offset_u = 0.5
modifier.offset_v = 0.5
modifier.delete_curve = True

extract_trim.mesh_selection = k3d.geometry.selection.create(1)

k3d.property.connect(document, patch.get_property("output_mesh"),
                     merge_mesh.get_property("input_mesh1"))
k3d.property.connect(document, curve.get_property("output_mesh"),
                     merge_mesh.get_property("input_mesh2"))
k3d.property.connect(document, merge_mesh.get_property("output_mesh"),
                     modifier.get_property("input_mesh"))
k3d.property.connect(document, modifier.get_property("output_mesh"),
                     extract_trim.get_property("input_mesh"))

testing.require_valid_mesh(document, extract_trim.get_property("output_mesh"))
testing.require_similar_mesh(document,
                             extract_trim.get_property("output_mesh"),
                             "mesh.modifier.NurbsExtractTrimCurves", 10)