Skip to content

Commit acafc59

Browse files
authored
feat(Static): static library generation
BREAKING CHANGE: Library initialization function design changed
1 parent 4904bc6 commit acafc59

File tree

89 files changed

+1644
-1126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1644
-1126
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ option(OPENGEODE_WITH_PYTHON "Compile Python bindings" OFF)
2929
if(OPENGEODE_WITH_PYTHON)
3030
set(PYTHON_VERSION "" CACHE STRING "Python version to use for compiling modules")
3131
endif()
32+
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
3233

3334
# Internal options
3435
option(USE_SUPERBUILD "Whether or not a superbuild should be invoked" ON)

bindings/python/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@
2121
from .opengeode_py_basic import *
2222
from .opengeode_py_geometry import *
2323
from .opengeode_py_mesh import *
24-
from .opengeode_py_model import *
24+
from .opengeode_py_model import *
25+
26+
OpenGeodeModel.initialize()

bindings/python/src/basic/basic.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <pybind11/pybind11.h>
2626
#include <pybind11/stl.h>
2727

28+
#include <geode/basic/library.h>
29+
2830
#include "attribute.h"
2931
#include "attribute_manager.h"
3032
#include "identifier.h"
@@ -57,6 +59,8 @@ PYBIND11_MODULE( opengeode_py_basic, module )
5759
module.attr( "NO_ID" ) = geode::NO_ID;
5860
module.attr( "NO_LID" ) = geode::NO_LID;
5961
module.attr( "global_epsilon" ) = geode::global_epsilon;
62+
pybind11::class_< geode::OpenGeodeBasic >( module, "OpenGeodeBasic" )
63+
.def( "initialize", &geode::OpenGeodeBasic::initialize );
6064
geode::define_uuid( module );
6165
geode::define_attributes( module );
6266
geode::define_attribute_manager( module );

bindings/python/src/geometry/geometry.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ PYBIND11_MODULE( opengeode_py_geometry, module )
9595
{
9696
pybind11::add_ostream_redirect( module );
9797
module.doc() = "OpenGeode Python binding for geometry";
98+
pybind11::class_< geode::OpenGeodeGeometry >( module, "OpenGeodeGeometry" )
99+
.def( "initialize", &geode::OpenGeodeGeometry::initialize );
98100
geode::define_barycentric( module );
99101
geode::define_basic_objects( module );
100102
geode::define_bounding_box( module );

bindings/python/src/mesh/mesh.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ PYBIND11_MODULE( opengeode_py_mesh, module )
141141
}
142142
pybind11::add_ostream_redirect( module );
143143
module.doc() = "OpenGeode Python binding for mesh";
144+
pybind11::class_< geode::OpenGeodeMesh >( module, "OpenGeodeMesh" )
145+
.def( "initialize", &geode::OpenGeodeMesh::initialize );
144146
geode::define_vertex_set( module );
145147
geode::define_graph( module );
146148
geode::define_edged_curve( module );

bindings/python/src/model/model.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ PYBIND11_MODULE( opengeode_py_model, module )
128128
}
129129
pybind11::add_ostream_redirect( module );
130130
module.doc() = "OpenGeode Python binding for model";
131+
pybind11::class_< geode::OpenGeodeModel >( module, "OpenGeodeModel" )
132+
.def( "initialize", &geode::OpenGeodeModel::initialize );
131133
geode::define_component_type( module );
132134
geode::define_component( module );
133135
geode::define_block( module );

bindings/python/tests/mesh/test-py-edged-curve.py

Lines changed: 158 additions & 144 deletions
Large diffs are not rendered by default.

bindings/python/tests/mesh/test-py-geometrical-opeations-on-mesh.py

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,57 +19,65 @@
1919
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
# SOFTWARE.
2121

22-
import os, sys, platform
23-
if sys.version_info >= (3,8,0) and platform.system() == "Windows":
22+
import os
23+
import sys
24+
import platform
25+
if sys.version_info >= (3, 8, 0) and platform.system() == "Windows":
2426
for path in [x.strip() for x in os.environ['PATH'].split(';') if x]:
2527
os.add_dll_directory(path)
2628

2729
import opengeode_py_basic as basic
2830
import opengeode_py_geometry as geom
2931
import opengeode_py_mesh as mesh
3032

