ConstantVectorField2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: ConstantVectorField2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 2-D constant vector field.
6 > Created Time: 2017/04/01
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_CONSTANT_VECTOR_FIELD2_H
10 #define CUBBYFLOW_CONSTANT_VECTOR_FIELD2_H
11 
13 
14 namespace CubbyFlow
15 {
17  class ConstantVectorField2 final : public VectorField2
18  {
19  public:
20  class Builder;
21 
23  explicit ConstantVectorField2(const Vector2D& value);
24 
26  Vector2D Sample(const Vector2D& x) const override;
27 
29  std::function<Vector2D(const Vector2D&)> Sampler() const override;
30 
32  static Builder GetBuilder();
33 
34  private:
35  Vector2D m_value;
36  };
37 
39  using ConstantVectorField2Ptr = std::shared_ptr<ConstantVectorField2>;
40 
41 
46  {
47  public:
49  Builder& WithValue(const Vector2D& value);
50 
53 
56 
57  private:
58  Vector2D m_value{ 0, 0 };
59  };
60 }
61 
62 #endif
ConstantVectorField2(const Vector2D &value)
Constructs a constant vector field with given value.
std::shared_ptr< ConstantVectorField2 > ConstantVectorField2Ptr
Shared pointer for the ConstantVectorField2 type.
Definition: ConstantVectorField2.h:39
Front-end to create ConstantVectorField2 objects step by step.
Definition: ConstantVectorField2.h:45
Definition: pybind11Utils.h:24
Vector2D Sample(const Vector2D &x) const override
Returns the sampled value at given position x.
Builder & WithValue(const Vector2D &value)
Returns builder with value.
ConstantVectorField2 Build() const
Builds ConstantVectorField2.
std::function< Vector2D(const Vector2D &)> Sampler() const override
Returns the sampler function.
2-D constant vector field.
Definition: ConstantVectorField2.h:17
ConstantVectorField2Ptr MakeShared() const
Builds shared pointer of ConstantVectorField2 instance.
2-D vector class.
Definition: Vector2.h:26
Abstract base class for 2-D vector field.
Definition: VectorField2.h:21
static Builder GetBuilder()
Returns builder fox ConstantVectorField2.