Skip to content

Commit 30ba18b

Browse files
authored
Merge pull request #1176 from Geode-solutions/fix/unsegmentation
Fix/unsegmentation
2 parents e3e8fd9 + 15bde22 commit 30ba18b

File tree

7 files changed

+114
-0
lines changed

7 files changed

+114
-0
lines changed

commitlint.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export default {
2+
extends: ["@commitlint/config-angular"],
3+
rules: {
4+
"scope-empty": [2, "never"],
5+
"subject-empty": [2, "never"],
6+
"subject-max-length": [0],
7+
"body-leading-blank": [0],
8+
"footer-leading-blank": [0],
9+
"header-max-length": [0],
10+
"scope-case": [0],
11+
"subject-case": [0],
12+
"subject-full-stop": [0],
13+
"type-case": [0],
14+
"type-empty": [0],
15+
},
16+
}

include/geode/mesh/core/solid_mesh.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,15 @@ namespace geode
210210

211211
using PolyhedronFacetVertices = absl::InlinedVector< index_t, 3 >;
212212

213+
using PolyhedronFacetLocalVertices =
214+
absl::InlinedVector< local_index_t, 3 >;
215+
213216
using PolyhedronFacetsVertices =
214217
absl::InlinedVector< PolyhedronFacetVertices, 4 >;
215218

219+
using PolyhedronFacetsLocalVertices =
220+
absl::InlinedVector< PolyhedronFacetLocalVertices, 4 >;
221+
216222
using PolyhedronVertices = absl::InlinedVector< index_t, 4 >;
217223

218224
using PolyhedronFacets = absl::InlinedVector< PolyhedronFacet, 4 >;
@@ -349,6 +355,9 @@ namespace geode
349355
[[nodiscard]] virtual PolyhedronFacetsVertices
350356
polyhedron_facets_vertices( index_t polyhedron ) const;
351357

358+
[[nodiscard]] virtual PolyhedronFacetsLocalVertices
359+
polyhedron_facets_local_vertices( index_t polyhedron ) const;
360+
352361
[[nodiscard]] virtual PolyhedronFacets polyhedron_vertex_facets(
353362
const PolyhedronVertex& polyhedron_vertex ) const;
354363

include/geode/mesh/core/tetrahedral_solid.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ namespace geode
7373
[[nodiscard]] PolyhedronFacetsVertices polyhedron_facets_vertices(
7474
index_t polyhedron ) const final;
7575

76+
[[nodiscard]] PolyhedronFacetsLocalVertices
77+
polyhedron_facets_local_vertices( index_t polyhedron ) const final;
78+
7679
[[nodiscard]] typename SolidMesh< dimension >::VerticesAroundVertex
7780
vertices_around_vertex( index_t vertex_id ) const final;
7881

include/geode/model/helpers/component_mesh_polygons.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,5 +213,10 @@ namespace geode
213213
opengeode_model_api
214214
block_component_mesh_polygons( const BRep& brep,
215215
const PolygonVertices& polygon_unique_vertices );
216+
217+
[[nodiscard]] std::vector< PolyhedronFacet >
218+
opengeode_model_api block_component_mesh_polygons( const BRep& brep,
219+
const PolygonVertices& polygon_unique_vertices,
220+
const Block3D& block );
216221
} // namespace detail
217222
} // namespace geode

src/geode/mesh/core/solid_mesh.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,27 @@ namespace geode
13411341
return facets_vertices;
13421342
}
13431343

1344+
template < index_t dimension >
1345+
PolyhedronFacetsLocalVertices
1346+
SolidMesh< dimension >::polyhedron_facets_local_vertices(
1347+
index_t polyhedron ) const
1348+
{
1349+
PolyhedronFacetsLocalVertices facets_vertices;
1350+
facets_vertices.reserve( nb_polyhedron_facets( polyhedron ) );
1351+
for( const auto f : LRange{ nb_polyhedron_facets( polyhedron ) } )
1352+
{
1353+
const PolyhedronFacet facet{ polyhedron, f };
1354+
auto& facet_vertices = facets_vertices.emplace_back();
1355+
for( const auto v :
1356+
LRange{ nb_polyhedron_facet_vertices( facet ) } )
1357+
{
1358+
facet_vertices.push_back(
1359+
polyhedron_facet_vertex_id( { facet, v } ).vertex_id );
1360+
}
1361+
}
1362+
return facets_vertices;
1363+
}
1364+
13441365
template < index_t dimension >
13451366
PolyhedronFacets SolidMesh< dimension >::polyhedron_vertex_facets(
13461367
const PolyhedronVertex& polyhedron_vertex ) const

src/geode/mesh/core/tetrahedral_solid.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,20 @@ namespace geode
449449
return result;
450450
}
451451

452+
template < index_t dimension >
453+
PolyhedronFacetsLocalVertices
454+
TetrahedralSolid< dimension >::polyhedron_facets_local_vertices(
455+
index_t /*unused*/ ) const
456+
{
457+
PolyhedronFacetsLocalVertices result;
458+
for( const auto& facet : detail::TETRAHEDRON_FACET_VERTICES )
459+
{
460+
result.emplace_back(
461+
PolyhedronFacetLocalVertices{ facet[0], facet[1], facet[2] } );
462+
}
463+
return result;
464+
}
465+
452466
template < index_t dimension >
453467
std::optional< PolyhedronFacet >
454468
TetrahedralSolid< dimension >::polyhedron_adjacent_facet(

src/geode/model/helpers/component_mesh_polygons.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,24 @@ namespace
560560
unique_vertices, type );
561561
}
562562

563+
template < typename Model >
564+
geode::ComponentMeshVertexGeneric< 3 > model_polygon_pairs(
565+
const Model& model,
566+
const geode::PolygonVertices& polygon_unique_vertices,
567+
const geode::ComponentID& component )
568+
{
569+
std::vector< absl::Span< const geode::ComponentMeshVertex > >
570+
unique_vertices;
571+
unique_vertices.reserve( polygon_unique_vertices.size() );
572+
for( const auto polygon_unique_vertex : polygon_unique_vertices )
573+
{
574+
unique_vertices.emplace_back(
575+
model.component_mesh_vertices( polygon_unique_vertex ) );
576+
}
577+
return geode::component_mesh_vertex_generic< 3 >(
578+
unique_vertices, component );
579+
}
580+
563581
template < typename Model >
564582
void model_component_mesh_polygons(
565583
geode::ModelComponentMeshPolygons& polygons,
@@ -673,6 +691,34 @@ namespace geode
673691
return polygons;
674692
}
675693

694+
std::vector< PolyhedronFacet > block_component_mesh_polygons(
695+
const BRep& model,
696+
const PolygonVertices& polygon_unique_vertices,
697+
const Block3D& block )
698+
{
699+
const auto block_pairs = model_polygon_pairs(
700+
model, polygon_unique_vertices, block.component_id() );
701+
if( !block_pairs.contains( block.component_id() ) )
702+
{
703+
return {};
704+
}
705+
std::vector< PolyhedronFacet > facets;
706+
const auto& mesh = block.mesh();
707+
for( const auto& pair : block_pairs.at( block.component_id() ) )
708+
{
709+
if( auto facet = mesh.polyhedron_facet_from_vertices( pair ) )
710+
{
711+
facets.emplace_back( std::move( facet.value() ) );
712+
if( auto adj =
713+
mesh.polyhedron_adjacent_facet( facet.value() ) )
714+
{
715+
facets.emplace_back( std::move( adj.value() ) );
716+
}
717+
}
718+
}
719+
geode::sort_unique( facets );
720+
return facets;
721+
}
676722
} // namespace detail
677723

678724
PolygonVertices polygon_unique_vertices(

0 commit comments

Comments
 (0)