Go to the documentation of this file.
42 auto nt = tris.
size();
56 for(
auto i=0; i<nt; i++)
59 const auto& tri = tris[i];
63 "Invalid triangle "<< tri <<
endl;
67 if(
auto np =
find(points, tri.comp1()); np<0 )
69 points.push_back(tri.comp1());
70 newTri.
comp1() =
static_cast<uint32>( basePointIndex + points.
size() - 1);
74 newTri.
comp1() = basePointIndex+
static_cast<uint32>(np);
77 if(
auto np =
find(points, tri.comp2()); np<0 )
79 points.push_back(tri.comp2());
80 newTri.
comp2() =
static_cast<uint32>( basePointIndex + points.
size() - 1);
84 newTri.
comp2() = basePointIndex+
static_cast<uint32>(np);
87 if(
auto np =
find(points, tri.comp3()); np<0 )
89 points.push_back(tri.comp3());
90 newTri.
comp3() =
static_cast<uint32>( basePointIndex + points.
size() - 1);
94 newTri.
comp3() = basePointIndex+
static_cast<uint32>(np);
128 uint32 basePointIndex = numPoints();
130 auto triData = triangles.
getSpan();
146 "Error in constructing triSuface from raw data "<<triangles.
name()<<
endl;
150 points_.append(points);
151 vertices_.append(vertices);
160 uint32 basePointIndex = numPoints();
162 auto triData = triangles.
getSpan();
178 "Error in constructing triSuface from raw data "<<triangles.
name()<<
endl;
182 points_.append(points);
183 vertices_.append(vertices);
249 if( !append(triangles) )
260 if(!points_.read(is, iop,
true))
263 " when reading field "<< points_.name()<<
endl;
268 if(!vertices_.read(is, iop,
true))
271 " when reading field "<< vertices_.name()<<
endl;
275 normals_.reallocate(vertices_.capacity(), vertices_.size());
276 area_.reallocate(vertices_.capacity(), vertices_.size());
284 if( !points_.write(os, iop))
287 "when writing field "<<points_.name()<<
endl;
291 if( !vertices_.write(os,iop) )
294 "when writing field "<<vertices_.name()<<
endl;
INLINE_FUNCTION_H bool calculateNormals(const realx3Field_D &points, const uint32x3Field_D &vertices, realx3Field_D &normals)
#define fatalExit
Fatal exit.
realx3Field_D normals_
normal vector of triangles
INLINE_FUNCTION_HD bool valid(const realx3 &p1, const realx3 &p2, const realx3 &p3)
int64 find(Vector< T, Allocator > &vec, const T &val)
INLINE_FUNCTION_HD T & comp3()
access component
void reserve(size_t cap)
Reserve capacity for vector Preserve the content.
INLINE_FUNCTION_HD uint32 size() const
Returns the number of elements in the span.
INLINE_FUNCTION_HD realx3 normal(const realx3 &p1, const realx3 &p2, const realx3 &p3)
auto size() const
Size of the vector.
bool write(iOstream &os, const IOPattern &iop) const override
iOstream & endl(iOstream &os)
Add newline and flush stream.
realx3Field_D points_
points of triangles
Interface class for any input stream
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
INLINE_FUNCTION_H auto getSpan()
uint32x3Field_D vertices_
vectices indices of triangles
virtual const word & name() const
INLINE_FUNCTION_HD T & comp1()
access component
virtual const word & name() const
Return the name of the stream.
INLINE_FUNCTION_H bool calculateArea(const realx3Field_D &points, const uint32x3Field_D &vertices, realField_D &area)
bool read(iIstream &is, const IOPattern &iop) override
const word & name() const
Name of the vector.
#define ioErrorInFile(fileName, lineNumber)
Report an error in file operation with supplied fileName and lineNumber.
virtual const fileSystem & localPath() const
int32 lineNumber() const
Const access to the current stream line number.
realField_D area_
area of each triangle
triSurface(const objectFile &obj, repository *owner)
A set of 3 variables that can be used for vector variables.
bool convertToTriSurfaceComponents(uint32 basePointIndex, span< realx3x3 > tris, realx3Vector &points, uint32x3Vector &vertices, realVector &area, realx3Vector &normal)
Interface class for any output stream.
bool append(const realx3x3Field_H &triangles)
INLINE_FUNCTION_HD real surface(const realx3 &p1, const realx3 &p2, const realx3 &p3)
INLINE_FUNCTION_HD T & comp2()
access component