mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop
This commit is contained in:
@ -149,10 +149,10 @@ do
|
||||
echo "Processing $appName"
|
||||
|
||||
# Options with args
|
||||
optsWithArgs=($(awk '/^ *-[a-z]/ && /</ {print $1}' <<< "$appHelp"))
|
||||
optsWithArgs=($(awk '/^ {0,4}-[a-z]/ && /</ {print $1}' <<< "$appHelp"))
|
||||
|
||||
# Options without args
|
||||
opts=($(awk '/^ *-[a-z]/ && !/</ {print $1}' <<< "$appHelp"))
|
||||
opts=($(awk '/^ {0,4}-[a-z]/ && !/</ {print $1}' <<< "$appHelp"))
|
||||
|
||||
cat<<WRITECOMPLETION >> $outFile
|
||||
unset -f _${appName}
|
||||
|
||||
@ -41,22 +41,28 @@ Foam::label Foam::mergePoints
|
||||
{
|
||||
typedef typename PointList::value_type point_type;
|
||||
|
||||
// Create a old to new point mapping array
|
||||
pointMap.setSize(points.size());
|
||||
const label nPoints = points.size();
|
||||
|
||||
// Create an old to new point mapping array
|
||||
pointMap.setSize(nPoints);
|
||||
pointMap = -1;
|
||||
|
||||
if (points.empty())
|
||||
if (!nPoints)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Explicitly convert to Field to support various list types
|
||||
tmp<Field<point_type>> tPoints(new Field<point_type>(points));
|
||||
|
||||
point_type compareOrigin = origin;
|
||||
if (origin == point_type::max)
|
||||
{
|
||||
compareOrigin = sum(tPoints())/points.size();
|
||||
// Use average of input points to define a comparison origin.
|
||||
// Same as sum(points)/nPoints, but handles different list types
|
||||
compareOrigin = points[0];
|
||||
for (label pointi=1; pointi < nPoints; ++pointi)
|
||||
{
|
||||
compareOrigin += points[pointi];
|
||||
}
|
||||
compareOrigin /= nPoints;
|
||||
}
|
||||
|
||||
// We're comparing distance squared to origin first.
|
||||
@ -68,34 +74,31 @@ Foam::label Foam::mergePoints
|
||||
// x^2+y^2+z^2 + 2*mergeTol*(x+z+y) + mergeTol^2*...
|
||||
// so the difference will be 2*mergeTol*(x+y+z)
|
||||
|
||||
const scalar mergeTolSqr = Foam::sqr(scalar(mergeTol));
|
||||
const scalar mergeTolSqr = Foam::sqr(mergeTol);
|
||||
|
||||
// Sort points by magSqr
|
||||
const Field<point_type> d(tPoints - compareOrigin);
|
||||
|
||||
List<scalar> magSqrD(d.size());
|
||||
forAll(d, pointi)
|
||||
List<scalar> magSqrDist(nPoints);
|
||||
forAll(points, pointi)
|
||||
{
|
||||
magSqrD[pointi] = magSqr(d[pointi]);
|
||||
magSqrDist[pointi] = magSqr(points[pointi] - compareOrigin);
|
||||
}
|
||||
labelList order;
|
||||
Foam::sortedOrder(magSqrD, order);
|
||||
Foam::sortedOrder(magSqrDist, order);
|
||||
|
||||
|
||||
Field<scalar> sortedTol(points.size());
|
||||
Field<scalar> sortedTol(nPoints);
|
||||
forAll(order, sortI)
|
||||
{
|
||||
const label pointi = order[sortI];
|
||||
const point_type& pt = points[order[sortI]];
|
||||
|
||||
// Convert to scalar precision
|
||||
// NOTE: not yet using point_type template parameter
|
||||
const point pt
|
||||
// Use scalar precision
|
||||
sortedTol[sortI] =
|
||||
2*mergeTol*
|
||||
(
|
||||
scalar(d[pointi].x()),
|
||||
scalar(d[pointi].y()),
|
||||
scalar(d[pointi].z())
|
||||
mag(scalar(pt.x() - compareOrigin.x())),
|
||||
+ mag(scalar(pt.y() - compareOrigin.y())),
|
||||
+ mag(scalar(pt.z() - compareOrigin.z()))
|
||||
);
|
||||
sortedTol[sortI] = 2*mergeTol*(mag(pt.x())+mag(pt.y())+mag(pt.z()));
|
||||
}
|
||||
|
||||
label newPointi = 0;
|
||||
@ -104,11 +107,11 @@ Foam::label Foam::mergePoints
|
||||
label pointi = order[0];
|
||||
pointMap[pointi] = newPointi++;
|
||||
|
||||
for (label sortI = 1; sortI < order.size(); sortI++)
|
||||
for (label sortI = 1; sortI < order.size(); ++sortI)
|
||||
{
|
||||
// Get original point index
|
||||
const label pointi = order[sortI];
|
||||
const scalar mag2 = magSqrD[order[sortI]];
|
||||
const scalar mag2 = magSqrDist[order[sortI]];
|
||||
|
||||
// Convert to scalar precision
|
||||
// NOTE: not yet using point_type template parameter
|
||||
@ -127,8 +130,8 @@ Foam::label Foam::mergePoints
|
||||
(
|
||||
label prevSortI = sortI - 1;
|
||||
prevSortI >= 0
|
||||
&& (mag(magSqrD[order[prevSortI]] - mag2) <= sortedTol[sortI]);
|
||||
prevSortI--
|
||||
&& (mag(magSqrDist[order[prevSortI]] - mag2) <= sortedTol[sortI]);
|
||||
--prevSortI
|
||||
)
|
||||
{
|
||||
const label prevPointi = order[prevSortI];
|
||||
|
||||
@ -281,22 +281,22 @@ bool Foam::fileFormats::FIREMeshWriter::write(const fileName& meshName) const
|
||||
if (FIRECore::file3dExtensions.hasEnum(ext))
|
||||
{
|
||||
FIRECore::fileExt3d fireFileType = FIRECore::file3dExtensions[ext];
|
||||
if (fireFileType == FIRECore::POLY_ASCII)
|
||||
if (fireFileType == FIRECore::fileExt3d::POLY_ASCII)
|
||||
{
|
||||
useBinary = false;
|
||||
useCompress = false;
|
||||
}
|
||||
else if (fireFileType == FIRECore::POLY_BINARY)
|
||||
else if (fireFileType == FIRECore::fileExt3d::POLY_BINARY)
|
||||
{
|
||||
useBinary = true;
|
||||
useCompress = false;
|
||||
}
|
||||
else if (fireFileType == FIRECore::POLY_ASCII_COMPRESSED)
|
||||
else if (fireFileType == FIRECore::fileExt3d::POLY_ASCII_Z)
|
||||
{
|
||||
useBinary = false;
|
||||
useCompress = true;
|
||||
}
|
||||
else if (fireFileType == FIRECore::POLY_BINARY_COMPRESSED)
|
||||
else if (fireFileType == FIRECore::fileExt3d::POLY_BINARY_Z)
|
||||
{
|
||||
useBinary = true;
|
||||
useCompress = true;
|
||||
|
||||
@ -27,26 +27,15 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::coordSet::coordFormat,
|
||||
5
|
||||
>::names[] =
|
||||
const Foam::Enum<Foam::coordSet::coordFormat>
|
||||
Foam::coordSet::coordFormatNames_
|
||||
{
|
||||
"xyz",
|
||||
"x",
|
||||
"y",
|
||||
"z",
|
||||
"distance"
|
||||
{ coordFormat::XYZ, "xyz" },
|
||||
{ coordFormat::X, "x" },
|
||||
{ coordFormat::Y, "y" },
|
||||
{ coordFormat::Z, "z" },
|
||||
{ coordFormat::DISTANCE, "distance" }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
const Foam::NamedEnum<Foam::coordSet::coordFormat, 5>
|
||||
Foam::coordSet::coordFormatNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -37,6 +37,7 @@ SourceFiles
|
||||
|
||||
#include "pointField.H"
|
||||
#include "word.H"
|
||||
#include "Enum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -70,7 +71,7 @@ public:
|
||||
private:
|
||||
|
||||
//- String representation of coordFormat enums
|
||||
static const NamedEnum<coordFormat, 5> coordFormatNames_;
|
||||
static const Enum<coordFormat> coordFormatNames_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -27,24 +27,14 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::NamedEnum<Foam::fileFormats::FIRECore::fileExt3d, 4>
|
||||
Foam::fileFormats::FIRECore::file3dExtensions;
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::fileFormats::FIRECore::fileExt3d,
|
||||
4
|
||||
>::names[] =
|
||||
const Foam::Enum<Foam::fileFormats::FIRECore::fileExt3d>
|
||||
Foam::fileFormats::FIRECore::file3dExtensions
|
||||
{
|
||||
"fpma",
|
||||
"fpmb",
|
||||
"fpmaz",
|
||||
"fpmbz"
|
||||
{ fileExt3d::POLY_ASCII, "fpma" },
|
||||
{ fileExt3d::POLY_BINARY, "fpmb" },
|
||||
{ fileExt3d::POLY_ASCII_Z, "fpmaz" },
|
||||
{ fileExt3d::POLY_BINARY_Z, "fpmbz" }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -40,7 +40,7 @@ SourceFiles
|
||||
#include "labelList.H"
|
||||
#include "pointField.H"
|
||||
#include "IOstreams.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -86,8 +86,8 @@ public:
|
||||
{
|
||||
POLY_ASCII,
|
||||
POLY_BINARY,
|
||||
POLY_ASCII_COMPRESSED,
|
||||
POLY_BINARY_COMPRESSED
|
||||
POLY_ASCII_Z,
|
||||
POLY_BINARY_Z
|
||||
};
|
||||
|
||||
|
||||
@ -97,11 +97,12 @@ public:
|
||||
//- Float type (binary format)
|
||||
typedef double fireReal_t;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Data
|
||||
|
||||
static const NamedEnum<fileExt3d, 4> file3dExtensions;
|
||||
static const Enum<fileExt3d> file3dExtensions;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
@ -33,40 +33,22 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::NamedEnum<Foam::fileFormats::STARCDCore::fileHeader, 3>
|
||||
Foam::fileFormats::STARCDCore::fileHeaders_;
|
||||
|
||||
const Foam::NamedEnum<Foam::fileFormats::STARCDCore::fileExt, 4>
|
||||
Foam::fileFormats::STARCDCore::fileExtensions_;
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::fileFormats::STARCDCore::fileHeader,
|
||||
3
|
||||
>::names[] =
|
||||
const Foam::Enum<Foam::fileFormats::STARCDCore::fileHeader>
|
||||
Foam::fileFormats::STARCDCore::fileHeaders_
|
||||
{
|
||||
"PROSTAR_CELL",
|
||||
"PROSTAR_VERTEX",
|
||||
"PROSTAR_BOUNDARY"
|
||||
{ fileHeader::HEADER_CEL, "PROSTAR_CELL" },
|
||||
{ fileHeader::HEADER_VRT, "PROSTAR_VERTEX" },
|
||||
{ fileHeader::HEADER_BND, "PROSTAR_BOUNDARY" }
|
||||
};
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::fileFormats::STARCDCore::fileExt,
|
||||
4
|
||||
>::names[] =
|
||||
const Foam::Enum<Foam::fileFormats::STARCDCore::fileExt>
|
||||
Foam::fileFormats::STARCDCore::fileExtensions_
|
||||
{
|
||||
"cel",
|
||||
"vrt",
|
||||
"bnd",
|
||||
"inp"
|
||||
{ fileExt::CEL_FILE, "cel" },
|
||||
{ fileExt::VRT_FILE, "vrt" },
|
||||
{ fileExt::BND_FILE, "bnd" },
|
||||
{ fileExt::INP_FILE, "inp" }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
const char* const Foam::fileFormats::STARCDCore::defaultBoundaryName =
|
||||
"Default_Boundary_Region";
|
||||
|
||||
@ -36,7 +36,7 @@ SourceFiles
|
||||
#define STARCDCore_H
|
||||
|
||||
#include "IFstream.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
#include "pointField.H"
|
||||
#include "Map.H"
|
||||
#include "FixedList.H"
|
||||
@ -113,8 +113,8 @@ private:
|
||||
|
||||
// Private Data
|
||||
|
||||
static const NamedEnum<fileHeader, 3> fileHeaders_;
|
||||
static const NamedEnum<fileExt, 4> fileExtensions_;
|
||||
static const Enum<fileHeader> fileHeaders_;
|
||||
static const Enum<fileExt> fileExtensions_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -26,6 +26,7 @@ License
|
||||
#include "STLReader.H"
|
||||
#include "Map.H"
|
||||
#include "IFstream.H"
|
||||
#include "mergePoints.H"
|
||||
|
||||
#undef DEBUG_STLBINARY
|
||||
|
||||
@ -202,4 +203,38 @@ void Foam::fileFormats::STLReader::clear()
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::fileFormats::STLReader::mergePointsMap
|
||||
(
|
||||
labelList& pointMap
|
||||
) const
|
||||
{
|
||||
// With the merge distance depending on the input format (ASCII | BINARY),
|
||||
// but must be independent of WM_SP or WM_DP flag.
|
||||
// - floatScalarSMALL = 1e-6
|
||||
// - doubleScalarSMALL = 1e-15
|
||||
|
||||
return mergePointsMap
|
||||
(
|
||||
(format_ == BINARY ? 10 : 100) * doubleScalarSMALL,
|
||||
pointMap
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::fileFormats::STLReader::mergePointsMap
|
||||
(
|
||||
const scalar mergeTol,
|
||||
labelList& pointMap
|
||||
) const
|
||||
{
|
||||
return Foam::mergePoints
|
||||
(
|
||||
points_,
|
||||
mergeTol,
|
||||
false, // verbose
|
||||
pointMap
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -61,7 +61,7 @@ class STLReader
|
||||
bool sorted_;
|
||||
|
||||
//- The points supporting the facets
|
||||
pointField points_;
|
||||
List<STLpoint> points_;
|
||||
|
||||
//- The zones associated with the faces
|
||||
List<label> zoneIds_;
|
||||
@ -117,6 +117,15 @@ public:
|
||||
//- Flush all values
|
||||
void clear();
|
||||
|
||||
//- Calculate merge points mapping, return old to new pointMap.
|
||||
// The merge tolerance based on ASCII or BINARY input format.
|
||||
// \return number of unique points
|
||||
label mergePointsMap(labelList& pointMap) const;
|
||||
|
||||
//- Calculate merge points mapping, return old to new pointMap.
|
||||
// \return number of unique points
|
||||
label mergePointsMap(const scalar mergeTol, labelList& pointMap) const;
|
||||
|
||||
//- File read was already sorted?
|
||||
inline bool sorted() const
|
||||
{
|
||||
@ -124,7 +133,7 @@ public:
|
||||
}
|
||||
|
||||
//- Return full access to the points
|
||||
inline pointField& points()
|
||||
inline List<STLpoint>& points()
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
|
||||
@ -23,9 +23,10 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
%{
|
||||
%option prefix="yySTL"
|
||||
%option yyclass="yySTLFlexLexer"
|
||||
|
||||
#undef yyFlexLexer
|
||||
%{
|
||||
|
||||
/* ------------------------------------------------------------------------ *\
|
||||
------ local definitions
|
||||
@ -35,9 +36,9 @@ License
|
||||
#include "OSspecific.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// Dummy yyFlexLexer::yylex() to keep the linker happy. It is not called
|
||||
//! \cond dummy
|
||||
#if YY_FLEX_MAJOR_VERSION <= 2 && YY_FLEX_MINOR_VERSION <= 5 && YY_FLEX_SUBMINOR_VERSION < 34
|
||||
int yyFlexLexer::yylex()
|
||||
{
|
||||
FatalErrorInFunction
|
||||
@ -45,29 +46,29 @@ int yyFlexLexer::yylex()
|
||||
<< abort(FatalError);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
//! \endcond
|
||||
|
||||
// Dummy yywrap to keep yylex happy at compile time.
|
||||
// It is called by yylex but is not used as the mechanism to change file.
|
||||
// See <<EOF>>
|
||||
//! \cond dummy
|
||||
#if YY_FLEX_MINOR_VERSION < 6 && YY_FLEX_SUBMINOR_VERSION < 34
|
||||
#if YY_FLEX_MAJOR_VERSION <= 2 && YY_FLEX_MINOR_VERSION <= 5 && YY_FLEX_SUBMINOR_VERSION < 34
|
||||
extern "C" int yywrap()
|
||||
#else
|
||||
int yyFlexLexer::yywrap()
|
||||
int yySTLFlexLexer::yywrap()
|
||||
#endif
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
//! \endcond
|
||||
|
||||
|
||||
//- A lexer for parsing STL ASCII files.
|
||||
// Returns DynamicList(s) of points and facets (zoneIds).
|
||||
// The facets are within a solid/endsolid grouping
|
||||
class STLASCIILexer
|
||||
:
|
||||
public yyFlexLexer
|
||||
public yySTLFlexLexer
|
||||
{
|
||||
// Private data
|
||||
|
||||
@ -76,7 +77,7 @@ class STLASCIILexer
|
||||
label lineNo_;
|
||||
word startError_;
|
||||
|
||||
DynamicList<point> points_;
|
||||
DynamicList<STLpoint> points_;
|
||||
DynamicList<label> facets_;
|
||||
DynamicList<word> names_;
|
||||
DynamicList<label> sizes_;
|
||||
@ -104,7 +105,7 @@ public:
|
||||
}
|
||||
|
||||
//- A list of unstitched triangle points
|
||||
inline DynamicList<point>& points()
|
||||
inline DynamicList<STLpoint>& points()
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
@ -132,7 +133,7 @@ public:
|
||||
|
||||
STLASCIILexer::STLASCIILexer(istream* is, const label approxNpoints)
|
||||
:
|
||||
yyFlexLexer(is),
|
||||
yySTLFlexLexer(is),
|
||||
sorted_(true),
|
||||
groupID_(-1),
|
||||
lineNo_(1),
|
||||
@ -145,6 +146,7 @@ STLASCIILexer::STLASCIILexer(istream* is, const label approxNpoints)
|
||||
------ cppLexer::yylex()
|
||||
\* ------------------------------------------------------------------------ */
|
||||
|
||||
#undef YY_DECL
|
||||
#define YY_DECL int STLASCIILexer::lex()
|
||||
|
||||
%}
|
||||
@ -202,9 +204,9 @@ endsolid {space}("endsolid"|"ENDSOLID")({some_space}{word})*
|
||||
// End of read character pointer returned by strtof
|
||||
// char* endPtr;
|
||||
|
||||
STLpoint normal;
|
||||
label cmpt = 0; // Component index when reading vertex
|
||||
STLpoint vertex;
|
||||
label cmpt = 0; // component index used for reading vertex
|
||||
// STLpoint normal;
|
||||
|
||||
static const char* stateNames[7] =
|
||||
{
|
||||
@ -238,66 +240,79 @@ endsolid {space}("endsolid"|"ENDSOLID")({some_space}{word})*
|
||||
|
||||
{solid} {
|
||||
BEGIN(readSolidName);
|
||||
}
|
||||
}
|
||||
|
||||
<readSolidName>{string} {
|
||||
word name(Foam::string::validate<word>(YYText()));
|
||||
const word solidName(Foam::string::validate<word>(YYText()));
|
||||
|
||||
HashTable<label>::const_iterator fnd = lookup_.find(name);
|
||||
if (fnd != lookup_.end())
|
||||
auto iter = lookup_.cfind(solidName);
|
||||
if (iter.found())
|
||||
{
|
||||
if (groupID_ != fnd())
|
||||
if (groupID_ != iter.object())
|
||||
{
|
||||
// group appeared out of order
|
||||
sorted_ = false;
|
||||
sorted_ = false; // Group appeared out of order
|
||||
groupID_ = iter.object();
|
||||
}
|
||||
groupID_ = fnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
groupID_ = sizes_.size();
|
||||
lookup_.insert(name, groupID_);
|
||||
names_.append(name);
|
||||
if (lookup_.insert(solidName, groupID_))
|
||||
{
|
||||
names_.append(solidName);
|
||||
sizes_.append(0);
|
||||
}
|
||||
BEGIN(INITIAL);
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction<< "Duplicate solid-name: " << solidName
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
BEGIN(INITIAL);
|
||||
}
|
||||
|
||||
<readSolidName>{space}\n {
|
||||
word name("solid");
|
||||
const word solidName("solid"); // Could also use solid0, solid1, ...
|
||||
|
||||
HashTable<label>::const_iterator fnd = lookup_.find(name);
|
||||
if (fnd != lookup_.end())
|
||||
auto iter = lookup_.cfind(solidName);
|
||||
if (iter.found())
|
||||
{
|
||||
if (groupID_ != fnd())
|
||||
if (groupID_ != iter.object())
|
||||
{
|
||||
// group appeared out of order
|
||||
sorted_ = false;
|
||||
sorted_ = false; // Group appeared out of order
|
||||
groupID_ = iter.object();
|
||||
}
|
||||
groupID_ = fnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
groupID_ = sizes_.size();
|
||||
lookup_.insert(name, groupID_);
|
||||
names_.append(name);
|
||||
if (lookup_.insert(solidName, groupID_))
|
||||
{
|
||||
names_.append(solidName);
|
||||
sizes_.append(0);
|
||||
}
|
||||
|
||||
lineNo_++;
|
||||
BEGIN(INITIAL);
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction<< "Duplicate solid-name: " << solidName
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
++lineNo_;
|
||||
BEGIN(INITIAL);
|
||||
}
|
||||
|
||||
{color} {
|
||||
}
|
||||
/* ignore 'color' */
|
||||
}
|
||||
|
||||
{facet} {
|
||||
BEGIN(readFacet);
|
||||
}
|
||||
}
|
||||
|
||||
<readFacet>{normal} {
|
||||
BEGIN(readNormal);
|
||||
}
|
||||
}
|
||||
|
||||
<readNormal>{point} {
|
||||
/*
|
||||
@ -308,15 +323,15 @@ endsolid {space}("endsolid"|"ENDSOLID")({some_space}{word})*
|
||||
normals_.append(normal);
|
||||
*/
|
||||
BEGIN(readFacet);
|
||||
}
|
||||
}
|
||||
|
||||
<readFacet>{outerloop} {
|
||||
BEGIN(readVertices);
|
||||
}
|
||||
}
|
||||
|
||||
<readVertices>{vertex} {
|
||||
BEGIN(readVertex);
|
||||
}
|
||||
}
|
||||
|
||||
<readVertex>{space}{signedInteger}{space} {
|
||||
vertex[cmpt++] = atol(YYText());
|
||||
@ -327,7 +342,7 @@ endsolid {space}("endsolid"|"ENDSOLID")({some_space}{word})*
|
||||
points_.append(vertex);
|
||||
BEGIN(readVertices);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<readVertex>{space}{floatNum}{space} {
|
||||
vertex[cmpt++] = atof(YYText());
|
||||
@ -338,26 +353,26 @@ endsolid {space}("endsolid"|"ENDSOLID")({some_space}{word})*
|
||||
points_.append(vertex);
|
||||
BEGIN(readVertices);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<readVertices>{endloop} {
|
||||
BEGIN(readFacet);
|
||||
}
|
||||
}
|
||||
|
||||
<readFacet>{endfacet} {
|
||||
facets_.append(groupID_);
|
||||
sizes_[groupID_]++;
|
||||
BEGIN(INITIAL);
|
||||
}
|
||||
}
|
||||
|
||||
{endsolid} {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------ Ignore remaining space and \n s. -------------------- */
|
||||
/* ---------------- Ignore remaining spaces and newlines ------------------ */
|
||||
|
||||
<*>{space} {}
|
||||
<*>\n { lineNo_++; }
|
||||
<*>\n { ++lineNo_; }
|
||||
|
||||
|
||||
/* ------------------- Any other characters are errors -------------------- */
|
||||
@ -365,7 +380,7 @@ endsolid {space}("endsolid"|"ENDSOLID")({some_space}{word})*
|
||||
<*>. {
|
||||
startError_ = YYText();
|
||||
yy_push_state(stlError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------- Error handler ----------------------------- */
|
||||
@ -377,14 +392,14 @@ endsolid {space}("endsolid"|"ENDSOLID")({some_space}{word})*
|
||||
<< " expected " << stateExpects[YY_START]
|
||||
<< " but found '" << startError_.c_str() << YYText() << "'"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------ On EOF terminate ---------------------------- */
|
||||
|
||||
<<EOF>> {
|
||||
yyterminate();
|
||||
}
|
||||
}
|
||||
%%
|
||||
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ namespace Foam
|
||||
|
||||
class STLpoint
|
||||
:
|
||||
public Vector<float>
|
||||
public floatVector
|
||||
{
|
||||
|
||||
public:
|
||||
@ -58,28 +58,34 @@ public:
|
||||
inline STLpoint()
|
||||
{}
|
||||
|
||||
//- Construct from base class
|
||||
inline STLpoint(const floatVector& v)
|
||||
:
|
||||
floatVector(v)
|
||||
{}
|
||||
|
||||
//- Construct from components
|
||||
inline STLpoint(float x, float y, float z)
|
||||
:
|
||||
Vector<float>(x, y, z)
|
||||
floatVector(x, y, z)
|
||||
{}
|
||||
|
||||
//- Construct from components
|
||||
inline STLpoint(double x, double y, double z)
|
||||
:
|
||||
Vector<float>(float(x), float(y), float(z))
|
||||
floatVector(float(x), float(y), float(z))
|
||||
{}
|
||||
|
||||
//- Construct from point
|
||||
inline STLpoint(const point& pt)
|
||||
:
|
||||
Vector<float>(float(pt.x()), float(pt.y()), float(pt.z()))
|
||||
floatVector(float(pt.x()), float(pt.y()), float(pt.z()))
|
||||
{}
|
||||
|
||||
//- Construct from istream
|
||||
inline STLpoint(Istream& is)
|
||||
:
|
||||
Vector<float>(is)
|
||||
floatVector(is)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -35,50 +35,39 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(vtkUnstructuredReader, 1);
|
||||
|
||||
template<>
|
||||
const char*
|
||||
NamedEnum<vtkUnstructuredReader::vtkDataType, 8>::names[] =
|
||||
{
|
||||
"int",
|
||||
"unsigned_int",
|
||||
"long",
|
||||
"unsigned_long",
|
||||
"float",
|
||||
"double",
|
||||
"string",
|
||||
"vtkIdType"
|
||||
};
|
||||
const NamedEnum<vtkUnstructuredReader::vtkDataType, 8>
|
||||
vtkUnstructuredReader::vtkDataTypeNames;
|
||||
|
||||
|
||||
template<>
|
||||
const char*
|
||||
NamedEnum<vtkUnstructuredReader::vtkDataSetType, 3>::names[] =
|
||||
{
|
||||
"FIELD",
|
||||
"SCALARS",
|
||||
"VECTORS"
|
||||
};
|
||||
const NamedEnum<vtkUnstructuredReader::vtkDataSetType, 3>
|
||||
vtkUnstructuredReader::vtkDataSetTypeNames;
|
||||
|
||||
|
||||
template<>
|
||||
const char*
|
||||
NamedEnum<vtkUnstructuredReader::parseMode, 5>::names[] =
|
||||
{
|
||||
"NOMODE",
|
||||
"UNSTRUCTURED_GRID",
|
||||
"POLYDATA",
|
||||
"CELL_DATA",
|
||||
"POINT_DATA"
|
||||
};
|
||||
const NamedEnum<vtkUnstructuredReader::parseMode, 5>
|
||||
vtkUnstructuredReader::parseModeNames;
|
||||
}
|
||||
|
||||
const Foam::Enum<Foam::vtkUnstructuredReader::vtkDataType>
|
||||
Foam::vtkUnstructuredReader::vtkDataTypeNames
|
||||
{
|
||||
{ vtkDataType::VTK_INT, "int" },
|
||||
{ vtkDataType::VTK_UINT, "unsigned_int" },
|
||||
{ vtkDataType::VTK_LONG, "long" },
|
||||
{ vtkDataType::VTK_ULONG, "unsigned_long" },
|
||||
{ vtkDataType::VTK_FLOAT, "float" },
|
||||
{ vtkDataType::VTK_DOUBLE, "double" },
|
||||
{ vtkDataType::VTK_STRING, "string" },
|
||||
{ vtkDataType::VTK_ID, "vtkIdType" }
|
||||
};
|
||||
|
||||
const Foam::Enum<Foam::vtkUnstructuredReader::vtkDataSetType>
|
||||
Foam::vtkUnstructuredReader::vtkDataSetTypeNames
|
||||
{
|
||||
{ vtkDataSetType::VTK_FIELD, "FIELD" },
|
||||
{ vtkDataSetType::VTK_SCALARS, "SCALARS" },
|
||||
{ vtkDataSetType::VTK_VECTORS, "VECTORS" }
|
||||
};
|
||||
|
||||
const Foam::Enum<Foam::vtkUnstructuredReader::parseMode>
|
||||
Foam::vtkUnstructuredReader::parseModeNames
|
||||
{
|
||||
{ parseMode::NOMODE, "NOMODE" },
|
||||
{ parseMode::UNSTRUCTURED_GRID, "UNSTRUCTURED_GRID" },
|
||||
{ parseMode::POLYDATA, "POLYDATA" },
|
||||
{ parseMode::CELL_DATA, "CELL_DATA" },
|
||||
{ parseMode::POINT_DATA, "POINT_DATA" }
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ SourceFiles
|
||||
#include "objectRegistry.H"
|
||||
#include "cellShapeList.H"
|
||||
#include "HashSet.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -83,7 +83,7 @@ public:
|
||||
VTK_ID
|
||||
};
|
||||
|
||||
static const NamedEnum<vtkDataType, 8> vtkDataTypeNames;
|
||||
static const Enum<vtkDataType> vtkDataTypeNames;
|
||||
|
||||
|
||||
//- Enumeration defining the vtk dataset types
|
||||
@ -94,11 +94,10 @@ public:
|
||||
VTK_VECTORS
|
||||
};
|
||||
|
||||
static const NamedEnum<vtkDataSetType, 3> vtkDataSetTypeNames;
|
||||
static const Enum<vtkDataSetType> vtkDataSetTypeNames;
|
||||
|
||||
|
||||
//- Enumeration defining the parse mode - what type of data is being
|
||||
// read
|
||||
//- Enumeration defining the parse mode - type of data being read
|
||||
enum parseMode
|
||||
{
|
||||
NOMODE,
|
||||
@ -108,7 +107,7 @@ public:
|
||||
POINT_DATA
|
||||
};
|
||||
|
||||
static const NamedEnum<parseMode, 5> parseModeNames;
|
||||
static const Enum<parseMode> parseModeNames;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -222,7 +222,7 @@ void Foam::fileFormats::FLMAsurfaceFormat<Face>::write
|
||||
// Set the precision of the points data to 10
|
||||
os.precision(10);
|
||||
|
||||
Info<< "points: " << pointLst.size() << endl;
|
||||
Info<< nl << "points: " << pointLst.size() << endl;
|
||||
putFireLabel(os, pointLst.size());
|
||||
newline(os);
|
||||
|
||||
|
||||
@ -24,7 +24,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "STLsurfaceFormat.H"
|
||||
#include "labelledTri.H"
|
||||
#include "triPointRef.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
@ -126,13 +125,25 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
|
||||
{
|
||||
this->clear();
|
||||
|
||||
// read in the values
|
||||
// Read in the values
|
||||
STLReader reader(filename);
|
||||
|
||||
// transfer points
|
||||
this->storedPoints().transfer(reader.points());
|
||||
// Get the map for stitched surface points, with merge tolerance depending
|
||||
// on the input format
|
||||
labelList pointMap;
|
||||
const label nUniquePoints = reader.mergePointsMap(pointMap);
|
||||
|
||||
// retrieve the original zone information
|
||||
const auto& readpts = reader.points();
|
||||
|
||||
// Assign points
|
||||
pointField& pointLst = this->storedPoints();
|
||||
pointLst.setSize(nUniquePoints);
|
||||
forAll(readpts, pointi)
|
||||
{
|
||||
pointLst[pointMap[pointi]] = readpts[pointi];
|
||||
}
|
||||
|
||||
// Retrieve the original zone information
|
||||
List<word> names(reader.names().xfer());
|
||||
List<label> sizes(reader.sizes().xfer());
|
||||
List<label> zoneIds(reader.zoneIds().xfer());
|
||||
@ -142,16 +153,21 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
|
||||
|
||||
if (reader.sorted())
|
||||
{
|
||||
// already sorted - generate directly
|
||||
// Already sorted - generate directly
|
||||
forAll(faceLst, facei)
|
||||
{
|
||||
const label startPt = 3*facei;
|
||||
faceLst[facei] = Face{startPt, startPt+1, startPt+2};
|
||||
faceLst[facei] = Face
|
||||
{
|
||||
pointMap[startPt],
|
||||
pointMap[startPt+1],
|
||||
pointMap[startPt+2]
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// unsorted - determine the sorted order:
|
||||
// Unsorted - determine the sorted order:
|
||||
// avoid SortableList since we discard the main list anyhow
|
||||
List<label> faceMap;
|
||||
sortedOrder(zoneIds, faceMap);
|
||||
@ -160,7 +176,12 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
|
||||
forAll(faceMap, facei)
|
||||
{
|
||||
const label startPt = 3*faceMap[facei];
|
||||
faceLst[facei] = Face{startPt, startPt+1, startPt+2};
|
||||
faceLst[facei] = Face
|
||||
{
|
||||
pointMap[startPt],
|
||||
pointMap[startPt+1],
|
||||
pointMap[startPt+2]
|
||||
};
|
||||
}
|
||||
}
|
||||
zoneIds.clear();
|
||||
@ -177,7 +198,6 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
|
||||
this->addZones(sizes);
|
||||
}
|
||||
this->addZonesToFaces(); // for labelledTri
|
||||
this->stitchFaces(SMALL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -78,13 +78,24 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
|
||||
{
|
||||
this->clear();
|
||||
|
||||
// read in the values
|
||||
// Read in the values
|
||||
TRIsurfaceFormatCore reader(filename);
|
||||
|
||||
// transfer points
|
||||
this->storedPoints().transfer(reader.points());
|
||||
// Get the map for stitched surface points
|
||||
labelList pointMap;
|
||||
const label nUniquePoints = reader.mergePointsMap(pointMap);
|
||||
|
||||
// retrieve the original zone information
|
||||
const auto& readpts = reader.points();
|
||||
|
||||
// Assign points
|
||||
pointField& pointLst = this->storedPoints();
|
||||
pointLst.setSize(nUniquePoints);
|
||||
forAll(readpts, pointi)
|
||||
{
|
||||
pointLst[pointMap[pointi]] = readpts[pointi];
|
||||
}
|
||||
|
||||
// Retrieve the original zone information
|
||||
List<label> sizes(reader.sizes().xfer());
|
||||
List<label> zoneIds(reader.zoneIds().xfer());
|
||||
|
||||
@ -93,16 +104,21 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
|
||||
|
||||
if (reader.sorted())
|
||||
{
|
||||
// already sorted - generate directly
|
||||
// Already sorted - generate directly
|
||||
forAll(faceLst, facei)
|
||||
{
|
||||
const label startPt = 3*facei;
|
||||
faceLst[facei] = Face{startPt, startPt+1, startPt+2};
|
||||
faceLst[facei] = Face
|
||||
{
|
||||
pointMap[startPt],
|
||||
pointMap[startPt+1],
|
||||
pointMap[startPt+2]
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// unsorted - determine the sorted order:
|
||||
// Unsorted - determine the sorted order:
|
||||
// avoid SortableList since we discard the main list anyhow
|
||||
List<label> faceMap;
|
||||
sortedOrder(zoneIds, faceMap);
|
||||
@ -111,7 +127,12 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
|
||||
forAll(faceMap, facei)
|
||||
{
|
||||
const label startPt = 3*faceMap[facei];
|
||||
faceLst[facei] = Face{startPt, startPt+1, startPt+2};
|
||||
faceLst[facei] = Face
|
||||
{
|
||||
pointMap[startPt],
|
||||
pointMap[startPt+1],
|
||||
pointMap[startPt+2]
|
||||
};
|
||||
}
|
||||
}
|
||||
zoneIds.clear();
|
||||
@ -121,7 +142,7 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
|
||||
|
||||
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-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,6 +27,7 @@ License
|
||||
#include "IFstream.H"
|
||||
#include "IOmanip.H"
|
||||
#include "IStringStream.H"
|
||||
#include "mergePoints.H"
|
||||
#include "Map.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
@ -71,7 +72,7 @@ bool Foam::fileFormats::TRIsurfaceFormatCore::read
|
||||
|
||||
// uses similar structure as STL, just some points
|
||||
// the rest of the reader resembles the STL binary reader
|
||||
DynamicList<point> dynPoints;
|
||||
DynamicList<STLpoint> dynPoints;
|
||||
DynamicList<label> dynZones;
|
||||
DynamicList<label> dynSizes;
|
||||
HashTable<label> lookup;
|
||||
@ -94,7 +95,7 @@ bool Foam::fileFormats::TRIsurfaceFormatCore::read
|
||||
|
||||
IStringStream lineStream(line);
|
||||
|
||||
point p
|
||||
STLpoint p
|
||||
(
|
||||
readScalar(lineStream),
|
||||
readScalar(lineStream),
|
||||
@ -106,7 +107,7 @@ bool Foam::fileFormats::TRIsurfaceFormatCore::read
|
||||
dynPoints.append(p);
|
||||
dynPoints.append
|
||||
(
|
||||
point
|
||||
STLpoint
|
||||
(
|
||||
readScalar(lineStream),
|
||||
readScalar(lineStream),
|
||||
@ -115,7 +116,7 @@ bool Foam::fileFormats::TRIsurfaceFormatCore::read
|
||||
);
|
||||
dynPoints.append
|
||||
(
|
||||
point
|
||||
STLpoint
|
||||
(
|
||||
readScalar(lineStream),
|
||||
readScalar(lineStream),
|
||||
@ -179,4 +180,43 @@ bool Foam::fileFormats::TRIsurfaceFormatCore::read
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::TRIsurfaceFormatCore::clear()
|
||||
{
|
||||
sorted_ = true;
|
||||
points_.clear();
|
||||
zoneIds_.clear();
|
||||
sizes_.clear();
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::fileFormats::TRIsurfaceFormatCore::mergePointsMap
|
||||
(
|
||||
labelList& pointMap
|
||||
) const
|
||||
{
|
||||
// Use merge tolerance as per STL ascii
|
||||
return mergePointsMap
|
||||
(
|
||||
100 * doubleScalarSMALL,
|
||||
pointMap
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::fileFormats::TRIsurfaceFormatCore::mergePointsMap
|
||||
(
|
||||
const scalar mergeTol,
|
||||
labelList& pointMap
|
||||
) const
|
||||
{
|
||||
return Foam::mergePoints
|
||||
(
|
||||
points_,
|
||||
mergeTol,
|
||||
false, // verbose
|
||||
pointMap
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -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) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,7 +36,7 @@ SourceFiles
|
||||
#define TRIsurfaceFormatCore_H
|
||||
|
||||
#include "surfaceFormatsCore.H"
|
||||
#include "triFace.H"
|
||||
#include "STLpoint.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -58,7 +58,7 @@ class TRIsurfaceFormatCore
|
||||
bool sorted_;
|
||||
|
||||
//- The points supporting the facets
|
||||
pointField points_;
|
||||
List<STLpoint> points_;
|
||||
|
||||
//- The zones associated with the faces
|
||||
List<label> zoneIds_;
|
||||
@ -83,7 +83,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Read from file, filling in the information
|
||||
TRIsurfaceFormatCore(const fileName&);
|
||||
TRIsurfaceFormatCore(const fileName& filename);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -92,35 +92,39 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Flush all values
|
||||
void clear();
|
||||
|
||||
//- Calculate merge points mapping, return old to new pointMap.
|
||||
// Use merge tolerance as per STL ascii
|
||||
// \return number of unique points
|
||||
label mergePointsMap(labelList& pointMap) const;
|
||||
|
||||
//- Calculate merge points mapping, return old to new pointMap.
|
||||
// \return number of unique points
|
||||
label mergePointsMap(const scalar mergeTol, labelList& pointMap) const;
|
||||
|
||||
|
||||
//- File read was already sorted
|
||||
bool sorted() const
|
||||
inline bool sorted() const
|
||||
{
|
||||
return sorted_;
|
||||
}
|
||||
|
||||
//- Flush all values
|
||||
void clear()
|
||||
{
|
||||
sorted_ = true;
|
||||
points_.clear();
|
||||
zoneIds_.clear();
|
||||
sizes_.clear();
|
||||
}
|
||||
|
||||
//- Return full access to the points
|
||||
pointField& points()
|
||||
inline List<STLpoint>& points()
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
|
||||
//- Return full access to the zones
|
||||
List<label>& zoneIds()
|
||||
inline List<label>& zoneIds()
|
||||
{
|
||||
return zoneIds_;
|
||||
}
|
||||
|
||||
//- The list of zone sizes in the order of their first appearance
|
||||
List<label>& sizes()
|
||||
inline List<label>& sizes()
|
||||
{
|
||||
return sizes_;
|
||||
}
|
||||
|
||||
@ -24,7 +24,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "STLReader.H"
|
||||
#include "mergePoints.H"
|
||||
#include "triSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
@ -42,21 +41,12 @@ bool Foam::triSurface::readSTL(const fileName& STLfileName, bool forceBinary)
|
||||
)
|
||||
);
|
||||
|
||||
// Stitch points
|
||||
// Get the map for stitched surface points, with merge tolerance depending
|
||||
// on the input format
|
||||
labelList pointMap;
|
||||
label nUniquePoints = mergePoints
|
||||
(
|
||||
reader.points(),
|
||||
(
|
||||
// With the merge distance depending on the input format
|
||||
(reader.stlFormat() == fileFormats::STLCore::BINARY ? 10 : 100)
|
||||
* SMALL
|
||||
),
|
||||
false, // verbose
|
||||
pointMap // old to new point map
|
||||
);
|
||||
const label nUniquePoints = reader.mergePointsMap(pointMap);
|
||||
|
||||
const pointField& readpts = reader.points();
|
||||
const auto& readpts = reader.points();
|
||||
const labelList& zoneIds = reader.zoneIds();
|
||||
|
||||
pointField& pointLst = storedPoints();
|
||||
@ -84,18 +74,16 @@ bool Foam::triSurface::readSTL(const fileName& STLfileName, bool forceBinary)
|
||||
f.region() = zoneIds[i];
|
||||
}
|
||||
|
||||
// Set patch names (and sizes)
|
||||
// - there is likely a more efficient means of doing this
|
||||
// Set patch name/index.
|
||||
if (reader.stlFormat() == fileFormats::STLCore::ASCII)
|
||||
{
|
||||
const List<word>& names = reader.names();
|
||||
|
||||
patches_.setSize(names.size());
|
||||
forAll(names, namei)
|
||||
forAll(patches_, patchi)
|
||||
{
|
||||
patches_[namei].name() = names[namei];
|
||||
patches_[patchi] = geometricSurfacePatch(names[patchi], patchi);
|
||||
}
|
||||
setDefaultPatches();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user