33+
3134
def create_surface():
3235
surface = mesh.TriangulatedSurface3D.create()
33-
builder = mesh.TriangulatedSurfaceBuilder3D.create( surface )
34-
builder.create_point( geom.Point3D( [ 0.1, 0.2, 0.3 ] ) )
35-
builder.create_point( geom.Point3D( [ 2.1, 9.4, 6.7 ] ) )
36-
builder.create_point( geom.Point3D( [ 7.5, 5.2, 6.3 ] ) )
37-
builder.create_point( geom.Point3D( [ 8.1, 1.4, 4.7 ] ) )
38-
builder.create_point( geom.Point3D( [ 4.7, 2.1, 1.3 ] ) )
39-
builder.create_triangle( [ 0, 1, 2 ] )
40-
builder.create_triangle( [ 1, 3, 2 ] )
41-
builder.create_triangle( [ 3, 4, 2 ] )
36+
builder = mesh.TriangulatedSurfaceBuilder3D.create(surface)
37+
builder.create_point(geom.Point3D([0.1, 0.2, 0.3]))
38+
builder.create_point(geom.Point3D([2.1, 9.4, 6.7]))
39+
builder.create_point(geom.Point3D([7.5, 5.2, 6.3]))
40+
builder.create_point(geom.Point3D([8.1, 1.4, 4.7]))
41+
builder.create_point(geom.Point3D([4.7, 2.1, 1.3]))
42+
builder.create_triangle([0, 1, 2])
43+
builder.create_triangle([1, 3, 2])
44+
builder.create_triangle([3, 4, 2])
4245
return surface
4346

44-
def test_rescale( surface ):
45-
builder = mesh.TriangulatedSurfaceBuilder3D.create( surface )
46-
mesh.rescale_triangulated_surface3D( surface, builder, [ 2, -2, 0.1 ] )
47-
if not surface.point( 0 ).inexact_equal(geom.Point3D( [ 0.2, -0.4, 0.03 ]), 1e-6 ):
48-
raise ValueError( "[Test] Wrong rescale of vertex 0" )
49-
if not surface.point( 1 ).inexact_equal(geom.Point3D( [ 4.2, -18.8, 0.67 ]), 1e-6 ):
50-
raise ValueError( "[Test] Wrong rescale of vertex 1" )
51-
if not surface.point( 2 ).inexact_equal(geom.Point3D( [ 15.0, -10.4, 0.63 ]), 1e-6 ):
52-
raise ValueError( "[Test] Wrong rescale of vertex 2" )
53-
if not surface.point( 3 ).inexact_equal(geom.Point3D( [ 16.2, -2.8, 0.47 ]), 1e-6 ):
54-
raise ValueError( "[Test] Wrong rescale of vertex 3" )
55-
if not surface.point( 4 ).inexact_equal(geom.Point3D( [ 9.4, -4.2, 0.13 ]), 1e-6 ):
56-
raise ValueError( "[Test] Wrong rescale of vertex 4" )
5747

58-
def test_translate( surface ):
59-
builder = mesh.TriangulatedSurfaceBuilder3D.create( surface )
60-
mesh.translate_triangulated_surface3D( surface, builder, geom.Vector3D( [ 2, -2, 1 ] ) )
61-
if not surface.point( 0 ).inexact_equal(geom.Point3D([ 2.1, -1.8, 1.3 ] ) , 1e-6 ):
62-
raise ValueError( "[Test] Wrong translation of vertex 0" )
63-
if not surface.point( 1 ).inexact_equal(geom.Point3D([ 4.1, 7.4, 7.7 ] ) , 1e-6 ):
64-
raise ValueError( "[Test] Wrong translation of vertex 1" )
65-
if not surface.point( 2 ).inexact_equal(geom.Point3D([ 9.5, 3.2, 7.3 ] ) , 1e-6 ):
66-
raise ValueError( "[Test] Wrong translation of vertex 2" )
67-
if not surface.point( 3 ).inexact_equal(geom.Point3D([ 10.1, -0.6, 5.7 ] ) , 1e-6 ):
68-
raise ValueError( "[Test] Wrong translation of vertex 3" )
69-
if not surface.point( 4 ).inexact_equal(geom.Point3D([ 6.7, 0.1, 2.3 ] ) , 1e-6 ):
70-
raise ValueError( "[Test] Wrong translation of vertex 4" )
48+
def test_rescale(surface):
49+
builder = mesh.TriangulatedSurfaceBuilder3D.create(surface)
50+
mesh.rescale_triangulated_surface3D(surface, builder, [2, -2, 0.1])
51+
if not surface.point(0).inexact_equal(geom.Point3D([0.2, -0.4, 0.03]), 1e-6):
52+
raise ValueError("[Test] Wrong rescale of vertex 0")
53+
if not surface.point(1).inexact_equal(geom.Point3D([4.2, -18.8, 0.67]), 1e-6):
54+
raise ValueError("[Test] Wrong rescale of vertex 1")
55+
if not surface.point(2).inexact_equal(geom.Point3D([15.0, -10.4, 0.63]), 1e-6):
56+
raise ValueError("[Test] Wrong rescale of vertex 2")
57+
if not surface.point(3).inexact_equal(geom.Point3D([16.2, -2.8, 0.47]), 1e-6):
58+
raise ValueError("[Test] Wrong rescale of vertex 3")
59+
if not surface.point(4).inexact_equal(geom.Point3D([9.4, -4.2, 0.13]), 1e-6):
60+
raise ValueError("[Test] Wrong rescale of vertex 4")
61+
62+
63+
def test_translate(surface):
64+
builder = mesh.TriangulatedSurfaceBuilder3D.create(surface)
65+
mesh.translate_triangulated_surface3D(
66+
surface, builder, geom.Vector3D([2, -2, 1]))
67+
if not surface.point(0).inexact_equal(geom.Point3D([2.1, -1.8, 1.3]), 1e-6):
68+
raise ValueError("[Test] Wrong translation of vertex 0")
69+
if not surface.point(1).inexact_equal(geom.Point3D([4.1, 7.4, 7.7]), 1e-6):
70+
raise ValueError("[Test] Wrong translation of vertex 1")
71+
if not surface.point(2).inexact_equal(geom.Point3D([9.5, 3.2, 7.3]), 1e-6):
72+
raise ValueError("[Test] Wrong translation of vertex 2")
73+
if not surface.point(3).inexact_equal(geom.Point3D([10.1, -0.6, 5.7]), 1e-6):
74+
raise ValueError("[Test] Wrong translation of vertex 3")
75+
if not surface.point(4).inexact_equal(geom.Point3D([6.7, 0.1, 2.3]), 1e-6):
76+
raise ValueError("[Test] Wrong translation of vertex 4")
77+
7178

7279
if __name__ == '__main__':
80+
mesh.OpenGeodeMesh.initialize()
7381
surface = create_surface()
74-
test_rescale( surface.clone() )
75-
test_translate( surface.clone() )
82+
test_rescale(surface.clone())
83+
test_translate(surface.clone())

bindings/python/tests/mesh/test-py-graph.py

Lines changed: 80 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -19,114 +19,125 @@
1919
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
# SOFTWARE.
2121

22-
import os, sys, platform
23-
if sys.version_info >= (3,8,0) and platform.system() == "Windows":
22+
import os
23+
import sys
24+
import platform
25+
if sys.version_info >= (3, 8, 0) and platform.system() == "Windows":
2426
for path in [x.strip() for x in os.environ['PATH'].split(';') if x]:
2527
os.add_dll_directory(path)
2628

2729
import opengeode_py_mesh as mesh
2830

29-
def test_create_vertices( graph, builder ):
31+
32+
def test_create_vertices(graph, builder):
3033
builder.create_vertex()
3134
if graph.nb_vertices() != 1:
32-
raise ValueError( "[Test] Graph should have 1 vertex" )
33-
builder.create_vertices( 3 )
35+
raise ValueError("[Test] Graph should have 1 vertex")
36+
builder.create_vertices(3)
3437
if graph.nb_vertices() != 4:
35-
raise ValueError( "[Test] Graph should have 4 vertices" )
38+
raise ValueError("[Test] Graph should have 4 vertices")
3639

3740

