Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace geode
InspectionIssuesMap< PolyhedronFacet >&
components_wrong_adjacencies ) const
{
for( const auto& block : model().blocks() )
for( const auto& block : model().active_blocks() )
{
const geode::SolidMeshAdjacency3D inspector{ block.mesh() };
auto wrong_adjacencies =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace
{
template < typename Model >
std::vector< std::vector< geode::index_t > >
filter_colocated_points_with_same_uuid( const Model& model,
filter_colocated_points_with_same_unique_vertex( const Model& model,
const geode::ComponentID& component_id,
absl::Span< const std::vector< geode::index_t > >
colocated_points_groups )
Expand Down Expand Up @@ -100,13 +100,13 @@ namespace
geode::InspectionIssuesMap< std::vector< geode::index_t > >&
components_colocated_points )
{
for( const auto& line : model.lines() )
for( const auto& line : model.active_lines() )
{
const geode::EdgedCurveColocation< Model::dim > inspector{
line.mesh()
};
auto colocated_pts =
filter_colocated_points_with_same_uuid< Model >( model,
filter_colocated_points_with_same_unique_vertex< Model >( model,
line.component_id(),
inspector.colocated_points_groups().issues() );
if( !colocated_pts.empty() )
Expand Down Expand Up @@ -135,13 +135,13 @@ namespace
line.id(), std::move( line_issues ) );
}
}
for( const auto& surface : model.surfaces() )
for( const auto& surface : model.active_surfaces() )
{
const geode::SurfaceMeshColocation< Model::dim > inspector{
surface.mesh()
};
auto colocated_pts =
filter_colocated_points_with_same_uuid< Model >( model,
filter_colocated_points_with_same_unique_vertex< Model >( model,
surface.component_id(),
inspector.colocated_points_groups().issues() );
if( !colocated_pts.empty() )
Expand Down Expand Up @@ -187,12 +187,12 @@ namespace
{
add_model_components_colocated_points_groups_base< geode::BRep >(
model, components_colocated_points );
for( const auto& block : model.blocks() )
for( const auto& block : model.active_blocks() )
{
const geode::SolidMeshColocation3D inspector{ block.mesh() };
auto colocated_pts =
filter_colocated_points_with_same_uuid< geode::BRep >( model,
block.component_id(),
filter_colocated_points_with_same_unique_vertex< geode::BRep >(
model, block.component_id(),
inspector.colocated_points_groups().issues() );
if( !colocated_pts.empty() )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,15 @@ namespace

template < typename Model >
bool model_cmvs_are_colocated_on_point( const Model& model,
const std::vector< geode::ComponentMeshVertex >& cmvs,
absl::Span< const geode::ComponentMeshVertex > cmvs,
const geode::Point< Model::dim >& point )
{
for( const auto& cmv : cmvs )
{
if( !model.component( cmv.component_id.id() ).is_active() )
{
continue;
}
if( !model_cmv_is_colocated_on_point( model, cmv, point ) )
{
return false;
Expand All @@ -108,40 +112,61 @@ namespace
}

template < typename Model >
geode::Point< Model::dim > model_unique_vertex_point_base(
geode::Point< Model::dim > model_cmv_point(
const Model& model, const geode::ComponentMeshVertex& cmv )
{
if( cmv.component_id.type()
== geode::Line< Model::dim >::component_type_static() )
{
const auto& mesh = model.line( cmv.component_id.id() ).mesh();
return mesh.point( cmv.vertex );
return model.line( cmv.component_id.id() )
.mesh()
.point( cmv.vertex );
}
if( cmv.component_id.type()
== geode::Surface< Model::dim >::component_type_static() )
{
const auto& mesh = model.surface( cmv.component_id.id() ).mesh();
return mesh.point( cmv.vertex );
return model.surface( cmv.component_id.id() )
.mesh()
.point( cmv.vertex );
}
const auto& mesh = model.corner( cmv.component_id.id() ).mesh();
return mesh.point( cmv.vertex );
return model.corner( cmv.component_id.id() ).mesh().point( cmv.vertex );
}

geode::Point2D model_unique_vertex_point(
const geode::Section& model, const geode::ComponentMeshVertex& cmv )
std::optional< geode::Point2D > model_unique_vertex_point(
const geode::Section& model,
absl::Span< const geode::ComponentMeshVertex > cmvs )
{
return model_unique_vertex_point_base< geode::Section >( model, cmv );
for( const auto& cmv : cmvs )
{
if( !model.component( cmv.component_id.id() ).is_active() )
{
continue;
}
return model_cmv_point< geode::Section >( model, cmv );
}
return std::nullopt;
}

geode::Point3D model_unique_vertex_point(
const geode::BRep& model, const geode::ComponentMeshVertex& cmv )
std::optional< geode::Point3D > model_unique_vertex_point(
const geode::BRep& model,
absl::Span< const geode::ComponentMeshVertex > cmvs )
{
if( cmv.component_id.type() == geode::Block3D::component_type_static() )
for( const auto& cmv : cmvs )
{
const auto& mesh = model.block( cmv.component_id.id() ).mesh();
return mesh.point( cmv.vertex );
if( !model.component( cmv.component_id.id() ).is_active() )
{
continue;
}
if( cmv.component_id.type()
== geode::Block3D::component_type_static() )
{
return model.block( cmv.component_id.id() )
.mesh()
.point( cmv.vertex );
}
return model_cmv_point< geode::BRep >( model, cmv );
}
return model_unique_vertex_point_base< geode::BRep >( model, cmv );
return std::nullopt;
}
} // namespace

Expand Down Expand Up @@ -170,22 +195,27 @@ namespace geode
public:
Impl( const Model& model )
: model_( model ),
unique_vertices_{ PointSet< Model::dim >::create() }
active_uv_pointset_{ PointSet< Model::dim >::create() }
{
auto builder =
PointSetBuilder< Model::dim >::create( *unique_vertices_ );
PointSetBuilder< Model::dim >::create( *active_uv_pointset_ );
builder->create_vertices( model.nb_unique_vertices() );
std::vector< bool > not_assigned(
model.nb_unique_vertices(), true );
for( const auto unique_vertex_id :
Range{ model.nb_unique_vertices() } )
{
const auto& cmvs =
model.component_mesh_vertices( unique_vertex_id );
if( cmvs.empty() )
if( auto point = model_unique_vertex_point( model,
model.component_mesh_vertices( unique_vertex_id ) ) )
{
continue;
builder->set_point( unique_vertex_id, point.value() );
not_assigned[unique_vertex_id] = false;
}
builder->set_point( unique_vertex_id,
model_unique_vertex_point( model, cmvs.at( 0 ) ) );
}
const auto old2new = builder->delete_vertices( not_assigned );
for( const auto old_index : Indices{ old2new } )
{
uv_to_active_uv_.map( old_index, old2new[old_index] );
}
}

Expand All @@ -194,9 +224,15 @@ namespace geode
for( const auto unique_vertex_id :
Range{ model_.nb_unique_vertices() } )
{
const auto active_uv_id =
uv_to_active_uv_.in2out( unique_vertex_id ).at( 0 );
if( active_uv_id == NO_ID )
{
continue;
}
if( !model_cmvs_are_colocated_on_point( model_,
model_.component_mesh_vertices( unique_vertex_id ),
unique_vertices_->point( unique_vertex_id ) ) )
active_uv_pointset_->point( active_uv_id ) ) )
{
return true;
}
Expand All @@ -207,7 +243,7 @@ namespace geode
bool model_has_colocated_unique_vertices() const
{
const PointSetColocation< Model::dim > pointset_inspector{
*unique_vertices_
*active_uv_pointset_
};
const auto has_colocation =
pointset_inspector.mesh_has_colocated_points();
Expand All @@ -220,9 +256,15 @@ namespace geode
for( const auto unique_vertex_id :
Range{ model_.nb_unique_vertices() } )
{
const auto active_uv_id =
uv_to_active_uv_.in2out( unique_vertex_id ).at( 0 );
if( active_uv_id == NO_ID )
{
continue;
}
if( !model_cmvs_are_colocated_on_point( model_,
model_.component_mesh_vertices( unique_vertex_id ),
unique_vertices_->point( unique_vertex_id ) ) )
active_uv_pointset_->point( active_uv_id ) ) )
{
vertices_issues.add_issue( unique_vertex_id,
absl::StrCat( "unique vertex ", unique_vertex_id,
Expand All @@ -236,41 +278,33 @@ namespace geode
InspectionIssues< std::vector< index_t > >& vertices_issues ) const
{
const PointSetColocation< Model::dim > pointset_inspector{
*unique_vertices_
*active_uv_pointset_
};
const auto colocated_pts_groups =
pointset_inspector.colocated_points_groups();
for( const auto& point_group : colocated_pts_groups.issues() )
{
std::vector< index_t > fixed_point_group;
std::string point_group_string;
for( const auto point_index : Indices{ point_group } )
{
if( model_
.component_mesh_vertices( point_group[point_index] )
.empty() )
{
continue;
}
fixed_point_group.push_back( point_group[point_index] );
absl::StrAppend(
&point_group_string, " ", point_group[point_index] );
}
if( !fixed_point_group.empty() )
for( const auto active_uv_index : point_group )
{
vertices_issues.add_issue( fixed_point_group,
absl::StrCat( "unique vertices ", point_group_string,
" are colocated at the position [",
unique_vertices_->point( fixed_point_group[0] )
.string(),
"]" ) );
const auto model_uv_index =
uv_to_active_uv_.out2in( active_uv_index ).at( 0 );
fixed_point_group.push_back( model_uv_index );
absl::StrAppend( &point_group_string, " ", model_uv_index );
}
vertices_issues.add_issue( fixed_point_group,
absl::StrCat( "unique vertices ", point_group_string,
" are colocated at the position [",
active_uv_pointset_->point( point_group[0] ).string(),
"]" ) );
}
}

private:
const Model& model_;
std::unique_ptr< PointSet< Model::dim > > unique_vertices_;
std::unique_ptr< PointSet< Model::dim > > active_uv_pointset_;
geode::GenericMapping< index_t > uv_to_active_uv_;
};

template < typename Model >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace geode
InspectionIssuesMap< index_t >& small_polyhedra_map,
double threshold ) const
{
for( const auto& block : model().blocks() )
for( const auto& block : model().active_blocks() )
{
const auto& mesh = block.mesh();
if( !mesh.are_edges_enabled() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace geode
InspectionIssuesMap< PolygonEdge >&
components_wrong_adjacencies ) const
{
for( const auto& surface : model_.surfaces() )
for( const auto& surface : model_.active_surfaces() )
{
const SurfaceMeshAdjacency< Model::dim > inspector{
surface.mesh()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ namespace geode
std::vector<
async::task< std::pair< uuid, InspectionIssues< index_t > > > >
line_tasks;
line_tasks.reserve( model_.nb_lines() );
for( const auto& line : model_.lines() )
line_tasks.reserve( model_.nb_active_lines() );
for( const auto& line : model_.active_lines() )
{
line_tasks.emplace_back( async::spawn( [&threshold, &line] {
const EdgedCurveDegeneration< Model::dim > inspector{
Expand All @@ -87,9 +87,9 @@ namespace geode
std::vector<
async::task< std::pair< uuid, InspectionIssues< index_t > > > >
surface_tasks;
surface_tasks.reserve( model_.nb_surfaces() );
surface_tasks.reserve( model_.nb_active_surfaces() );
const auto surfaces_to_enable = surfaces_on_which_enable_edges();
for( const auto& surface : model_.surfaces() )
for( const auto& surface : model_.active_surfaces() )
{
const auto enable_edges =
absl::c_contains( surfaces_to_enable, surface.id() );
Expand Down Expand Up @@ -134,8 +134,8 @@ namespace geode
std::vector<
async::task< std::pair< uuid, InspectionIssues< index_t > > > >
tasks;
tasks.reserve( model_.nb_surfaces() );
for( const auto& surface : model_.surfaces() )
tasks.reserve( model_.nb_active_surfaces() );
for( const auto& surface : model_.active_surfaces() )
{
tasks.emplace_back( async::spawn( [&threshold, &surface] {
const geode::SurfaceMeshDegeneration< Model::dim >
Expand Down Expand Up @@ -176,7 +176,7 @@ namespace geode
Model >::surfaces_on_which_enable_edges() const
{
std::vector< uuid > result;
for( const auto& surface : model_.surfaces() )
for( const auto& surface : model_.active_surfaces() )
{
const auto& mesh = surface.mesh();
if( !mesh.are_edges_enabled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace geode
InspectionIssuesMap< index_t >& surfaces_non_manifold_vertices )
const
{
for( const auto& surface : model_.surfaces() )
for( const auto& surface : model_.active_surfaces() )
{
const SurfaceMeshVertexManifold< Model::dim > inspector{
surface.mesh()
Expand All @@ -72,7 +72,7 @@ namespace geode
InspectionIssuesMap< std::array< index_t, 2 > >&
surfaces_non_manifold_edges ) const
{
for( const auto& surface : model_.surfaces() )
for( const auto& surface : model_.active_surfaces() )
{
const SurfaceMeshEdgeManifold< Model::dim > inspector{
surface.mesh()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ namespace geode
std::vector<
std::pair< ComponentMeshElement, ComponentMeshElement > >
component_intersections;
for( const auto& surface : model_.surfaces() )
for( const auto& surface : model_.active_surfaces() )
{
if( surface.mesh().nb_polygons() == 0 )
{
Expand All @@ -570,7 +570,7 @@ namespace geode
}
}
const auto model_tree = create_surface_meshes_aabb_trees( model_ );
for( const auto& surface : model_.surfaces() )
for( const auto& surface : model_.active_surfaces() )
{
Action surfaces_intersection_action{ model_, surface.id(),
surface.id() };
Expand Down
Loading