31 #define _USE_MATH_DEFINES 34 #include <gp_Trsf.hxx> 42 std::size_t coordsToSpiralFlat(
int right,
int rightUp) {
56 ring = right + rightUp;
58 if (ring == 0) offset = -1;
59 }
else if (right <= -rightUp) {
71 ring = -(right + rightUp);
73 }
else if (-right <= rightUp) {
84 return 3 * ring * (ring - 1) + 1 + corner * ring + offset;
87 void incrementSpiral(
int &right,
int &rightUp,
int &side) {
92 if (right == 0) ++side;
97 if (right == -rightUp) ++side;
102 if (rightUp == 0) ++side;
108 if (right == 0) ++side;
113 if (right == -rightUp) ++side;
130 std::array<int, 2> rowColToCoords(
int row,
int col, std::size_t width) {
131 int iwidth =
static_cast<int>(width);
132 if (row <= iwidth - 1) {
133 return {col - iwidth + 1, iwidth - row - 1};
135 return {row + col - 2 * (iwidth - 1), iwidth - row - 1};
142 const std::array<double, 3> ¢er)
143 :
ShapesArray(center, 3 * (numRadii) * (numRadii - 1) + 1),
145 numRadii_(numRadii) {}
148 auto coords = rowColToCoords(row, col,
numRadii_);
154 return this->
getPattern(coordsToSpiralFlat(right, rightUp));
158 std::size_t patternKey) {
159 auto coords = rowColToCoords(row, col,
numRadii_);
164 std::size_t patternKey) {
165 this->
setPattern(coordsToSpiralFlat(right, rightUp), patternKey);
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);
186 incrementSpiral(right, rightUp, side);
Class to manage TopoDS_Shapes along with metadata.
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() * c...
NEM::GEO::GeoManager createGeo() const override
Construct a NEM::GEO::GeoManager.
HexagonalArray(std::size_t numRadii, double deltaRadius, const std::array< double, 3 > ¢er={0, 0, 0})
const std::array< double, 3 > & getCenter() const
const std::size_t & getPatternRowCol(int row, int col) const
NEM::GEO::GeoManager createGeoImpl(Modifier &&modifier) const
const std::size_t & getPatternCoordCenter(int right, int rightUp) const
static NEM::GEO::GeoManager basicTransformation(const gp_Trsf &transformation, NEM::GEO::GeoManager &&geoMetadata)
Abstract base class representing a set of other ShapeBase objects, with a transformation applied to e...
void setPattern(std::size_t idx, std::size_t patternKey)
const std::size_t & getPattern(std::size_t idx) const