28#include <DGtal/base/Common.h>
29#include <DGtal/helpers/StdDefs.h>
30#include <DGtal/helpers/Shortcuts.h>
31#include <DGtal/helpers/ShortcutsGeometry.h>
32#include <DGtal/shapes/SurfaceMesh.h>
33#include <DGtal/geometry/surfaces/DigitalSurfaceRegularization.h>
34#include <DGtal/dec/PolygonalCalculus.h>
35#include <DGtal/math/linalg/DirichletConditions.h>
37#include <polyscope/polyscope.h>
38#include <polyscope/surface_mesh.h>
39#include <polyscope/point_cloud.h>
41#include <Eigen/Sparse>
43#include "ConfigExamples.h"
72 auto nf = vertices.size();
73 Eigen::VectorXd ph(nf);
96 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Vector> gradients;
97 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Vector> cogradients;
98 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Real3dPoint> normals;
99 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Real3dPoint> vectorArea;
100 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Real3dPoint> centroids;
102 std::vector<double> faceArea;
107 gradients.push_back( grad );
110 cogradients.push_back( cograd );
115 vectorArea.push_back({vA(0) , vA(1), vA(2)});
121 psMesh->addFaceVectorQuantity(
"Gradients", gradients);
122 psMesh->addFaceVectorQuantity(
"co-Gradients", cogradients);
123 psMesh->addFaceVectorQuantity(
"Normals", normals);
124 psMesh->addFaceScalarQuantity(
"Face area", faceArea);
125 psMesh->addFaceVectorQuantity(
"Vector area", vectorArea);
134 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Vector> gradients;
135 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Vector> cogradients;
136 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Real3dPoint> normals;
137 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Real3dPoint> vectorArea;
138 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Real3dPoint> centroids;
140 std::vector<double> faceArea;
145 gradients.push_back( grad );
148 cogradients.push_back( cograd );
153 vectorArea.push_back({vA(0) , vA(1), vA(2)});
159 psMesh->addFaceVectorQuantity(
"Gradients", gradients);
160 psMesh->addFaceVectorQuantity(
"co-Gradients", cogradients);
161 psMesh->addFaceVectorQuantity(
"Normals", normals);
162 psMesh->addFaceScalarQuantity(
"Face area", faceArea);
163 psMesh->addFaceVectorQuantity(
"Vector area", vectorArea);
179 DC::IntegerVector p = DC::nullBoundaryVector( g );
180 for(
auto cpt=0; cpt< 10;++cpt)
182 int idx = rand() % nbv;
183 g( idx ) = rand() % 100;
191 DC::SparseMatrix L_dirichlet = DC::dirichletOperator( L, p );
192 solver.compute( L_dirichlet );
193 ASSERT(solver.info()==Eigen::Success);
200 ASSERT(solver.info()==Eigen::Success);
203 psMesh->addVertexScalarQuantity(
"g", g);
204 psMesh->addVertexScalarQuantity(
"u", u);
209 ImGui::SliderFloat(
"Phi scale", &scale, 0., 1.);
210 if (ImGui::Button(
"Phi and basic operators"))
215 if (ImGui::Button(
"Phi and basic operators (cached)"))
220 if(ImGui::Button(
"Compute Laplace problem"))
227 params(
"surfaceComponents",
"All");
229 std::string filename = examplesPath + std::string(
"/samples/bunny-32.vol");
237 std::vector<std::vector<SH3::SurfaceMesh::Vertex>> faces;
238 std::vector<RealPoint> positions;
240 for(
auto face= 0 ; face < primalSurface->nbFaces(); ++face)
241 faces.push_back(primalSurface->incidentVertices( face ));
244 positions = primalSurface->positions();
252 psMesh = polyscope::registerSurfaceMesh(
"digital surface", positions, faces);
Aim: A helper class to solve a system with Dirichlet boundary conditions.
Implements differential operators on polygonal surfaces from degoes2020discrete.
LinAlg::SparseMatrix SparseMatrix
Type of sparse matrix.
Real3dVector faceNormalAsDGtalVector(const Face f) const
Vector vectorArea(const Face f) const
SparseMatrix globalLaplaceBeltrami(const double lambda=1.0) const
LinAlg::SolverSimplicialLDLT Solver
Type of a sparse matrix solver.
double faceArea(const Face f) const
DenseMatrix coGradient(const Face f) const
DenseMatrix gradient(const Face f) const
LinAlg::DenseVector Vector
Type of Vector.
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
static Parameters parametersGeometryEstimation()
static Parameters defaultParameters()
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
std::map< Cell, IdxVertex > Cell2Index
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static Parameters defaultParameters()
static CountedPtr< SurfaceMesh > makePrimalSurfaceMesh(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
void beginBlock(const std::string &keyword="")
SurfaceMesh< RealPoint, RealVector > SurfMesh
PolygonalCalculus< SH3::RealPoint, SH3::RealVector >::Vector phiEigen
double phiVertex(const Vertex v)
void initQuantitiesCached()
polyscope::SurfaceMesh * psMesh
Shortcuts< Z3i::KSpace > SH3
ShortcutsGeometry< Z3i::KSpace > SHG3
PolygonalCalculus< SH3::RealPoint, SH3::RealVector >::Vector phi(const Face f)
CountedPtr< SH3::DigitalSurface > surface
CountedPtr< SH3::BinaryImage > binary_image
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Represents an embedded mesh as faces and a list of vertices. Vertices may be shared among faces ...
const Vertices & incidentVertices(Face f) const
RealPoint & position(Vertex v)
Edges computeNonManifoldEdges() const