38-
def test_create_edges( graph, builder ):
39-
builder.create_edge_with_vertices( 0, 1 )
40-
builder.create_edge_with_vertices( 0, 2 )
41-
builder.create_edge_with_vertices( 3, 2 )
42-
builder.create_edge_with_vertices( 1, 2 )
41+
def test_create_edges(graph, builder):
42+
builder.create_edge_with_vertices(0, 1)
43+
builder.create_edge_with_vertices(0, 2)
44+
builder.create_edge_with_vertices(3, 2)
45+
builder.create_edge_with_vertices(1, 2)
4346
if graph.nb_edges() != 4:
44-
raise ValueError( "[Test] Graph should have 4 edges" )
45-
answer = [ 3, 2 ]
46-
if graph.edge_vertices( 2 ) != answer:
47-
raise ValueError( "[Test] Wrong edge vertices" )
48-
49-
edges_around_0 = graph.edges_around_vertex( 0 )
50-
if len( edges_around_0 ) != 2:
51-
raise ValueError( "[Test] edges_around_0 should have 2 edges" )
47+
raise ValueError("[Test] Graph should have 4 edges")
48+
answer = [3, 2]
49+
if graph.edge_vertices(2) != answer:
50+
raise ValueError("[Test] Wrong edge vertices")
51+
52+
edges_around_0 = graph.edges_around_vertex(0)
53+
if len(edges_around_0) != 2:
54+
raise ValueError("[Test] edges_around_0 should have 2 edges")
5255
if edges_around_0[0].edge_id != 0:
53-
raise ValueError( "[Test] edges_around_0 has wrong value" )
56+
raise ValueError("[Test] edges_around_0 has wrong value")
5457
if edges_around_0[0].vertex_id != 0:
55-
raise ValueError( "[Test] edges_around_0 has wrong value" )
58+
raise ValueError("[Test] edges_around_0 has wrong value")
5659
if edges_around_0[1].edge_id != 1:
57-
raise ValueError( "[Test] edges_around_0 has wrong value" )
60+
raise ValueError("[Test] edges_around_0 has wrong value")
5861
if edges_around_0[1].vertex_id != 0:
59-
raise ValueError( "[Test] edges_around_0 has wrong value" )
62+
raise ValueError("[Test] edges_around_0 has wrong value")
6063

61-
edges_around_2 = graph.edges_around_vertex( 2 )
62-
if len( edges_around_2 ) != 3:
63-
raise ValueError( "[Test] edges_around_2 should have 3 edges" )
64+
edges_around_2 = graph.edges_around_vertex(2)
65+
if len(edges_around_2) != 3:
66+
raise ValueError("[Test] edges_around_2 should have 3 edges")
6467
if edges_around_2[0].edge_id != 1:
65-
raise ValueError( "[Test] edges_around_2 has wrong value" )
68+
raise ValueError("[Test] edges_around_2 has wrong value")
6669
if edges_around_2[0].vertex_id != 1:
67-
raise ValueError( "[Test] edges_around_2 has wrong value" )
70+
raise ValueError("[Test] edges_around_2 has wrong value")
6871
if edges_around_2[1].edge_id != 2:
69-
raise ValueError( "[Test] edges_around_2 has wrong value" )
72+
raise ValueError("[Test] edges_around_2 has wrong value")
7073
if edges_around_2[1].vertex_id != 1:
71-
raise ValueError( "[Test] edges_around_2 has wrong value" )
74+
raise ValueError("[Test] edges_around_2 has wrong value")
7275
if edges_around_2[2].edge_id != 3:
73-
raise ValueError( "[Test] edges_around_2 has wrong value" )
76+
raise ValueError("[Test] edges_around_2 has wrong value")
7477
if edges_around_2[2].vertex_id != 1:
75-
raise ValueError( "[Test] edges_around_2 has wrong value" )
78+
raise ValueError("[Test] edges_around_2 has wrong value")
79+
7680

77-
def test_delete_edge( graph, builder ):
81+
def test_delete_edge(graph, builder):
7882
to_delete = [False] * graph.nb_edges()
7983
to_delete[0] = True
80-
builder.delete_edges( to_delete )
84+
builder.delete_edges(to_delete)
8185
if graph.nb_edges() != 3:
82-
raise ValueError( "[Test] Graph should have 3 edges" )
83-
if graph.edge_vertex( mesh.EdgeVertex( 0, 0 ) ) != 0:
84-
raise ValueError( "[Test] Graph edge vertex index is not correct" )
85-
if graph.edge_vertex( mesh.EdgeVertex( 0, 1 ) ) != 2:
86-
raise ValueError( "[Test] Graph edge vertex index is not correct" )
87-
88-
builder.create_edges( 10 )
89-
builder.set_edge_vertex( mesh.EdgeVertex( 1, 0 ), 1 )
90-
builder.set_edge_vertex( mesh.EdgeVertex( 1, 1 ), 0 )
86+
raise ValueError("[Test] Graph should have 3 edges")
87+
if graph.edge_vertex(mesh.EdgeVertex(0, 0)) != 0:
88+
raise ValueError("[Test] Graph edge vertex index is not correct")
89+
if graph.edge_vertex(mesh.EdgeVertex(0, 1)) != 2:
90+
raise ValueError("[Test] Graph edge vertex index is not correct")
91+
92+
builder.create_edges(10)
93+
builder.set_edge_vertex(mesh.EdgeVertex(1, 0), 1)
94+
builder.set_edge_vertex(mesh.EdgeVertex(1, 1), 0)
9195
if graph.nb_edges() != 13:
92-
raise ValueError( "[Test] Graph should have 13 edges" )
96+
raise ValueError("[Test] Graph should have 13 edges")
9397

