Skip to content

Commit

Permalink
brep_inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisbonneau committed Oct 18, 2023
1 parent 2281ae7 commit 43b3b17
Show file tree
Hide file tree
Showing 18 changed files with 721 additions and 642 deletions.
53 changes: 28 additions & 25 deletions bindings/python/src/inspector/topology/brep_topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace geode
void define_brep_topology_inspector( pybind11::module& module )
{
pybind11::class_< BRepCornersTopologyInspectionResult >(
module, "BRepCornersInspectionResult" )
module, "BRepCornersTopologyInspectionResult" )
.def( pybind11::init<>() )
.def_readwrite( "multiple_corners_unique_vertices",
&BRepCornersTopologyInspectionResult::
Expand All @@ -46,60 +46,61 @@ namespace geode
&BRepCornersTopologyInspectionResult::
line_corners_without_boundary_status );

pybind11::class_< BRepLinesInspectionResult >(
module, "BRepLinesInspectionResult" )
pybind11::class_< BRepLinesTopologyInspectionResult >(
module, "BRepLinesTopologyInspectionResult" )
.def( pybind11::init<>() )
.def_readwrite(
"part_of_not_boundary_nor_internal_line_unique_vertices",
&BRepLinesInspectionResult::
&BRepLinesTopologyInspectionResult::
part_of_not_boundary_nor_internal_line_unique_vertices )
.def_readwrite(
"part_of_line_with_invalid_internal_topology_unique_vertices",
&BRepLinesInspectionResult::
&BRepLinesTopologyInspectionResult::
part_of_line_with_invalid_internal_topology_unique_vertices )
.def_readwrite( "part_of_invalid_unique_line_unique_vertices",
&BRepLinesInspectionResult::
&BRepLinesTopologyInspectionResult::
part_of_invalid_unique_line_unique_vertices )
.def_readwrite( "part_of_lines_but_not_corner_unique_vertices",
&BRepLinesInspectionResult::
&BRepLinesTopologyInspectionResult::
part_of_lines_but_not_corner_unique_vertices );

pybind11::class_< BRepSurfacesInspectionResult >(
module, "BRepSurfacesInspectionResult" )
pybind11::class_< BRepSurfacesTopologyInspectionResult >(
module, "BRepSurfacesTopologyInspectionResult" )
.def( pybind11::init<>() )
.def_readwrite(
"part_of_not_boundary_nor_internal_surface_unique_vertices",
&BRepSurfacesInspectionResult::
&BRepSurfacesTopologyInspectionResult::
part_of_not_boundary_nor_internal_surface_unique_vertices )
.def_readwrite( "part_of_surface_with_invalid_internal_topology_"
"unique_vertices",
&BRepSurfacesInspectionResult::
&BRepSurfacesTopologyInspectionResult::
part_of_surface_with_invalid_internal_topology_unique_vertices )
.def_readwrite( "part_of_invalid_unique_surface_unique_vertices",
&BRepSurfacesInspectionResult::
&BRepSurfacesTopologyInspectionResult::
part_of_invalid_unique_surface_unique_vertices )
.def_readwrite( "part_of_invalid_multiple_surfaces_unique_vertices",
&BRepSurfacesInspectionResult::
&BRepSurfacesTopologyInspectionResult::
part_of_invalid_multiple_surfaces_unique_vertices )
.def_readwrite(
"part_of_line_and_not_on_surface_border_unique_vertices",
&BRepSurfacesInspectionResult::
&BRepSurfacesTopologyInspectionResult::
part_of_line_and_not_on_surface_border_unique_vertices );

pybind11::class_< BRepBlocksInspectionResult >(
module, "BRepBlocksInspectionResult" )
pybind11::class_< BRepBlocksTopologyInspectionResult >(
module, "BRepBlocksTopologyInspectionResult" )
.def( pybind11::init<>() )
.def_readwrite( "part_of_invalid_blocks_unique_vertices",
&BRepBlocksInspectionResult::
&BRepBlocksTopologyInspectionResult::
part_of_invalid_blocks_unique_vertices );

