ImplicitTriangleMesh3.hpp
Go to the documentation of this file.
1 // This code is based on Jet framework.
2 // Copyright (c) 2018 Doyub Kim
3 // CubbyFlow is voxel-based fluid simulation engine for computer games.
4 // Copyright (c) 2020 CubbyFlow Team
5 // Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6 // AI Part: Dongheon Cho, Minseo Kim
7 // We are making my contributions/submissions to this project solely in our
8 // personal capacity and are not conveying any rights to any intellectual
9 // property of any third parties.
10 
11 #ifndef CUBBYFLOW_IMPLICIT_TRIANGLE_MESH3_HPP
12 #define CUBBYFLOW_IMPLICIT_TRIANGLE_MESH3_HPP
13 
18 
19 namespace CubbyFlow
20 {
31 {
32  public:
33  class Builder;
34 
37  size_t resolutionX = 32, double margin = 0.2,
38  const Transform3& _transform = Transform3{},
39  bool _isNormalFlipped = false);
40 
43 
45  ImplicitTriangleMesh3(ImplicitTriangleMesh3&&) noexcept = default;
46 
48  ~ImplicitTriangleMesh3() override = default;
49 
52 
55  default;
56 
58  [[nodiscard]] static Builder GetBuilder();
59 
61  [[nodiscard]] const VertexCenteredScalarGrid3Ptr& GetGrid() const;
62 
63  private:
64  [[nodiscard]] Vector3D ClosestPointLocal(
65  const Vector3D& otherPoint) const override;
66 
67  [[nodiscard]] double ClosestDistanceLocal(
68  const Vector3D& otherPoint) const override;
69 
70  [[nodiscard]] bool IntersectsLocal(const Ray3D& ray) const override;
71 
72  [[nodiscard]] BoundingBox3D BoundingBoxLocal() const override;
73 
74  [[nodiscard]] Vector3D ClosestNormalLocal(
75  const Vector3D& otherPoint) const override;
76 
77  [[nodiscard]] double SignedDistanceLocal(
78  const Vector3D& otherPoint) const override;
79 
80  [[nodiscard]] SurfaceRayIntersection3 ClosestIntersectionLocal(
81  const Ray3D& ray) const override;
82 
83  TriangleMesh3Ptr m_mesh;
85  CustomImplicitSurface3Ptr m_customImplicitSurface;
86 };
87 
89 using ImplicitTriangleMesh3Ptr = std::shared_ptr<ImplicitTriangleMesh3>;
90 
95 {
96  public:
98  [[nodiscard]] Builder& WithTriangleMesh(const TriangleMesh3Ptr& mesh);
99 
101  [[nodiscard]] Builder& WithResolutionX(size_t resolutionX);
102 
104  [[nodiscard]] Builder& WithMargin(double margin);
105 
107  [[nodiscard]] ImplicitTriangleMesh3 Build() const;
108 
110  [[nodiscard]] ImplicitTriangleMesh3Ptr MakeShared() const;
111 
112  private:
113  TriangleMesh3Ptr m_mesh;
114  size_t m_resolutionX = 32;
115  double m_margin = 0.2;
116 };
117 } // namespace CubbyFlow
118 
119 #endif
std::shared_ptr< VertexCenteredScalarGrid3 > VertexCenteredScalarGrid3Ptr
Shared pointer for the VertexCenteredScalarGrid3 type.
Definition: VertexCenteredScalarGrid.hpp:107
Abstract base class for N-D implicit surface.
Definition: ImplicitSurface.hpp:20
Class for N-D ray.
Definition: Ray.hpp:25
std::shared_ptr< CustomImplicitSurface3 > CustomImplicitSurface3Ptr
Shared pointer type for the CustomImplicitSurface3.
Definition: CustomImplicitSurface.hpp:102
~ImplicitTriangleMesh3() override=default
Default virtual destructor.
N-D axis-aligned bounding box class.
Definition: BoundingBox.hpp:46
ImplicitTriangleMesh3(TriangleMesh3Ptr mesh, size_t resolutionX=32, double margin=0.2, const Transform3 &_transform=Transform3{}, bool _isNormalFlipped=false)
Constructs an ImplicitSurface3 with mesh and other grid parameters.
ImplicitTriangleMesh3 & operator=(const ImplicitTriangleMesh3 &)=default
Default copy assignment operator.
Represents N-D rigid body transform.
Definition: Transform.hpp:82
Definition: Matrix.hpp:27
const VertexCenteredScalarGrid3Ptr & GetGrid() const
Returns grid data.
Definition: pybind11Utils.hpp:20
std::shared_ptr< TriangleMesh3 > TriangleMesh3Ptr
Shared pointer for the TriangleMesh3 type.
Definition: TriangleMesh3.hpp:250
Struct that represents ray-surface intersection point.
Definition: Surface.hpp:25
static Builder GetBuilder()
Returns builder fox ImplicitTriangleMesh3.
TriangleMesh3 to ImplicitSurface3 converter.
Definition: ImplicitTriangleMesh3.hpp:30
Base class for N-D surface builder.
Definition: Surface.hpp:153
std::shared_ptr< ImplicitTriangleMesh3 > ImplicitTriangleMesh3Ptr
Shared pointer for the ImplicitTriangleMesh3 type.
Definition: ImplicitTriangleMesh3.hpp:89
Front-end to create ImplicitTriangleMesh3 objects step by step.
Definition: ImplicitTriangleMesh3.hpp:94