SurfaceToImplicit3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: SurfaceToImplicit3.h
3 > Project Name: CubbyFlow
4 > Author: Dongmin Kim
5 > Purpose: 3-D implicit surface wrapper for generic Surface3 instance.
6 > Created Time: 2017/04/18
7 > Copyright (c) 2018, Dongmin Kim
8 *************************************************************************/
9 #ifndef CUBBYFLOW_SURFACE_TO_IMPLICIT3_H
10 #define CUBBYFLOW_SURFACE_TO_IMPLICIT3_H
11 
13 
14 namespace CubbyFlow
15 {
27  class SurfaceToImplicit3 final : public ImplicitSurface3
28  {
29  public:
30  class Builder;
31 
34  const Surface3Ptr& surface,
35  const Transform3& transform = Transform3(),
36  bool isNormalFlipped = false);
37 
40 
42  Surface3Ptr GetSurface() const;
43 
45  static Builder GetBuilder();
46 
47  protected:
48  Vector3D ClosestPointLocal(const Vector3D& otherPoint) const override;
49 
50  double ClosestDistanceLocal(const Vector3D& otherPoint) const override;
51 
52  bool IntersectsLocal(const Ray3D& ray) const override;
53 
54  BoundingBox3D BoundingBoxLocal() const override;
55 
56  Vector3D ClosestNormalLocal(const Vector3D& ohterPoint) const override;
57 
58  double SignedDistanceLocal(const Vector3D& otherPoint) const override;
59 
60  SurfaceRayIntersection3 ClosestIntersectionLocal(const Ray3D& ray) const override;
61 
62  private:
63  Surface3Ptr m_surface;
64  };
65 
67  using SurfaceToImplicit3Ptr = std::shared_ptr<SurfaceToImplicit3>;
68 
72  class SurfaceToImplicit3::Builder final : public SurfaceBuilderBase3<SurfaceToImplicit3::Builder>
73  {
74  public:
76  Builder& WithSurface(const Surface3Ptr& surface);
77 
79  SurfaceToImplicit3 Build() const;
80 
83  private:
84  Surface3Ptr m_surface;
85  };
86 }
87 
88 #endif
SurfaceToImplicit3 Build() const
Builds SurfaceToImplicit3.
3-D vector class.
Definition: Vector3.h:26
BoundingBox3D BoundingBoxLocal() const override
Returns the bounding box of this surface object in local frame.
static Builder GetBuilder()
Returns builder for SurfaceToImplicit3.
SurfaceRayIntersection3 ClosestIntersectionLocal(const Ray3D &ray) const override
Returns the closest intersection point for given ray in local frame.
Structure that represents ray-surface intersection point.
Definition: Surface3.h:23
SurfaceToImplicit3Ptr MakeShared() const
Builds shared pointer of SurfaceToImplicit3 instance.
Front-end to create SurfaceToImplicit3 objects step by step.
Definition: SurfaceToImplicit3.h:72
Base class for 3-D surface builder.
Definition: Surface3.h:106
double SignedDistanceLocal(const Vector3D &otherPoint) const override
Returns signed distance from the given point otherPoint in local space.
Definition: pybind11Utils.h:24
Builder & WithSurface(const Surface3Ptr &surface)
Returns builder with surface.
std::shared_ptr< SurfaceToImplicit3 > SurfaceToImplicit3Ptr
Shared pointer for the SurfaceToImplicit3.
Definition: SurfaceToImplicit3.h:67
Transform3 transform
Local-to-world transform.
Definition: Surface3.h:36
std::shared_ptr< Surface3 > Surface3Ptr
Shared pointer for the Surface3 type.
Definition: Surface3.h:100
3-D axis-aligned bounding box class.
Definition: BoundingBox3.h:44
double ClosestDistanceLocal(const Vector3D &otherPoint) const override
Surface3Ptr GetSurface() const
Returns the raw surface instance.
Represents 3-D rigid body transform.
Definition: Transform3.h:22
bool isNormalFlipped
Flips normal when calling Surface3::closestNormal(...).
Definition: Surface3.h:39
Abstract base class for 3-D implicit surface.
Definition: ImplicitSurface3.h:17
Vector3D ClosestNormalLocal(const Vector3D &ohterPoint) const override
bool IntersectsLocal(const Ray3D &ray) const override
Class for 3-D ray.
Definition: Ray3.h:23
3-D implicit surface wrapper for generic Surface3 instance.
Definition: SurfaceToImplicit3.h:27
SurfaceToImplicit3(const Surface3Ptr &surface, const Transform3 &transform=Transform3(), bool isNormalFlipped=false)
Constructs an instance with generic Surface3 instance.
Vector3D ClosestPointLocal(const Vector3D &otherPoint) const override