Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bindings/python/image_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
import opengeode

from opengeode_io_py_image import *
IOImageLibrary.initialize()

OpenGeodeIOImageLibrary.initialize()
3 changes: 2 additions & 1 deletion bindings/python/mesh_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
import opengeode

from opengeode_io_py_mesh import *
IOMeshLibrary.initialize()

OpenGeodeIOMeshLibrary.initialize()
3 changes: 2 additions & 1 deletion bindings/python/model_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
import opengeode

from opengeode_io_py_model import *
IOModelLibrary.initialize()

OpenGeodeIOModelLibrary.initialize()
5 changes: 3 additions & 2 deletions bindings/python/src/image_io/image_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
PYBIND11_MODULE( opengeode_io_py_image, module )
{
module.doc() = "OpenGeode-IO Python binding for image";
pybind11::class_< geode::IOImageLibrary >( module, "IOImageLibrary" )
.def( "initialize", &geode::IOImageLibrary::initialize );
pybind11::class_< geode::OpenGeodeIOImageLibrary >(
module, "OpenGeodeIOImageLibrary" )
.def( "initialize", &geode::OpenGeodeIOImageLibrary::initialize );
}
5 changes: 3 additions & 2 deletions bindings/python/src/mesh_io/mesh_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
PYBIND11_MODULE( opengeode_io_py_mesh, module )
{
module.doc() = "OpenGeode-IO Python binding for mesh";
pybind11::class_< geode::IOMeshLibrary >( module, "IOMeshLibrary" )
.def( "initialize", &geode::IOMeshLibrary::initialize );
pybind11::class_< geode::OpenGeodeIOMeshLibrary >(
module, "OpenGeodeIOMeshLibrary" )
.def( "initialize", &geode::OpenGeodeIOMeshLibrary::initialize );
}
5 changes: 3 additions & 2 deletions bindings/python/src/model_io/model_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
PYBIND11_MODULE( opengeode_io_py_model, module )
{
module.doc() = "OpenGeode-IO Python binding for model";
pybind11::class_< geode::IOModelLibrary >( module, "IOModelLibrary" )
.def( "initialize", &geode::IOModelLibrary::initialize );
pybind11::class_< geode::OpenGeodeIOModelLibrary >(
module, "OpenGeodeIOModelLibrary" )
.def( "initialize", &geode::OpenGeodeIOModelLibrary::initialize );
}
19 changes: 10 additions & 9 deletions bindings/python/tests/mesh_io/test-py-obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,27 @@
import os
import sys
import platform

if sys.version_info >= (3, 8, 0) and platform.system() == "Windows":
for path in [x.strip() for x in os.environ['PATH'].split(';') if x]:
for path in [x.strip() for x in os.environ["PATH"].split(";") if x]:
os.add_dll_directory(path)

import opengeode
import opengeode_io_py_mesh as mesh_io

if __name__ == '__main__':
mesh_io.IOMeshLibrary.initialize()
if __name__ == "__main__":
mesh_io.OpenGeodeIOMeshLibrary.initialize()
test_dir = os.path.dirname(__file__)
data_dir = os.path.abspath(os.path.join(
test_dir, "../../../../tests/data"))
data_dir = os.path.abspath(os.path.join(test_dir, "../../../../tests/data"))

surface = opengeode.load_polygonal_surface3D(
os.path.join(data_dir, "TopHat.obj"))
surface = opengeode.load_polygonal_surface3D(os.path.join(data_dir, "TopHat.obj"))
if surface.nb_vertices() != 363:
raise ValueError(
"[Test] Number of vertices in the loaded Surface is not correct")
"[Test] Number of vertices in the loaded Surface is not correct"
)
if surface.nb_polygons() != 380:
raise ValueError(
"[Test] Number of polygons in the loaded Surface is not correct")
"[Test] Number of polygons in the loaded Surface is not correct"
)

opengeode.save_polygonal_surface3D(surface, "TopHat_save.obj")
19 changes: 11 additions & 8 deletions bindings/python/tests/mesh_io/test-py-ply.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,29 @@
import os
import sys
import platform

