Skip to content
Snippets Groups Projects
Commit 02afe270 authored by samuel.hayden's avatar samuel.hayden
Browse files

Lattice builder base class now stores the base data required to build the...

Lattice builder base class now stores the base data required to build the lattice. Extra data is handled by derived classes
parent 0282cf6c
No related branches found
No related tags found
No related merge requests found
......@@ -20,11 +20,12 @@ private:
std::vector<ErrorCodes> _errors;
protected:
bool _buildSuccessful;
double _cx, _cy, _cz; // Size of each cell
const std::vector<gp_Pnt>& _cellPositions; // Position of node1 of unit cell (NOT CENTER)
const std::vector<double>& _cellRadii;
/* Data to build lattice */
double _cellX, _cellY, _cellZ;
std::vector<double> _cellRadii;
std::vector<gp_Pnt> _cellPositions;
/* Built objects */
TopoDS_ListOfShape _unitCells;
TopoDS_Shape _tmpUnitCell;
TopoDS_Shape _lattice;
......@@ -36,10 +37,7 @@ protected:
bool mergeCells();
bool trimLattice();
public:
BuildLattice(const std::vector<gp_Pnt>& positions, const std::vector<double>& radii, double cx = 5.0, double cy = 5.0, double cz = 5.0)
: _cellPositions(positions), _cellRadii(radii), _buildSuccessful(false),
_cx(cx), _cy(cy), _cz(cz)
void determineBoundingBox()
{
// Compute Basic Bounding Box
double x0 = DBL_MAX, y0 = DBL_MAX, z0 = DBL_MAX;
......@@ -53,15 +51,16 @@ public:
y1 = point.Y() > y1 ? point.Y() : y1;
z1 = point.Z() > z1 ? point.Z() : z1;
}
x1 += _cx;
y1 += _cy;
z1 += _cz;
x1 += _cellX;
y1 += _cellY;
z1 += _cellZ;
_boundingBox = BRepPrimAPI_MakeBox(gp_Pnt(x0, y0, z0), gp_Pnt(x1, y1, z1));
}
// Setters
void setCellSize(double cellWidth, double cellDepth, double cellHeight) { _cx = cellWidth, _cy = cellDepth; _cz = cellHeight; }
void setBoundingBox(const TopoDS_Solid& boundingBox) { _boundingBox = _boundingBox; }
public:
BuildLattice()
: _cellX(0.0), _cellY(0.0), _cellZ(0.0)
{}
bool buildLattice();
TopoDS_Shape getLattice() { return _lattice; }
......@@ -164,11 +163,14 @@ bool BuildLattice<UnitCell>::trimLattice()
template<class UnitCell>
inline bool BuildLattice<UnitCell>::buildLattice()
{
if (_boundingBox.IsNull())
determineBoundingBox();
size_t nCells = _cellRadii.size();
std::cout << "[Info](buildLattice) Building " << nCells << " cells" << std::endl;
for (size_t i = 0; i < nCells; i++)
{
if (!buildCell(_cx, _cy, _cz, _cellRadii[i]))
if (!buildCell(_cellX, _cellY, _cellZ, _cellRadii[i]))
return false;
const gp_Pnt& pos = _cellPositions[i];
if (!translateCell(pos.X(), pos.Y(), pos.Z()))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment