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>
40 #include <Eigen/Dense>
41 #include <Eigen/Sparse>
43 #include "ConfigExamples.h"
45 using namespace DGtal;
72 auto nf = vertices.size();
73 Eigen::VectorXd ph(nf);
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);
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;
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"))
226 auto params = SH3::defaultParameters() | SHG3::defaultParameters() | SHG3::parametersGeometryEstimation();
227 params(
"surfaceComponents",
"All");
229 std::string filename = examplesPath + std::string(
"/samples/bunny-32.vol");
230 auto binary_image = SH3::makeBinaryImage(filename, params );
234 auto primalSurface = SH3::makePrimalSurfaceMesh(
surface);
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();
255 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 .
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...
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
std::map< Cell, IdxVertex > Cell2Index
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
PolygonalCalculus< SH3::RealPoint, SH3::RealVector >::Vector phi(const Face f)
Shortcuts< Z3i::KSpace > SH3
ShortcutsGeometry< Z3i::KSpace > SHG3
CountedPtr< SH3::DigitalSurface > surface
CountedPtr< SH3::BinaryImage > binary_image
DigitalPlane::Point Vector
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 ...
RealPoint & position(Vertex v)
const Vertices & incidentVertices(Face f) const
Edges computeNonManifoldEdges() const
K init(Point(0, 0, 0), Point(512, 512, 512), true)
EigenLinearAlgebraBackend::SparseMatrix SparseMatrix