pybind11::class_< BRepInspectionResult >(
module, "BRepInspectionResult" )
pybind11::class_< BRepTopologyInspectionResult >(
module, "BRepTopologyInspectionResult" )
.def( pybind11::init<>() )
.def_readwrite( "corners", &BRepInspectionResult::corners )
.def_readwrite( "lines", &BRepInspectionResult::lines )
.def_readwrite( "surfaces", &BRepInspectionResult::surfaces )
.def_readwrite( "blocks", &BRepInspectionResult::blocks );
.def_readwrite( "corners", &BRepTopologyInspectionResult::corners )
.def_readwrite( "lines", &BRepTopologyInspectionResult::lines )
.def_readwrite(
"surfaces", &BRepTopologyInspectionResult::surfaces )
.def_readwrite( "blocks", &BRepTopologyInspectionResult::blocks );

pybind11::class_< BRepTopologyInspector >(
module, "BRepTopologyInspector" )
Expand All @@ -113,12 +114,14 @@ namespace geode
.def( "brep_unique_vertices_are_linked_to_a_component_vertex",
&BRepTopologyInspector::
brep_unique_vertices_are_linked_to_a_component_vertex )
.def( "unique_vertices_not_linked_to_a_component_vertex",
/*.def( "unique_vertices_not_linked_to_a_component_vertex",
&BRepTopologyInspector::
unique_vertices_not_linked_to_a_component_vertex )
*/
.def( "invalid_components_topology_unique_vertices",
&BRepTopologyInspector::
invalid_components_topology_unique_vertices )
.def( "inspect_brep", &BRepTopologyInspector::inspect_brep );
.def( "inspect_brep_topology",
&BRepTopologyInspector::inspect_brep_topology );
}
} // namespace geode
57 changes: 57 additions & 0 deletions include/geode/inspector/information.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2019 - 2023 Geode-solutions
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#pragma once

#include <string>
#include <vector>

#include <geode/inspector/common.h>

namespace geode
{
template < typename ProblemType >
struct ProblemInspectionResult
{
ProblemInspectionResult( absl::string_view problem_descrption )
: description{ problem_descrption }
{
}

index_t number()
{
return problems.size();
}

void add_problem(
const ProblemType& problem, const std::string& message )
{
problems.push_back( problem );
messages.push_back( message );
}

std::string description;
std::vector< ProblemType > problems{};
std::vector< std::string > messages{};
};
} // namespace geode
25 changes: 17 additions & 8 deletions include/geode/inspector/topology/brep_blocks_topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,32 @@

#pragma once

#include <absl/types/optional.h>

#include <geode/inspector/common.h>
#include <geode/inspector/information.h>

namespace geode
{
struct ComponentMeshVertex;
class BRep;
struct uuid;
} // namespace geode

namespace geode
{

struct opengeode_inspector_inspector_api BRepBlocksInspectionResult
struct opengeode_inspector_inspector_api BRepBlocksTopologyInspectionResult
{
std::vector< index_t > part_of_invalid_blocks_unique_vertices{};
ProblemInspectionResult< uuid > blocks_not_meshed{
"Blocks not meshed"
};
ProblemInspectionResult< ComponentMeshVertex >
blocks_not_linked_to_unique_vertex{
"Blocks without unique vertex"
};
ProblemInspectionResult< index_t >
part_of_invalid_blocks_unique_vertices{ "" };
};
/*!
* Class for inspecting the topology of a BRep model blocks through
Expand All @@ -45,9 +58,6 @@ namespace geode
{
public:
BRepBlocksTopology( const BRep& brep );

BRepBlocksTopology( const BRep& brep, bool verbose );

/*!
* Checks if the brep unique vertices are parts of valid blocks,
* i.e. verify:
Expand All @@ -56,13 +66,12 @@ namespace geode
* the 2 blocks), or it is part of more than to blocks (and it is
* either a corner, or not a corner but part of only one line).
*/
bool brep_vertex_blocks_topology_is_valid(
absl::optional< std::string > brep_vertex_blocks_topology_is_valid(
index_t unique_vertex_index ) const;

BRepBlocksInspectionResult inspect_blocks() const;
BRepBlocksTopologyInspectionResult inspect_blocks() const;

private:
const BRep& brep_;
bool verbose_;
};
} // namespace geode
28 changes: 18 additions & 10 deletions include/geode/inspector/topology/brep_corners_topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@

