Skip to content

Commit 640b94c

Browse files
committed
Merge branch 'next' of https://github.com/Geode-solutions/OpenGeode into generic-search-in-aabbtree
2 parents 9a40e5d + 8054388 commit 640b94c

File tree

15 files changed

+551
-113
lines changed

15 files changed

+551
-113
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2019 - 2025 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+
24+
#pragma once
25+
26+
#include <geode/basic/mapping.hpp>
27+
28+
#include <geode/mesh/common.hpp>
29+
30+
namespace geode
31+
{
32+
FORWARD_DECLARATION_DIMENSION_CLASS( SolidMesh );
33+
FORWARD_DECLARATION_DIMENSION_CLASS( SolidMeshBuilder );
34+
} // namespace geode
35+
36+
namespace geode
37+
{
38+
namespace detail
39+
{
40+
template < index_t dimension >
41+
GenericMapping< index_t > repair_non_manifold_vertices(
42+
const SolidMesh< dimension >& mesh,
43+
SolidMeshBuilder< dimension >& builder );
44+
} // namespace detail
45+
} // namespace geode
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2019 - 2025 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+
24+
#pragma once
25+
26+
#include <geode/basic/mapping.hpp>
27+
28+
#include <geode/mesh/common.hpp>
29+
30+
namespace geode
31+
{
32+
FORWARD_DECLARATION_DIMENSION_CLASS( SurfaceMesh );
33+
FORWARD_DECLARATION_DIMENSION_CLASS( SurfaceMeshBuilder );
34+
} // namespace geode
35+
36+
namespace geode
37+
{
38+
namespace detail
39+
{
40+
template < index_t dimension >
41+
GenericMapping< index_t > repair_non_manifold_vertices(
42+
const SurfaceMesh< dimension >& mesh,
43+
SurfaceMeshBuilder< dimension >& builder );
44+
} // namespace detail
45+
} // namespace geode

include/geode/model/helpers/detail/mappings_merger.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ namespace geode
4141
[[nodiscard]] ModelGenericMapping opengeode_model_api
4242
copy_to_generic_mappings( const ModelCopyMapping& mappings2 );
4343

44-
[[nodiscard]] ModelMappings opengeode_model_api merge_mappings(
45-
const ModelMappings& mappings1, const ModelMappings& mappings2 );
44+
[[nodiscard]] SectionMappings opengeode_model_api merge_mappings(
45+
const SectionMappings& mappings1,
46+
const SectionMappings& mappings2 );
47+
48+
[[nodiscard]] BRepMappings opengeode_model_api merge_mappings(
49+
const BRepMappings& mappings1, const BRepMappings& mappings2 );
4650
} // namespace detail
4751
} // namespace geode
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (c) 2019 - 2025 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+
24+
#pragma once
25+
26+
#include <geode/basic/mapping.hpp>
27+
28+
#include <geode/model/common.hpp>
29+
30+
namespace geode
31+
{
32+
class BRep;
33+
class BRepBuilder;
34+
FORWARD_DECLARATION_DIMENSION_CLASS( Block );
35+
ALIAS_3D( Block );
36+
} // namespace geode
37+
38+
namespace geode
39+
{
40+
namespace detail
41+
{
42+
GenericMapping< index_t >
43+
opengeode_model_api repair_non_manifold_vertices(
44+
const BRep& model, BRepBuilder& builder, const Block3D& block );
45+
} // namespace detail
46+
} // namespace geode

include/geode/model/helpers/detail/surface_mesh_validity_fix.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#pragma once
2525

26+
#include <geode/basic/mapping.hpp>
27+
2628
#include <geode/model/common.hpp>
2729

2830
namespace geode
@@ -35,7 +37,9 @@ namespace geode
3537
namespace detail
3638
{
3739
template < typename Model >
38-
void repair_non_manifold_vertices(
39-
Model& model, const Surface< Model::dim >& surface );
40+
GenericMapping< index_t > repair_non_manifold_vertices(
41+
const Model& model,
42+
typename Model::Builder& builder,
43+
const Surface< Model::dim >& surface );
4044
} // namespace detail
4145
} // namespace geode

include/geode/model/representation/core/mapping.hpp

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
#include <geode/model/mixin/core/component_mesh_element.hpp>
3535
#include <geode/model/mixin/core/vertex_identifier.hpp>
3636

37+
namespace geode
38+
{
39+
class Section;
40+
class BRep;
41+
} // namespace geode
42+
3743
namespace geode
3844
{
3945
template < typename MappingType >
@@ -126,6 +132,23 @@ namespace geode
126132
MeshElementMapping blocks;
127133
};
128134

135+
template < typename Model >
136+
struct TypedModelMeshesElementMapping
137+
{
138+
};
139+
140+
template <>
141+
struct TypedModelMeshesElementMapping< Section >
142+
{
143+
using type = SectionMeshesElementMapping;
144+
};
145+
146+
template <>
147+
struct TypedModelMeshesElementMapping< BRep >
148+
{
149+
using type = BRepMeshesElementMapping;
150+
};
151+
129152
struct ModelMeshesVertexMapping
130153
{
131154
MeshVertexMapping corners;
@@ -142,19 +165,62 @@ namespace geode
142165
MeshVertexMapping blocks;
143166
};
144167

145-
struct ModelMappings
168+
template < typename Model >
169+
struct TypedModelMeshesVertexMapping
170+
{
171+
};
172+
173+
template <>
174+
struct TypedModelMeshesVertexMapping< Section >
175+
{
176+
using type = SectionMeshesVertexMapping;
177+
};
178+
179+
template <>
180+
struct TypedModelMeshesVertexMapping< BRep >
181+
{
182+
using type = BRepMeshesVertexMapping;
183+
};
184+
185+
struct ModelComponentMappings
146186
{
147187
ModelGenericMapping component_mapping;
148188
ModelAddedComponentMapping added_components;
149189
ModelUnchangedComponentMapping unchanged_components;
190+
};
191+
192+
struct [[deprecated]] ModelMappings : public ModelComponentMappings
193+
{
150194
ModelMeshesElementMapping mesh_element_mapping;
151195
ModelMeshesVertexMapping mesh_vertices_mapping;
152196
};
153197

154-
struct BRepMappings
198+
struct SectionMappings : public ModelComponentMappings
199+
{
200+
ModelMeshesElementMapping mesh_element_mapping;
201+
ModelMeshesVertexMapping mesh_vertices_mapping;
202+
};
203+
204+
struct BRepMappings : public ModelComponentMappings
155205
{
156-
ModelGenericMapping component_mapping;
157206
BRepMeshesElementMapping mesh_element_mapping;
158207
BRepMeshesVertexMapping mesh_vertices_mapping;
159208
};
209+
210+
template < typename Model >
211+
struct TypedModelMappings
212+
{
213+
};
214+
215+
template <>
216+
struct TypedModelMappings< Section >
217+
{
218+
using type = SectionMappings;
219+
};
220+
221+
template <>
222+
struct TypedModelMappings< BRep >
223+
{
224+
using type = BRepMappings;
225+
};
160226
} // namespace geode

src/geode/mesh/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ add_geode_library(
127127
"helpers/detail/mesh_intersection_detection.cpp"
128128
"helpers/detail/point_set_merger.cpp"
129129
"helpers/detail/solid_merger.cpp"
130+
"helpers/detail/solid_mesh_validity_fix.cpp"
130131
"helpers/detail/split_along_solid_facets.cpp"
131132
"helpers/detail/surface_merger.cpp"
133+
"helpers/detail/surface_mesh_validity_fix.cpp"
132134
"helpers/detail/vertex_merger.cpp"
133135
"helpers/internal/copy.cpp"
134136
"helpers/internal/grid_shape_function.cpp"
@@ -316,8 +318,10 @@ add_geode_library(
316318
"helpers/detail/mesh_intersection_detection.hpp"
317319
"helpers/detail/point_set_merger.hpp"
318320
"helpers/detail/solid_merger.hpp"
321+
"helpers/detail/solid_mesh_validity_fix.hpp"
319322
"helpers/detail/split_along_solid_facets.hpp"
320323
"helpers/detail/surface_merger.hpp"
324+
"helpers/detail/surface_mesh_validity_fix.hpp"
321325
"helpers/detail/vertex_merger.hpp"
322326
INTERNAL_HEADERS
323327
"core/internal/edges_impl.hpp"

src/geode/mesh/builder/solid_mesh_builder.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,11 @@ namespace
204204
vertices_old2new[solid.polyhedron_vertex( { p, v } )];
205205
OPENGEODE_EXCEPTION( new_vertex != geode::NO_ID,
206206
"[SolidMesh::update_polyhedron_vertices] No polyhedron "
207-
"should be removed" );
207+
"should be removed (",
208+
p, ", ", v, " -> ", solid.polyhedron_vertex( { p, v } ),
209+
" located at ",
210+
solid.point( solid.polyhedron_vertex( { p, v } ) ).string(),
211+
")" );
208212
}
209213
}
210214
}

0 commit comments

Comments
 (0)