Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#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)
#python
import k3d
import testing
script_path = k3d.share_path() / k3d.filesystem.generic_path("scripts/MeshSourceScript/paraboloids.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.paraboloids", 2)
#python
import k3d
import testing
script_path = k3d.share_path() / k3d.filesystem.generic_path("scripts/MeshSourceScript/spheres.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.spheres", 2)
#python
import k3d
import testing
setup = testing.setup_bitmap_modifier_test("BitmapReader", "BitmapGamma")
setup.source.file = k3d.filesystem.generic_path(testing.source_path() + "/bitmaps/" + "test_rgb_8.png")
setup.modifier.gamma = 2.2
testing.require_similar_bitmap(setup.document, setup.modifier.get_property("output_bitmap"), "BitmapGamma", 0)
#python
import k3d
import testing
script_path = k3d.share_path() / k3d.filesystem.generic_path("scripts/MeshSourceScript/bilinear_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.bilinear.patches", 2)
#python
import k3d
import testing
setup = testing.setup_mesh_modifier_test("K3DMeshReader", "CUDASubdivideEdges")
setup.source.file = k3d.filesystem.generic_path(testing.source_path() + "/meshes/polyhedron.k3d")
# select some edges, distributed along polyhedra
selection = k3d.geometry.selection.create(0)
selection.edges =[(0, 4294967295, 0), (0, 1, 1), (1, 2, 1), (2, 3, 1), (3, 4, 1), (52, 53, 1), (53, 54, 1), (54, 55, 1), (55, 56, 1), (56, 57, 1), (57, 58, 1), (58, 59, 1), (59, 60, 1), (60, 61, 1), (61, 62, 1), (62, 63, 1), (63, 64, 1), (64, 65, 1), (74, 75, 1), (75, 76, 1), (76, 77, 1), (77, 78, 1), (78, 79, 1), (79, 80, 1), (80, 81, 1), (81, 82, 1)]
setup.modifier.mesh_selection = selection
setup.modifier.vertices = 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.modifier.SubdivideEdges", 1)
#python
import k3d
import testing
import copy
source_file = "papagayo_example.dat"
setup = testing.setup_scalar_source_test("PapagayoLipsyncReader")
setup.source.frame_rate = 30
setup.source.interpolate = True
setup.source.interpolation_time = 0.2
setup.source.papagayo_file = k3d.filesystem.generic_path(testing.source_path() + "/lipsync/" + source_file)
test_cases = \
[
[0.0,{"rest":1.0}],
[1.98,{"E":0.24000000000000021,"etc":0.75999999999999979}],
[2.0,{"E":0.5,"etc":0.5}],
[4.34,{"E":0.69999999999999463,"MBP":0.30000000000000537}],
]
mouths = ["AI","E","etc","FV","L","MBP","O","rest","U","WQ"]
for test_case in test_cases:
setup.source.time = test_case[0]
source_mouth_value = 0.0
mouths_in_zero = copy.deepcopy(mouths)
for mouth,reference_value in test_case[1].iteritems():
#python
import k3d
import glob
import os
import testing
scalable_icons = []
for icon in glob.glob(str(k3d.share_path() / k3d.filesystem.generic_path("ngui/scalable/*.svg"))):
scalable_icons.append(os.path.splitext(os.path.basename(icon))[0])
rasterized_icons = []
for icon in glob.glob(str(k3d.share_path() / k3d.filesystem.generic_path("ngui/rasterized/*.png"))):
rasterized_icons.append(os.path.splitext(os.path.basename(icon))[0])
scalable_icons.sort()
rasterized_icons.sort()
unrasterized = []
for icon in scalable_icons:
if icon not in rasterized_icons:
unrasterized.append(icon)
if len(unrasterized):
print "\nScalable icons without corresponding rasterized icons:\n"
import k3d
factories = k3d.plugin.factory.lookup()
for factory in factories :
if factory.is_application_plugin() and ("DocumentImporter" in factory.name()):
print "\n\nTesting " + factory.name() + " with a file containing all zeroes ..."
path = k3d.filesystem.generic_path(testing.source_path() + "/meshes/" + "zero_bytes")
document = k3d.new_document()
document_importer = k3d.plugin.create(factory.name())
document_importer.read_file(path, document)
k3d.close_document(document)
print "\n\nTesting " + factory.name() + " with a file containing random data ..."
path = k3d.filesystem.generic_path(testing.source_path() + "/meshes/" + "random_bytes")
document = k3d.new_document()
document_importer = k3d.plugin.create(factory.name())
document_importer.read_file(path, document)
k3d.close_document(document)
p3 += vsnoise(p3)
control_points.append(p1)
control_points.append(p2)
control_points.append(p3)
control_points.append(p4)
widths.append(0.08)
widths.append(0.01)
RiSurface("k3d_hair")
RiCurves(RI_CUBIC, control_point_counts, RI_NONPERIODIC, "P", control_points, "width", widths)
ri._ribout.flush()
context.render_state.use_shader(k3d.share_path() / k3d.filesystem.generic_path("shaders/surface/k3d_hair.sl"))