mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: use triSurface::FaceType where triangle or region information
not required
This commit is contained in:
@ -47,19 +47,16 @@ bool validTri
|
|||||||
|
|
||||||
const labelledTri& f = surf[faceI];
|
const labelledTri& f = surf[faceI];
|
||||||
|
|
||||||
if
|
forAll(f, fp)
|
||||||
(
|
|
||||||
(f[0] < 0) || (f[0] >= surf.points().size())
|
|
||||||
|| (f[1] < 0) || (f[1] >= surf.points().size())
|
|
||||||
|| (f[2] < 0) || (f[2] >= surf.points().size())
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
WarningIn("validTri(const triSurface&, const label)")
|
if (f[fp] < 0 || f[fp] >= surf.points().size())
|
||||||
<< "triangle " << faceI << " vertices " << f
|
{
|
||||||
<< " uses point indices outside point range 0.."
|
WarningIn("validTri(const triSurface&, const label)")
|
||||||
<< surf.points().size()-1 << endl;
|
<< "triangle " << faceI << " vertices " << f
|
||||||
|
<< " uses point indices outside point range 0.."
|
||||||
return false;
|
<< surf.points().size()-1 << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((f[0] == f[1]) || (f[0] == f[2]) || (f[1] == f[2]))
|
if ((f[0] == f[1]) || (f[0] == f[2]) || (f[1] == f[2]))
|
||||||
|
|||||||
@ -100,8 +100,8 @@ static void splitTri
|
|||||||
label oldNTris = tris.size();
|
label oldNTris = tris.size();
|
||||||
|
|
||||||
label fp = findIndex(f, e[0]);
|
label fp = findIndex(f, e[0]);
|
||||||
label fp1 = (fp+1)%3;
|
label fp1 = f.fcIndex(fp);
|
||||||
label fp2 = (fp1+1)%3;
|
label fp2 = f.fcIndex(fp1);
|
||||||
|
|
||||||
if (f[fp1] == e[1])
|
if (f[fp1] == e[1])
|
||||||
{
|
{
|
||||||
|
|||||||
@ -34,7 +34,7 @@ static void markPointNbrs
|
|||||||
boolList& okToCollapse
|
boolList& okToCollapse
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const labelledTri& f = surf.localFaces()[faceI];
|
const triSurface::FaceType& f = surf.localFaces()[faceI];
|
||||||
|
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
@ -108,12 +108,12 @@ label collapseEdge(triSurface& surf, const scalar minLen)
|
|||||||
if (okToCollapse[faceI])
|
if (okToCollapse[faceI])
|
||||||
{
|
{
|
||||||
// Check edge lengths.
|
// Check edge lengths.
|
||||||
const labelledTri& f = localFaces[faceI];
|
const triSurface::FaceType& f = localFaces[faceI];
|
||||||
|
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
label v = 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)
|
if (mag(localPoints[v1] - localPoints[v]) < minLen)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -128,9 +128,7 @@ void dumpFaces
|
|||||||
|
|
||||||
forAllConstIter(Map<label>, connectedFaces, iter)
|
forAllConstIter(Map<label>, connectedFaces, iter)
|
||||||
{
|
{
|
||||||
const labelledTri& f = surf.localFaces()[iter.key()];
|
point ctr = surf.localFaces()[iter.key()].centre(surf.localPoints());
|
||||||
|
|
||||||
point ctr(f.centre(surf.localPoints()));
|
|
||||||
|
|
||||||
os << "v " << ctr.x() << ' ' << ctr.y() << ' ' << ctr.z() << endl;
|
os << "v " << ctr.x() << ' ' << ctr.y() << ' ' << ctr.z() << endl;
|
||||||
}
|
}
|
||||||
@ -453,7 +451,7 @@ label sharedFace
|
|||||||
|
|
||||||
const edge& e = surf.edges()[sharedEdgeI];
|
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());
|
label startIndex = findIndex(f, e.start());
|
||||||
|
|
||||||
@ -597,13 +595,13 @@ void renumberFaces
|
|||||||
const triSurface& surf,
|
const triSurface& surf,
|
||||||
const labelList& pointMap,
|
const labelList& pointMap,
|
||||||
const Map<label>& faceToEdge,
|
const Map<label>& faceToEdge,
|
||||||
List<labelledTri>& newTris
|
List<triSurface::FaceType>& newTris
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
forAllConstIter(Map<label>, faceToEdge, iter)
|
forAllConstIter(Map<label>, faceToEdge, iter)
|
||||||
{
|
{
|
||||||
const label faceI = iter.key();
|
const label faceI = iter.key();
|
||||||
const labelledTri& f = surf.localFaces()[faceI];
|
const triSurface::FaceType& f = surf.localFaces()[faceI];
|
||||||
|
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
@ -911,7 +909,6 @@ int main(int argc, char *argv[])
|
|||||||
forAll(surf, faceI)
|
forAll(surf, faceI)
|
||||||
{
|
{
|
||||||
newTris[faceI] = surf.localFaces()[faceI];
|
newTris[faceI] = surf.localFaces()[faceI];
|
||||||
|
|
||||||
newTris[faceI].region() = surf[faceI].region();
|
newTris[faceI].region() = surf[faceI].region();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -924,7 +921,7 @@ int main(int argc, char *argv[])
|
|||||||
// Check if faces use unmoved points.
|
// Check if faces use unmoved points.
|
||||||
forAll(newTris, faceI)
|
forAll(newTris, faceI)
|
||||||
{
|
{
|
||||||
const labelledTri& f = newTris[faceI];
|
const triSurface::FaceType& f = newTris[faceI];
|
||||||
|
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -196,8 +196,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
forAll(surf1, faceI)
|
forAll(surf1, faceI)
|
||||||
{
|
{
|
||||||
const labelledTri& f = surf1[faceI];
|
const point centre = surf1[faceI].centre(surf1.points());
|
||||||
const point centre = f.centre(surf1.points());
|
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
|
|||||||
@ -324,13 +324,7 @@ void Foam::treeDataTriSurface::findNearest
|
|||||||
forAll(indices, i)
|
forAll(indices, i)
|
||||||
{
|
{
|
||||||
label index = indices[i];
|
label index = indices[i];
|
||||||
const labelledTri& f = surface_[index];
|
const triSurface::FaceType& f = surface_[index];
|
||||||
|
|
||||||
// Triangle points
|
|
||||||
const point& p0 = points[f[0]];
|
|
||||||
const point& p1 = points[f[1]];
|
|
||||||
const point& p2 = points[f[2]];
|
|
||||||
|
|
||||||
|
|
||||||
////- Possible optimization: do quick rejection of triangle if bounding
|
////- Possible optimization: do quick rejection of triangle if bounding
|
||||||
//// sphere does not intersect triangle bounding box. From simplistic
|
//// sphere does not intersect triangle bounding box. From simplistic
|
||||||
@ -379,7 +373,7 @@ void Foam::treeDataTriSurface::findNearest
|
|||||||
// t
|
// t
|
||||||
// );
|
// );
|
||||||
|
|
||||||
pointHit pHit = triPointRef(p0, p1, p2).nearestPoint(sample);
|
pointHit pHit = f.nearestPoint(sample, points);
|
||||||
|
|
||||||
scalar distSqr = sqr(pHit.distance());
|
scalar distSqr = sqr(pHit.distance());
|
||||||
|
|
||||||
@ -425,14 +419,16 @@ bool Foam::treeDataTriSurface::intersects
|
|||||||
{
|
{
|
||||||
const pointField& points = surface_.points();
|
const pointField& points = surface_.points();
|
||||||
|
|
||||||
const labelledTri& f = surface_[index];
|
const triSurface::FaceType& f = surface_[index];
|
||||||
|
|
||||||
// Do quick rejection test
|
// Do quick rejection test
|
||||||
treeBoundBox triBb(points[f[0]], points[f[0]]);
|
treeBoundBox triBb(points[f[0]], points[f[0]]);
|
||||||
triBb.min() = min(triBb.min(), points[f[1]]);
|
|
||||||
triBb.max() = max(triBb.max(), points[f[1]]);
|
for (label ptI=1; ptI < f.size(); ++ptI)
|
||||||
triBb.min() = min(triBb.min(), points[f[2]]);
|
{
|
||||||
triBb.max() = max(triBb.max(), points[f[2]]);
|
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 startBits(triBb.posBits(start));
|
||||||
const direction endBits(triBb.posBits(end));
|
const direction endBits(triBb.posBits(end));
|
||||||
@ -443,16 +439,14 @@ bool Foam::treeDataTriSurface::intersects
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const triPointRef tri(points[f[0]], points[f[1]], points[f[2]]);
|
|
||||||
|
|
||||||
const vector dir(end - start);
|
const vector dir(end - start);
|
||||||
|
|
||||||
// Use relative tolerance (from octree) to determine intersection.
|
// Use relative tolerance (from octree) to determine intersection.
|
||||||
|
pointHit inter = f.intersection
|
||||||
pointHit inter = tri.intersection
|
|
||||||
(
|
(
|
||||||
start,
|
start,
|
||||||
dir,
|
dir,
|
||||||
|
points,
|
||||||
intersection::HALF_RAY,
|
intersection::HALF_RAY,
|
||||||
indexedOctree<treeDataTriSurface>::perturbTol()
|
indexedOctree<treeDataTriSurface>::perturbTol()
|
||||||
);
|
);
|
||||||
|
|||||||
@ -162,7 +162,7 @@ bool Foam::triSurfaceMesh::isSurfaceClosed() const
|
|||||||
facesPerEdge.clear();
|
facesPerEdge.clear();
|
||||||
forAll(pFaces, i)
|
forAll(pFaces, i)
|
||||||
{
|
{
|
||||||
const labelledTri& f = triSurface::operator[](pFaces[i]);
|
const triSurface::FaceType& f = triSurface::operator[](pFaces[i]);
|
||||||
label fp = findIndex(f, pointI);
|
label fp = findIndex(f, pointI);
|
||||||
|
|
||||||
// Something weird: if I expand the code of addFaceToEdge in both
|
// 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;
|
nPoints = 0;
|
||||||
bb = boundBox::invertedBox;
|
bb = boundBox::invertedBox;
|
||||||
|
|
||||||
forAll(s, triI)
|
forAll(s, faceI)
|
||||||
{
|
{
|
||||||
const labelledTri& f = s[triI];
|
const triSurface::FaceType& f = s[faceI];
|
||||||
|
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
@ -475,9 +475,9 @@ void Foam::triSurfaceMesh::clearOut()
|
|||||||
Foam::pointField Foam::triSurfaceMesh::coordinates() const
|
Foam::pointField Foam::triSurfaceMesh::coordinates() const
|
||||||
{
|
{
|
||||||
// Use copy to calculate face centres so they don't get stored
|
// 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()
|
triSurface::points()
|
||||||
).faceCentres();
|
).faceCentres();
|
||||||
}
|
}
|
||||||
@ -804,12 +804,12 @@ void Foam::triSurfaceMesh::getNormal
|
|||||||
{
|
{
|
||||||
if (info[i].hit())
|
if (info[i].hit())
|
||||||
{
|
{
|
||||||
label triI = info[i].index();
|
label faceI = info[i].index();
|
||||||
//- Cached:
|
//- Cached:
|
||||||
//normal[i] = faceNormals()[triI];
|
//normal[i] = faceNormals()[faceI];
|
||||||
|
|
||||||
//- Uncached
|
//- Uncached
|
||||||
normal[i] = triSurface::operator[](triI).normal(points());
|
normal[i] = triSurface::operator[](faceI).normal(points());
|
||||||
normal[i] /= mag(normal[i]) + VSMALL;
|
normal[i] /= mag(normal[i]) + VSMALL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -489,7 +489,7 @@ Foam::booleanSurface::booleanSurface
|
|||||||
}
|
}
|
||||||
|
|
||||||
labelList faceZone1;
|
labelList faceZone1;
|
||||||
(void)cutSurf1.markZones(isIntersectionEdge1, faceZone1);
|
cutSurf1.markZones(isIntersectionEdge1, faceZone1);
|
||||||
|
|
||||||
|
|
||||||
// Check whether at least one of sides of intersection has been marked.
|
// Check whether at least one of sides of intersection has been marked.
|
||||||
@ -537,7 +537,7 @@ Foam::booleanSurface::booleanSurface
|
|||||||
}
|
}
|
||||||
|
|
||||||
labelList faceZone2;
|
labelList faceZone2;
|
||||||
(void)cutSurf2.markZones(isIntersectionEdge2, faceZone2);
|
cutSurf2.markZones(isIntersectionEdge2, faceZone2);
|
||||||
|
|
||||||
|
|
||||||
// Check whether at least one of sides of intersection has been marked.
|
// Check whether at least one of sides of intersection has been marked.
|
||||||
@ -960,20 +960,11 @@ Foam::booleanSurface::booleanSurface
|
|||||||
|
|
||||||
forAll(combinedSurf, faceI)
|
forAll(combinedSurf, faceI)
|
||||||
{
|
{
|
||||||
const labelledTri& f = combinedSurf[faceI];
|
pointHit curHit = combinedSurf[faceI].nearestPoint(outsidePoint, pts);
|
||||||
|
|
||||||
pointHit curHit =
|
|
||||||
triPointRef
|
|
||||||
(
|
|
||||||
pts[f[0]],
|
|
||||||
pts[f[1]],
|
|
||||||
pts[f[2]]
|
|
||||||
).nearestPoint(outsidePoint);
|
|
||||||
|
|
||||||
if (curHit.distance() < minHit.distance())
|
if (curHit.distance() < minHit.distance())
|
||||||
{
|
{
|
||||||
minHit = curHit;
|
minHit = curHit;
|
||||||
|
|
||||||
minFaceI = faceI;
|
minFaceI = faceI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -219,12 +219,12 @@ bool Foam::intersectedSurface::sameEdgeOrder
|
|||||||
if (fpB != -1)
|
if (fpB != -1)
|
||||||
{
|
{
|
||||||
// Get prev/next vertex on fA
|
// Get prev/next vertex on fA
|
||||||
label vA1 = fA[(fpA + 1) % 3];
|
label vA1 = fA[fA.fcIndex(fpA)];
|
||||||
label vAMin1 = fA[fpA ? fpA-1 : 2];
|
label vAMin1 = fA[fA.rcIndex(fpA)];
|
||||||
|
|
||||||
// Get prev/next vertex on fB
|
// Get prev/next vertex on fB
|
||||||
label vB1 = fB[(fpB + 1) % 3];
|
label vB1 = fB[fB.fcIndex(fpB)];
|
||||||
label vBMin1 = fB[fpB ? fpB-1 : 2];
|
label vBMin1 = fB[fB.rcIndex(fpB)];
|
||||||
|
|
||||||
if (vA1 == vB1 || vAMin1 == vBMin1)
|
if (vA1 == vB1 || vAMin1 == vBMin1)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -414,23 +414,14 @@ bool Foam::edgeIntersections::offsetPerturb
|
|||||||
// Classify point on face of surface2
|
// Classify point on face of surface2
|
||||||
label surf2FaceI = pHit.index();
|
label surf2FaceI = pHit.index();
|
||||||
|
|
||||||
const labelledTri& f2 = surf2.localFaces()[surf2FaceI];
|
const triSurface::FaceType& f2 = surf2.localFaces()[surf2FaceI];
|
||||||
|
|
||||||
const pointField& surf2Pts = surf2.localPoints();
|
const pointField& surf2Pts = surf2.localPoints();
|
||||||
|
|
||||||
label nearType;
|
const point ctr = f2.centre(surf2Pts);
|
||||||
label nearLabel;
|
|
||||||
|
|
||||||
triPointRef tri
|
label nearType, nearLabel;
|
||||||
(
|
|
||||||
surf2Pts[f2[0]],
|
|
||||||
surf2Pts[f2[1]],
|
|
||||||
surf2Pts[f2[2]]
|
|
||||||
);
|
|
||||||
|
|
||||||
point ctr = tri.centre();
|
f2.nearestPointClassify(pHit.hitPoint(), surf2Pts, nearType, nearLabel);
|
||||||
|
|
||||||
tri.classify(pHit.hitPoint(), nearType, nearLabel);
|
|
||||||
|
|
||||||
if (nearType == triPointRef::POINT || nearType == triPointRef::EDGE)
|
if (nearType == triPointRef::POINT || nearType == triPointRef::EDGE)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -53,22 +53,18 @@ bool Foam::surfaceIntersection::excludeEdgeHit
|
|||||||
const scalar
|
const scalar
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const labelledTri& f = surf.localFaces()[faceI];
|
const triSurface::FaceType& f = surf.localFaces()[faceI];
|
||||||
|
|
||||||
const edge& e = surf.edges()[edgeI];
|
const edge& e = surf.edges()[edgeI];
|
||||||
|
|
||||||
if
|
forAll(f, fp)
|
||||||
(
|
|
||||||
(f[0] == e.start())
|
|
||||||
|| (f[0] == e.end())
|
|
||||||
|| (f[1] == e.start())
|
|
||||||
|| (f[1] == e.end())
|
|
||||||
|| (f[2] == e.start())
|
|
||||||
|| (f[2] == e.end())
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return true;
|
if (f[0] == e.start() || f[0] == e.end())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// {
|
||||||
// // Get edge vector
|
// // Get edge vector
|
||||||
// vector eVec = e.vec(surf.localPoints());
|
// vector eVec = e.vec(surf.localPoints());
|
||||||
// eVec /= mag(eVec) + VSMALL;
|
// eVec /= mag(eVec) + VSMALL;
|
||||||
@ -112,11 +108,9 @@ bool Foam::surfaceIntersection::excludeEdgeHit
|
|||||||
// {
|
// {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
}
|
// }
|
||||||
else
|
|
||||||
{
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -137,14 +131,14 @@ bool Foam::surfaceIntersection::excludeEdgeHit
|
|||||||
//
|
//
|
||||||
// const pointField& points = surf.points();
|
// const pointField& points = surf.points();
|
||||||
//
|
//
|
||||||
// const labelledTri& f = surf.localFaces()[hitFaceI];
|
// const triSurface::FaceType& f = surf.localFaces()[hitFaceI];
|
||||||
//
|
//
|
||||||
// // Plane for intersect test.
|
// // Plane for intersect test.
|
||||||
// plane pl(eStart, n);
|
// plane pl(eStart, n);
|
||||||
//
|
//
|
||||||
// forAll(f, fp)
|
// forAll(f, fp)
|
||||||
// {
|
// {
|
||||||
// label fp1 = (fp + 1) % 3;
|
// label fp1 = f.fcIndex(fp);
|
||||||
//
|
//
|
||||||
// const point& start = points[f[fp]];
|
// const point& start = points[f[fp]];
|
||||||
// const point& end = points[f[fp1]];
|
// const point& end = points[f[fp1]];
|
||||||
@ -303,19 +297,12 @@ void Foam::surfaceIntersection::classifyHit
|
|||||||
|
|
||||||
// Classify point on surface2
|
// Classify point on surface2
|
||||||
|
|
||||||
const labelledTri& f2 = surf2.localFaces()[surf2FaceI];
|
const triSurface::FaceType& f2 = surf2.localFaces()[surf2FaceI];
|
||||||
|
|
||||||
const pointField& surf2Pts = surf2.localPoints();
|
const pointField& surf2Pts = surf2.localPoints();
|
||||||
|
|
||||||
label nearType;
|
label nearType, nearLabel;
|
||||||
label nearLabel;
|
|
||||||
|
|
||||||
(void)triPointRef
|
f2.nearestPointClassify(pHit.hitPoint(), surf2Pts, nearType, nearLabel);
|
||||||
(
|
|
||||||
surf2Pts[f2[0]],
|
|
||||||
surf2Pts[f2[1]],
|
|
||||||
surf2Pts[f2[2]]
|
|
||||||
).classify(pHit.hitPoint(), nearType, nearLabel);
|
|
||||||
|
|
||||||
// Classify points on edge of surface1
|
// Classify points on edge of surface1
|
||||||
label edgeEnd =
|
label edgeEnd =
|
||||||
@ -333,7 +320,7 @@ void Foam::surfaceIntersection::classifyHit
|
|||||||
if (edgeEnd >= 0)
|
if (edgeEnd >= 0)
|
||||||
{
|
{
|
||||||
// 1. Point hits point. Do nothing.
|
// 1. Point hits point. Do nothing.
|
||||||
if (debug&2)
|
if (debug & 2)
|
||||||
{
|
{
|
||||||
Pout<< pHit.hitPoint() << " is surf1:"
|
Pout<< pHit.hitPoint() << " is surf1:"
|
||||||
<< " end point of edge " << e
|
<< " end point of edge " << e
|
||||||
@ -344,7 +331,7 @@ void Foam::surfaceIntersection::classifyHit
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 2. Edge hits point. Cut edge with new point.
|
// 2. Edge hits point. Cut edge with new point.
|
||||||
if (debug&2)
|
if (debug & 2)
|
||||||
{
|
{
|
||||||
Pout<< pHit.hitPoint() << " is surf1:"
|
Pout<< pHit.hitPoint() << " is surf1:"
|
||||||
<< " somewhere on edge " << e
|
<< " somewhere on edge " << e
|
||||||
|
|||||||
@ -90,9 +90,7 @@ Foam::label Foam::surfaceIntersection::getEdge
|
|||||||
const label fp
|
const label fp
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const labelledTri& f = surf.localFaces()[faceI];
|
const edge faceEdge = surf.localFaces()[faceI].faceEdge(fp);
|
||||||
|
|
||||||
edge faceEdge(f[fp], f[(fp+1) % 3]);
|
|
||||||
|
|
||||||
const labelList& eLabels = surf.faceEdges()[faceI];
|
const labelList& eLabels = surf.faceEdges()[faceI];
|
||||||
|
|
||||||
|
|||||||
@ -340,15 +340,7 @@ Foam::label Foam::octreeDataTriSurface::getSampleType
|
|||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
const pointField& pts = surface_.points();
|
pointHit curHit = surface_[faceI].nearestPoint(sample, surface_.points());
|
||||||
const labelledTri& f = surface_[faceI];
|
|
||||||
|
|
||||||
pointHit curHit = triPointRef
|
|
||||||
(
|
|
||||||
pts[f[0]],
|
|
||||||
pts[f[1]],
|
|
||||||
pts[f[2]]
|
|
||||||
).nearestPoint(sample);
|
|
||||||
|
|
||||||
// Get normal according to position on face. On point -> pointNormal,
|
// Get normal according to position on face. On point -> pointNormal,
|
||||||
// on edge-> edge normal, face normal on interior.
|
// on edge-> edge normal, face normal on interior.
|
||||||
@ -433,18 +425,18 @@ bool Foam::octreeDataTriSurface::intersects
|
|||||||
return false;
|
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);
|
const vector dir(end - start);
|
||||||
|
|
||||||
// Disable picking up intersections behind us.
|
// Disable picking up intersections behind us.
|
||||||
scalar oldTol = intersection::setPlanarTol(0.0);
|
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);
|
intersection::setPlanarTol(oldTol);
|
||||||
|
|
||||||
@ -512,10 +504,8 @@ Foam::scalar Foam::octreeDataTriSurface::calcSign
|
|||||||
{
|
{
|
||||||
n = surface_.faceNormals()[index];
|
n = surface_.faceNormals()[index];
|
||||||
|
|
||||||
const labelledTri& tri = surface_[index];
|
// take vector from sample to any point on face (we use vertex 0)
|
||||||
|
vector vec = sample - surface_.points()[surface_[index][0]];
|
||||||
// take vector from sample to any point on triangle (we use vertex 0)
|
|
||||||
vector vec = sample - surface_.points()[tri[0]];
|
|
||||||
|
|
||||||
vec /= mag(vec) + VSMALL;
|
vec /= mag(vec) + VSMALL;
|
||||||
|
|
||||||
|
|||||||
@ -34,38 +34,15 @@ defineTypeNameAndDebug(Foam::orientedSurface, 0);
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * 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
|
// Return true if edge is used in opposite order in faces
|
||||||
bool Foam::orientedSurface::consistentEdge
|
bool Foam::orientedSurface::consistentEdge
|
||||||
(
|
(
|
||||||
const edge& e,
|
const edge& e,
|
||||||
const labelledTri& f0,
|
const triSurface::FaceType& f0,
|
||||||
const labelledTri& f1
|
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 face0 = eFaces[0];
|
||||||
label face1 = eFaces[1];
|
label face1 = eFaces[1];
|
||||||
|
|
||||||
const labelledTri& f0 = s.localFaces()[face0];
|
const triSurface::FaceType& f0 = s.localFaces()[face0];
|
||||||
const labelledTri& f1 = s.localFaces()[face1];
|
const triSurface::FaceType& f1 = s.localFaces()[face1];
|
||||||
|
|
||||||
if (flip[face0] == UNVISITED)
|
if (flip[face0] == UNVISITED)
|
||||||
{
|
{
|
||||||
@ -401,15 +378,8 @@ bool Foam::orientedSurface::orient
|
|||||||
{
|
{
|
||||||
if (flipState[faceI] == UNVISITED)
|
if (flipState[faceI] == UNVISITED)
|
||||||
{
|
{
|
||||||
const labelledTri& f = s[faceI];
|
|
||||||
|
|
||||||
pointHit curHit =
|
pointHit curHit =
|
||||||
triPointRef
|
s[faceI].nearestPoint(samplePoint, s.points());
|
||||||
(
|
|
||||||
s.points()[f[0]],
|
|
||||||
s.points()[f[1]],
|
|
||||||
s.points()[f[2]]
|
|
||||||
).nearestPoint(samplePoint);
|
|
||||||
|
|
||||||
if (curHit.distance() < minDist)
|
if (curHit.distance() < minDist)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -66,15 +66,12 @@ class orientedSurface
|
|||||||
|
|
||||||
// Private Member Functions
|
// 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
|
//- Return true if edge is used in opposite order in faces
|
||||||
static bool consistentEdge
|
static bool consistentEdge
|
||||||
(
|
(
|
||||||
const edge& e,
|
const edge& e,
|
||||||
const labelledTri& f0,
|
const triSurface::FaceType& f0,
|
||||||
const labelledTri& f1
|
const triSurface::FaceType& f1
|
||||||
);
|
);
|
||||||
|
|
||||||
//- From changed faces get the changed edges
|
//- From changed faces get the changed edges
|
||||||
|
|||||||
@ -1111,7 +1111,7 @@ void Foam::triSurfaceTools::snapToEnd
|
|||||||
if (current.elementType() == triPointRef::NONE)
|
if (current.elementType() == triPointRef::NONE)
|
||||||
{
|
{
|
||||||
// endpoint on point; current on triangle
|
// 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)
|
if (findIndex(f, end.index()) != -1)
|
||||||
{
|
{
|
||||||
@ -1566,8 +1566,7 @@ Foam::label Foam::triSurfaceTools::oppositeVertex
|
|||||||
const label edgeI
|
const label edgeI
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const labelledTri& f = surf.localFaces()[faceI];
|
const triSurface::FaceType& f = surf.localFaces()[faceI];
|
||||||
|
|
||||||
const edge& e = surf.edges()[edgeI];
|
const edge& e = surf.edges()[edgeI];
|
||||||
|
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
@ -1601,7 +1600,6 @@ Foam::label Foam::triSurfaceTools::getEdge
|
|||||||
forAll(v1Edges, v1EdgeI)
|
forAll(v1Edges, v1EdgeI)
|
||||||
{
|
{
|
||||||
label edgeI = v1Edges[v1EdgeI];
|
label edgeI = v1Edges[v1EdgeI];
|
||||||
|
|
||||||
const edge& e = surf.edges()[edgeI];
|
const edge& e = surf.edges()[edgeI];
|
||||||
|
|
||||||
if ((e.start() == v2) || (e.end() == v2))
|
if ((e.start() == v2) || (e.end() == v2))
|
||||||
@ -2116,18 +2114,12 @@ Foam::vector Foam::triSurfaceTools::surfaceNormal
|
|||||||
const point& nearestPt
|
const point& nearestPt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const labelledTri& f = surf[nearestFaceI];
|
const triSurface::FaceType& f = surf[nearestFaceI];
|
||||||
const pointField& points = surf.points();
|
const pointField& points = surf.points();
|
||||||
|
|
||||||
label nearType;
|
label nearType, nearLabel;
|
||||||
label nearLabel;
|
|
||||||
|
|
||||||
triPointRef
|
f.nearestPointClassify(nearestPt, points, nearType, nearLabel);
|
||||||
(
|
|
||||||
points[f[0]],
|
|
||||||
points[f[1]],
|
|
||||||
points[f[2]]
|
|
||||||
).classify(nearestPt, nearType, nearLabel);
|
|
||||||
|
|
||||||
if (nearType == triPointRef::NONE)
|
if (nearType == triPointRef::NONE)
|
||||||
{
|
{
|
||||||
@ -2153,7 +2145,7 @@ Foam::vector Foam::triSurfaceTools::surfaceNormal
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Nearest to point
|
// Nearest to point
|
||||||
const labelledTri& localF = surf.localFaces()[nearestFaceI];
|
const triSurface::FaceType& localF = surf.localFaces()[nearestFaceI];
|
||||||
return surf.pointNormals()[localF[nearLabel]];
|
return surf.pointNormals()[localF[nearLabel]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2203,18 +2195,13 @@ Foam::triSurfaceTools::sideType Foam::triSurfaceTools::surfaceSide
|
|||||||
const label nearestFaceI
|
const label nearestFaceI
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const labelledTri& f = surf[nearestFaceI];
|
const triSurface::FaceType& f = surf[nearestFaceI];
|
||||||
const pointField& points = surf.points();
|
const pointField& points = surf.points();
|
||||||
|
|
||||||
// Find where point is on triangle.
|
// Find where point is on face
|
||||||
label nearType, nearLabel;
|
label nearType, nearLabel;
|
||||||
|
|
||||||
pointHit pHit = triPointRef
|
pointHit pHit = f.nearestPointClassify(sample, points, nearType, nearLabel);
|
||||||
(
|
|
||||||
points[f[0]],
|
|
||||||
points[f[1]],
|
|
||||||
points[f[2]]
|
|
||||||
).nearestPointClassify(sample, nearType, nearLabel);
|
|
||||||
|
|
||||||
const point& nearestPoint(pHit.rawPoint());
|
const point& nearestPoint(pHit.rawPoint());
|
||||||
|
|
||||||
@ -2304,7 +2291,7 @@ Foam::triSurfaceTools::sideType Foam::triSurfaceTools::surfaceSide
|
|||||||
// above (nearType == triPointRef::EDGE).
|
// above (nearType == triPointRef::EDGE).
|
||||||
|
|
||||||
|
|
||||||
const labelledTri& localF = surf.localFaces()[nearestFaceI];
|
const triSurface::FaceType& localF = surf.localFaces()[nearestFaceI];
|
||||||
label nearPointI = localF[nearLabel];
|
label nearPointI = localF[nearLabel];
|
||||||
|
|
||||||
const edgeList& edges = surf.edges();
|
const edgeList& edges = surf.edges();
|
||||||
@ -2497,7 +2484,7 @@ Foam::triSurface Foam::triSurfaceTools::triangulateFaceCentre
|
|||||||
|
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
label fp1 = (fp + 1) % f.size();
|
label fp1 = f.fcIndex(fp);
|
||||||
|
|
||||||
triangles.append(labelledTri(f[fp], f[fp1], fc, newPatchI));
|
triangles.append(labelledTri(f[fp], f[fp1], fc, newPatchI));
|
||||||
|
|
||||||
|
|||||||
@ -903,18 +903,13 @@ Foam::distributedTriSurfaceMesh::independentlyDistributedBbs
|
|||||||
point& bbMin = bbs[distribution[triI]][0].min();
|
point& bbMin = bbs[distribution[triI]][0].min();
|
||||||
point& bbMax = bbs[distribution[triI]][0].max();
|
point& bbMax = bbs[distribution[triI]][0].max();
|
||||||
|
|
||||||
const labelledTri& f = s[triI];
|
const triSurface::FaceType& f = s[triI];
|
||||||
const point& p0 = s.points()[f[0]];
|
forAll(f, fp)
|
||||||
const point& p1 = s.points()[f[1]];
|
{
|
||||||
const point& p2 = s.points()[f[2]];
|
const point& pt = s.points()[f[fp]];
|
||||||
|
bbMin = ::Foam::min(bbMin, pt);
|
||||||
bbMin = min(bbMin, p0);
|
bbMax = ::Foam::max(bbMax, pt);
|
||||||
bbMin = min(bbMin, p1);
|
}
|
||||||
bbMin = min(bbMin, p2);
|
|
||||||
|
|
||||||
bbMax = max(bbMax, p0);
|
|
||||||
bbMax = max(bbMax, p1);
|
|
||||||
bbMax = max(bbMax, p2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now combine for all processors and convert to correct format.
|
// Now combine for all processors and convert to correct format.
|
||||||
@ -1003,12 +998,12 @@ void Foam::distributedTriSurfaceMesh::subsetMeshMap
|
|||||||
// Store new faces compact
|
// Store new faces compact
|
||||||
newToOldFaces[faceI++] = oldFacei;
|
newToOldFaces[faceI++] = oldFacei;
|
||||||
|
|
||||||
// Renumber labels for triangle
|
// Renumber labels for face
|
||||||
const labelledTri& tri = s[oldFacei];
|
const triSurface::FaceType& f = s[oldFacei];
|
||||||
|
|
||||||
forAll(tri, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
label oldPointI = tri[fp];
|
label oldPointI = f[fp];
|
||||||
|
|
||||||
if (oldToNewPoints[oldPointI] == -1)
|
if (oldToNewPoints[oldPointI] == -1)
|
||||||
{
|
{
|
||||||
@ -1122,12 +1117,12 @@ Foam::triSurface Foam::distributedTriSurfaceMesh::subsetMesh
|
|||||||
{
|
{
|
||||||
if (include[oldFacei])
|
if (include[oldFacei])
|
||||||
{
|
{
|
||||||
// Renumber labels for triangle
|
// Renumber labels for face
|
||||||
const labelledTri& tri = s[oldFacei];
|
const triSurface::FaceType& f = s[oldFacei];
|
||||||
|
|
||||||
forAll(tri, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
label oldPointI = tri[fp];
|
label oldPointI = f[fp];
|
||||||
|
|
||||||
if (oldToNewPoints[oldPointI] == -1)
|
if (oldToNewPoints[oldPointI] == -1)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -931,19 +931,17 @@ bool Foam::isoSurfaceCell::validTri(const triSurface& surf, const label faceI)
|
|||||||
|
|
||||||
const labelledTri& f = surf[faceI];
|
const labelledTri& f = surf[faceI];
|
||||||
|
|
||||||
if
|
forAll(f, fp)
|
||||||
(
|
|
||||||
(f[0] < 0) || (f[0] >= surf.points().size())
|
|
||||||
|| (f[1] < 0) || (f[1] >= surf.points().size())
|
|
||||||
|| (f[2] < 0) || (f[2] >= surf.points().size())
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
WarningIn("validTri(const triSurface&, const label)")
|
if (f[fp] < 0 || f[fp] >= surf.points().size())
|
||||||
<< "triangle " << faceI << " vertices " << f
|
{
|
||||||
<< " uses point indices outside point range 0.."
|
WarningIn("validTri(const triSurface&, const label)")
|
||||||
<< surf.points().size()-1 << endl;
|
<< "triangle " << faceI << " vertices " << f
|
||||||
|
<< " uses point indices outside point range 0.."
|
||||||
|
<< surf.points().size()-1 << endl;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((f[0] == f[1]) || (f[0] == f[2]) || (f[1] == f[2]))
|
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])
|
if (include[oldFacei])
|
||||||
{
|
{
|
||||||
// Renumber labels for triangle
|
// Renumber labels for face
|
||||||
const labelledTri& tri = s[oldFacei];
|
const triSurface::FaceType& f = s[oldFacei];
|
||||||
|
|
||||||
forAll(tri, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
label oldPointI = tri[fp];
|
label oldPointI = f[fp];
|
||||||
|
|
||||||
if (oldToNewPoints[oldPointI] == -1)
|
if (oldToNewPoints[oldPointI] == -1)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -239,15 +239,15 @@ bool Foam::sampledTriSurfaceMesh::update()
|
|||||||
|
|
||||||
{
|
{
|
||||||
label newPointI = 0;
|
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)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
if (reversePointMap[f[fp]] == -1)
|
if (reversePointMap[f[fp]] == -1)
|
||||||
@ -258,7 +258,7 @@ bool Foam::sampledTriSurfaceMesh::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
faceMap.setSize(newTriI);
|
faceMap.setSize(newFaceI);
|
||||||
pointMap.setSize(newPointI);
|
pointMap.setSize(newPointI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -62,6 +62,13 @@ public:
|
|||||||
//- Construct null
|
//- Construct null
|
||||||
inline labelledTri();
|
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
|
//- Construct from three point labels and a region label
|
||||||
inline labelledTri
|
inline labelledTri
|
||||||
(
|
(
|
||||||
|
|||||||
@ -21,41 +21,43 @@ License
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Description
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
//- Construct null
|
inline Foam::labelledTri::labelledTri()
|
||||||
inline labelledTri::labelledTri()
|
|
||||||
:
|
:
|
||||||
region_(-1)
|
region_(-1)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
//- Construct from components
|
inline Foam::labelledTri::labelledTri
|
||||||
inline labelledTri::labelledTri
|
|
||||||
(
|
(
|
||||||
const label A,
|
const triFace& tri,
|
||||||
const label B,
|
|
||||||
const label C,
|
|
||||||
const label region
|
const label region
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
triFace(A, B, C),
|
triFace(tri),
|
||||||
region_(region)
|
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);
|
operator>>(is, *this);
|
||||||
}
|
}
|
||||||
@ -63,12 +65,12 @@ inline labelledTri::labelledTri(Istream& is)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline label labelledTri::region() const
|
inline Foam::label Foam::labelledTri::region() const
|
||||||
{
|
{
|
||||||
return region_;
|
return region_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline label& labelledTri::region()
|
inline Foam::label& Foam::labelledTri::region()
|
||||||
{
|
{
|
||||||
return region_;
|
return region_;
|
||||||
}
|
}
|
||||||
@ -76,7 +78,7 @@ inline label& labelledTri::region()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline Istream& operator>>(Istream& is, labelledTri& t)
|
inline Foam::Istream& Foam::operator>>(Istream& is, labelledTri& t)
|
||||||
{
|
{
|
||||||
if (is.format() == IOstream::ASCII)
|
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)
|
if (os.format() == IOstream::ASCII)
|
||||||
{
|
{
|
||||||
@ -125,8 +127,4 @@ inline Ostream& operator<<(Ostream& os, const labelledTri& t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -26,14 +26,10 @@ License
|
|||||||
#include "triSurface.H"
|
#include "triSurface.H"
|
||||||
#include "IOmanip.H"
|
#include "IOmanip.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void triSurface::writeAC(Ostream& os) const
|
void Foam::triSurface::writeAC(Ostream& os) const
|
||||||
{
|
{
|
||||||
// Write with patches as separate objects under "world" object.
|
// Write with patches as separate objects under "world" object.
|
||||||
// Header is taken over from sample file.
|
// Header is taken over from sample file.
|
||||||
@ -140,8 +136,4 @@ void triSurface::writeAC(Ostream& os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -27,14 +27,10 @@ License
|
|||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool triSurface::readGTS(const fileName& GTSfileName)
|
bool Foam::triSurface::readGTS(const fileName& GTSfileName)
|
||||||
{
|
{
|
||||||
IFstream GTSfile(GTSfileName);
|
IFstream GTSfile(GTSfileName);
|
||||||
|
|
||||||
@ -162,8 +158,4 @@ bool triSurface::readGTS(const fileName& GTSfileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -27,14 +27,9 @@ License
|
|||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool triSurface::readOBJ(const fileName& OBJfileName)
|
bool Foam::triSurface::readOBJ(const fileName& OBJfileName)
|
||||||
{
|
{
|
||||||
IFstream OBJfile(OBJfileName);
|
IFstream OBJfile(OBJfileName);
|
||||||
|
|
||||||
@ -195,8 +190,4 @@ bool triSurface::readOBJ(const fileName& OBJfileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -30,14 +30,9 @@ Description
|
|||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool triSurface::readOFF(const fileName& OFFfileName)
|
bool Foam::triSurface::readOFF(const fileName& OFFfileName)
|
||||||
{
|
{
|
||||||
IFstream OFFfile(OFFfileName);
|
IFstream OFFfile(OFFfileName);
|
||||||
|
|
||||||
@ -136,8 +131,4 @@ bool triSurface::readOFF(const fileName& OFFfileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -29,14 +29,10 @@ License
|
|||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
#include "gzstream.h"
|
#include "gzstream.h"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool triSurface::readSTLBINARY(const fileName& STLfileName)
|
bool Foam::triSurface::readSTLBINARY(const fileName& STLfileName)
|
||||||
{
|
{
|
||||||
bool compressed = false;
|
bool compressed = false;
|
||||||
|
|
||||||
@ -133,8 +129,4 @@ bool triSurface::readSTLBINARY(const fileName& STLfileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -29,14 +29,9 @@ License
|
|||||||
#include "HashTable.H"
|
#include "HashTable.H"
|
||||||
#include "hashSignedLabel.H"
|
#include "hashSignedLabel.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void triSurface::writeSTLASCII(Ostream& os) const
|
void Foam::triSurface::writeSTLASCII(Ostream& os) const
|
||||||
{
|
{
|
||||||
labelList faceMap;
|
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
|
// Write the STL header
|
||||||
string header("Foam binary STL", STLheaderSize);
|
string header("Foam binary STL", STLheaderSize);
|
||||||
@ -113,8 +108,4 @@ void triSurface::writeSTLBINARY(std::ostream& os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -27,14 +27,9 @@ License
|
|||||||
#include "mergePoints.H"
|
#include "mergePoints.H"
|
||||||
#include "PackedBoolList.H"
|
#include "PackedBoolList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool triSurface::stitchTriangles
|
bool Foam::triSurface::stitchTriangles
|
||||||
(
|
(
|
||||||
const pointField& rawPoints,
|
const pointField& rawPoints,
|
||||||
const scalar tol,
|
const scalar tol,
|
||||||
@ -114,11 +109,11 @@ bool triSurface::stitchTriangles
|
|||||||
|
|
||||||
forAll(*this, i)
|
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))
|
if (pointIsUsed.set(pointI, 1))
|
||||||
{
|
{
|
||||||
nPoints++;
|
nPoints++;
|
||||||
@ -161,8 +156,4 @@ bool triSurface::stitchTriangles
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -187,20 +187,18 @@ void Foam::triSurface::checkTriangles(const bool verbose)
|
|||||||
|
|
||||||
forAll(*this, faceI)
|
forAll(*this, faceI)
|
||||||
{
|
{
|
||||||
const labelledTri& f = (*this)[faceI];
|
const triSurface::FaceType& f = (*this)[faceI];
|
||||||
|
|
||||||
if
|
forAll(f, fp)
|
||||||
(
|
|
||||||
(f[0] < 0) || (f[0] > maxPointI)
|
|
||||||
|| (f[1] < 0) || (f[1] > maxPointI)
|
|
||||||
|| (f[2] < 0) || (f[2] > maxPointI)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
FatalErrorIn("triSurface::checkTriangles(bool)")
|
if (f[fp] < 0 || f[fp] > maxPointI)
|
||||||
<< "triangle " << f
|
{
|
||||||
<< " uses point indices outside point range 0.."
|
FatalErrorIn("triSurface::checkTriangles(bool)")
|
||||||
<< maxPointI
|
<< "triangle " << f
|
||||||
<< exit(FatalError);
|
<< " uses point indices outside point range 0.."
|
||||||
|
<< maxPointI
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -960,42 +958,30 @@ void Foam::triSurface::subsetMeshMap
|
|||||||
|
|
||||||
boolList pointHad(nPoints(), false);
|
boolList pointHad(nPoints(), false);
|
||||||
|
|
||||||
forAll(include, oldFacei)
|
forAll(include, oldFaceI)
|
||||||
{
|
{
|
||||||
if (include[oldFacei])
|
if (include[oldFaceI])
|
||||||
{
|
{
|
||||||
// Store new faces compact
|
// Store new faces compact
|
||||||
faceMap[faceI++] = oldFacei;
|
faceMap[faceI++] = oldFaceI;
|
||||||
|
|
||||||
// Renumber labels for triangle
|
// Renumber labels for face
|
||||||
const labelledTri& tri = locFaces[oldFacei];
|
const triSurface::FaceType& f = locFaces[oldFaceI];
|
||||||
|
|
||||||
label a = tri[0];
|
forAll(f, fp)
|
||||||
if (!pointHad[a])
|
|
||||||
{
|
{
|
||||||
pointHad[a] = true;
|
label labI = f[fp];
|
||||||
pointMap[pointI++] = a;
|
if (!pointHad[labI])
|
||||||
}
|
{
|
||||||
|
pointHad[labI] = true;
|
||||||
label b = tri[1];
|
pointMap[pointI++] = labI;
|
||||||
if (!pointHad[b])
|
}
|
||||||
{
|
|
||||||
pointHad[b] = true;
|
|
||||||
pointMap[pointI++] = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
label c = tri[2];
|
|
||||||
if (!pointHad[c])
|
|
||||||
{
|
|
||||||
pointHad[c] = true;
|
|
||||||
pointMap[pointI++] = c;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trim
|
// Trim
|
||||||
faceMap.setSize(faceI);
|
faceMap.setSize(faceI);
|
||||||
|
|
||||||
pointMap.setSize(pointI);
|
pointMap.setSize(pointI);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1086,9 +1072,9 @@ void Foam::triSurface::writeStats(Ostream& os) const
|
|||||||
label nPoints = 0;
|
label nPoints = 0;
|
||||||
boundBox bb = boundBox::invertedBox;
|
boundBox bb = boundBox::invertedBox;
|
||||||
|
|
||||||
forAll(*this, triI)
|
forAll(*this, faceI)
|
||||||
{
|
{
|
||||||
const labelledTri& f = operator[](triI);
|
const triSurface::FaceType& f = operator[](faceI);
|
||||||
|
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -32,14 +32,10 @@ Description
|
|||||||
#include "SortableList.H"
|
#include "SortableList.H"
|
||||||
#include "transform.H"
|
#include "transform.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void triSurface::calcSortedEdgeFaces() const
|
void Foam::triSurface::calcSortedEdgeFaces() const
|
||||||
{
|
{
|
||||||
if (sortedEdgeFacesPtr_)
|
if (sortedEdgeFacesPtr_)
|
||||||
{
|
{
|
||||||
@ -126,7 +122,7 @@ void triSurface::calcSortedEdgeFaces() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void triSurface::calcEdgeOwner() const
|
void Foam::triSurface::calcEdgeOwner() const
|
||||||
{
|
{
|
||||||
if (edgeOwnerPtr_)
|
if (edgeOwnerPtr_)
|
||||||
{
|
{
|
||||||
@ -187,8 +183,4 @@ void triSurface::calcEdgeOwner() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
Reference in New Issue
Block a user