Skip to content

Commit c21fb2f

Browse files
committed
Merge remote-tracking branch 'origin/next' into fix/modify-component-mesh-edges-method
2 parents 92f0d2a + aeda0c7 commit c21fb2f

17 files changed

+779
-389
lines changed

cmake/CppTargets.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ function(add_geode_library)
5858
)
5959
endforeach()
6060
set(PROJECT_LIB_NAME ${PROJECT_NAME}::${GEODE_LIB_NAME})
61-
set(VERSION_RC_FILE ${PROJECT_BINARY_DIR}/${GEODE_LIB_FOLDER}/version.rc)
62-
if(EXISTS ${VERSION_RC_FILE})
61+
set(VERSION_RC_FILE_IN ${PROJECT_SOURCE_DIR}/cmake/version.rc.in)
62+
if(EXISTS ${VERSION_RC_FILE_IN})
6363
message(STATUS "Configuring version.rc")
64+
set(VERSION_RC_FILE ${PROJECT_BINARY_DIR}/${GEODE_LIB_FOLDER}/version.rc)
6465
configure_file(
65-
${PROJECT_SOURCE_DIR}/cmake/version.rc.in
66+
${VERSION_RC_FILE_IN}
6667
${VERSION_RC_FILE}
6768
@ONLY
6869
)

include/geode/mesh/core/detail/facet_storage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ namespace geode
115115
for( const auto e :
116116
Range{ facet_attribute_manager_.nb_elements() } )
117117
{
118-
to_delete[e] = !counter_->value( e );
118+
to_delete[e] = counter_->value( e ) == 0;
119119
}
120120
return delete_facets( to_delete );
121121
}

include/geode/mesh/core/grid.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,27 @@ namespace geode
170170
IMPLEMENTATION_MEMBER( impl_ );
171171
};
172172
ALIAS_2D_AND_3D( Grid );
173+
174+
namespace detail
175+
{
176+
static constexpr std::array< std::array< geode::local_index_t, 2 >, 12 >
177+
CELL_EDGE_VERTICES_3D{ { { 0, 1 }, { 0, 2 }, { 2, 3 }, { 1, 3 },
178+
{ 4, 5 }, { 4, 6 }, { 6, 7 }, { 5, 7 }, { 0, 4 }, { 1, 5 },
179+
{ 2, 6 }, { 3, 7 } } };
180+
181+
static constexpr std::array< std::array< geode::local_index_t, 4 >, 6 >
182+
CELL_FACET_VERTICES_3D{ { { 0, 4, 6, 2 }, { 1, 5, 7, 3 },
183+
{ 0, 4, 5, 1 }, { 2, 3, 7, 6 }, { 0, 1, 3, 2 },
184+
{ 4, 6, 7, 5 } } };
185+
186+
static constexpr std::array< std::array< geode::local_index_t, 3 >, 8 >
187+
CELL_EDGES_AROUND_VERTEX_3D{ { { 0, 1, 8 }, { 0, 3, 9 },
188+
{ 1, 2, 10 }, { 2, 3, 11 }, { 4, 5, 8 }, { 4, 7, 9 },
189+
{ 5, 6, 10 }, { 6, 7, 11 } } };
190+
191+
static constexpr std::array< std::array< geode::local_index_t, 3 >, 8 >
192+
CELL_FACETS_AROUND_VERTEX_3D{ { { 0, 2, 4 }, { 1, 2, 4 },
193+
{ 0, 3, 4 }, { 1, 3, 4 }, { 0, 2, 5 }, { 1, 2, 5 }, { 0, 3, 5 },
194+
{ 1, 3, 5 } } };
195+
} // namespace detail
173196
} // namespace geode
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2019 - 2024 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.h>
27+
28+
#include <geode/mesh/common.h>
29+
30+
namespace geode
31+
{
32+
using ElementsMapping = GenericMapping< index_t, index_t >;
33+
34+
struct MeshesElementsMapping
35+
{
36+
ElementsMapping vertices;
37+
ElementsMapping edges;
38+
ElementsMapping polygons;
39+
ElementsMapping polyhedra;
40+
};
41+
} // namespace geode
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (c) 2019 - 2024 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 <absl/types/span.h>
27+
28+
#include <geode/basic/pimpl.h>
29+
30+
#include <geode/mesh/common.h>
31+
#include <geode/mesh/core/meshes_mapping.h>
32+
33+
namespace geode
34+
{
35+
FORWARD_DECLARATION_DIMENSION_CLASS( SolidMesh );
36+
FORWARD_DECLARATION_DIMENSION_CLASS( SolidMeshBuilder );
37+
ALIAS_3D( SolidMesh );
38+
ALIAS_3D( SolidMeshBuilder );
39+
} // namespace geode
40+
41+
namespace geode
42+
{
43+
namespace detail
44+
{
45+
class opengeode_mesh_api SplitAlongSolidFacets
46+
{
47+
public:
48+
SplitAlongSolidFacets(
49+
const SolidMesh3D& mesh, SolidMeshBuilder3D& builder );
50+
~SplitAlongSolidFacets();
51+
52+
/*
53+
* Splits the solid along given facets, and returns the mapping on
54+
* vertices and facets.
55+
*/
56+
MeshesElementsMapping split_solid_along_facets(
57+
absl::Span< const PolyhedronFacet > facets_list );
58+
59+
private:
60+
IMPLEMENTATION_MEMBER( impl_ );
61+
};
62+
} // namespace detail
63+
} // namespace geode

