mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: surfaceCheck: added writing of zones as vtk file
This commit is contained in:
@ -1,9 +1,11 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/sampling/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/triSurface/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lsampling \
|
||||
-ltriSurface \
|
||||
-lsurfMesh \
|
||||
-lmeshTools
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -39,6 +39,7 @@ Description
|
||||
#include "surfaceIntersection.H"
|
||||
#include "SortableList.H"
|
||||
#include "PatchTools.H"
|
||||
#include "vtkSurfaceWriter.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -183,6 +184,12 @@ int main(int argc, char *argv[])
|
||||
"also check for self-intersection"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"splitNonManifold",
|
||||
"split surface along non-manifold edges"
|
||||
" (default split is fully disconnected)"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"verbose",
|
||||
"verbose operation"
|
||||
@ -198,6 +205,7 @@ int main(int argc, char *argv[])
|
||||
const fileName surfFileName = args[1];
|
||||
const bool checkSelfIntersect = args.optionFound("checkSelfIntersection");
|
||||
const bool verbose = args.optionFound("verbose");
|
||||
const bool splitNonManifold = args.optionFound("splitNonManifold");
|
||||
|
||||
Info<< "Reading surface from " << surfFileName << " ..." << nl << endl;
|
||||
|
||||
@ -565,56 +573,108 @@ int main(int argc, char *argv[])
|
||||
// Check singly connected domain
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
labelList faceZone;
|
||||
label numZones = surf.markZones(boolList(surf.nEdges(), false), faceZone);
|
||||
|
||||
Info<< "Number of unconnected parts : " << numZones << endl;
|
||||
|
||||
if (numZones > 1)
|
||||
{
|
||||
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")
|
||||
boolList borderEdge(surf.nEdges(), false);
|
||||
if (splitNonManifold)
|
||||
{
|
||||
surfFileNameBase = surfFileNameBase.lessExt();
|
||||
}
|
||||
|
||||
for (label zone = 0; zone < numZones; zone++)
|
||||
{
|
||||
boolList includeMap(surf.size(), false);
|
||||
|
||||
forAll(faceZone, faceI)
|
||||
const labelListList& eFaces = surf.edgeFaces();
|
||||
forAll(eFaces, edgeI)
|
||||
{
|
||||
if (faceZone[faceI] == zone)
|
||||
if (eFaces[edgeI].size() > 2)
|
||||
{
|
||||
includeMap[faceI] = true;
|
||||
borderEdge[edgeI] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
labelList pointMap;
|
||||
labelList faceMap;
|
||||
labelList faceZone;
|
||||
label numZones = surf.markZones(borderEdge, faceZone);
|
||||
|
||||
triSurface subSurf
|
||||
(
|
||||
surf.subsetMesh
|
||||
Info<< "Number of unconnected parts : " << numZones << endl;
|
||||
|
||||
if (numZones > 1)
|
||||
{
|
||||
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
|
||||
(
|
||||
includeMap,
|
||||
pointMap,
|
||||
faceMap
|
||||
)
|
||||
);
|
||||
surfFileName.path(),
|
||||
surfFileNameBase,
|
||||
surf.points(),
|
||||
faces,
|
||||
"zone",
|
||||
scalarFaceZone,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
fileName subFileName(surfFileNameBase + "_" + name(zone) + ".obj");
|
||||
|
||||
Info<< "writing part " << zone << " size " << subSurf.size()
|
||||
<< " to " << subFileName << endl;
|
||||
for (label zone = 0; zone < numZones; zone++)
|
||||
{
|
||||
boolList includeMap(surf.size(), false);
|
||||
|
||||
subSurf.write(subFileName);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user