/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 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 "intersectedSurface.H"
#include "surfaceIntersection.H"
#include "faceList.H"
#include "polygonTriangulate.H"
#include "treeBoundBox.H"
#include "OFstream.H"
#include "error.H"
#include "meshTools.H"
#include "edgeSurface.H"
#include "DynamicList.H"
#include "transform.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(intersectedSurface, 0);
}
const Foam::label Foam::intersectedSurface::UNVISITED = 0;
const Foam::label Foam::intersectedSurface::STARTTOEND = 1;
const Foam::label Foam::intersectedSurface::ENDTOSTART = 2;
const Foam::label Foam::intersectedSurface::BOTH = STARTTOEND | ENDTOSTART;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Write whole pointField and edges to stream
void Foam::intersectedSurface::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() << nl;
}
forAll(edges, edgeI)
{
const edge& e = edges[edgeI];
os << "l " << e.start()+1 << ' ' << e.end()+1 << nl;
}
}
// Write whole pointField and selected edges to stream
void Foam::intersectedSurface::writeOBJ
(
const pointField& points,
const edgeList& edges,
const labelList& faceEdges,
Ostream& os
)
{
forAll(points, pointi)
{
const point& pt = points[pointi];
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
}
forAll(faceEdges, i)
{
const edge& e = edges[faceEdges[i]];
os << "l " << e.start()+1 << ' ' << e.end()+1 << nl;
}
}
// write local points and edges to stream
void Foam::intersectedSurface::writeLocalOBJ
(
const pointField& points,
const edgeList& edges,
const labelList& faceEdges,
const fileName& fName
)
{
OFstream os(fName);
labelList pointMap(points.size(), -1);
label maxVertI = 0;
forAll(faceEdges, i)
{
const edge& e = edges[faceEdges[i]];
forAll(e, i)
{
label pointi = e[i];
if (pointMap[pointi] == -1)
{
const point& pt = points[pointi];
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
pointMap[pointi] = maxVertI++;
}
}
}
forAll(faceEdges, i)
{
const edge& e = edges[faceEdges[i]];
os << "l " << pointMap[e.start()]+1 << ' ' << pointMap[e.end()]+1
<< nl;
}
}
// Write whole pointField and face to stream
void Foam::intersectedSurface::writeOBJ
(
const pointField& points,
const face& f,
Ostream& os
)
{
forAll(points, pointi)
{
const point& pt = points[pointi];
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
}
os << 'f';
forAll(f, fp)
{
os << ' ' << f[fp]+1;
}
os << nl;
}
// Print current visited state.
void Foam::intersectedSurface::printVisit
(
const edgeList& edges,
const labelList& edgeLabels,
const Map