Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import k3d
import testing
setup = testing.setup_mesh_modifier_test("PolyGrid", "GrowSelection")
selection = k3d.geometry.selection.create(0)
point_selection = k3d.geometry.point_selection.create(selection)
k3d.geometry.point_selection.append(point_selection, 15, 16, 1)
k3d.geometry.point_selection.append(point_selection, 18, 19, 1)
edge_selection = k3d.geometry.primitive_selection.create(selection, k3d.selection.type.EDGE)
k3d.geometry.primitive_selection.append(edge_selection, 17, 18, 1)
k3d.geometry.primitive_selection.append(edge_selection, 55, 56, 1)
face_selection = k3d.geometry.primitive_selection.create(selection, k3d.selection.type.FACE)
k3d.geometry.primitive_selection.append(face_selection, 12, 13, 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.selection.GrowSelection", 2)
#python
import k3d
import testing
setup = testing.setup_mesh_modifier_test("NurbsCircle","NurbsEditCurveKnotVector")
selection = k3d.geometry.selection.create(0)
curve_selection = k3d.geometry.primitive_selection.create(selection, k3d.selection.type.CURVE)
k3d.geometry.primitive_selection.append(curve_selection, 0, 10000, 1)
setup.modifier.mesh_selection = selection
setup.modifier.knot_vector = [0, 0, 0, 0.1, 0.2, 0.25, 0.3, 0.3, 0.8, 0.8, 1, 1, 1]
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.NurbsEditKnotVector", 1, ["Darwin-i386"])
#python
import k3d
import testing
setup = testing.setup_mesh_modifier_test("PolyGrid", "CollapseEdges")
selection = k3d.selection.set()
primitive_selection = k3d.geometry.primitive_selection.create(selection, k3d.selection.type.EDGE)
k3d.geometry.primitive_selection.append(primitive_selection, 10, 11, 1)
k3d.geometry.primitive_selection.append(primitive_selection, 28, 29, 1)
k3d.geometry.primitive_selection.append(primitive_selection, 30, 31, 1)
k3d.geometry.primitive_selection.append(primitive_selection, 48, 49, 1)
k3d.geometry.primitive_selection.append(primitive_selection, 48, 49, 1)
k3d.geometry.primitive_selection.append(primitive_selection, 50, 51, 1)
k3d.geometry.primitive_selection.append(primitive_selection, 68, 69, 1)
k3d.geometry.primitive_selection.append(primitive_selection, 70, 71, 1)
k3d.geometry.primitive_selection.append(primitive_selection, 88, 89, 1)
k3d.geometry.primitive_selection.append(primitive_selection, 90, 91, 1)
k3d.geometry.primitive_selection.append(primitive_selection, 43, 44, 1)
k3d.geometry.primitive_selection.append(primitive_selection, 18, 19, 1)
k3d.geometry.primitive_selection.append(primitive_selection, 36, 37, 1)
#python
import k3d
import testing
setup = testing.setup_mesh_modifier_test("PolyGrid", "ExtrudeFaces")
setup.source.rows = 3
setup.source.columns = 3
selection = k3d.geometry.selection.create(0)
face_selection = k3d.geometry.primitive_selection.create(selection, k3d.selection.type.FACE)
k3d.geometry.primitive_selection.append(face_selection, 4, 5, 1)
setup.modifier.mesh_selection = selection
setup.modifier.distance = 5
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.ExtrudeFaces", 2)
#python
import testing
import k3d
setup = testing.setup_mesh_modifier_test("NurbsCircle", "NurbsCurveInsertKnot")
setup.modifier.u_value = 0.1
selection = k3d.geometry.selection.create(0)
curve_selection = k3d.geometry.primitive_selection.create(selection, k3d.selection.type.CURVE)
k3d.geometry.primitive_selection.append(curve_selection, 0, 10000, 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.NurbsCurveInsertKnot", 2, ["Darwin-i386"])
#python
import k3d
import testing
setup = testing.setup_mesh_modifier_test("K3DMeshReader", "SubdivideFaces")
# load a mesh that has multiple polyhedra, triangles, quads, n-sided polygons and holes. (i.e. a mesh from hell)
setup.source.file = k3d.filesystem.generic_path(testing.source_path() + "/meshes/polyhedron.hole.k3d")
setup.source.center = False
setup.source.scale_to_size = False
# select some faces, distributed along polyhedra
selection = k3d.geometry.selection.create(0)
face_selection = k3d.geometry.primitive_selection.create(selection, k3d.selection.type.FACE)
k3d.geometry.primitive_selection.append(face_selection, 0, 6, 0)
k3d.geometry.primitive_selection.append(face_selection, 6, 7, 1)
k3d.geometry.primitive_selection.append(face_selection, 7, 8, 0)
k3d.geometry.primitive_selection.append(face_selection, 8, 9, 1)
k3d.geometry.primitive_selection.append(face_selection, 9, 13, 0)
k3d.geometry.primitive_selection.append(face_selection, 13, 15, 1)
k3d.geometry.primitive_selection.append(face_selection, 15, 16, 0)
k3d.geometry.primitive_selection.append(face_selection, 16, 17, 1)
k3d.geometry.primitive_selection.append(face_selection, 17, 19, 0)
k3d.geometry.primitive_selection.append(face_selection, 19, 20, 1)
k3d.geometry.primitive_selection.append(face_selection, 20, 23, 0)
setup.modifier.mesh_selection = selection
setup.modifier.subdivision_type = "midpoints"
testing.require_valid_mesh(setup.document, setup.modifier.get_property("output_mesh"))
#python
import k3d
import testing
setup = testing.setup_mesh_modifier_test("PolyGrid", "EulerKillEdgeMakeLoop")
setup.source.rows = 3
setup.source.columns = 3
selection = k3d.geometry.selection.create(0)
edge_selection = k3d.geometry.primitive_selection.create(selection, k3d.selection.type.EDGE)
k3d.geometry.primitive_selection.append(edge_selection, 0, 4294967295, 0)
k3d.geometry.primitive_selection.append(edge_selection, 7, 8, 1)
k3d.geometry.primitive_selection.append(edge_selection, 1, 2, 1)
k3d.geometry.primitive_selection.append(edge_selection, 2, 3, 1)
k3d.geometry.primitive_selection.append(edge_selection, 12, 13, 1)
k3d.geometry.primitive_selection.append(edge_selection, 14, 15, 1)
k3d.geometry.primitive_selection.append(edge_selection, 24, 25, 1)
k3d.geometry.primitive_selection.append(edge_selection, 31, 32, 1)
k3d.geometry.primitive_selection.append(edge_selection, 25, 26, 1)
k3d.geometry.primitive_selection.append(edge_selection, 35, 36, 1)
k3d.geometry.primitive_selection.append(edge_selection, 29, 30, 1)
k3d.geometry.primitive_selection.append(edge_selection, 22, 23, 1)
k3d.geometry.primitive_selection.append(edge_selection, 32, 33, 1)
k3d.geometry.primitive_selection.append(edge_selection, 10, 11, 1)
k3d.geometry.primitive_selection.append(edge_selection, 20, 21, 1)
k3d.geometry.primitive_selection.append(edge_selection, 5, 6, 1)
#python
import k3d
import testing
setup = testing.setup_mesh_modifier_test("PolyCube", "SDSCrease")
selection = k3d.geometry.selection.create(0)
edge_selection = k3d.geometry.primitive_selection.create(selection)
edge_selection.primitive_begin().append(0)
edge_selection.primitive_end().append(1)
edge_selection.primitive_selection_type().append(k3d.selection.type.EDGE)
edge_selection.primitive_first_range().append(0)
edge_selection.primitive_range_count().append(1)
edge_selection.index_begin().append(2)
edge_selection.index_end().append(3)
edge_selection.weight().append(1)
setup.modifier.mesh_selection = selection
setup.modifier.sharpness = 2.5
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.SDSCrease", 1)
#python
import k3d
import testing
setup = testing.setup_mesh_modifier_test("PolyGrid", "EulerKillEdgeAndVertex")
selection = k3d.geometry.selection.create(1)
edge_selection = k3d.geometry.primitive_selection.create(selection, k3d.selection.type.EDGE)
k3d.geometry.primitive_selection.append(edge_selection, 0, 4294967295, 0)
k3d.geometry.primitive_selection.append(edge_selection, 49, 50, 1)
k3d.geometry.primitive_selection.append(edge_selection, 55, 56, 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.EulerKillEdgeAndVertex", 1)