mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: meshTools output for treeBoundBox, points.
ENH: OBJstream output for treeBoundBox
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,6 +26,7 @@ License
|
||||
#include "meshTools.H"
|
||||
#include "polyMesh.H"
|
||||
#include "hexMatcher.H"
|
||||
#include "treeBoundBox.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -209,16 +210,31 @@ void Foam::meshTools::writeOBJ
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshTools::writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const UList<point>& pts
|
||||
)
|
||||
{
|
||||
forAll(pts, i)
|
||||
{
|
||||
const point& pt = pts[i];
|
||||
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshTools::writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const triad& t,
|
||||
const point& pt
|
||||
const point& origin
|
||||
)
|
||||
{
|
||||
forAll(t, dirI)
|
||||
{
|
||||
writeOBJ(os, pt, pt + t[dirI]);
|
||||
writeOBJ(os, origin, origin + t[dirI]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,10 +247,9 @@ void Foam::meshTools::writeOBJ
|
||||
label& count
|
||||
)
|
||||
{
|
||||
os << "v" << ' ' << p1.x() << ' ' << p1.y() << ' ' << p1.z() << endl;
|
||||
os << "v" << ' ' << p2.x() << ' ' << p2.y() << ' ' << p2.z() << endl;
|
||||
|
||||
os << "l" << " " << (count + 1) << " " << (count + 2) << endl;
|
||||
os << "v " << p1.x() << ' ' << p1.y() << ' ' << p1.z() << nl;
|
||||
os << "v " << p2.x() << ' ' << p2.y() << ' ' << p2.z() << nl;
|
||||
os << "l " << (count + 1) << " " << (count + 2) << endl;
|
||||
|
||||
count += 2;
|
||||
}
|
||||
@ -247,12 +262,28 @@ void Foam::meshTools::writeOBJ
|
||||
const point& p2
|
||||
)
|
||||
{
|
||||
os << "v" << ' ' << p1.x() << ' ' << p1.y() << ' ' << p1.z() << endl;
|
||||
os << "v " << p1.x() << ' ' << p1.y() << ' ' << p1.z() << nl;
|
||||
os << "vn "
|
||||
<< (p2.x() - p1.x()) << ' '
|
||||
<< (p2.y() - p1.y()) << ' '
|
||||
<< (p2.z() - p1.z()) << endl;
|
||||
}
|
||||
|
||||
os << "vn"
|
||||
<< ' ' << p2.x() - p1.x()
|
||||
<< ' ' << p2.y() - p1.y()
|
||||
<< ' ' << p2.z() - p1.z() << endl;
|
||||
|
||||
void Foam::meshTools::writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const treeBoundBox& bb
|
||||
)
|
||||
{
|
||||
writeOBJ(os, bb.points());
|
||||
|
||||
forAll(treeBoundBox::edges, edgei)
|
||||
{
|
||||
const edge& e = treeBoundBox::edges[edgei];
|
||||
|
||||
os << "l " << (e[0] + 1) << ' ' << (e[1] + 1) << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -261,7 +292,7 @@ void Foam::meshTools::writeOBJ
|
||||
Ostream& os,
|
||||
const cellList& cells,
|
||||
const faceList& faces,
|
||||
const pointField& points,
|
||||
const UList<point>& points,
|
||||
const labelList& cellLabels
|
||||
)
|
||||
{
|
||||
@ -342,7 +373,7 @@ Foam::label Foam::meshTools::findEdge
|
||||
{
|
||||
forAll(candidates, i)
|
||||
{
|
||||
label edgeI = candidates[i];
|
||||
const label edgeI = candidates[i];
|
||||
|
||||
const edge& e = edges[edgeI];
|
||||
|
||||
|
||||
@ -49,8 +49,9 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class primitiveMesh;
|
||||
class polyMesh;
|
||||
class primitiveMesh;
|
||||
class treeBoundBox;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Namespace meshTools Declaration
|
||||
@ -101,23 +102,30 @@ namespace meshTools
|
||||
|
||||
// OBJ writing
|
||||
|
||||
//- Write obj representation of point
|
||||
//- Write obj representation of a point
|
||||
void writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const point& pt
|
||||
);
|
||||
|
||||
//- Write obj representation of a triad. Requires the location of the
|
||||
//- Write obj representation of points
|
||||
void writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const UList<point>& pts
|
||||
);
|
||||
|
||||
//- Write obj representation of a triad. Requires the origin of the
|
||||
// triad to be supplied
|
||||
void writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const triad& t,
|
||||
const point& pt
|
||||
const point& origin
|
||||
);
|
||||
|
||||
//- Write obj representation of a line connecting two points
|
||||
//- Write obj representation of a line connecting two points.
|
||||
// Need to keep track of points that have been added. count starts at 0
|
||||
void writeOBJ
|
||||
(
|
||||
@ -135,13 +143,20 @@ namespace meshTools
|
||||
const point& p2
|
||||
);
|
||||
|
||||
//- Write obj representation of tree-bounding box as a series of lines
|
||||
void writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const treeBoundBox& bb
|
||||
);
|
||||
|
||||
//- Write obj representation of faces subset
|
||||
template<class FaceType>
|
||||
void writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const UList<FaceType>&,
|
||||
const pointField&,
|
||||
const UList<FaceType>& faces,
|
||||
const UList<point>& points,
|
||||
const labelList& faceLabels
|
||||
);
|
||||
|
||||
@ -150,17 +165,17 @@ namespace meshTools
|
||||
void writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const UList<FaceType>&,
|
||||
const pointField&
|
||||
const UList<FaceType>& faces,
|
||||
const UList<point>& points
|
||||
);
|
||||
|
||||
//- Write obj representation of cell subset
|
||||
void writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const cellList&,
|
||||
const faceList&,
|
||||
const pointField&,
|
||||
const cellList& cells,
|
||||
const faceList& faces,
|
||||
const UList<point>& points,
|
||||
const labelList& cellLabels
|
||||
);
|
||||
|
||||
@ -170,7 +185,7 @@ namespace meshTools
|
||||
//- Is edge used by cell
|
||||
bool edgeOnCell
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const primitiveMesh& mesh,
|
||||
const label celli,
|
||||
const label edgeI
|
||||
);
|
||||
@ -178,7 +193,7 @@ namespace meshTools
|
||||
//- Is edge used by face
|
||||
bool edgeOnFace
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const primitiveMesh& mesh,
|
||||
const label facei,
|
||||
const label edgeI
|
||||
);
|
||||
@ -186,7 +201,7 @@ namespace meshTools
|
||||
//- Is face used by cell
|
||||
bool faceOnCell
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const primitiveMesh& mesh,
|
||||
const label celli,
|
||||
const label facei
|
||||
);
|
||||
@ -203,7 +218,7 @@ namespace meshTools
|
||||
//- Return edge between two mesh vertices. Returns -1 if no edge.
|
||||
label findEdge
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const primitiveMesh& mesh,
|
||||
const label v0,
|
||||
const label v1
|
||||
);
|
||||
@ -211,7 +226,7 @@ namespace meshTools
|
||||
//- Return edge shared by two faces. Throws error if no edge found.
|
||||
label getSharedEdge
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const primitiveMesh& mesh,
|
||||
const label f0,
|
||||
const label f1
|
||||
);
|
||||
@ -219,7 +234,7 @@ namespace meshTools
|
||||
//- Return face shared by two cells. Throws error if none found.
|
||||
label getSharedFace
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const primitiveMesh& mesh,
|
||||
const label cell0,
|
||||
const label cell1
|
||||
);
|
||||
@ -227,7 +242,7 @@ namespace meshTools
|
||||
//- Get faces on cell using edgeI. Throws error if no two found.
|
||||
void getEdgeFaces
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const primitiveMesh& mesh,
|
||||
const label celli,
|
||||
const label edgeI,
|
||||
label& face0,
|
||||
@ -238,17 +253,17 @@ namespace meshTools
|
||||
// connected to vertex but not edgeI. Throws error if none found.
|
||||
label otherEdge
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const primitiveMesh& mesh,
|
||||
const labelList& edgeLabels,
|
||||
const label edgeI,
|
||||
const label vertI
|
||||
const label thisEdgeI,
|
||||
const label thisVertI
|
||||
);
|
||||
|
||||
//- Return face on cell using edgeI but not facei. Throws error
|
||||
// if none found.
|
||||
label otherFace
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const primitiveMesh& mesh,
|
||||
const label celli,
|
||||
const label facei,
|
||||
const label edgeI
|
||||
@ -258,7 +273,7 @@ namespace meshTools
|
||||
// if face not internal.
|
||||
label otherCell
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const primitiveMesh& mesh,
|
||||
const label celli,
|
||||
const label facei
|
||||
);
|
||||
@ -267,7 +282,7 @@ namespace meshTools
|
||||
// of startVertI)
|
||||
label walkFace
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const primitiveMesh& mesh,
|
||||
const label facei,
|
||||
const label startEdgeI,
|
||||
const label startVertI,
|
||||
@ -309,19 +324,19 @@ namespace meshTools
|
||||
//- Given edge on hex find other 'parallel', non-connected edges.
|
||||
void getParallelEdges
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const primitiveMesh& mesh,
|
||||
const label celli,
|
||||
const label e0,
|
||||
label&,
|
||||
label&,
|
||||
label&
|
||||
label& e1,
|
||||
label& e2,
|
||||
label& e3
|
||||
);
|
||||
|
||||
//- Given edge on hex find all 'parallel' (i.e. non-connected)
|
||||
// edges and average direction of them
|
||||
vector edgeToCutDir
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const primitiveMesh& mesh,
|
||||
const label celli,
|
||||
const label edgeI
|
||||
);
|
||||
@ -330,7 +345,7 @@ namespace meshTools
|
||||
// return one of them.
|
||||
label cutDirToEdge
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const primitiveMesh& mesh,
|
||||
const label celli,
|
||||
const vector& cutDir
|
||||
);
|
||||
|
||||
@ -28,7 +28,7 @@ void Foam::meshTools::writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const UList<FaceType>& faces,
|
||||
const pointField& points,
|
||||
const UList<point>& points,
|
||||
const labelList& faceLabels
|
||||
)
|
||||
{
|
||||
@ -64,7 +64,7 @@ void Foam::meshTools::writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const UList<FaceType>& faces,
|
||||
const pointField& points
|
||||
const UList<point>& points
|
||||
)
|
||||
{
|
||||
labelList allFaces(faces.size());
|
||||
|
||||
Reference in New Issue
Block a user