if sys.version_info >= (3, 8, 0) and platform.system() == "Windows":
for path in [x.strip() for x in os.environ['PATH'].split(';') if x]:
for path in [x.strip() for x in os.environ["PATH"].split(";") if x]:
os.add_dll_directory(path)

import opengeode
import opengeode_io_py_mesh as mesh_io

if __name__ == '__main__':
mesh_io.IOMeshLibrary.initialize()
if __name__ == "__main__":
mesh_io.OpenGeodeIOMeshLibrary.initialize()

test_dir = os.path.dirname(__file__)
data_dir = os.path.abspath(os.path.join(
test_dir, "../../../../tests/data"))
data_dir = os.path.abspath(os.path.join(test_dir, "../../../../tests/data"))
surface = opengeode.load_polygonal_surface3D(
os.path.join(data_dir, "Armadillo.ply"))
os.path.join(data_dir, "Armadillo.ply")
)
if surface.nb_vertices() != 172974:
raise ValueError(
"[Test] Number of vertices in the loaded Surface is not correct")
"[Test] Number of vertices in the loaded Surface is not correct"
)
if surface.nb_polygons() != 345944:
raise ValueError(
"[Test] Number of polygons in the loaded Surface is not correct")
"[Test] Number of polygons in the loaded Surface is not correct"
)

opengeode.save_polygonal_surface3D(surface, "Armadillo_save.ply")
19 changes: 11 additions & 8 deletions bindings/python/tests/mesh_io/test-py-stl.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,29 @@
import os
import sys
import platform

if sys.version_info >= (3, 8, 0) and platform.system() == "Windows":
for path in [x.strip() for x in os.environ['PATH'].split(';') if x]:
for path in [x.strip() for x in os.environ["PATH"].split(";") if x]:
os.add_dll_directory(path)

import opengeode
import opengeode_io_py_mesh as mesh_io

if __name__ == '__main__':
mesh_io.IOMeshLibrary.initialize()
if __name__ == "__main__":
mesh_io.OpenGeodeIOMeshLibrary.initialize()

test_dir = os.path.dirname(__file__)
data_dir = os.path.abspath(os.path.join(
test_dir, "../../../../tests/data"))
data_dir = os.path.abspath(os.path.join(test_dir, "../../../../tests/data"))
surface = opengeode.load_triangulated_surface3D(
os.path.join(data_dir, "thumbwheel.stl"))
os.path.join(data_dir, "thumbwheel.stl")
)
if surface.nb_vertices() != 525:
raise ValueError(
"[Test] Number of vertices in the loaded Surface is not correct")
"[Test] Number of vertices in the loaded Surface is not correct"
)
if surface.nb_polygons() != 1027:
raise ValueError(
"[Test] Number of polygons in the loaded Surface is not correct")
"[Test] Number of polygons in the loaded Surface is not correct"
)

opengeode.save_triangulated_surface3D(surface, "thumbwheel_save.stl")
25 changes: 14 additions & 11 deletions bindings/python/tests/mesh_io/test-py-vtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import os
import sys
import platform

if sys.version_info >= (3, 8, 0) and platform.system() == "Windows":
for path in [x.strip() for x in os.environ['PATH'].split(';') if x]:
for path in [x.strip() for x in os.environ["PATH"].split(";") if x]:
os.add_dll_directory(path)

import opengeode
Expand All @@ -33,27 +34,29 @@
def check(surface, nb_vertices, nb_polygons):
if surface.nb_vertices() != nb_vertices:
raise ValueError(
"[Test] Number of vertices in the loaded Surface is not correct")
"[Test] Number of vertices in the loaded Surface is not correct"
)
if surface.nb_polygons() != nb_polygons:
raise ValueError(
"[Test] Number of polygons in the loaded Surface is not correct")
"[Test] Number of polygons in the loaded Surface is not correct"
)


