Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup_mesh_test(nodes):
if len(nodes) < 1:
raise Exception("Mesh test requires at least one node.")
class result_object:
pass
result = result_object
result.document = k3d.new_document()
result.nodes = []
for node in nodes:
result.nodes.append(k3d.plugin.create(node, result.document))
if len(result.nodes) > 1:
k3d.property.connect(result.document, result.nodes[-2].get_property("output_mesh"), result.nodes[-1].get_property("input_mesh"))
result.source = result.nodes[0]
if len(nodes) == 3:
result.modifier = result.nodes[1]
if len(nodes) > 1:
result.sink = result.nodes[-1]
return result
import k3d
import testing
document = k3d.new_document()
source1 = k3d.plugin.create("BlobbyEllipsoid", document)
source1.color = k3d.color(1, 0, 0)
source2 = k3d.plugin.create("BlobbySegment", document)
source2.color = k3d.color(1, 1, 0)
modifier = k3d.plugin.create("BlobbySubtract", document)
k3d.property.connect(document, source1.get_property("output_mesh"), modifier.get_property("input_a"))
k3d.property.connect(document, source2.get_property("output_mesh"), modifier.get_property("input_b"))
testing.require_valid_mesh(document, modifier.get_property("output_mesh"))
testing.require_similar_mesh(document, modifier.get_property("output_mesh"), "mesh.modifier.BlobbySubtract", 5)
import testing
document = k3d.new_document()
source1 = k3d.plugin.create("BlobbyEllipsoid", document)
source1.color = k3d.color(1, 0, 0)
source2 = k3d.plugin.create("BlobbySegment", document)
source2.color = k3d.color(1, 1, 0)
modifier = k3d.plugin.create("BlobbyMultiply", document)
modifier.create_property("k3d::mesh*", "input_mesh1", "Input Mesh 1", "")
modifier.create_property("k3d::mesh*", "input_mesh2", "Input Mesh 2", "")
k3d.property.connect(document, source1.get_property("output_mesh"), modifier.get_property("input_mesh1"))
k3d.property.connect(document, source2.get_property("output_mesh"), modifier.get_property("input_mesh2"))
testing.require_valid_mesh(document, modifier.get_property("output_mesh"))
testing.require_similar_mesh(document, modifier.get_property("output_mesh"), "mesh.modifier.BlobbyMultiply", 5)
import k3d
import testing
document = k3d.new_document()
source1 = k3d.plugin.create("PolyCone", document)
source2 = k3d.plugin.create("PolySphere", document)
source3 = k3d.plugin.create("PolyCube", document)
modifier = k3d.plugin.create("MorphPoints", document)
modifier.create_property("k3d::mesh*", "input1", "input1", "input1")
modifier.create_property("k3d::mesh*", "input2", "input2", "input2")
modifier.create_property("k3d::double_t", "amount1", "amount1", "amount1")
modifier.create_property("k3d::double_t", "amount2", "amount2", "amount2")
k3d.property.connect(document, source1.get_property("output_mesh"), modifier.get_property("input_mesh"))
k3d.property.connect(document, source2.get_property("output_mesh"), modifier.get_property("input1"))
k3d.property.connect(document, source3.get_property("output_mesh"), modifier.get_property("input2"))
selection = k3d.geometry.selection.create(0)
point_selection = k3d.geometry.point_selection.create(selection, 1)
modifier.mesh_selection = selection
modifier.amount1 = 0.1
modifier.amount2 = 0.1
testing.require_valid_mesh(document, modifier.get_property("output_mesh"))
testing.require_similar_mesh(document, modifier.get_property("output_mesh"), "mesh.modifier.MorphPoints", 4)
document = k3d.new_document()
source1 = k3d.plugin.create("PolyCone", document)
source2 = k3d.plugin.create("PolySphere", document)
source3 = k3d.plugin.create("PolyCube", document)
modifier = k3d.plugin.create("MorphPoints", document)
modifier.create_property("k3d::mesh*", "input1", "input1", "input1")
modifier.create_property("k3d::mesh*", "input2", "input2", "input2")
modifier.create_property("k3d::double_t", "amount1", "amount1", "amount1")
modifier.create_property("k3d::double_t", "amount2", "amount2", "amount2")
k3d.property.connect(document, source1.get_property("output_mesh"), modifier.get_property("input_mesh"))
k3d.property.connect(document, source2.get_property("output_mesh"), modifier.get_property("input1"))
k3d.property.connect(document, source3.get_property("output_mesh"), modifier.get_property("input2"))
selection = k3d.geometry.selection.create(0)
point_selection = k3d.geometry.point_selection.create(selection, 1)
modifier.mesh_selection = selection
modifier.amount1 = 0.1
modifier.amount2 = 0.1
testing.require_valid_mesh(document, modifier.get_property("output_mesh"))
testing.require_similar_mesh(document, modifier.get_property("output_mesh"), "mesh.modifier.MorphPoints", 4)
import testing
document = k3d.new_document()
source1 = k3d.plugin.create("BlobbyEllipsoid", document)
source1.color = k3d.color(1, 0, 0)
source2 = k3d.plugin.create("BlobbySegment", document)
source2.color = k3d.color(1, 1, 0)
modifier = k3d.plugin.create("BlobbyMinimum", document)
modifier.create_property("k3d::mesh*", "input_mesh1", "Input Mesh 1", "")
modifier.create_property("k3d::mesh*", "input_mesh2", "Input Mesh 2", "")
k3d.property.connect(document, source1.get_property("output_mesh"), modifier.get_property("input_mesh1"))
k3d.property.connect(document, source2.get_property("output_mesh"), modifier.get_property("input_mesh2"))
testing.require_valid_mesh(document, modifier.get_property("output_mesh"))
testing.require_similar_mesh(document, modifier.get_property("output_mesh"), "mesh.modifier.BlobbyMinimum", 5)
modifier = k3d.plugin.create("MergeMesh", document)
k3d.property.create(modifier, "k3d::mesh*", "input_mesh1", "Input Mesh 1", "")
k3d.property.create(modifier, "k3d::mesh*", "input_mesh2", "Input Mesh 2", "")
k3d.property.create(modifier, "k3d::mesh*", "input_mesh3", "Input Mesh 3", "")
k3d.property.create(modifier, "k3d::mesh*", "input_mesh4", "Input Mesh 4", "")
k3d.property.create(modifier, "k3d::mesh*", "input_mesh5", "Input Mesh 5", "")
k3d.property.create(modifier, "k3d::mesh*", "input_mesh6", "Input Mesh 6", "")
k3d.property.create(modifier, "k3d::mesh*", "input_mesh7", "Input Mesh 7", "")
k3d.property.create(modifier, "k3d::mesh*", "input_mesh8", "Input Mesh 8", "")
k3d.property.create(modifier, "k3d::mesh*", "input_mesh9", "Input Mesh 9", "")
k3d.property.connect(document, source1.get_property("output_mesh"), modifier.get_property("input_mesh1"))
k3d.property.connect(document, source2.get_property("output_mesh"), modifier.get_property("input_mesh2"))
k3d.property.connect(document, source3.get_property("output_mesh"), modifier.get_property("input_mesh3"))
k3d.property.connect(document, source4.get_property("output_mesh"), modifier.get_property("input_mesh4"))
k3d.property.connect(document, source5.get_property("output_mesh"), modifier.get_property("input_mesh5"))
k3d.property.connect(document, source6.get_property("output_mesh"), modifier.get_property("input_mesh6"))
k3d.property.connect(document, source7.get_property("output_mesh"), modifier.get_property("input_mesh7"))
k3d.property.connect(document, source8.get_property("output_mesh"), modifier.get_property("input_mesh8"))
k3d.property.connect(document, source9.get_property("output_mesh"), modifier.get_property("input_mesh9"))
testing.require_valid_mesh(document, modifier.get_property("output_mesh"))
testing.require_similar_mesh(document, modifier.get_property("output_mesh"), "mesh.modifier.MergeMesh", 32, ["Darwin-i386"])
def create_camera(document):
camera_view = k3d.plugin.create("ViewMatrix", document)
camera_view.position = k3d.translate3(k3d.vector3(-10, -15, 10))
camera_view.look = k3d.identity3()
camera_view.up = k3d.translate3(k3d.vector3(0, 0, 20))
camera = k3d.plugin.create("Camera", document)
k3d.property.connect(document, camera_view.get_property("output_matrix"), camera.get_property("input_matrix"))
return camera
grid = k3d.plugin.create("PolyGrid"), document;
grid.columns = 1
grid.rows = 1
modifier = k3d.plugin.create("SubdivideEdges", document)
cuda_modifier = k3d.plugin.create("CUDASubdivideEdges", document)
modifier.mesh_selection = k3d.geometry.selection.create(1)
modifier.vertices = 1
cuda_modifier.mesh_selection = modifier.mesh_selection
cuda_modifier.vertices = 1
k3d.property.connect(document, grid.get_property("output_mesh"), modifier.get_property("input_mesh"))
k3d.property.connect(document, grid.get_property("output_mesh"), cuda_modifier.get_property("input_mesh"))
testing.output_mesh_difference(cuda_modifier.output_mesh, modifier.output_mesh, 1)
difference = testing.get_mesh_difference(document, cuda_modifier.get_property("output_mesh"), modifier.get_property("output_mesh"), 1)
if not difference.equal:
raise "Meshes not equal"
#python
import k3d
import testing
document = k3d.new_document()
source1 = k3d.plugin.create("BlobbyEllipsoid", document)
source1.color = k3d.color(1, 0, 0)
modifier = k3d.plugin.create("BlobbyNegate", document)
k3d.property.connect(document, source1.get_property("output_mesh"), modifier.get_property("input_mesh"))
testing.require_valid_mesh(document, modifier.get_property("output_mesh"))
testing.require_similar_mesh(document, modifier.get_property("output_mesh"), "mesh.modifier.BlobbyNegate", 5)