ENH: additional methods and improvements to plane

- signedDistance() method is like distance() but retains
  the positive/negative sign for the side of the plane.

- the sign() method returns the sign as -1,0,+1 integer for
  classification purposes where it is important to distinguish between
  a zero value and a positive value (eg, for cutting). Optional
  tolerance can be supplied to round for zero.

- refactor and inlined simple and frequently used methods.

- add boundBox faceCentre() method, which can be useful for creating
  clipping planes from a bounding box.
  Relocated treeBoundBox faceNormals to boundBox since they apply
  equally there - the meaning of the faces (x-min, x-max, etc)
  is the same, even if the point addressing for the faces differs.
This commit is contained in:
Mark Olesen
2018-08-03 23:17:49 +02:00
parent 84e2df4994
commit de2eed3e7d
32 changed files with 537 additions and 442 deletions

View File

@ -126,8 +126,7 @@ void Foam::sampledCuttingPlane::createGeometry()
forAll(cc, i)
{
// Signed distance
fld[i] = (cc[i] - plane_.refPoint()) & plane_.normal();
fld[i] = plane_.signedDistance(cc[i]);
}
}
@ -163,7 +162,7 @@ void Foam::sampledCuttingPlane::createGeometry()
fld.setSize(pp.size());
forAll(fld, i)
{
fld[i] = (cc[i] - plane_.refPoint()) & plane_.normal();
fld[i] = plane_.signedDistance(cc[i]);
}
}
else
@ -173,7 +172,7 @@ void Foam::sampledCuttingPlane::createGeometry()
forAll(fld, i)
{
fld[i] = (cc[i] - plane_.refPoint()) & plane_.normal();
fld[i] = plane_.signedDistance(cc[i]);
}
}
}
@ -191,7 +190,7 @@ void Foam::sampledCuttingPlane::createGeometry()
forAll(pointDistance_, i)
{
pointDistance_[i] = (pts[i] - plane_.refPoint()) & plane_.normal();
pointDistance_[i] = plane_.signedDistance(pts[i]);
}
}

View File

@ -90,7 +90,7 @@ Foam::sampledPlane::sampledPlane
{
coordinateSystem cs(mesh, dict.subDict("coordinateSystem"));
const point base = cs.globalPosition(planeDesc().refPoint());
const point base = cs.globalPosition(planeDesc().origin());
const vector norm = cs.globalVector(planeDesc().normal());
// Assign the plane description
@ -334,8 +334,8 @@ Foam::tmp<Foam::tensorField> Foam::sampledPlane::interpolate
void Foam::sampledPlane::print(Ostream& os) const
{
os << "sampledPlane: " << name() << " :"
<< " base:" << refPoint()
<< " normal:" << normal()
<< " base:" << plane::origin()
<< " normal:" << plane::normal()
<< " triangulate:" << triangulate_
<< " faces:" << faces().size()
<< " points:" << points().size();

View File

@ -91,7 +91,7 @@ Foam::surfMeshSamplePlane::surfMeshSamplePlane
{
coordinateSystem cs(mesh, dict.subDict("coordinateSystem"));
const point base = cs.globalPosition(planeDesc().refPoint());
const point base = cs.globalPosition(planeDesc().origin());
const vector norm = cs.globalVector(planeDesc().normal());
// Assign the plane description
@ -263,8 +263,8 @@ bool Foam::surfMeshSamplePlane::sample
void Foam::surfMeshSamplePlane::print(Ostream& os) const
{
os << "surfMeshSamplePlane: " << name() << " :"
<< " base:" << cuttingPlane::refPoint()
<< " normal:" << cuttingPlane::normal()
<< " base:" << plane::origin()
<< " normal:" << plane::normal()
<< " triangulate:" << triangulate_
<< " faces:" << SurfaceSource::surfFaces().size()
<< " points:" << SurfaceSource::points().size();

View File

@ -86,7 +86,7 @@ void Foam::cuttingPlane::calcCutCells
}
// Set correct list size
meshCells_.setSize(cutcelli);
meshCells_.resize(cutcelli);
}
@ -102,7 +102,7 @@ void Foam::cuttingPlane::intersectEdges
const pointField& points = mesh.points();
// Per edge -1 or the label of the intersection point
edgePoint.setSize(edges.size());
edgePoint.resize(edges.size());
DynamicList<point> dynCuttingPoints(4*meshCells_.size());

View File

@ -1080,7 +1080,7 @@ void Foam::isoSurface::trimToPlanes
forAll(planes, faceI)
{
const plane& pl = planes[faceI];
const plane& pln = planes[faceI];
if (useA)
{
@ -1088,7 +1088,7 @@ void Foam::isoSurface::trimToPlanes
forAll(insideOpA.tris_, i)
{
const triPoints& tri = insideOpA.tris_[i];
triPointRef(tri).sliceWithPlane(pl, insideOpB, dop);
triPointRef(tri).sliceWithPlane(pln, insideOpB, dop);
}
}
else
@ -1097,7 +1097,7 @@ void Foam::isoSurface::trimToPlanes
forAll(insideOpB.tris_, i)
{
const triPoints& tri = insideOpB.tris_[i];
triPointRef(tri).sliceWithPlane(pl, insideOpA, dop);
triPointRef(tri).sliceWithPlane(pln, insideOpA, dop);
}
}
useA = !useA;
@ -1141,13 +1141,11 @@ void Foam::isoSurface::trimToBox
}
// Generate inwards pointing planes
PtrList<plane> planes(6);
const pointField pts(bb.treeBoundBox::points());
forAll(treeBoundBox::faces, faceI)
PtrList<plane> planes(treeBoundBox::faceNormals.size());
forAll(treeBoundBox::faceNormals, faceI)
{
const face& f = treeBoundBox::faces[faceI];
const vector& n = treeBoundBox::faceNormals[faceI];
planes.set(faceI, new plane(pts[f[0]], -n));
planes.set(faceI, new plane(bb.faceCentre(faceI), -n));
}
label nTris = triPoints.size()/3;