Skip to content

Commit addd853

Browse files
committed
added model python bindings
1 parent 6c09886 commit addd853

7 files changed

Lines changed: 208 additions & 0 deletions

File tree

bindings/python/src/validity/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
add_geode_python_binding(
2222
NAME "py_validity"
2323
SOURCES
24+
"brep_validity.hpp"
2425
"edgedcurve_validity.hpp"
2526
"object_validity.hpp"
2627
"pointset_validity.hpp"
28+
"section_validity.hpp"
2729
"solid_validity.hpp"
2830
"surface_validity.hpp"
2931
"validity.cpp"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2019 - 2026 Geode-solutions
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
*/
23+
#include <string>
24+
25+
#include <geode/model/representation/core/brep.hpp>
26+
27+
#include <geode/inspector/validity/brep_validity.hpp>
28+
#include <geode/inspector/validity/object_validity.hpp>
29+
30+
namespace geode
31+
{
32+
void define_brep_validity( pybind11::module& module )
33+
{
34+
module.def( "is_brep_valid", &is_brep_valid );
35+
}
36+
} // namespace geode
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2019 - 2026 Geode-solutions
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
*/
23+
#include <string>
24+
25+
#include <geode/model/representation/core/section.hpp>
26+
27+
#include <geode/inspector/validity/object_validity.hpp>
28+
#include <geode/inspector/validity/section_validity.hpp>
29+
30+
namespace geode
31+
{
32+
void define_section_validity( pybind11::module& module )
33+
{
34+
module.def( "is_section_valid", &is_section_valid );
35+
}
36+
} // namespace geode

bindings/python/src/validity/validity.cpp

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

28+
#include "brep_validity.hpp"
2829
#include "edgedcurve_validity.hpp"
2930
#include "object_validity.hpp"
3031
#include "pointset_validity.hpp"
32+
#include "section_validity.hpp"
3133
#include "solid_validity.hpp"
3234
#include "surface_validity.hpp"
3335

@@ -39,8 +41,10 @@ PYBIND11_MODULE( opengeode_inspector_py_validity, module )
3941
.def( "initialize",
4042
&geode::OpenGeodeInspectorValidityLibrary::initialize );
4143
geode::define_object_validity( module );
44+
geode::define_brep_validity( module );
4245
geode::define_edged_curve_validity( module );
4346
geode::define_point_set_validity( module );
47+
geode::define_section_validity( module );
4448
geode::define_solid_mesh_validity( module );
4549
geode::define_surface_mesh_validity( module );
4650
}

bindings/python/tests/validity/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
# SOFTWARE.
2020

21+
add_geode_python_test(
22+
SOURCE "test-py-brep-validity.py"
23+
DEPENDENCIES
24+
${PROJECT_NAME}::py_validity
25+
)
26+
2127
add_geode_python_test(
2228
SOURCE "test-py-edgedcurve-validity.py"
2329
DEPENDENCIES
@@ -30,6 +36,12 @@
3036
${PROJECT_NAME}::py_validity
3137
)
3238

39+
add_geode_python_test(
40+
SOURCE "test-py-section-validity.py"
41+
DEPENDENCIES
42+
${PROJECT_NAME}::py_validity
43+
)
44+
3345
add_geode_python_test(
3446
SOURCE "test-py-solid-validity.py"
3547
DEPENDENCIES
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright (c) 2019 - 2026 Geode-solutions
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
# SOFTWARE.
21+
22+
import os
23+
import sys
24+
import platform
25+
26+
if sys.version_info >= (3, 8, 0) and platform.system() == "Windows":
27+
for path in [x.strip() for x in os.environ["PATH"].split("") if x]:
28+
os.add_dll_directory(path)
29+
30+
import opengeode as geode
31+
import opengeode_inspector_py_validity as validity
32+
33+
def data_dir():
34+
test_dir = os.path.dirname(__file__)
35+
return os.path.abspath(os.path.join(test_dir, "../../../../tests/data"))
36+
37+
38+
def check_a1():
39+
model_brep = geode.load_brep(data_dir() + "/model_A1.og_brep")
40+
result = validity.is_brep_valid(model_brep)
41+
if result.nb_issues()!=7:
42+
raise ValueError( "[Test] model model_A1 should have 7 issues." )
43+
44+
45+
def check_a1_valid():
46+
model_brep = geode.load_brep(data_dir() + "/model_A1_valid.og_brep")
47+
result = validity.is_brep_valid(model_brep)
48+
if result.nb_issues()!=7:
49+
raise ValueError( "[Test] model model_A1_valid should have 7 issues." )
50+
51+
52+
def check_model_mss():
53+
model_brep = geode.load_brep(data_dir() + "/mss.og_brep")
54+
result = validity.is_brep_valid(model_brep)
55+
if result.nb_issues()!=5:
56+
raise ValueError( "[Test] model_mss should have 5 issues." )
57+
58+
59+
def check_model_D():
60+
model_brep = geode.load_brep(data_dir() + "/model_D.og_brep")
61+
result = validity.is_brep_valid(model_brep)
62+
if result.nb_issues()!=0:
63+
raise ValueError( "[Test] model_D should have 0 issues." )
64+
65+
66+
if __name__ == "__main__":
67+
validity.OpenGeodeInspectorValidityLibrary.initialize()
68+
check_a1()
69+
check_a1_valid()
70+
check_model_mss()
71+
check_model_D()
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright (c) 2019 - 2026 Geode-solutions
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
# SOFTWARE.
21+
22+
import os
23+
import sys
24+
import platform
25+
26+
if sys.version_info >= (3, 8, 0) and platform.system() == "Windows":
27+
for path in [x.strip() for x in os.environ["PATH"].split("") if x]:
28+
os.add_dll_directory(path)
29+
30+
import opengeode as geode
31+
import opengeode_inspector_py_validity as validity
32+
33+
def data_dir():
34+
test_dir = os.path.dirname(__file__)
35+
return os.path.abspath(os.path.join(test_dir, "../../../../tests/data"))
36+
37+
38+
def check_section():
39+
model_section = geode.load_section(data_dir() + "/vertical_lines.og_sctn")
40+
result = validity.is_section_valid(model_section)
41+
if result.nb_issues()!=0:
42+
raise ValueError( "[Test] Section vertical_lines should have 0 issues." )
43+
44+
45+
if __name__ == "__main__":
46+
validity.OpenGeodeInspectorValidityLibrary.initialize()
47+
check_section()

0 commit comments

Comments
 (0)