ShapeOp
 All Classes Files Functions Variables Typedefs Macros Pages
Force.h
Go to the documentation of this file.
1 // This file is part of ShapeOp, a lightweight C++ library
3 // for static and dynamic geometry processing.
4 //
5 // Copyright (C) 2014 Sofien Bouaziz <sofien.bouaziz@gmail.com>
6 // Copyright (C) 2014 LGG EPFL
7 //
8 // This Source Code Form is subject to the terms of the Mozilla
9 // Public License v. 2.0. If a copy of the MPL was not distributed
10 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 #ifndef FORCE_H
13 #define FORCE_H
14 #include "Types.h"
17 
19 namespace ShapeOp {
22 
23 class SHAPEOP_API Force {
24  public:
25  virtual ~Force() {};
27  virtual Vector3 get(const Matrix3X &positions, int id) const = 0;
28 };
30 
31 class SHAPEOP_API GravityForce : public Force {
32  public:
34  GravityForce(const Vector3 &f);
35  virtual ~GravityForce() {};
37  virtual Vector3 get(const Matrix3X &/*positions*/, int /*id*/) const override final;
38  private:
39  Vector3 f_;
40 };
42 
43 class SHAPEOP_API VertexForce : public Force {
44  public:
46  VertexForce(const Vector3 &f = Vector3::Zero(), int id = -1);
47  virtual ~VertexForce() {};
49  virtual Vector3 get(const Matrix3X &/*position*/, int id) const override final;
51  void setId(int id);
53  void setForce(const Vector3 &f);
54  private:
55  Vector3 f_;
56  int id_;
57 };
59 } // namespace ShapeOp
61 #ifdef SHAPEOP_HEADER_ONLY
62 #include "Force.cpp"
63 #endif
64 #endif // FORCE_H
66 
Base class of any forces. This class defines interface of a ShapeOp force.
Definition: Force.h:23
This class defines a constant force for a unique vertex.
Definition: Force.h:43
This class defines a constant force for all vertices.
Definition: Force.h:31