mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: surface: various updates to the surface utilities
surfaceBooleanFeatures: use CGAL for intersection surfaceCheck: write surface zoning as vtk file surfaceInflate: new utility to offset surface surfacePatch: replacement for surfaceAutoPatch. Also does cutting of surfaces.
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -170,6 +170,101 @@ labelList countBins
|
||||
}
|
||||
|
||||
|
||||
|
||||
void writeZoning
|
||||
(
|
||||
const triSurface& surf,
|
||||
const labelList& faceZone,
|
||||
const word& fieldName,
|
||||
const fileName& surfFilePath,
|
||||
const fileName& surfFileNameBase
|
||||
)
|
||||
{
|
||||
Info<< "Writing zoning to "
|
||||
<< fileName
|
||||
(
|
||||
surfFilePath
|
||||
/ fieldName
|
||||
+ '_'
|
||||
+ surfFileNameBase
|
||||
+ '.'
|
||||
+ vtkSurfaceWriter::typeName
|
||||
)
|
||||
<< "..." << endl << endl;
|
||||
|
||||
// Convert data
|
||||
scalarField scalarFaceZone(faceZone.size());
|
||||
forAll(faceZone, i)
|
||||
{
|
||||
scalarFaceZone[i] = faceZone[i];
|
||||
}
|
||||
faceList faces(surf.size());
|
||||
forAll(surf, i)
|
||||
{
|
||||
faces[i] = surf[i].triFaceFace();
|
||||
}
|
||||
|
||||
vtkSurfaceWriter().write
|
||||
(
|
||||
surfFilePath,
|
||||
surfFileNameBase,
|
||||
surf.points(),
|
||||
faces,
|
||||
fieldName,
|
||||
scalarFaceZone,
|
||||
false // face based data
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void writeParts
|
||||
(
|
||||
const triSurface& surf,
|
||||
const label nFaceZones,
|
||||
const labelList& faceZone,
|
||||
const fileName& surfFilePath,
|
||||
const fileName& surfFileNameBase
|
||||
)
|
||||
{
|
||||
for (label zone = 0; zone < nFaceZones; zone++)
|
||||
{
|
||||
boolList includeMap(surf.size(), false);
|
||||
|
||||
forAll(faceZone, faceI)
|
||||
{
|
||||
if (faceZone[faceI] == zone)
|
||||
{
|
||||
includeMap[faceI] = true;
|
||||
}
|
||||
}
|
||||
|
||||
labelList pointMap;
|
||||
labelList faceMap;
|
||||
|
||||
triSurface subSurf
|
||||
(
|
||||
surf.subsetMesh
|
||||
(
|
||||
includeMap,
|
||||
pointMap,
|
||||
faceMap
|
||||
)
|
||||
);
|
||||
|
||||
fileName subName
|
||||
(
|
||||
surfFilePath
|
||||
/surfFileNameBase + "_" + name(zone) + ".obj"
|
||||
);
|
||||
|
||||
Info<< "writing part " << zone << " size " << subSurf.size()
|
||||
<< " to " << subName << endl;
|
||||
|
||||
subSurf.write(subName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@ -218,6 +313,20 @@ int main(int argc, char *argv[])
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
|
||||
|
||||
// Determine path and extension
|
||||
fileName surfFileNameBase(surfFileName.name());
|
||||
const word fileType = surfFileNameBase.ext();
|
||||
// Strip extension
|
||||
surfFileNameBase = surfFileNameBase.lessExt();
|
||||
// If extension was .gz strip original extension
|
||||
if (fileType == "gz")
|
||||
{
|
||||
surfFileNameBase = surfFileNameBase.lessExt();
|
||||
}
|
||||
const fileName surfFilePath(surfFileName.path());
|
||||
|
||||
|
||||
// write bounding box corners
|
||||
if (args.optionFound("blockMesh"))
|
||||
{
|
||||
@ -515,12 +624,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
DynamicList<label> problemFaces(surf.size()/100 + 1);
|
||||
|
||||
const labelListList& eFaces = surf.edgeFaces();
|
||||
const labelListList& edgeFaces = surf.edgeFaces();
|
||||
|
||||
label nSingleEdges = 0;
|
||||
forAll(eFaces, edgeI)
|
||||
forAll(edgeFaces, edgeI)
|
||||
{
|
||||
const labelList& myFaces = eFaces[edgeI];
|
||||
const labelList& myFaces = edgeFaces[edgeI];
|
||||
|
||||
if (myFaces.size() == 1)
|
||||
{
|
||||
@ -531,9 +640,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
label nMultEdges = 0;
|
||||
forAll(eFaces, edgeI)
|
||||
forAll(edgeFaces, edgeI)
|
||||
{
|
||||
const labelList& myFaces = eFaces[edgeI];
|
||||
const labelList& myFaces = edgeFaces[edgeI];
|
||||
|
||||
if (myFaces.size() > 2)
|
||||
{
|
||||
@ -549,7 +658,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if ((nSingleEdges != 0) || (nMultEdges != 0))
|
||||
{
|
||||
Info<< "Surface is not closed since not all edges connected to "
|
||||
Info<< "Surface is not closed since not all edges ("
|
||||
<< edgeFaces.size() << ") connected to "
|
||||
<< "two faces:" << endl
|
||||
<< " connected to one face : " << nSingleEdges << endl
|
||||
<< " connected to >2 faces : " << nMultEdges << endl;
|
||||
@ -578,10 +688,9 @@ int main(int argc, char *argv[])
|
||||
boolList borderEdge(surf.nEdges(), false);
|
||||
if (splitNonManifold)
|
||||
{
|
||||
const labelListList& eFaces = surf.edgeFaces();
|
||||
forAll(eFaces, edgeI)
|
||||
forAll(edgeFaces, edgeI)
|
||||
{
|
||||
if (eFaces[edgeI].size() > 2)
|
||||
if (edgeFaces[edgeI].size() > 2)
|
||||
{
|
||||
borderEdge[edgeI] = true;
|
||||
}
|
||||
@ -597,85 +706,15 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "Splitting surface into parts ..." << endl << endl;
|
||||
|
||||
fileName surfFileNameBase(surfFileName.name());
|
||||
const word fileType = surfFileNameBase.ext();
|
||||
// Strip extension
|
||||
surfFileNameBase = surfFileNameBase.lessExt();
|
||||
// If extension was .gz strip original extension
|
||||
if (fileType == "gz")
|
||||
{
|
||||
surfFileNameBase = surfFileNameBase.lessExt();
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
Info<< "Writing zoning to "
|
||||
<< fileName
|
||||
(
|
||||
"zone_"
|
||||
+ surfFileNameBase
|
||||
+ '.'
|
||||
+ vtkSurfaceWriter::typeName
|
||||
)
|
||||
<< "..." << endl << endl;
|
||||
|
||||
// Convert data
|
||||
scalarField scalarFaceZone(faceZone.size());
|
||||
forAll(faceZone, i)
|
||||
{
|
||||
scalarFaceZone[i] = faceZone[i];
|
||||
}
|
||||
faceList faces(surf.size());
|
||||
forAll(surf, i)
|
||||
{
|
||||
faces[i] = surf[i].triFaceFace();
|
||||
}
|
||||
|
||||
vtkSurfaceWriter().write
|
||||
(
|
||||
surfFileName.path(),
|
||||
surfFileNameBase,
|
||||
surf.points(),
|
||||
faces,
|
||||
"zone",
|
||||
scalarFaceZone,
|
||||
false // face based data
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
for (label zone = 0; zone < numZones; zone++)
|
||||
{
|
||||
boolList includeMap(surf.size(), false);
|
||||
|
||||
forAll(faceZone, faceI)
|
||||
{
|
||||
if (faceZone[faceI] == zone)
|
||||
{
|
||||
includeMap[faceI] = true;
|
||||
}
|
||||
}
|
||||
|
||||
labelList pointMap;
|
||||
labelList faceMap;
|
||||
|
||||
triSurface subSurf
|
||||
(
|
||||
surf.subsetMesh
|
||||
(
|
||||
includeMap,
|
||||
pointMap,
|
||||
faceMap
|
||||
)
|
||||
);
|
||||
|
||||
fileName subName(surfFileNameBase + "_" + name(zone) + ".obj");
|
||||
|
||||
Info<< "writing part " << zone << " size " << subSurf.size()
|
||||
<< " to " << subName << endl;
|
||||
|
||||
subSurf.write(subName);
|
||||
}
|
||||
writeZoning(surf, faceZone, "zone", surfFilePath, surfFileNameBase);
|
||||
writeParts
|
||||
(
|
||||
surf,
|
||||
numZones,
|
||||
faceZone,
|
||||
surfFilePath,
|
||||
surfFileNameBase
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -700,6 +739,15 @@ int main(int argc, char *argv[])
|
||||
if (numNormalZones > 1)
|
||||
{
|
||||
Info<< "More than one normal orientation." << endl;
|
||||
writeZoning(surf, normalZone, "normal", surfFilePath, surfFileNameBase);
|
||||
writeParts
|
||||
(
|
||||
surf,
|
||||
numNormalZones,
|
||||
normalZone,
|
||||
surfFilePath,
|
||||
surfFileNameBase + "_normal"
|
||||
);
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user