mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
add corners() method to boundBox
This commit is contained in:
@ -37,7 +37,12 @@ License
|
|||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
// Does face use valid vertices?
|
// Does face use valid vertices?
|
||||||
bool validTri(const bool verbose, const triSurface& surf, const label faceI)
|
bool validTri
|
||||||
|
(
|
||||||
|
const bool verbose,
|
||||||
|
const triSurface& surf,
|
||||||
|
const label faceI
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// Simple check on indices ok.
|
// Simple check on indices ok.
|
||||||
|
|
||||||
@ -175,6 +180,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
argList::addBoolOption("checkSelfIntersection");
|
argList::addBoolOption("checkSelfIntersection");
|
||||||
argList::addBoolOption("verbose");
|
argList::addBoolOption("verbose");
|
||||||
|
argList::addBoolOption
|
||||||
|
(
|
||||||
|
"blockMesh",
|
||||||
|
"write vertices/blocks for blockMeshDict"
|
||||||
|
);
|
||||||
|
|
||||||
argList args(argc, argv);
|
argList args(argc, argv);
|
||||||
|
|
||||||
@ -182,7 +192,7 @@ int main(int argc, char *argv[])
|
|||||||
bool verbose = args.optionFound("verbose");
|
bool verbose = args.optionFound("verbose");
|
||||||
|
|
||||||
fileName surfFileName(args.additionalArgs()[0]);
|
fileName surfFileName(args.additionalArgs()[0]);
|
||||||
Pout<< "Reading surface from " << surfFileName << " ..." << nl << endl;
|
Info<< "Reading surface from " << surfFileName << " ..." << nl << endl;
|
||||||
|
|
||||||
|
|
||||||
// Read
|
// Read
|
||||||
@ -191,9 +201,33 @@ int main(int argc, char *argv[])
|
|||||||
triSurface surf(surfFileName);
|
triSurface surf(surfFileName);
|
||||||
|
|
||||||
|
|
||||||
Pout<< "Statistics:" << endl;
|
Info<< "Statistics:" << endl;
|
||||||
surf.writeStats(Pout);
|
surf.writeStats(Info);
|
||||||
Pout<< endl;
|
Info<< endl;
|
||||||
|
|
||||||
|
// write bounding box corners
|
||||||
|
if (args.optionFound("blockMesh"))
|
||||||
|
{
|
||||||
|
pointField cornerPts = boundBox(surf.points()).corners();
|
||||||
|
|
||||||
|
Info<<"// blockMeshDict info" << nl;
|
||||||
|
|
||||||
|
Info<<"vertices\n(" << nl;
|
||||||
|
forAll(cornerPts, ptI)
|
||||||
|
{
|
||||||
|
Info << " " << cornerPts[ptI] << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// number of divisions needs adjustment later
|
||||||
|
Info<<");\n" << nl
|
||||||
|
<<"blocks\n"
|
||||||
|
<<"(\n"
|
||||||
|
<<" hex (0 1 2 3 4 5 6 7) (10 10 10) simpleGrading (1 1 1)\n"
|
||||||
|
<<");\n" << nl;
|
||||||
|
|
||||||
|
Info<<"edges();" << nl
|
||||||
|
<<"patches();" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Region sizes
|
// Region sizes
|
||||||
@ -220,14 +254,14 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Pout<< "Region\tSize" << nl
|
Info<< "Region\tSize" << nl
|
||||||
<< "------\t----" << nl;
|
<< "------\t----" << nl;
|
||||||
forAll(surf.patches(), patchI)
|
forAll(surf.patches(), patchI)
|
||||||
{
|
{
|
||||||
Pout<< surf.patches()[patchI].name() << '\t'
|
Info<< surf.patches()[patchI].name() << '\t'
|
||||||
<< regionSize[patchI] << nl;
|
<< regionSize[patchI] << nl;
|
||||||
}
|
}
|
||||||
Pout<< nl << endl;
|
Info<< nl << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -247,19 +281,19 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (illegalFaces.size())
|
if (illegalFaces.size())
|
||||||
{
|
{
|
||||||
Pout<< "Surface has " << illegalFaces.size()
|
Info<< "Surface has " << illegalFaces.size()
|
||||||
<< " illegal triangles." << endl;
|
<< " illegal triangles." << endl;
|
||||||
|
|
||||||
OFstream str("illegalFaces");
|
OFstream str("illegalFaces");
|
||||||
Pout<< "Dumping conflicting face labels to " << str.name() << endl
|
Info<< "Dumping conflicting face labels to " << str.name() << endl
|
||||||
<< "Paste this into the input for surfaceSubset" << endl;
|
<< "Paste this into the input for surfaceSubset" << endl;
|
||||||
str << illegalFaces;
|
str << illegalFaces;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pout<< "Surface has no illegal triangles." << endl;
|
Info<< "Surface has no illegal triangles." << endl;
|
||||||
}
|
}
|
||||||
Pout<< endl;
|
Info<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -312,28 +346,28 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
labelList binCount = countBins(0, 1, 20, triQ);
|
labelList binCount = countBins(0, 1, 20, triQ);
|
||||||
|
|
||||||
Pout<< "Triangle quality (equilateral=1, collapsed=0):"
|
Info<< "Triangle quality (equilateral=1, collapsed=0):"
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
|
|
||||||
OSstream& os = Pout;
|
OSstream& os = Info;
|
||||||
os.width(4);
|
os.width(4);
|
||||||
|
|
||||||
scalar dist = (1.0 - 0.0)/20.0;
|
scalar dist = (1.0 - 0.0)/20.0;
|
||||||
scalar min = 0;
|
scalar min = 0;
|
||||||
forAll(binCount, binI)
|
forAll(binCount, binI)
|
||||||
{
|
{
|
||||||
Pout<< " " << min << " .. " << min+dist << " : "
|
Info<< " " << min << " .. " << min+dist << " : "
|
||||||
<< 1.0/surf.size() * binCount[binI]
|
<< 1.0/surf.size() * binCount[binI]
|
||||||
<< endl;
|
<< endl;
|
||||||
min += dist;
|
min += dist;
|
||||||
}
|
}
|
||||||
Pout<< endl;
|
Info<< endl;
|
||||||
|
|
||||||
label minIndex = findMin(triQ);
|
label minIndex = findMin(triQ);
|
||||||
label maxIndex = findMax(triQ);
|
label maxIndex = findMax(triQ);
|
||||||
|
|
||||||
Pout<< " min " << triQ[minIndex] << " for triangle " << minIndex
|
Info<< " min " << triQ[minIndex] << " for triangle " << minIndex
|
||||||
<< nl
|
<< nl
|
||||||
<< " max " << triQ[maxIndex] << " for triangle " << maxIndex
|
<< " max " << triQ[maxIndex] << " for triangle " << maxIndex
|
||||||
<< nl
|
<< nl
|
||||||
@ -360,7 +394,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
OFstream str("badFaces");
|
OFstream str("badFaces");
|
||||||
|
|
||||||
Pout<< "Dumping bad quality faces to " << str.name() << endl
|
Info<< "Dumping bad quality faces to " << str.name() << endl
|
||||||
<< "Paste this into the input for surfaceSubset" << nl
|
<< "Paste this into the input for surfaceSubset" << nl
|
||||||
<< nl << endl;
|
<< nl << endl;
|
||||||
|
|
||||||
@ -390,7 +424,7 @@ int main(int argc, char *argv[])
|
|||||||
const edge& maxE = edges[maxEdgeI];
|
const edge& maxE = edges[maxEdgeI];
|
||||||
|
|
||||||
|
|
||||||
Pout<< "Edges:" << nl
|
Info<< "Edges:" << nl
|
||||||
<< " min " << edgeMag[minEdgeI] << " for edge " << minEdgeI
|
<< " min " << edgeMag[minEdgeI] << " for edge " << minEdgeI
|
||||||
<< " points " << localPoints[minE[0]] << localPoints[minE[1]]
|
<< " points " << localPoints[minE[0]] << localPoints[minE[1]]
|
||||||
<< nl
|
<< nl
|
||||||
@ -411,7 +445,7 @@ int main(int argc, char *argv[])
|
|||||||
const boundBox bb(localPoints);
|
const boundBox bb(localPoints);
|
||||||
scalar smallDim = 1E-6 * bb.mag();
|
scalar smallDim = 1E-6 * bb.mag();
|
||||||
|
|
||||||
Pout<< "Checking for points less than 1E-6 of bounding box ("
|
Info<< "Checking for points less than 1E-6 of bounding box ("
|
||||||
<< bb.span() << " meter) apart."
|
<< bb.span() << " meter) apart."
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
@ -450,7 +484,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (edgeI == -1)
|
if (edgeI == -1)
|
||||||
{
|
{
|
||||||
Pout<< " close unconnected points "
|
Info<< " close unconnected points "
|
||||||
<< ptI << ' ' << localPoints[ptI]
|
<< ptI << ' ' << localPoints[ptI]
|
||||||
<< " and " << prevPtI << ' '
|
<< " and " << prevPtI << ' '
|
||||||
<< localPoints[prevPtI]
|
<< localPoints[prevPtI]
|
||||||
@ -460,7 +494,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pout<< " small edge between points "
|
Info<< " small edge between points "
|
||||||
<< ptI << ' ' << localPoints[ptI]
|
<< ptI << ' ' << localPoints[ptI]
|
||||||
<< " and " << prevPtI << ' '
|
<< " and " << prevPtI << ' '
|
||||||
<< localPoints[prevPtI]
|
<< localPoints[prevPtI]
|
||||||
@ -471,7 +505,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Pout<< "Found " << nClose << " nearby points." << nl
|
Info<< "Found " << nClose << " nearby points." << nl
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -516,25 +550,25 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if ((nSingleEdges != 0) || (nMultEdges != 0))
|
if ((nSingleEdges != 0) || (nMultEdges != 0))
|
||||||
{
|
{
|
||||||
Pout<< "Surface is not closed since not all edges connected to "
|
Info<< "Surface is not closed since not all edges connected to "
|
||||||
<< "two faces:" << endl
|
<< "two faces:" << endl
|
||||||
<< " connected to one face : " << nSingleEdges << endl
|
<< " connected to one face : " << nSingleEdges << endl
|
||||||
<< " connected to >2 faces : " << nMultEdges << endl;
|
<< " connected to >2 faces : " << nMultEdges << endl;
|
||||||
|
|
||||||
Pout<< "Conflicting face labels:" << problemFaces.size() << endl;
|
Info<< "Conflicting face labels:" << problemFaces.size() << endl;
|
||||||
|
|
||||||
OFstream str("problemFaces");
|
OFstream str("problemFaces");
|
||||||
|
|
||||||
Pout<< "Dumping conflicting face labels to " << str.name() << endl
|
Info<< "Dumping conflicting face labels to " << str.name() << endl
|
||||||
<< "Paste this into the input for surfaceSubset" << endl;
|
<< "Paste this into the input for surfaceSubset" << endl;
|
||||||
|
|
||||||
str << problemFaces;
|
str << problemFaces;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pout<< "Surface is closed. All edges connected to two faces." << endl;
|
Info<< "Surface is closed. All edges connected to two faces." << endl;
|
||||||
}
|
}
|
||||||
Pout<< endl;
|
Info<< endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -544,11 +578,11 @@ int main(int argc, char *argv[])
|
|||||||
labelList faceZone;
|
labelList faceZone;
|
||||||
label numZones = surf.markZones(boolList(surf.nEdges(), false), faceZone);
|
label numZones = surf.markZones(boolList(surf.nEdges(), false), faceZone);
|
||||||
|
|
||||||
Pout<< "Number of unconnected parts : " << numZones << endl;
|
Info<< "Number of unconnected parts : " << numZones << endl;
|
||||||
|
|
||||||
if (numZones > 1)
|
if (numZones > 1)
|
||||||
{
|
{
|
||||||
Pout<< "Splitting surface into parts ..." << endl << endl;
|
Info<< "Splitting surface into parts ..." << endl << endl;
|
||||||
|
|
||||||
fileName surfFileNameBase(surfFileName.name());
|
fileName surfFileNameBase(surfFileName.name());
|
||||||
|
|
||||||
@ -585,7 +619,7 @@ int main(int argc, char *argv[])
|
|||||||
+ ".ftr"
|
+ ".ftr"
|
||||||
);
|
);
|
||||||
|
|
||||||
Pout<< "writing part " << zone << " size " << subSurf.size()
|
Info<< "writing part " << zone << " size " << subSurf.size()
|
||||||
<< " to " << subFileName << endl;
|
<< " to " << subFileName << endl;
|
||||||
|
|
||||||
subSurf.write(subFileName);
|
subSurf.write(subFileName);
|
||||||
@ -608,15 +642,15 @@ int main(int argc, char *argv[])
|
|||||||
labelList normalZone;
|
labelList normalZone;
|
||||||
label numNormalZones = PatchTools::markZones(surf, borderEdge, normalZone);
|
label numNormalZones = PatchTools::markZones(surf, borderEdge, normalZone);
|
||||||
|
|
||||||
Pout<< endl
|
Info<< endl
|
||||||
<< "Number of zones (connected area with consistent normal) : "
|
<< "Number of zones (connected area with consistent normal) : "
|
||||||
<< numNormalZones << endl;
|
<< numNormalZones << endl;
|
||||||
|
|
||||||
if (numNormalZones > 1)
|
if (numNormalZones > 1)
|
||||||
{
|
{
|
||||||
Pout<< "More than one normal orientation." << endl;
|
Info<< "More than one normal orientation." << endl;
|
||||||
}
|
}
|
||||||
Pout<< endl;
|
Info<< endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -625,19 +659,19 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (checkSelfIntersection)
|
if (checkSelfIntersection)
|
||||||
{
|
{
|
||||||
Pout<< "Checking self-intersection." << endl;
|
Info<< "Checking self-intersection." << endl;
|
||||||
|
|
||||||
triSurfaceSearch querySurf(surf);
|
triSurfaceSearch querySurf(surf);
|
||||||
surfaceIntersection inter(querySurf);
|
surfaceIntersection inter(querySurf);
|
||||||
|
|
||||||
if (inter.cutEdges().empty() && inter.cutPoints().empty())
|
if (inter.cutEdges().empty() && inter.cutPoints().empty())
|
||||||
{
|
{
|
||||||
Pout<< "Surface is not self-intersecting" << endl;
|
Info<< "Surface is not self-intersecting" << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pout<< "Surface is self-intersecting" << endl;
|
Info<< "Surface is self-intersecting" << endl;
|
||||||
Pout<< "Writing edges of intersection to selfInter.obj" << endl;
|
Info<< "Writing edges of intersection to selfInter.obj" << endl;
|
||||||
|
|
||||||
OFstream intStream("selfInter.obj");
|
OFstream intStream("selfInter.obj");
|
||||||
forAll(inter.cutPoints(), cutPointI)
|
forAll(inter.cutPoints(), cutPointI)
|
||||||
@ -654,11 +688,11 @@ int main(int argc, char *argv[])
|
|||||||
intStream << "l " << e.start()+1 << ' ' << e.end()+1 << endl;
|
intStream << "l " << e.start()+1 << ' ' << e.end()+1 << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Pout<< endl;
|
Info<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Pout<< "End\n" << endl;
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,6 +110,26 @@ Foam::boundBox::boundBox(Istream& is)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::tmp<Foam::pointField> Foam::boundBox::corners() const
|
||||||
|
{
|
||||||
|
tmp<pointField> tPts = tmp<pointField>(new pointField(8));
|
||||||
|
pointField& pt = tPts();
|
||||||
|
|
||||||
|
pt[0] = min_; // min-x, min-y, min-z
|
||||||
|
pt[1] = point(max_.x(), min_.y(), min_.z()); // max-x, min-y, min-z
|
||||||
|
pt[2] = point(max_.x(), max_.y(), min_.z()); // max-x, max-y, min-z
|
||||||
|
pt[3] = point(min_.x(), max_.y(), min_.z()); // min-x, max-y, min-z
|
||||||
|
pt[4] = point(min_.x(), min_.y(), max_.z()); // min-x, min-y, max-z
|
||||||
|
pt[5] = point(max_.x(), min_.y(), max_.z()); // max-x, min-y, max-z
|
||||||
|
pt[6] = max_; // max-x, max-y, max-z
|
||||||
|
pt[7] = point(min_.x(), max_.y(), max_.z()); // min-x, max-y, max-z
|
||||||
|
|
||||||
|
return tPts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const boundBox& bb)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const boundBox& bb)
|
||||||
|
|||||||
@ -171,6 +171,8 @@ public:
|
|||||||
return cmptAv(span());
|
return cmptAv(span());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Return corner points in an order corresponding to a 'hex' cell
|
||||||
|
tmp<pointField> corners() const;
|
||||||
|
|
||||||
// Query
|
// Query
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user