Jet  v1.3.3
box3.h
Go to the documentation of this file.
1 // Copyright (c) 2018 Doyub Kim
2 //
3 // I am making my contributions/submissions to this project solely in my
4 // personal capacity and am not conveying any rights to any intellectual
5 // property of any third parties.
6 
7 #ifndef INCLUDE_JET_BOX3_H_
8 #define INCLUDE_JET_BOX3_H_
9 
10 #include <jet/surface3.h>
11 #include <jet/bounding_box3.h>
12 
13 namespace jet {
14 
22 class Box3 final : public Surface3 {
23  public:
24  class Builder;
25 
28  = BoundingBox3D(Vector3D(), Vector3D(1.0, 1.0, 1.0));
29 
32  const Transform3& transform = Transform3(),
33  bool isNormalFlipped = false);
34 
37  const Vector3D& lowerCorner,
38  const Vector3D& upperCorner,
39  const Transform3& transform = Transform3(),
40  bool isNormalFlipped = false);
41 
43  explicit Box3(
45  const Transform3& transform = Transform3(),
46  bool isNormalFlipped = false);
47 
49  Box3(const Box3& other);
50 
52  static Builder builder();
53 
54  protected:
55  // Surface3 implementations
56 
57  Vector3D closestPointLocal(const Vector3D& otherPoint) const override;
58 
59  bool intersectsLocal(const Ray3D& ray) const override;
60 
61  BoundingBox3D boundingBoxLocal() const override;
62 
63  Vector3D closestNormalLocal(const Vector3D& otherPoint) const override;
64 
66  const Ray3D& ray) const override;
67 };
68 
70 typedef std::shared_ptr<Box3> Box3Ptr;
71 
72 
76 class Box3::Builder final : public SurfaceBuilderBase3<Box3::Builder> {
77  public:
80 
83 
86 
88  Box3 build() const;
89 
92 
93  private:
94  Vector3D _lowerCorner{0, 0, 0};
95  Vector3D _upperCorner{1, 1, 1};
96 };
97 
98 } // namespace jet
99 
100 
101 #endif // INCLUDE_JET_BOX3_H_
jet::Box3::Box3
Box3(const BoundingBox3D &boundingBox, const Transform3 &transform=Transform3(), bool isNormalFlipped=false)
Constructs a box with BoundingBox3D instance.
jet::Box3Ptr
std::shared_ptr< Box3 > Box3Ptr
Shared pointer type for the Box3.
Definition: box3.h:70
jet::Box3::intersectsLocal
bool intersectsLocal(const Ray3D &ray) const override
jet::Box3::builder
static Builder builder()
Returns builder fox Box3.
jet::Box3::Builder::withUpperCorner
Builder & withUpperCorner(const Vector3D &pt)
Returns builder with upper corner set.
surface3.h
jet::BoundingBox< T, 3 >
3-D axis-aligned bounding box class.
Definition: bounding_box3.h:41
jet::Box3::closestPointLocal
Vector3D closestPointLocal(const Vector3D &otherPoint) const override
jet::Box3::bound
BoundingBox3D bound
Bounding box of this box.
Definition: box3.h:28
jet::Box3::Builder::build
Box3 build() const
Builds Box3.
jet::SurfaceBuilderBase3
Base class for 3-D surface builder.
Definition: surface3.h:115
jet::Box3::Box3
Box3(const Box3 &other)
Copy constructor.
jet::Surface3::isNormalFlipped
bool isNormalFlipped
Flips normal when calling Surface3::closestNormal(...).
Definition: surface3.h:33
jet::Box3::Builder::withBoundingBox
Builder & withBoundingBox(const BoundingBox3D &bbox)
Returns builder with bounding box.
jet::Box3::boundingBoxLocal
BoundingBox3D boundingBoxLocal() const override
Returns the bounding box of this surface object in local frame.
jet
Definition: advection_solver2.h:18
jet::Box3::Builder
Front-end to create Box3 objects step by step.
Definition: box3.h:76
jet::BoundingBox3D
BoundingBox3< double > BoundingBox3D
Double-type 3-D BoundingBox.
Definition: bounding_box3.h:127
jet::Box3::Box3
Box3(const Transform3 &transform=Transform3(), bool isNormalFlipped=false)
Constructs (0, 0, 0) x (1, 1, 1) box.
jet::Box3::Builder::makeShared
Box3Ptr makeShared() const
Builds shared pointer of Box3 instance.
jet::Box3::closestIntersectionLocal
SurfaceRayIntersection3 closestIntersectionLocal(const Ray3D &ray) const override
Returns the closest intersection point for given ray in local frame.
jet::Box3
3-D box geometry.
Definition: box3.h:22
jet::Surface3::transform
Transform3 transform
Local-to-world transform.
Definition: surface3.h:30
jet::Ray< T, 3 >
Class for 2-D ray.
Definition: ray3.h:21
jet::SurfaceRayIntersection3
Struct that represents ray-surface intersection point.
Definition: surface3.h:19
jet::Vector3D
Vector3< double > Vector3D
Double-type 3D vector.
Definition: vector3.h:349
jet::Box3::Builder::withLowerCorner
Builder & withLowerCorner(const Vector3D &pt)
Returns builder with lower corner set.
jet::Vector< T, 3 >
3-D vector class.
Definition: vector3.h:25
jet::Box3::Box3
Box3(const Vector3D &lowerCorner, const Vector3D &upperCorner, const Transform3 &transform=Transform3(), bool isNormalFlipped=false)
Constructs a box with given lowerCorner and upperCorner.
jet::Surface3::boundingBox
BoundingBox3D boundingBox() const
Returns the bounding box of this surface object.
bounding_box3.h
jet::Transform3
Represents 3-D rigid body transform.
Definition: transform3.h:20
jet::Box3::closestNormalLocal
Vector3D closestNormalLocal(const Vector3D &otherPoint) const override
jet::Surface3
Abstract base class for 3-D surface.
Definition: surface3.h:27