7#include <MRPch/MREigenSparseCore.h>
55 [[nodiscard]]
const VertBitSet &
region()
const {
return region_; }
58 [[nodiscard]]
const VertBitSet &
freeVerts()
const {
return freeVerts_; }
61 [[nodiscard]]
const VertBitSet &
firstLayerFixedVerts()
const { assert( solverValid_ );
return firstLayerFixedVerts_; }
70 template <
typename I,
typename G,
typename S>
71 void prepareRhs_(
I && iniRhs, G && g, S && s );
80 VertBitSet freeVerts_;
83 VertBitSet fixedSharpVertices_;
86 VertBitSet firstLayerFixedVerts_;
92 double centerCoeff = 0;
95 std::vector<Equation> equations_;
102 std::vector<Element> nonZeroElements_;
105 Vector< int, VertId > regionVert2id_;
106 Vector< int, VertId > freeVert2id_;
108 using SparseMatrix = Eigen::SparseMatrix<double,Eigen::RowMajor>;
112 bool solverValid_ =
false;
113 using SparseMatrixColMajor = Eigen::SparseMatrix<double,Eigen::ColMajor>;
119 virtual ~Solver() =
default;
120 virtual void compute(
const SparseMatrixColMajor& A ) = 0;
121 virtual Eigen::VectorXd solve(
const Eigen::VectorXd& rhs ) = 0;
123 std::unique_ptr<Solver> solver_;
126 bool rhsValid_ =
false;
127 Eigen::VectorXd rhs_[3];
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
Definition MRMesh/MRLaplacian.h:21
const VertBitSet & freeVerts() const
return currently free vertices
Definition MRMesh/MRLaplacian.h:58
MRMESH_API void apply()
given fixed vertices, computes positions of remaining region vertices
const VertBitSet & firstLayerFixedVerts() const
return fixed vertices from the first layer around free vertices
Definition MRMesh/MRLaplacian.h:61
MRMESH_API void fixVertex(VertId v, const Vector3f &fixedPos, bool smooth=true)
MRMESH_API void updateSolver()
if you manually call this method after initialization and fixing vertices then next apply call will b...
RememberShape
Definition MRMesh/MRLaplacian.h:24
MRMESH_API Laplacian(Mesh &mesh)
Laplacian(const MeshTopology &topology, VertCoords &points)
Definition MRMesh/MRLaplacian.h:30
MRMESH_API void init(const VertBitSet &freeVerts, EdgeWeights weights, VertexMass vmass=VertexMass::Unit, RememberShape rem=Laplacian::RememberShape::Yes)
const VertBitSet & region() const
return all initially free vertices and the first layer of vertices around them
Definition MRMesh/MRLaplacian.h:55
MRMESH_API void fixVertex(VertId v, bool smooth=true)
MRMESH_API void applyToScalar(VertScalars &scalarField)
given a pre-resized scalar field with set values in fixed vertices, computes the values in free verti...
Definition MRMesh/MRMeshTopology.h:19
Definition MRCameraOrientationPlugin.h:8
EdgeWeights
determines the weight of each edge in applications like Laplacian
Definition MREnums.h:41
I
Definition MRMesh/MRMeshFwd.h:130
VertexMass
determines the weight or mass of each vertex in applications like Laplacian
Definition MREnums.h:31
@ Unit
all vertices have same mass=1
Definition MRMesh/MRMesh.h:23