Jet  v1.3.3
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
jet::TriangleMesh3 Class Referencefinal

3-D triangle mesh geometry. More...

#include <jet/triangle_mesh3.h>

Inheritance diagram for jet::TriangleMesh3:
jet::Surface3

Classes

class  Builder
 Front-end to create TriangleMesh3 objects step by step. More...
 

Public Types

typedef Array1< Vector2DVector2DArray
 
typedef Array1< Vector3DVector3DArray
 
typedef Array1< Point3UIIndexArray
 
typedef Vector3DArray PointArray
 
typedef Vector3DArray NormalArray
 
typedef Vector2DArray UvArray
 

Public Member Functions

 TriangleMesh3 (const Transform3 &transform=Transform3(), bool isNormalFlipped=false)
 Default constructor. More...
 
 TriangleMesh3 (const PointArray &points, const NormalArray &normals, const UvArray &uvs, const IndexArray &pointIndices, const IndexArray &normalIndices, const IndexArray &uvIndices, const Transform3 &transform_=Transform3(), bool isNormalFlipped=false)
 Constructs mesh with points, normals, uvs, and their indices. More...
 
 TriangleMesh3 (const TriangleMesh3 &other)
 Copy constructor. More...
 
void updateQueryEngine () override
 Updates internal spatial query engine. More...
 
void updateQueryEngine () const
 Updates internal spatial query engine. More...
 
void clear ()
 Clears all content. More...
 
void set (const TriangleMesh3 &other)
 Copies the contents from other mesh. More...
 
void swap (TriangleMesh3 &other)
 Swaps the contents with other mesh. More...
 
double area () const
 Returns area of this mesh. More...
 
double volume () const
 Returns volume of this mesh. More...
 
const Vector3Dpoint (size_t i) const
 Returns constant reference to the i-th point. More...
 
Vector3Dpoint (size_t i)
 Returns reference to the i-th point. More...
 
const Vector3Dnormal (size_t i) const
 Returns constant reference to the i-th normal. More...
 
Vector3Dnormal (size_t i)
 Returns reference to the i-th normal. More...
 
const Vector2Duv (size_t i) const
 Returns constant reference to the i-th UV coordinates. More...
 
Vector2Duv (size_t i)
 Returns reference to the i-th UV coordinates. More...
 
const Point3UIpointIndex (size_t i) const
 Returns constant reference to the point indices of i-th triangle. More...
 
Point3UIpointIndex (size_t i)
 Returns reference to the point indices of i-th triangle. More...
 
const Point3UInormalIndex (size_t i) const
 Returns constant reference to the normal indices of i-th triangle. More...
 
Point3UInormalIndex (size_t i)
 Returns reference to the normal indices of i-th triangle. More...
 
const Point3UIuvIndex (size_t i) const
 Returns constant reference to the UV indices of i-th triangle. More...
 
Point3UIuvIndex (size_t i)
 Returns reference to the UV indices of i-th triangle. More...
 
Triangle3 triangle (size_t i) const
 Returns i-th triangle. More...
 
size_t numberOfPoints () const
 Returns number of points. More...
 
size_t numberOfNormals () const
 Returns number of normals. More...
 
size_t numberOfUvs () const
 Returns number of UV coordinates. More...
 
size_t numberOfTriangles () const
 Returns number of triangles. More...
 
bool hasNormals () const
 Returns true if the mesh has normals. More...
 
bool hasUvs () const
 Returns true if the mesh has UV coordinates. More...
 
void addPoint (const Vector3D &pt)
 Adds a point. More...
 
void addNormal (const Vector3D &n)
 Adds a normal. More...
 
void addUv (const Vector2D &t)
 Adds a UV. More...
 
void addPointTriangle (const Point3UI &newPointIndices)
 Adds a triangle with points. More...
 
void addNormalTriangle (const Point3UI &newNormalIndices)
 Adds a triangle with normal. More...
 
void addUvTriangle (const Point3UI &newUvIndices)
 Adds a triangle with UV. More...
 
void addPointNormalTriangle (const Point3UI &newPointIndices, const Point3UI &newNormalIndices)
 Adds a triangle with point and normal. More...
 
void addPointUvNormalTriangle (const Point3UI &newPointIndices, const Point3UI &newUvIndices, const Point3UI &newNormalIndices)
 Adds a triangle with point, normal, and UV. More...
 
