NEMoSys  0.63.0
A modular, extensible resource with robust automated mesh generation, mesh quality analysis, adaptive mesh refinement, and data transfer between arbitrary meshes.
NEM::NUCMESH::ShapeBase Class Referenceabstract

Abstract base class for types that create NEM::GEO::GeoManager. More...

Detailed Description

Also see NEM::DRV::NucMeshDriver

Definition at line 52 of file ShapeBase.H.

Public Member Functions

virtual ~ShapeBase ()=default
 
const std::array< double, 3 > & getCenter () const
 
void setCenter (const std::array< double, 3 > &center)
 

Static Public Member Functions

static std::array< double, 3 > getRotatedPoint (const std::array< double, 3 > &center, const std::array< double, 2 > &rotation)
 

Protected Member Functions

 ShapeBase (const std::array< double, 3 > &center={0, 0, 0})
 
 ShapeBase (const ShapeBase &)=default
 
ShapeBaseoperator= (const ShapeBase &)=default
 
 ShapeBase (ShapeBase &&)=default
 
ShapeBaseoperator= (ShapeBase &&)=default
 
virtual NEM::GEO::GeoManager createGeo () const =0
 Construct a NEM::GEO::GeoManager. More...
 

Static Protected Member Functions

static void mergeGeo (NEM::GEO::GeoManager &keepGeo, NEM::GEO::GeoManager &&removeGeo)
 Merge two 2d NEM::GEO::GeoManager objects by cutting shapes in removeGeo from shapes in keepGeo and sewing the resulting faces. More...
 

Private Attributes

std::array< double, 3 > center_
 

Friends

class NEM::SRV::NucMeshSrv
 
class ShapesArray
 

Inherited by NEM::NUCMESH::Circles, NEM::NUCMESH::CirclesAndPolys, and NEM::NUCMESH::ShapesArray.

Constructor & Destructor Documentation

◆ ~ShapeBase()

virtual NEM::NUCMESH::ShapeBase::~ShapeBase ( )
virtualdefault

◆ ShapeBase() [1/3]

NEM::NUCMESH::ShapeBase::ShapeBase ( const std::array< double, 3 > &  center = {0, 0, 0})
explicitprotected

Definition at line 56 of file ShapeBase.C.

56 : center_(center) {}
std::array< double, 3 > center_
Definition: ShapeBase.H:97

◆ ShapeBase() [2/3]

NEM::NUCMESH::ShapeBase::ShapeBase ( const ShapeBase )
protecteddefault

◆ ShapeBase() [3/3]

NEM::NUCMESH::ShapeBase::ShapeBase ( ShapeBase &&  )
protecteddefault

Member Function Documentation

◆ createGeo()

virtual NEM::GEO::GeoManager NEM::NUCMESH::ShapeBase::createGeo ( ) const
protectedpure virtual

◆ getCenter()

const std::array< double, 3 > & NEM::NUCMESH::ShapeBase::getCenter ( ) const

◆ getRotatedPoint()

std::array< double, 3 > NEM::NUCMESH::ShapeBase::getRotatedPoint ( const std::array< double, 3 > &  center,
const std::array< double, 2 > &  rotation 
)
static
Parameters
centerCenter of circle
rotation{Radius, angle in degrees}
Returns
Point on circle with center center and normal [0, 0, 1], radius rotation[0] and angle (in degrees) rotation[1]

Definition at line 58 of file ShapeBase.C.

Referenced by NEM::NUCMESH::PolarArray::createGeo(), and NEM::DRV::JSON::modify_helper().

60  {
61  auto angle = rotation[1] * M_PI / 180.;
62  return {center[0] + rotation[0] * std::cos(angle),
63  center[1] + rotation[0] * std::sin(angle), center[2]};
64 }

◆ mergeGeo()

void NEM::NUCMESH::ShapeBase::mergeGeo ( NEM::GEO::GeoManager keepGeo,
NEM::GEO::GeoManager &&  removeGeo 
)
staticprotected
Parameters
[in,out]keepGeoMerge geometry from removeGeo into this object
[in]removeGeoMove geometry and data from this object into keepGeo

Definition at line 66 of file ShapeBase.C.

References NEM::GEO::GeoManager::buildCompound(), NEM::GEO::GeoManager::deleteShapes(), NEM::GEO::GeoManager::getDim(), NEM::GEO::GeoManager::insert(), NEM::GEO::GeoManager::modify(), NEM::GEO::GeoManager::setDim(), and NEM::DRV::JSON::shapeType.