#pragma once

#include <vector>
#include <absl/types/optional.h>
#include <string>

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

namespace geode
{
Expand All @@ -38,14 +39,21 @@ namespace geode
{
struct opengeode_inspector_inspector_api BRepCornersTopologyInspectionResult
{
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{};
std::vector< index_t > line_corners_without_boundary_status{};
ProblemInspectionResult< ComponentMeshVertex >
corners_not_linked_to_unique_vertex{
"Corners without unique vertex"
};
ProblemInspectionResult< index_t > multiple_corners_unique_vertices{
"Unique vertices that are part of several corners."
};
ProblemInspectionResult< index_t > multiple_internals_corner_vertices{
"Corners with several embeddings"
};
ProblemInspectionResult< index_t >
not_internal_nor_boundary_corner_vertices{ "Isolated Corners" };
ProblemInspectionResult< index_t > line_corners_without_boundary_status{
"Corner on line but not a boundary)"
};
};

class opengeode_inspector_inspector_api BRepCornersTopology
Expand Down
46 changes: 29 additions & 17 deletions include/geode/inspector/topology/brep_lines_topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,37 @@
*/

#pragma once
#include <absl/types/optional.h>

#include <geode/inspector/common.h>
#include <geode/inspector/information.h>

namespace geode
{
struct ComponentMeshVertex;
class BRep;
struct uuid;
} // namespace geode

namespace geode
{
struct opengeode_inspector_inspector_api BRepLinesInspectionResult
struct opengeode_inspector_inspector_api BRepLinesTopologyInspectionResult
{
std::vector< index_t >
part_of_not_boundary_nor_internal_line_unique_vertices{};
std::vector< index_t >
part_of_line_with_invalid_internal_topology_unique_vertices{};
std::vector< index_t > part_of_invalid_unique_line_unique_vertices{};
std::vector< index_t > part_of_lines_but_not_corner_unique_vertices{};
ProblemInspectionResult< uuid > lines_not_meshed{ "Lines not meshed" };
ProblemInspectionResult< ComponentMeshVertex >
lines_not_linked_to_unique_vertex{
"Lines not completly linked to unique vertex"
};
ProblemInspectionResult< index_t >
part_of_not_boundary_nor_internal_line_unique_vertices{ "" };
ProblemInspectionResult< index_t >
part_of_line_with_invalid_internal_topology_unique_vertices{ "" };
ProblemInspectionResult< index_t >
part_of_invalid_unique_line_unique_vertices{ "" };
ProblemInspectionResult< index_t >
part_of_lines_but_not_corner_unique_vertices{
"unique vertices on a line "
};
};
/*!
* Class for inspecting the topology of a BRep model lines through their
Expand All @@ -50,8 +63,6 @@ namespace geode
public:
BRepLinesTopology( const BRep& brep );

BRepLinesTopology( const BRep& brep, bool verbose );

/*!
* Checks if the brep unique vertices are parts of valid lines, i.e.
* verify:
Expand All @@ -65,22 +76,23 @@ namespace geode
bool brep_vertex_lines_topology_is_valid(
index_t unique_vertex_index ) const;

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

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

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

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

BRepLinesInspectionResult inspect_lines() const;
BRepLinesTopologyInspectionResult inspect_lines() const;

private:
const BRep& brep_;
bool verbose_;
};
} // namespace geode
Loading

0 comments on commit 43b3b17

Please sign in to comment.