How to use the k3d.geometry.selection.create function in k3d

To help you get started, we’ve selected a few k3d examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github K-3D / k3d / tests / mesh / mesh.modifier.NurbsExtractPatchCurve.py View on Github external
#python

import testing
import k3d

setup = testing.setup_mesh_modifier_test("NurbsCylinder","NurbsExtractPatchCurve")

setup.modifier.mesh_selection = k3d.geometry.selection.create(1)
setup.modifier.parameter = 0.5
setup.modifier.extract_v_curve = True

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.NurbsExtractPatchCurve", 2, ["Darwin-i386"])
github K-3D / k3d / tests / mesh / mesh.modifier.CalculateNormals.2.py View on Github external
#python

import k3d
import testing
import math

setup = testing.setup_mesh_modifier_test("PolyCube", "CalculateNormals")
setup.modifier.mesh_selection = k3d.geometry.selection.create(1)
setup.modifier.max_angle = math.radians(91.0)
setup.modifier.face = True
setup.modifier.varying = True
setup.modifier.vertex = True
setup.modifier.face_array = "Nu"
setup.modifier.varying_array = "Nf"
setup.modifier.vertex_array = "Nv"


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.CalculateNormals.2", 1)
github K-3D / k3d / tests / mesh / mesh.modifier.NurbsCurveInsertKnot.py View on Github external
#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"])
github K-3D / k3d / tests / mesh / mesh.modifier.MoveFirstEdge.py View on Github external
#python

import k3d
import testing

setup = testing.setup_mesh_modifier_test("PolyCube", "MoveFirstEdge")

selection = k3d.geometry.selection.create(0)
face_selection = k3d.geometry.primitive_selection.create(selection)
face_selection.primitive_begin().append(0)
face_selection.primitive_end().append(1)
face_selection.primitive_selection_type().append(k3d.selection.type.FACE)
face_selection.primitive_first_range().append(0)
face_selection.primitive_range_count().append(1)
face_selection.index_begin().append(0)
face_selection.index_end().append(3)
face_selection.weight().append(1)

setup.modifier.mesh_selection = selection
setup.modifier.distance = 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.MoveFirstEdge", 1)
github K-3D / k3d / tests / mesh / mesh.modifier.SubdivideFaces.Midpoints.py View on Github external
#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"
github K-3D / k3d / tests / mesh / mesh.selection.all.py View on Github external
#python

import k3d
import testing

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

setup.source.rows = 1
setup.source.columns = 1

mesh_selection = k3d.geometry.selection.create(1.0)
setup.modifier.mesh_selection = mesh_selection
setup.modifier.x = 2

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.all", 1)
github K-3D / k3d / tests / mesh / mesh.modifier.NurbsCloseCurve1.py View on Github external
#python

import testing
import k3d

setup = testing.setup_mesh_modifier_test("NurbsCurve", "NurbsCloseCurve")

setup.modifier.keep_ends = True

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.NurbsCloseCurve1", 1)
github K-3D / k3d / tests / mesh / mesh.modifier.NurbsCreateCap.py View on Github external
#python

import testing
import k3d

setup = testing.setup_mesh_modifier_test("NurbsCircle","NurbsCreateCap")

setup.modifier.mesh_selection = k3d.geometry.selection.create(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.NurbsCreateCap", 1, ["Darwin-i386"])
github K-3D / k3d / tests / mesh.diff.MeshDiff.SubdivideEdges.py View on Github external
import k3d

doc = k3d.new_document()

memory_pools = k3d.plugin.create("MemoryPools")
memory_pools.execute_command("shuffle", "4000 points")
memory_pools.execute_command("shuffle", "4000 split_edges")
memory_pools.execute_command("shuffle", "4000 faces")

diff = doc.new_node("MeshDiff")

for i in range(100):
	cube = doc.new_node("PolyCube")

	subdivide_edges = doc.new_node("SubdivideEdges")
	selection = k3d.geometry.selection.create(0)
	selection.edges = [(0, 4, 1), (4, 1000, 0)]
	subdivide_edges.mesh_selection = selection

	diff_input = diff.create_property("k3d::mesh*", "input_" + str(i), "Input " + str(i), "Input mesh " + str(i))

	doc.set_dependency(subdivide_edges.get_property("input_mesh"), cube.get_property("output_mesh"));
	doc.set_dependency(diff_input, subdivide_edges.get_property("output_mesh"));

if not diff.equal:
	raise Exception("Input meshes differ")
github K-3D / k3d / tests / mesh / mesh.modifier.TriangulateFaces.self_intersection.py View on Github external
polyhedron.shell_types().append(k3d.polyhedron.shell_type.POLYGONS)
polyhedron.face_shells().append(0)
polyhedron.face_first_loops().append(0)
polyhedron.face_loop_counts().append(1)
polyhedron.face_materials().append(None)
polyhedron.face_selections().append(0.0)
polyhedron.loop_first_edges().append(0)
polyhedron.clockwise_edges().assign([1, 2, 3, 0])
polyhedron.edge_selections().assign([0, 0, 0, 0])
polyhedron.vertex_points().assign([0, 1, 2, 3])
polyhedron.vertex_selections().assign([0, 0, 0, 0])

Cs = polyhedron.vertex_attributes().create("Cs", "k3d::color")
Cs.assign([k3d.color(1, 0, 0), k3d.color(0, 1, 0), k3d.color(0, 0, 1), k3d.color(1, 1, 1)])

mesh_selection = k3d.geometry.selection.create(1)
setup.modifier.mesh_selection = mesh_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.TriangulateFaces.self_intersection", 0)