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

Detailed Description

Definition at line 40 of file RectangularArray.H.

Public Member Functions

 RectangularArray (const std::array< std::size_t, 2 > &gridDims, const std::array< double, 2 > &deltaGrid, const std::array< double, 3 > &center={0, 0, 0})
 
const std::size_t & getPattern (std::size_t x, std::size_t y) const
 
void setPattern (std::size_t x, std::size_t y, std::size_t patternKey)
 The shape at [x, y] will be translated by [(x - (getGridDims()[0] - 1) / 2) * getGridDistance()[0], (y - (getGridDims()[1]. More...
 
const std::array< std::size_t, 2 > & getGridDims () const
 
const std::array< double, 2 > & getGridDistance () const
 
void setGridDistance (const std::array< double, 2 > &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

std::array< std::size_t, 2 > dims_
 
std::array< double, 2 > delta_
 

Inherits NEM::NUCMESH::ShapesArray.

Constructor & Destructor Documentation

◆ RectangularArray()

NEM::NUCMESH::RectangularArray::RectangularArray ( const std::array< std::size_t, 2 > &  gridDims,
const std::array< double, 2 > &  deltaGrid,
const std::array< double, 3 > &  center = {0, 0, 0} 
)

Definition at line 37 of file RectangularArray.C.

40  : ShapesArray(center, gridDims[0] * gridDims[1]),
41  dims_(gridDims),
42  delta_(deltaGrid) {}
std::array< double, 2 > delta_
ShapesArray(const std::array< double, 3 > &center, std::size_t numPatternShapes)
Definition: ShapesArray.C:41
std::array< std::size_t, 2 > dims_

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

Implements NEM::NUCMESH::ShapeBase.

Definition at line 54 of file RectangularArray.C.

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

54  {
55  const auto maxY = static_cast<int>(this->dims_[1] - 1);
56  std::array<int, 2> coord{-static_cast<int>(this->dims_[0] - 1), -maxY};
57  return this->createGeoImpl([this, maxY,
58  &coord](NEM::GEO::GeoManager *const inp) {
59  if (inp) {
60  auto &center = this->getCenter();
61  gp_Trsf transformation{};
62  transformation.SetTranslation(
63  gp_Vec{center[0] + coord[0] * this->delta_[0] / 2.,
64  center[1] + coord[1] * this->delta_[1] / 2., center[2]});
65  *inp = ShapesArray::basicTransformation(transformation, std::move(*inp));
66  }
67  coord[1] += 2;
68  if (coord[1] > maxY) {
69  coord[1] = -maxY;
70  coord[0] += 2;
71  }
72  });
73 }
Class to manage TopoDS_Shapes along with metadata.
Definition: GeoManager.H:61
std::array< double, 2 > delta_
const std::array< double, 3 > & getCenter() const
Definition: ShapeBase.C:50
NEM::GEO::GeoManager createGeoImpl(Modifier &&modifier) const
Definition: ShapesArray.H:87
std::array< std::size_t, 2 > dims_
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(), 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

◆ getGridDims()

const std::array<std::size_t, 2>& NEM::NUCMESH::RectangularArray::getGridDims ( ) const
inline

Definition at line 54 of file RectangularArray.H.

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

54 { return dims_; }
std::array< std::size_t, 2 > dims_

◆ getGridDistance()

const std::array<double, 2>& NEM::NUCMESH::RectangularArray::getGridDistance ( ) const
inline

Definition at line 55 of file RectangularArray.H.

55 { return delta_; }
std::array< double, 2 > 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

◆ getPattern() [1/2]

const std::size_t & NEM::NUCMESH::RectangularArray::getPattern ( std::size_t  x,
std::size_t  y 
) const

Definition at line 44 of file RectangularArray.C.

References dims_, and NEM::NUCMESH::ShapesArray::getPattern().

45  {
46  return this->ShapesArray::getPattern(x * dims_[1] + y);
47 }
std::array< std::size_t, 2 > dims_
const std::size_t & getPattern(std::size_t idx) const
Definition: ShapesArray.C:73

◆ getPattern() [2/2]

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

◆ 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::RectangularArray::setGridDistance ( const std::array< double, 2 > &  gridDistance)
inline

Definition at line 56 of file RectangularArray.H.

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

56  {
57  delta_ = gridDistance;
58  }
std::array< double, 2 > delta_

◆ setPattern() [1/2]

void NEM::NUCMESH::RectangularArray::setPattern ( std::size_t  x,
std::size_t  y,
std::size_t  patternKey 
)

Definition at line 49 of file RectangularArray.C.

References dims_, and NEM::NUCMESH::ShapesArray::setPattern().

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

50  {
51  this->ShapesArray::setPattern(x * dims_[1] + y, patternKey);
52 }
std::array< std::size_t, 2 > dims_
void setPattern(std::size_t idx, std::size_t patternKey)
Definition: ShapesArray.C:77

◆ setPattern() [2/2]

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(), 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

Member Data Documentation

◆ delta_

std::array<double, 2> NEM::NUCMESH::RectangularArray::delta_
private

Definition at line 65 of file RectangularArray.H.

Referenced by createGeo().

◆ dims_

std::array<std::size_t, 2> NEM::NUCMESH::RectangularArray::dims_
private

Definition at line 64 of file RectangularArray.H.

Referenced by createGeo(), getPattern(), and setPattern().


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