ENH: additional methods for OBJstream

- write point fields
- writeLine (takes two points)
- writeFace (takes list of face loop points)
This commit is contained in:
Mark Olesen
2022-07-13 20:16:35 +02:00
parent dea31e9b4a
commit c4d18e97a3
40 changed files with 301 additions and 359 deletions

View File

@ -699,7 +699,7 @@ void Foam::radiation::laserDTRM::calculate()
for (label pointi = 0; pointi < lines.size(); pointi += 2)
{
os.write(linePointRef(lines[pointi], lines[pointi+1]));
os.writeLine(lines[pointi], lines[pointi+1]);
}
}

View File

@ -1397,26 +1397,20 @@ void extrudeGeometricProperties
{
Pout<< "Model :" << faceCentres[facei] << endl
<< "regionMesh:" << regionMesh.faceCentres()[facei] << endl;
faceStr.write
(
linePointRef
faceStr.writeLine
(
faceCentres[facei],
regionMesh.faceCentres()[facei]
)
);
}
forAll(cellCentres, celli)
{
Pout<< "Model :" << cellCentres[celli] << endl
<< "regionMesh:" << regionMesh.cellCentres()[celli] << endl;
cellStr.write
(
linePointRef
cellStr.writeLine
(
cellCentres[celli],
regionMesh.cellCentres()[celli]
)
);
}
}

View File

@ -1687,7 +1687,7 @@ void Foam::conformalVoronoiMesh::move()
)
)
{
multipleIntersections.write(linePointRef(ptA, ptB));
multipleIntersections.writeLine(ptA, ptB);
}
}
}

View File

@ -83,7 +83,7 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
// Forward Declarations
class initialPointsMethod;
class relaxationModel;
class faceAreaWeightModel;

View File

@ -1433,18 +1433,15 @@ void Foam::conformalVoronoiMesh::indexDualVertices
// && (mag(snapDir & norm[0]) > 0.5)
// )
// {
// snapping1.write
// snapping1.writeLine
// (
// linePointRef(dual, nearestPointOnTet)
// dual,
// nearestPointOnTet
// );
//
// snapping2.write
// (
// linePointRef
// snapping2.writeLine
// (
// nearestPointOnTet,
// hitInfo.hitPoint()
// )
// );
//
// pts[cit->cellIndex()] = hitInfo.hitPoint();
@ -1764,9 +1761,10 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
if ((*vcit)->real())
{
featurePointDualsStr.write
featurePointDualsStr.writeLine
(
linePointRef(topoint(vit->point()), (*vcit)->dual())
topoint(vit->point()),
(*vcit)->dual()
);
}
}
@ -1867,7 +1865,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
<< " " << vc2->dual()
<< endl;
startCellStr.write(linePointRef(vc1->dual(), vc2->dual()));
startCellStr.writeLine(vc1->dual(), vc2->dual());
// Get patch by getting face between cells and the two
// points on the face that are not the feature vertex

View File

@ -1395,10 +1395,7 @@ void Foam::conformalVoronoiMesh::writePointPairs
if (ptPairs_.isPointPair(vA, vB))
{
os.write
(
linePointRef(topoint(vA->point()), topoint(vB->point()))
);
os.writeLine(topoint(vA->point()), topoint(vB->point()));
}
}
}

View File

@ -76,7 +76,7 @@ void isoFacesToFile
{
for (const List<point>& facePts : procFaces)
{
os.write(face(identity(facePts.size())), facePts);
os.writeFace(facePts);
}
}
}
@ -87,7 +87,7 @@ void isoFacesToFile
for (const List<point>& facePts : faces)
{
os.write(face(identity(facePts.size())), facePts);
os.writeFace(facePts);
}
}
}

View File

@ -81,7 +81,6 @@ Description
#include "triSurfaceSearch.H"
#include "triSurfaceMesh.H"
#include "OFstream.H"
#include "OBJstream.H"
#include "booleanSurface.H"
#include "edgeIntersections.H"
#include "meshTools.H"

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -856,12 +856,10 @@ int main(int argc, char *argv[])
if (debug)
{
OBJstream str(runTime.path()/"isScaledPoint.obj");
forAll(isScaledPoint, pointI)
for (const label pointi : isScaledPoint)
{
if (isScaledPoint[pointI])
{
str.write(initialPoints[meshPoints[pointI]]);
}
str.write(initialPoints[meshPoints[pointi]]);
}
}

View File

@ -34,7 +34,7 @@ License
namespace Foam
{
defineTypeNameAndDebug(OBJstream, 0);
defineTypeName(OBJstream);
}
@ -161,35 +161,45 @@ Foam::Ostream& Foam::OBJstream::writeQuoted
}
Foam::Ostream& Foam::OBJstream::write(const point& pt)
Foam::Ostream& Foam::OBJstream::write(const point& p)
{
write("v ") << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
write('v') << ' ' << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
return *this;
}
Foam::Ostream& Foam::OBJstream::write(const point& pt, const vector& n)
Foam::Ostream& Foam::OBJstream::write(const point& p, const vector& n)
{
write(pt);
write(p);
OFstream::write("vn ") << n.x() << ' ' << n.y() << ' ' << n.z() << nl;
return *this;
}
Foam::Ostream& Foam::OBJstream::write(const UList<point>& points)
{
for (const point& p : points)
{
write('v') << ' ' << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
}
return *this;
}
Foam::Ostream& Foam::OBJstream::write(const edge& e, const UList<point>& points)
{
write(points[e[0]]);
write(points[e[1]]);
write("l ") << nVertices_-1 << ' ' << nVertices_ << nl;
write(points[e.first()]);
write(points[e.second()]);
write('l') << ' ' << nVertices_-1 << ' ' << nVertices_ << nl;
return *this;
}
Foam::Ostream& Foam::OBJstream::write(const linePointRef& ln)
{
write(ln.start());
write(ln.end());
write("l ") << nVertices_-1 << ' ' << nVertices_ << nl;
write(ln.first());
write(ln.second());
write('l') << ' ' << nVertices_-1 << ' ' << nVertices_ << nl;
return *this;
}
@ -201,9 +211,22 @@ Foam::Ostream& Foam::OBJstream::write
const vector& n1
)
{
write(ln.start(), n0);
write(ln.end(), n1);
write("l ") << nVertices_-1 << ' ' << nVertices_ << nl;
write(ln.first(), n0);
write(ln.second(), n1);
write('l') << ' ' << nVertices_-1 << ' ' << nVertices_ << nl;
return *this;
}
Foam::Ostream& Foam::OBJstream::writeLine
(
const point& p0,
const point& p1
)
{
write(p0);
write(p1);
write('l') << ' ' << nVertices_-1 << ' ' << nVertices_ << nl;
return *this;
}
@ -221,7 +244,7 @@ Foam::Ostream& Foam::OBJstream::write
if (lines)
{
write('l');
for (int i = 0; i < 3; i++)
for (int i = 0; i < 3; ++i)
{
write(' ') << i+start;
}
@ -230,7 +253,39 @@ Foam::Ostream& Foam::OBJstream::write
else
{
write('f');
for (int i = 0; i < 3; i++)
for (int i = 0; i < 3; ++i)
{
write(' ') << i+start;
}
write('\n');
}
return *this;
}
Foam::Ostream& Foam::OBJstream::writeFace
(
const UList<point>& points,
const bool lines
)
{
const label start = nVertices_+1; // 1-offset for obj included here
write(points);
if (lines)
{
write('l');
forAll(points, i)
{
write(' ') << i+start;
}
write(' ') << start << '\n';
}
else
{
write('f');
forAll(points, i)
{
write(' ') << i+start;
}
@ -248,9 +303,10 @@ Foam::Ostream& Foam::OBJstream::write
)
{
const label start = nVertices_+1; // 1-offset for obj included here
forAll(f, i)
for (const label fp : f)
{
write(points[f[i]]);
write(points[fp]);
}
if (lines)
{
@ -283,35 +339,27 @@ Foam::Ostream& Foam::OBJstream::write
{
primitivePatch pp(SubList<face>(faces), points);
const pointField& localPoints = pp.localPoints();
const faceList& localFaces = pp.localFaces();
const label start = nVertices_+1; // 1-offset for obj included here
forAll(localPoints, i)
{
write(localPoints[i]);
}
write(pp.localPoints());
if (lines)
{
const edgeList& edges = pp.edges();
forAll(edges, edgeI)
for (const edge& e : pp.edges())
{
const edge& e = edges[edgeI];
write("l ") << e[0]+start << ' ' << e[1]+start << nl;
write('l') << ' '
<< e.first()+start << ' '
<< e.second()+start << nl;
}
}
else
{
forAll(localFaces, facei)
for (const face& f : pp.localFaces())
{
const face& f = localFaces[facei];
write('f');
forAll(f, i)
for (const label fp : f)
{
write(' ') << f[i]+start;
write(' ') << fp+start;
}
write('\n');
}
@ -335,46 +383,39 @@ Foam::Ostream& Foam::OBJstream::write
label objPointId = nVertices_+1; // 1-offset for obj included here
Map<label> markedPoints(2*edges.size());
forAll(edges, edgei)
{
const edge& e = edges[edgei];
if (markedPoints.insert(e[0], objPointId))
for (const edge& e : edges)
{
write(points[e[0]]);
if (markedPoints.insert(e.first(), objPointId))
{
write(points[e.first()]);
++objPointId;
}
if (markedPoints.insert(e[1], objPointId))
if (markedPoints.insert(e.second(), objPointId))
{
write(points[e[1]]);
write(points[e.second()]);
++objPointId;
}
}
forAll(edges, edgei)
for (const edge& e : edges)
{
const edge& e = edges[edgei];
write("l ")
<< markedPoints[e[0]] << ' '
<< markedPoints[e[1]] << nl;
write('l') << ' '
<< markedPoints[e.first()] << ' '
<< markedPoints[e.second()] << nl;
}
}
else
{
const label start = nVertices_+1; // 1-offset for obj included here
forAll(points, i)
{
write(points[i]);
}
write(points);
forAll(edges, edgei)
for (const edge& e : edges)
{
const edge& e = edges[edgei];
write("l ")
<< e[0]+start << ' ' << e[1]+start << nl;
write('l') << ' '
<< e.first()+start << ' '
<< e.second()+start << nl;
}
}
@ -390,31 +431,25 @@ Foam::Ostream& Foam::OBJstream::write
{
const label start = nVertices_+1; // 1-offset for obj included here
pointField points(bb.points());
forAll(points, i)
{
write(points[i]);
}
write(bb.points());
if (lines)
{
forAll(treeBoundBox::edges, edgei)
for (const edge& e : treeBoundBox::edges)
{
const edge& e = treeBoundBox::edges[edgei];
write("l ") << e[0]+start << ' ' << e[1]+start << nl;
write('l') << ' '
<< e.first()+start << ' '
<< e.second()+start << nl;
}
}
else
{
forAll(treeBoundBox::faces, facei)
for (const face& f : treeBoundBox::faces)
{
const face& f = treeBoundBox::faces[facei];
write('f');
forAll(f, i)
for (const label fp : f)
{
write(' ') << f[i]+start;
write(' ') << fp+start;
}
write('\n');
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2015 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,7 +28,8 @@ Class
Foam::OBJstream
Description
OFstream that keeps track of vertices
An OFstream that keeps track of vertices and provides convenience
output methods for OBJ files.
SourceFiles
OBJstream.C
@ -73,8 +74,8 @@ class OBJstream
public:
//- Declare type-name (with debug switch)
ClassName("OBJstream");
//- Declare type-name (no debug switch)
ClassNameNoDebug("OBJstream");
// Constructors
@ -105,10 +106,8 @@ public:
// Member Functions
// Access
//- Return the number of vertices written
label nVertices() const
label nVertices() const noexcept
{
return nVertices_;
}
@ -143,12 +142,15 @@ public:
// Direct write functionality
//- Write point
Ostream& write(const point& pt);
Ostream& write(const point& p);
//- Write point and vector normal ('vn')
Ostream& write(const point& pt, const vector& n);
Ostream& write(const point& p, const vector& n);
//- Write edge as points and line
//- Write multiple points
Ostream& write(const UList<point>& points);
//- Write edge as points with line
Ostream& write(const edge& e, const UList<point>& points);
//- Write line
@ -162,10 +164,20 @@ public:
const vector& n1
);
//- Write triangle as points and lines/filled-polygon
//- Write line joining two points
Ostream& writeLine(const point& p0, const point& p1);
//- Write triangle as points with lines/filled-polygon
Ostream& write(const triPointRef& f, const bool lines = true);
//- Write face as points and lines/filled-polygon
//- Write face loop points with lines/filled-polygon
Ostream& writeFace
(
const UList<point>& points,
const bool lines = true
);
//- Write face as points with lines/filled-polygon
Ostream& write
(
const face& f,
@ -173,7 +185,7 @@ public:
const bool lines = true
);
//- Write patch faces as points and lines/filled-polygon
//- Write patch faces as points with lines/filled-polygon
Ostream& write
(
const UList<face>& faces,
@ -181,7 +193,7 @@ public:
const bool lines = true
);
//- Write edges as points and lines.
//- Write edges as points with lines.
// Optionally eliminate unused points.
Ostream& write
(
@ -190,12 +202,8 @@ public:
const bool compact = false
);
//- Write tree-bounding box as lines/filled-polygons
Ostream& write
(
const treeBoundBox& bb,
const bool lines = true
);
//- Write tree-bounding box with lines/filled-polygons
Ostream& write(const treeBoundBox& bb, const bool lines = true);
};

View File

@ -801,7 +801,7 @@ void Foam::averageNeighbourFvGeometryScheme::movePoints()
forAll(cellCentres, celli)
{
const point& cc = cellCentres[celli];
osPtr().write(linePointRef(cc-correction[celli], cc));
osPtr().writeLine(cc-correction[celli], cc);
}
const scalarField magCorrection(mag(correction));
@ -871,7 +871,7 @@ void Foam::averageNeighbourFvGeometryScheme::movePoints()
{
const point& oldCc = mesh_.cellCentres()[celli];
const point& newCc = cellCentres[celli];
str.write(linePointRef(oldCc, newCc));
str.writeLine(oldCc, newCc);
}
}
if (debug)
@ -885,7 +885,7 @@ void Foam::averageNeighbourFvGeometryScheme::movePoints()
{
const point& oldFc = mesh_.faceCentres()[facei];
const point& newFc = faceCentres[facei];
str.write(linePointRef(oldFc, newFc));
str.writeLine(oldFc, newFc);
}
}

View File

@ -168,7 +168,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
for (const findCellParticle& tp : cloud)
{
str.write(linePointRef(tp.position(), tp.end()));
str.writeLine(tp.position(), tp.end());
}
}
@ -232,7 +232,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
const labelList& cData = cellToWalls_[celli];
forAll(cData, i)
{
str.write(linePointRef(ends[i], start[cData[i]]));
str.writeLine(ends[i], start[cData[i]]);
}
}
}

View File

@ -196,7 +196,7 @@ Foam::blockEdges::projectCurveEdge::position(const scalarList& lambdas) const
{
forAll(points, i)
{
debugStr().write(linePointRef(start[i], points[i]));
debugStr().writeLine(start[i], points[i]);
}
}
}
@ -257,7 +257,7 @@ Foam::blockEdges::projectCurveEdge::position(const scalarList& lambdas) const
forAll(points, i)
{
const point predicted(points[i] + residual[i]);
debugStr().write(linePointRef(points[i], predicted));
debugStr().writeLine(points[i], predicted);
}
}

