/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright held by original author \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Description Takes multiply connected surface and tries to split surface at multiply connected edges by duplicating points. Introduces concept of - borderEdge. Edge with 4 faces connected to it. - borderPoint. Point connected to exactly 2 borderEdges. - borderLine. Connected list of borderEdges. By duplicating borderPoints this will split 'borderLines'. As a preprocessing step it can detect borderEdges without any borderPoints and explicitly split these triangles. The problems in this algorithm are: - determining which two (of the four) faces form a surface. Done by walking face-edge-face while keeping and edge or point on the borderEdge borderPoint. - determining the outwards pointing normal to be used to slightly offset the duplicated point. Uses sortedEdgeFaces quite a bit. Is tested on simple borderLines resulting from extracting a surface from a hex mesh. Will quite possibly go wrong on more complicated border lines (i.e. ones forming a loop). Dumps surface every so often since might take a long time to complete. \*---------------------------------------------------------------------------*/ #include "argList.H" #include "triSurface.H" #include "OFstream.H" #include "ListOps.H" #include "triSurfaceTools.H" using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void writeOBJ(Ostream& os, const pointField& pts) { forAll(pts, i) { const point& pt = pts[i]; os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl; } } void dumpPoints(const triSurface& surf, const labelList& borderPoint) { fileName fName("borderPoints.obj"); Info<< "Dumping borderPoints as Lightwave .obj file to " << fName << "\nThis can be visualized with e.g. javaview (www.javaview.de)\n\n"; OFstream os(fName); forAll(borderPoint, pointI) { if (borderPoint[pointI] != -1) { const point& pt = surf.localPoints()[pointI]; os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl; } } } void dumpEdges(const triSurface& surf, const boolList& borderEdge) { fileName fName("borderEdges.obj"); Info<< "Dumping borderEdges as Lightwave .obj file to " << fName << "\nThis can be visualized with e.g. javaview (www.javaview.de)\n\n"; OFstream os(fName); writeOBJ(os, surf.localPoints()); forAll(borderEdge, edgeI) { if (borderEdge[edgeI]) { const edge& e = surf.edges()[edgeI]; os << "l " << e.start()+1 << ' ' << e.end()+1 << endl; } } } void dumpFaces ( const fileName& fName, const triSurface& surf, const Map