Skip to content
Snippets Groups Projects
Commit 3c8d80b9 authored by Franjo's avatar Franjo
Browse files

surfaceBoundingBox can now use fms, too.

parent 483f38e1
No related branches found
No related tags found
No related merge requests found
...@@ -29,14 +29,14 @@ Description ...@@ -29,14 +29,14 @@ Description
#include "argList.H" #include "argList.H"
#include "IFstream.H" #include "IFstream.H"
#include "fileName.H" #include "fileName.H"
#include "triSurface.H" #include "triSurf.H"
#include "triSurfModifier.H"
#include "boundBox.H" #include "boundBox.H"
#include "OFstream.H" #include "OFstream.H"
#include <cstdlib> #include <cstdlib>
#include <sstream> #include <sstream>
#include "triSurfaceDetectFeatureEdges.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program: // Main program:
using namespace Foam; using namespace Foam;
...@@ -67,8 +67,9 @@ int main(int argc, char *argv[]) ...@@ -67,8 +67,9 @@ int main(int argc, char *argv[])
<< exit(FatalError); << exit(FatalError);
} }
triSurface origSurface(inFileName); triSurf origSurface(inFileName);
const pointField& points = origSurface.points(); triSurfModifier sMod(origSurface);
pointField& points = sMod.pointsAccess();
const boundBox bb(points); const boundBox bb(points);
...@@ -100,36 +101,33 @@ int main(int argc, char *argv[]) ...@@ -100,36 +101,33 @@ int main(int argc, char *argv[])
//- generate bounding box points //- generate bounding box points
const label nPoints = points.size(); const label nPoints = points.size();
pointField newPoints(nPoints+8); points.setSize(nPoints + 8);
forAll(points, pointI)
newPoints[pointI] = points[pointI];
newPoints[nPoints] = newBB.min(); points[nPoints] = newBB.min();
newPoints[nPoints+1] = points[nPoints+1] =
point(newBB.max().x(), newBB.min().y(), newBB.min().z()); point(newBB.max().x(), newBB.min().y(), newBB.min().z());
newPoints[nPoints+2] = points[nPoints+2] =
point(newBB.min().x(), newBB.max().y(), newBB.min().z()); point(newBB.min().x(), newBB.max().y(), newBB.min().z());
newPoints[nPoints+3] = points[nPoints+3] =
point(newBB.max().x(), newBB.max().y(), newBB.min().z()); point(newBB.max().x(), newBB.max().y(), newBB.min().z());
newPoints[nPoints+4] = points[nPoints+4] =
point(newBB.min().x(), newBB.min().y(), newBB.max().z()); point(newBB.min().x(), newBB.min().y(), newBB.max().z());
newPoints[nPoints+5] = points[nPoints+5] =
point(newBB.max().x(), newBB.min().y(), newBB.max().z()); point(newBB.max().x(), newBB.min().y(), newBB.max().z());
newPoints[nPoints+6] = points[nPoints+6] =
point(newBB.min().x(), newBB.max().y(), newBB.max().z()); point(newBB.min().x(), newBB.max().y(), newBB.max().z());
newPoints[nPoints+7] = newBB.max(); points[nPoints+7] = newBB.max();
//- generate bounding bound triangles //- generate bounding bound triangles
const label nTriangles = origSurface.size(); const label nTriangles = origSurface.size();
List<labelledTri> newTriangles(nTriangles+12); LongList<labelledTri>& newTriangles = sMod.facetsAccess();
forAll(origSurface, triI) newTriangles.setSize(nTriangles+12);
newTriangles[triI] = origSurface[triI];
//- create patches //- create patches
geometricSurfacePatchList& newPatches = sMod.patchesAccess();
const label nPatches = origSurface.patches().size(); const label nPatches = origSurface.patches().size();
geometricSurfacePatchList newPatches(nPatches+6); newPatches.setSize(nPatches+6);
forAll(origSurface.patches(), patchI)
newPatches[patchI] = origSurface.patches()[patchI];
newPatches[nPatches].name() = "xMin"; newPatches[nPatches].name() = "xMin";
newPatches[nPatches+1].name() = "xMax"; newPatches[nPatches+1].name() = "xMax";
newPatches[nPatches+2].name() = "yMin"; newPatches[nPatches+2].name() = "yMin";
...@@ -169,8 +167,7 @@ int main(int argc, char *argv[]) ...@@ -169,8 +167,7 @@ int main(int argc, char *argv[])
labelledTri(nPoints+4, nPoints+5, nPoints+7, nPatches+5); labelledTri(nPoints+4, nPoints+5, nPoints+7, nPatches+5);
//- write the surface //- write the surface
triSurface newSurface(newTriangles, newPatches, newPoints); origSurface.writeSurface(outFileName);
newSurface.write(outFileName);
Info << "End\n" << endl; Info << "End\n" << endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment