ImplicitTriangleMesh3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: ImplicitTriangleMesh3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: TriangleMesh3 to ImplicitSurface3 converter.
6 > Created Time: 2017/09/23
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_IMPLICIT_TRIANGLE_MESH3_H
10 #define CUBBYFLOW_IMPLICIT_TRIANGLE_MESH3_H
11 
16 
17 namespace CubbyFlow
18 {
29  {
30  public:
31  class Builder;
32 
34  const TriangleMesh3Ptr& mesh,
35  size_t resolutionX,
36  double margin,
37  const Transform3& transform = Transform3(),
38  bool isNormalFlipped = false);
39 
40  virtual ~ImplicitTriangleMesh3();
41 
43  static Builder GetBuilder();
44 
47 
48  private:
49  TriangleMesh3Ptr m_mesh;
51  CustomImplicitSurface3Ptr m_customImplicitSurface;
52 
53  Vector3D ClosestPointLocal(const Vector3D& otherPoint) const override;
54 
55  double ClosestDistanceLocal(const Vector3D& otherPoint) const override;
56 
57  bool IntersectsLocal(const Ray3D& ray) const override;
58 
59  BoundingBox3D BoundingBoxLocal() const override;
60 
61  Vector3D ClosestNormalLocal(const Vector3D& otherPoint) const override;
62 
63  double SignedDistanceLocal(const Vector3D& otherPoint) const override;
64 
65  SurfaceRayIntersection3 ClosestIntersectionLocal(const Ray3D& ray) const override;
66  };
67 
69  using ImplicitTriangleMesh3Ptr = std::shared_ptr<ImplicitTriangleMesh3>;
70 
74  class ImplicitTriangleMesh3::Builder final : public SurfaceBuilderBase3<ImplicitTriangleMesh3::Builder>
75  {
76  public:
79 
81  Builder& WithResolutionX(size_t resolutionX);
82 
84  Builder& WithMargin(double margin);
85 
88 
91 
92  private:
93  TriangleMesh3Ptr m_mesh;
94  size_t m_resolutionX = 32;
95  double m_margin = 0.2;
96  };
97 }
98 
99 #endif
std::shared_ptr< VertexCenteredScalarGrid3 > VertexCenteredScalarGrid3Ptr
Shared pointer for the VertexCenteredScalarGrid3 type.
Definition: VertexCenteredScalarGrid3.h:83
3-D vector class.
Definition: Vector3.h:26
std::shared_ptr< CustomImplicitSurface3 > CustomImplicitSurface3Ptr
Shared pointer type for the CustomImplicitSurface3.
Definition: CustomImplicitSurface3.h:73
Builder & WithResolutionX(size_t resolutionX)
Returns builder with resolution in x axis.
Structure that represents ray-surface intersection point.
Definition: Surface3.h:23
Base class for 3-D surface builder.
Definition: Surface3.h:106
const VertexCenteredScalarGrid3Ptr & GetGrid() const
Returns grid data.
Definition: pybind11Utils.h:24
std::shared_ptr< TriangleMesh3 > TriangleMesh3Ptr
Shared pointer for the TriangleMesh3 type.
Definition: TriangleMesh3.h:228
Builder & WithTriangleMesh(const TriangleMesh3Ptr &mesh)
Returns builder with triangle mesh.
Transform3 transform
Local-to-world transform.
Definition: Surface3.h:36
3-D axis-aligned bounding box class.
Definition: BoundingBox3.h:44
Represents 3-D rigid body transform.
Definition: Transform3.h:22
ImplicitTriangleMesh3(const TriangleMesh3Ptr &mesh, size_t resolutionX, double margin, const Transform3 &transform=Transform3(), bool isNormalFlipped=false)
bool isNormalFlipped
Flips normal when calling Surface3::closestNormal(...).
Definition: Surface3.h:39
Abstract base class for 3-D implicit surface.
Definition: ImplicitSurface3.h:17
static Builder GetBuilder()
Returns builder fox ImplicitTriangleMesh3.
TriangleMesh3 to ImplicitSurface3 converter.
Definition: ImplicitTriangleMesh3.h:28
ImplicitTriangleMesh3Ptr MakeShared() const
Builds shared pointer of ImplicitTriangleMesh3 instance.
Builder & WithMargin(double margin)
Returns builder with margin around the mesh.
Class for 3-D ray.
Definition: Ray3.h:23
ImplicitTriangleMesh3 Build() const
Builds ImplicitTriangleMesh3.
std::shared_ptr< ImplicitTriangleMesh3 > ImplicitTriangleMesh3Ptr
Shared pointer for the ImplicitTriangleMesh3 type.
Definition: ImplicitTriangleMesh3.h:69
Front-end to create ImplicitTriangleMesh3 objects step by step.
Definition: ImplicitTriangleMesh3.h:74