void addPointUvTriangle (const Point3UI &newPointIndices, const Point3UI &newUvIndices)
 Adds a triangle with point and UV. More...
 
void addTriangle (const Triangle3 &tri)
 Add a triangle. More...
 
void setFaceNormal ()
 Sets entire normals to the face normals. More...
 
void setAngleWeightedVertexNormal ()
 Sets angle weighted vertex normal. More...
 
void scale (double factor)
 Scales the mesh by given factor. More...
 
void translate (const Vector3D &t)
 Translates the mesh. More...
 
void rotate (const QuaternionD &q)
 Rotates the mesh. More...
 
void writeObj (std::ostream *strm) const
 Writes the mesh in obj format to the output stream. More...
 
bool writeObj (const std::string &filename) const
 Writes the mesh in obj format to the file. More...
 
bool readObj (std::istream *strm)
 Reads the mesh in obj format from the input stream. More...
 
bool readObj (const std::string &filename)
 Reads the mesh in obj format from the file. More...
 
TriangleMesh3operator= (const TriangleMesh3 &other)
 Copies other mesh. More...
 
- Public Member Functions inherited from jet::Surface3
 Surface3 (const Transform3 &transform=Transform3(), bool isNormalFlipped=false)
 Constructs a surface with normal direction. More...
 
 Surface3 (const Surface3 &other)
 Copy constructor. More...
 
virtual ~Surface3 ()
 Default destructor. More...
 
Vector3D closestPoint (const Vector3D &otherPoint) const
 
BoundingBox3D boundingBox () const
 Returns the bounding box of this surface object. More...
 
bool intersects (const Ray3D &ray) const
 Returns true if the given ray intersects with this surface object. More...
 
double closestDistance (const Vector3D &otherPoint) const
 
SurfaceRayIntersection3 closestIntersection (const Ray3D &ray) const
 Returns the closest intersection point for given ray. More...
 
Vector3D closestNormal (const Vector3D &otherPoint) const
 
virtual bool isBounded () const
 Returns true if bounding box can be defined. More...
 
virtual bool isValidGeometry () const
 Returns true if the surface is a valid geometry. More...
 
bool isInside (const Vector3D &otherPoint) const
 

Static Public Member Functions

static Builder builder ()
 Returns builder fox TriangleMesh3. More...
 

Protected Member Functions

Vector3D closestPointLocal (const Vector3D &otherPoint) const override
 
double closestDistanceLocal (const Vector3D &otherPoint) const override
 
bool intersectsLocal (const Ray3D &ray) const override
 
BoundingBox3D boundingBoxLocal () const override
 Returns the bounding box of this surface object in local frame. More...
 
Vector3D closestNormalLocal (const Vector3D &otherPoint) const override
 
SurfaceRayIntersection3 closestIntersectionLocal (const Ray3D &ray) const override
 Returns the closest intersection point for given ray in local frame. More...
 
bool isInsideLocal (const Vector3D &otherPoint) const override
 

Additional Inherited Members

- Public Attributes inherited from jet::Surface3
Transform3 transform
 Local-to-world transform. More...
 
bool isNormalFlipped = false
 Flips normal when calling Surface3::closestNormal(...). More...
 

Detailed Description

3-D triangle mesh geometry.

This class represents 3-D triangle mesh geometry which extends Surface3 by overriding surface-related queries. The mesh structure stores point, normals, and UV coordinates.

Member Typedef Documentation

◆ IndexArray

◆ NormalArray

◆ PointArray

◆ UvArray

◆ Vector2DArray

◆ Vector3DArray

Constructor & Destructor Documentation

◆ TriangleMesh3() [1/3]

jet::TriangleMesh3::TriangleMesh3 ( const Transform3 transform = Transform3(),
bool  isNormalFlipped = false 
)

Default constructor.

◆ TriangleMesh3() [2/3]

jet::TriangleMesh3::TriangleMesh3 ( const PointArray points,
const NormalArray normals,
const UvArray uvs,
const IndexArray pointIndices,
const IndexArray normalIndices,
const IndexArray uvIndices,
const Transform3 transform_ = Transform3(),
bool  isNormalFlipped = false 
)

Constructs mesh with points, normals, uvs, and their indices.

◆ TriangleMesh3() [3/3]

jet::TriangleMesh3::TriangleMesh3 ( const TriangleMesh3 other)

Copy constructor.

Member Function Documentation

◆ addNormal()

void jet::TriangleMesh3::addNormal ( const Vector3D n)

Adds a normal.

◆ addNormalTriangle()

void jet::TriangleMesh3::addNormalTriangle ( const Point3UI newNormalIndices)

Adds a triangle with normal.

◆ addPoint()

void jet::TriangleMesh3::addPoint ( const Vector3D pt)

Adds a point.

◆ addPointNormalTriangle()

void jet::TriangleMesh3::addPointNormalTriangle ( const Point3UI newPointIndices,
const Point3UI newNormalIndices 
)

Adds a triangle with point and normal.

◆ addPointTriangle()

void jet::TriangleMesh3::addPointTriangle ( const Point3UI newPointIndices)

Adds a triangle with points.

◆ addPointUvNormalTriangle()

void jet::TriangleMesh3::addPointUvNormalTriangle ( const Point3UI newPointIndices,
const Point3UI newUvIndices,
const Point3UI newNormalIndices 
)

Adds a triangle with point, normal, and UV.

◆ addPointUvTriangle()

void jet::TriangleMesh3::addPointUvTriangle ( const Point3UI newPointIndices,
const Point3UI newUvIndices 
)

Adds a triangle with point and UV.

◆ addTriangle()

void jet::TriangleMesh3::addTriangle ( const Triangle3 tri)

Add a triangle.

◆ addUv()

void jet::TriangleMesh3::addUv ( const Vector2D t)

Adds a UV.

◆ addUvTriangle()

void jet::TriangleMesh3::addUvTriangle ( const Point3UI newUvIndices)

Adds a triangle with UV.

◆ area()

double jet::TriangleMesh3::area ( ) const

Returns area of this mesh.

◆ boundingBoxLocal()

BoundingBox3D jet::TriangleMesh3::boundingBoxLocal ( ) const
overrideprotectedvirtual

Returns the bounding box of this surface object in local frame.

Implements jet::Surface3.

◆ builder()

static Builder jet::TriangleMesh3::builder ( )
static

Returns builder fox TriangleMesh3.

◆ clear()

void jet::TriangleMesh3::clear ( )

Clears all content.

◆ closestDistanceLocal()

double jet::TriangleMesh3::closestDistanceLocal ( const Vector3D otherPoint) const
overrideprotectedvirtual

Returns the closest distance from the given point otherPoint to the point on the surface in local frame.

Reimplemented from jet::Surface3.

◆ closestIntersectionLocal()

SurfaceRayIntersection3 jet::TriangleMesh3::closestIntersectionLocal ( const Ray3D ray) const
overrideprotectedvirtual

Returns the closest intersection point for given ray in local frame.

Implements jet::Surface3.

◆ closestNormalLocal()

Vector3D jet::TriangleMesh3::closestNormalLocal ( const Vector3D otherPoint) const
overrideprotectedvirtual

Returns the normal to the closest point on the surface from the given point otherPoint in local frame.

Implements jet::Surface3.

◆ closestPointLocal()

Vector3D jet::TriangleMesh3::closestPointLocal ( const Vector3D otherPoint) const
overrideprotectedvirtual

Returns the closest point from the given point otherPoint to the surface in local frame.

Implements jet::Surface3.

◆ hasNormals()

bool jet::TriangleMesh3::hasNormals ( ) const

Returns true if the mesh has normals.

◆ hasUvs()

bool jet::TriangleMesh3::hasUvs ( ) const

Returns true if the mesh has UV coordinates.

◆ intersectsLocal()

bool jet::TriangleMesh3::intersectsLocal ( const Ray3D ray) const
overrideprotectedvirtual

Returns true if the given ray intersects with this surface object in local frame.

Reimplemented from jet::Surface3.

◆ isInsideLocal()

bool jet::TriangleMesh3::isInsideLocal ( const Vector3D otherPoint) const
overrideprotectedvirtual

Returns true if otherPoint is inside by given depth the volume defined by the surface in local frame.

Reimplemented from jet::Surface3.

◆ normal() [1/2]

Vector3D& jet::TriangleMesh3::normal ( size_t  i)

Returns reference to the i-th normal.

◆ normal() [2/2]

const Vector3D& jet::TriangleMesh3::normal ( size_t  i) const

Returns constant reference to the i-th normal.

◆ normalIndex() [1/2]

Point3UI& jet::TriangleMesh3::normalIndex ( size_t  i)

Returns reference to the normal indices of i-th triangle.

◆ normalIndex() [2/2]

const Point3UI& jet::TriangleMesh3::normalIndex ( size_t  i) const

Returns constant reference to the normal indices of i-th triangle.

◆ numberOfNormals()

size_t jet::TriangleMesh3::numberOfNormals ( ) const

Returns number of normals.

◆ numberOfPoints()

size_t jet::TriangleMesh3::numberOfPoints ( ) const

Returns number of points.

◆ numberOfTriangles()

size_t jet::TriangleMesh3::numberOfTriangles ( ) const

Returns number of triangles.

◆ numberOfUvs()

size_t jet::TriangleMesh3::numberOfUvs ( ) const

Returns number of UV coordinates.

◆ operator=()

TriangleMesh3& jet::TriangleMesh3::operator= ( const TriangleMesh3 other)

Copies other mesh.

◆ point() [1/2]

Vector3D& jet::TriangleMesh3::point ( size_t  i)

Returns reference to the i-th point.

◆ point() [2/2]

const Vector3D& jet::TriangleMesh3::point ( size_t  i) const

Returns constant reference to the i-th point.

◆ pointIndex() [1/2]

Point3UI& jet::TriangleMesh3::pointIndex ( size_t  i)

Returns reference to the point indices of i-th triangle.

◆ pointIndex() [2/2]

const Point3UI& jet::TriangleMesh3::pointIndex ( size_t  i) const

Returns constant reference to the point indices of i-th triangle.

◆ readObj() [1/2]

bool jet::TriangleMesh3::readObj ( const std::string &  filename)

Reads the mesh in obj format from the file.

◆ readObj() [2/2]

bool jet::TriangleMesh3::readObj ( std::istream *  strm)

Reads the mesh in obj format from the input stream.

◆ rotate()

void jet::TriangleMesh3::rotate ( const QuaternionD q)

Rotates the mesh.

◆ scale()

void jet::TriangleMesh3::scale ( double  factor)

Scales the mesh by given factor.

◆ set()

void jet::TriangleMesh3::set ( const TriangleMesh3 other)

Copies the contents from other mesh.

◆ setAngleWeightedVertexNormal()

void jet::TriangleMesh3::setAngleWeightedVertexNormal ( )

Sets angle weighted vertex normal.

◆ setFaceNormal()

void jet::TriangleMesh3::setFaceNormal ( )

Sets entire normals to the face normals.

◆ swap()

void jet::TriangleMesh3::swap ( TriangleMesh3 other)

Swaps the contents with other mesh.

◆ translate()

void jet::TriangleMesh3::translate ( const Vector3D t)

Translates the mesh.

◆ triangle()

Triangle3 jet::TriangleMesh3::triangle ( size_t  i) const

Returns i-th triangle.

◆ updateQueryEngine() [1/2]

void jet::TriangleMesh3::updateQueryEngine ( ) const

Updates internal spatial query engine.

◆ updateQueryEngine() [2/2]

void jet::TriangleMesh3::updateQueryEngine ( )
overridevirtual

Updates internal spatial query engine.

Reimplemented from jet::Surface3.

◆ uv() [1/2]

Vector2D& jet::TriangleMesh3::uv ( size_t  i)

Returns reference to the i-th UV coordinates.

◆ uv() [2/2]

const Vector2D& jet::TriangleMesh3::uv ( size_t  i) const

Returns constant reference to the i-th UV coordinates.

◆ uvIndex() [1/2]

Point3UI& jet::TriangleMesh3::uvIndex ( size_t  i)

Returns reference to the UV indices of i-th triangle.

◆ uvIndex() [2/2]

const Point3UI& jet::TriangleMesh3::uvIndex ( size_t  i) const

Returns constant reference to the UV indices of i-th triangle.

◆ volume()

double jet::TriangleMesh3::volume ( ) const

Returns volume of this mesh.

◆ writeObj() [1/2]

bool jet::TriangleMesh3::writeObj ( const std::string &  filename) const

Writes the mesh in obj format to the file.

◆ writeObj() [2/2]

void jet::TriangleMesh3::writeObj ( std::ostream *  strm) const

Writes the mesh in obj format to the output stream.


The documentation for this class was generated from the following file: