Skip to content

Commit

Permalink
new propopsition
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisbonneau committed Oct 17, 2023
1 parent aa6dac9 commit 5e87f4f
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 93 deletions.
11 changes: 6 additions & 5 deletions bindings/python/src/inspector/topology/brep_topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,20 @@ namespace geode

void define_brep_topology_inspector( pybind11::module& module )
{
pybind11::class_< BRepCornersInspectionResult >(
pybind11::class_< BRepCornersTopologyInspectionResult >(
module, "BRepCornersInspectionResult" )
.def( pybind11::init<>() )
.def_readwrite( "multiple_corners_unique_vertices",
&BRepCornersInspectionResult::multiple_corners_unique_vertices )
&BRepCornersTopologyInspectionResult::
multiple_corners_unique_vertices )
.def_readwrite( "multiple_internals_corner_vertices",
&BRepCornersInspectionResult::
&BRepCornersTopologyInspectionResult::
multiple_internals_corner_vertices )
.def_readwrite( "not_internal_nor_boundary_corner_vertices",
&BRepCornersInspectionResult::
&BRepCornersTopologyInspectionResult::
not_internal_nor_boundary_corner_vertices )
.def_readwrite( "line_corners_without_boundary_status",
&BRepCornersInspectionResult::
&BRepCornersTopologyInspectionResult::
line_corners_without_boundary_status );

pybind11::class_< BRepLinesInspectionResult >(
Expand Down
23 changes: 12 additions & 11 deletions include/geode/inspector/topology/brep_corners_topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

#include <vector>

#include <absl/container/flat_hash_map.h>
#include <geode/inspector/common.h>

namespace geode
{
struct ComponentMeshVertex;
Expand All @@ -34,10 +36,12 @@ namespace geode

namespace geode
{
struct opengeode_inspector_inspector_api BRepCornersInspectionResult
struct opengeode_inspector_inspector_api BRepCornersTopologyInspectionResult
{
/* std::vector< ComponentMeshVertex >
corners_not_linked_to_unique_vertex{};*/
std::vector< ComponentMeshVertex >
corners_not_linked_to_unique_vertex{};
absl::flat_hash_map< index_t, std::vector< std::string > > problems{};

std::vector< index_t > multiple_corners_unique_vertices{};
std::vector< index_t > multiple_internals_corner_vertices{};
std::vector< index_t > not_internal_nor_boundary_corner_vertices{};
Expand All @@ -49,8 +53,6 @@ namespace geode
public:
BRepCornersTopology( const BRep& brep );

BRepCornersTopology( const BRep& brep, bool verbose );

/*!
* Checks if the brep unique vertices are valid corners, i.e.
* corners that verify:
Expand All @@ -61,22 +63,21 @@ namespace geode
*/
bool brep_corner_topology_is_valid( index_t unique_vertex_index ) const;

bool unique_vertex_has_multiple_corners(
absl::optional< std::string > unique_vertex_has_multiple_corners(
index_t unique_vertex_index ) const;

bool corner_has_multiple_embeddings(
absl::optional< std::string > corner_has_multiple_embeddings(
index_t unique_vertex_index ) const;

bool corner_is_not_internal_nor_boundary(
absl::optional< std::string > corner_is_not_internal_nor_boundary(
index_t unique_vertex_index ) const;

bool corner_is_part_of_line_but_not_boundary(
absl::optional< std::string > corner_is_part_of_line_but_not_boundary(
index_t unique_vertex_index ) const;

BRepCornersInspectionResult inspect_corners() const;
BRepCornersTopologyInspectionResult inspect_corners() const;

private:
const BRep& brep_;
bool verbose_;
};
} // namespace geode
2 changes: 1 addition & 1 deletion include/geode/inspector/topology/brep_topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace geode
{
struct opengeode_inspector_inspector_api BRepInspectionResult
{
BRepCornersInspectionResult corners;
BRepCornersTopologyInspectionResult corners;
BRepLinesInspectionResult lines;
BRepSurfacesInspectionResult surfaces;
BRepBlocksInspectionResult blocks;
Expand Down
8 changes: 8 additions & 0 deletions include/geode/inspector/topology/private/topology_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ namespace geode
class Section;
struct uuid;
struct ComponentMeshVertex;
class ComponentID;
class VertexSet;
} // namespace geode

namespace geode
Expand All @@ -45,5 +47,11 @@ namespace geode

std::vector< uuid > components_uuids(
absl::Span< const ComponentMeshVertex > components );

std::vector< geode::ComponentMeshVertex >
brep_component_vertices_not_associated_to_unique_vertices(
const geode::BRep& brep,
const geode::ComponentID& component_id,
const geode::VertexSet& component_mesh );
} // namespace detail
} // namespace geode
154 changes: 80 additions & 74 deletions src/geode/inspector/topology/brep_corners_topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,19 @@
*/

#include <geode/inspector/topology/brep_corners_topology.h>
#include <geode/inspector/topology/private/topology_helpers.h>

#include <geode/basic/logger.h>

#include <geode/mesh/core/point_set.h>

#include <geode/model/mixin/core/corner.h>
#include <geode/model/mixin/core/line.h>
#include <geode/model/representation/core/brep.h>

namespace geode
{
BRepCornersTopology::BRepCornersTopology( const BRep& brep, bool verbose )
: brep_( brep ), verbose_( verbose )
{
}
BRepCornersTopology::BRepCornersTopology( const BRep& brep )
: BRepCornersTopology( brep, false )
BRepCornersTopology::BRepCornersTopology( const BRep& brep ) : brep_{ brep }
{
}

Expand Down Expand Up @@ -81,68 +79,63 @@ namespace geode
return true;
}

bool BRepCornersTopology::unique_vertex_has_multiple_corners(
index_t unique_vertex_index ) const
absl::optional< std::string >
BRepCornersTopology::unique_vertex_has_multiple_corners(
index_t unique_vertex_index ) const
{
if( brep_
.component_mesh_vertices(
unique_vertex_index, Corner3D::component_type_static() )
.size()
> 1 )
{
if( verbose_ )
{
Logger::info( "Unique vertex with index ", unique_vertex_index,
" is part of several corners." );
}
return true;
return std::string( "Unique vertex with index " )
+ std::to_string( unique_vertex_index )
+ std::string( " is part of several corners." );
}
return false;
return absl::nullopt;
}

bool BRepCornersTopology::corner_has_multiple_embeddings(
index_t unique_vertex_index ) const
absl::optional< std::string >
BRepCornersTopology::corner_has_multiple_embeddings(
index_t unique_vertex_index ) const
{
const auto corners = brep_.component_mesh_vertices(
unique_vertex_index, Corner3D::component_type_static() );
if( !corners.empty()
&& brep_.nb_embeddings( corners[0].component_id.id() ) > 1 )
{
if( verbose_ )
{
Logger::info( "Unique vertex with index ", unique_vertex_index,
" is associated to corner with uuid '",
corners[0].component_id.id().string(),
"', which has several embeddings." );
}
return true;
return std::string( "Unique vertex with index " )
+ std::to_string( unique_vertex_index )
+ std::string( " is associated to corner with uuid '" )
+ corners[0].component_id.id().string()
+ std::string( "', which has several embeddings." );
}
return false;
return absl::nullopt;
}

bool BRepCornersTopology::corner_is_not_internal_nor_boundary(
index_t unique_vertex_index ) const
absl::optional< std::string >
BRepCornersTopology::corner_is_not_internal_nor_boundary(
index_t unique_vertex_index ) const
{
const auto corners = brep_.component_mesh_vertices(
unique_vertex_index, Corner3D::component_type_static() );
if( !corners.empty()
&& brep_.nb_embeddings( corners[0].component_id.id() ) < 1
&& brep_.nb_incidences( corners[0].component_id.id() ) < 1 )
{
if( verbose_ )
{
Logger::info( "Unique vertex with index ", unique_vertex_index,
" is associated to corner with uuid '",
corners[0].component_id.id().string(),
"', which is neither incident nor embedded." );
}
return true;
std::string( "Unique vertex with index " )
+ std::to_string( unique_vertex_index )
+ std::string( " is associated to corner with uuid '" )
+ corners[0].component_id.id().string()
+ std::string( "', which is neither incident nor embedded." );
}
return false;
return absl::nullopt;
}

bool BRepCornersTopology::corner_is_part_of_line_but_not_boundary(
index_t unique_vertex_index ) const
absl::optional< std::string >
BRepCornersTopology::corner_is_part_of_line_but_not_boundary(
index_t unique_vertex_index ) const
{
const auto corners = brep_.component_mesh_vertices(
unique_vertex_index, Corner3D::component_type_static() );
Expand All @@ -155,56 +148,69 @@ namespace geode
if( !brep_.Relationships::is_boundary(
corner_uuid, line.component_id.id() ) )
{
if( verbose_ )
{
Logger::info( "Unique vertex with index ",
unique_vertex_index,
" is associated with corner with uuid '",
corner_uuid.string(), "', part of line with uuid '",
line.component_id.id().string(),
"', but not boundary of it." );
}
return true;
std::string( "Unique vertex with index " )
+ std::to_string( unique_vertex_index )
+ std::string(
" is associated with corner with uuid '" )
+ corner_uuid.string()
+ std::string( "', part of line with uuid '" )
+ line.component_id.id().string()
+ std::string( "', but not boundary of it." );
}
}
}
return false;
return absl::nullopt;
}

BRepCornersInspectionResult BRepCornersTopology::inspect_corners() const
BRepCornersTopologyInspectionResult
BRepCornersTopology::inspect_corners() const
{
BRepCornersInspectionResult result;
/* for( const auto& corner : brep_.corners() )
{
const geode::ComponentMeshVertex mesh_vertex{
corner.component_id(), 0 }; if( brep_.unique_vertex( mesh_vertex ) ==
geode::NO_ID )
{
result.corners_not_linked_to_unique_vertex.push_back(
mesh_vertex );
}
}*/
BRepCornersTopologyInspectionResult result;
for( const auto& corner : brep_.corners() )
{
auto corner_result = detail::
brep_component_vertices_not_associated_to_unique_vertices(
brep_, corner.component_id(), corner.mesh() );
result.corners_not_linked_to_unique_vertex.insert(
result.corners_not_linked_to_unique_vertex.end(),
std::make_move_iterator( corner_result.begin() ),
std::make_move_iterator( corner_result.end() ) );
}
for( const auto unique_vertex_id : Range{ brep_.nb_unique_vertices() } )
{
if( unique_vertex_has_multiple_corners( unique_vertex_id ) )
std::vector< std::string > unique_vertex_problems;
const auto has_multiple_corners =
unique_vertex_has_multiple_corners( unique_vertex_id );
if( has_multiple_corners )
{
unique_vertex_problems.push_back(
has_multiple_corners.value() );
}
const auto has_multiple_embeddings =
corner_has_multiple_embeddings( unique_vertex_id );
if( has_multiple_embeddings )
{
result.multiple_corners_unique_vertices.push_back(
unique_vertex_id );
unique_vertex_problems.push_back(
has_multiple_embeddings.value() );
}
if( corner_has_multiple_embeddings( unique_vertex_id ) )
const auto not_internal_nor_boundary =
corner_is_not_internal_nor_boundary( unique_vertex_id );
if( not_internal_nor_boundary )
{
result.multiple_internals_corner_vertices.push_back(
unique_vertex_id );
unique_vertex_problems.push_back(
not_internal_nor_boundary.value() );
}
if( corner_is_not_internal_nor_boundary( unique_vertex_id ) )
const auto without_boundary_status =
corner_is_part_of_line_but_not_boundary( unique_vertex_id );
if( without_boundary_status )
{
result.not_internal_nor_boundary_corner_vertices.push_back(
unique_vertex_id );
unique_vertex_problems.push_back(
without_boundary_status.value() );
}
if( corner_is_part_of_line_but_not_boundary( unique_vertex_id ) )
if( !unique_vertex_problems.empty() )
{
result.line_corners_without_boundary_status.push_back(
unique_vertex_id );
result.problems.emplace(
unique_vertex_id, unique_vertex_problems );
}
}
return result;
Expand Down
4 changes: 2 additions & 2 deletions src/geode/inspector/topology/brep_topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ namespace geode
};

BRepTopologyInspector::BRepTopologyInspector( const BRep& brep )
: BRepCornersTopology( brep, false ),
: BRepCornersTopology( brep ),
BRepLinesTopology( brep, false ),
BRepSurfacesTopology( brep, false ),
BRepBlocksTopology( brep, false ),
Expand All @@ -250,7 +250,7 @@ namespace geode

BRepTopologyInspector::BRepTopologyInspector(
const BRep& brep, bool verbose )
: BRepCornersTopology( brep, verbose ),
: BRepCornersTopology( brep ),
BRepLinesTopology( brep, verbose ),
BRepSurfacesTopology( brep, verbose ),
BRepBlocksTopology( brep, verbose ),
Expand Down
Loading

0 comments on commit 5e87f4f

Please sign in to comment.