View File

@ -198,7 +198,7 @@ Foam::blockEdges::projectEdge::position(const scalarList& lambdas) const
{
forAll(points, i)
{
debugStr().write(linePointRef(start[i], points[i]));
debugStr().writeLine(start[i], points[i]);
}
}
}
@ -259,7 +259,7 @@ Foam::blockEdges::projectEdge::position(const scalarList& lambdas) const
forAll(points, i)
{
const point predicted(points[i] + residual[i]);
debugStr().write(linePointRef(points[i], predicted));
debugStr().writeLine(points[i], predicted);
}
}

View File

@ -233,7 +233,7 @@ void Foam::blockFaces::projectFace::project
const point& hitPt = hits[i].hitPoint();
if (debugStr)
{
debugStr().write(linePointRef(points[i], hitPt));
debugStr().writeLine(points[i], hitPt);
}
points[i] = hitPt;
}
@ -304,7 +304,7 @@ void Foam::blockFaces::projectFace::project
forAll(points, i)
{
const point predicted(points[i] + residual[i]);
debugStr().write(linePointRef(points[i], predicted));
debugStr().writeLine(points[i], predicted);
}
}
@ -356,7 +356,7 @@ void Foam::blockFaces::projectFace::project
forAll(points, i)
{
const point predicted(points[i] + residual[i]);
debugStr().write(linePointRef(points[i], predicted));
debugStr().writeLine(points[i], predicted);
}
}

View File

@ -1558,19 +1558,12 @@ void Foam::medialAxisMeshMover::calculateDisplacement
if (str)
{
const point& pt = mesh().points()[pointI];
str().write(linePointRef(pt, pt+patchDisp[patchPointI]));
str().writeLine(pt, pt+patchDisp[patchPointI]);
}
if (medialVecStr)
{
const point& pt = mesh().points()[pointI];
medialVecStr().write
(
linePointRef
(
pt,
medialVec_[pointI]
)
);
medialVecStr().writeLine(pt, medialVec_[pointI]);
}
}
}

View File

@ -261,12 +261,9 @@ void Foam::meshRefinement::getIntersections
{
if (str)
{
str().write(linePointRef(start[i], hit1[i].rawPoint()));
str().write
(
linePointRef(hit1[i].rawPoint(), hit2[i].rawPoint())
);
str().write(linePointRef(hit2[i].rawPoint(), end[i]));
str().writeLine(start[i], hit1[i].rawPoint());
str().writeLine(hit1[i].rawPoint(), hit2[i].rawPoint());
str().writeLine(hit2[i].rawPoint(), end[i]);
}
// Pick up the patches

View File

@ -828,8 +828,8 @@ Foam::label Foam::meshRefinement::markProximityRefinementWave
// max(smallGapDistance[celli], maxDist);
//
//
// str.write(linePointRef(cc, origin[i]));
// str.write(linePointRef(cc, origin[j]));
// str.writeLine(cc, origin[i]);
// str.writeLine(cc, origin[j]);
//
// nMulti++;
//}

View File

@ -40,7 +40,6 @@ License
#include "mapDistributePolyMesh.H"
#include "Cloud.H"
//#include "globalIndex.H"
#include "OBJstream.H"
#include "cellSet.H"
#include "treeDataCell.H"
@ -1797,22 +1796,8 @@ Foam::label Foam::meshRefinement::markProximityRefinement
end.clear();
minLevel.clear();
//// Extract per cell information on the surface with the highest max
//OBJstream str
//(
// mesh_.time().path()
// / "findAllIntersections_"
// + mesh_.time().timeName()
// + ".obj"
//);
//// All intersections
//OBJstream str2
//(
// mesh_.time().path()
// / "findAllIntersections2_"
// + mesh_.time().timeName()
// + ".obj"
//);
forAll(testFaces, i)
{

View File

@ -89,7 +89,7 @@ void Foam::snappyLayerDriver::dumpDisplacement
forAll(patchDisp, patchPointi)
{
const point& pt = pp.localPoints()[patchPointi];
dispStr.write(linePointRef(pt, pt + patchDisp[patchPointi]));
dispStr.writeLine(pt, pt + patchDisp[patchPointi]);
}
@ -101,7 +101,7 @@ void Foam::snappyLayerDriver::dumpDisplacement
if (extrudeStatus[patchPointi] != EXTRUDE)
{
const point& pt = pp.localPoints()[patchPointi];
illStr.write(linePointRef(pt, pt + patchDisp[patchPointi]));
illStr.writeLine(pt, pt + patchDisp[patchPointi]);
}
}
}
@ -797,9 +797,7 @@ void Foam::snappyLayerDriver::handleFeatureAngle
if (str)
{
const point& p0 = pp.localPoints()[e[0]];
const point& p1 = pp.localPoints()[e[1]];
str().write(linePointRef(p0, p1));
str().write(e, pp.localPoints());
}
}
}
@ -3572,7 +3570,7 @@ void Foam::snappyLayerDriver::dupFaceZonePoints
if (newMasteri != pointi)
{
str.write(linePointRef(p[pointi], p[newMasteri]));
str.writeLine(p[pointi], p[newMasteri]);
}
}
}
@ -3626,7 +3624,7 @@ void Foam::snappyLayerDriver::mergeFaceZonePoints
{
const point& pt = mesh.points()[pointi];
const point& otherPt = mesh.points()[otherPointi];
str.write(linePointRef(pt, otherPt));
str.writeLine(pt, otherPt);
}
}
}

View File

@ -1300,11 +1300,11 @@ void Foam::snappySnapDriver::detectNearSurfaces
// {
// if (hit1[i].hit())
// {
// str.write(linePointRef(start[i], hit1[i].hitPoint()));
// str.writeLine(start[i], hit1[i].hitPoint());
// }
// if (hit2[i].hit())
// {
// str.write(linePointRef(start[i], hit2[i].hitPoint()));
// str.writeLine(start[i], hit2[i].hitPoint());
// }
// }
// }
@ -1403,7 +1403,7 @@ void Foam::snappySnapDriver::detectNearSurfaces
//
// if (isCoplanar)
// {
// str.write(linePointRef(surfPointA, surfPointB));
// str.writeLine(surfPointA, surfPointB);
// }
// }
// }
@ -1550,7 +1550,7 @@ void Foam::snappySnapDriver::detectNearSurfaces
if (gapStr)
{
const point& intPt = hit2[pointi].hitPoint();
gapStr().write(linePointRef(pt, intPt));
gapStr().writeLine(pt, intPt);
}
// Choose hit2 : nearest to end point (so inside the domain)
@ -1692,7 +1692,7 @@ void Foam::snappySnapDriver::detectNearSurfaces
if (gapStr)
{
const point& intPt = hit2[i].hitPoint();
gapStr().write(linePointRef(pt, intPt));
gapStr().writeLine(pt, intPt);
}
disp[pointi] = hit2[i].hitPoint()-pt;

View File

@ -1255,11 +1255,11 @@ void Foam::snappySnapDriver::featureAttractionUsingReconstruction
if (feStr && patchConstraints[pointi].first() == 2)
{
feStr().write(linePointRef(pt, pt+patchAttraction[pointi]));
feStr().writeLine(pt, pt+patchAttraction[pointi]);
}
else if (fpStr && patchConstraints[pointi].first() == 3)
{
fpStr().write(linePointRef(pt, pt+patchAttraction[pointi]));
fpStr().writeLine(pt, pt+patchAttraction[pointi]);
}
}
}
@ -2516,9 +2516,10 @@ void Foam::snappySnapDriver::determineFeatures
// Dump
if (featureEdgeStr)
{
featureEdgeStr().write
featureEdgeStr().writeLine
(
linePointRef(pt, info.hitPoint())
pt,
info.hitPoint()
);
}
}
@ -2526,9 +2527,10 @@ void Foam::snappySnapDriver::determineFeatures
{
if (missedEdgeStr)
{
missedEdgeStr().write
missedEdgeStr().writeLine
(
linePointRef(pt, multiPatchPt.hitPoint())
pt,
multiPatchPt.hitPoint()
);
}
}
@ -2582,10 +2584,7 @@ void Foam::snappySnapDriver::determineFeatures
// Debug: dump missed feature point
if (missedMP0Str && !nearInfo.second().hit())
{
missedMP0Str().write
(
linePointRef(pt, estimatedPt)
);
missedMP0Str().writeLine(pt, estimatedPt);
}
}
else
@ -2647,10 +2646,7 @@ void Foam::snappySnapDriver::determineFeatures
// Debug: dump missed feature point
if (missedMP1Str && !nearInfo.second().hit())
{
missedMP1Str().write
(
linePointRef(pt, estimatedPt)
);
missedMP1Str().writeLine(pt, estimatedPt);
}
}
}
@ -2689,10 +2685,7 @@ void Foam::snappySnapDriver::determineFeatures
&& patchConstraints[pointi].first() == 3
)
{
featurePointStr().write
(
linePointRef(pt, info.hitPoint())
);
featurePointStr().writeLine(pt, info.hitPoint());
}
else if
(
@ -2700,20 +2693,14 @@ void Foam::snappySnapDriver::determineFeatures
&& patchConstraints[pointi].first() == 2
)
{
featureEdgeStr().write
(
linePointRef(pt, info.hitPoint())
);
featureEdgeStr().writeLine(pt, info.hitPoint());
}
}
else
{
if (missedEdgeStr)
{
missedEdgeStr().write
(
linePointRef(pt, estimatedPt)
);
missedEdgeStr().writeLine(pt, estimatedPt);
}
}
}
@ -2806,10 +2793,7 @@ void Foam::snappySnapDriver::determineFeatures
const pointIndexHit& info = nearInfo.second();
if (featurePointStr && info.hit())
{
featurePointStr().write
(
linePointRef(pt, info.hitPoint())
);
featurePointStr().writeLine(pt, info.hitPoint());
}
}
}
@ -2931,9 +2915,7 @@ void Foam::snappySnapDriver::determineBaffleFeatures
if (baffleEdgeStr)
{
const point& p0 = pp.localPoints()[e[0]];
const point& p1 = pp.localPoints()[e[1]];
baffleEdgeStr().write(linePointRef(p0, p1));
baffleEdgeStr().write(e, pp.localPoints());
}
}
}
@ -3640,11 +3622,11 @@ void Foam::snappySnapDriver::featureAttractionUsingFeatureEdges
if (patchConstraints[pointi].first() == 2)
{
featureEdgeStr.write(linePointRef(pt, pt+attr));
featureEdgeStr.writeLine(pt, pt+attr);
}
else if (patchConstraints[pointi].first() == 3)
{
featurePointStr.write(linePointRef(pt, pt+attr));
featurePointStr.writeLine(pt, pt+attr);
}
}
}
@ -3827,10 +3809,7 @@ void Foam::snappySnapDriver::preventFaceSqueeze
if (strPtr)
{
strPtr().write
(
linePointRef(pt, pt+patchAttraction[pointi])
);
strPtr().writeLine(pt, pt+patchAttraction[pointi]);
}
}
}

View File

@ -63,9 +63,8 @@ namespace Foam
// Write out triangulated surfaces as OBJ files
OBJstream srcTriObj("srcTris_" + Foam::name(nAMI) + ".obj");
const pointField& srcPts = src.points();
forAll(srcTris_, facei)
for (const DynamicList<face>& faces : srcTris_)
{
const DynamicList<face>& faces = srcTris_[facei];
for (const face& f : faces)
{
srcTriObj.write
@ -77,9 +76,8 @@ namespace Foam
OBJstream tgtTriObj("tgtTris_" + Foam::name(nAMI) + ".obj");
const pointField& tgtPts = tgt.points();
forAll(tgtTris_, facei)
for (const DynamicList<face>& faces : tgtTris_)
{
const DynamicList<face>& faces = tgtTris_[facei];
for (const face& f : faces)
{
tgtTriObj.write

View File

@ -27,7 +27,6 @@ License
#include "faceAreaWeightAMI2D.H"
#include "profiling.H"
#include "OBJstream.H"
#include "addToRunTimeSelectionTable.H"
#include "triangle2D.H"

View File

@ -44,6 +44,7 @@ SourceFiles
namespace Foam
{
// Forward Declarations
class OBJstream;
/*---------------------------------------------------------------------------*\

View File

@ -1940,14 +1940,10 @@ void Foam::extendedEdgeMesh::writeObj(const fileName& prefix) const
{
const labelList& ptEds = pointEdges()[i];
forAll(ptEds, j)
for (const label edgei : ptEds)
{
const edge& e = edges()[ptEds[j]];
mixedFtPtStructureStr.write
(
linePointRef(points()[e[0]],
points()[e[1]])
);
const edge& e = edges()[edgei];
mixedFtPtStructureStr.write(e, points());
}
}
}
@ -1960,7 +1956,7 @@ void Foam::extendedEdgeMesh::writeObj(const fileName& prefix) const
for (label i = externalStart_; i < internalStart_; i++)
{
const edge& e = edges()[i];
externalStr.write(linePointRef(points()[e[0]], points()[e[1]]));
externalStr.write(e, points());
}
}
@ -1972,7 +1968,7 @@ void Foam::extendedEdgeMesh::writeObj(const fileName& prefix) const
for (label i = internalStart_; i < flatStart_; i++)
{
const edge& e = edges()[i];
internalStr.write(linePointRef(points()[e[0]], points()[e[1]]));
internalStr.write(e, points());
}
}
@ -1984,7 +1980,7 @@ void Foam::extendedEdgeMesh::writeObj(const fileName& prefix) const
for (label i = flatStart_; i < openStart_; i++)
{
const edge& e = edges()[i];
flatStr.write(linePointRef(points()[e[0]], points()[e[1]]));
flatStr.write(e, points());
}
}
@ -1996,7 +1992,7 @@ void Foam::extendedEdgeMesh::writeObj(const fileName& prefix) const
for (label i = openStart_; i < multipleStart_; i++)
{
const edge& e = edges()[i];
openStr.write(linePointRef(points()[e[0]], points()[e[1]]));
openStr.write(e, points());
}
}
@ -2008,7 +2004,7 @@ void Foam::extendedEdgeMesh::writeObj(const fileName& prefix) const
for (label i = multipleStart_; i < edges().size(); i++)
{
const edge& e = edges()[i];
multipleStr.write(linePointRef(points()[e[0]], points()[e[1]]));
multipleStr.write(e, points());
}
}
@ -2017,10 +2013,10 @@ void Foam::extendedEdgeMesh::writeObj(const fileName& prefix) const
Info<< "Writing " << regionEdges_.size()
<< " region edges to " << regionStr.name() << endl;
forAll(regionEdges_, i)
for (const label edgei : regionEdges_)
{
const edge& e = edges()[regionEdges_[i]];
regionStr.write(linePointRef(points()[e[0]], points()[e[1]]));
const edge& e = edges()[edgei];
regionStr.write(e, points());
}
}
@ -2034,9 +2030,10 @@ void Foam::extendedEdgeMesh::writeObj(const fileName& prefix) const
const vector& eVec = edgeDirections_[i];
const edge& e = edges()[i];
edgeDirsStr.write
edgeDirsStr.writeLine
(
linePointRef(points()[e.start()], eVec + points()[e.start()])
points()[e.start()],
points()[e.start()] + eVec
);
}
}

View File

@ -35,36 +35,36 @@ License
namespace Foam
{
defineTypeNameAndDebug(edgeSurface, 0);
// file-scope
// Write points in obj format
static void writeObjPoints(const UList<point>& pts, Ostream& os)
{
forAll(pts, i)
{
const point& pt = pts[i];
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
}
}
} // End namespace Foam
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
// Write whole pointField and selected edges to stream
void writeObjEdges
static void writeObjEdges
(
const UList<point>& points,
const edgeList& edges,
const labelList& edgeLabels,
const labelUList& edgeLabels,
Ostream& os
)
{
writeObjPoints(points, os);
forAll(edgeLabels, i)
for (const point& p : points)
{
const edge& e = edges[edgeLabels[i]];
os << "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
}
os << "l " << e.start()+1 << ' ' << e.end()+1 << endl;
for (const label edgei : edgeLabels)
{
const edge& e = edges[edgei];
os << "l " << e.start()+1 << ' ' << e.end()+1 << nl;
}
}

View File

@ -195,8 +195,8 @@ void Foam::pointToPointPlanarInterpolation::calcWeights
forAll(destPoints, i)
{
label v0 = nearestVertex_[i][0];
str.write(linePointRef(destPoints[i], sourcePoints[v0]));
const label v0 = nearestVertex_[i][0];
str.writeLine(destPoints[i], sourcePoints[v0]);
}
}
}
@ -245,10 +245,7 @@ void Foam::pointToPointPlanarInterpolation::calcWeights
Pout<< "pointToPointPlanarInterpolation::calcWeights :"
<< " Dumping face centres to " << str.name() << endl;
forAll(localFaceCentres, i)
{
str.write(localFaceCentres[i]);
}
str.write(localFaceCentres);
}
// Determine interpolation onto face centres.
@ -275,9 +272,9 @@ void Foam::pointToPointPlanarInterpolation::calcWeights
forAll(destPoints, i)
{
label v0 = nearestVertex_[i][0];
label v1 = nearestVertex_[i][1];
label v2 = nearestVertex_[i][2];
const label v0 = nearestVertex_[i][0];
const label v1 = nearestVertex_[i][1];
const label v2 = nearestVertex_[i][2];
Pout<< "For location " << destPoints[i]
<< " 2d:" << localFaceCentres[i]
@ -286,21 +283,21 @@ void Foam::pointToPointPlanarInterpolation::calcWeights
<< " at:" << sourcePoints[v0]
<< " weight:" << nearestVertexWeight_[i][0] << nl;
str.write(linePointRef(destPoints[i], sourcePoints[v0]));
str.writeLine(destPoints[i], sourcePoints[v0]);
if (v1 != -1)
{
Pout<< " " << v1
<< " at:" << sourcePoints[v1]
<< " weight:" << nearestVertexWeight_[i][1] << nl;
str.write(linePointRef(destPoints[i], sourcePoints[v1]));
str.writeLine(destPoints[i], sourcePoints[v1]);
}
if (v2 != -1)
{
Pout<< " " << v2
<< " at:" << sourcePoints[v2]
<< " weight:" << nearestVertexWeight_[i][2] << nl;
str.write(linePointRef(destPoints[i], sourcePoints[v2]));
str.writeLine(destPoints[i], sourcePoints[v2]);
}
Pout<< endl;

View File

@ -1251,7 +1251,7 @@ bool Foam::cellCellStencils::cellVolumeWeight::update()
const point& donorCc = cc[slots[i]];
const point& accCc = mesh_.cellCentres()[cellI];
str.write(linePointRef(accCc, 0.1*accCc+0.9*donorCc));
str.writeLine(accCc, 0.1*accCc+0.9*donorCc);
}
}
}

View File

@ -2168,7 +2168,7 @@ bool Foam::cellCellStencils::inverseDistance::update()
forAll(slots, i)
{
const point& donorCc = cc[slots[i]];
str.write(linePointRef(accCc, 0.1*accCc+0.9*donorCc));
str.writeLine(accCc, 0.1*accCc+0.9*donorCc);
}
}
}
@ -2264,7 +2264,7 @@ bool Foam::cellCellStencils::inverseDistance::update()
forAll(slots, i)
{
const point& donorCc = cc[slots[i]];
str.write(linePointRef(accCc, 0.1*accCc+0.9*donorCc));
str.writeLine(accCc, 0.1*accCc+0.9*donorCc);
}
}
}

View File

@ -1000,7 +1000,7 @@ bool Foam::cellCellStencils::trackingInverseDistance::update()
forAll(slots, i)
{
const point& donorCc = cc[slots[i]];
str.write(linePointRef(accCc, 0.1*accCc+0.9*donorCc));
str.writeLine(accCc, 0.1*accCc+0.9*donorCc);
}
}
}
@ -1065,7 +1065,7 @@ bool Foam::cellCellStencils::trackingInverseDistance::update()
forAll(slots, i)
{
const point& donorCc = cc[slots[i]];
str.write(linePointRef(accCc, 0.1*accCc+0.9*donorCc));
str.writeLine(accCc, 0.1*accCc+0.9*donorCc);
}
}
}

View File

@ -171,7 +171,7 @@ void Foam::voxelMeshSearch::writeGrid
{
point p1(bb.min()+point((i-1)*s[0], j*s[1], k*s[2]));
point p2(bb.min()+point(i*s[0], j*s[1], k*s[2]));
os.write(linePointRef(p1, p2));
os.writeLine(p1, p2);
}
}
}
@ -183,7 +183,7 @@ void Foam::voxelMeshSearch::writeGrid
{
point p1(bb.min()+point(i*s[0], (j-1)*s[1], k*s[2]));
point p2(bb.min()+point(i*s[0], j*s[1], k*s[2]));
os.write(linePointRef(p1, p2));
os.writeLine(p1, p2);
}
}
}
@ -195,7 +195,7 @@ void Foam::voxelMeshSearch::writeGrid
{
point p1(bb.min()+point(i*s[0], j*s[1], (k-1)*s[2]));
point p2(bb.min()+point(i*s[0], j*s[1], k*s[2]));
os.write(linePointRef(p1, p2));
os.writeLine(p1, p2);
}
}
}

View File

@ -45,11 +45,11 @@ SourceFiles
namespace Foam
{
// Forward declaration of friend functions and operators
// Forward Declarations
class polyMesh;
class fvMesh;
class OBJstream;
class IOobject;
class fvMesh;
/*---------------------------------------------------------------------------*\
Class voxelMeshSearch Declaration
@ -57,7 +57,7 @@ class fvMesh;
class voxelMeshSearch
{
// Private data
// Private Data
const polyMesh& mesh_;

View File

@ -4979,13 +4979,10 @@ void Foam::distributedTriSurfaceMesh::distribute
/searchableSurface::name() + "_after.obj"
);
Info<< "Writing local bounding box to " << str.name() << endl;
const List<treeBoundBox>& myBbs = procBb_[Pstream::myProcNo()];
for (const treeBoundBox& bb : myBbs)
{
pointField pts(bb.points());
for (const edge& e : treeBoundBox::edges)
for (const treeBoundBox& bb : procBb_[Pstream::myProcNo()])
{
str.write(linePointRef(pts[e[0]], pts[e[1]]));
str.write(bb, true); // lines
}
}
}
@ -5001,11 +4998,7 @@ void Foam::distributedTriSurfaceMesh::distribute
{
for (const treeBoundBox& bb : myBbs)
{
pointField pts(bb.points());
for (const edge& e : treeBoundBox::edges)
{
str.write(linePointRef(pts[e[0]], pts[e[1]]));
}
str.write(bb, true); // lines
}
}
}

View File

@ -189,12 +189,12 @@ bool Foam::patchDistMethods::exact::correct
if (debug)
{
OBJstream str(mesh_.time().timePath()/"wallPoint.obj");
Info<< type() << ": dumping nearest wall point to " << str.name()
<< endl;
forAll(mesh_.cellCentres(), cellI)
Info<< type() << ": dumping nearest wall point to "
<< str.name() << endl;
forAll(mesh_.cellCentres(), celli)
{
const point& cc = mesh_.cellCentres()[cellI];
str.write(linePointRef(cc, info[cellI].hitPoint()));
const point& cc = mesh_.cellCentres()[celli];
str.writeLine(cc, info[celli].hitPoint());
}
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1064,10 +1064,7 @@ void Foam::shortestPathSet::genSamples
/"isLeakCell" + Foam::name(iter) + ".obj"
);
Pout<< "Writing new isLeakCell to " << str.name() << endl;
forAll(leakCcs, i)
{
str.write(leakCcs[i]);
}
str.write(leakCcs);
}
if (debug & 2)
{
@ -1090,13 +1087,10 @@ void Foam::shortestPathSet::genSamples
<< " distance:" << samplingCurveDist[samplei]
<< endl;
str.write
(
linePointRef
str.writeLine
(
samplingPts[samplei-1],
samplingPts[samplei]
)
);
}
}
@ -1121,9 +1115,9 @@ void Foam::shortestPathSet::genSamples
fm,
dimensionedScalar(dimless, Zero)
);
forAll(isLeakCell, celli)
for (const label celli : isLeakCell)
{
fld[celli] = isLeakCell[celli];
fld[celli] = scalar(1);
}
fld.correctBoundaryConditions();
fld.write();
@ -1193,8 +1187,8 @@ void Foam::shortestPathSet::genSamples
{
str.write(mesh.points()[pointi]);
}
Pout<< "Writing " << str.nVertices() << " points to " << str.name()
<< endl;
Pout<< "Writing " << str.nVertices()
<< " points to " << str.name() << endl;
}
}
@ -1266,8 +1260,8 @@ void Foam::shortestPathSet::genSamples
mkDir(mesh.time().timePath());
OBJstream str(mesh.time().timePath()/"isLeakFace.obj");
str.write(leakFaces, mesh.points(), false);
Pout<< "Writing " << leakFaces.size() << " faces to " << str.name()
<< endl;
Pout<< "Writing " << leakFaces.size()
<< " faces to " << str.name() << endl;
}

View File

@ -54,9 +54,9 @@ void Foam::faceShading::writeRays
Pout<< "Dumping rays to " << os.name() << endl;
forAll(myFc, faceI)
forAll(myFc, facei)
{
os.write(linePointRef(myFc[faceI], endCf[faceI]));
os.writeLine(myFc[facei], endCf[facei]);
}
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2020,2022 OpenCFD Ltd
Copyright (C) 2016-2022 OpenCFD Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -115,17 +115,10 @@ bool Foam::dynamicMotionSolverTopoFvMesh::update()
if (debug)
{
OBJstream osOld("oldPts_" + time().timeName() + ".obj");
const pointField& oldPts = oldPoints();
forAll(oldPts, i)
{
osOld.write(oldPts[i]);
}
osOld.write(oldPoints());
OBJstream osNew("newPts_" + time().timeName() + ".obj");
forAll(points(), i)
{
osNew.write(points()[i]);
}
osNew.write(points());
}
}
else

View File

@ -695,20 +695,15 @@ void Foam::isoAdvection::writeIsoFaces
Info<< nl << "isoAdvection: writing iso faces to file: "
<< os.name() << nl << endl;
face f;
forAll(allProcFaces, proci)
for
(
const DynamicList<List<point>>& procFacePts
: allProcFaces
)
{
const DynamicList<List<point>>& procFacePts =
allProcFaces[proci];
for (const List<point>& facePts : procFacePts)
{
if (facePts.size() != f.size())
{
f = face(identity(facePts.size()));
}
os.write(f, facePts, false);
os.writeFace(facePts, false);
}
}
}
@ -720,15 +715,9 @@ void Foam::isoAdvection::writeIsoFaces
Info<< nl << "isoAdvection: writing iso faces to file: "
<< os.name() << nl << endl;
face f;
for (const List<point>& facePts : faces)
{
if (facePts.size() != f.size())
{
f = face(identity(facePts.size()));
}
os.write(f, facePts, false);
os.writeFace(facePts, false);
}
}
}