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

Detailed Description

Definition at line 40 of file HexagonalArray.H.

Public Member Functions

 HexagonalArray (std::size_t numRadii, double deltaRadius, const std::array< double, 3 > &center={0, 0, 0})
 
const std::size_t & getPatternRowCol (int row, int col) const
 
const std::size_t & getPatternCoordCenter (int right, int rightUp) const
 
void setPatternRowCol (int row, int col, std::size_t patternKey)
 
void setPatternCoordCenter (int right, int rightUp, std::size_t patternKey)
 The shape will be translated by right * [getGridDistance(), 0, 0] + rightUp * [getGridDistance() * cos(60), getGridDistance() * sin(60), 0] + getCenter() . More...
 
std::size_t getNumRadii () const
 
double getGridDistance () const
 
void setGridDistance (double gridDistance)
 
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

double delta_
 
std::size_t numRadii_
 

Inherits NEM::NUCMESH::ShapesArray.

Constructor & Destructor Documentation

◆ HexagonalArray()

NEM::NUCMESH::HexagonalArray::HexagonalArray ( std::size_t  numRadii,
double  deltaRadius,
const std::array< double, 3 > &  center = {0, 0, 0} 
)

Definition at line 141 of file HexagonalArray.C.

143  : ShapesArray(center, 3 * (numRadii) * (numRadii - 1) + 1),
144  delta_(deltaRadius),
145  numRadii_(numRadii) {}
ShapesArray(const std::array< double, 3 > &center, std::size_t numPatternShapes)
Definition: ShapesArray.C:41

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 createGeo(), NEM::NUCMESH::RectangularArray::createGeo(), and NEM::NUCMESH::PolarArray::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::HexagonalArray::createGeo ( ) const
overrideprotectedvirtual
Returns
A NEM::GEO::GeoManager object representing the shape described by this object

Implements NEM::NUCMESH::ShapeBase.

Definition at line 171 of file HexagonalArray.C.

References NEM::NUCMESH::ShapesArray::basicTransformation(), NEM::NUCMESH::ShapesArray::createGeoImpl(), delta_, and NEM::NUCMESH::ShapeBase::getCenter().

171  {
172  int right = 0;
173  int rightUp = 0;
174  int side = 5;
175  return this->createGeoImpl([this, &right, &rightUp,
176  &side](NEM::GEO::GeoManager *const inp) {
177  if (inp) {
178  const auto &center = this->getCenter();
179  const gp_Vec dest{
180  center[0] + delta_ * (right + rightUp * std::cos(60 * M_PI / 180.)),
181  center[1] + rightUp * delta_ * std::sin(60 * M_PI / 180.), center[2]};
182  gp_Trsf translation{};
183  translation.SetTranslation(dest);
184  *inp = ShapesArray::basicTransformation(translation, std::move(*inp));
185  }
186  incrementSpiral(right, rightUp, side);
187  });
188 }
Class to manage TopoDS_Shapes along with metadata.
Definition: GeoManager.H:61
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 createGeo(), NEM::NUCMESH::RectangularArray::createGeo(), and NEM::NUCMESH::PolarArray::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

◆ getGridDistance()

double NEM::NUCMESH::HexagonalArray::getGridDistance ( ) const
inline

Definition at line 57 of file HexagonalArray.H.

57 { return delta_; }

◆ 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

◆ getNumRadii()

std::size_t NEM::NUCMESH::HexagonalArray::getNumRadii ( ) const
inline

Definition at line 56 of file HexagonalArray.H.

56 { return numRadii_; }

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

◆ getPatternCoordCenter()

const std::size_t & NEM::NUCMESH::HexagonalArray::getPatternCoordCenter ( int  right,
int  rightUp 
) const

Definition at line 152 of file HexagonalArray.C.

References NEM::NUCMESH::ShapesArray::getPattern().

Referenced by getPatternRowCol().

153  {
154  return this->getPattern(coordsToSpiralFlat(right, rightUp));
155 }
const std::size_t & getPattern(std::size_t idx) const
Definition: ShapesArray.C:73

◆ getPatternRowCol()

const std::size_t & NEM::NUCMESH::HexagonalArray::getPatternRowCol ( int  row,
int  col 
) const

Definition at line 147 of file HexagonalArray.C.

References getPatternCoordCenter(), and numRadii_.

147  {
148  auto coords = rowColToCoords(row, col, numRadii_);
149  return getPatternCoordCenter(coords[0], coords[1]);
150 }
const std::size_t & getPatternCoordCenter(int right, int rightUp) const

◆ 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

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

◆ 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

◆ setGridDistance()

void NEM::NUCMESH::HexagonalArray::setGridDistance ( double  gridDistance)
inline

Definition at line 58 of file HexagonalArray.H.

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

58 { delta_ = gridDistance; }

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

◆ setPatternCoordCenter()

void NEM::NUCMESH::HexagonalArray::setPatternCoordCenter ( int  right,
int  rightUp,
std::size_t  patternKey 
)

Definition at line 163 of file HexagonalArray.C.

References NEM::NUCMESH::ShapesArray::setPattern().

Referenced by setPatternRowCol().

164  {
165  this->setPattern(coordsToSpiralFlat(right, rightUp), patternKey);
166 }
void setPattern(std::size_t idx, std::size_t patternKey)
Definition: ShapesArray.C:77

◆ setPatternRowCol()

void NEM::NUCMESH::HexagonalArray::setPatternRowCol ( int  row,
int  col,
std::size_t  patternKey 
)

Definition at line 157 of file HexagonalArray.C.

References numRadii_, and setPatternCoordCenter().

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

158  {
159  auto coords = rowColToCoords(row, col, numRadii_);
160  setPatternCoordCenter(coords[0], coords[1], patternKey);
161 }
void setPatternCoordCenter(int right, int rightUp, std::size_t patternKey)
The shape will be translated by right * [getGridDistance(), 0, 0] + rightUp * [getGridDistance() * c...

◆ 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

Member Data Documentation

◆ delta_

double NEM::NUCMESH::HexagonalArray::delta_
private

Definition at line 64 of file HexagonalArray.H.

Referenced by createGeo().

◆ numRadii_

std::size_t NEM::NUCMESH::HexagonalArray::numRadii_
private

Definition at line 65 of file HexagonalArray.H.

Referenced by getPatternRowCol(), and setPatternRowCol().


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