/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2011-2025 OpenFOAM Foundation \\/ 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 3 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, see . \*---------------------------------------------------------------------------*/ #include "edgeSurface.H" #include "triSurface.H" #include "surfaceIntersection.H" #include "meshTools.H" #include "OFstream.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(edgeSurface, 0); } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // Write whole pointField and edges to stream void Foam::edgeSurface::writeOBJ ( const pointField& points, const edgeList& edges, Ostream& os ) { forAll(points, pointi) { const point& pt = points[pointi]; os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl; } forAll(edges, edgeI) { const edge& e = edges[edgeI]; os << "l " << e.start()+1 << ' ' << e.end()+1 << endl; } } // Write whole pointField and selected edges to stream void Foam::edgeSurface::writeOBJ ( const pointField& points, const edgeList& edges, const labelList& edgeLabels, Ostream& os ) { forAll(points, pointi) { const point& pt = points[pointi]; os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl; } forAll(edgeLabels, i) { const edge& e = edges[edgeLabels[i]]; os << "l " << e.start()+1 << ' ' << e.end()+1 << endl; } } // Pointedges in edgeSurface indices only. void Foam::edgeSurface::calcPointEdges() { pointEdges_.setSize(points_.size()); labelList pointNEdges(points_.size(), 0); forAll(edges_, edgeI) { const edge& e = edges_[edgeI]; pointNEdges[e[0]]++; pointNEdges[e[1]]++; } forAll(pointEdges_, pointi) { pointEdges_[pointi].setSize(pointNEdges[pointi]); } pointNEdges = 0; forAll(edges_, edgeI) { const edge& e = edges_[edgeI]; labelList& pEdges0 = pointEdges_[e[0]]; pEdges0[pointNEdges[e[0]]++] = edgeI; labelList& pEdges1 = pointEdges_[e[1]]; pEdges1[pointNEdges[e[1]]++] = edgeI; } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Construct from surface and intersection description Foam::edgeSurface::edgeSurface ( const triSurface& surf, const bool isFirstSurface, const surfaceIntersection& inter ) : points_(surf.nPoints() + inter.cutPoints().size()), nSurfacePoints_(surf.nPoints()), edges_(), nSurfaceEdges_(surf.nEdges()), parentEdges_(0), faceEdges_(surf.size()), pointEdges_(points_.size()) { // Copy points (surface ones first) // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ label pointi = 0; const pointField& surfPoints = surf.localPoints(); forAll(surfPoints, i) { points_[pointi++] = surfPoints[i]; } const pointField& cutPoints = inter.cutPoints(); forAll(cutPoints, i) { points_[pointi++] = cutPoints[i]; } // Copy edges (surface ones first) // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DynamicList allEdges(surf.nEdges() + inter.cutEdges().size()); DynamicList