Loading...
Searching...
No Matches
CustomImplicitSurface.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_CUSTOM_IMPLICIT_SURFACE_HPP
12#define CUBBYFLOW_CUSTOM_IMPLICIT_SURFACE_HPP
13
15
16namespace CubbyFlow
17{
19template <size_t N>
21{
22 public:
23 class Builder;
24
37 std::function<double(const Vector<double, N>&)> func,
39 double resolution = 1e-3, double rayMarchingResolution = 1e-6,
40 unsigned int maxNumOfIterations = 5,
42 bool _isNormalFlipped = false);
43
45 ~CustomImplicitSurface() override = default;
46
49
52
55 default;
56
59 default;
60
63
64 private:
65 [[nodiscard]] Vector<double, N> ClosestPointLocal(
66 const Vector<double, N>& otherPoint) const override;
67
68 [[nodiscard]] bool IntersectsLocal(
69 const Ray<double, N>& ray) const override;
70
71 [[nodiscard]] BoundingBox<double, N> BoundingBoxLocal() const override;
72
73 [[nodiscard]] Vector<double, N> ClosestNormalLocal(
74 const Vector<double, N>& otherPoint) const override;
75
76 [[nodiscard]] double SignedDistanceLocal(
77 const Vector<double, N>& otherPoint) const override;
78
79 [[nodiscard]] SurfaceRayIntersection<N> ClosestIntersectionLocal(
80 const Ray<double, N>& ray) const override;
81
82 [[nodiscard]] Vector<double, N> GradientLocal(
83 const Vector<double, N>& x) const;
84
85 std::function<double(const Vector<double, N>&)> m_func;
87 double m_resolution = 1e-3;
88 double m_rayMarchingResolution = 1e-6;
89 unsigned int m_maxNumOfIterations = 5;
90};
91
94
97
99using CustomImplicitSurface2Ptr = std::shared_ptr<CustomImplicitSurface2>;
100
102using CustomImplicitSurface3Ptr = std::shared_ptr<CustomImplicitSurface3>;
103
107template <size_t N>
109 : public SurfaceBuilderBase<N, typename CustomImplicitSurface<N>::Builder>
110{
111 public:
114 const std::function<double(const Vector<double, N>&)>& func);
115
118
121
125
129
132
134 std::shared_ptr<CustomImplicitSurface<N>> MakeShared() const;
135
136 private:
137 using Base =
139 using Base::m_isNormalFlipped;
140 using Base::m_transform;
141
142 std::function<double(const Vector<double, N>&)> m_func;
143 BoundingBox<double, N> m_domain;
144 double m_resolution = 1e-3;
145 double m_rayMarchingResolution = 1e-6;
146 unsigned int m_maxNumOfIterations = 5;
147};
148} // namespace CubbyFlow
149
150#endif
Front-end to create CustomImplicitSurface objects step by step.
Definition CustomImplicitSurface.hpp:110
Builder & WithSignedDistanceFunction(const std::function< double(const Vector< double, N > &)> &func)
Returns builder with custom signed-distance function.
std::shared_ptr< CustomImplicitSurface< N > > MakeShared() const
Builds shared pointer of CustomImplicitSurface instance.
Builder & WithDomain(const BoundingBox< double, N > &domain)
Returns builder with domain.
Builder & WithResolution(double resolution)
Returns builder with finite differencing resolution.
Builder & WithMaxNumberOfIterations(unsigned int numIter)
Builder & WithRayMarchingResolution(double rayMarchingResolution)
CustomImplicitSurface< N > Build() const
Builds CustomImplicitSurface.
Custom N-D implicit surface using arbitrary function.
Definition CustomImplicitSurface.hpp:21
CustomImplicitSurface & operator=(const CustomImplicitSurface &other)=default
Default copy assignment operator.
CustomImplicitSurface(CustomImplicitSurface &&other) noexcept=default
Default move constructor.
static Builder GetBuilder()
Returns builder for CustomImplicitSurface.
CustomImplicitSurface & operator=(CustomImplicitSurface &&other) noexcept=default
Default move assignment operator.
CustomImplicitSurface(std::function< double(const Vector< double, N > &)> func, const BoundingBox< double, N > &domain=BoundingBox< double, N >{}, double resolution=1e-3, double rayMarchingResolution=1e-6, unsigned int maxNumOfIterations=5, const Transform< N > &_transform=Transform< N >{}, bool _isNormalFlipped=false)
~CustomImplicitSurface() override=default
Default virtual destructor.
CustomImplicitSurface(const CustomImplicitSurface &other)=default
Default copy constructor.
Abstract base class for N-D implicit surface.
Definition ImplicitSurface.hpp:21
Definition Matrix.hpp:30
Base class for N-D surface builder.
Definition Surface.hpp:154
Definition pybind11Utils.hpp:21
std::shared_ptr< CustomImplicitSurface2 > CustomImplicitSurface2Ptr
Shared pointer type for the CustomImplicitSurface2.
Definition CustomImplicitSurface.hpp:99
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738
std::shared_ptr< CustomImplicitSurface3 > CustomImplicitSurface3Ptr
Shared pointer type for the CustomImplicitSurface3.
Definition CustomImplicitSurface.hpp:102