Loading...
Searching...
No Matches
SurfaceToImplicit.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_SURFACE_TO_IMPLICIT_HPP
12#define CUBBYFLOW_SURFACE_TO_IMPLICIT_HPP
13
15
16#include <memory>
17
18namespace CubbyFlow
19{
29template <size_t N>
30class SurfaceToImplicit final : public ImplicitSurface<N>
31{
32 public:
33 class Builder;
34
37
39 SurfaceToImplicit(std::shared_ptr<Surface<N>> surface,
40 const Transform<N>& _transform = Transform<N>{},
41 bool _isNormalFlipped = false);
42
44 ~SurfaceToImplicit() override = default;
45
48
51
54
57
59 void UpdateQueryEngine() override;
60
62 [[nodiscard]] bool IsBounded() const override;
63
65 [[nodiscard]] bool IsValidGeometry() const override;
66
68 [[nodiscard]] std::shared_ptr<Surface<N>> GetSurface() const;
69
72
73 protected:
75 const Vector<double, N>& otherPoint) const override;
76
77 [[nodiscard]] double ClosestDistanceLocal(
78 const Vector<double, N>& otherPoint) const override;
79
80 [[nodiscard]] bool IntersectsLocal(
81 const Ray<double, N>& ray) const override;
82
83 [[nodiscard]] BoundingBox<double, N> BoundingBoxLocal() const override;
84
86 const Vector<double, N>& otherPoint) const override;
87
88 [[nodiscard]] double SignedDistanceLocal(
89 const Vector<double, N>& otherPoint) const override;
90
92 const Ray<double, N>& ray) const override;
93
94 private:
95 std::shared_ptr<Surface<N>> m_surface;
96};
97
100
103
105using SurfaceToImplicit2Ptr = std::shared_ptr<SurfaceToImplicit2>;
106
108using SurfaceToImplicit3Ptr = std::shared_ptr<SurfaceToImplicit3>;
109
113template <size_t N>
115 : public SurfaceBuilderBase<N, typename SurfaceToImplicit<N>::Builder>
116{
117 public:
119 Builder& WithSurface(const std::shared_ptr<Surface<N>>& surface);
120
123
125 std::shared_ptr<SurfaceToImplicit> MakeShared() const;
126
127 private:
129 using Base::m_isNormalFlipped;
130 using Base::m_transform;
131
132 std::shared_ptr<Surface<N>> m_surface;
133};
134} // namespace CubbyFlow
135
136#endif
N-D axis-aligned bounding box class.
Definition BoundingBox.hpp:47
Abstract base class for N-D implicit surface.
Definition ImplicitSurface.hpp:21
Definition Matrix.hpp:30
Class for N-D ray.
Definition Ray.hpp:26
Base class for N-D surface builder.
Definition Surface.hpp:154
Abstract base class for N-D surface.
Definition Surface.hpp:39
bool isNormalFlipped
Flips normal.
Definition Surface.hpp:102
Transform< N > transform
Local-to-world transform.
Definition Surface.hpp:99
Front-end to create SurfaceToImplicit objects step by step.
Definition SurfaceToImplicit.hpp:116
SurfaceToImplicit Build() const
Builds SurfaceToImplicit.
Builder & WithSurface(const std::shared_ptr< Surface< N > > &surface)
Returns builder with surface.
std::shared_ptr< SurfaceToImplicit > MakeShared() const
Builds shared pointer of SurfaceToImplicit instance.
N-D implicit surface wrapper for generic Surface instance.
Definition SurfaceToImplicit.hpp:31
SurfaceToImplicit(const SurfaceToImplicit &other)
Copy constructor.
BoundingBox< double, N > BoundingBoxLocal() const override
Returns the bounding box of this surface object in local frame.
double ClosestDistanceLocal(const Vector< double, N > &otherPoint) const override
Vector< double, N > ClosestNormalLocal(const Vector< double, N > &otherPoint) const override
static Builder GetBuilder()
Returns builder fox SurfaceToImplicit.
double SignedDistanceLocal(const Vector< double, N > &otherPoint) const override
std::shared_ptr< Surface< N > > GetSurface() const
Returns the raw surface instance.
bool IsValidGeometry() const override
Returns true if the surface is a valid geometry.
SurfaceToImplicit & operator=(const SurfaceToImplicit &other)
Copy assignment operator.
void UpdateQueryEngine() override
Updates internal spatial query engine.
SurfaceToImplicit(SurfaceToImplicit &&other) noexcept
Move constructor.
SurfaceToImplicit(std::shared_ptr< Surface< N > > surface, const Transform< N > &_transform=Transform< N >{}, bool _isNormalFlipped=false)
Constructs an instance with generic Surface2 instance.
SurfaceToImplicit & operator=(SurfaceToImplicit &&other) noexcept
Move assignment operator.
~SurfaceToImplicit() override=default
Default virtual destructor.
bool IntersectsLocal(const Ray< double, N > &ray) const override
bool IsBounded() const override
Returns true if bounding box can be defined.
SurfaceRayIntersection< N > ClosestIntersectionLocal(const Ray< double, N > &ray) const override
Returns the closest intersection point for given ray in local frame.
Vector< double, N > ClosestPointLocal(const Vector< double, N > &otherPoint) const override
Represents N-D rigid body transform.
Definition Transform.hpp:83
Definition pybind11Utils.hpp:21
std::shared_ptr< SurfaceToImplicit2 > SurfaceToImplicit2Ptr
Shared pointer for the SurfaceToImplicit2 type.
Definition SurfaceToImplicit.hpp:105
std::shared_ptr< SurfaceToImplicit3 > SurfaceToImplicit3Ptr
Shared pointer for the SurfaceToImplicit3 type.
Definition SurfaceToImplicit.hpp:108
Struct that represents ray-surface intersection point.
Definition Surface.hpp:26