Referenced by NEM::NUCMESH::ShapesArray::createGeoImpl(), and NEM::SRV::NucMeshSrv::FillOutputPortInformation().

67  {
68  auto origCompound = keepGeo.buildCompound();
69  if (origCompound.IsNull()) {
70  keepGeo = std::move(removeGeo);
71  return;
72  } else {
73  auto newCompound = removeGeo.buildCompound();
74  TopoDS_ListOfShape newShapes;
75  static constexpr std::array<TopAbs_ShapeEnum, 4> shapeTypes{
76  TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX};
77  for (auto &shapeType : shapeTypes) {
78  for (TopExp_Explorer explorer{newCompound, shapeType}; explorer.More();
79  explorer.Next()) {
80  auto &oldSubshape = explorer.Current();
81  if (auto old_metadata = removeGeo.get(oldSubshape)) {
82  keepGeo.insert(oldSubshape, std::move(*old_metadata));
83  }
84  }
85  }
86  if (!newCompound.IsNull()) {
87  keepGeo.setDim(std::max(keepGeo.getDim(), removeGeo.getDim()));
88  BRepAlgoAPI_Cut cutter{origCompound, newCompound};
89  if (cutter.HasDeleted() || cutter.HasModified() ||
90  cutter.HasGenerated()) {
91  auto deletedShapes = keepGeo.modify(cutter, {TopAbs_EDGE, TopAbs_FACE});
92  keepGeo.deleteShapes(deletedShapes[0]);
93  }
94  BRepBuilderAPI_Sewing sewer{};
95  std::vector<TopoDS_Shape> sewedShapes;
96  auto compound = keepGeo.buildCompound();
97  for (TopExp_Explorer explorer{compound, TopAbs_FACE}; explorer.More();
98  explorer.Next()) {
99  sewer.Add(explorer.Current());
100  sewedShapes.emplace_back(explorer.Current());
101  }
102  sewer.Perform();
103  auto deletedShapes =
104  keepGeo.modify(sewer, sewedShapes, {TopAbs_EDGE, TopAbs_FACE});
105  keepGeo.deleteShapes(deletedShapes);
106  }
107  }
108 }
std::pair< MapType::iterator, bool > insert(const TopoDS_Shape &shape, std::shared_ptr< ShapeData > shapeData)
Definition: GeoManager.C:181
std::shared_ptr< ShapeData > * get(const TopoDS_Shape &shape)
Get the data from the map.
Definition: GeoManager.C:162
void deleteShapes(const TopoDS_Shape &shape)
Remove a shape from the map.
Definition: GeoManager.C:127
int getDim() const
Get dimension of geometry.
Definition: GeoManager.C:50
static constexpr auto shapeType
Definition: NucMeshJson.H:81
TopoDS_Compound buildCompound() const
Create a compound from shapes present in the map that have same dimension as the instance.
Definition: GeoManager.C:145
std::vector< TopoDS_Shape > modify(BRepBuilderAPI_MakeShape &op, const std::vector< TopoDS_Shape > &shapes, const std::vector< TopAbs_ShapeEnum > &typesToTraverse={ TopAbs_VERTEX, TopAbs_EDGE, TopAbs_FACE, TopAbs_SOLID})
Modify this geoMetadata after a BRepBuilderAPI_MakeShape operation.
Definition: GeoManager.C:74
void setDim(int dim)
Set the dimension.
Definition: GeoManager.C:52

◆ operator=() [1/2]

ShapeBase& NEM::NUCMESH::ShapeBase::operator= ( const ShapeBase )
protecteddefault

◆ operator=() [2/2]

ShapeBase& NEM::NUCMESH::ShapeBase::operator= ( ShapeBase &&  )
protecteddefault

◆ setCenter()

void NEM::NUCMESH::ShapeBase::setCenter ( const std::array< double, 3 > &  center)

Definition at line 52 of file ShapeBase.C.

References center_.

Referenced by NEM::DRV::JSON::modify_helper().

52  {
53  center_ = center;
54 }
std::array< double, 3 > center_
Definition: ShapeBase.H:97

Friends And Related Function Documentation

◆ NEM::SRV::NucMeshSrv

friend class NEM::SRV::NucMeshSrv
friend

Definition at line 56 of file ShapeBase.H.

◆ ShapesArray

friend class ShapesArray
friend

Definition at line 57 of file ShapeBase.H.

Member Data Documentation

◆ center_

std::array<double, 3> NEM::NUCMESH::ShapeBase::center_
private

Definition at line 97 of file ShapeBase.H.

Referenced by getCenter(), and setCenter().


The documentation for this class was generated from the following files: