diff --git a/applications/utilities/surface/surfaceCheck/Make/options b/applications/utilities/surface/surfaceCheck/Make/options index 27e7740a942115faa91ed234a4925ac90dd1d955..ef204ab685abd76efe285c169f1597226b475441 100644 --- a/applications/utilities/surface/surfaceCheck/Make/options +++ b/applications/utilities/surface/surfaceCheck/Make/options @@ -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 diff --git a/applications/utilities/surface/surfaceCheck/surfaceCheck.C b/applications/utilities/surface/surfaceCheck/surfaceCheck.C index 0e28f5c6c5b00a581556f4e0c14b546545de1553..db6b1b02af4ab25ac2aad3b1e08a46626bd9a0ba 100644 --- a/applications/utilities/surface/surfaceCheck/surfaceCheck.C +++ b/applications/utilities/surface/surfaceCheck/surfaceCheck.C @@ -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(); + const labelListList& eFaces = surf.edgeFaces(); + forAll(eFaces, edgeI) + { + if (eFaces[edgeI].size() > 2) + { + borderEdge[edgeI] = true; + } + } } - for (label zone = 0; zone < numZones; zone++) + labelList faceZone; + label numZones = surf.markZones(borderEdge, faceZone); + + Info<< "Number of unconnected parts : " << numZones << endl; + + if (numZones > 1) { - boolList includeMap(surf.size(), false); + Info<< "Splitting surface into parts ..." << endl << endl; - forAll(faceZone, faceI) + fileName surfFileNameBase(surfFileName.name()); + const word fileType = surfFileNameBase.ext(); + // Strip extension + surfFileNameBase = surfFileNameBase.lessExt(); + // If extension was .gz strip original extension + if (fileType == "gz") { - if (faceZone[faceI] == zone) + surfFileNameBase = surfFileNameBase.lessExt(); + } + + + { + Info<< "Writing zoning to " + << fileName + ( + "zone_" + + surfFileNameBase + + '.' + + vtkSurfaceWriter::typeName + ) + << "..." << endl << endl; + + // Convert data + scalarField scalarFaceZone(faceZone.size()); + forAll(faceZone, i) { - includeMap[faceI] = true; + 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, + true + ); } - labelList pointMap; - labelList faceMap; - triSurface subSurf - ( - surf.subsetMesh + 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 ( - includeMap, - pointMap, - faceMap - ) - ); + surf.subsetMesh + ( + includeMap, + pointMap, + faceMap + ) + ); - fileName subFileName(surfFileNameBase + "_" + name(zone) + ".obj"); + fileName subName(surfFileNameBase + "_" + name(zone) + ".obj"); - Info<< "writing part " << zone << " size " << subSurf.size() - << " to " << subFileName << endl; + Info<< "writing part " << zone << " size " << subSurf.size() + << " to " << subName << endl; - subSurf.write(subFileName); + subSurf.write(subName); + } } }