def run_test(filename, nb_vertices, nb_polygons):
test_dir = os.path.dirname(__file__)
data_dir = os.path.abspath(os.path.join(
test_dir, "../../../../tests/data"))
data_dir = os.path.abspath(os.path.join(test_dir, "../../../../tests/data"))
surface = opengeode.load_polygonal_surface3D(
os.path.join(data_dir, filename + ".vtp"))
os.path.join(data_dir, filename + ".vtp")
)
check(surface, nb_vertices, nb_polygons)
opengeode.save_polygonal_surface3D(
surface, os.path.join(filename + ".og_psf3d"))
opengeode.save_polygonal_surface3D(surface, os.path.join(filename + ".og_psf3d"))
reloaded_surface = opengeode.load_polygonal_surface3D(
os.path.join(filename + ".og_psf3d"))
os.path.join(filename + ".og_psf3d")
)
check(surface, nb_vertices, nb_polygons)


if __name__ == '__main__':
mesh_io.IOMeshLibrary.initialize()
if __name__ == "__main__":
mesh_io.OpenGeodeIOMeshLibrary.initialize()
run_test("dfn1_ascii", 187, 10)
run_test("dfn2_mesh_compressed", 33413, 58820)
55 changes: 20 additions & 35 deletions bindings/python/tests/model_io/test-py-msh.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import os
import sys
import platform

if sys.version_info >= (3, 8, 0) and platform.system() == "Windows":
for path in [x.strip() for x in os.environ['PATH'].split(';') if x]:
for path in [x.strip() for x in os.environ["PATH"].split(";") if x]:
os.add_dll_directory(path)

import opengeode
Expand All @@ -44,27 +45,22 @@ def test_brep_cube(brep):
# Number of vertices and elements in components
for c in brep.corners():
if c.mesh().nb_vertices() != 1:
raise ValueError(
"[Test] Number of vertices in corners should be 1")
raise ValueError("[Test] Number of vertices in corners should be 1")
for l in brep.lines():
if l.mesh().nb_vertices() != 5:
raise ValueError("[Test] Number of vertices in lines should be 5")
if l.mesh().nb_edges() != 4:
raise ValueError("[Test] Number of edges in lines should be 4")
for s in brep.surfaces():
if s.mesh().nb_vertices() != 29:
raise ValueError(
"[Test] Number of vertices in surfaces should be 29")
raise ValueError("[Test] Number of vertices in surfaces should be 29")
if s.mesh().nb_polygons() != 40:
raise ValueError(
"[Test] Number of polygons in surfaces should be 40")
raise ValueError("[Test] Number of polygons in surfaces should be 40")
for b in brep.blocks():
if b.mesh().nb_vertices() != 131:
raise ValueError(
"[Test] Number of vertices in blocks should be 131")
raise ValueError("[Test] Number of vertices in blocks should be 131")
if b.mesh().nb_polyhedra() != 364:
raise ValueError(
"[Test] Number of polyhedra in blocks should be 364")
raise ValueError("[Test] Number of polyhedra in blocks should be 364")

# Number of component boundaries and incidences
for c in brep.corners():
Expand Down Expand Up @@ -103,61 +99,50 @@ def test_brep_cone(brep):
# Number of vertices and elements in components
for c in brep.corners():
if c.mesh().nb_vertices() != 1:
raise ValueError(
"[Test] Number of vertices in corners should be 1")
raise ValueError("[Test] Number of vertices in corners should be 1")
for l in brep.lines():
if l.mesh().nb_vertices() == 0:
raise ValueError(
"[Test] Number of vertices in lines should not be null")
raise ValueError("[Test] Number of vertices in lines should not be null")
if l.mesh().nb_edges() == 0:
raise ValueError(
"[Test] Number of edges in lines should not be null")
raise ValueError("[Test] Number of edges in lines should not be null")
for s in brep.surfaces():
if s.mesh().nb_vertices() == 0:
raise ValueError(
"[Test] Number of vertices in surfaces should not be null")
raise ValueError("[Test] Number of vertices in surfaces should not be null")
if s.mesh().nb_polygons() == 0:
raise ValueError(
"[Test] Number of polygons in surfaces should not be null")
raise ValueError("[Test] Number of polygons in surfaces should not be null")
for b in brep.blocks():
if b.mesh().nb_vertices() == 0:
raise ValueError(
"[Test] Number of vertices in blocks should not be null")
raise ValueError("[Test] Number of vertices in blocks should not be null")
if b.mesh().nb_polyhedra() == 0:
raise ValueError(
"[Test] Number of polyhedra in blocks should not be null")
raise ValueError("[Test] Number of polyhedra in blocks should not be null")