include/geode/model/helpers/detail/cut_along_internal_surfaces.h renamed to include/geode/model/helpers/detail/split_along_block_mesh_borders.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,30 @@ namespace geode
4040
{
4141
namespace detail
4242
{
43-
class opengeode_model_api CutAlongInternalSurfaces
43+
class opengeode_model_api SplitAlongBlockMeshBorders
4444
{
4545
public:
46-
CutAlongInternalSurfaces( BRep& model );
47-
CutAlongInternalSurfaces( const BRep& model, BRepBuilder& builder );
48-
~CutAlongInternalSurfaces();
46+
SplitAlongBlockMeshBorders(
47+
const BRep& model, BRepBuilder& builder );
48+
~SplitAlongBlockMeshBorders();
4949

50-
/* Cuts the blocks along internal surfaces, and returns pairs of
50+
/* Splits the blocks along internal surfaces, facets without
51+
* adjacencies and non manifold vertices, and returns pairs of
5152
* component mesh vertices where the blocks vertices were split
5253
* (first the initial cmv of the vertices, second the cmv of the
5354
* newly created vertex)
5455
*/
5556
std::vector< std::pair< ComponentMeshVertex, ComponentMeshVertex > >
56-
cut_all_blocks();
57+
split_all_blocks();
5758

58-
/* Cuts the block along internal surfaces, and returns pairs of
59+
/* Splits the block along internal surfaces, facets without
60+
* adjacencies and non manifold vertices, and returns pairs of
5961
* component mesh vertices where the block vertices were split
6062
* (first the initial id of the vertices, second the id of the newly
6163
* created vertex)
6264
*/
6365
std::vector< std::pair< ComponentMeshVertex, ComponentMeshVertex > >
64-
cut_block( const Block3D& block );
66+
split_block( const Block3D& block );
6567

6668
private:
6769
IMPLEMENTATION_MEMBER( impl_ );

include/geode/model/helpers/detail/cut_along_internal_lines.h renamed to include/geode/model/helpers/detail/split_along_surface_mesh_borders.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,29 @@ namespace geode
3838
namespace detail
3939
{
4040
template < typename Model >
41-
class CutAlongInternalLines
41+
class SplitAlongSurfaceMeshBorders
4242
{
4343
public:
44-
CutAlongInternalLines( Model& model );
45-
CutAlongInternalLines(
44+
SplitAlongSurfaceMeshBorders( Model& model );
45+
SplitAlongSurfaceMeshBorders(
4646
const Model& model, typename Model::Builder& builder );
47-
~CutAlongInternalLines();
47+
~SplitAlongSurfaceMeshBorders();
4848

49-
/* Cuts the surfaces along internal lines, and returns pairs of
49+
/* Splits the surfaces along internal lines, and returns pairs of
5050
* component mesh vertices where the surfaces vertices were split
5151
* (first the initial cmv of the vertices, second the cmv of the
5252
* newly created vertex)
5353
*/
5454
std::vector< std::pair< ComponentMeshVertex, ComponentMeshVertex > >
55-
cut_all_surfaces();
55+
split_all_surfaces();
5656

57-
/* Cuts the surface along internal lines, and returns pairs of
57+
/* Splits the surface along internal lines, and returns pairs of
5858
* component mesh vertices where the surface vertices were split
5959
* (first the initial id of the vertices, second the id of the newly
6060
* created vertex)
6161
*/
6262
std::vector< std::pair< ComponentMeshVertex, ComponentMeshVertex > >
63-
cut_surface( const Surface< Model::dim >& surface );
63+
split_surface( const Surface< Model::dim >& surface );
6464

6565
private:
6666
IMPLEMENTATION_MEMBER( impl_ );

src/geode/mesh/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ add_geode_library(
117117
"helpers/detail/component_identifier.cpp"
118118
"helpers/detail/create_mesh.cpp"
119119
"helpers/detail/curve_merger.cpp"
120+
"helpers/detail/split_along_solid_facets.cpp"
120121
"helpers/detail/debug.cpp"
121122
"helpers/detail/element_identifier.cpp"
122123
"helpers/detail/solid_merger.cpp"
@@ -298,6 +299,7 @@ add_geode_library(
298299
"core/detail/geode_elements.h"
299300
"core/detail/vertex_cycle.h"
300301
"helpers/detail/curve_merger.h"
302+
"helpers/detail/split_along_solid_facets.h"
301303
"helpers/detail/component_identifier.h"
302304
"helpers/detail/create_mesh.h"
303305
"helpers/detail/debug.h"

src/geode/mesh/builder/solid_mesh_builder.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -293,49 +293,49 @@ namespace
293293
}
294294
const auto position_it =
295295
absl::c_find( facet_vertices, polyhedron_vertex );
296-
if( position_it != facet_vertices.end() )
296+
if( position_it == facet_vertices.end() )
297297
{
298-
geode::PolyhedronFacetVertices facet_vertices_id;
299-
facet_vertices_id.reserve( nb_facet_vertices );
300-
for( const auto& v : facet_vertices )
301-
{
302-
facet_vertices_id.emplace_back(
303-
solid.polyhedron_vertex( v ) );
304-
}
298+
continue;
299+
}
300+
geode::PolyhedronFacetVertices facet_vertices_id;
301+
facet_vertices_id.reserve( nb_facet_vertices );
302+
for( const auto& v : facet_vertices )
303+
{
304+
facet_vertices_id.emplace_back( solid.polyhedron_vertex( v ) );
305+
}
305306

306-
const auto position = static_cast< geode::index_t >(
307-
std::distance( facet_vertices.begin(), position_it ) );
307+
const auto position = static_cast< geode::index_t >(
308+
std::distance( facet_vertices.begin(), position_it ) );
308309

309-
if( solid.are_facets_enabled() )
310+
if( solid.are_facets_enabled() )
311+
{
312+
auto facets = builder.facets_builder();
313+
facets.update_facet_vertex(
314+
facet_vertices_id, position, new_vertex_id );
315+
}
316+
317+
if( solid.are_edges_enabled() )
318+
{
319+
auto edges = builder.edges_builder();
320+
const auto next =
321+
position + 1 == nb_facet_vertices ? 0 : position + 1;
322+
std::array< geode::index_t, 2 > next_edge_vertices{
323+
facet_vertices_id[position], facet_vertices_id[next]
324+
};
325+
if( next_edge_vertices[0] < next_edge_vertices[1] )
310326
{
311-
auto facets = builder.facets_builder();
312-
facets.update_facet_vertex(
313-
facet_vertices_id, position, new_vertex_id );
327+
edges.update_edge_vertex(
328+
next_edge_vertices, 0, new_vertex_id );
314329
}
315-
316-
if( solid.are_edges_enabled() )
330+
const auto prev =
331+
position == 0 ? nb_facet_vertices - 1 : position - 1;
332+
std::array< geode::index_t, 2 > previous_edge_vertices{
333+
facet_vertices_id[prev], facet_vertices_id[position]
334+
};
335+
if( previous_edge_vertices[0] < previous_edge_vertices[1] )
317336
{
318-
auto edges = builder.edges_builder();
319-
const auto next =
320-
position + 1 == nb_facet_vertices ? 0 : position + 1;
321-
std::array< geode::index_t, 2 > next_edge_vertices{
322-
facet_vertices_id[position], facet_vertices_id[next]
323-
};
324-
if( next_edge_vertices[0] < next_edge_vertices[1] )
325-
{
326-
edges.update_edge_vertex(
327-
next_edge_vertices, 0, new_vertex_id );
328-
}
329-
const auto prev =
330-
position == 0 ? nb_facet_vertices - 1 : position - 1;
331-
std::array< geode::index_t, 2 > previous_edge_vertices{
332-
facet_vertices_id[prev], facet_vertices_id[position]
333-
};
334-
if( previous_edge_vertices[0] < previous_edge_vertices[1] )
335-
{
336-
edges.update_edge_vertex(
337-
previous_edge_vertices, 1, new_vertex_id );
338-
}
337+
edges.update_edge_vertex(
338+
previous_edge_vertices, 1, new_vertex_id );
339339
}
340340
}
341341
}

src/geode/mesh/core/solid_mesh.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,21 @@ namespace
191191
const geode::SolidMesh< dimension >& solid,
192192
const std::array< geode::index_t, 2 >& vertices )
193193
{
194-
for( const auto& polyhedron :
195-
solid.polyhedra_around_vertex( vertices[0] ) )
194+
for( const auto vertex : vertices )
196195
{
197-
for( const auto& edge_vertices :
198-
solid.polyhedron_edges_vertices( polyhedron.polyhedron_id ) )
196+
for( const auto& polyhedron :
197+
solid.polyhedra_around_vertex( vertex ) )
199198
{
200-
if( vertices == edge_vertices
201-
|| ( vertices[0] == edge_vertices[1]
202-
&& vertices[1] == edge_vertices[0] ) )
199+
for( const auto& edge_vertices :
200+
solid.polyhedron_edges_vertices(
201+
polyhedron.polyhedron_id ) )
203202
{
204-
return polyhedron.polyhedron_id;
203+
if( vertices == edge_vertices
204+
|| ( vertices[0] == edge_vertices[1]
205+
&& vertices[1] == edge_vertices[0] ) )
206+
{
207+
return polyhedron.polyhedron_id;
208+
}
205209
}
206210
}
207211
}
@@ -1142,6 +1146,7 @@ namespace geode
11421146
}
11431147
return result;
11441148
}
1149+
11451150
template < index_t dimension >
11461151
absl::optional< index_t > SolidMesh< dimension >::polyhedron_around_edge(
11471152
const std::array< index_t, 2 >& vertices ) const

0 commit comments

Comments
 (0)