VertexCenteredScalarGrid2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: VertexCenteredScalarGrid2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 2-D Vertex-centered scalar grid structure.
6 > Created Time: 2017/07/07
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_VERTEX_CENTERED_SCALAR_GRID2_H
10 #define CUBBYFLOW_VERTEX_CENTERED_SCALAR_GRID2_H
11 
12 #include <Core/Grid/ScalarGrid2.h>
13 
14 namespace CubbyFlow
15 {
25  {
26  public:
28 
29  class Builder;
30 
33 
37  size_t resolutionX, size_t resolutionY,
38  double gridSpacingX = 1.0, double gridSpacingY = 1.0,
39  double originX = 0.0, double originY = 0.0,
40  double initialValue = 0.0);
41 
45  const Size2& resolution,
46  const Vector2D& gridSpacing = Vector2D(1.0, 1.0),
47  const Vector2D& origin = Vector2D(),
48  double initialValue = 0.0);
49 
52 
54  Size2 GetDataSize() const override;
55 
59  Vector2D GetDataOrigin() const override;
60 
62  std::shared_ptr<ScalarGrid2> Clone() const override;
63 
70  void Swap(Grid2* other) override;
71 
73  void Set(const VertexCenteredScalarGrid2& other);
74 
77 
79  static Builder GetBuilder();
80  };
81 
83  using VertexCenteredScalarGrid2Ptr = std::shared_ptr<VertexCenteredScalarGrid2>;
84 
87  {
88  public:
90  Builder& WithResolution(const Size2& resolution);
91 
93  Builder& WithResolution(size_t resolutionX, size_t resolutionY);
94 
96  Builder& WithGridSpacing(const Vector2D& gridSpacing);
97 
99  Builder& WithGridSpacing(double gridSpacingX, double gridSpacingY);
100 
102  Builder& WithOrigin(const Vector2D& gridOrigin);
103 
105  Builder& WithOrigin(double gridOriginX, double gridOriginY);
106 
108  Builder& WithInitialValue(double initialVal);
109 
112 
115 
122  const Size2& resolution,
123  const Vector2D& gridSpacing,
124  const Vector2D& gridOrigin,
125  double initialVal) const override;
126 
127  private:
128  Size2 m_resolution{ 1, 1 };
129  Vector2D m_gridSpacing{ 1, 1 };
130  Vector2D m_gridOrigin{ 0, 0 };
131  double m_initialVal = 0.0;
132  };
133 }
134 
135 #endif
Size2 GetDataSize() const override
Returns the actual data point size.
VertexCenteredScalarGrid2 Build() const
Builds VertexCenteredScalarGrid2 instance.
void Swap(Grid2 *other) override
Swaps the contents with the given other grid.
void Set(const VertexCenteredScalarGrid2 &other)
Sets the contents with the given other grid.
VertexCenteredScalarGrid2()
Constructs zero-sized grid.
Abstract base class for 2-D cartesian grid structure.
Definition: Grid2.h:30
Abstract base class for 2-D scalar grid builder.
Definition: ScalarGrid2.h:182
std::shared_ptr< ScalarGrid2 > Clone() const override
Returns the copy of the grid instance.
2-D Vertex-centered scalar grid structure.
Definition: VertexCenteredScalarGrid2.h:24
2-D point class.
Definition: Point2.h:25
VertexCenteredScalarGrid2Ptr MakeShared() const
Builds shared pointer of VertexCenteredScalarGrid2 instance.
static Builder GetBuilder()
Returns builder fox VertexCenteredScalarGrid2.
Definition: pybind11Utils.h:24
Builder & WithGridSpacing(const Vector2D &gridSpacing)
Returns builder with grid spacing.
std::shared_ptr< ScalarGrid2 > ScalarGrid2Ptr
Shared pointer for the ScalarGrid2 type.
Definition: ScalarGrid2.h:179
Vector2< double > Vector2D
Double-type 2D vector.
Definition: Vector2.h:341
VertexCenteredScalarGrid2 & operator=(const VertexCenteredScalarGrid2 &other)
Sets the contents with the given other grid.
Vector2D GetDataOrigin() const override
#define CUBBYFLOW_GRID2_TYPE_NAME(DerivedClassName)
Definition: Grid2.h:110
A grid builder class that returns 2-D vertex-centered scalar grid.
Definition: VertexCenteredScalarGrid2.h:86
2-D vector class.
Definition: Vector2.h:26
Builder & WithOrigin(const Vector2D &gridOrigin)
Returns builder with grid origin.
Builder & WithResolution(const Size2 &resolution)
Returns builder with resolution.
Abstract base class for 2-D scalar grid structure.
Definition: ScalarGrid2.h:21
std::shared_ptr< VertexCenteredScalarGrid2 > VertexCenteredScalarGrid2Ptr
Shared pointer for the VertexCenteredScalarGrid2 type.
Definition: VertexCenteredScalarGrid2.h:83
Builder & WithInitialValue(double initialVal)
Returns builder with initial value.