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::CirclesAndPolys Class Reference

A set of concentric circles and polygons and the faces they enclose. More...

Detailed Description

Definition at line 48 of file CirclesAndPolys.H.

Public Member Functions

 CirclesAndPolys (int numSides, std::vector< PolyRing > rings, const std::array< double, 3 > &center={0, 0, 0})
 Container to describe a set of concentric circles/polygons. More...
 
int getNumSides () const
 
void setNumSides (int numSides)
 
const std::vector< PolyRing > & getRings () const
 
void setRings (std::vector< PolyRing > rings)
 
void addRing (const PolyRing &ring)
 
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

NEM::GEO::GeoManager createGeo () const override
 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

int numSides_
 
std::vector< PolyRingrings_
 

Inherits NEM::NUCMESH::ShapeBase.

Constructor & Destructor Documentation

◆ CirclesAndPolys()

NEM::NUCMESH::CirclesAndPolys::CirclesAndPolys ( int  numSides,
std::vector< PolyRing rings,
const std::array< double, 3 > &  center = {0, 0, 0} 
)
Parameters
numSidesNumber of sides for polygons (note circles are treated as numSides arcs)
ringsRadius and meshing description of each ring
centerCenter of shapes

Definition at line 151 of file CirclesAndPolys.C.

153  : ShapeBase(center), numSides_(numSides), rings_(std::move(rings)) {}
std::vector< PolyRing > rings_
ShapeBase(const std::array< double, 3 > &center={0, 0, 0})
Definition: ShapeBase.C:56

Member Function Documentation

◆ addRing()

void NEM::NUCMESH::CirclesAndPolys::addRing ( const PolyRing ring)

Definition at line 167 of file CirclesAndPolys.C.

References rings_.

167  {
168  this->rings_.emplace_back(ring);
169 }
std::vector< PolyRing > rings_

◆ createGeo()

NEM::GEO::GeoManager NEM::NUCMESH::CirclesAndPolys::createGeo ( ) const
overrideprotectedvirtual
Returns
A NEM::GEO::GeoManager object representing the shape described by this object

Implements NEM::NUCMESH::ShapeBase.

Definition at line 298 of file CirclesAndPolys.C.

References NEM::NUCMESH::drawNested(), NEM::NUCMESH::ShapeBase::getCenter(), numSides_, NEM::NUCMESH::Ring::radius, rings_, NEM::NUCMESH::PolyRing::rotation, and NEM::NUCMESH::PolyRing::shapeType.

298  {
299  return drawNested(
300  numSides_, rings_, this->getCenter(), [this](const PolyRing &ring) {
301  return getRingVerticesAndCircEdges(this->getCenter(), this->numSides_,
302  ring.radius, ring.rotation,
303  ring.shapeType);
304  });
305 }
NEM::GEO::GeoManager drawNested(int numSides, const std::vector< RingT > &rings, const std::array< double, 3 > &center, FVertCirc funcVertsCircEdges)
const std::array< double, 3 > & getCenter() const
Definition: ShapeBase.C:50
std::vector< PolyRing > rings_

◆ getCenter()

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

◆ getNumSides()

int NEM::NUCMESH::CirclesAndPolys::getNumSides ( ) const

Definition at line 155 of file CirclesAndPolys.C.

References numSides_.

◆ getRings()

const std::vector< PolyRing > & NEM::NUCMESH::CirclesAndPolys::getRings ( ) const

Definition at line 159 of file CirclesAndPolys.C.

References rings_.

159  {
160  return rings_;
161 }
std::vector< PolyRing > rings_

◆ getRotatedPoint()

std::array< double, 3 > NEM::NUCMESH::ShapeBase::getRotatedPoint ( const std::array< double, 3 > &  center,
const std::array< double, 2 > &  rotation 
)
staticinherited
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 
)
staticprotectedinherited
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

◆ setCenter()

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

Definition at line 52 of file ShapeBase.C.

References NEM::NUCMESH::ShapeBase::center_.

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

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

◆ setNumSides()

void NEM::NUCMESH::CirclesAndPolys::setNumSides ( int  numSides)

Definition at line 157 of file CirclesAndPolys.C.

References numSides_.

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

157 { this->numSides_ = numSides; }

◆ setRings()

void NEM::NUCMESH::CirclesAndPolys::setRings ( std::vector< PolyRing rings)

Definition at line 163 of file CirclesAndPolys.C.

References rings_.

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

163  {
164  this->rings_ = std::move(rings);
165 }
std::vector< PolyRing > rings_

Member Data Documentation

◆ numSides_

int NEM::NUCMESH::CirclesAndPolys::numSides_
private

Definition at line 70 of file CirclesAndPolys.H.

Referenced by createGeo(), getNumSides(), and setNumSides().

◆ rings_

std::vector<PolyRing> NEM::NUCMESH::CirclesAndPolys::rings_
private

Definition at line 71 of file CirclesAndPolys.H.

Referenced by addRing(), createGeo(), getRings(), and setRings().


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