SurfaceToImplicit2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: SurfaceToImplicit2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 2-D implicit surface wrapper for generic Surface2 instance.
6 > Created Time: 2017/04/16
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_SURFACE_TO_IMPLICIT2_H
10 #define CUBBYFLOW_SURFACE_TO_IMPLICIT2_H
11 
13 
14 namespace CubbyFlow
15 {
25  class SurfaceToImplicit2 final : public ImplicitSurface2
26  {
27  public:
28  class Builder;
29 
32  const Surface2Ptr& surface,
33  const Transform2& transform = Transform2(),
34  bool isNormalFlipped = false);
35 
38 
40  Surface2Ptr GetSurface() const;
41 
43  static Builder GetBuilder();
44 
45  protected:
46  Vector2D ClosestPointLocal(const Vector2D& otherPoint) const override;
47 
48  double ClosestDistanceLocal(const Vector2D& otherPoint) const override;
49 
50  bool IntersectsLocal(const Ray2D& ray) const override;
51 
52  BoundingBox2D BoundingBoxLocal() const override;
53 
54  Vector2D ClosestNormalLocal(const Vector2D& otherPoint) const override;
55 
56  double SignedDistanceLocal(const Vector2D& otherPoint) const override;
57 
58  SurfaceRayIntersection2 ClosestIntersectionLocal(const Ray2D& ray) const override;
59 
60  private:
61  Surface2Ptr m_surface;
62  };
63 
65  using SurfaceToImplicit2Ptr = std::shared_ptr<SurfaceToImplicit2>;
66 
70  class SurfaceToImplicit2::Builder final : public SurfaceBuilderBase2<SurfaceToImplicit2::Builder>
71  {
72  public:
74  Builder& WithSurface(const Surface2Ptr& surface);
75 
77  SurfaceToImplicit2 Build() const;
78 
81 
82  private:
83  Surface2Ptr m_surface;
84  };
85 }
86 
87 #endif
Builder & WithSurface(const Surface2Ptr &surface)
Returns builder with surface.
Vector2D ClosestPointLocal(const Vector2D &otherPoint) const override
2-D implicit surface wrapper for generic Surface2 instance.
Definition: SurfaceToImplicit2.h:25
double ClosestDistanceLocal(const Vector2D &otherPoint) const override
Vector2D ClosestNormalLocal(const Vector2D &otherPoint) const override
Base class for 2-D surface builder.
Definition: Surface2.h:106
Class for 2-D ray.
Definition: Ray2.h:23
Represents 2-D rigid body transform.
Definition: Transform2.h:21
SurfaceToImplicit2 Build() const
Builds SurfaceToImplicit2.
double SignedDistanceLocal(const Vector2D &otherPoint) const override
Returns signed distance from the given point otherPoint in local space.
Transform2 transform
Local-to-world transform.
Definition: Surface2.h:36
Structure that represents ray-surface intersection point.
Definition: Surface2.h:23
SurfaceRayIntersection2 ClosestIntersectionLocal(const Ray2D &ray) const override
Returns the closest intersection point for given ray in local frame.
2-D axis-aligned bounding box class.
Definition: BoundingBox2.h:44
bool isNormalFlipped
Flips normal.
Definition: Surface2.h:39
Definition: pybind11Utils.h:24
static Builder GetBuilder()
Returns builder for SurfaceToImplicit2.
SurfaceToImplicit2Ptr MakeShared() const
Builds shared pointer of SurfaceToImplicit2 instance.
bool IntersectsLocal(const Ray2D &ray) const override
Abstract base class for 2-D implicit surface.
Definition: ImplicitSurface2.h:17
Surface2Ptr GetSurface() const
Returns the raw surface instance.
2-D vector class.
Definition: Vector2.h:26
Front-end to create SurfaceToImplicit2 objects step by step.
Definition: SurfaceToImplicit2.h:70
SurfaceToImplicit2(const Surface2Ptr &surface, const Transform2 &transform=Transform2(), bool isNormalFlipped=false)
Constructs an instance with generic Surface2 instance.
std::shared_ptr< SurfaceToImplicit2 > SurfaceToImplicit2Ptr
Shared pointer for the SurfaceToImplicit2 type.
Definition: SurfaceToImplicit2.h:65
std::shared_ptr< Surface2 > Surface2Ptr
Shared pointer for the Surface2 type.
Definition: Surface2.h:100
BoundingBox2D BoundingBoxLocal() const override
Returns the bounding box of this surface object in local frame.