/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | foam-extend: Open Source CFD \\ / O peration | Version: 4.1 \\ / A nd | Web: http://www.foam-extend.org \\/ M anipulation | For copyright notice see file Copyright ------------------------------------------------------------------------------- License This file is part of foam-extend. foam-extend 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 3 of the License, or (at your option) any later version. foam-extend 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 foam-extend. If not, see . 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