ShapeOp  0.1.0
Solver.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 SOLVER_H
13 #define SOLVER_H
14 #include <vector>
17 #include <memory>
18 #include "Types.h"
20 
22 namespace ShapeOp {
25 // Forward Declarations
26 class LSSolver;
27 class Constraint;
28 class Force;
30 
32  public:
34  int addConstraint(const std::shared_ptr<Constraint> &c);
36  std::shared_ptr<Constraint> &getConstraint(int id);
38  int addForces(const std::shared_ptr<Force> &f);
40  std::shared_ptr<Force> &getForce(int id);
42  void setPoints(const Matrix3X &p);
44  void setTimeStep(Scalar timestep);
46  void setDamping(Scalar damping);
48  const Matrix3X &getPoints();
51  bool initialize(bool dynamic = false, Scalar masses = 1.0, Scalar damping = 1.0, Scalar timestep = 1.0);
54  bool solve(unsigned int iteration);
55  private:
56  typedef std::vector<std::shared_ptr<Constraint> > Constraints;
57  typedef std::vector<std::shared_ptr<Force> > Forces;
58 
59 //Static
60  Matrix3X points_;
61  Matrix3X projections_;
62  Constraints constraints_;
63  std::shared_ptr<LSSolver> solver_;
64  SparseMatrix At_;
65  SparseMatrix N_;
66 
67 //Dynamic
68  bool dynamic_;
69  SparseMatrix M_;
70  Matrix3X oldPoints_;
71  Matrix3X velocities_;
72  Matrix3X momentum_;
73  Scalar masses_;
74  Forces forces_;
75  Scalar damping_;
76  Scalar delta_;
77 };
79 } // namespace ShapeOp
81 #ifdef SHAPEOP_HEADER_ONLY
82 #include "Solver.cpp"
83 #endif
84 #endif // SOLVER_H
86 
SparseMatrixT SparseMatrix
The default sparse matrix of Eigen.
Definition: Types.h:52
MatrixT< 3, Eigen::Dynamic > Matrix3X
A 3 by n matrix.
Definition: Types.h:45
ShapeOp Solver. This class implements the main ShapeOp solver based on and .
Definition: Solver.h:31
Namespace of the ShapeOp library.
Definition: Constraint.cpp:18
ShapeOpScalar Scalar
A scalar type, double or float, as defined in ShapeOpScalar in Common.h.
Definition: Types.h:32
#define SHAPEOP_API
Defines the API prefix for the current platform.
Definition: Common.h:34