Skip to content

Commit 66f0418

Browse files
test
1 parent 66e2048 commit 66f0418

File tree

2 files changed

+244
-1
lines changed

2 files changed

+244
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55

66
[project]
77
name = "OpenGeodeWeb-Back"
8-
version = "0.0.7"
8+
version = "0.0.8"
99
authors = [
1010
{ name="Geode-solutions", email="[email protected]" },
1111
]
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
import opengeode_inspector as inspector
2+
3+
class Result:
4+
def __init__(self
5+
, children: list
6+
, route: str
7+
, sentence: str = None
8+
, value = None
9+
):
10+
self.children = children
11+
self.is_leaf = len(children) == 0
12+
self.route = route
13+
self.value = value
14+
self.sentence = sentence
15+
self.list_invalidities = None
16+
17+
def json_return(Result_list: list):
18+
json_result = []
19+
for result in Result_list:
20+
json_temp = {"value": result.value
21+
, "children" : result.children if result.is_leaf else json_return(result.children)
22+
, "is_leaf": result.is_leaf
23+
, "route": result.route
24+
, "sentence": result.sentence if result.sentence != None else result.route
25+
}
26+
json_result.append(json_temp)
27+
return json_result
28+
29+
def AdjacencyTests(object: str):
30+
AdjacencyTests = [
31+
Result([], f"nb_{object}_with_wrong_adjacency", f"Number of {object} with invalid adjacencies")
32+
]
33+
Wrapper_AdjacencyTests = Result(AdjacencyTests, "Adjacency")
34+
return Wrapper_AdjacencyTests
35+
36+
def ColocationTests():
37+
ColocationTests = [
38+
Result([], "nb_colocated_points", "Number of colocated points")
39+
]
40+
Wrapper_ColocationTests = Result(ColocationTests, "Colocation")
41+
return Wrapper_ColocationTests
42+
def DegenerationTests():
43+
DegenerationTests = [
44+
Result([], "nb_degenerated_edges", "Number of degenerated edges")
45+
]
46+
Wrapper_DegenerationTests = Result(DegenerationTests, "Degeneration")
47+
return Wrapper_DegenerationTests
48+
def ManifoldTests(objects: list):
49+
ManifoldTests = []
50+
for object in objects:
51+
ManifoldTests.append(Result([], f"nb_non_manifold_{object}", f"Number of non manifold {object}"))
52+
Wrapper_ManifoldTests = Result(ManifoldTests, "Manifold")
53+
return Wrapper_ManifoldTests
54+
def IntersectionTests():
55+
IntersectionTests = [
56+
Result([], "intersecting_elements", "Number of intersecting elements")
57+
]
58+
Wrapper_IntersectionTests = Result(IntersectionTests, "Intersection")
59+
return Wrapper_IntersectionTests
60+
def TopologyTests(object: str):
61+
unique_vertices_colocation = [
62+
Result([], "unique_vertices_linked_to_different_points", "Number of unique vertices linked to different points in space")
63+
, Result([], "colocated_unique_vertices_groups", "Number of unique vertices colocated in space")
64+
]
65+
66+
components_are_linked_to_a_unique_vertex = [
67+
Result([], "nb_corners_not_linked_to_a_unique_vertex", "Number of corners not linked to a unique vertex")
68+
, Result([], "nb_lines_meshed_but_not_linked_to_a_unique_vertex", "Number of lines not linked to a unique vertex")
69+
, Result([], "nb_surfaces_meshed_but_not_linked_to_a_unique_vertex", "Number of surfaces not linked to a unique vertex")
70+
]
71+
72+
invalid_components_topology_unique_vertices = [
73+
Result([], "unique_vertices_not_linked_to_a_component_vertex", "Number of unique vertices not linked to a component mesh vertex")
74+
, Result([], "multiple_corners_unique_vertices", "Unique vertices linked to multiple corners")
75+
, Result([], "multiple_internals_corner_vertices", "Unique vertices linked to a corner with multiple internal relations")
76+
, Result([], "not_internal_nor_boundary_corner_vertices", "Unique vertices linked to a corner which is neither internal nor boundary")
77+
, Result([], "line_corners_without_boundary_status", "Unique vertices linked to a line and a corner not boundary of the line")
78+
, Result([], "part_of_not_boundary_nor_internal_line_unique_vertices", "Unique vertices part of a line without boundary or internal relations")
79+
, Result([], "part_of_line_with_invalid_internal_topology_unique_vertices", "Unique vertices part of a line with invalid internal topology relations")
80+
, Result([], "part_of_invalid_unique_line_unique_vertices", "Unique vertices part of a single line with invalid topology")
81+
, Result([], "part_of_lines_but_not_corner_unique_vertices", "Unique vertices part of multiple lines with invalid topology")
82+
, Result([], "part_of_line_and_not_on_surface_border_unique_vertices", "Unique vertices part of a line and a surface but not on the border of the surface mesh")
83+
]
84+
85+
if object == "brep":
86+
brep_components_are_linked_to_a_unique_vertex = components_are_linked_to_a_unique_vertex
87+
brep_components_are_linked_to_a_unique_vertex.append(Result([], "nb_blocks_meshed_but_not_linked_to_a_unique_vertex", "Number of blocks not linked to a unique vertex"))
88+
89+
brep_invalid_components_topology_unique_vertices = invalid_components_topology_unique_vertices
90+
brep_invalid_components_topology_unique_vertices.append(Result([], "part_of_not_boundary_nor_internal_surface_unique_vertices", "Unique vertices part of a surface which has no boundary or internal relations"))
91+
brep_invalid_components_topology_unique_vertices.append(Result([], "part_of_surface_with_invalid_internal_topology_unique_vertices", "Unique vertices part of a surface with invalid internal topology"))
92+
brep_invalid_components_topology_unique_vertices.append(Result([], "part_of_invalid_unique_surface_unique_vertices", "Unique vertices part of a unique surface with invalid topology"))
93+
brep_invalid_components_topology_unique_vertices.append(Result([], "part_of_invalid_multiple_surfaces_unique_vertices", "Unique vertices part of multiple surfaces with invalid topology"))
94+
brep_invalid_components_topology_unique_vertices.append(Result([], "part_of_invalid_blocks_unique_vertices", "Unique vertices part of blocks with invalid topology"))
95+
96+
TopologyTests = [
97+
Result(brep_components_are_linked_to_a_unique_vertex, "Meshed components are linked to a unique vertex")
98+
, Result(brep_invalid_components_topology_unique_vertices, "Unique vertices linked to components with invalid topology")
99+
, Result(unique_vertices_colocation, "Unique vertices with colocation issues")
100+
]
101+
elif object == "section":
102+
section_invalid_components_topology_unique_vertices = invalid_components_topology_unique_vertices
103+
section_invalid_components_topology_unique_vertices.append(Result([], "part_of_invalid_surfaces_unique_vertices", "Unique vertices part of surfaces with invalid topology"))
104+
105+
TopologyTests = [
106+
Result(components_are_linked_to_a_unique_vertex, "Meshed components are linked to a unique vertex")
107+
, Result(section_invalid_components_topology_unique_vertices, "Unique vertices linked to components with invalid topology")
108+
, Result(unique_vertices_colocation, "Unique vertices with colocation issues")
109+
]
110+
Wrapper_TopologyTests = Result(TopologyTests, "Topology")
111+
return Wrapper_TopologyTests
112+
113+
def ComponentMeshesTests(object: str):
114+
component_meshes_adjacency = [
115+
Result([], "surfaces_nb_edges_with_wrong_adjacencies", "Model component meshes edge adjacencies")
116+
]
117+
component_meshes_colocation = [
118+
Result([], "components_nb_colocated_points", "Model component meshes point colocation")
119+
]
120+
component_meshes_degeneration = [
121+
Result([], "components_nb_degenerated_elements", "Model component meshes element degeneration")
122+
]
123+
component_meshes_manifold = [
124+
Result([], "component_meshes_nb_non_manifold_vertices", "Model component meshes vertex manifold")
125+
, Result([], "component_meshes_nb_non_manifold_edges", "Model component meshes edge manifold")
126+
]
127+
component_meshes_intersection = [
128+
Result([], "intersecting_surfaces_elements", "Pairs of component meshes triangles intersecting")
129+
]
130+
131+
if object == "brep":
132+
brep_component_meshes_adjacency = component_meshes_adjacency
133+
brep_component_meshes_adjacency.append(Result([], "blocks_nb_facets_with_wrong_adjacencies", "Model component meshes facet adjacencies"))
134+
135+
brep_component_meshes_manifold = component_meshes_manifold
136+
brep_component_meshes_manifold.append(Result([], "component_meshes_nb_non_manifold_facets", "Model component meshes facet manifold"))
137+
138+
ComponentMeshesTests = [
139+
Result(brep_component_meshes_adjacency, "Adjacency")
140+
, Result(component_meshes_colocation, "Colocation")
141+
, Result(component_meshes_degeneration, "Degeneration")
142+
, Result(brep_component_meshes_manifold, "Manifold")
143+
, Result(component_meshes_intersection, "Intersections")
144+
]
145+
146+
elif object == "section":
147+
148+
ComponentMeshesTests = [
149+
Result(component_meshes_adjacency, "Adjacency")
150+
, Result(component_meshes_colocation, "Colocation")
151+
, Result(component_meshes_degeneration, "Degeneration")
152+
, Result(component_meshes_manifold, "Manifold")
153+
]
154+
155+
Wrapper_ComponentMeshesTests = Result(ComponentMeshesTests, "Component Meshes")
156+
return Wrapper_ComponentMeshesTests
157+
158+
def inspectors():
159+
160+
BRep_Tests = [Result([TopologyTests("brep"), ComponentMeshesTests("brep")], "BRep")]
161+
CrossSection_Tests = [Result([TopologyTests("section"), ComponentMeshesTests("section")], "CrossSection")]
162+
EdgedCurve2D_Tests = [Result([ColocationTests(), DegenerationTests()], "EdgedCurve2D")]
163+
EdgedCurve3D_Tests = [Result([ColocationTests(), DegenerationTests()], "EdgedCurve3D")]
164+
Graph_Tests = [Result([], "Graph", value=True)]
165+
HybridSolid3D_Tests = [Result([AdjacencyTests("facets"), ColocationTests(), DegenerationTests(), ManifoldTests(["edges", "facets", "vertices"])], "HybridSolid3D")]
166+
PointSet2D_Tests = [Result([ColocationTests()], "PointSet2D", value=True)]
167+
PointSet3D_Tests = [Result([ColocationTests()], "PointSet3D", value=True)]
168+
PolygonalSurface2D_Tests = [Result([AdjacencyTests("edges"), ColocationTests(), DegenerationTests(), ManifoldTests(["edges", "vertices"])], "PolygonalSurface2D")]
169+
PolygonalSurface3D_Tests = [Result([AdjacencyTests("edges"), ColocationTests(), DegenerationTests(), ManifoldTests(["edges", "vertices"])], "PolygonalSurface3D")]
170+
PolyhedralSolid3D_Tests = [Result([AdjacencyTests("facets"), ColocationTests(), DegenerationTests(), ManifoldTests(["edges", "facets", "vertices"])], "PolyhedralSolid3D")]
171+
RegularGrid2D_Tests = [Result([], "RegularGrid2D", value=True)]
172+
RegularGrid3D_Tests = [Result([], "RegularGrid3D", value=True)]
173+
Section_Tests = [Result([TopologyTests("section"), ComponentMeshesTests("section")], "Section")]
174+
StructuralModel_Tests = [Result([TopologyTests("brep"), ComponentMeshesTests("brep")], "StructuralModel")]
175+
TetrahedralSolid3D_Tests = [Result([AdjacencyTests("facets"), ColocationTests(), DegenerationTests(), ManifoldTests(["edges", "facets", "vertices"])], "TetrahedralSolid3D")]
176+
TriangulatedSurface2D_Tests = [Result([AdjacencyTests("edges"), ColocationTests(), DegenerationTests(), ManifoldTests(["edges", "vertices"]),IntersectionTests()], "TriangulatedSurface2D")]
177+
TriangulatedSurface3D_Tests = [Result([AdjacencyTests("edges"), ColocationTests(), DegenerationTests(), ManifoldTests(["edges", "vertices"]),IntersectionTests()], "TriangulatedSurface3D")]
178+
VertexSet_Tests = [Result([], "VertexSet", value=True)]
179+
180+
return {
181+
"BRep": { "inspector": inspector.BRepInspector, "tests_names": BRep_Tests }
182+
, "CrossSection": { "inspector": inspector.SectionInspector, "tests_names": CrossSection_Tests }
183+
, "EdgedCurve2D": { "inspector": inspector.EdgedCurveInspector2D, "tests_names": EdgedCurve2D_Tests }
184+
, "EdgedCurve3D": { "inspector": inspector.EdgedCurveInspector3D, "tests_names": EdgedCurve3D_Tests }
185+
, "Graph": { "inspector": "", "tests_names": Graph_Tests }
186+
, "HybridSolid3D": { "inspector": inspector.SolidMeshInspector3D, "tests_names": HybridSolid3D_Tests }
187+
, "PointSet2D": { "inspector": inspector.PointSetInspector2D, "tests_names": PointSet2D_Tests }
188+
, "PointSet3D": { "inspector": inspector.PointSetInspector3D, "tests_names": PointSet3D_Tests }
189+
, "PolygonalSurface2D": { "inspector": inspector.SurfaceMeshInspector2D, "tests_names": PolygonalSurface2D_Tests }
190+
, "PolygonalSurface3D": { "inspector": inspector.SurfaceMeshInspector3D, "tests_names": PolygonalSurface3D_Tests }
191+
, "PolyhedralSolid3D": { "inspector": inspector.SolidMeshInspector3D, "tests_names": PolyhedralSolid3D_Tests }
192+
, "RegularGrid2D": { "inspector": "", "tests_names": RegularGrid2D_Tests }
193+
, "RegularGrid3D": { "inspector": "", "tests_names": RegularGrid3D_Tests }
194+
, "Section": { "inspector": inspector.SectionInspector, "tests_names": Section_Tests }
195+
, "StructuralModel": { "inspector": inspector.BRepInspector, "tests_names": StructuralModel_Tests }
196+
, "TetrahedralSolid3D": { "inspector": inspector.SolidMeshInspector3D, "tests_names": TetrahedralSolid3D_Tests }
197+
, "TriangulatedSurface2D": { "inspector": inspector.TriangulatedSurfaceInspector2D, "tests_names": TriangulatedSurface2D_Tests }
198+
, "TriangulatedSurface3D": { "inspector": inspector.TriangulatedSurfaceInspector3D, "tests_names": TriangulatedSurface3D_Tests }
199+
, "VertexSet": { "inspector": "", "tests_names": VertexSet_Tests }
200+
}
201+
202+
203+
def expected_results():
204+
return {
205+
"blocks_nb_facets_with_wrong_adjacencies" : {}
206+
, "colocated_unique_vertices_groups" : []
207+
, "components_nb_colocated_points" : {}
208+
, "components_nb_degenerated_elements" : {}
209+
, "component_meshes_nb_non_manifold_edges" : {}
210+
, "component_meshes_nb_non_manifold_facets": {}
211+
, "component_meshes_nb_non_manifold_vertices" : {}
212+
, "line_corners_without_boundary_status" : []
213+
, "intersecting_elements": []
214+
, "intersecting_surfaces_elements": []
215+
, "multiple_corners_unique_vertices" : []
216+
, "multiple_internals_corner_vertices" : []
217+
, "nb_blocks_meshed_but_not_linked_to_a_unique_vertex" : 0
218+
, "nb_colocated_points" : 0
219+
, "nb_corners_not_linked_to_a_unique_vertex" : 0
220+
, "nb_degenerated_edges" : 0
221+
, "nb_edges_with_wrong_adjacency" : 0
222+
, "nb_facets_with_wrong_adjacency" : 0
223+
, "nb_lines_meshed_but_not_linked_to_a_unique_vertex" : 0
224+
, "nb_non_manifold_edges" : 0
225+
, "nb_non_manifold_facets" : 0
226+
, "nb_non_manifold_vertices" : 0
227+
, "nb_surfaces_meshed_but_not_linked_to_a_unique_vertex" : 0
228+
, "not_internal_nor_boundary_corner_vertices" : []
229+
, "part_of_not_boundary_nor_internal_line_unique_vertices" : []
230+
, "part_of_invalid_unique_line_unique_vertices" : []
231+
, "part_of_line_and_not_on_surface_border_unique_vertices" : []
232+
, "part_of_invalid_blocks_unique_vertices" : []
233+
, "part_of_invalid_multiple_surfaces_unique_vertices" : []
234+
, "part_of_invalid_surfaces_unique_vertices": []
235+
, "part_of_invalid_unique_surface_unique_vertices" : []
236+
, "part_of_surface_with_invalid_internal_topology_unique_vertices" : []
237+
, "part_of_line_with_invalid_internal_topology_unique_vertices" : []
238+
, "part_of_lines_but_not_corner_unique_vertices" : []
239+
, "part_of_not_boundary_nor_internal_surface_unique_vertices" : []
240+
, "surfaces_nb_edges_with_wrong_adjacencies" : {}
241+
, "unique_vertices_linked_to_different_points" : []
242+
, "unique_vertices_not_linked_to_a_component_vertex" : []
243+
}

0 commit comments

Comments
 (0)