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.
RectangularArray.C
Go to the documentation of this file.
1 /*******************************************************************************
2 * Promesh *
3 * Copyright (C) 2022, IllinoisRocstar LLC. All rights reserved. *
4 * *
5 * Promesh is the property of IllinoisRocstar LLC. *
6 * *
7 * IllinoisRocstar LLC *
8 * Champaign, IL *
9 * www.illinoisrocstar.com *
10 * promesh@illinoisrocstar.com *
11 *******************************************************************************/
12 /*******************************************************************************
13 * This file is part of Promesh *
14 * *
15 * This version of Promesh is free software: you can redistribute it and/or *
16 * modify it under the terms of the GNU Lesser General Public License as *
17 * published by the Free Software Foundation, either version 3 of the License, *
18 * or (at your option) any later version. *
19 * *
20 * Promesh is distributed in the hope that it will be useful, but WITHOUT ANY *
21 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more *
23 * details. *
24 * *
25 * You should have received a copy of the GNU Lesser General Public License *
26 * along with this program. If not, see <https://www.gnu.org/licenses/>. *
27 * *
28 *******************************************************************************/
30 
31 #include <gp_Trsf.hxx>
32 #include <gp_Vec.hxx>
33 
34 namespace NEM {
35 namespace NUCMESH {
36 
37 RectangularArray::RectangularArray(const std::array<std::size_t, 2> &gridDims,
38  const std::array<double, 2> &deltaGrid,
39  const std::array<double, 3> &center)
40  : ShapesArray(center, gridDims[0] * gridDims[1]),
41  dims_(gridDims),
42  delta_(deltaGrid) {}
43 
44 const std::size_t &RectangularArray::getPattern(std::size_t x,
45  std::size_t y) const {
46  return this->ShapesArray::getPattern(x * dims_[1] + y);
47 }
48 
49 void RectangularArray::setPattern(std::size_t x, std::size_t y,
50  std::size_t patternKey) {
51  this->ShapesArray::setPattern(x * dims_[1] + y, patternKey);
52 }
53 
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 }
74 
75 } // namespace NUCMESH
76 } // namespace NEM
NEM::GEO::GeoManager createGeo() const override
Construct a NEM::GEO::GeoManager.
Class to manage TopoDS_Shapes along with metadata.
Definition: GeoManager.H:61
std::array< double, 2 > delta_
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::array< double, 3 > & getCenter() const
Definition: ShapeBase.C:50
NEM::GEO::GeoManager createGeoImpl(Modifier &&modifier) const
Definition: ShapesArray.H:87
const std::size_t & getPattern(std::size_t x, std::size_t y) const
std::array< std::size_t, 2 > dims_
static NEM::GEO::GeoManager basicTransformation(const gp_Trsf &transformation, NEM::GEO::GeoManager &&geoMetadata)
Definition: ShapesArray.C:81
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]...
Abstract base class representing a set of other ShapeBase objects, with a transformation applied to e...
Definition: ShapesArray.H:52
void setPattern(std::size_t idx, std::size_t patternKey)
Definition: ShapesArray.C:77
const std::size_t & getPattern(std::size_t idx) const
Definition: ShapesArray.C:73