Example #1
0
	type = array_types[i]
	value = array_values[i]

	named_array = primitive.structure().create(type, type)
	named_array.append(value)
	named_array.append(value)

	attribute_array = attributes.create(type, type)
	attribute_array.append(value)
	attribute_array.append(value)
	attribute_array.append(value)

print repr(mesh)
sys.stdout.flush()

mesh_writer = document.new_node("K3DMeshWriter")
mesh_writer.file = k3d.filesystem.generic_path(testing.binary_path() + "/mesh.serialization.output.k3d")
document.set_dependency(mesh_writer.get_property("input_mesh"), source.get_property("output_mesh"))

mesh_reader = document.new_node("K3DMeshReader")
mesh_reader.file = mesh_writer.file

print repr(mesh_reader.output_mesh)
sys.stdout.flush()

difference = testing.get_mesh_difference(document, source.get_property("output_mesh"), mesh_reader.get_property("output_mesh"), 0)
if not difference.equal:
	testing.output_mesh_difference(source.output_mesh, mesh_reader.output_mesh, 0)
	raise Exception("serialized mesh differs from reference")

#python

import k3d
import testing

receiver = k3d.file_change_receiver()
notifier = k3d.plugin.create("InotifyFileChangeNotifier")

path = k3d.filesystem.generic_path(testing.binary_path() + "/" +
                                   "notifier.InotifyFileChangeNotifier.test")

f = file(str(path), "w")
f.write("Howdy, ")
f.close()

id1 = notifier.watch_file(path, receiver)
if not id1:
    raise Exception("couldn't create 1st watch")

id2 = notifier.watch_file(path, receiver)
if not id2:
    raise Exception("couldn't create 2nd watch")

notifier.unwatch_file(id1)
notifier.unwatch_file(id2)

id3 = notifier.watch_file(path, receiver)
if not id3:
    raise Exception("couldn't create 3rd watch")

f = file(str(path), "w")
#python

import k3d
import testing

receiver = k3d.file_change_receiver()
notifier = k3d.plugin.create("InotifyFileChangeNotifier")

path = k3d.filesystem.generic_path(testing.binary_path() + "/" + "notifier.InotifyFileChangeNotifier.test")

f = file(str(path), "w")
f.write("Howdy, ")
f.close()

id1 = notifier.watch_file(path, receiver)
if not id1:
	raise Exception("couldn't create 1st watch")

id2 = notifier.watch_file(path, receiver)
if not id2:
	raise Exception("couldn't create 2nd watch")

notifier.unwatch_file(id1)
notifier.unwatch_file(id2)

id3 = notifier.watch_file(path, receiver)
if not id3:
	raise Exception("couldn't create 3rd watch")

f = file(str(path), "w")
f.write("World!\n")
Example #4
0
#python

import k3d
import testing

target_file = "mesh.sink.IGESMeshWriter.iges"

setup = testing.setup_mesh_test(["NurbsCylinder", "IGESMeshWriter"])
setup.sink.file = k3d.filesystem.generic_path(testing.binary_path() +
                                              "/meshes/" + target_file)
create_property(test_container, "k3d::double_t", 3.1415)
create_property(test_container, "k3d::filesystem::path", k3d.filesystem.generic_path("/foo/bar/baz"))
create_property(test_container, "k3d::gl::imesh_painter*", test_gl_mesh_painter)
create_property(test_container, "k3d::imaterial*", test_material)
create_property(test_container, "k3d::inode*", test_node)
create_property(test_container, "k3d::int32_t", 19700827)
create_property(test_container, "k3d::matrix4", k3d.scale3(1, 2, 3))
create_property(test_container, "k3d::normal3", k3d.normal3(1, 2, 3))
create_property(test_container, "k3d::point3", k3d.point3(1, 2, 3))
create_property(test_container, "k3d::point4", k3d.point4(1, 2, 3, 4))
create_property(test_container, "k3d::ri::imesh_painter*", test_ri_mesh_painter)
create_property(test_container, "k3d::ri::itexture*", test_ri_texture)
create_property(test_container, "k3d::string_t", "K-3D Rocks!")
create_property(test_container, "k3d::vector3", k3d.vector3(1, 2, 3))

path = testing.binary_path() + "/document.serialization.properties.output.k3d"
document.save(path)

def test_property(value, expected_value):
	if value != expected_value:
		raise "property value doesn't match: ", value, expected_value

document2 = k3d.open_document(k3d.filesystem.native_path(path))
test_container2 = k3d.node.lookup_one(document, "test_container")

test_property(test_container2.get_property("k3d::bool_t").internal_value(), True)
test_property(test_container2.get_property("k3d::color").internal_value(), k3d.color(1, 2, 3))
test_property(test_container2.get_property("k3d::double_t").internal_value(), 3.1415)
test_property(test_container2.get_property("k3d::filesystem::path").internal_value(), k3d.filesystem.generic_path("/foo/bar/baz"))
test_property(test_container2.get_property("k3d::gl::imesh_painter*").internal_value().name, "test_gl_mesh_painter")
test_property(test_container2.get_property("k3d::imaterial*").internal_value().name, "test_material")
#python

import k3d
import testing

target_file = "mesh.sink.GmshGeoMeshWriter.geo"

setup = testing.setup_mesh_test(["PolyCube", "GmshGeoMeshWriter"])
setup.sink.file = k3d.filesystem.generic_path(testing.binary_path() + "/meshes/" + target_file)

Example #7
0
create_property(test_container, "k3d::gl::imesh_painter*",
                test_gl_mesh_painter)
create_property(test_container, "k3d::imaterial*", test_material)
create_property(test_container, "k3d::inode*", test_node)
create_property(test_container, "k3d::int32_t", 19700827)
create_property(test_container, "k3d::matrix4", k3d.scale3(1, 2, 3))
create_property(test_container, "k3d::normal3", k3d.normal3(1, 2, 3))
create_property(test_container, "k3d::point3", k3d.point3(1, 2, 3))
create_property(test_container, "k3d::point4", k3d.point4(1, 2, 3, 4))
create_property(test_container, "k3d::ri::imesh_painter*",
                test_ri_mesh_painter)
create_property(test_container, "k3d::ri::itexture*", test_ri_texture)
create_property(test_container, "k3d::string_t", "K-3D Rocks!")
create_property(test_container, "k3d::vector3", k3d.vector3(1, 2, 3))

path = testing.binary_path() + "/document.serialization.properties.output.k3d"
document.save(path)


def test_property(value, expected_value):
    if value != expected_value:
        raise "property value doesn't match: ", value, expected_value


document2 = k3d.open_document(path)
test_container2 = document.get_node("test_container")

test_property(
    test_container2.get_property("k3d::bool_t").internal_value(), True)
test_property(
    test_container2.get_property("k3d::color").internal_value(),
Example #8
0
#python

import k3d
import testing

doc = k3d.new_document()

# We will be writing a temporary file ...
file = k3d.filesystem.generic_path(testing.binary_path() + "/mesh.sink.K3DMeshWriter.k3d")

# Create a simple polyhedron source ...
source = doc.new_node("PolyCube")

# Write the geometry to a temporary file ...
writer = doc.new_node("K3DMeshWriter")
writer.file = file
doc.set_dependency(writer.get_property("input_mesh"), source.get_property("output_mesh"))

# Read the geometry back in ...
reader = doc.new_node("K3DMeshReader")
reader.file = file
reader.center = False
reader.scale_to_size = False

# Compare the original to the imported data ...
diff = doc.new_node("MeshDiff")
diff.create_property("k3d::mesh*", "input_a", "InputA", "First input mesh")
diff.create_property("k3d::mesh*", "input_b", "InputB", "Second input mesh")

doc.set_dependency(diff.get_property("input_a"), source.get_property("output_mesh"))
doc.set_dependency(diff.get_property("input_b"), reader.get_property("output_mesh"))
Example #9
0
#python

import k3d
import testing

doc = k3d.new_document()

# We will be writing a temporary file ...
file = k3d.filesystem.generic_path(testing.binary_path() + "/mesh.sink.OBJMeshWriter.obj")

# Create a simple polyhedron source ...
source = doc.new_node("PolyCube")

# Write the geometry to a temporary file ...
writer = doc.new_node("OBJMeshWriter")
writer.file = file
doc.set_dependency(writer.get_property("input_mesh"), source.get_property("output_mesh"))

# Read the geometry back in ...
reader = doc.new_node("OBJMeshReader")
reader.file = file
reader.center = False
reader.scale_to_size = False

# Compare the original to the imported data ...

diff = doc.new_node("MeshDiff")
diff.create_property("k3d::mesh*", "input_a", "InputA", "First input mesh")
diff.create_property("k3d::mesh*", "input_b", "InputB", "Second input mesh")

doc.set_dependency(diff.get_property("input_a"), source.get_property("output_mesh"))