29 #ifndef NEMOSYS_GEOMANAGER_H_ 30 #define NEMOSYS_GEOMANAGER_H_ 32 #include "nemosys_export.h" 36 #include <type_traits> 37 #include <unordered_map> 41 #include <TopAbs_ShapeEnum.hxx> 42 #include <TopTools_ShapeMapHasher.hxx> 46 class TopoDS_Compound;
48 class BRepBuilderAPI_MakeShape;
49 class BRepAlgoAPI_BooleanOperation;
50 class BRepBuilderAPI_Sewing;
68 std::size_t
operator()(
const TopoDS_Shape &shape)
const {
69 return TopTools_ShapeMapHasher::HashCode(shape, IntegerLast());
79 const TopoDS_Shape &shape2)
const {
80 return TopTools_ShapeMapHasher::IsEqual(shape1, shape2);
84 std::unordered_map<TopoDS_Shape, std::shared_ptr<ShapeData>,
104 void setDim(
int dim);
116 std::vector<TopoDS_Shape> modify(
117 BRepBuilderAPI_MakeShape &op,
const std::vector<TopoDS_Shape> &shapes,
118 const std::vector<TopAbs_ShapeEnum> &typesToTraverse = {
119 TopAbs_VERTEX, TopAbs_EDGE, TopAbs_FACE, TopAbs_SOLID});
125 std::vector<TopoDS_Shape> modify(
127 const std::vector<TopAbs_ShapeEnum> &typesToTraverse = {
128 TopAbs_VERTEX, TopAbs_EDGE, TopAbs_FACE, TopAbs_SOLID});
135 std::array<std::vector<TopoDS_Shape>, 2> modify(
136 BRepAlgoAPI_BooleanOperation &op,
137 const std::vector<TopAbs_ShapeEnum> &typesToTraverse = {
138 TopAbs_VERTEX, TopAbs_EDGE, TopAbs_FACE, TopAbs_SOLID});
144 std::vector<TopoDS_Shape> modify(
145 BRepBuilderAPI_Sewing &op,
const std::vector<TopoDS_Shape> &shapes,
146 const std::vector<TopAbs_ShapeEnum> &typesToTraverse = {
147 TopAbs_VERTEX, TopAbs_EDGE, TopAbs_FACE, TopAbs_SOLID});
156 void deleteShapes(
const TopoDS_Shape &shape);
163 void deleteShapes(
const std::vector<TopoDS_Shape> &shapes);
170 TopoDS_Compound buildCompound()
const;
175 std::shared_ptr<ShapeData> *
get(
const TopoDS_Shape &shape);
183 const std::shared_ptr<ShapeData> *
get(
const TopoDS_Shape &shape)
const;
185 std::pair<MapType::iterator, bool> insert(
186 const TopoDS_Shape &shape, std::shared_ptr<ShapeData> shapeData);
196 template <
typename T>
199 auto emplaceIter = getMap().emplace(shape, std::shared_ptr<ShapeData>{});
200 if (emplaceIter.second) {
201 emplaceIter.first->second.reset(
202 new typename std::decay<T>::type(std::forward<T>(shapeData)));
217 template <
typename T,
typename... Args>
220 auto emplaceIter = getMap().emplace(shape, std::shared_ptr<ShapeData>{});
221 if (emplaceIter.second) {
222 emplaceIter.first->second.reset(
new T(std::forward<Args>(args)...));
242 bool isChild(
const TopoDS_Shape &shape)
const;
244 void modifyImpl(BRepBuilderAPI_MakeShape &op,
const TopoDS_Shape &shape,
245 std::vector<TopoDS_Shape> &shapesToRemove);
251 #endif // NEMOSYS_GEOMANAGER_H_ std::unordered_map< TopoDS_Shape, std::shared_ptr< ShapeData >, ShapeMapHasher_Hash, ShapeMapHasher_KeyEqual > MapType
Class to manage TopoDS_Shapes along with metadata.
bool operator()(const TopoDS_Shape &shape1, const TopoDS_Shape &shape2) const
Hasher based on TopTools_ShapeMapHasher, which relies on TopoDS_Shape::IsSame, which is not TopoDS_Sh...
std::size_t operator()(const TopoDS_Shape &shape) const
Equality operator based on TopTools_ShapeMapHasher, which relies on TopoDS_Shape::IsSame, which is not TopoDS_Shape::operator==.
std::pair< MapType::iterator, bool > insertConstruct(const TopoDS_Shape &shape, Args &&...args)
Helper to insert a shape and construct data.
std::pair< MapType::iterator, bool > insertForward(const TopoDS_Shape &shape, T &&shapeData)
Helper to insert a shape and data into the map.