mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'surface-declutter' into 'develop'
Surface declutter - issue #294 Removing various clutter from surfMesh and triSurface - unused classes/files (backup copies on non-release repo) - relocate some triSurface-related classes to where they make more sense, and where they can be reused. - improve handling of various face types in MeshedSurface and UnsortedMeshedSurface (to bridge the gap to triSurface) - improve transfer methods for reclaiming/reusing surface allocations See merge request !77
This commit is contained in:
3
applications/test/faces/Make/files
Normal file
3
applications/test/faces/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-faces.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-faces
|
||||
0
applications/test/faces/Make/options
Normal file
0
applications/test/faces/Make/options
Normal file
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,47 +21,64 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::hashSignedLabel
|
||||
Application
|
||||
Test-faces
|
||||
|
||||
Description
|
||||
hash for signed integers (Hash\<label\> only works for unsigned ints)
|
||||
Simple tests for various faces
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef HashSignedLabel_H
|
||||
#define HashSignedLabel_H
|
||||
#include "argList.H"
|
||||
#include "labelledTri.H"
|
||||
|
||||
#include "List.H"
|
||||
#include "word.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class hashSignedLabel Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class hashSignedLabel
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
hashSignedLabel()
|
||||
{}
|
||||
|
||||
|
||||
label operator()(const label key, const label tableSize) const
|
||||
{
|
||||
return mag(key)%tableSize;
|
||||
}
|
||||
};
|
||||
|
||||
} // End namespace Foam
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
face f1{ 1, 2, 3, 4 };
|
||||
Info<< "face:" << f1 << nl;
|
||||
|
||||
triFace t1{ 1, 2, 3 };
|
||||
Info<< "triFace:" << t1 << nl;
|
||||
|
||||
f1 = t1;
|
||||
Info<< "face:" << f1 << nl;
|
||||
|
||||
f1 = t1.triFaceFace();
|
||||
Info<< "face:" << f1 << nl;
|
||||
|
||||
// expect these to fail
|
||||
FatalError.throwExceptions();
|
||||
try
|
||||
{
|
||||
labelledTri l1{ 1, 2, 3, 10, 24 };
|
||||
Info<< "labelled:" << l1 << nl;
|
||||
}
|
||||
catch (Foam::error& err)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Caught FatalError " << err << nl << endl;
|
||||
}
|
||||
FatalError.dontThrowExceptions();
|
||||
|
||||
labelledTri l2{ 1, 2, 3 };
|
||||
Info<< "labelled:" << l2 << nl;
|
||||
|
||||
labelledTri l3{ 1, 2, 3, 10 };
|
||||
Info<< "labelled:" << l3 << nl;
|
||||
|
||||
t1.flip();
|
||||
l3.flip();
|
||||
|
||||
Info<< "flip:" << t1 << nl;
|
||||
Info<< "flip:" << l3 << nl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -41,6 +41,9 @@ Usage
|
||||
- \par -orient
|
||||
Check face orientation on the input surface
|
||||
|
||||
- \par -testModify
|
||||
Test modification mechanism
|
||||
|
||||
- \par -scale \<scale\>
|
||||
Specify a scaling factor for writing the files
|
||||
|
||||
@ -65,6 +68,7 @@ Note
|
||||
#include "PackedBoolList.H"
|
||||
|
||||
#include "MeshedSurfaces.H"
|
||||
#include "ModifiableMeshedSurface.H"
|
||||
#include "UnsortedMeshedSurfaces.H"
|
||||
|
||||
#include "IStringStream.H"
|
||||
@ -93,6 +97,13 @@ int main(int argc, char *argv[])
|
||||
"orient",
|
||||
"check surface orientation"
|
||||
);
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"testModify",
|
||||
"Test modification mechanism (MeshedSurface)"
|
||||
);
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"surfMesh",
|
||||
@ -389,6 +400,34 @@ int main(int argc, char *argv[])
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (args.optionFound("testModify"))
|
||||
{
|
||||
Info<< "Use ModifiableMeshedSurface to shift (1, 0, 0)" << endl;
|
||||
Info<< "original" << nl;
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
|
||||
ModifiableMeshedSurface<face> tsurf(surf.xfer());
|
||||
// ModifiableMeshedSurface<face> tsurf;
|
||||
// tsurf.reset(surf.xfer());
|
||||
|
||||
Info<< "in-progress" << nl;
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
|
||||
tsurf.storedPoints() += vector(1, 0, 0);
|
||||
|
||||
surf.transfer(tsurf);
|
||||
|
||||
Info<< "updated" << nl;
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
|
||||
Info<< "modifier" << nl;
|
||||
tsurf.writeStats(Info);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
Info<< "writing " << exportName;
|
||||
if (scaleFactor <= 0)
|
||||
{
|
||||
|
||||
@ -794,7 +794,6 @@ DebugSwitches
|
||||
surfaceIntersection 0;
|
||||
surfaceNormalFixedValue 0;
|
||||
surfacePatch 0;
|
||||
surfacePatchIOList 0;
|
||||
surfaceScalarField 0;
|
||||
surfaceScalarField::Internal 0;
|
||||
surfaceSlipDisplacement 0;
|
||||
|
||||
@ -418,6 +418,7 @@ $(cellShape)/cellShapeIOList.C
|
||||
|
||||
meshes/Identifiers/patch/patchIdentifier.C
|
||||
meshes/Identifiers/patch/coupleGroupIdentifier.C
|
||||
meshes/Identifiers/surface/surfZoneIdentifier.C
|
||||
|
||||
meshes/MeshObject/meshObject.C
|
||||
|
||||
|
||||
@ -97,14 +97,11 @@ Foam::surfZoneIdentifier::~surfZoneIdentifier()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
void Foam::surfZoneIdentifier::write(Ostream& os) const
|
||||
{
|
||||
if (geometricType_.size())
|
||||
{
|
||||
os.writeKeyword("geometricType")
|
||||
<< geometricType_
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeEntry("geometricType", geometricType_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +109,6 @@ void Foam::surfZoneIdentifier::write(Ostream& os) const
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
// needed for list output
|
||||
|
||||
bool Foam::surfZoneIdentifier::operator!=
|
||||
(
|
||||
const surfZoneIdentifier& rhs
|
||||
@ -129,8 +125,9 @@ bool Foam::surfZoneIdentifier::operator==
|
||||
{
|
||||
return
|
||||
(
|
||||
name() == rhs.name()
|
||||
&& geometricType() == rhs.geometricType()
|
||||
(index() == rhs.index())
|
||||
&& (name() == rhs.name())
|
||||
&& (geometricType() == rhs.geometricType())
|
||||
);
|
||||
}
|
||||
|
||||
@ -139,8 +136,7 @@ bool Foam::surfZoneIdentifier::operator==
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& obj)
|
||||
{
|
||||
is >> obj.name_
|
||||
>> obj.geometricType_;
|
||||
is >> obj.name_ >> obj.geometricType_;
|
||||
|
||||
return is;
|
||||
}
|
||||
@ -148,7 +144,8 @@ Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& obj)
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIdentifier& obj)
|
||||
{
|
||||
os << obj.name_ << ' ' << obj.geometricType_;
|
||||
// newlines to separate, since that is what triSurface currently expects
|
||||
os << nl << obj.name_ << nl << obj.geometricType_;
|
||||
|
||||
os.check("Ostream& operator<<(Ostream&, const surfZoneIdentifier&)");
|
||||
return os;
|
||||
@ -40,7 +40,6 @@ SourceFiles
|
||||
|
||||
#include "word.H"
|
||||
#include "label.H"
|
||||
#include "typeInfo.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -56,7 +55,7 @@ Istream& operator>>(Istream&, surfZoneIdentifier&);
|
||||
Ostream& operator<<(Ostream&, const surfZoneIdentifier&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfZoneIdentifier Declaration
|
||||
Class surfZoneIdentifier Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfZoneIdentifier
|
||||
@ -155,8 +155,8 @@ public:
|
||||
//- Construct from list of labels
|
||||
explicit inline face(const labelUList&);
|
||||
|
||||
//- Construct from list of labels
|
||||
explicit inline face(const labelList&);
|
||||
//- Construct from an initializer list of labels
|
||||
explicit inline face(std::initializer_list<label>);
|
||||
|
||||
//- Construct by transferring the parameter contents
|
||||
explicit inline face(const Xfer<labelList>&);
|
||||
|
||||
@ -57,7 +57,7 @@ inline Foam::face::face(const labelUList& lst)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::face::face(const labelList& lst)
|
||||
inline Foam::face::face(std::initializer_list<label> lst)
|
||||
:
|
||||
labelList(lst)
|
||||
{}
|
||||
@ -79,7 +79,7 @@ inline Foam::face::face(Istream& is)
|
||||
|
||||
inline Foam::pointField Foam::face::points(const pointField& meshPoints) const
|
||||
{
|
||||
// There are as many points as there labels for them
|
||||
// There are as many points as there are labels for them
|
||||
pointField p(size());
|
||||
|
||||
// For each point in list, set it to the point in 'pnts' addressed
|
||||
|
||||
@ -43,8 +43,6 @@ namespace Foam
|
||||
typedef List<face> faceList;
|
||||
typedef SubList<face> faceSubList;
|
||||
typedef List<faceList> faceListList;
|
||||
// same as faceUList:
|
||||
typedef UList<face> unallocFaceList;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -64,29 +64,44 @@ class labelledTri
|
||||
label region_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Assign from a list of 3 or 4 labels.
|
||||
// Default region is 0.
|
||||
inline void assign(const labelUList&);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
//- Construct null with invalid point labels and region (-1).
|
||||
inline labelledTri();
|
||||
|
||||
//- Construct from triFace and a region label
|
||||
//- Construct from triFace and region label.
|
||||
// Default region is 0 if not specified.
|
||||
inline labelledTri
|
||||
(
|
||||
const triFace&,
|
||||
const label region
|
||||
const label region = 0
|
||||
);
|
||||
|
||||
//- Construct from three point labels and a region label
|
||||
//- Construct from three point labels and a region label.
|
||||
// Default region is 0 if not specified.
|
||||
inline labelledTri
|
||||
(
|
||||
const label a,
|
||||
const label b,
|
||||
const label c,
|
||||
const label region
|
||||
const label region = 0
|
||||
);
|
||||
|
||||
//- Construct from a list of 3 or 4 labels.
|
||||
// Default region is 0.
|
||||
explicit inline labelledTri(const labelUList&);
|
||||
|
||||
//- Construct from an initializer list of 3 or 4 labels.
|
||||
explicit inline labelledTri(std::initializer_list<label>);
|
||||
|
||||
//- Construct from Istream
|
||||
inline labelledTri(Istream&);
|
||||
|
||||
@ -102,17 +117,6 @@ public:
|
||||
inline label& region();
|
||||
|
||||
|
||||
// Check
|
||||
|
||||
// Edit
|
||||
|
||||
// Write
|
||||
|
||||
|
||||
// Friend Functions
|
||||
|
||||
// Friend Operators
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
inline friend Istream& operator>>(Istream&, labelledTri&);
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,10 +25,34 @@ License
|
||||
|
||||
#include "IOstreams.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
inline void Foam::labelledTri::assign(const labelUList& lst)
|
||||
{
|
||||
const label sz = lst.size();
|
||||
|
||||
// checkSize
|
||||
if (sz < 3 || sz > 4)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "size " << sz << " != (3 or 4)"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
for (label i=0; i<3; ++i)
|
||||
{
|
||||
operator[](i) = lst[i];
|
||||
}
|
||||
|
||||
region_ = (sz > 3 ? lst[3] : 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::labelledTri::labelledTri()
|
||||
:
|
||||
triFace(),
|
||||
region_(-1)
|
||||
{}
|
||||
|
||||
@ -57,6 +81,24 @@ inline Foam::labelledTri::labelledTri
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::labelledTri::labelledTri(const labelUList& lst)
|
||||
:
|
||||
triFace(),
|
||||
region_(0)
|
||||
{
|
||||
assign(lst);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::labelledTri::labelledTri(std::initializer_list<label> initLst)
|
||||
:
|
||||
triFace(),
|
||||
region_(0)
|
||||
{
|
||||
assign(labelList(initLst));
|
||||
}
|
||||
|
||||
|
||||
inline Foam::labelledTri::labelledTri(Istream& is)
|
||||
{
|
||||
operator>>(is, *this);
|
||||
@ -75,7 +75,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
//- Construct null with invalid point labels (-1)
|
||||
inline triFace();
|
||||
|
||||
//- Construct from three point labels
|
||||
@ -86,9 +86,12 @@ public:
|
||||
const label c
|
||||
);
|
||||
|
||||
//- Construct from a list of labels
|
||||
//- Construct from a list of 3 labels.
|
||||
explicit inline triFace(const labelUList&);
|
||||
|
||||
//- Construct from an initializer list of 3 labels
|
||||
explicit inline triFace(std::initializer_list<label>);
|
||||
|
||||
//- Construct from Istream
|
||||
inline triFace(Istream&);
|
||||
|
||||
|
||||
@ -62,6 +62,8 @@ inline int Foam::triFace::compare(const triFace& a, const triFace& b)
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::triFace::triFace()
|
||||
:
|
||||
FixedList<label, 3>(-1)
|
||||
{}
|
||||
|
||||
|
||||
@ -84,6 +86,12 @@ inline Foam::triFace::triFace(const labelUList& lst)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::triFace::triFace(std::initializer_list<label> lst)
|
||||
:
|
||||
FixedList<label, 3>(lst)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::triFace::triFace(Istream& is)
|
||||
:
|
||||
FixedList<label, 3>(is)
|
||||
|
||||
@ -10,6 +10,9 @@ ensight/type/ensightPTraits.C
|
||||
nas/NASCore.C
|
||||
fire/FIRECore.C
|
||||
starcd/STARCDCore.C
|
||||
stl/STLCore.C
|
||||
stl/STLReader.C
|
||||
stl/STLReaderASCII.L
|
||||
|
||||
vtk/foamVtkCore.C
|
||||
vtk/format/foamVtkAppendBase64Formatter.C
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -23,36 +23,75 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "STLsurfaceFormatCore.H"
|
||||
#include "STLCore.H"
|
||||
#include "gzstream.h"
|
||||
#include "OSspecific.H"
|
||||
#include "Map.H"
|
||||
#include "IFstream.H"
|
||||
#include "Ostream.H"
|
||||
|
||||
#undef DEBUG_STLBINARY
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
//! \cond fileScope
|
||||
|
||||
// check binary by getting the header and number of facets
|
||||
// The number of bytes in the STL binary header
|
||||
static const unsigned STLHeaderSize = 80;
|
||||
|
||||
//! \endcond
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::STLCore::STLCore()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::fileFormats::STLCore::isBinaryName
|
||||
(
|
||||
const fileName& filename,
|
||||
const STLFormat& format
|
||||
)
|
||||
{
|
||||
return (format == DETECT ? (filename.ext() == "stlb") : format == BINARY);
|
||||
}
|
||||
|
||||
|
||||
// Check binary by getting the header and number of facets
|
||||
// this seems to work better than the old token-based method
|
||||
// - some programs (eg, pro-STAR) have 'solid' as the first word in
|
||||
// the binary header.
|
||||
// - using wordToken can cause an abort if non-word (binary) content
|
||||
// is detected ... this is not exactly what we want.
|
||||
int Foam::fileFormats::STLsurfaceFormatCore::detectBINARY
|
||||
int Foam::fileFormats::STLCore::detectBinaryHeader
|
||||
(
|
||||
const fileName& filename
|
||||
)
|
||||
{
|
||||
off_t dataFileSize = Foam::fileSize(filename);
|
||||
bool compressed = false;
|
||||
autoPtr<istream> streamPtr
|
||||
(
|
||||
new ifstream(filename.c_str(), std::ios::binary)
|
||||
);
|
||||
|
||||
IFstream str(filename, IOstream::BINARY);
|
||||
istream& is = str().stdStream();
|
||||
// If the file is compressed, decompress it before further checking.
|
||||
if (!streamPtr->good() && isFile(filename + ".gz", false))
|
||||
{
|
||||
compressed = true;
|
||||
streamPtr.reset(new igzstream((filename + ".gz").c_str()));
|
||||
}
|
||||
istream& is = streamPtr();
|
||||
|
||||
if (!is.good())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot read file " << filename
|
||||
<< " or file " << filename + ".gz"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Read the STL header
|
||||
char header[headerSize];
|
||||
is.read(header, headerSize);
|
||||
char header[STLHeaderSize];
|
||||
is.read(header, STLHeaderSize);
|
||||
|
||||
// Check that stream is OK, if not this may be an ASCII file
|
||||
if (!is.good())
|
||||
@ -60,7 +99,7 @@ int Foam::fileFormats::STLsurfaceFormatCore::detectBINARY
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Read the number of triangles in the STl file
|
||||
// Read the number of triangles in the STL file
|
||||
// (note: read as int so we can check whether >2^31)
|
||||
int nTris;
|
||||
is.read(reinterpret_cast<char*>(&nTris), sizeof(unsigned int));
|
||||
@ -74,33 +113,73 @@ int Foam::fileFormats::STLsurfaceFormatCore::detectBINARY
|
||||
(
|
||||
!is
|
||||
|| nTris < 0
|
||||
|| nTris < (dataFileSize - headerSize)/50
|
||||
|| nTris > (dataFileSize - headerSize)/25
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (!compressed)
|
||||
{
|
||||
const off_t dataFileSize = Foam::fileSize(filename);
|
||||
|
||||
if
|
||||
(
|
||||
nTris < int(dataFileSize - STLHeaderSize)/50
|
||||
|| nTris > int(dataFileSize - STLHeaderSize)/25
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// looks like it might be BINARY, return number of triangles
|
||||
return nTris;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
|
||||
Foam::autoPtr<std::istream>
|
||||
Foam::fileFormats::STLCore::readBinaryHeader
|
||||
(
|
||||
istream& is,
|
||||
const off_t dataFileSize
|
||||
const fileName& filename,
|
||||
label& nTrisEstimated
|
||||
)
|
||||
{
|
||||
sorted_ = true;
|
||||
bool bad = false;
|
||||
bool compressed = false;
|
||||
nTrisEstimated = 0;
|
||||
|
||||
autoPtr<istream> streamPtr
|
||||
(
|
||||
new ifstream(filename.c_str(), std::ios::binary)
|
||||
);
|
||||
|
||||
// If the file is compressed, decompress it before reading.
|
||||
if (!streamPtr->good() && isFile(filename + ".gz", false))
|
||||
{
|
||||
compressed = true;
|
||||
streamPtr.reset(new igzstream((filename + ".gz").c_str()));
|
||||
}
|
||||
istream& is = streamPtr();
|
||||
|
||||
if (!is.good())
|
||||
{
|
||||
streamPtr.clear();
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "Cannot read file " << filename
|
||||
<< " or file " << filename + ".gz"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
// Read the STL header
|
||||
char header[headerSize];
|
||||
is.read(header, headerSize);
|
||||
char header[STLHeaderSize];
|
||||
is.read(header, STLHeaderSize);
|
||||
|
||||
// Check that stream is OK, if not this may be an ASCII file
|
||||
if (!is.good())
|
||||
{
|
||||
streamPtr.clear();
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "problem reading header, perhaps file is not binary "
|
||||
<< exit(FatalError);
|
||||
@ -116,156 +195,56 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
|
||||
//
|
||||
// Also compare the file size with that expected from the number of tris
|
||||
// If the comparison is not sensible then it may be an ASCII file
|
||||
if
|
||||
(
|
||||
!is
|
||||
|| nTris < 0
|
||||
|| nTris < int(dataFileSize - headerSize)/50
|
||||
|| nTris > int(dataFileSize - headerSize)/25
|
||||
)
|
||||
if (!is || nTris < 0)
|
||||
{
|
||||
bad = true;
|
||||
}
|
||||
else if (!compressed)
|
||||
{
|
||||
const off_t dataFileSize = Foam::fileSize(filename);
|
||||
|
||||
if
|
||||
(
|
||||
nTris < int(dataFileSize - STLHeaderSize)/50
|
||||
|| nTris > int(dataFileSize - STLHeaderSize)/25
|
||||
)
|
||||
{
|
||||
bad = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (bad)
|
||||
{
|
||||
streamPtr.clear();
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "problem reading number of triangles, perhaps file is not binary"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_STLBINARY
|
||||
Info<< "# " << nTris << " facets" << endl;
|
||||
label prevZone = -1;
|
||||
#endif
|
||||
|
||||
points_.setSize(3*nTris);
|
||||
zoneIds_.setSize(nTris);
|
||||
|
||||
Map<label> lookup;
|
||||
DynamicList<label> dynSizes;
|
||||
|
||||
label ptI = 0;
|
||||
label zoneI = -1;
|
||||
forAll(zoneIds_, facei)
|
||||
{
|
||||
// Read an STL triangle
|
||||
STLtriangle stlTri(is);
|
||||
|
||||
// transcribe the vertices of the STL triangle -> points
|
||||
points_[ptI++] = stlTri.a();
|
||||
points_[ptI++] = stlTri.b();
|
||||
points_[ptI++] = stlTri.c();
|
||||
|
||||
// interprete stl attribute as a zone
|
||||
const label origId = stlTri.attrib();
|
||||
|
||||
Map<label>::const_iterator fnd = lookup.find(origId);
|
||||
if (fnd != lookup.end())
|
||||
{
|
||||
if (zoneI != fnd())
|
||||
{
|
||||
// group appeared out of order
|
||||
sorted_ = false;
|
||||
}
|
||||
zoneI = fnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
zoneI = dynSizes.size();
|
||||
lookup.insert(origId, zoneI);
|
||||
dynSizes.append(0);
|
||||
}
|
||||
|
||||
zoneIds_[facei] = zoneI;
|
||||
dynSizes[zoneI]++;
|
||||
|
||||
#ifdef DEBUG_STLBINARY
|
||||
if (prevZone != zoneI)
|
||||
{
|
||||
if (prevZone != -1)
|
||||
{
|
||||
Info<< "endsolid zone" << prevZone << nl;
|
||||
}
|
||||
prevZone = zoneI;
|
||||
|
||||
Info<< "solid zone" << prevZone << nl;
|
||||
}
|
||||
|
||||
Info<< " facet normal " << stlTri.normal() << nl
|
||||
<< " outer loop" << nl
|
||||
<< " vertex " << stlTri.a() << nl
|
||||
<< " vertex " << stlTri.b() << nl
|
||||
<< " vertex " << stlTri.c() << nl
|
||||
<< " outer loop" << nl
|
||||
<< " endfacet" << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
names_.clear();
|
||||
sizes_.transfer(dynSizes);
|
||||
|
||||
return true;
|
||||
nTrisEstimated = nTris;
|
||||
return streamPtr;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::STLsurfaceFormatCore::STLsurfaceFormatCore
|
||||
(
|
||||
const fileName& filename
|
||||
)
|
||||
:
|
||||
sorted_(true),
|
||||
points_(0),
|
||||
zoneIds_(0),
|
||||
names_(0),
|
||||
sizes_(0)
|
||||
{
|
||||
off_t dataFileSize = Foam::fileSize(filename);
|
||||
|
||||
// auto-detect ascii/binary
|
||||
if (detectBINARY(filename))
|
||||
{
|
||||
readBINARY
|
||||
(
|
||||
IFstream(filename, IOstream::BINARY)().stdStream(),
|
||||
dataFileSize
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
readASCII
|
||||
(
|
||||
IFstream(filename)().stdStream(),
|
||||
dataFileSize
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::STLsurfaceFormatCore::~STLsurfaceFormatCore()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::STLsurfaceFormatCore::writeHeaderBINARY
|
||||
void Foam::fileFormats::STLCore::writeBinaryHeader
|
||||
(
|
||||
ostream& os,
|
||||
unsigned int nTris
|
||||
)
|
||||
{
|
||||
// STL header with extra information about nTris
|
||||
char header[headerSize];
|
||||
char header[STLHeaderSize];
|
||||
sprintf(header, "STL binary file %u facets", nTris);
|
||||
|
||||
// avoid trailing junk
|
||||
for (size_t i = strlen(header); i < headerSize; ++i)
|
||||
for (size_t i = strlen(header); i < STLHeaderSize; ++i)
|
||||
{
|
||||
header[i] = 0;
|
||||
}
|
||||
|
||||
os.write(header, headerSize);
|
||||
os.write(header, STLHeaderSize);
|
||||
os.write(reinterpret_cast<char*>(&nTris), sizeof(unsigned int));
|
||||
|
||||
}
|
||||
|
||||
|
||||
115
src/fileFormats/stl/STLCore.H
Normal file
115
src/fileFormats/stl/STLCore.H
Normal file
@ -0,0 +1,115 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::fileFormats::STLCore
|
||||
|
||||
Description
|
||||
Core routines used when reading/writing STL files.
|
||||
|
||||
SourceFiles
|
||||
STLCore.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef STLCore_H
|
||||
#define STLCore_H
|
||||
|
||||
#include "STLpoint.H"
|
||||
#include "STLtriangle.H"
|
||||
#include "autoPtr.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fileFormats::STLCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class STLCore
|
||||
{
|
||||
public:
|
||||
|
||||
// Public data types
|
||||
|
||||
//- Enumeration for the format of data in the stream
|
||||
enum STLFormat
|
||||
{
|
||||
ASCII, //!< ASCII
|
||||
BINARY, //!< BINARY
|
||||
DETECT //!< Detect based on (input) content or (output) extension
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Detect 'stlb' extension as binary
|
||||
static bool isBinaryName
|
||||
(
|
||||
const fileName& filename,
|
||||
const STLFormat& format
|
||||
);
|
||||
|
||||
|
||||
//- Check contents to detect if the file is a binary STL.
|
||||
// Return the estimated number of triangles or 0 on error.
|
||||
static int detectBinaryHeader(const fileName&);
|
||||
|
||||
|
||||
//- Read STL binary file header.
|
||||
// Return the opened file stream and estimated number of triangles.
|
||||
// The stream is invalid and number of triangles is 0 on error.
|
||||
static autoPtr<std::istream> readBinaryHeader
|
||||
(
|
||||
const fileName& filename,
|
||||
label& nTrisEstimated
|
||||
);
|
||||
|
||||
//- Write STL binary file and number of triangles to stream
|
||||
static void writeBinaryHeader(ostream&, unsigned int);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
STLCore();
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace fileFormats
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
188
src/fileFormats/stl/STLReader.C
Normal file
188
src/fileFormats/stl/STLReader.C
Normal file
@ -0,0 +1,188 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "STLReader.H"
|
||||
#include "Map.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
#undef DEBUG_STLBINARY
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::fileFormats::STLReader::readBINARY
|
||||
(
|
||||
const fileName& filename
|
||||
)
|
||||
{
|
||||
sorted_ = true;
|
||||
|
||||
label nTris = 0;
|
||||
autoPtr<istream> streamPtr = readBinaryHeader(filename, nTris);
|
||||
|
||||
if (!streamPtr.valid())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Error reading file " << filename
|
||||
<< " or file " << filename + ".gz"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
istream& is = streamPtr();
|
||||
|
||||
#ifdef DEBUG_STLBINARY
|
||||
Info<< "# " << nTris << " facets" << endl;
|
||||
label prevZone = -1;
|
||||
#endif
|
||||
|
||||
points_.setSize(3*nTris);
|
||||
zoneIds_.setSize(nTris);
|
||||
|
||||
Map<label> lookup;
|
||||
DynamicList<label> dynSizes;
|
||||
|
||||
label ptI = 0;
|
||||
label zoneI = -1;
|
||||
forAll(zoneIds_, facei)
|
||||
{
|
||||
// Read STL triangle
|
||||
STLtriangle stlTri(is);
|
||||
|
||||
// transcribe the vertices of the STL triangle -> points
|
||||
points_[ptI++] = stlTri.a();
|
||||
points_[ptI++] = stlTri.b();
|
||||
points_[ptI++] = stlTri.c();
|
||||
|
||||
// interpret STL attribute as a zone
|
||||
const label origId = stlTri.attrib();
|
||||
|
||||
Map<label>::const_iterator fnd = lookup.find(origId);
|
||||
if (fnd != lookup.end())
|
||||
{
|
||||
if (zoneI != fnd())
|
||||
{
|
||||
// group appeared out of order
|
||||
sorted_ = false;
|
||||
}
|
||||
zoneI = fnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
zoneI = dynSizes.size();
|
||||
lookup.insert(origId, zoneI);
|
||||
dynSizes.append(0);
|
||||
}
|
||||
|
||||
zoneIds_[facei] = zoneI;
|
||||
dynSizes[zoneI]++;
|
||||
|
||||
#ifdef DEBUG_STLBINARY
|
||||
if (prevZone != zoneI)
|
||||
{
|
||||
if (prevZone != -1)
|
||||
{
|
||||
Info<< "endsolid zone" << prevZone << nl;
|
||||
}
|
||||
prevZone = zoneI;
|
||||
|
||||
Info<< "solid zone" << prevZone << nl;
|
||||
}
|
||||
|
||||
stlTri.print(Info);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG_STLBINARY
|
||||
if (prevZone != -1)
|
||||
{
|
||||
Info<< "endsolid zone" << prevZone << nl;
|
||||
}
|
||||
#endif
|
||||
|
||||
names_.clear();
|
||||
sizes_.transfer(dynSizes);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fileFormats::STLReader::readFile
|
||||
(
|
||||
const fileName& filename,
|
||||
const STLFormat& format
|
||||
)
|
||||
{
|
||||
if (format == DETECT ? detectBinaryHeader(filename) : format == BINARY)
|
||||
{
|
||||
return readBINARY(filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
return readASCII(filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::STLReader::STLReader
|
||||
(
|
||||
const fileName& filename
|
||||
)
|
||||
:
|
||||
sorted_(true),
|
||||
points_(),
|
||||
zoneIds_(),
|
||||
names_(),
|
||||
sizes_()
|
||||
{
|
||||
// Auto-detect ASCII/BINARY format
|
||||
readFile(filename, STLCore::DETECT);
|
||||
}
|
||||
|
||||
|
||||
Foam::fileFormats::STLReader::STLReader
|
||||
(
|
||||
const fileName& filename,
|
||||
const STLFormat& format
|
||||
)
|
||||
:
|
||||
sorted_(true),
|
||||
points_(),
|
||||
zoneIds_(),
|
||||
names_(),
|
||||
sizes_()
|
||||
{
|
||||
// Manually specified ASCII/BINARY format
|
||||
readFile(filename, format);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::STLReader::~STLReader()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -22,22 +22,22 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::fileFormats::STLsurfaceFormatCore
|
||||
Foam::fileFormats::STLReader
|
||||
|
||||
Description
|
||||
Internal class used by the STLsurfaceFormat
|
||||
|
||||
SourceFiles
|
||||
STLsurfaceFormatCore.C
|
||||
STLReader.C
|
||||
STLsurfaceFormatASCII.L
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef STLsurfaceFormatCore_H
|
||||
#define STLsurfaceFormatCore_H
|
||||
#ifndef STLReader_H
|
||||
#define STLReader_H
|
||||
|
||||
#include "STLtriangle.H"
|
||||
#include "triFace.H"
|
||||
#include "STLCore.H"
|
||||
#include "labelledTri.H"
|
||||
#include "IFstream.H"
|
||||
#include "Ostream.H"
|
||||
|
||||
@ -49,10 +49,12 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class STLsurfaceFormatCore Declaration
|
||||
Class fileFormats::STLReader Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class STLsurfaceFormatCore
|
||||
class STLReader
|
||||
:
|
||||
public STLCore
|
||||
{
|
||||
// Private Data
|
||||
|
||||
@ -73,44 +75,37 @@ class STLsurfaceFormatCore
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
STLsurfaceFormatCore(const STLsurfaceFormatCore&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const STLsurfaceFormatCore&);
|
||||
|
||||
//- Determine the file type
|
||||
static int detectBINARY(const fileName&);
|
||||
|
||||
//- Read ASCII
|
||||
bool readASCII(istream&, const off_t);
|
||||
bool readASCII(const fileName&);
|
||||
|
||||
//- Read BINARY
|
||||
bool readBINARY(istream&, const off_t);
|
||||
bool readBINARY(const fileName&);
|
||||
|
||||
//- Read ASCII or BINARY
|
||||
bool readFile(const fileName&, const STLFormat&);
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
STLReader(const STLReader&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const STLReader&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Static Data
|
||||
|
||||
//- The number of bytes in the STL binary header
|
||||
static const unsigned int headerSize = 80;
|
||||
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Write "STL binary file" and number of triangles to stream
|
||||
static void writeHeaderBINARY(ostream&, unsigned int);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Read from file, filling in the information
|
||||
STLsurfaceFormatCore(const fileName&);
|
||||
STLReader(const fileName&);
|
||||
|
||||
//- Read from file, filling in the information.
|
||||
// Manually selected choice of ascii/binary/detect.
|
||||
STLReader(const fileName&, const STLFormat&);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~STLsurfaceFormatCore();
|
||||
~STLReader();
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,7 +31,8 @@ License
|
||||
------ local definitions
|
||||
\* ------------------------------------------------------------------------ */
|
||||
|
||||
#include "STLsurfaceFormatCore.H"
|
||||
#include "STLReader.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -97,32 +98,32 @@ public:
|
||||
// Access
|
||||
|
||||
//- Do all the solid groups appear in order
|
||||
bool sorted() const
|
||||
inline bool sorted() const
|
||||
{
|
||||
return sorted_;
|
||||
}
|
||||
|
||||
//- A list of points corresponding to a pointField
|
||||
DynamicList<point>& points()
|
||||
inline DynamicList<point>& points()
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
|
||||
//- A list of facet IDs (group IDs)
|
||||
// corresponds to the number of triangles
|
||||
DynamicList<label>& facets()
|
||||
inline DynamicList<label>& facets()
|
||||
{
|
||||
return facets_;
|
||||
}
|
||||
|
||||
//- Names
|
||||
DynamicList<word>& names()
|
||||
inline DynamicList<word>& names()
|
||||
{
|
||||
return names_;
|
||||
}
|
||||
|
||||
//- Sizes
|
||||
DynamicList<label>& sizes()
|
||||
inline DynamicList<label>& sizes()
|
||||
{
|
||||
return sizes_;
|
||||
}
|
||||
@ -390,20 +391,27 @@ endsolid {space}("endsolid"|"ENDSOLID")({some_space}{word})*
|
||||
//
|
||||
// member function
|
||||
//
|
||||
bool Foam::fileFormats::STLsurfaceFormatCore::readASCII
|
||||
bool Foam::fileFormats::STLReader::readASCII
|
||||
(
|
||||
istream& is,
|
||||
const off_t dataFileSize
|
||||
const fileName& filename
|
||||
)
|
||||
{
|
||||
IFstream is(filename);
|
||||
if (!is)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "file " << filename << " not found"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Create the lexer with the approximate number of vertices in the STL
|
||||
// from the file size
|
||||
STLASCIILexer lexer(&is, dataFileSize/400);
|
||||
STLASCIILexer lexer(&(is.stdStream()), Foam::fileSize(filename)/400);
|
||||
while (lexer.lex() != 0) {}
|
||||
|
||||
sorted_ = lexer.sorted();
|
||||
|
||||
// transfer to normal lists
|
||||
// Transfer to normal lists
|
||||
points_.transfer(lexer.points());
|
||||
zoneIds_.transfer(lexer.facets());
|
||||
names_.transfer(lexer.names());
|
||||
@ -413,5 +421,5 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readASCII
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ *\
|
||||
------ End of STLfileFormatASCII.L
|
||||
------ End of STLReaderASCII.L
|
||||
\* ------------------------------------------------------------------------ */
|
||||
@ -2,8 +2,8 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,14 +27,13 @@ Class
|
||||
Description
|
||||
A vertex point representation for STL files.
|
||||
|
||||
SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef STLpoint_H
|
||||
#define STLpoint_H
|
||||
|
||||
#include "point.H"
|
||||
#include "floatVector.H"
|
||||
#include "Istream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -80,11 +79,13 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Conversion to point
|
||||
#ifdef WM_DP
|
||||
//- Conversion to double-precision point
|
||||
inline operator point() const
|
||||
{
|
||||
return point(x(), y(), z());
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -45,12 +45,9 @@ namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class STLtriangle;
|
||||
|
||||
Ostream& operator<<(Ostream&, const STLtriangle&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class STLtriangle Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -62,7 +59,7 @@ class STLtriangle
|
||||
//- Attribute is 16-bit
|
||||
typedef unsigned short STLattrib;
|
||||
|
||||
//- The face normal, many programs write zore or other junk
|
||||
//- The face normal, many programs write zero or other junk
|
||||
STLpoint normal_;
|
||||
|
||||
//- The three points defining the triangle
|
||||
@ -113,7 +110,30 @@ public:
|
||||
// Write
|
||||
|
||||
//- Write to ostream (binary)
|
||||
inline void write(ostream&);
|
||||
inline void write(ostream&) const;
|
||||
|
||||
//- Write to Ostream (ASCII)
|
||||
inline Ostream& print(Ostream& os) const;
|
||||
|
||||
|
||||
//- Write components to Ostream (ASCII)
|
||||
inline static void write
|
||||
(
|
||||
Ostream& os,
|
||||
const vector& norm,
|
||||
const point& pt0,
|
||||
const point& pt1,
|
||||
const point& pt2
|
||||
);
|
||||
|
||||
//- Write components to Ostream (ASCII), calculating the normal
|
||||
inline static void write
|
||||
(
|
||||
Ostream& os,
|
||||
const point& pt0,
|
||||
const point& pt1,
|
||||
const point& pt2
|
||||
);
|
||||
|
||||
|
||||
// Ostream operator
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -23,6 +23,8 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "triPointRef.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::STLtriangle::STLtriangle()
|
||||
@ -91,10 +93,61 @@ inline void Foam::STLtriangle::read(istream& is)
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::STLtriangle::write(ostream& os)
|
||||
inline void Foam::STLtriangle::write(ostream& os) const
|
||||
{
|
||||
os.write(reinterpret_cast<char*>(this), 4*sizeof(STLpoint));
|
||||
os.write(reinterpret_cast<char*>(&attrib_), sizeof(STLattrib));
|
||||
os.write(reinterpret_cast<const char*>(this), 4*sizeof(STLpoint));
|
||||
os.write(reinterpret_cast<const char*>(&attrib_), sizeof(STLattrib));
|
||||
}
|
||||
|
||||
|
||||
inline Foam::Ostream& Foam::STLtriangle::print(Ostream& os) const
|
||||
{
|
||||
os << " facet normal "
|
||||
<< normal_.x() << ' ' << normal_.y() << ' ' << normal_.z() << nl
|
||||
<< " outer loop" << nl
|
||||
<< " vertex " << a_.x() << ' ' << a_.y() << ' ' << a_.z() << nl
|
||||
<< " vertex " << b_.x() << ' ' << b_.y() << ' ' << b_.z() << nl
|
||||
<< " vertex " << c_.x() << ' ' << c_.y() << ' ' << c_.z() << nl
|
||||
<< " endloop" << nl
|
||||
<< " endfacet" << nl;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::STLtriangle::write
|
||||
(
|
||||
Ostream& os,
|
||||
const vector& norm,
|
||||
const point& pt0,
|
||||
const point& pt1,
|
||||
const point& pt2
|
||||
)
|
||||
{
|
||||
os << " facet normal "
|
||||
<< norm.x() << ' ' << norm.y() << ' ' << norm.z() << nl
|
||||
<< " outer loop" << nl
|
||||
<< " vertex " << pt0.x() << ' ' << pt0.y() << ' ' << pt0.z() << nl
|
||||
<< " vertex " << pt1.x() << ' ' << pt1.y() << ' ' << pt1.z() << nl
|
||||
<< " vertex " << pt2.x() << ' ' << pt2.y() << ' ' << pt2.z() << nl
|
||||
<< " endloop" << nl
|
||||
<< " endfacet" << nl;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::STLtriangle::write
|
||||
(
|
||||
Ostream& os,
|
||||
const point& pt0,
|
||||
const point& pt1,
|
||||
const point& pt2
|
||||
)
|
||||
{
|
||||
// calculate the normal ourselves
|
||||
vector norm = triPointRef(pt0, pt1, pt2).normal();
|
||||
norm /= mag(norm) + VSMALL;
|
||||
|
||||
write(os, norm, pt0, pt1, pt2);
|
||||
}
|
||||
|
||||
|
||||
@ -149,6 +149,7 @@ momentOfInertia/momentOfInertia.C
|
||||
|
||||
surfaceSets/surfaceSets.C
|
||||
|
||||
triSurface/faceTriangulation/faceTriangulation.C
|
||||
triSurface/orientedSurface/orientedSurface.C
|
||||
triSurface/surfaceLocation/surfaceLocation.C
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
surfZone/surfZone/surfZone.C
|
||||
surfZone/surfZone/surfZoneIOList.C
|
||||
surfZone/surfZoneIdentifier/surfZoneIdentifier.C
|
||||
|
||||
MeshedSurfaceAllocator/MeshedSurfaceIOAllocator.C
|
||||
|
||||
@ -8,7 +7,7 @@ MeshedSurface/MeshedSurfaceCore.C
|
||||
MeshedSurface/MeshedSurfaces.C
|
||||
UnsortedMeshedSurface/UnsortedMeshedSurfaces.C
|
||||
|
||||
MeshedSurfaceProxy/MeshedSurfaceProxyCore.C
|
||||
MeshedSurfaceProxy/MeshedSurfaceProxys.C
|
||||
|
||||
mergedSurf/mergedSurf.C
|
||||
|
||||
@ -33,9 +32,7 @@ $(surfaceFormats)/off/OFFsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/smesh/SMESHsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/starcd/STARCDsurfaceFormatCore.C
|
||||
$(surfaceFormats)/starcd/STARCDsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/stl/STLsurfaceFormatCore.C
|
||||
$(surfaceFormats)/stl/STLsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/stl/STLsurfaceFormatASCII.L
|
||||
$(surfaceFormats)/tri/TRIsurfaceFormatCore.C
|
||||
$(surfaceFormats)/tri/TRIsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/vtk/VTKsurfaceFormatCore.C
|
||||
|
||||
@ -532,6 +532,16 @@ void Foam::MeshedSurface<Face>::scalePoints(const scalar scaleFactor)
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::reset
|
||||
(
|
||||
const Xfer<MeshedSurface<Face>>& surf
|
||||
)
|
||||
{
|
||||
transfer(surf());
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::reset
|
||||
(
|
||||
@ -837,6 +847,61 @@ bool Foam::MeshedSurface<Face>::checkFaces
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::label Foam::MeshedSurface<Face>::nTriangles() const
|
||||
{
|
||||
return nTriangles
|
||||
(
|
||||
const_cast<List<label>&>(List<label>::null())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::label Foam::MeshedSurface<Face>::nTriangles
|
||||
(
|
||||
List<label>& faceMap
|
||||
) const
|
||||
{
|
||||
label nTri = 0;
|
||||
const List<Face>& faceLst = surfFaces();
|
||||
|
||||
// Count triangles needed
|
||||
forAll(faceLst, facei)
|
||||
{
|
||||
nTri += faceLst[facei].nTriangles();
|
||||
}
|
||||
|
||||
// Nothing to do
|
||||
if (nTri <= faceLst.size())
|
||||
{
|
||||
if (notNull(faceMap))
|
||||
{
|
||||
faceMap.clear();
|
||||
}
|
||||
}
|
||||
else if (notNull(faceMap))
|
||||
{
|
||||
// face map requested
|
||||
faceMap.setSize(nTri);
|
||||
|
||||
nTri = 0;
|
||||
forAll(faceLst, facei)
|
||||
{
|
||||
label n = faceLst[facei].nTriangles();
|
||||
while (n-- > 0)
|
||||
{
|
||||
faceMap[nTri++] = facei;
|
||||
}
|
||||
}
|
||||
|
||||
faceMap.setSize(nTri);
|
||||
}
|
||||
|
||||
return nTri;
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::label Foam::MeshedSurface<Face>::triangulate()
|
||||
{
|
||||
@ -888,14 +953,11 @@ Foam::label Foam::MeshedSurface<Face>::triangulate
|
||||
}
|
||||
faceMap.setSize(nTri);
|
||||
|
||||
// remember the number of *additional* faces
|
||||
nTri -= faceLst.size();
|
||||
|
||||
if (this->points().empty())
|
||||
{
|
||||
// triangulate without points
|
||||
// simple face triangulation around f[0]
|
||||
label newFacei = 0;
|
||||
nTri = 0;
|
||||
forAll(faceLst, facei)
|
||||
{
|
||||
const Face& f = faceLst[facei];
|
||||
@ -904,9 +966,9 @@ Foam::label Foam::MeshedSurface<Face>::triangulate
|
||||
{
|
||||
label fp1 = f.fcIndex(fp);
|
||||
|
||||
newFaces[newFacei] = triFace(f[0], f[fp], f[fp1]);
|
||||
faceMap[newFacei] = facei;
|
||||
newFacei++;
|
||||
newFaces[nTri] = triFace(f[0], f[fp], f[fp1]);
|
||||
faceMap[nTri] = facei;
|
||||
nTri++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -915,7 +977,7 @@ Foam::label Foam::MeshedSurface<Face>::triangulate
|
||||
// triangulate with points
|
||||
List<face> tmpTri(maxTri);
|
||||
|
||||
label newFacei = 0;
|
||||
nTri = 0;
|
||||
forAll(faceLst, facei)
|
||||
{
|
||||
// 'face' not '<Face>'
|
||||
@ -925,16 +987,19 @@ Foam::label Foam::MeshedSurface<Face>::triangulate
|
||||
f.triangles(this->points(), nTmp, tmpTri);
|
||||
for (label triI = 0; triI < nTmp; triI++)
|
||||
{
|
||||
newFaces[newFacei] = Face
|
||||
newFaces[nTri] = Face
|
||||
(
|
||||
static_cast<labelUList&>(tmpTri[triI])
|
||||
);
|
||||
faceMap[newFacei] = facei;
|
||||
newFacei++;
|
||||
faceMap[nTri] = facei;
|
||||
nTri++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The number of *additional* faces
|
||||
nTri -= faceLst.size();
|
||||
|
||||
faceLst.transfer(newFaces);
|
||||
remapFaces(faceMap);
|
||||
|
||||
@ -947,6 +1012,7 @@ Foam::label Foam::MeshedSurface<Face>::triangulate
|
||||
|
||||
// Topology can change because of renumbering
|
||||
ParentType::clearOut();
|
||||
|
||||
return nTri;
|
||||
}
|
||||
|
||||
@ -1056,12 +1122,13 @@ void Foam::MeshedSurface<Face>::transfer
|
||||
MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
reset
|
||||
(
|
||||
xferMove(surf.storedPoints()),
|
||||
xferMove(surf.storedFaces()),
|
||||
xferMove(surf.storedZones())
|
||||
);
|
||||
ParentType::clearOut();
|
||||
|
||||
this->storedPoints().transfer(surf.storedPoints());
|
||||
this->storedFaces().transfer(surf.storedFaces());
|
||||
this->storedZones().transfer(surf.storedZones());
|
||||
|
||||
surf.clear();
|
||||
}
|
||||
|
||||
|
||||
@ -1109,12 +1176,43 @@ void Foam::MeshedSurface<Face>::transfer
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::Xfer<Foam::MeshedSurface<Face>> Foam::MeshedSurface<Face>::xfer()
|
||||
Foam::Xfer<Foam::MeshedSurface<Face>>
|
||||
Foam::MeshedSurface<Face>::xfer()
|
||||
{
|
||||
return xferMove(*this);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::Xfer<Foam::List<Face>>
|
||||
Foam::MeshedSurface<Face>::xferFaces()
|
||||
{
|
||||
// Topology changed because of transfer
|
||||
ParentType::clearOut();
|
||||
|
||||
return this->storedFaces().xfer();
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::Xfer<Foam::List<Foam::point>>
|
||||
Foam::MeshedSurface<Face>::xferPoints()
|
||||
{
|
||||
// Topology changed because of transfer
|
||||
ParentType::clearOut();
|
||||
|
||||
return this->storedPoints().xfer();
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::Xfer<Foam::surfZoneList>
|
||||
Foam::MeshedSurface<Face>::xferZones()
|
||||
{
|
||||
return this->storedZones().xfer();
|
||||
}
|
||||
|
||||
|
||||
// Read from file, determine format from extension
|
||||
template<class Face>
|
||||
bool Foam::MeshedSurface<Face>::read(const fileName& name)
|
||||
|
||||
@ -51,7 +51,7 @@ SourceFiles
|
||||
#include "PatchTools.H"
|
||||
#include "pointField.H"
|
||||
#include "face.H"
|
||||
#include "triFace.H"
|
||||
#include "labelledTri.H"
|
||||
|
||||
#include "surfZoneList.H"
|
||||
#include "surfaceFormatsCore.H"
|
||||
@ -134,7 +134,10 @@ protected:
|
||||
|
||||
// Protected Member functions
|
||||
|
||||
//- Transfer points/zones and transcribe face -> triFace
|
||||
//- Transfer points/zones from 'face' to other other shapes.
|
||||
// Eg, transcribe face to triFace, or face -> labelledTri, including
|
||||
// any addZonesToFaces adjustment.
|
||||
// No general form, only specializations.
|
||||
void transcribe(MeshedSurface<face>&);
|
||||
|
||||
//- Basic sanity check on zones
|
||||
@ -386,6 +389,12 @@ public:
|
||||
const bool cullEmpty=false
|
||||
);
|
||||
|
||||
//- Propagate zone information on face regions.
|
||||
// Normally a no-op, only used by the labelledTri specialization.
|
||||
// Specializations return true, others return false.
|
||||
bool addZonesToFaces();
|
||||
|
||||
|
||||
//- Remove surface zones
|
||||
virtual void removeZones();
|
||||
|
||||
@ -396,6 +405,12 @@ public:
|
||||
//- Scale points. A non-positive factor is ignored
|
||||
virtual void scalePoints(const scalar);
|
||||
|
||||
//- Reset by transferring contents of the argument and annul it
|
||||
virtual void reset
|
||||
(
|
||||
const Xfer<MeshedSurface<Face>>&
|
||||
);
|
||||
|
||||
//- Reset primitive data (points, faces and zones)
|
||||
// Note, optimized to avoid overwriting data (with Xfer::null)
|
||||
virtual void reset
|
||||
@ -428,7 +443,14 @@ public:
|
||||
const bool verbose=false
|
||||
);
|
||||
|
||||
//- Triangulate in-place, returning the number of triangles added
|
||||
//- Count number of triangles.
|
||||
virtual label nTriangles() const;
|
||||
|
||||
//- Count number of triangles, returning a face map of original ids.
|
||||
// The faceMap is zero-sized when no triangulation would be needed.
|
||||
virtual label nTriangles(List<label>& faceMap) const;
|
||||
|
||||
//- Triangulate in-place, returning the number of triangles added.
|
||||
virtual label triangulate();
|
||||
|
||||
//- Triangulate in-place, returning the number of triangles added
|
||||
@ -436,7 +458,6 @@ public:
|
||||
// The faceMap is zero-sized when no triangulation was done.
|
||||
virtual label triangulate(List<label>& faceMap);
|
||||
|
||||
|
||||
//- Return new surface.
|
||||
// Returns return pointMap, faceMap from subsetMeshMap
|
||||
MeshedSurface subsetMesh
|
||||
@ -461,6 +482,15 @@ public:
|
||||
//- Transfer contents to the Xfer container
|
||||
Xfer<MeshedSurface<Face>> xfer();
|
||||
|
||||
//- Transfer stored faces to an Xfer container
|
||||
Xfer<List<Face>> xferFaces();
|
||||
|
||||
//- Transfer stored points to an Xfer container
|
||||
Xfer<List<point>> xferPoints();
|
||||
|
||||
//- Transfer stored zones to an Xfer container
|
||||
Xfer<surfZoneList> xferZones();
|
||||
|
||||
|
||||
// Read
|
||||
|
||||
@ -521,34 +551,11 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Specialization for holding triangulated information
|
||||
//- Specialization for labelledTri.
|
||||
template<>
|
||||
inline bool MeshedSurface<triFace>::isTri()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool MeshedSurface<labelledTri>::addZonesToFaces();
|
||||
|
||||
|
||||
//- Specialization for holding triangulated information
|
||||
template<>
|
||||
inline label MeshedSurface<triFace>::triangulate()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//- Specialization for holding triangulated information
|
||||
template<>
|
||||
inline label MeshedSurface<triFace>::triangulate(List<label>& faceMap)
|
||||
{
|
||||
if (notNull(faceMap))
|
||||
{
|
||||
faceMap.clear();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -556,6 +563,8 @@ inline label MeshedSurface<triFace>::triangulate(List<label>& faceMap)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "MeshedSurfaceI.H"
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "MeshedSurface.C"
|
||||
#endif
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -30,18 +30,34 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// specialization: from face -> triFace
|
||||
// Transcribe 'face' to 'face' (ie, just transfer)
|
||||
template<>
|
||||
void Foam::MeshedSurface<triFace>::transcribe(MeshedSurface<face>& surf)
|
||||
void Foam::MeshedSurface<Foam::face>::transcribe
|
||||
(
|
||||
MeshedSurface<face>& surf
|
||||
)
|
||||
{
|
||||
// first triangulate
|
||||
this->transfer(surf);
|
||||
this->addZonesToFaces(); // currently a no-op
|
||||
}
|
||||
|
||||
// Transcribe 'face' to 'triFace'
|
||||
// Transfer points/zones and triangulate faces
|
||||
template<>
|
||||
void Foam::MeshedSurface<Foam::triFace>::transcribe
|
||||
(
|
||||
MeshedSurface<face>& surf
|
||||
)
|
||||
{
|
||||
// First triangulate
|
||||
// - slightly wasteful for space, but manages adjusts the zones too!
|
||||
surf.triangulate();
|
||||
this->storedPoints().transfer(surf.storedPoints());
|
||||
this->storedZones().transfer(surf.storedZones());
|
||||
|
||||
// transcribe from face -> triFace
|
||||
List<face>& origFaces = surf.storedFaces();
|
||||
List<triFace> newFaces(origFaces.size());
|
||||
const List<face>& origFaces = surf.surfFaces();
|
||||
List<triFace> newFaces(origFaces.size());
|
||||
forAll(origFaces, facei)
|
||||
{
|
||||
newFaces[facei] = triFace
|
||||
@ -52,18 +68,65 @@ namespace Foam
|
||||
surf.clear();
|
||||
|
||||
this->storedFaces().transfer(newFaces);
|
||||
this->addZonesToFaces(); // currently a no-op
|
||||
}
|
||||
|
||||
|
||||
// specialization: from face -> face
|
||||
// Transcribe 'face' to 'labelledTri'
|
||||
// Transfer points/zones and triangulate faces
|
||||
template<>
|
||||
void Foam::MeshedSurface<face>::transcribe(MeshedSurface<face>& surf)
|
||||
void Foam::MeshedSurface<Foam::labelledTri>::transcribe
|
||||
(
|
||||
MeshedSurface<face>& surf
|
||||
)
|
||||
{
|
||||
this->transfer(surf);
|
||||
// First triangulate
|
||||
// - slightly wasteful for space, but manages adjusts the zones too!
|
||||
surf.triangulate();
|
||||
this->storedPoints().transfer(surf.storedPoints());
|
||||
this->storedZones().transfer(surf.storedZones());
|
||||
|
||||
// transcribe from face -> triFace
|
||||
const List<face>& origFaces = surf.surfFaces();
|
||||
List<labelledTri> newFaces(origFaces.size());
|
||||
forAll(origFaces, facei)
|
||||
{
|
||||
newFaces[facei] = triFace
|
||||
(
|
||||
static_cast<const labelUList&>(origFaces[facei])
|
||||
);
|
||||
}
|
||||
surf.clear();
|
||||
|
||||
this->storedFaces().transfer(newFaces);
|
||||
this->addZonesToFaces(); // for labelledTri
|
||||
}
|
||||
|
||||
|
||||
// Propagate zone information on face regions for labelledTri.
|
||||
template<>
|
||||
bool Foam::MeshedSurface<Foam::labelledTri>::addZonesToFaces()
|
||||
{
|
||||
List<labelledTri>& faceLst = this->storedFaces();
|
||||
const surfZoneList& zones = this->surfZones();
|
||||
|
||||
forAll(zones, zoneI)
|
||||
{
|
||||
const surfZone& zone = zones[zoneI];
|
||||
|
||||
label faceI = zone.start();
|
||||
forAll(zone, i)
|
||||
{
|
||||
faceLst[faceI++].region() = zoneI;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // end of namespace Foam
|
||||
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,65 +23,76 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "sortLabelledTri.H"
|
||||
#include "labelledTri.H"
|
||||
#include "triSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Private Classes * * * * * * * * * * * * * * //
|
||||
|
||||
inline bool surfAndLabel::less::operator()
|
||||
(
|
||||
const surfAndLabel& one,
|
||||
const surfAndLabel& two
|
||||
) const
|
||||
// A triFace surface only handles triangulated faces
|
||||
template<>
|
||||
inline bool MeshedSurface<triFace>::isTri()
|
||||
{
|
||||
const triSurface& surf = *one.surfPtr_;
|
||||
return surf[one.index_].region() < surf[two.index_].region();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
sortLabelledTri::sortLabelledTri(const triSurface& surf)
|
||||
:
|
||||
List<surfAndLabel>(surf.size(), surfAndLabel(surf, -1))
|
||||
// A labelledTri surface only handles triangulated faces
|
||||
template<>
|
||||
inline bool MeshedSurface<labelledTri>::isTri()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set the face label
|
||||
forAll(surf, facei)
|
||||
|
||||
// Number of triangles for a triFace surface
|
||||
template<>
|
||||
inline label MeshedSurface<triFace>::nTriangles() const
|
||||
{
|
||||
return ParentType::size();
|
||||
}
|
||||
|
||||
// Number of triangles for a labelledTri surface
|
||||
template<>
|
||||
inline label MeshedSurface<labelledTri>::nTriangles() const
|
||||
{
|
||||
return ParentType::size();
|
||||
}
|
||||
|
||||
|
||||
// Inplace triangulation of triFace surface = no-op
|
||||
template<>
|
||||
inline label MeshedSurface<triFace>::triangulate()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Inplace triangulation of labelledTri surface = no-op
|
||||
template<>
|
||||
inline label MeshedSurface<labelledTri>::triangulate()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Inplace triangulation of triFace surface (with face map) = no-op
|
||||
template<>
|
||||
inline label MeshedSurface<triFace>::triangulate(List<label>& faceMap)
|
||||
{
|
||||
if (notNull(faceMap))
|
||||
{
|
||||
operator[](facei).index_ = facei;
|
||||
faceMap.clear();
|
||||
}
|
||||
|
||||
// Sort according to region number.
|
||||
sort(*this, surfAndLabel::less());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void sortLabelledTri::indices(labelList& newIndices) const
|
||||
// Inplace triangulation of labelledTri surface (with face map) = no-op
|
||||
template<>
|
||||
inline label MeshedSurface<labelledTri>::triangulate(List<label>& faceMap)
|
||||
{
|
||||
newIndices.setSize(size());
|
||||
|
||||
forAll(newIndices, i)
|
||||
if (notNull(faceMap))
|
||||
{
|
||||
newIndices[i] = operator[](i).index_;
|
||||
faceMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
labelList sortLabelledTri::indices() const
|
||||
{
|
||||
labelList newIndices(size());
|
||||
indices(newIndices);
|
||||
return newIndices;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -131,7 +131,7 @@ void Foam::MeshedSurface<Face>::addZones
|
||||
const bool cullEmpty
|
||||
)
|
||||
{
|
||||
label start = 0;
|
||||
label start = 0;
|
||||
label nZone = 0;
|
||||
|
||||
surfZoneList& zones = this->storedZones();
|
||||
@ -162,7 +162,7 @@ void Foam::MeshedSurface<Face>::addZones
|
||||
const bool cullEmpty
|
||||
)
|
||||
{
|
||||
label start = 0;
|
||||
label start = 0;
|
||||
label nZone = 0;
|
||||
|
||||
surfZoneList& zones = this->storedZones();
|
||||
@ -186,6 +186,14 @@ void Foam::MeshedSurface<Face>::addZones
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
bool Foam::MeshedSurface<Face>::addZonesToFaces()
|
||||
{
|
||||
// Normally a no-op, only the specializations are used.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::removeZones()
|
||||
{
|
||||
|
||||
@ -46,6 +46,7 @@ namespace Foam
|
||||
|
||||
makeSurface(MeshedSurface, face)
|
||||
makeSurface(MeshedSurface, triFace)
|
||||
makeSurface(MeshedSurface, labelledTri)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ public:
|
||||
//- Clear primitive data (points, faces and zones)
|
||||
void clear();
|
||||
|
||||
//- Reset primitive data (points, faces and zones)
|
||||
//- Reset primitive data (faces and zones)
|
||||
// Note, optimized to avoid overwriting data (with Xfer::null)
|
||||
void resetFaces
|
||||
(
|
||||
|
||||
@ -235,4 +235,41 @@ Foam::MeshedSurfaceProxy<Face>::~MeshedSurfaceProxy()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Number of triangles for a triFace surface
|
||||
template<>
|
||||
inline label MeshedSurfaceProxy<triFace>::nTriangles() const
|
||||
{
|
||||
return this->size();
|
||||
}
|
||||
|
||||
// Number of triangles for a labelledTri surface
|
||||
template<>
|
||||
inline label MeshedSurfaceProxy<labelledTri>::nTriangles() const
|
||||
{
|
||||
return this->size();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
inline Foam::label Foam::MeshedSurfaceProxy<Face>::nTriangles() const
|
||||
{
|
||||
label nTri = 0;
|
||||
const List<Face>& faceLst = this->surfFaces();
|
||||
forAll(faceLst, facei)
|
||||
{
|
||||
nTri += faceLst[facei].nTriangles();
|
||||
}
|
||||
|
||||
return nTri;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -30,7 +30,7 @@ Description
|
||||
|
||||
SourceFiles
|
||||
MeshedSurfaceProxy.C
|
||||
MeshedSurfaceProxyCore.C
|
||||
MeshedSurfaceProxys.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -38,8 +38,7 @@ SourceFiles
|
||||
#define MeshedSurfaceProxy_H
|
||||
|
||||
#include "pointField.H"
|
||||
#include "face.H"
|
||||
#include "triFace.H"
|
||||
#include "labelledTri.H"
|
||||
|
||||
#include "surfZoneList.H"
|
||||
#include "surfaceFormatsCore.H"
|
||||
@ -139,6 +138,12 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- The surface size is the number of faces
|
||||
inline label size() const
|
||||
{
|
||||
return faces_.size();
|
||||
}
|
||||
|
||||
//- Return const access to the points
|
||||
inline const pointField& points() const
|
||||
{
|
||||
@ -171,6 +176,10 @@ public:
|
||||
return faceMap_.size() == faces_.size();
|
||||
}
|
||||
|
||||
//- Count number of triangles.
|
||||
inline label nTriangles() const;
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
//- Generic write routine. Chooses writer based on extension.
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -46,6 +46,7 @@ namespace Foam
|
||||
|
||||
makeSurface(MeshedSurfaceProxy, face)
|
||||
makeSurface(MeshedSurfaceProxy, triFace)
|
||||
makeSurface(MeshedSurfaceProxy, labelledTri)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -22,110 +22,83 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::surfacePatchIOList
|
||||
Foam::ModifiableMeshedSurface
|
||||
|
||||
Description
|
||||
IOobject for a surfacePatchList
|
||||
A special purpose MeshedSurface that exposes the stored values
|
||||
for direct modification.
|
||||
|
||||
SourceFiles
|
||||
surfacePatchIOList.C
|
||||
Its usage should be restricted to special cases where the surface
|
||||
needs modifications as an atomic operation.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfacePatchIOList_H
|
||||
#define surfacePatchIOList_H
|
||||
#ifndef ModifiableMeshedSurface_H
|
||||
#define ModifiableMeshedSurface_H
|
||||
|
||||
#include "surfacePatchList.H"
|
||||
#include "regIOobject.H"
|
||||
#include "faceList.H"
|
||||
#include "className.H"
|
||||
#include "MeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class surfacePatchIOList;
|
||||
|
||||
Ostream& operator<<(Ostream&, const surfacePatchIOList&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfacePatchIOList Declaration
|
||||
Class ModifiableMeshedSurface Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfacePatchIOList
|
||||
template<class Face>
|
||||
class ModifiableMeshedSurface
|
||||
:
|
||||
public surfacePatchList,
|
||||
public regIOobject
|
||||
public MeshedSurface<Face>
|
||||
{
|
||||
// Private data
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
surfacePatchIOList(const surfacePatchIOList&);
|
||||
ModifiableMeshedSurface(const ModifiableMeshedSurface<Face>&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const surfacePatchIOList&);
|
||||
void operator=(const ModifiableMeshedSurface<Face>&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("surfacePatchIOList");
|
||||
|
||||
|
||||
// Static data members
|
||||
|
||||
//- Static data someStaticData
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from IOobject
|
||||
explicit surfacePatchIOList(const IOobject& io);
|
||||
//- Construct null, use reset/transfer to adjust contents
|
||||
ModifiableMeshedSurface()
|
||||
:
|
||||
MeshedSurface<Face>()
|
||||
{}
|
||||
|
||||
|
||||
//- Construct by transferring the contents from a MeshedSurface
|
||||
explicit ModifiableMeshedSurface
|
||||
(
|
||||
const Xfer<MeshedSurface<Face>>& surf
|
||||
)
|
||||
:
|
||||
MeshedSurface<Face>(surf)
|
||||
{}
|
||||
|
||||
//- Construct from IOobject
|
||||
surfacePatchIOList(const IOobject& io, const surfacePatchList&);
|
||||
|
||||
//- Destructor
|
||||
~surfacePatchIOList();
|
||||
virtual ~ModifiableMeshedSurface()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- writeData member function required by regIOobject
|
||||
bool writeData(Ostream&) const;
|
||||
// Edit
|
||||
|
||||
//- Is object global
|
||||
virtual bool global() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//- Return complete path + object name if the file exists
|
||||
// either in the case/processor or case otherwise null
|
||||
virtual fileName filePath() const
|
||||
{
|
||||
return globalFilePath();
|
||||
}
|
||||
// Expose protected methods
|
||||
using MeshedSurface<Face>::storedFaces;
|
||||
using MeshedSurface<Face>::storedPoints;
|
||||
using MeshedSurface<Face>::storedZones;
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const surfacePatchIOList&);
|
||||
};
|
||||
|
||||
|
||||
//- Template function for obtaining global status
|
||||
template<>
|
||||
inline bool typeGlobal<surfacePatchIOList>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
@ -722,6 +722,14 @@ Foam::UnsortedMeshedSurface<Face>::xfer()
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::Xfer<Foam::labelList>
|
||||
Foam::UnsortedMeshedSurface<Face>::xferZoneIds()
|
||||
{
|
||||
return this->storedZoneIds().xfer();
|
||||
}
|
||||
|
||||
|
||||
// Read from file, determine format from extension
|
||||
template<class Face>
|
||||
bool Foam::UnsortedMeshedSurface<Face>::read(const fileName& name)
|
||||
|
||||
@ -366,6 +366,9 @@ public:
|
||||
//- Transfer contents to the Xfer container
|
||||
Xfer<UnsortedMeshedSurface<Face>> xfer();
|
||||
|
||||
//- Transfer stored zoneIds to an Xfer container
|
||||
Xfer<labelList> xferZoneIds();
|
||||
|
||||
|
||||
// Read
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -46,6 +46,7 @@ namespace Foam
|
||||
|
||||
makeSurface(UnsortedMeshedSurface, face)
|
||||
makeSurface(UnsortedMeshedSurface, triFace)
|
||||
makeSurface(UnsortedMeshedSurface, labelledTri)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -260,7 +260,28 @@ void Foam::surfMesh::resetPrimitives
|
||||
)
|
||||
{
|
||||
// Clear addressing.
|
||||
MeshReference::clearGeom();
|
||||
clearOut();
|
||||
|
||||
Allocator::reset(points, faces, zones);
|
||||
this->updateRefs();
|
||||
|
||||
if (validate)
|
||||
{
|
||||
checkZones();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::surfMesh::resetPrimitives
|
||||
(
|
||||
const Xfer<List<point>>& points,
|
||||
const Xfer<faceList>& faces,
|
||||
const Xfer<surfZoneList>& zones,
|
||||
const bool validate
|
||||
)
|
||||
{
|
||||
// Clear addressing.
|
||||
clearOut();
|
||||
|
||||
Allocator::reset(points, faces, zones);
|
||||
this->updateRefs();
|
||||
@ -278,7 +299,7 @@ void Foam::surfMesh::transfer
|
||||
)
|
||||
{
|
||||
// Clear addressing.
|
||||
MeshReference::clearGeom();
|
||||
clearOut();
|
||||
|
||||
this->storedIOPoints().transfer(surf.storedPoints());
|
||||
this->storedIOFaces().transfer(surf.storedFaces());
|
||||
@ -288,7 +309,8 @@ void Foam::surfMesh::transfer
|
||||
}
|
||||
|
||||
|
||||
Foam::Xfer<Foam::MeshedSurface<Foam::face>> Foam::surfMesh::xfer()
|
||||
Foam::Xfer<Foam::MeshedSurface<Foam::face>>
|
||||
Foam::surfMesh::xfer()
|
||||
{
|
||||
Xfer<MeshedSurface<face>> xf;
|
||||
|
||||
@ -300,7 +322,7 @@ Foam::Xfer<Foam::MeshedSurface<Foam::face>> Foam::surfMesh::xfer()
|
||||
this->updateRefs();
|
||||
|
||||
// Clear addressing.
|
||||
MeshReference::clearGeom();
|
||||
clearOut();
|
||||
|
||||
return xf;
|
||||
}
|
||||
|
||||
@ -277,6 +277,15 @@ public:
|
||||
const bool validate = true
|
||||
);
|
||||
|
||||
//- Reset mesh primitive data.
|
||||
void resetPrimitives
|
||||
(
|
||||
const Xfer<List<point>>& points,
|
||||
const Xfer<faceList>& faces,
|
||||
const Xfer<surfZoneList>& zones,
|
||||
const bool validate = true
|
||||
);
|
||||
|
||||
|
||||
//- Transfer the contents of the argument and annul the argument
|
||||
void transfer(MeshedSurface<face>&);
|
||||
|
||||
@ -24,10 +24,8 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "AC3DsurfaceFormat.H"
|
||||
#include "clock.H"
|
||||
#include "IStringStream.H"
|
||||
#include "tensor.H"
|
||||
#include "primitivePatch.H"
|
||||
#include "PrimitivePatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -49,7 +47,6 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
const fileName& filename
|
||||
)
|
||||
{
|
||||
const bool mustTriangulate = this->isTri();
|
||||
this->clear();
|
||||
|
||||
IFstream is(filename);
|
||||
@ -199,7 +196,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
|
||||
labelUList& f = static_cast<labelUList&>(verts);
|
||||
|
||||
if (mustTriangulate && f.size() > 3)
|
||||
if (MeshedSurface<Face>::isTri() && f.size() > 3)
|
||||
{
|
||||
// simple face triangulation about f[0]
|
||||
// points may be incomplete
|
||||
@ -248,11 +245,64 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
|
||||
// add zones, culling empty ones
|
||||
this->addZones(sizes, names, true);
|
||||
this->addZonesToFaces(); // for labelledTri
|
||||
this->stitchFaces(SMALL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// file-scope writing of a patch of faces
|
||||
template
|
||||
<
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
static void writeZone
|
||||
(
|
||||
Ostream& os,
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>& patch,
|
||||
const word& name,
|
||||
const label zoneI
|
||||
)
|
||||
{
|
||||
// An isolated surface region (patch).
|
||||
os << "OBJECT poly" << nl
|
||||
<< "name \"" << name << "\"" << nl;
|
||||
|
||||
os << "numvert " << patch.nPoints() << nl;
|
||||
|
||||
forAll(patch.localPoints(), pti)
|
||||
{
|
||||
const point& pt = patch.localPoints()[pti];
|
||||
|
||||
os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
||||
}
|
||||
|
||||
os << "numsurf " << patch.size() << nl;
|
||||
|
||||
forAll(patch.localFaces(), facei)
|
||||
{
|
||||
const Face& f = patch.localFaces()[facei];
|
||||
|
||||
os << "SURF 0x20" << nl // polygon
|
||||
<< "mat " << zoneI << nl
|
||||
<< "refs " << f.size() << nl;
|
||||
|
||||
forAll(f, fp)
|
||||
{
|
||||
os << f[fp] << " 0 0" << nl;
|
||||
}
|
||||
}
|
||||
|
||||
os << "kids 0" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
(
|
||||
@ -272,14 +322,6 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
|
||||
const bool useFaceMap = (surf.useFaceMap() && zones.size() > 1);
|
||||
|
||||
if (useFaceMap)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "output with faceMap is not supported " << filename
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
OFstream os(filename);
|
||||
if (!os.good())
|
||||
{
|
||||
@ -290,52 +332,42 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
|
||||
writeHeader(os, zones);
|
||||
|
||||
if (zones.size() == 1)
|
||||
{
|
||||
PrimitivePatch<Face, UList, const pointField&> patch
|
||||
(
|
||||
faceLst, pointLst
|
||||
);
|
||||
|
||||
writeZone(os, patch, zones[0].name(), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
forAll(zones, zoneI)
|
||||
{
|
||||
const surfZone& zone = zones[zoneI];
|
||||
|
||||
os << "OBJECT poly" << nl
|
||||
<< "name \"" << zone.name() << "\"\n";
|
||||
|
||||
// Temporary PrimitivePatch to calculate compact points & faces
|
||||
// use 'UList' to avoid allocations!
|
||||
PrimitivePatch<Face, UList, const pointField&> patch
|
||||
(
|
||||
SubList<Face>
|
||||
if (useFaceMap)
|
||||
{
|
||||
SubList<label> zoneMap(surf.faceMap(), zone.size(), zone.start());
|
||||
PrimitivePatch<Face, UIndirectList, const pointField&> patch
|
||||
(
|
||||
faceLst,
|
||||
zone.size(),
|
||||
zone.start()
|
||||
),
|
||||
pointLst
|
||||
);
|
||||
UIndirectList<Face>(faceLst, zoneMap),
|
||||
pointLst
|
||||
);
|
||||
|
||||
os << "numvert " << patch.nPoints() << endl;
|
||||
|
||||
forAll(patch.localPoints(), ptI)
|
||||
{
|
||||
const point& pt = patch.localPoints()[ptI];
|
||||
|
||||
os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
||||
writeZone(os, patch, zone.name(), zoneI);
|
||||
}
|
||||
|
||||
os << "numsurf " << patch.localFaces().size() << endl;
|
||||
|
||||
forAll(patch.localFaces(), localFacei)
|
||||
else
|
||||
{
|
||||
const Face& f = patch.localFaces()[localFacei];
|
||||
PrimitivePatch<Face, UList, const pointField&> patch
|
||||
(
|
||||
SubList<Face>(faceLst, zone.size(), zone.start()),
|
||||
pointLst
|
||||
);
|
||||
|
||||
os << "SURF 0x20" << nl // polygon
|
||||
<< "mat " << zoneI << nl
|
||||
<< "refs " << f.size() << nl;
|
||||
|
||||
forAll(f, fp)
|
||||
{
|
||||
os << f[fp] << " 0 0" << nl;
|
||||
}
|
||||
writeZone(os, patch, zone.name(), zoneI);
|
||||
}
|
||||
|
||||
os << "kids 0" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -347,81 +379,44 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
OFstream os(filename);
|
||||
if (!os.good())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot open file for writing " << filename
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
labelList faceMap;
|
||||
List<surfZone> zoneLst = surf.sortedZones(faceMap);
|
||||
|
||||
if (zoneLst.size() <= 1)
|
||||
{
|
||||
write
|
||||
const List<surfZone>& zones =
|
||||
(
|
||||
filename,
|
||||
MeshedSurfaceProxy<Face>
|
||||
(
|
||||
surf.points(),
|
||||
surf.surfFaces(),
|
||||
zoneLst
|
||||
)
|
||||
zoneLst.size()
|
||||
? zoneLst
|
||||
: surfaceFormatsCore::oneZone(surf.surfFaces())
|
||||
);
|
||||
|
||||
writeHeader(os, zones);
|
||||
writeZone(os, surf, zones[0].name(), 0);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
writeHeader(os, zoneLst);
|
||||
forAll(zoneLst, zoneI)
|
||||
{
|
||||
OFstream os(filename);
|
||||
if (!os.good())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot open file for writing " << filename
|
||||
<< exit(FatalError);
|
||||
}
|
||||
const surfZone& zone = zoneLst[zoneI];
|
||||
|
||||
writeHeader(os, zoneLst);
|
||||
SubList<label> zoneMap(faceMap, zone.size(), zone.start());
|
||||
PrimitivePatch<Face, UIndirectList, const pointField&> patch
|
||||
(
|
||||
UIndirectList<Face>(surf.surfFaces(), zoneMap),
|
||||
surf.points()
|
||||
);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(zoneLst, zoneI)
|
||||
{
|
||||
const surfZone& zone = zoneLst[zoneI];
|
||||
|
||||
os << "OBJECT poly" << nl
|
||||
<< "name \"" << zone.name() << "\"\n";
|
||||
|
||||
// Create zone with only zone faces included for ease of addressing
|
||||
labelHashSet include(surf.size());
|
||||
|
||||
forAll(zone, localFacei)
|
||||
{
|
||||
const label facei = faceMap[faceIndex++];
|
||||
include.insert(facei);
|
||||
}
|
||||
|
||||
UnsortedMeshedSurface<Face> subm = surf.subsetMesh(include);
|
||||
|
||||
// Now we have isolated surface for this patch alone. Write it.
|
||||
os << "numvert " << subm.nPoints() << endl;
|
||||
|
||||
forAll(subm.localPoints(), ptI)
|
||||
{
|
||||
const point& pt = subm.localPoints()[ptI];
|
||||
|
||||
os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
|
||||
}
|
||||
|
||||
os << "numsurf " << subm.localFaces().size() << endl;
|
||||
|
||||
forAll(subm.localFaces(), localFacei)
|
||||
{
|
||||
const Face& f = subm.localFaces()[localFacei];
|
||||
|
||||
os << "SURF 0x20" << nl // polygon
|
||||
<< "mat " << zoneI << nl
|
||||
<< "refs " << f.size() << nl;
|
||||
|
||||
forAll(f, fp)
|
||||
{
|
||||
os << f[fp] << " 0 0" << nl;
|
||||
}
|
||||
}
|
||||
|
||||
os << "kids 0" << endl;
|
||||
}
|
||||
writeZone(os, patch, zone.name(), zoneI);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -67,10 +67,10 @@ class AC3DsurfaceFormat
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
AC3DsurfaceFormat(const AC3DsurfaceFormat<Face>&);
|
||||
AC3DsurfaceFormat(const AC3DsurfaceFormat<Face>&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const AC3DsurfaceFormat<Face>&);
|
||||
void operator=(const AC3DsurfaceFormat<Face>&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -101,10 +101,18 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Write surface mesh components by proxy
|
||||
static void write(const fileName&, const MeshedSurfaceProxy<Face>&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const MeshedSurfaceProxy<Face>&
|
||||
);
|
||||
|
||||
//- Write UnsortedMeshedSurface, the output is always sorted by zones.
|
||||
static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const UnsortedMeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -52,6 +52,14 @@ addNamedTemplatedToRunTimeSelectionTable
|
||||
fileExtension,
|
||||
ac
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
AC3DsurfaceFormat,
|
||||
labelledTri,
|
||||
fileExtension,
|
||||
ac
|
||||
);
|
||||
|
||||
// write MeshedSurfaceProxy
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
@ -72,6 +80,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
ac
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurfaceProxy,
|
||||
AC3DsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
ac
|
||||
);
|
||||
|
||||
|
||||
// write UnsortedMeshedSurface
|
||||
@ -93,6 +110,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
ac
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
AC3DsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
ac
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,6 +54,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
flma
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurfaceProxy,
|
||||
FLMAsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
flma
|
||||
);
|
||||
|
||||
|
||||
// write MeshedSurfaceProxy (comnpressed versions of above)
|
||||
@ -75,6 +84,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
flmaz
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurfaceProxy,
|
||||
FLMAZsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
flmaz
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,6 +203,7 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
|
||||
}
|
||||
|
||||
this->storedZoneToc().transfer(newZones);
|
||||
this->addZonesToFaces(); // for labelledTri
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -60,10 +60,10 @@ class GTSsurfaceFormat
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
GTSsurfaceFormat(const GTSsurfaceFormat<Face>&);
|
||||
GTSsurfaceFormat(const GTSsurfaceFormat<Face>&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const GTSsurfaceFormat<Face>&);
|
||||
void operator=(const GTSsurfaceFormat<Face>&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -94,10 +94,18 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Write MeshedSurface
|
||||
static void write(const fileName&, const MeshedSurface<Face>&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const MeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write UnsortedMeshedSurface, the output remains unsorted
|
||||
static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const UnsortedMeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -52,6 +52,14 @@ addNamedTemplatedToRunTimeSelectionTable
|
||||
fileExtension,
|
||||
gts
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
GTSsurfaceFormat,
|
||||
labelledTri,
|
||||
fileExtension,
|
||||
gts
|
||||
);
|
||||
|
||||
// write MeshedSurface
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
@ -72,6 +80,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
gts
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
GTSsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
gts
|
||||
);
|
||||
|
||||
// write UnsortedMeshedSurface
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
@ -92,6 +109,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
gts
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
GTSsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
gts
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +47,6 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
const fileName& filename
|
||||
)
|
||||
{
|
||||
const bool mustTriangulate = this->isTri();
|
||||
this->clear();
|
||||
|
||||
IFstream is(filename);
|
||||
@ -253,7 +252,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
}
|
||||
|
||||
|
||||
if (mustTriangulate)
|
||||
if (MeshedSurface<Face>::isTri())
|
||||
{
|
||||
dynFaces.append(triFace(f[0], f[1], f[2]));
|
||||
dynFaces.append(triFace(f[0], f[2], f[3]));
|
||||
@ -374,9 +373,8 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
}
|
||||
|
||||
this->sortFacesAndStore(dynFaces.xfer(), dynZones.xfer(), sorted);
|
||||
|
||||
// add zones, culling empty ones
|
||||
this->addZones(dynSizes, names, true);
|
||||
this->addZones(dynSizes, names, true); // add zones, cull empty ones
|
||||
this->addZonesToFaces(); // for labelledTri
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -68,10 +68,10 @@ class NASsurfaceFormat
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
NASsurfaceFormat(const NASsurfaceFormat<Face>&);
|
||||
NASsurfaceFormat(const NASsurfaceFormat<Face>&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const NASsurfaceFormat<Face>&);
|
||||
void operator=(const NASsurfaceFormat<Face>&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,7 +35,7 @@ namespace Foam
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
// read MeshedSurface - .bdf (Bulk Data Format)
|
||||
// read MeshedSurface - .bdf (Bulk Data Format) and nas (Nastran)
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
@ -53,7 +53,6 @@ addNamedTemplatedToRunTimeSelectionTable
|
||||
nas
|
||||
);
|
||||
|
||||
// read MeshedSurface - .nas (Nastran)
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
@ -71,6 +70,23 @@ addNamedTemplatedToRunTimeSelectionTable
|
||||
nas
|
||||
);
|
||||
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
NASsurfaceFormat,
|
||||
labelledTri,
|
||||
fileExtension,
|
||||
bdf
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
NASsurfaceFormat,
|
||||
labelledTri,
|
||||
fileExtension,
|
||||
nas
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -51,7 +51,6 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
|
||||
const fileName& filename
|
||||
)
|
||||
{
|
||||
const bool mustTriangulate = this->isTri();
|
||||
this->clear();
|
||||
|
||||
IFstream is(filename);
|
||||
@ -173,7 +172,7 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
|
||||
|
||||
labelUList& f = static_cast<labelUList&>(dynVertices);
|
||||
|
||||
if (mustTriangulate && f.size() > 3)
|
||||
if (MeshedSurface<Face>::isTri() && f.size() > 3)
|
||||
{
|
||||
// simple face triangulation about f[0]
|
||||
// points may be incomplete
|
||||
@ -200,9 +199,9 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
|
||||
this->storedPoints().transfer(dynPoints);
|
||||
|
||||
this->sortFacesAndStore(dynFaces.xfer(), dynZones.xfer(), sorted);
|
||||
this->addZones(dynSizes, dynNames, true); // add zones, cull empty ones
|
||||
this->addZonesToFaces(); // for labelledTri
|
||||
|
||||
// add zones, culling empty ones
|
||||
this->addZones(dynSizes, dynNames, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -60,10 +60,10 @@ class OBJsurfaceFormat
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
OBJsurfaceFormat(const OBJsurfaceFormat<Face>&);
|
||||
OBJsurfaceFormat(const OBJsurfaceFormat<Face>&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const OBJsurfaceFormat<Face>&);
|
||||
void operator=(const OBJsurfaceFormat<Face>&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -94,7 +94,11 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Write surface mesh components by proxy
|
||||
static void write(const fileName&, const MeshedSurfaceProxy<Face>&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const MeshedSurfaceProxy<Face>&
|
||||
);
|
||||
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -52,6 +52,14 @@ addNamedTemplatedToRunTimeSelectionTable
|
||||
fileExtension,
|
||||
obj
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
OBJsurfaceFormat,
|
||||
labelledTri,
|
||||
fileExtension,
|
||||
obj
|
||||
);
|
||||
|
||||
// write MeshedSurfaceProxy
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
@ -72,6 +80,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
obj
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurfaceProxy,
|
||||
OBJsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
obj
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +50,6 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
|
||||
const fileName& filename
|
||||
)
|
||||
{
|
||||
const bool mustTriangulate = this->isTri();
|
||||
this->clear();
|
||||
|
||||
IFstream is(filename);
|
||||
@ -116,7 +115,7 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
|
||||
|
||||
labelUList& f = static_cast<labelUList&>(verts);
|
||||
|
||||
if (mustTriangulate && f.size() > 3)
|
||||
if (MeshedSurface<Face>::isTri() && f.size() > 3)
|
||||
{
|
||||
// simple face triangulation about f[0]
|
||||
// cannot use face::triangulation (points may be incomplete)
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -68,10 +68,10 @@ class OFFsurfaceFormat
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
OFFsurfaceFormat(const OFFsurfaceFormat&);
|
||||
OFFsurfaceFormat(const OFFsurfaceFormat&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const OFFsurfaceFormat&);
|
||||
void operator=(const OFFsurfaceFormat&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -102,7 +102,11 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Write surface mesh components by proxy
|
||||
static void write(const fileName&, const MeshedSurfaceProxy<Face>&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const MeshedSurfaceProxy<Face>&
|
||||
);
|
||||
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -52,6 +52,14 @@ addNamedTemplatedToRunTimeSelectionTable
|
||||
fileExtension,
|
||||
off
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
OFFsurfaceFormat,
|
||||
labelledTri,
|
||||
fileExtension,
|
||||
off
|
||||
);
|
||||
|
||||
// write MeshedSurfaceProxy
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
@ -72,7 +80,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
off
|
||||
);
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurfaceProxy,
|
||||
OFFsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
off
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,9 +25,7 @@ License
|
||||
|
||||
#include "SMESHsurfaceFormat.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
#include "Ostream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -58,7 +56,6 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
||||
|
||||
const bool useFaceMap = (surf.useFaceMap() && zones.size() > 1);
|
||||
|
||||
|
||||
OFstream os(filename);
|
||||
if (!os.good())
|
||||
{
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -64,10 +64,10 @@ class SMESHsurfaceFormat
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
SMESHsurfaceFormat(const SMESHsurfaceFormat<Face>&);
|
||||
SMESHsurfaceFormat(const SMESHsurfaceFormat<Face>&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const SMESHsurfaceFormat<Face>&);
|
||||
void operator=(const SMESHsurfaceFormat<Face>&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -86,7 +86,11 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Write surface mesh components by proxy
|
||||
static void write(const fileName&, const MeshedSurfaceProxy<Face>&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const MeshedSurfaceProxy<Face>&
|
||||
);
|
||||
|
||||
//- Write object
|
||||
virtual void write(const fileName& name) const
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -54,6 +54,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
smesh
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurfaceProxy,
|
||||
SMESHsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
smesh
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +79,6 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
||||
const fileName& filename
|
||||
)
|
||||
{
|
||||
const bool mustTriangulate = this->isTri();
|
||||
this->clear();
|
||||
|
||||
fileName baseName = filename.lessExt();
|
||||
@ -194,24 +193,19 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
||||
}
|
||||
|
||||
SubList<label> vertices(vertexLabels, vertexLabels.size());
|
||||
if (mustTriangulate && nLabels > 3)
|
||||
if (MeshedSurface<Face>::isTri() && nLabels > 3)
|
||||
{
|
||||
// face needs triangulation
|
||||
face f(vertices);
|
||||
|
||||
faceList triFaces(f.nTriangles());
|
||||
faceList trias(f.nTriangles());
|
||||
label nTri = 0;
|
||||
f.triangles(this->points(), nTri, triFaces);
|
||||
f.triangles(this->points(), nTri, trias);
|
||||
|
||||
forAll(triFaces, facei)
|
||||
forAll(trias, facei)
|
||||
{
|
||||
// a triangular face, but not yet a triFace
|
||||
dynFaces.append
|
||||
(
|
||||
triFace
|
||||
(
|
||||
static_cast<labelUList&>(triFaces[facei])
|
||||
)
|
||||
);
|
||||
// a triangular 'face', convert to 'triFace' etc
|
||||
dynFaces.append(Face(trias[facei]));
|
||||
dynZones.append(zoneI);
|
||||
dynSizes[zoneI]++;
|
||||
}
|
||||
@ -228,8 +222,9 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
||||
|
||||
this->sortFacesAndStore(dynFaces.xfer(), dynZones.xfer(), sorted);
|
||||
|
||||
// add zones, culling empty ones
|
||||
this->addZones(dynSizes, dynNames, true);
|
||||
this->addZones(dynSizes, dynNames, true); // add zones, cull empty ones
|
||||
this->addZonesToFaces(); // for labelledTri
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -108,7 +108,11 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Write surface mesh components by proxy
|
||||
static void write(const fileName&, const MeshedSurfaceProxy<Face>&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const MeshedSurfaceProxy<Face>&
|
||||
);
|
||||
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -52,6 +52,14 @@ addNamedTemplatedToRunTimeSelectionTable
|
||||
fileExtension,
|
||||
inp
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
STARCDsurfaceFormat,
|
||||
labelledTri,
|
||||
fileExtension,
|
||||
inp
|
||||
);
|
||||
|
||||
// write MeshedSurfaceProxy
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
@ -72,7 +80,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
inp
|
||||
);
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurfaceProxy,
|
||||
STARCDsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
inp
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "STLsurfaceFormat.H"
|
||||
#include "ListOps.H"
|
||||
#include "labelledTri.H"
|
||||
#include "triPointRef.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
@ -51,20 +51,17 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
|
||||
const point& p0 = pointLst[f[0]];
|
||||
for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
|
||||
{
|
||||
label fp2 = f.fcIndex(fp1);
|
||||
const label fp2 = f.fcIndex(fp1);
|
||||
|
||||
const point& p1 = pointLst[f[fp1]];
|
||||
const point& p2 = pointLst[f[fp2]];
|
||||
|
||||
// write STL triangle
|
||||
os << " facet normal "
|
||||
<< norm.x() << ' ' << norm.y() << ' ' << norm.z() << nl
|
||||
<< " outer loop\n"
|
||||
<< " vertex " << p0.x() << ' ' << p0.y() << ' ' << p0.z() << nl
|
||||
<< " vertex " << p1.x() << ' ' << p1.y() << ' ' << p1.z() << nl
|
||||
<< " vertex " << p2.x() << ' ' << p2.y() << ' ' << p2.z() << nl
|
||||
<< " endloop\n"
|
||||
<< " endfacet" << endl;
|
||||
// Write ASCII
|
||||
STLtriangle::write
|
||||
(
|
||||
os,
|
||||
norm,
|
||||
p0,
|
||||
pointLst[f[fp1]],
|
||||
pointLst[f[fp2]]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,18 +89,17 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
|
||||
const point& p0 = pointLst[f[0]];
|
||||
for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
|
||||
{
|
||||
label fp2 = f.fcIndex(fp1);
|
||||
const label fp2 = f.fcIndex(fp1);
|
||||
|
||||
STLtriangle stlTri
|
||||
// Write BINARY
|
||||
STLtriangle
|
||||
(
|
||||
norm,
|
||||
p0,
|
||||
pointLst[f[fp1]],
|
||||
pointLst[f[fp2]],
|
||||
zoneI
|
||||
);
|
||||
|
||||
stlTri.write(os);
|
||||
).write(os);
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,7 +127,7 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
|
||||
this->clear();
|
||||
|
||||
// read in the values
|
||||
STLsurfaceFormatCore reader(filename);
|
||||
STLReader reader(filename);
|
||||
|
||||
// transfer points
|
||||
this->storedPoints().transfer(reader.points());
|
||||
@ -180,13 +176,13 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
|
||||
{
|
||||
this->addZones(sizes);
|
||||
}
|
||||
|
||||
this->addZonesToFaces(); // for labelledTri
|
||||
this->stitchFaces(SMALL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STLsurfaceFormat<Face>::writeAscii
|
||||
(
|
||||
@ -271,23 +267,9 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBinary
|
||||
|
||||
const bool useFaceMap = (surf.useFaceMap() && zones.size() > 1);
|
||||
|
||||
|
||||
unsigned int nTris = 0;
|
||||
if (MeshedSurface<Face>::isTri())
|
||||
{
|
||||
nTris = faceLst.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
// count triangles for on-the-fly triangulation
|
||||
forAll(faceLst, facei)
|
||||
{
|
||||
nTris += faceLst[facei].size() - 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Write the STL header
|
||||
STLsurfaceFormatCore::writeHeaderBINARY(os, nTris);
|
||||
unsigned int nTris = surf.nTriangles();
|
||||
STLCore::writeBinaryHeader(os, nTris);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(zones, zoneI)
|
||||
@ -345,7 +327,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeAscii
|
||||
// a single zone - we can skip sorting
|
||||
if (surf.zoneToc().size() == 1)
|
||||
{
|
||||
os << "solid " << surf.zoneToc()[0].name() << endl;
|
||||
os << "solid " << surf.zoneToc()[0].name() << nl;
|
||||
forAll(faceLst, facei)
|
||||
{
|
||||
writeShell(os, pointLst, faceLst[facei]);
|
||||
@ -391,22 +373,9 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBinary
|
||||
const List<Face>& faceLst = surf.surfFaces();
|
||||
const List<label>& zoneIds = surf.zoneIds();
|
||||
|
||||
unsigned int nTris = 0;
|
||||
if (MeshedSurface<Face>::isTri())
|
||||
{
|
||||
nTris = faceLst.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
// count triangles for on-the-fly triangulation
|
||||
forAll(faceLst, facei)
|
||||
{
|
||||
nTris += faceLst[facei].size() - 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Write the STL header
|
||||
STLsurfaceFormatCore::writeHeaderBINARY(os, nTris);
|
||||
unsigned int nTris = surf.nTriangles();
|
||||
STLCore::writeBinaryHeader(os, nTris);
|
||||
|
||||
// always write unsorted
|
||||
forAll(faceLst, facei)
|
||||
@ -429,10 +398,20 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::write
|
||||
const MeshedSurfaceProxy<Face>& surf
|
||||
)
|
||||
{
|
||||
const word ext = filename.ext();
|
||||
// Auto-detect ASCII/BINARY extension
|
||||
write(filename, surf, STLCore::DETECT);
|
||||
}
|
||||
|
||||
// handle 'stlb' as binary directly
|
||||
if (ext == "stlb")
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STLsurfaceFormat<Face>::write
|
||||
(
|
||||
const fileName& filename,
|
||||
const MeshedSurfaceProxy<Face>& surf,
|
||||
const STLFormat& format
|
||||
)
|
||||
{
|
||||
if (STLCore::isBinaryName(filename, format))
|
||||
{
|
||||
writeBinary(filename, surf);
|
||||
}
|
||||
@ -450,10 +429,20 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::write
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
word ext = filename.ext();
|
||||
// Auto-detect ASCII/BINARY extension
|
||||
write(filename, surf, STLCore::DETECT);
|
||||
}
|
||||
|
||||
// handle 'stlb' as binary directly
|
||||
if (ext == "stlb")
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STLsurfaceFormat<Face>::write
|
||||
(
|
||||
const fileName& filename,
|
||||
const UnsortedMeshedSurface<Face>& surf,
|
||||
const STLFormat& format
|
||||
)
|
||||
{
|
||||
if (STLCore::isBinaryName(filename, format))
|
||||
{
|
||||
writeBinary(filename, surf);
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::fileFormats::STLsurfaceFormat
|
||||
|
||||
Description
|
||||
Provide a means of reading/writing STL files (ASCII and binary).
|
||||
Provide a means of reading/writing STL files (ASCII and BINARY).
|
||||
|
||||
Note
|
||||
For efficiency, the zones are sorted before creating the faces.
|
||||
@ -40,7 +40,7 @@ SourceFiles
|
||||
#ifndef STLsurfaceFormat_H
|
||||
#define STLsurfaceFormat_H
|
||||
|
||||
#include "STLsurfaceFormatCore.H"
|
||||
#include "STLReader.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "MeshedSurfaceProxy.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
@ -59,7 +59,8 @@ namespace fileFormats
|
||||
template<class Face>
|
||||
class STLsurfaceFormat
|
||||
:
|
||||
public MeshedSurface<Face>
|
||||
public MeshedSurface<Face>,
|
||||
public STLCore
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
@ -80,11 +81,12 @@ class STLsurfaceFormat
|
||||
const label zoneI
|
||||
);
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
STLsurfaceFormat(const STLsurfaceFormat<Face>&);
|
||||
STLsurfaceFormat(const STLsurfaceFormat<Face>&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const STLsurfaceFormat<Face>&);
|
||||
void operator=(const STLsurfaceFormat<Face>&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -130,7 +132,20 @@ public:
|
||||
|
||||
//- Write surface mesh components by proxy
|
||||
// as ASCII or BINARY, depending on the extension
|
||||
static void write(const fileName&, const MeshedSurfaceProxy<Face>&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const MeshedSurfaceProxy<Face>&
|
||||
);
|
||||
|
||||
//- Write surface mesh components by proxy
|
||||
// as ASCII or BINARY or dependent on the extension
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const MeshedSurfaceProxy<Face>&,
|
||||
const STLFormat&
|
||||
);
|
||||
|
||||
//- Write UnsortedMeshedSurface (as ASCII) sorted by zone
|
||||
static void writeAscii
|
||||
@ -148,7 +163,20 @@ public:
|
||||
|
||||
//- Write UnsortedMeshedSurface
|
||||
// as ASCII or BINARY, depending on the extension
|
||||
static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const UnsortedMeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write UnsortedMeshedSurface
|
||||
// as ASCII or BINARY or dependent on the extension
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const UnsortedMeshedSurface<Face>&,
|
||||
const STLFormat&
|
||||
);
|
||||
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -24,6 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "STLsurfaceFormat.H"
|
||||
#include "labelledTri.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
@ -52,6 +53,14 @@ addNamedTemplatedToRunTimeSelectionTable
|
||||
fileExtension,
|
||||
stl
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
STLsurfaceFormat,
|
||||
labelledTri,
|
||||
fileExtension,
|
||||
stl
|
||||
);
|
||||
|
||||
// read MeshedSurface (binary)
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
@ -70,6 +79,14 @@ addNamedTemplatedToRunTimeSelectionTable
|
||||
fileExtension,
|
||||
stlb
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
STLsurfaceFormat,
|
||||
labelledTri,
|
||||
fileExtension,
|
||||
stlb
|
||||
);
|
||||
|
||||
|
||||
// write MeshedSurfaceProxy (ascii)
|
||||
@ -91,6 +108,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
stl
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurfaceProxy,
|
||||
STLsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
stl
|
||||
);
|
||||
|
||||
// write MeshedSurfaceProxy (binary)
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
@ -111,6 +137,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
stlb
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurfaceProxy,
|
||||
STLsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
stlb
|
||||
);
|
||||
|
||||
// write UnsortedMeshedSurface (ascii)
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
@ -131,6 +166,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
stl
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
STLsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
stl
|
||||
);
|
||||
|
||||
// write UnsortedMeshedSurface (binary)
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
@ -151,6 +195,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
stlb
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
STLsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
stlb
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,15 +99,26 @@ public:
|
||||
|
||||
//- Return the local file name (within time directory)
|
||||
// NEEDS FIXING
|
||||
static fileName localMeshFileName(const word& surfName="");
|
||||
static fileName localMeshFileName
|
||||
(
|
||||
const word& surfName = word::null
|
||||
);
|
||||
|
||||
//- Find instance with surfName
|
||||
// NEEDS FIXING
|
||||
static fileName findMeshInstance(const Time&, const word& surfName="");
|
||||
static fileName findMeshInstance
|
||||
(
|
||||
const Time&,
|
||||
const word& surfName = word::null
|
||||
);
|
||||
|
||||
//- Find mesh file with surfName
|
||||
// NEEDS FIXING
|
||||
static fileName findMeshFile(const Time&, const word& surfName="");
|
||||
static fileName findMeshFile
|
||||
(
|
||||
const Time&,
|
||||
const word& surfName = word::null
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
@ -118,6 +129,7 @@ public:
|
||||
|
||||
//- Destructor
|
||||
virtual ~surfaceFormatsCore();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "TRIsurfaceFormat.H"
|
||||
#include "ListOps.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -51,7 +51,7 @@ inline void Foam::fileFormats::TRIsurfaceFormat<Face>::writeShell
|
||||
<< p1.x() << ' ' << p1.y() << ' ' << p1.z() << ' '
|
||||
<< p2.x() << ' ' << p2.y() << ' ' << p2.z() << ' '
|
||||
// zone as colour
|
||||
<< "0x" << hex << zoneI << dec << endl;
|
||||
<< "0x" << hex << zoneI << dec << nl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,6 +120,7 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
|
||||
this->storedFaces().transfer(faceLst);
|
||||
|
||||
this->addZones(sizes);
|
||||
this->addZonesToFaces(); // for labelledTri
|
||||
this->stitchFaces(SMALL);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -71,10 +71,10 @@ class TRIsurfaceFormat
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
TRIsurfaceFormat(const TRIsurfaceFormat<Face>&);
|
||||
TRIsurfaceFormat(const TRIsurfaceFormat<Face>&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const TRIsurfaceFormat<Face>&);
|
||||
void operator=(const TRIsurfaceFormat<Face>&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -105,11 +105,19 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Write surface mesh components by proxy
|
||||
static void write(const fileName&, const MeshedSurfaceProxy<Face>&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const MeshedSurfaceProxy<Face>&
|
||||
);
|
||||
|
||||
//- Write UnsortedMeshedSurface,
|
||||
// by default the output is not sorted by zones
|
||||
static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const UnsortedMeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
@ -38,10 +38,6 @@ SourceFiles
|
||||
#include "surfaceFormatsCore.H"
|
||||
#include "triFace.H"
|
||||
|
||||
#include "IFstream.H"
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -74,10 +70,10 @@ class TRIsurfaceFormatCore
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
TRIsurfaceFormatCore(const TRIsurfaceFormatCore&);
|
||||
TRIsurfaceFormatCore(const TRIsurfaceFormatCore&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const TRIsurfaceFormatCore&);
|
||||
void operator=(const TRIsurfaceFormatCore&) = delete;
|
||||
|
||||
bool read(const fileName&);
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -52,6 +52,14 @@ addNamedTemplatedToRunTimeSelectionTable
|
||||
fileExtension,
|
||||
tri
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
TRIsurfaceFormat,
|
||||
labelledTri,
|
||||
fileExtension,
|
||||
tri
|
||||
);
|
||||
|
||||
// write MeshedSurfaceProxy
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
@ -72,6 +80,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
tri
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurfaceProxy,
|
||||
TRIsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
tri
|
||||
);
|
||||
|
||||
// write UnsortedMeshedSurface
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
@ -92,6 +109,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
tri
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
TRIsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
tri
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ License
|
||||
#include "VTKsurfaceFormat.H"
|
||||
#include "vtkUnstructuredReader.H"
|
||||
#include "scalarIOField.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -69,7 +70,6 @@ bool Foam::fileFormats::VTKsurfaceFormat<Face>::read
|
||||
const fileName& filename
|
||||
)
|
||||
{
|
||||
const bool mustTriangulate = this->isTri();
|
||||
this->clear();
|
||||
|
||||
IFstream is(filename);
|
||||
@ -148,18 +148,21 @@ bool Foam::fileFormats::VTKsurfaceFormat<Face>::read
|
||||
}
|
||||
|
||||
|
||||
// See if needs triangulation
|
||||
// Check if it needs triangulation
|
||||
label nTri = 0;
|
||||
if (mustTriangulate)
|
||||
if (MeshedSurface<Face>::isTri())
|
||||
{
|
||||
forAll(faces, facei)
|
||||
{
|
||||
nTri += faces[facei].size()-2;
|
||||
nTri += faces[facei].nTriangles();
|
||||
}
|
||||
}
|
||||
|
||||
if (nTri > 0)
|
||||
if (nTri > faces.size())
|
||||
{
|
||||
// We are here if the target surface needs triangles and
|
||||
// the source surface has non-triangles
|
||||
|
||||
DynamicList<Face> dynFaces(nTri);
|
||||
DynamicList<label> dynZones(nTri);
|
||||
forAll(faces, facei)
|
||||
@ -207,6 +210,7 @@ bool Foam::fileFormats::VTKsurfaceFormat<Face>::read
|
||||
// add zones, culling empty ones
|
||||
this->addZones(zoneSizes, zoneNames, true);
|
||||
}
|
||||
this->addZonesToFaces(); // for labelledTri
|
||||
|
||||
// transfer to normal lists
|
||||
this->storedPoints().transfer(reader.points());
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -64,10 +64,10 @@ class VTKsurfaceFormat
|
||||
static void writeHeaderPolygons(Ostream&, const UList<Face>&);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
VTKsurfaceFormat(const VTKsurfaceFormat<Face>&);
|
||||
VTKsurfaceFormat(const VTKsurfaceFormat<Face>&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const VTKsurfaceFormat<Face>&);
|
||||
void operator=(const VTKsurfaceFormat<Face>&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -89,6 +89,7 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~VTKsurfaceFormat()
|
||||
{}
|
||||
@ -99,10 +100,18 @@ public:
|
||||
// Write
|
||||
|
||||
//- Write surface mesh components by proxy
|
||||
static void write(const fileName&, const MeshedSurfaceProxy<Face>&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const MeshedSurfaceProxy<Face>&
|
||||
);
|
||||
|
||||
//- Write UnsortedMeshedSurface, the output remains unsorted
|
||||
static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const UnsortedMeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
@ -35,9 +35,8 @@ SourceFiles
|
||||
#ifndef VTKsurfaceFormatCore_H
|
||||
#define VTKsurfaceFormatCore_H
|
||||
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "Ostream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -52,6 +52,14 @@ addNamedTemplatedToRunTimeSelectionTable
|
||||
fileExtension,
|
||||
vtk
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
VTKsurfaceFormat,
|
||||
labelledTri,
|
||||
fileExtension,
|
||||
vtk
|
||||
);
|
||||
|
||||
// write MeshedSurfaceProxy
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
@ -72,6 +80,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
vtk
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurfaceProxy,
|
||||
VTKsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
vtk
|
||||
);
|
||||
|
||||
// write UnsortedMeshedSurface
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
@ -92,7 +109,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
vtk
|
||||
);
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
VTKsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
vtk
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,12 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "X3DsurfaceFormat.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -55,7 +50,7 @@ void Foam::fileFormats::X3DsurfaceFormat<Face>::write
|
||||
const List<surfZone>& zones =
|
||||
(
|
||||
surf.surfZones().empty()
|
||||
? surfaceFormatsCore::oneZone(faceLst, "")
|
||||
? surfaceFormatsCore::oneZone(faceLst, word::null)
|
||||
: surf.surfZones()
|
||||
);
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -60,10 +60,10 @@ class X3DsurfaceFormat
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
X3DsurfaceFormat(const X3DsurfaceFormat<Face>&);
|
||||
X3DsurfaceFormat(const X3DsurfaceFormat<Face>&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const X3DsurfaceFormat<Face>&);
|
||||
void operator=(const X3DsurfaceFormat<Face>&) = delete;
|
||||
|
||||
public:
|
||||
|
||||
@ -81,9 +81,14 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Write surface mesh components by proxy
|
||||
static void write(const fileName&, const MeshedSurfaceProxy<Face>&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const MeshedSurfaceProxy<Face>&
|
||||
);
|
||||
|
||||
//- Write object file
|
||||
|
||||
//- Write object
|
||||
virtual void write(const fileName& name) const
|
||||
{
|
||||
write(name, MeshedSurfaceProxy<Face>(*this));
|
||||
|
||||
@ -35,9 +35,8 @@ SourceFiles
|
||||
#ifndef X3DsurfaceFormatCore_H
|
||||
#define X3DsurfaceFormatCore_H
|
||||
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "Ostream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -53,6 +53,15 @@ addNamedTemplatedToMemberFunctionSelectionTable
|
||||
fileExtension,
|
||||
x3d
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurfaceProxy,
|
||||
X3DsurfaceFormat,
|
||||
labelledTri,
|
||||
write,
|
||||
fileExtension,
|
||||
x3d
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,3 @@
|
||||
triSurfaceTools = triSurface/triSurfaceTools
|
||||
geometricSurfacePatch = triSurface/geometricSurfacePatch
|
||||
|
||||
faceTriangulation/faceTriangulation.C
|
||||
meshTriangulation/meshTriangulation.C
|
||||
|
||||
triSurface/triSurface.C
|
||||
triSurface/triSurfaceAddressing.C
|
||||
triSurface/stitchTriangles.C
|
||||
@ -31,9 +25,6 @@ $(interfaces)/NAS/readNAS.C
|
||||
|
||||
triSurface/geometricSurfacePatch/geometricSurfacePatch.C
|
||||
triSurface/surfacePatch/surfacePatch.C
|
||||
triSurface/surfacePatch/surfacePatchIOList.C
|
||||
|
||||
tools/labelledTri/sortLabelledTri.C
|
||||
|
||||
triSurfaceFields/triSurfaceFields.C
|
||||
|
||||
|
||||
@ -1,511 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "meshTriangulation.H"
|
||||
#include "polyMesh.H"
|
||||
#include "faceTriangulation.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::meshTriangulation::isInternalFace
|
||||
(
|
||||
const primitiveMesh& mesh,
|
||||
const boolList& includedCell,
|
||||
const label facei
|
||||
)
|
||||
{
|
||||
if (mesh.isInternalFace(facei))
|
||||
{
|
||||
label own = mesh.faceOwner()[facei];
|
||||
label nei = mesh.faceNeighbour()[facei];
|
||||
|
||||
if (includedCell[own] && includedCell[nei])
|
||||
{
|
||||
// Neighbouring cell will get included in subset
|
||||
// as well so face is internal.
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshTriangulation::getFaces
|
||||
(
|
||||
const primitiveMesh& mesh,
|
||||
const boolList& includedCell,
|
||||
boolList& faceIsCut,
|
||||
label& nFaces,
|
||||
label& nInternalFaces
|
||||
)
|
||||
{
|
||||
// All faces to be triangulated.
|
||||
faceIsCut.setSize(mesh.nFaces());
|
||||
faceIsCut = false;
|
||||
|
||||
nFaces = 0;
|
||||
nInternalFaces = 0;
|
||||
|
||||
forAll(includedCell, celli)
|
||||
{
|
||||
// Include faces of cut cells only.
|
||||
if (includedCell[celli])
|
||||
{
|
||||
const labelList& cFaces = mesh.cells()[celli];
|
||||
|
||||
forAll(cFaces, i)
|
||||
{
|
||||
label facei = cFaces[i];
|
||||
|
||||
if (!faceIsCut[facei])
|
||||
{
|
||||
// First visit of face.
|
||||
nFaces++;
|
||||
faceIsCut[facei] = true;
|
||||
|
||||
// See if would become internal or external face
|
||||
if (isInternalFace(mesh, includedCell, facei))
|
||||
{
|
||||
nInternalFaces++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Pout<< "Subset consists of " << nFaces << " faces out of " << mesh.nFaces()
|
||||
<< " of which " << nInternalFaces << " are internal" << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshTriangulation::insertTriangles
|
||||
(
|
||||
const triFaceList& faceTris,
|
||||
const label facei,
|
||||
const label regionI,
|
||||
const bool reverse,
|
||||
|
||||
List<labelledTri>& triangles,
|
||||
label& triI
|
||||
)
|
||||
{
|
||||
// Copy triangles. Optionally reverse them
|
||||
forAll(faceTris, i)
|
||||
{
|
||||
const triFace& f = faceTris[i];
|
||||
|
||||
labelledTri& tri = triangles[triI];
|
||||
|
||||
if (reverse)
|
||||
{
|
||||
tri[0] = f[0];
|
||||
tri[2] = f[1];
|
||||
tri[1] = f[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
tri[0] = f[0];
|
||||
tri[1] = f[1];
|
||||
tri[2] = f[2];
|
||||
}
|
||||
|
||||
tri.region() = regionI;
|
||||
|
||||
faceMap_[triI] = facei;
|
||||
|
||||
triI++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Null constructor
|
||||
Foam::meshTriangulation::meshTriangulation()
|
||||
:
|
||||
triSurface(),
|
||||
nInternalFaces_(0),
|
||||
faceMap_()
|
||||
{}
|
||||
|
||||
|
||||
// Construct from faces of cells
|
||||
Foam::meshTriangulation::meshTriangulation
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label internalFacesPatch,
|
||||
const boolList& includedCell,
|
||||
const bool faceCentreDecomposition
|
||||
)
|
||||
:
|
||||
triSurface(),
|
||||
nInternalFaces_(0),
|
||||
faceMap_()
|
||||
{
|
||||
const faceList& faces = mesh.faces();
|
||||
const pointField& points = mesh.points();
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
// All faces to be triangulated.
|
||||
boolList faceIsCut;
|
||||
label nFaces, nInternalFaces;
|
||||
|
||||
getFaces
|
||||
(
|
||||
mesh,
|
||||
includedCell,
|
||||
faceIsCut,
|
||||
nFaces,
|
||||
nInternalFaces
|
||||
);
|
||||
|
||||
|
||||
// Find upper limit for number of triangles
|
||||
// (can be less if triangulation fails)
|
||||
label nTotTri = 0;
|
||||
|
||||
if (faceCentreDecomposition)
|
||||
{
|
||||
forAll(faceIsCut, facei)
|
||||
{
|
||||
if (faceIsCut[facei])
|
||||
{
|
||||
nTotTri += faces[facei].size();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(faceIsCut, facei)
|
||||
{
|
||||
if (faceIsCut[facei])
|
||||
{
|
||||
nTotTri += faces[facei].nTriangles(points);
|
||||
}
|
||||
}
|
||||
}
|
||||
Pout<< "nTotTri : " << nTotTri << endl;
|
||||
|
||||
|
||||
// Storage for new and old points (only for faceCentre decomposition;
|
||||
// for triangulation uses only existing points)
|
||||
pointField newPoints;
|
||||
|
||||
if (faceCentreDecomposition)
|
||||
{
|
||||
newPoints.setSize(mesh.nPoints() + faces.size());
|
||||
forAll(mesh.points(), pointi)
|
||||
{
|
||||
newPoints[pointi] = mesh.points()[pointi];
|
||||
}
|
||||
// Face centres
|
||||
forAll(faces, facei)
|
||||
{
|
||||
newPoints[mesh.nPoints() + facei] = mesh.faceCentres()[facei];
|
||||
}
|
||||
}
|
||||
|
||||
// Storage for all triangles
|
||||
List<labelledTri> triangles(nTotTri);
|
||||
faceMap_.setSize(nTotTri);
|
||||
label triI = 0;
|
||||
|
||||
|
||||
if (faceCentreDecomposition)
|
||||
{
|
||||
// Decomposition around face centre
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// Triangulate internal faces
|
||||
forAll(faceIsCut, facei)
|
||||
{
|
||||
if (faceIsCut[facei] && isInternalFace(mesh, includedCell, facei))
|
||||
{
|
||||
// Face was internal to the mesh and will be 'internal' to
|
||||
// the surface.
|
||||
|
||||
// Triangulate face
|
||||
const face& f = faces[facei];
|
||||
|
||||
forAll(f, fp)
|
||||
{
|
||||
faceMap_[triI] = facei;
|
||||
|
||||
triangles[triI++] =
|
||||
labelledTri
|
||||
(
|
||||
f[fp],
|
||||
f.nextLabel(fp),
|
||||
mesh.nPoints() + facei, // face centre
|
||||
internalFacesPatch
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
nInternalFaces_ = triI;
|
||||
|
||||
|
||||
// Triangulate external faces
|
||||
forAll(faceIsCut, facei)
|
||||
{
|
||||
if (faceIsCut[facei] && !isInternalFace(mesh, includedCell, facei))
|
||||
{
|
||||
// Face will become outside of the surface.
|
||||
|
||||
label patchi = -1;
|
||||
bool reverse = false;
|
||||
|
||||
if (mesh.isInternalFace(facei))
|
||||
{
|
||||
patchi = internalFacesPatch;
|
||||
|
||||
// Check orientation. Check which side of the face gets
|
||||
// included (note: only one side is).
|
||||
if (includedCell[mesh.faceOwner()[facei]])
|
||||
{
|
||||
reverse = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
reverse = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Face was already outside so orientation ok.
|
||||
|
||||
patchi = patches.whichPatch(facei);
|
||||
|
||||
reverse = false;
|
||||
}
|
||||
|
||||
|
||||
// Triangulate face
|
||||
const face& f = faces[facei];
|
||||
|
||||
if (reverse)
|
||||
{
|
||||
forAll(f, fp)
|
||||
{
|
||||
faceMap_[triI] = facei;
|
||||
|
||||
triangles[triI++] =
|
||||
labelledTri
|
||||
(
|
||||
f.nextLabel(fp),
|
||||
f[fp],
|
||||
mesh.nPoints() + facei, // face centre
|
||||
patchi
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(f, fp)
|
||||
{
|
||||
faceMap_[triI] = facei;
|
||||
|
||||
triangles[triI++] =
|
||||
labelledTri
|
||||
(
|
||||
f[fp],
|
||||
f.nextLabel(fp),
|
||||
mesh.nPoints() + facei, // face centre
|
||||
patchi
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Triangulation using existing vertices
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// Triangulate internal faces
|
||||
forAll(faceIsCut, facei)
|
||||
{
|
||||
if (faceIsCut[facei] && isInternalFace(mesh, includedCell, facei))
|
||||
{
|
||||
// Face was internal to the mesh and will be 'internal' to
|
||||
// the surface.
|
||||
|
||||
// Triangulate face. Fall back to naive triangulation if failed.
|
||||
faceTriangulation faceTris(points, faces[facei], true);
|
||||
|
||||
if (faceTris.empty())
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Could not find triangulation for face " << facei
|
||||
<< " vertices " << faces[facei] << " coords "
|
||||
<< IndirectList<point>(points, faces[facei])() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Copy triangles. Make them internalFacesPatch
|
||||
insertTriangles
|
||||
(
|
||||
faceTris,
|
||||
facei,
|
||||
internalFacesPatch,
|
||||
false, // no reverse
|
||||
|
||||
triangles,
|
||||
triI
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
nInternalFaces_ = triI;
|
||||
|
||||
|
||||
// Triangulate external faces
|
||||
forAll(faceIsCut, facei)
|
||||
{
|
||||
if (faceIsCut[facei] && !isInternalFace(mesh, includedCell, facei))
|
||||
{
|
||||
// Face will become outside of the surface.
|
||||
|
||||
label patchi = -1;
|
||||
bool reverse = false;
|
||||
|
||||
if (mesh.isInternalFace(facei))
|
||||
{
|
||||
patchi = internalFacesPatch;
|
||||
|
||||
// Check orientation. Check which side of the face gets
|
||||
// included (note: only one side is).
|
||||
if (includedCell[mesh.faceOwner()[facei]])
|
||||
{
|
||||
reverse = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
reverse = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Face was already outside so orientation ok.
|
||||
|
||||
patchi = patches.whichPatch(facei);
|
||||
|
||||
reverse = false;
|
||||
}
|
||||
|
||||
// Triangulate face
|
||||
faceTriangulation faceTris(points, faces[facei], true);
|
||||
|
||||
if (faceTris.empty())
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Could not find triangulation for face " << facei
|
||||
<< " vertices " << faces[facei] << " coords "
|
||||
<< IndirectList<point>(points, faces[facei])() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Copy triangles. Optionally reverse them
|
||||
insertTriangles
|
||||
(
|
||||
faceTris,
|
||||
facei,
|
||||
patchi,
|
||||
reverse, // whether to reverse
|
||||
|
||||
triangles,
|
||||
triI
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Shrink if necessary (because of invalid triangulations)
|
||||
triangles.setSize(triI);
|
||||
faceMap_.setSize(triI);
|
||||
|
||||
Pout<< "nInternalFaces_:" << nInternalFaces_ << endl;
|
||||
Pout<< "triangles:" << triangles.size() << endl;
|
||||
|
||||
|
||||
geometricSurfacePatchList surfPatches(patches.size());
|
||||
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
surfPatches[patchi] =
|
||||
geometricSurfacePatch
|
||||
(
|
||||
patches[patchi].physicalType(),
|
||||
patches[patchi].name(),
|
||||
patchi
|
||||
);
|
||||
}
|
||||
|
||||
// Create globally numbered tri surface
|
||||
if (faceCentreDecomposition)
|
||||
{
|
||||
// Use newPoints (mesh points + face centres)
|
||||
triSurface globalSurf(triangles, surfPatches, newPoints);
|
||||
|
||||
// Create locally numbered tri surface
|
||||
triSurface::operator=
|
||||
(
|
||||
triSurface
|
||||
(
|
||||
globalSurf.localFaces(),
|
||||
surfPatches,
|
||||
globalSurf.localPoints()
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use mesh points
|
||||
triSurface globalSurf(triangles, surfPatches, mesh.points());
|
||||
|
||||
// Create locally numbered tri surface
|
||||
triSurface::operator=
|
||||
(
|
||||
triSurface
|
||||
(
|
||||
globalSurf.localFaces(),
|
||||
surfPatches,
|
||||
globalSurf.localPoints()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,152 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::meshTriangulation
|
||||
|
||||
Description
|
||||
Triangulation of mesh faces. Generates (multiply connected) trisurface.
|
||||
|
||||
All patch faces keep their patchID as triangle region.
|
||||
Internal faces get the supplied region number.
|
||||
|
||||
SourceFiles
|
||||
meshTriangulation.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef meshTriangulation_H
|
||||
#define meshTriangulation_H
|
||||
|
||||
#include "triSurface.H"
|
||||
#include "typeInfo.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class polyMesh;
|
||||
class primitiveMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class meshTriangulation Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class meshTriangulation
|
||||
:
|
||||
public triSurface
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Number of triangles in this that are internal to the surface.
|
||||
label nInternalFaces_;
|
||||
|
||||
//- From triangle to mesh face
|
||||
labelList faceMap_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Is face internal to the subset.
|
||||
static bool isInternalFace
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const boolList& includedCell,
|
||||
const label facei
|
||||
);
|
||||
|
||||
//- Find boundary faces of subset.
|
||||
static void getFaces
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const boolList& includedCell,
|
||||
boolList& faceIsCut,
|
||||
label& nFaces,
|
||||
label& nInternalFaces
|
||||
);
|
||||
|
||||
//- Add triangulation of face to triangles. Optionally reverse.
|
||||
void insertTriangles
|
||||
(
|
||||
const triFaceList&,
|
||||
const label facei,
|
||||
const label regionI,
|
||||
const bool reverse,
|
||||
|
||||
List<labelledTri>& triangles,
|
||||
label& triI
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
ClassName("meshTriangulation");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
meshTriangulation();
|
||||
|
||||
//- Construct from selected mesh cell and region number to be used
|
||||
// for triangles resulting from internal faces. (all boundary triangles
|
||||
// get polyMesh patch id).
|
||||
// faceCentreDecomposition = true : decomposition around face centre
|
||||
// false : decomposition using
|
||||
// existing vertices
|
||||
meshTriangulation
|
||||
(
|
||||
const polyMesh&,
|
||||
const label internalFacesPatch,
|
||||
const boolList& includedCell,
|
||||
const bool faceCentreDecomposition = false
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Number of triangles in *this which are internal to the surface
|
||||
label nInternalFaces() const
|
||||
{
|
||||
return nInternalFaces_;
|
||||
}
|
||||
|
||||
//- From triangle to mesh face
|
||||
const labelList& faceMap() const
|
||||
{
|
||||
return faceMap_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,135 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::sortLabelledTri
|
||||
|
||||
Description
|
||||
Helper class which when constructed with a triSurface
|
||||
sorts the faces according to region number (or rather constructs a
|
||||
mapping).
|
||||
|
||||
SourceFiles
|
||||
sortLabelledTri.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef sortLabelledTri_H
|
||||
#define sortLabelledTri_H
|
||||
|
||||
#include "labelList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class sortLabelledTri;
|
||||
class triSurface;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfAndLabel Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Hold surface and label
|
||||
class surfAndLabel
|
||||
{
|
||||
const triSurface* surfPtr_;
|
||||
|
||||
label index_;
|
||||
|
||||
// Private Classes
|
||||
|
||||
//- Scalar comparison function used for sorting
|
||||
class less
|
||||
{
|
||||
public:
|
||||
|
||||
inline bool operator()
|
||||
(
|
||||
const surfAndLabel& one,
|
||||
const surfAndLabel& two
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
|
||||
friend class sortLabelledTri;
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
surfAndLabel()
|
||||
:
|
||||
surfPtr_(nullptr),
|
||||
index_(-1)
|
||||
{}
|
||||
|
||||
//- Construct from surface and index
|
||||
surfAndLabel(const triSurface& surf, const label index)
|
||||
:
|
||||
surfPtr_(&surf),
|
||||
index_(index)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sortLabelledTri Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sortLabelledTri
|
||||
:
|
||||
public List<surfAndLabel>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from surface, sorting the faces according to patch
|
||||
sortLabelledTri(const triSurface&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Set the labelList to those of sorted point indices
|
||||
void indices(labelList&) const;
|
||||
|
||||
//- Return the list of sorted point indices
|
||||
labelList indices() const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -26,8 +26,6 @@ License
|
||||
#include "triSurface.H"
|
||||
#include "STLtriangle.H"
|
||||
#include "primitivePatch.H"
|
||||
#include "HashTable.H"
|
||||
#include "hashSignedLabel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ bool Foam::triSurface::readVTK(const fileName& fName)
|
||||
(
|
||||
tris.xfer(),
|
||||
patches,
|
||||
xferCopy<List<point>>(surf.points())
|
||||
surf.xferPoints()
|
||||
);
|
||||
|
||||
return true;
|
||||
|
||||
@ -1,160 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfacePatchIOList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(surfacePatchIOList, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from IOObject
|
||||
Foam::surfacePatchIOList::surfacePatchIOList
|
||||
(
|
||||
const IOobject& io
|
||||
)
|
||||
:
|
||||
surfacePatchList(),
|
||||
regIOobject(io)
|
||||
{
|
||||
Foam::string functionName =
|
||||
"surfacePatchIOList::surfacePatchIOList"
|
||||
"(const IOobject& io)";
|
||||
|
||||
|
||||
if
|
||||
(
|
||||
readOpt() == IOobject::MUST_READ
|
||||
|| readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
{
|
||||
// Warn for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<surfacePatchIOList>();
|
||||
|
||||
surfacePatchList& patches = *this;
|
||||
|
||||
// read polyPatchList
|
||||
Istream& is = readStream(typeName);
|
||||
|
||||
PtrList<entry> patchEntries(is);
|
||||
patches.setSize(patchEntries.size());
|
||||
|
||||
label facei = 0;
|
||||
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
const dictionary& dict = patchEntries[patchi].dict();
|
||||
|
||||
label patchSize = readLabel(dict.lookup("nFaces"));
|
||||
label startFacei = readLabel(dict.lookup("startFace"));
|
||||
|
||||
patches[patchi] =
|
||||
surfacePatch
|
||||
(
|
||||
word(dict.lookup("geometricType")),
|
||||
patchEntries[patchi].keyword(),
|
||||
patchSize,
|
||||
startFacei,
|
||||
patchi
|
||||
);
|
||||
|
||||
|
||||
if (startFacei != facei)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Patches are not ordered. Start of patch " << patchi
|
||||
<< " does not correspond to sum of preceding patches."
|
||||
<< endl
|
||||
<< "while reading " << io.objectPath()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
facei += patchSize;
|
||||
}
|
||||
|
||||
// Check state of IOstream
|
||||
is.check(functionName.c_str());
|
||||
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
// Construct from IOObject
|
||||
Foam::surfacePatchIOList::surfacePatchIOList
|
||||
(
|
||||
const IOobject& io,
|
||||
const surfacePatchList& patches
|
||||
)
|
||||
:
|
||||
surfacePatchList(patches),
|
||||
regIOobject(io)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfacePatchIOList::~surfacePatchIOList()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// writeData member function required by regIOobject
|
||||
bool Foam::surfacePatchIOList::writeData(Ostream& os) const
|
||||
{
|
||||
os << *this;
|
||||
return os.good();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const surfacePatchIOList& patches)
|
||||
{
|
||||
os << patches.size() << nl << token::BEGIN_LIST;
|
||||
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
patches[patchi].writeDict(os);
|
||||
}
|
||||
|
||||
os << token::END_LIST;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -270,7 +270,7 @@ public:
|
||||
const bool reuse
|
||||
);
|
||||
|
||||
//- Construct from triangles, patches, points.
|
||||
//- Construct by transferring (triangles, points) components.
|
||||
triSurface
|
||||
(
|
||||
const Xfer<List<labelledTri>>&,
|
||||
@ -278,7 +278,7 @@ public:
|
||||
const Xfer<List<point>>&
|
||||
);
|
||||
|
||||
//- Construct from triangles, points. Set patchnames to default.
|
||||
//- Construct from triangles, points. Set patch names to default.
|
||||
triSurface(const List<labelledTri>&, const pointField&);
|
||||
|
||||
//- Construct from triangles, points. Set region to 0 and default
|
||||
@ -299,7 +299,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
~triSurface();
|
||||
virtual ~triSurface();
|
||||
|
||||
void clearOut();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user