Go to the documentation of this file.
7 #ifndef INCLUDE_JET_TRIANGLE_MESH3_H_
8 #define INCLUDE_JET_TRIANGLE_MESH3_H_
211 const Ray3D& ray)
const override;
224 mutable bool _bvhInvalidated =
true;
228 mutable bool _wnInvalidated =
true;
230 void invalidateCache();
232 void buildBvh()
const;
234 void buildWindingNumbers()
const;
236 double windingNumber(
const Vector3D& queryPoint,
size_t triIndex)
const;
238 double fastWindingNumber(
const Vector3D& queryPoint,
double accuracy)
const;
240 double fastWindingNumber(
const Vector3D& queryPoint,
size_t rootNodeIndex,
241 double accuracy)
const;
288 #endif // INCLUDE_JET_TRIANGLE_MESH3_H_
1-D array class.
Definition: array1.h:31
bool intersectsLocal(const Ray3D &ray) const override
Vector3D & normal(size_t i)
Returns reference to the i-th normal.
Array1< Point3UI > IndexArray
Definition: triangle_mesh3.h:34
void rotate(const QuaternionD &q)
Rotates the mesh.
void swap(TriangleMesh3 &other)
Swaps the contents with other mesh.
static Builder builder()
Returns builder fox TriangleMesh3.
TriangleMesh3Ptr makeShared() const
Builds shared pointer of TriangleMesh3 instance.
void setAngleWeightedVertexNormal()
Sets angle weighted vertex normal.
Array1< Vector2D > Vector2DArray
Definition: triangle_mesh3.h:30
void addPoint(const Vector3D &pt)
Adds a point.
Vector3D closestNormalLocal(const Vector3D &otherPoint) const override
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.
size_t numberOfNormals() const
Returns number of normals.
void writeObj(std::ostream *strm) const
Writes the mesh in obj format to the output stream.
Builder & withUvs(const UvArray &uvs)
Returns builder with uvs.
void translate(const Vector3D &t)
Translates the mesh.
3-D axis-aligned bounding box class.
Definition: bounding_box3.h:41
Front-end to create TriangleMesh3 objects step by step.
Definition: triangle_mesh3.h:251
Point3UI & uvIndex(size_t i)
Returns reference to the UV indices of i-th triangle.
bool readObj(std::istream *strm)
Reads the mesh in obj format from the input stream.
bool hasUvs() const
Returns true if the mesh has UV coordinates.
Builder & withUvIndices(const IndexArray &uvIndices)
Returns builder with uv indices.
double area() const
Returns area of this mesh.
Base class for 3-D surface builder.
Definition: surface3.h:115
const Point3UI & normalIndex(size_t i) const
Returns constant reference to the normal indices of i-th triangle.
3-D triangle mesh geometry.
Definition: triangle_mesh3.h:28
bool isNormalFlipped
Flips normal when calling Surface3::closestNormal(...).
Definition: surface3.h:33
void addNormal(const Vector3D &n)
Adds a normal.
bool isInsideLocal(const Vector3D &otherPoint) const override
Vector3DArray NormalArray
Definition: triangle_mesh3.h:37
void addPointNormalTriangle(const Point3UI &newPointIndices, const Point3UI &newNormalIndices)
Adds a triangle with point and normal.
size_t numberOfUvs() const
Returns number of UV coordinates.
void addPointTriangle(const Point3UI &newPointIndices)
Adds a triangle with points.
Vector2DArray UvArray
Definition: triangle_mesh3.h:38
Builder & withPointIndices(const IndexArray &pointIndices)
Returns builder with point indices.
Definition: advection_solver2.h:18
TriangleMesh3 build() const
Builds TriangleMesh3.
void scale(double factor)
Scales the mesh by given factor.
void addPointUvNormalTriangle(const Point3UI &newPointIndices, const Point3UI &newUvIndices, const Point3UI &newNormalIndices)
Adds a triangle with point, normal, and UV.
void addUv(const Vector2D &t)
Adds a UV.
void updateQueryEngine() override
Updates internal spatial query engine.
void clear()
Clears all content.
TriangleMesh3(const TriangleMesh3 &other)
Copy constructor.
Builder & withNormals(const NormalArray &normals)
Returns builder with normals.
const Vector3D & point(size_t i) const
Returns constant reference to the i-th point.
Builder & withPoints(const PointArray &points)
Returns builder with points.
2-D vector class.
Definition: vector2.h:24
Vector3D closestPointLocal(const Vector3D &otherPoint) const override
void updateQueryEngine() const
Updates internal spatial query engine.
void addPointUvTriangle(const Point3UI &newPointIndices, const Point3UI &newUvIndices)
Adds a triangle with point and UV.
Builder & withNormalIndices(const IndexArray &normalIndices)
Returns builder with normal indices.
Transform3 transform
Local-to-world transform.
Definition: surface3.h:30
size_t numberOfPoints() const
Returns number of points.
void addNormalTriangle(const Point3UI &newNormalIndices)
Adds a triangle with normal.
Class for 2-D ray.
Definition: ray3.h:21
Point3UI & pointIndex(size_t i)
Returns reference to the point indices of i-th triangle.
double closestDistanceLocal(const Vector3D &otherPoint) const override
3-D point class.
Definition: point3.h:23
const Point3UI & pointIndex(size_t i) const
Returns constant reference to the point indices of i-th triangle.
bool writeObj(const std::string &filename) const
Writes the mesh in obj format to the file.
Struct that represents ray-surface intersection point.
Definition: surface3.h:19
void setFaceNormal()
Sets entire normals to the face normals.
void addTriangle(const Triangle3 &tri)
Add a triangle.
double volume() const
Returns volume of this mesh.
const Vector3D & normal(size_t i) const
Returns constant reference to the i-th normal.
bool readObj(const std::string &filename)
Reads the mesh in obj format from the file.
3-D vector class.
Definition: vector3.h:25
Point3UI & normalIndex(size_t i)
Returns reference to the normal indices of i-th triangle.
3-D triangle geometry.
Definition: triangle3.h:20
void set(const TriangleMesh3 &other)
Copies the contents from other mesh.
Triangle3 triangle(size_t i) const
Returns i-th triangle.
Array1< Vector3D > Vector3DArray
Definition: triangle_mesh3.h:33
SurfaceRayIntersection3 closestIntersectionLocal(const Ray3D &ray) const override
Returns the closest intersection point for given ray in local frame.
std::shared_ptr< TriangleMesh3 > TriangleMesh3Ptr
Shared pointer for the TriangleMesh3 type.
Definition: triangle_mesh3.h:245
size_t numberOfTriangles() const
Returns number of triangles.
const Vector2D & uv(size_t i) const
Returns constant reference to the i-th UV coordinates.
TriangleMesh3(const Transform3 &transform=Transform3(), bool isNormalFlipped=false)
Default constructor.
void addUvTriangle(const Point3UI &newUvIndices)
Adds a triangle with UV.
Vector3DArray PointArray
Definition: triangle_mesh3.h:36
Abstract base class for 3-D surface.
Definition: surface3.h:27
bool hasNormals() const
Returns true if the mesh has normals.
TriangleMesh3 & operator=(const TriangleMesh3 &other)
Copies other mesh.
Vector3D & point(size_t i)
Returns reference to the i-th point.
BoundingBox3D boundingBoxLocal() const override
Returns the bounding box of this surface object in local frame.
const Point3UI & uvIndex(size_t i) const
Returns constant reference to the UV indices of i-th triangle.
Vector2D & uv(size_t i)
Returns reference to the i-th UV coordinates.