Merge branch 'cv2d'

This commit is contained in:
laurence
2011-12-09 10:47:54 +00:00
73 changed files with 7008 additions and 512 deletions

View File

@ -49,6 +49,7 @@ Note
#include "triSurface.H"
#include "OFstream.H"
#include "OSspecific.H"
#include "Time.H"
using namespace Foam;
@ -83,9 +84,25 @@ int main(int argc, char *argv[])
"factor",
"geometry scaling factor - default is 1"
);
argList::addOption
(
"writePrecision",
"label",
"write to output with the specified precision"
);
argList args(argc, argv);
if (args.optionFound("writePrecision"))
{
label writePrecision = args.optionRead<label>("writePrecision");
IOstream::defaultPrecision(writePrecision);
Sout.precision(writePrecision);
Info<< "Output write precision set to " << writePrecision << endl;
}
const fileName importName = args[1];
const fileName exportName = args[2];

View File

@ -44,6 +44,7 @@ Description
#include "indexedOctree.H"
#include "treeDataEdge.H"
#include "unitConversion.H"
#include "plane.H"
using namespace Foam;
@ -94,6 +95,56 @@ void deleteBox
}
bool onLine(const point& p, const linePointRef& line)
{
const point& a = line.start();
const point& b = line.end();
if
(
( p.x() < min(a.x(), b.x()) || p.x() > max(a.x(), b.x()) )
|| ( p.y() < min(a.y(), b.y()) || p.y() > max(a.y(), b.y()) )
|| ( p.z() < min(a.z(), b.z()) || p.z() > max(a.z(), b.z()) )
)
{
return false;
}
return true;
}
// Deletes all edges inside/outside bounding box from set.
void deleteEdges
(
const triSurface& surf,
const plane& cutPlane,
List<surfaceFeatures::edgeStatus>& edgeStat
)
{
const pointField& points = surf.points();
const labelList& meshPoints = surf.meshPoints();
forAll(edgeStat, edgeI)
{
const edge& e = surf.edges()[edgeI];
const point& p0 = points[meshPoints[e.start()]];
const point& p1 = points[meshPoints[e.end()]];
const linePointRef line(p0, p1);
// If edge does not intersect the plane, delete.
scalar intersect = cutPlane.lineIntersect(line);
point featPoint = intersect * (p1 - p0) + p0;
if (!onLine(featPoint, line))
{
edgeStat[edgeI] = surfaceFeatures::NONE;
}
}
}
void drawHitProblem
(
label fI,
@ -270,6 +321,12 @@ int main(int argc, char *argv[])
"manifoldEdgesOnly",
"remove any non-manifold (open or more than two connected faces) edges"
);
argList::addOption
(
"plane",
"(nx ny nz)(z0 y0 z0)",
"use a plane to create feature edges for 2D meshing"
);
# ifdef ENABLE_CURVATURE
argList::addBoolOption
@ -454,6 +511,21 @@ int main(int argc, char *argv[])
}
}
if (args.optionFound("plane"))
{
plane cutPlane(args.optionLookup("plane")());
deleteEdges
(
surf,
cutPlane,
edgeStat
);
Info<< "Only edges that intersect the plane with normal "
<< cutPlane.normal() << " and base point " << cutPlane.refPoint()
<< " will be included as feature edges."<< endl;
}
surfaceFeatures newSet(surf);
newSet.setFromStatus(edgeStat);
@ -475,7 +547,6 @@ int main(int argc, char *argv[])
<< endl;
// Extracting and writing a extendedFeatureEdgeMesh
extendedFeatureEdgeMesh feMesh
(
newSet,