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

Arrange a series of other ShapeBase objects along a circular arc. More...

Detailed Description

Definition at line 43 of file PolarArray.H.

Public Member Functions

 PolarArray (std::size_t numSubshapes, double startAngle, double endAngle, double radius, bool rotateWithArray=false, const std::array< double, 3 > &center={0, 0, 0})
 
std::size_t getNumSubshapes () const
 
double getRadius () const
 
void setRadius (double radius)
 
double getStartAngle () const
 
void setStartAngle (double startAngle)
 
double getEndAngle () const
 
void setEndAngle (double endAngle)
 
bool getRotateWithArray () const
 
void setRotateWithArray (bool rotateWithArray)
 
std::size_t getNumPatternShapes () const
 
const ShapeBasegetPatternShape (std::size_t idx) const
 
void setPatternShape (std::size_t idx, const std::shared_ptr< ShapeBase > &shape)
 
template<typename Shape >
void insertPatternShape (std::size_t idx, Shape &&shape)
 
template<typename Shape , typename... Args>
void makePatternShape (std::size_t idx, Args &&...args)
 
void fillPattern (std::size_t idx)
 
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...
 
std::size_t getPatternSize () const
 
const std::size_t & getPattern (std::size_t idx) const
 
void setPattern (std::size_t idx, std::size_t patternKey)
 
template<typename Modifier >
NEM::GEO::GeoManager createGeoImpl (Modifier &&modifier) const
 

Static Protected Member Functions

static NEM::GEO::GeoManager basicTransformation (const gp_Trsf &transformation, NEM::GEO::GeoManager &&geoMetadata)
 
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::size_t numShapesInArr_
 
double radius_
 
double start_
 
double end_
 
bool rotateWithArray_
 

Inherits NEM::NUCMESH::ShapesArray.

Constructor & Destructor Documentation

◆ PolarArray()

NEM::NUCMESH::PolarArray::PolarArray ( std::size_t  numSubshapes,
double  startAngle,
double  endAngle,
double  radius,
bool  rotateWithArray = false,
const std::array< double, 3 > &  center = {0, 0, 0} 
)

Definition at line 49 of file PolarArray.C.

52  : ShapesArray(center, numSubshapes),
53  numShapesInArr_(numSubshapes),
54  radius_(radius),
55  start_(startAngle),
56  end_(endAngle),
57  rotateWithArray_(rotateWithArray) {}
ShapesArray(const std::array< double, 3 > &center, std::size_t numPatternShapes)
Definition: ShapesArray.C:41
std::size_t numShapesInArr_
Definition: PolarArray.H:74

Member Function Documentation

◆ basicTransformation()

NEM::GEO::GeoManager NEM::NUCMESH::ShapesArray::basicTransformation ( const gp_Trsf &  transformation,
NEM::GEO::GeoManager &&  geoMetadata 
)
staticprotectedinherited

Definition at line 81 of file ShapesArray.C.

References NEM::GEO::GeoManager::buildCompound(), NEM::GEO::GeoManager::insert(), and NEM::DRV::JSON::shapeType.

Referenced by NEM::NUCMESH::HexagonalArray::createGeo(), NEM::NUCMESH::RectangularArray::createGeo(), and createGeo().

82  {
83  auto compound = geoMetadata.buildCompound();
84  BRepBuilderAPI_Transform transformer{transformation};
85  transformer.Perform(compound);
86  NEM::GEO::GeoManager output(geoMetadata.getDim());
87  static constexpr std::array<TopAbs_ShapeEnum, 4> shapeTypes{
88  TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX};
89  for (auto &shapeType : shapeTypes) {
90  for (TopExp_Explorer explorer{compound, shapeType}; explorer.More();
91  explorer.Next()) {
92  auto &oldSubshape = explorer.Current();
93  if (auto old_metadata = geoMetadata.get(oldSubshape)) {
94  output.insert(transformer.ModifiedShape(oldSubshape),
95  std::move(*old_metadata));
96  }
97  }
98  }
99  return output;
100 }
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
Class to manage TopoDS_Shapes along with metadata.
Definition: GeoManager.H:61
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

◆ createGeo()

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

Implements NEM::NUCMESH::ShapeBase.

Definition at line 59 of file PolarArray.C.

References NEM::NUCMESH::ShapesArray::basicTransformation(), NEM::NUCMESH::ShapesArray::createGeoImpl(), end_, NEM::NUCMESH::ShapeBase::getCenter(), NEM::NUCMESH::ShapeBase::getRotatedPoint(), numShapesInArr_, radius_, rotateWithArray_, and start_.

59  {
60  const auto start = std::fmod(start_, 360.);
61  const auto end = fixEndAngle(start, end_);
62  const auto increment = (end - start) / numShapesInArr_;
63  double angle = start;
64  return this->createGeoImpl([this, increment,
65  &angle](NEM::GEO::GeoManager *const inp) {
66  if (inp) {
67  const auto destCenter =
68  getRotatedPoint(this->getCenter(), {this->radius_, angle});
69  gp_Trsf transformation{};
70  transformation.SetTranslation(
71  gp_Vec{destCenter[0], destCenter[1], destCenter[2]});
72  if (this->rotateWithArray_) {
73  gp_Trsf rotation{};
74  gp_Ax1 axisOfRotation{}; // Z-axis by default
75  rotation.SetRotation(axisOfRotation, angle * M_PI / 180.);
76  transformation *= rotation;
77  }
78  *inp = ShapesArray::basicTransformation(transformation, std::move(*inp));
79  }
80  angle += increment;
81  });
82 }
Class to manage TopoDS_Shapes along with metadata.
Definition: GeoManager.H:61
static std::array< double, 3 > getRotatedPoint(const std::array< double, 3 > &center, const std::array< double, 2 > &rotation)
Definition: ShapeBase.C:58
std::size_t numShapesInArr_
Definition: PolarArray.H:74
const std::array< double, 3 > & getCenter() const
Definition: ShapeBase.C:50
NEM::GEO::GeoManager createGeoImpl(Modifier &&modifier) const
Definition: ShapesArray.H:87
static NEM::GEO::GeoManager basicTransformation(const gp_Trsf &transformation, NEM::GEO::GeoManager &&geoMetadata)
Definition: ShapesArray.C:81

◆ createGeoImpl()

template<typename Modifier >
NEM::GEO::GeoManager NEM::NUCMESH::ShapesArray::createGeoImpl ( Modifier &&  modifier) const
inlineprotectedinherited

Definition at line 87 of file ShapesArray.H.

References NEM::NUCMESH::ShapeBase::mergeGeo().

Referenced by NEM::NUCMESH::HexagonalArray::createGeo(), NEM::NUCMESH::RectangularArray::createGeo(), and createGeo().

87  {
88  NEM::GEO::GeoManager output(0);
89  for (auto &patternId : pattern_) {
90  auto shape = patternId < patternShapes_.size()
91  ? patternShapes_.at(patternId).get()
92  : nullptr;
93  if (shape) {
94  auto subShapeOut = shape->createGeo();
95  modifier(&subShapeOut);
96  ShapeBase::mergeGeo(output, std::move(subShapeOut));
97  } else {
98  modifier(nullptr);
99  }
100  }
101  return output;
102  }
std::vector< decltype(patternShapes_)::size_type > pattern_
Each entry of pattern_ is an index into patternShapes_; subclasses interpret how to transform each en...
Definition: ShapesArray.H:116
Class to manage TopoDS_Shapes along with metadata.
Definition: GeoManager.H:61
std::vector< std::shared_ptr< ShapeBase > > patternShapes_
A set of other ShapeBase objects, referenced by pattern_.
Definition: ShapesArray.H:111
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 s...
Definition: ShapeBase.C:66

◆ fillPattern()

void NEM::NUCMESH::ShapesArray::fillPattern ( std::size_t  idx)
inherited

Definition at line 65 of file ShapesArray.C.

References NEM::NUCMESH::ShapesArray::pattern_.

65  {
66  for (auto &pattern : pattern_) {
67  pattern = idx;
68  }
69 }
std::vector< decltype(patternShapes_)::size_type > pattern_
Each entry of pattern_ is an index into patternShapes_; subclasses interpret how to transform each en...
Definition: ShapesArray.H:116

◆ getCenter()

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

◆ getEndAngle()

double NEM::NUCMESH::PolarArray::getEndAngle ( ) const
inline

Definition at line 63 of file PolarArray.H.

63 { return end_; }

◆ getNumPatternShapes()

std::size_t NEM::NUCMESH::ShapesArray::getNumPatternShapes ( ) const
inherited

Definition at line 45 of file ShapesArray.C.

References NEM::NUCMESH::ShapesArray::patternShapes_.

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

45  {
46  return patternShapes_.size();
47 }
std::vector< std::shared_ptr< ShapeBase > > patternShapes_
A set of other ShapeBase objects, referenced by pattern_.
Definition: ShapesArray.H:111

◆ getNumSubshapes()

std::size_t NEM::NUCMESH::PolarArray::getNumSubshapes ( ) const
inline

Definition at line 58 of file PolarArray.H.

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

58 { return numShapesInArr_; }
std::size_t numShapesInArr_
Definition: PolarArray.H:74

◆ getPattern()

const std::size_t & NEM::NUCMESH::ShapesArray::getPattern ( std::size_t  idx) const
protectedinherited

Definition at line 73 of file ShapesArray.C.

References NEM::NUCMESH::ShapesArray::pattern_.

Referenced by NEM::NUCMESH::RectangularArray::getPattern(), and NEM::NUCMESH::HexagonalArray::getPatternCoordCenter().

73  {
74  return pattern_.at(idx);
75 }
std::vector< decltype(patternShapes_)::size_type > pattern_
Each entry of pattern_ is an index into patternShapes_; subclasses interpret how to transform each en...
Definition: ShapesArray.H:116

◆ getPatternShape()

const ShapeBase * NEM::NUCMESH::ShapesArray::getPatternShape ( std::size_t  idx) const
inherited

Definition at line 49 of file ShapesArray.C.

References NEM::NUCMESH::ShapesArray::patternShapes_.

49  {
50  if (idx < patternShapes_.size()) {
51  return patternShapes_.at(idx).get();
52  } else {
53  return nullptr;
54  }
55 }
std::vector< std::shared_ptr< ShapeBase > > patternShapes_
A set of other ShapeBase objects, referenced by pattern_.
Definition: ShapesArray.H:111

◆ getPatternSize()

std::size_t NEM::NUCMESH::ShapesArray::getPatternSize ( ) const
protectedinherited

Definition at line 71 of file ShapesArray.C.

References NEM::NUCMESH::ShapesArray::pattern_.

71 { return pattern_.size(); }
std::vector< decltype(patternShapes_)::size_type > pattern_
Each entry of pattern_ is an index into patternShapes_; subclasses interpret how to transform each en...
Definition: ShapesArray.H:116

◆ getRadius()

double NEM::NUCMESH::PolarArray::getRadius ( ) const
inline

Definition at line 59 of file PolarArray.H.

59 { return radius_; }

◆ 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 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 }

◆ getRotateWithArray()

bool NEM::NUCMESH::PolarArray::getRotateWithArray ( ) const
inline

Definition at line 65 of file PolarArray.H.

65 { return rotateWithArray_; }

◆ getStartAngle()

double NEM::NUCMESH::PolarArray::getStartAngle ( ) const
inline

Definition at line 61 of file PolarArray.H.

61 { return start_; }

◆ insertPatternShape()

template<typename Shape >
void NEM::NUCMESH::ShapesArray::insertPatternShape ( std::size_t  idx,
Shape &&  shape 
)
inlineinherited

Definition at line 62 of file ShapesArray.H.

62  {
63  this->setPatternShape(idx,
64  std::make_shared<typename std::decay<Shape>::type>(
65  std::forward<Shape>(shape)));
66  }
void setPatternShape(std::size_t idx, const std::shared_ptr< ShapeBase > &shape)
Definition: ShapesArray.C:57

◆ makePatternShape()

template<typename Shape , typename... Args>
void NEM::NUCMESH::ShapesArray::makePatternShape ( std::size_t  idx,
Args &&...  args 
)
inlineinherited

Definition at line 69 of file ShapesArray.H.

69  {
70  this->setPatternShape(idx,
71  std::make_shared<Shape>(std::forward<Args>(args)...));
72  }
void setPatternShape(std::size_t idx, const std::shared_ptr< ShapeBase > &shape)
Definition: ShapesArray.C:57

◆ 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

◆ setEndAngle()

void NEM::NUCMESH::PolarArray::setEndAngle ( double  endAngle)
inline

Definition at line 64 of file PolarArray.H.

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

64 { end_ = endAngle; }

◆ setPattern()

void NEM::NUCMESH::ShapesArray::setPattern ( std::size_t  idx,
std::size_t  patternKey 
)
protectedinherited

Definition at line 77 of file ShapesArray.C.

References NEM::NUCMESH::ShapesArray::pattern_.

Referenced by NEM::DRV::JSON::modify_helper(), NEM::NUCMESH::RectangularArray::setPattern(), and NEM::NUCMESH::HexagonalArray::setPatternCoordCenter().

77  {
78  pattern_.at(idx) = patternKey;
79 }
std::vector< decltype(patternShapes_)::size_type > pattern_
Each entry of pattern_ is an index into patternShapes_; subclasses interpret how to transform each en...
Definition: ShapesArray.H:116

◆ setPatternShape()

void NEM::NUCMESH::ShapesArray::setPatternShape ( std::size_t  idx,
const std::shared_ptr< ShapeBase > &  shape 
)
inherited

Definition at line 57 of file ShapesArray.C.

References NEM::NUCMESH::ShapesArray::patternShapes_.

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

58  {
59  if (idx >= patternShapes_.size()) {
60  patternShapes_.resize(idx + 1);
61  }
62  patternShapes_.at(idx) = shape;
63 }
std::vector< std::shared_ptr< ShapeBase > > patternShapes_
A set of other ShapeBase objects, referenced by pattern_.
Definition: ShapesArray.H:111

◆ setRadius()

void NEM::NUCMESH::PolarArray::setRadius ( double  radius)
inline

Definition at line 60 of file PolarArray.H.

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

60 { radius_ = radius; }

◆ setRotateWithArray()

void NEM::NUCMESH::PolarArray::setRotateWithArray ( bool  rotateWithArray)
inline

Definition at line 66 of file PolarArray.H.

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

66  {
67  rotateWithArray_ = rotateWithArray;
68  }

◆ setStartAngle()

void NEM::NUCMESH::PolarArray::setStartAngle ( double  startAngle)
inline

Definition at line 62 of file PolarArray.H.

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

62 { start_ = startAngle; }

Member Data Documentation

◆ end_

double NEM::NUCMESH::PolarArray::end_
private

Definition at line 77 of file PolarArray.H.

Referenced by createGeo().

◆ numShapesInArr_

std::size_t NEM::NUCMESH::PolarArray::numShapesInArr_
private

Definition at line 74 of file PolarArray.H.

Referenced by createGeo().

◆ radius_

double NEM::NUCMESH::PolarArray::radius_
private

Definition at line 75 of file PolarArray.H.

Referenced by createGeo().

◆ rotateWithArray_

bool NEM::NUCMESH::PolarArray::rotateWithArray_
private

Definition at line 78 of file PolarArray.H.

Referenced by createGeo().

◆ start_

double NEM::NUCMESH::PolarArray::start_
private

Definition at line 76 of file PolarArray.H.

Referenced by createGeo().


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