ShapeOp
All Classes Files Functions Variables Typedefs Macros Pages
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 
31 class SHAPEOP_API Solver {
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();
50  bool initialize(bool dynamic = false, Scalar masses = 1.0, Scalar damping = 1.0, Scalar timestep = 1.0);
52  bool solve(unsigned int iteration);
54  Scalar getError(int i);
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 
66 //Dynamic
67  bool dynamic_;
68  SparseMatrix M_;
69  Matrix3X oldPoints_;
70  Matrix3X velocities_;
71  Matrix3X momentum_;
72  Scalar masses_;
73  Forces forces_;
74  Scalar damping_;
75  Scalar delta_;
76 };
78 } // namespace ShapeOp
80 #ifdef SHAPEOP_HEADER_ONLY
81 #include "Solver.cpp"
82 #endif
83 #endif // SOLVER_H
85 
ShapeOp Solver. This class implements the main ShapeOp solver based on and .
Definition: Solver.h:31