Loading...
Searching...
No Matches
Box.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_BOX_HPP
12#define CUBBYFLOW_BOX_HPP
13
15
16namespace CubbyFlow
17{
25template <size_t N>
26class Box final : public Surface<N>
27{
28 public:
29 class Builder;
30
34
36 Box(const Transform<N>& _transform = Transform<N>{},
37 bool _isNormalFlipped = false);
38
40 Box(const Vector<double, N>& lowerCorner,
41 const Vector<double, N>& upperCorner,
42 const Transform<N>& _transform = Transform<N>{},
43 bool _isNormalFlipped = false);
44
46 Box(const BoundingBox<double, N>& boundingBox,
47 const Transform<N>& _transform = Transform<N>{},
48 bool _isNormalFlipped = false);
49
51 ~Box() override = default;
52
54 Box(const Box& other);
55
57 Box(Box&& other) noexcept;
58
60 Box& operator=(const Box& other);
61
63 Box& operator=(Box&& other) noexcept;
64
67
68 protected:
70 const Vector<double, N>& otherPoint) const override;
71
72 [[nodiscard]] bool IntersectsLocal(
73 const Ray<double, N>& ray) const override;
74
75 [[nodiscard]] BoundingBox<double, N> BoundingBoxLocal() const override;
76
78 const Vector<double, N>& otherPoint) const override;
79
81 const Ray<double, N>& ray) const override;
82};
83
85using Box2 = Box<2>;
86
88using Box3 = Box<3>;
89
91using Box2Ptr = std::shared_ptr<Box2>;
92
94using Box3Ptr = std::shared_ptr<Box3>;
95
99template <size_t N>
100class Box<N>::Builder final
101 : public SurfaceBuilderBase<N, typename Box<N>::Builder>
102{
103 public:
106
109
112
114 Box Build() const;
115
117 std::shared_ptr<Box<N>> MakeShared() const;
118
119 private:
121 using Base::m_isNormalFlipped;
122 using Base::m_transform;
123
124 Vector<double, N> m_lowerCorner;
126};
127} // namespace CubbyFlow
128
129#endif
N-D axis-aligned bounding box class.
Definition BoundingBox.hpp:47
Front-end to create Box objects step by step.
Definition Box.hpp:102
Builder & WithUpperCorner(const Vector< double, N > &pt)
Returns builder with upper corner set.
std::shared_ptr< Box< N > > MakeShared() const
Builds shared pointer of Box instance.
Box Build() const
Builds Box.
Builder & WithLowerCorner(const Vector< double, N > &pt)
Returns builder with lower corner set.
Builder & WithBoundingBox(const BoundingBox< double, N > &bbox)
Returns builder with bounding box.
N-D box geometry.
Definition Box.hpp:27
static Builder GetBuilder()
Returns builder fox Box.
Box(Box &&other) noexcept
Move constructor.
Vector< double, N > ClosestNormalLocal(const Vector< double, N > &otherPoint) const override
bool IntersectsLocal(const Ray< double, N > &ray) const override
Vector< double, N > ClosestPointLocal(const Vector< double, N > &otherPoint) const override
Box(const Box &other)
Copy constructor.
Box & operator=(const Box &other)
Copy assignment operator.
BoundingBox< double, N > BoundingBoxLocal() const override
Returns the bounding box of this surface object in local frame.
Box(const Vector< double, N > &lowerCorner, const Vector< double, N > &upperCorner, const Transform< N > &_transform=Transform< N >{}, bool _isNormalFlipped=false)
Constructs a box with given lowerCorner and upperCorner.
Box & operator=(Box &&other) noexcept
Move assignment operator.
Box(const BoundingBox< double, N > &boundingBox, const Transform< N > &_transform=Transform< N >{}, bool _isNormalFlipped=false)
Constructs a box with BoundingBox instance.
Box(const Transform< N > &_transform=Transform< N >{}, bool _isNormalFlipped=false)
Constructs (0, 0, ...) x (1, 1, ...) box.
SurfaceRayIntersection< N > ClosestIntersectionLocal(const Ray< double, N > &ray) const override
Returns the closest intersection point for given ray in local frame.
BoundingBox< double, N > bound
Bounding box of this box.
Definition Box.hpp:32
~Box() override=default
Default virtual destructor.
static std::enable_if_t< IsMatrixSizeStatic< Rows, Cols >(), D > MakeConstant(ValueType val)
Makes a static matrix with constant entries.
Definition MatrixDenseBase-Impl.hpp:152
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
Represents N-D rigid body transform.
Definition Transform.hpp:83
Definition pybind11Utils.hpp:21
std::shared_ptr< Box3 > Box3Ptr
Shared pointer type for the Box3.
Definition Box.hpp:94
std::shared_ptr< Box2 > Box2Ptr
Shared pointer type for the Box2.
Definition Box.hpp:91
Struct that represents ray-surface intersection point.
Definition Surface.hpp:26