mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: minor regression. STL reading in double, not float (issue #491)
- By definition, binary STL uses float (not double) when reading. The ascii STL should be the same. This reduces memory overhead when loading files. The older triSurface reader had float, the surfMesh reader had double, but now has float. - Inconsistency in the STL merge-tolerances between triSurface reader, surfMesh reader and WM_SP vs WM_DP. Now use consistent tolerances conrresponding to 10,100 * doubleSMALL. - Similar float/double code adjustments for TRI format since this is very similar to the STL reader and had a similar inconsistency between the triSurface and surfMesh version. The AC3D reader still uses double when reading, but this can be revisited in the future (and can then remove the stichTriangles method too).
This commit is contained in:
@ -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_;
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ class STLASCIILexer
|
||||
label lineNo_;
|
||||
word startError_;
|
||||
|
||||
DynamicList<point> points_;
|
||||
DynamicList<STLpoint> points_;
|
||||
DynamicList<label> facets_;
|
||||
DynamicList<word> names_;
|
||||
DynamicList<label> sizes_;
|
||||
@ -105,7 +105,7 @@ public:
|
||||
}
|
||||
|
||||
//- A list of unstitched triangle points
|
||||
inline DynamicList<point>& points()
|
||||
inline DynamicList<STLpoint>& points()
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user