# Number of component boundaries and incidences
for c in brep.corners():
if brep.nb_boundaries(c.id()) != 0:
raise ValueError("[Test] Number of corner boundary should be 0")
if brep.nb_incidences(c.id()) != 4 and brep.nb_incidences(c.id()) != 5:
raise ValueError(
"[Test] Number of corner incidences should be 4 or 5")
raise ValueError("[Test] Number of corner incidences should be 4 or 5")
for l in brep.lines():
if brep.nb_boundaries(l.id()) != 2:
raise ValueError("[Test] Number of line boundary should be 2")
if brep.nb_incidences(l.id()) < 2 or brep.nb_incidences(l.id()) > 4:
raise ValueError(
"[Test] Number of line incidences should be 2, 3 or 4")
raise ValueError("[Test] Number of line incidences should be 2, 3 or 4")
for s in brep.surfaces():
if brep.nb_boundaries(s.id()) != 3:
raise ValueError("[Test] Number of surface boundary should be 3")
if brep.nb_incidences(s.id()) != 1 and brep.nb_incidences(s.id()) != 2:
raise ValueError(
"[Test] Number of surface incidences should be 1 or 2")
raise ValueError("[Test] Number of surface incidences should be 1 or 2")
for b in brep.blocks():
if brep.nb_boundaries(b.id()) != 4:
raise ValueError("[Test] Number of block boundary should be 4")
if brep.nb_incidences(b.id()) != 0:
raise ValueError("[Test] Number of block incidences should be 0")


if __name__ == '__main__':
model_io.IOModelLibrary.initialize()
if __name__ == "__main__":
model_io.OpenGeodeIOModelLibrary.initialize()
test_dir = os.path.dirname(__file__)
data_dir = os.path.abspath(os.path.join(
test_dir, "../../../../tests/data"))
data_dir = os.path.abspath(os.path.join(test_dir, "../../../../tests/data"))

brep_cube = opengeode.load_brep(os.path.join(data_dir, "cube_v22.msh"))
test_brep_cube(brep_cube)
Expand Down
13 changes: 7 additions & 6 deletions bindings/python/tests/model_io/test-py-svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import os
import sys
import platform

if sys.version_info >= (3, 8, 0) and platform.system() == "Windows":
for path in [x.strip() for x in os.environ['PATH'].split(';') if x]:
for path in [x.strip() for x in os.environ["PATH"].split(";") if x]:
os.add_dll_directory(path)

import opengeode
Expand Down Expand Up @@ -51,14 +52,14 @@ def test_section(section):
nb_cmv = len(section.component_mesh_vertices(uv))
if nb_cmv != 1 and nb_cmv != 3:
raise ValueError(
"[Test] Wrong number of mesh component vertices for one unique vertex")
"[Test] Wrong number of mesh component vertices for one unique vertex"
)


if __name__ == '__main__':
model_io.IOModelLibrary.initialize()
if __name__ == "__main__":
model_io.OpenGeodeIOModelLibrary.initialize()
test_dir = os.path.dirname(__file__)
data_dir = os.path.abspath(os.path.join(
test_dir, "../../../../tests/data"))
data_dir = os.path.abspath(os.path.join(test_dir, "../../../../tests/data"))

section = opengeode.load_section(os.path.join(data_dir, "logo.svg"))
test_section(section)
Expand Down
7 changes: 7 additions & 0 deletions cmake/OpenGeode-IO.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ if(NOT BUILD_SHARED_LIBS)
)
endif()


install(
FILES include/geode/io/project.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/geode/io
COMPONENT public
)

# ------------------------------------------------------------------------------------------------
# Configure the OpenGeode-IO libraries
add_subdirectory(src/geode)
Expand Down
3 changes: 2 additions & 1 deletion include/geode/io/image/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
#include <geode/basic/library.hpp>

#include <geode/io/image/opengeode_io_image_export.hpp>
#include <geode/io/project.hpp>

namespace geode
{
OPENGEODE_LIBRARY( opengeode_io_image_api, IOImage );
OPENGEODE_LIBRARY( opengeode_io_image_api, OpenGeodeIO, Image );
} // namespace geode
Loading
Loading