9498
to_delete[-1] = True
95-
to_delete.extend( [True] * 9 )
96-
builder.delete_edges( to_delete )
99+
to_delete.extend([True] * 9)
100+
builder.delete_edges(to_delete)
97101
if graph.nb_edges() != 2:
98-
raise ValueError( "[Test] Graph should have 2 edges" )
99-
if graph.edge_vertex( mesh.EdgeVertex( 0, 0 ) ) != 1:
100-
raise ValueError( "[Test] Graph edge vertex index is not correct (0, 0)" )
101-
if graph.edge_vertex( mesh.EdgeVertex( 0, 1 ) ) != 0:
102-
raise ValueError( "[Test] Graph edge vertex index is not correct (0, 1)" )
102+
raise ValueError("[Test] Graph should have 2 edges")
103+
if graph.edge_vertex(mesh.EdgeVertex(0, 0)) != 1:
104+
raise ValueError(
105+
"[Test] Graph edge vertex index is not correct (0, 0)")
106+
if graph.edge_vertex(mesh.EdgeVertex(0, 1)) != 0:
107+
raise ValueError(
108+
"[Test] Graph edge vertex index is not correct (0, 1)")
109+
103110

104-
def test_io( graph, filename ):
105-
mesh.save_graph( graph, filename )
106-
new_graph = mesh.load_graph( filename )
111+
def test_io(graph, filename):
112+
mesh.save_graph(graph, filename)
113+
new_graph = mesh.load_graph(filename)
107114

108-
def test_clone( graph ):
115+
116+
def test_clone(graph):
109117
graph2 = graph.clone()
110118
if graph2.nb_vertices() != 4:
111-
raise ValueError( "[Test] Graph2 should have 4 vertices" )
119+
raise ValueError("[Test] Graph2 should have 4 vertices")
112120
if graph2.nb_edges() != 2:
113-
raise ValueError( "[Test] Graph2 should have 2 edges" )
121+
raise ValueError("[Test] Graph2 should have 2 edges")
122+
114123

115-
def test_delete_isolated_vertices( graph, builder ):
124+
def test_delete_isolated_vertices(graph, builder):
116125
builder.delete_isolated_vertices()
117126
if graph.nb_vertices() != 3:
118-
raise ValueError( "[Test] Graph should have 3 vertices" )
127+
raise ValueError("[Test] Graph should have 3 vertices")
119128
if graph.nb_edges() != 2:
120-
raise ValueError( "[Test] Graph2 should have 2 edges" )
129+
raise ValueError("[Test] Graph2 should have 2 edges")
130+
121131

122132
if __name__ == '__main__':
133+
mesh.OpenGeodeMesh.initialize()
123134
graph = mesh.Graph.create()
124-
builder = mesh.GraphBuilder.create( graph )
125-
126-
test_create_vertices( graph, builder )
127-
test_create_edges( graph, builder )
128-
test_io( graph, "test." + graph.native_extension() )
129-
130-
test_delete_edge( graph, builder )
131-
test_clone( graph )
132-
test_delete_isolated_vertices( graph, builder )
135+
builder = mesh.GraphBuilder.create(graph)
136+
137+
test_create_vertices(graph, builder)
138+
test_create_edges(graph, builder)
139+
test_io(graph, "test." + graph.native_extension())
140+
141+
test_delete_edge(graph, builder)
142+
test_clone(graph)
143+
test_delete_isolated_vertices(graph, builder)

0 commit comments

Comments
 (0)