STYLE: use triSurface::FaceType where triangle or region information

not required
This commit is contained in:
Mark Olesen
2010-11-26 20:39:46 +01:00
parent 6d73c32b04
commit 0d662c74c6
30 changed files with 198 additions and 384 deletions

View File

@ -47,20 +47,17 @@ bool validTri
const labelledTri& f = surf[faceI];
if
(
(f[0] < 0) || (f[0] >= surf.points().size())
|| (f[1] < 0) || (f[1] >= surf.points().size())
|| (f[2] < 0) || (f[2] >= surf.points().size())
)
forAll(f, fp)
{
if (f[fp] < 0 || f[fp] >= surf.points().size())
{
WarningIn("validTri(const triSurface&, const label)")
<< "triangle " << faceI << " vertices " << f
<< " uses point indices outside point range 0.."
<< surf.points().size()-1 << endl;
return false;
}
}
if ((f[0] == f[1]) || (f[0] == f[2]) || (f[1] == f[2]))
{

View File

@ -100,8 +100,8 @@ static void splitTri
label oldNTris = tris.size();
label fp = findIndex(f, e[0]);
label fp1 = (fp+1)%3;
label fp2 = (fp1+1)%3;
label fp1 = f.fcIndex(fp);
label fp2 = f.fcIndex(fp1);
if (f[fp1] == e[1])
{

View File

@ -34,7 +34,7 @@ static void markPointNbrs
boolList& okToCollapse
)
{
const labelledTri& f = surf.localFaces()[faceI];
const triSurface::FaceType& f = surf.localFaces()[faceI];
forAll(f, fp)
{
@ -108,12 +108,12 @@ label collapseEdge(triSurface& surf, const scalar minLen)
if (okToCollapse[faceI])
{
// Check edge lengths.
const labelledTri& f = localFaces[faceI];
const triSurface::FaceType& f = localFaces[faceI];
forAll(f, fp)
{
label v = f[fp];
label v1 = f[(fp+1) % 3];
label v1 = f[f.fcIndex(fp)];
if (mag(localPoints[v1] - localPoints[v]) < minLen)
{

View File

@ -128,9 +128,7 @@ void dumpFaces
forAllConstIter(Map<label>, connectedFaces, iter)
{
const labelledTri& f = surf.localFaces()[iter.key()];
point ctr(f.centre(surf.localPoints()));
point ctr = surf.localFaces()[iter.key()].centre(surf.localPoints());
os << "v " << ctr.x() << ' ' << ctr.y() << ' ' << ctr.z() << endl;
}
@ -453,7 +451,7 @@ label sharedFace
const edge& e = surf.edges()[sharedEdgeI];
const labelledTri& f = surf.localFaces()[firstFaceI];
const triSurface::FaceType& f = surf.localFaces()[firstFaceI];
label startIndex = findIndex(f, e.start());
@ -597,13 +595,13 @@ void renumberFaces
const triSurface& surf,
const labelList& pointMap,
const Map<label>& faceToEdge,
List<labelledTri>& newTris
List<triSurface::FaceType>& newTris
)
{
forAllConstIter(Map<label>, faceToEdge, iter)
{
const label faceI = iter.key();
const labelledTri& f = surf.localFaces()[faceI];
const triSurface::FaceType& f = surf.localFaces()[faceI];
forAll(f, fp)
{
@ -911,7 +909,6 @@ int main(int argc, char *argv[])
forAll(surf, faceI)
{
newTris[faceI] = surf.localFaces()[faceI];
newTris[faceI].region() = surf[faceI].region();
}
@ -924,7 +921,7 @@ int main(int argc, char *argv[])
// Check if faces use unmoved points.
forAll(newTris, faceI)
{
const labelledTri& f = newTris[faceI];
const triSurface::FaceType& f = newTris[faceI];
forAll(f, fp)
{

View File

@ -196,8 +196,7 @@ int main(int argc, char *argv[])
forAll(surf1, faceI)
{
const labelledTri& f = surf1[faceI];
const point centre = f.centre(surf1.points());
const point centre = surf1[faceI].centre(surf1.points());
if
(

View File

@ -324,13 +324,7 @@ void Foam::treeDataTriSurface::findNearest
forAll(indices, i)
{
label index = indices[i];
const labelledTri& f = surface_[index];
// Triangle points
const point& p0 = points[f[0]];
const point& p1 = points[f[1]];
const point& p2 = points[f[2]];
const triSurface::FaceType& f = surface_[index];
////- Possible optimization: do quick rejection of triangle if bounding
//// sphere does not intersect triangle bounding box. From simplistic
@ -379,7 +373,7 @@ void Foam::treeDataTriSurface::findNearest
// t
// );
pointHit pHit = triPointRef(p0, p1, p2).nearestPoint(sample);
pointHit pHit = f.nearestPoint(sample, points);
scalar distSqr = sqr(pHit.distance());
@ -425,14 +419,16 @@ bool Foam::treeDataTriSurface::intersects
{
const pointField& points = surface_.points();
const labelledTri& f = surface_[index];
const triSurface::FaceType& f = surface_[index];
// Do quick rejection test
treeBoundBox triBb(points[f[0]], points[f[0]]);
triBb.min() = min(triBb.min(), points[f[1]]);
triBb.max() = max(triBb.max(), points[f[1]]);
triBb.min() = min(triBb.min(), points[f[2]]);
triBb.max() = max(triBb.max(), points[f[2]]);
for (label ptI=1; ptI < f.size(); ++ptI)
{
triBb.min() = ::Foam::min(triBb.min(), points[f[ptI]]);
triBb.max() = ::Foam::max(triBb.max(), points[f[ptI]]);
}
const direction startBits(triBb.posBits(start));
const direction endBits(triBb.posBits(end));
@ -443,16 +439,14 @@ bool Foam::treeDataTriSurface::intersects
return false;
}
const triPointRef tri(points[f[0]], points[f[1]], points[f[2]]);
const vector dir(end - start);
// Use relative tolerance (from octree) to determine intersection.
pointHit inter = tri.intersection
pointHit inter = f.intersection
(
start,
dir,
points,
intersection::HALF_RAY,
indexedOctree<treeDataTriSurface>::perturbTol()
);

View File

@ -162,7 +162,7 @@ bool Foam::triSurfaceMesh::isSurfaceClosed() const
facesPerEdge.clear();
forAll(pFaces, i)
{
const labelledTri& f = triSurface::operator[](pFaces[i]);
const triSurface::FaceType& f = triSurface::operator[](pFaces[i]);
label fp = findIndex(f, pointI);
// Something weird: if I expand the code of addFaceToEdge in both
@ -293,9 +293,9 @@ void Foam::triSurfaceMesh::calcBounds(boundBox& bb, label& nPoints) const
nPoints = 0;
bb = boundBox::invertedBox;
forAll(s, triI)
forAll(s, faceI)
{
const labelledTri& f = s[triI];
const triSurface::FaceType& f = s[faceI];
forAll(f, fp)
{
@ -475,9 +475,9 @@ void Foam::triSurfaceMesh::clearOut()
Foam::pointField Foam::triSurfaceMesh::coordinates() const
{
// Use copy to calculate face centres so they don't get stored
return PrimitivePatch<labelledTri, SubList, const pointField&>
return PrimitivePatch<triSurface::FaceType, SubList, const pointField&>
(
SubList<labelledTri>(*this, triSurface::size()),
SubList<triSurface::FaceType>(*this, triSurface::size()),
triSurface::points()
).faceCentres();
}
@ -804,12 +804,12 @@ void Foam::triSurfaceMesh::getNormal
{
if (info[i].hit())
{
label triI = info[i].index();
label faceI = info[i].index();
//- Cached:
//normal[i] = faceNormals()[triI];
//normal[i] = faceNormals()[faceI];
//- Uncached
normal[i] = triSurface::operator[](triI).normal(points());
normal[i] = triSurface::operator[](faceI).normal(points());
normal[i] /= mag(normal[i]) + VSMALL;
}
else

View File

@ -489,7 +489,7 @@ Foam::booleanSurface::booleanSurface
}
labelList faceZone1;
(void)cutSurf1.markZones(isIntersectionEdge1, faceZone1);
cutSurf1.markZones(isIntersectionEdge1, faceZone1);
// Check whether at least one of sides of intersection has been marked.
@ -537,7 +537,7 @@ Foam::booleanSurface::booleanSurface
}
labelList faceZone2;
(void)cutSurf2.markZones(isIntersectionEdge2, faceZone2);
cutSurf2.markZones(isIntersectionEdge2, faceZone2);
// Check whether at least one of sides of intersection has been marked.
@ -960,20 +960,11 @@ Foam::booleanSurface::booleanSurface
forAll(combinedSurf, faceI)
{
const labelledTri& f = combinedSurf[faceI];
pointHit curHit =
triPointRef
(
pts[f[0]],
pts[f[1]],
pts[f[2]]
).nearestPoint(outsidePoint);
pointHit curHit = combinedSurf[faceI].nearestPoint(outsidePoint, pts);
if (curHit.distance() < minHit.distance())
{
minHit = curHit;
minFaceI = faceI;
}
}

View File

@ -219,12 +219,12 @@ bool Foam::intersectedSurface::sameEdgeOrder
if (fpB != -1)
{
// Get prev/next vertex on fA
label vA1 = fA[(fpA + 1) % 3];
label vAMin1 = fA[fpA ? fpA-1 : 2];
label vA1 = fA[fA.fcIndex(fpA)];
label vAMin1 = fA[fA.rcIndex(fpA)];
// Get prev/next vertex on fB
label vB1 = fB[(fpB + 1) % 3];
label vBMin1 = fB[fpB ? fpB-1 : 2];
label vB1 = fB[fB.fcIndex(fpB)];
label vBMin1 = fB[fB.rcIndex(fpB)];
if (vA1 == vB1 || vAMin1 == vBMin1)
{

View File

@ -414,23 +414,14 @@ bool Foam::edgeIntersections::offsetPerturb
// Classify point on face of surface2
label surf2FaceI = pHit.index();
const labelledTri& f2 = surf2.localFaces()[surf2FaceI];
const triSurface::FaceType& f2 = surf2.localFaces()[surf2FaceI];
const pointField& surf2Pts = surf2.localPoints();
label nearType;
label nearLabel;
const point ctr = f2.centre(surf2Pts);
triPointRef tri
(
surf2Pts[f2[0]],
surf2Pts[f2[1]],
surf2Pts[f2[2]]
);
label nearType, nearLabel;
point ctr = tri.centre();
tri.classify(pHit.hitPoint(), nearType, nearLabel);
f2.nearestPointClassify(pHit.hitPoint(), surf2Pts, nearType, nearLabel);
if (nearType == triPointRef::POINT || nearType == triPointRef::EDGE)
{

View File

@ -53,22 +53,18 @@ bool Foam::surfaceIntersection::excludeEdgeHit
const scalar
)
{
const labelledTri& f = surf.localFaces()[faceI];
const triSurface::FaceType& f = surf.localFaces()[faceI];
const edge& e = surf.edges()[edgeI];
if
(
(f[0] == e.start())
|| (f[0] == e.end())
|| (f[1] == e.start())
|| (f[1] == e.end())
|| (f[2] == e.start())
|| (f[2] == e.end())
)
forAll(f, fp)
{
if (f[0] == e.start() || f[0] == e.end())
{
return true;
}
}
// {
// // Get edge vector
// vector eVec = e.vec(surf.localPoints());
// eVec /= mag(eVec) + VSMALL;
@ -112,11 +108,9 @@ bool Foam::surfaceIntersection::excludeEdgeHit
// {
// return false;
// }
}
else
{
// }
return false;
}
}
@ -137,14 +131,14 @@ bool Foam::surfaceIntersection::excludeEdgeHit
//
// const pointField& points = surf.points();
//
// const labelledTri& f = surf.localFaces()[hitFaceI];
// const triSurface::FaceType& f = surf.localFaces()[hitFaceI];
//
// // Plane for intersect test.
// plane pl(eStart, n);
//
// forAll(f, fp)
// {
// label fp1 = (fp + 1) % 3;
// label fp1 = f.fcIndex(fp);
//
// const point& start = points[f[fp]];
// const point& end = points[f[fp1]];
@ -303,19 +297,12 @@ void Foam::surfaceIntersection::classifyHit
// Classify point on surface2
const labelledTri& f2 = surf2.localFaces()[surf2FaceI];
const triSurface::FaceType& f2 = surf2.localFaces()[surf2FaceI];
const pointField& surf2Pts = surf2.localPoints();
label nearType;
label nearLabel;
label nearType, nearLabel;
(void)triPointRef
(
surf2Pts[f2[0]],
surf2Pts[f2[1]],
surf2Pts[f2[2]]
).classify(pHit.hitPoint(), nearType, nearLabel);
f2.nearestPointClassify(pHit.hitPoint(), surf2Pts, nearType, nearLabel);
// Classify points on edge of surface1
label edgeEnd =
@ -333,7 +320,7 @@ void Foam::surfaceIntersection::classifyHit
if (edgeEnd >= 0)
{
// 1. Point hits point. Do nothing.
if (debug&2)
if (debug & 2)
{
Pout<< pHit.hitPoint() << " is surf1:"
<< " end point of edge " << e
@ -344,7 +331,7 @@ void Foam::surfaceIntersection::classifyHit
else
{
// 2. Edge hits point. Cut edge with new point.
if (debug&2)
if (debug & 2)
{
Pout<< pHit.hitPoint() << " is surf1:"
<< " somewhere on edge " << e

View File

@ -90,9 +90,7 @@ Foam::label Foam::surfaceIntersection::getEdge
const label fp
)
{
const labelledTri& f = surf.localFaces()[faceI];
edge faceEdge(f[fp], f[(fp+1) % 3]);
const edge faceEdge = surf.localFaces()[faceI].faceEdge(fp);
const labelList& eLabels = surf.faceEdges()[faceI];

View File

@ -340,15 +340,7 @@ Foam::label Foam::octreeDataTriSurface::getSampleType
<< abort(FatalError);
}
const pointField& pts = surface_.points();
const labelledTri& f = surface_[faceI];
pointHit curHit = triPointRef
(
pts[f[0]],
pts[f[1]],
pts[f[2]]
).nearestPoint(sample);
pointHit curHit = surface_[faceI].nearestPoint(sample, surface_.points());
// Get normal according to position on face. On point -> pointNormal,
// on edge-> edge normal, face normal on interior.
@ -433,18 +425,18 @@ bool Foam::octreeDataTriSurface::intersects
return false;
}
const pointField& points = surface_.points();
const labelledTri& f = surface_[index];
triPointRef tri(points[f[0]], points[f[1]], points[f[2]]);
const vector dir(end - start);
// Disable picking up intersections behind us.
scalar oldTol = intersection::setPlanarTol(0.0);
pointHit inter = tri.ray(start, dir, intersection::HALF_RAY);
pointHit inter = surface_[index].ray
(
start,
dir,
surface_.points(),
intersection::HALF_RAY
);
intersection::setPlanarTol(oldTol);
@ -512,10 +504,8 @@ Foam::scalar Foam::octreeDataTriSurface::calcSign
{
n = surface_.faceNormals()[index];
const labelledTri& tri = surface_[index];
// take vector from sample to any point on triangle (we use vertex 0)
vector vec = sample - surface_.points()[tri[0]];
// take vector from sample to any point on face (we use vertex 0)
vector vec = sample - surface_.points()[surface_[index][0]];
vec /= mag(vec) + VSMALL;

View File

@ -34,38 +34,15 @@ defineTypeNameAndDebug(Foam::orientedSurface, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Return true if face uses edge from start to end.
bool Foam::orientedSurface::edgeOrder
(
const labelledTri& f,
const edge& e
)
{
if
(
(f[0] == e[0] && f[1] == e[1])
|| (f[1] == e[0] && f[2] == e[1])
|| (f[2] == e[0] && f[0] == e[1])
)
{
return true;
}
else
{
return false;
}
}
// Return true if edge is used in opposite order in faces
bool Foam::orientedSurface::consistentEdge
(
const edge& e,
const labelledTri& f0,
const labelledTri& f1
const triSurface::FaceType& f0,
const triSurface::FaceType& f1
)
{
return edgeOrder(f0, e) ^ edgeOrder(f1, e);
return (f0.edgeDirection(e) > 0) ^ (f1.edgeDirection(e) > 0);
}
@ -118,8 +95,8 @@ Foam::labelList Foam::orientedSurface::edgeToFace
label face0 = eFaces[0];
label face1 = eFaces[1];
const labelledTri& f0 = s.localFaces()[face0];
const labelledTri& f1 = s.localFaces()[face1];
const triSurface::FaceType& f0 = s.localFaces()[face0];
const triSurface::FaceType& f1 = s.localFaces()[face1];
if (flip[face0] == UNVISITED)
{
@ -401,15 +378,8 @@ bool Foam::orientedSurface::orient
{
if (flipState[faceI] == UNVISITED)
{
const labelledTri& f = s[faceI];
pointHit curHit =
triPointRef
(
s.points()[f[0]],
s.points()[f[1]],
s.points()[f[2]]
).nearestPoint(samplePoint);
s[faceI].nearestPoint(samplePoint, s.points());
if (curHit.distance() < minDist)
{

View File

@ -66,15 +66,12 @@ class orientedSurface
// Private Member Functions
//- Return true if face uses edge from start to end.
static bool edgeOrder(const labelledTri&, const edge&);
//- Return true if edge is used in opposite order in faces
static bool consistentEdge
(
const edge& e,
const labelledTri& f0,
const labelledTri& f1
const triSurface::FaceType& f0,
const triSurface::FaceType& f1
);
//- From changed faces get the changed edges

View File

@ -1111,7 +1111,7 @@ void Foam::triSurfaceTools::snapToEnd
if (current.elementType() == triPointRef::NONE)
{
// endpoint on point; current on triangle
const labelledTri& f = s.localFaces()[current.index()];
const triSurface::FaceType& f = s.localFaces()[current.index()];
if (findIndex(f, end.index()) != -1)
{
@ -1566,8 +1566,7 @@ Foam::label Foam::triSurfaceTools::oppositeVertex
const label edgeI
)
{
const labelledTri& f = surf.localFaces()[faceI];
const triSurface::FaceType& f = surf.localFaces()[faceI];
const edge& e = surf.edges()[edgeI];
forAll(f, fp)
@ -1601,7 +1600,6 @@ Foam::label Foam::triSurfaceTools::getEdge
forAll(v1Edges, v1EdgeI)
{
label edgeI = v1Edges[v1EdgeI];
const edge& e = surf.edges()[edgeI];
if ((e.start() == v2) || (e.end() == v2))
@ -2116,18 +2114,12 @@ Foam::vector Foam::triSurfaceTools::surfaceNormal
const point& nearestPt
)
{
const labelledTri& f = surf[nearestFaceI];
const triSurface::FaceType& f = surf[nearestFaceI];
const pointField& points = surf.points();
label nearType;
label nearLabel;
label nearType, nearLabel;
triPointRef
(
points[f[0]],
points[f[1]],
points[f[2]]
).classify(nearestPt, nearType, nearLabel);
f.nearestPointClassify(nearestPt, points, nearType, nearLabel);
if (nearType == triPointRef::NONE)
{
@ -2153,7 +2145,7 @@ Foam::vector Foam::triSurfaceTools::surfaceNormal
else
{
// Nearest to point
const labelledTri& localF = surf.localFaces()[nearestFaceI];
const triSurface::FaceType& localF = surf.localFaces()[nearestFaceI];
return surf.pointNormals()[localF[nearLabel]];
}
}
@ -2203,18 +2195,13 @@ Foam::triSurfaceTools::sideType Foam::triSurfaceTools::surfaceSide
const label nearestFaceI
)
{
const labelledTri& f = surf[nearestFaceI];
const triSurface::FaceType& f = surf[nearestFaceI];
const pointField& points = surf.points();
// Find where point is on triangle.
// Find where point is on face
label nearType, nearLabel;
pointHit pHit = triPointRef
(
points[f[0]],
points[f[1]],
points[f[2]]
).nearestPointClassify(sample, nearType, nearLabel);
pointHit pHit = f.nearestPointClassify(sample, points, nearType, nearLabel);
const point& nearestPoint(pHit.rawPoint());
@ -2304,7 +2291,7 @@ Foam::triSurfaceTools::sideType Foam::triSurfaceTools::surfaceSide
// above (nearType == triPointRef::EDGE).
const labelledTri& localF = surf.localFaces()[nearestFaceI];
const triSurface::FaceType& localF = surf.localFaces()[nearestFaceI];
label nearPointI = localF[nearLabel];
const edgeList& edges = surf.edges();
@ -2497,7 +2484,7 @@ Foam::triSurface Foam::triSurfaceTools::triangulateFaceCentre
forAll(f, fp)
{
label fp1 = (fp + 1) % f.size();
label fp1 = f.fcIndex(fp);
triangles.append(labelledTri(f[fp], f[fp1], fc, newPatchI));

View File

@ -903,18 +903,13 @@ Foam::distributedTriSurfaceMesh::independentlyDistributedBbs
point& bbMin = bbs[distribution[triI]][0].min();
point& bbMax = bbs[distribution[triI]][0].max();
const labelledTri& f = s[triI];
const point& p0 = s.points()[f[0]];
const point& p1 = s.points()[f[1]];
const point& p2 = s.points()[f[2]];
bbMin = min(bbMin, p0);
bbMin = min(bbMin, p1);
bbMin = min(bbMin, p2);
bbMax = max(bbMax, p0);
bbMax = max(bbMax, p1);
bbMax = max(bbMax, p2);
const triSurface::FaceType& f = s[triI];
forAll(f, fp)
{
const point& pt = s.points()[f[fp]];
bbMin = ::Foam::min(bbMin, pt);
bbMax = ::Foam::max(bbMax, pt);
}
}
// Now combine for all processors and convert to correct format.
@ -1003,12 +998,12 @@ void Foam::distributedTriSurfaceMesh::subsetMeshMap
// Store new faces compact
newToOldFaces[faceI++] = oldFacei;
// Renumber labels for triangle
const labelledTri& tri = s[oldFacei];
// Renumber labels for face
const triSurface::FaceType& f = s[oldFacei];
forAll(tri, fp)
forAll(f, fp)
{
label oldPointI = tri[fp];
label oldPointI = f[fp];
if (oldToNewPoints[oldPointI] == -1)
{
@ -1122,12 +1117,12 @@ Foam::triSurface Foam::distributedTriSurfaceMesh::subsetMesh
{
if (include[oldFacei])
{
// Renumber labels for triangle
const labelledTri& tri = s[oldFacei];
// Renumber labels for face
const triSurface::FaceType& f = s[oldFacei];
forAll(tri, fp)
forAll(f, fp)
{
label oldPointI = tri[fp];
label oldPointI = f[fp];
if (oldToNewPoints[oldPointI] == -1)
{

View File

@ -931,12 +931,9 @@ bool Foam::isoSurfaceCell::validTri(const triSurface& surf, const label faceI)
const labelledTri& f = surf[faceI];
if
(
(f[0] < 0) || (f[0] >= surf.points().size())
|| (f[1] < 0) || (f[1] >= surf.points().size())
|| (f[2] < 0) || (f[2] >= surf.points().size())
)
forAll(f, fp)
{
if (f[fp] < 0 || f[fp] >= surf.points().size())
{
WarningIn("validTri(const triSurface&, const label)")
<< "triangle " << faceI << " vertices " << f
@ -945,6 +942,7 @@ bool Foam::isoSurfaceCell::validTri(const triSurface& surf, const label faceI)
return false;
}
}
if ((f[0] == f[1]) || (f[0] == f[2]) || (f[1] == f[2]))
{
@ -1337,12 +1335,12 @@ Foam::triSurface Foam::isoSurfaceCell::subsetMesh
{
if (include[oldFacei])
{
// Renumber labels for triangle
const labelledTri& tri = s[oldFacei];
// Renumber labels for face
const triSurface::FaceType& f = s[oldFacei];
forAll(tri, fp)
forAll(f, fp)
{
label oldPointI = tri[fp];
label oldPointI = f[fp];
if (oldToNewPoints[oldPointI] == -1)
{

View File

@ -239,15 +239,15 @@ bool Foam::sampledTriSurfaceMesh::update()
{
label newPointI = 0;
label newTriI = 0;
label newFaceI = 0;
forAll(s, triI)
forAll(s, faceI)
{
if (include[triI])
if (include[faceI])
{
faceMap[newTriI++] = triI;
faceMap[newFaceI++] = faceI;
const labelledTri& f = s[triI];
const triSurface::FaceType& f = s[faceI];
forAll(f, fp)
{
if (reversePointMap[f[fp]] == -1)
@ -258,7 +258,7 @@ bool Foam::sampledTriSurfaceMesh::update()
}
}
}
faceMap.setSize(newTriI);
faceMap.setSize(newFaceI);
pointMap.setSize(newPointI);
}

View File

@ -62,6 +62,13 @@ public:
//- Construct null
inline labelledTri();
//- Construct from triFace and a region label
inline labelledTri
(
const triFace&,
const label region
);
//- Construct from three point labels and a region label
inline labelledTri
(

View File

@ -21,41 +21,43 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "IOstreams.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct null
inline labelledTri::labelledTri()
inline Foam::labelledTri::labelledTri()
:
region_(-1)
{}
//- Construct from components
inline labelledTri::labelledTri
inline Foam::labelledTri::labelledTri
(
const label A,
const label B,
const label C,
const triFace& tri,
const label region
)
:
triFace(A, B, C),
triFace(tri),
region_(region)
{}
inline labelledTri::labelledTri(Istream& is)
inline Foam::labelledTri::labelledTri
(
const label a,
const label b,
const label c,
const label region
)
:
triFace(a, b, c),
region_(region)
{}
inline Foam::labelledTri::labelledTri(Istream& is)
{
operator>>(is, *this);
}
@ -63,12 +65,12 @@ inline labelledTri::labelledTri(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline label labelledTri::region() const
inline Foam::label Foam::labelledTri::region() const
{
return region_;
}
inline label& labelledTri::region()
inline Foam::label& Foam::labelledTri::region()
{
return region_;
}
@ -76,7 +78,7 @@ inline label& labelledTri::region()
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
inline Istream& operator>>(Istream& is, labelledTri& t)
inline Foam::Istream& Foam::operator>>(Istream& is, labelledTri& t)
{
if (is.format() == IOstream::ASCII)
{
@ -100,7 +102,7 @@ inline Istream& operator>>(Istream& is, labelledTri& t)
}
inline Ostream& operator<<(Ostream& os, const labelledTri& t)
inline Foam::Ostream& Foam::operator<<(Ostream& os, const labelledTri& t)
{
if (os.format() == IOstream::ASCII)
{
@ -125,8 +127,4 @@ inline Ostream& operator<<(Ostream& os, const labelledTri& t)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -26,14 +26,10 @@ License
#include "triSurface.H"
#include "IOmanip.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void triSurface::writeAC(Ostream& os) const
void Foam::triSurface::writeAC(Ostream& os) const
{
// Write with patches as separate objects under "world" object.
// Header is taken over from sample file.
@ -140,8 +136,4 @@ void triSurface::writeAC(Ostream& os) const
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -27,14 +27,10 @@ License
#include "IFstream.H"
#include "IStringStream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool triSurface::readGTS(const fileName& GTSfileName)
bool Foam::triSurface::readGTS(const fileName& GTSfileName)
{
IFstream GTSfile(GTSfileName);
@ -162,8 +158,4 @@ bool triSurface::readGTS(const fileName& GTSfileName)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -27,14 +27,9 @@ License
#include "IFstream.H"
#include "IStringStream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool triSurface::readOBJ(const fileName& OBJfileName)
bool Foam::triSurface::readOBJ(const fileName& OBJfileName)
{
IFstream OBJfile(OBJfileName);
@ -195,8 +190,4 @@ bool triSurface::readOBJ(const fileName& OBJfileName)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -30,14 +30,9 @@ Description
#include "IFstream.H"
#include "IStringStream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool triSurface::readOFF(const fileName& OFFfileName)
bool Foam::triSurface::readOFF(const fileName& OFFfileName)
{
IFstream OFFfile(OFFfileName);
@ -136,8 +131,4 @@ bool triSurface::readOFF(const fileName& OFFfileName)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -29,14 +29,10 @@ License
#include "OSspecific.H"
#include "gzstream.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool triSurface::readSTLBINARY(const fileName& STLfileName)
bool Foam::triSurface::readSTLBINARY(const fileName& STLfileName)
{
bool compressed = false;
@ -133,8 +129,4 @@ bool triSurface::readSTLBINARY(const fileName& STLfileName)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -29,14 +29,9 @@ License
#include "HashTable.H"
#include "hashSignedLabel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void triSurface::writeSTLASCII(Ostream& os) const
void Foam::triSurface::writeSTLASCII(Ostream& os) const
{
labelList faceMap;
@ -85,7 +80,7 @@ void triSurface::writeSTLASCII(Ostream& os) const
}
void triSurface::writeSTLBINARY(std::ostream& os) const
void Foam::triSurface::writeSTLBINARY(std::ostream& os) const
{
// Write the STL header
string header("Foam binary STL", STLheaderSize);
@ -113,8 +108,4 @@ void triSurface::writeSTLBINARY(std::ostream& os) const
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -27,14 +27,9 @@ License
#include "mergePoints.H"
#include "PackedBoolList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool triSurface::stitchTriangles
bool Foam::triSurface::stitchTriangles
(
const pointField& rawPoints,
const scalar tol,
@ -114,11 +109,11 @@ bool triSurface::stitchTriangles
forAll(*this, i)
{
const labelledTri& tri = operator[](i);
const triSurface::FaceType& f = operator[](i);
forAll(tri, fp)
forAll(f, fp)
{
label pointI = tri[fp];
label pointI = f[fp];
if (pointIsUsed.set(pointI, 1))
{
nPoints++;
@ -161,8 +156,4 @@ bool triSurface::stitchTriangles
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -187,14 +187,11 @@ void Foam::triSurface::checkTriangles(const bool verbose)
forAll(*this, faceI)
{
const labelledTri& f = (*this)[faceI];
const triSurface::FaceType& f = (*this)[faceI];
if
(
(f[0] < 0) || (f[0] > maxPointI)
|| (f[1] < 0) || (f[1] > maxPointI)
|| (f[2] < 0) || (f[2] > maxPointI)
)
forAll(f, fp)
{
if (f[fp] < 0 || f[fp] > maxPointI)
{
FatalErrorIn("triSurface::checkTriangles(bool)")
<< "triangle " << f
@ -203,6 +200,7 @@ void Foam::triSurface::checkTriangles(const bool verbose)
<< exit(FatalError);
}
}
}
// Two phase process
// 1. mark invalid faces
@ -960,42 +958,30 @@ void Foam::triSurface::subsetMeshMap
boolList pointHad(nPoints(), false);
forAll(include, oldFacei)
forAll(include, oldFaceI)
{
if (include[oldFacei])
if (include[oldFaceI])
{
// Store new faces compact
faceMap[faceI++] = oldFacei;
faceMap[faceI++] = oldFaceI;
// Renumber labels for triangle
const labelledTri& tri = locFaces[oldFacei];
// Renumber labels for face
const triSurface::FaceType& f = locFaces[oldFaceI];
label a = tri[0];
if (!pointHad[a])
forAll(f, fp)
{
pointHad[a] = true;
pointMap[pointI++] = a;
label labI = f[fp];
if (!pointHad[labI])
{
pointHad[labI] = true;
pointMap[pointI++] = labI;
}
label b = tri[1];
if (!pointHad[b])
{
pointHad[b] = true;
pointMap[pointI++] = b;
}
label c = tri[2];
if (!pointHad[c])
{
pointHad[c] = true;
pointMap[pointI++] = c;
}
}
}
// Trim
faceMap.setSize(faceI);
pointMap.setSize(pointI);
}
@ -1086,9 +1072,9 @@ void Foam::triSurface::writeStats(Ostream& os) const
label nPoints = 0;
boundBox bb = boundBox::invertedBox;
forAll(*this, triI)
forAll(*this, faceI)
{
const labelledTri& f = operator[](triI);
const triSurface::FaceType& f = operator[](faceI);
forAll(f, fp)
{

View File

@ -32,14 +32,10 @@ Description
#include "SortableList.H"
#include "transform.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void triSurface::calcSortedEdgeFaces() const
void Foam::triSurface::calcSortedEdgeFaces() const
{
if (sortedEdgeFacesPtr_)
{
@ -126,7 +122,7 @@ void triSurface::calcSortedEdgeFaces() const
}
void triSurface::calcEdgeOwner() const
void Foam::triSurface::calcEdgeOwner() const
{
if (edgeOwnerPtr_)
{
@ -187,8 +183,4 @@ void triSurface::calcEdgeOwner() const
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //