26#include <DGtal/base/Common.h>
27#include <DGtal/helpers/StdDefs.h>
28#include <DGtal/helpers/Shortcuts.h>
29#include <DGtal/helpers/ShortcutsGeometry.h>
30#include <DGtal/shapes/SurfaceMesh.h>
31#include <DGtal/geometry/surfaces/DigitalSurfaceRegularization.h>
32#include <DGtal/dec/PolygonalCalculus.h>
34#include <polyscope/polyscope.h>
35#include <polyscope/surface_mesh.h>
36#include <polyscope/point_cloud.h>
38#include <Eigen/Sparse>
54polyscope::SurfaceMesh *psMesh;
56std::vector<double> phiV;
60double phiVertex(
const Vertex v)
62 return cos(scale*(surfmesh.
position(v)[0]))*sin(scale*surfmesh.
position(v)[1]);
70 Eigen::VectorXd ph(nf);
74 ph(cpt) = phiVertex(v);
84 for(
auto i = 0; i < surfmesh.
nbVertices(); ++i)
85 phiV.push_back(phiVertex(i));
86 psMesh->addVertexScalarQuantity(
"Phi", phiV);
93 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Vector> gradients;
94 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Vector> cogradients;
95 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Real3dVector> normals;
96 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Real3dVector> vectorArea;
97 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Real3dPoint> centroids;
98 std::vector<double> faceArea;
100 for(
auto f=0; f < surfmesh.
nbFaces(); ++f)
104 gradients.push_back( grad );
106 cogradients.push_back( cograd );
110 vectorArea.push_back({vA(0) , vA(1), vA(2)});
112 faceArea.push_back( calculus.
faceArea(f));
117 psMesh->addFaceVectorQuantity(
"Gradients", gradients);
118 psMesh->addFaceVectorQuantity(
"co-Gradients", cogradients);
119 psMesh->addFaceVectorQuantity(
"Normals", normals);
120 psMesh->addFaceScalarQuantity(
"Face area", faceArea);
121 psMesh->addFaceVectorQuantity(
"Vector area", vectorArea);
123 polyscope::registerPointCloud(
"Centroids", centroids);
129 ImGui::SliderFloat(
"Phi scale", &scale, 0., 1.);
130 if (ImGui::Button(
"Init phi"))
133 if (ImGui::Button(
"Compute quantities"))
143 params(
"polynomial",
"goursat" )(
"gridstep", h );
153 std::vector<std::vector<SH3::SurfaceMesh::Vertex>> faces;
154 for(
auto face= 0 ; face < primalSurface->nbFaces(); ++face)
155 faces.push_back(primalSurface->incidentVertices( face ));
158 auto positions = primalSurface->positions();
160 surfmesh =
SurfMesh(positions.begin(),
168 psMesh = polyscope::registerSurfaceMesh(
"digital surface", positions, faces);
171 polyscope::state::userCallback = myCallback;
Aim: Implements basic operations that will be used in Point and Vector classes.
Implements differential operators on polygonal surfaces from .
Real3dVector faceNormalAsDGtalVector(const Face f) const
Real3dPoint centroidAsDGtalPoint(const Face f) const
Vector vectorArea(const Face f) const
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())
static CountedPtr< DigitizedImplicitShape3D > makeDigitizedImplicitShape3D(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
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)
static CountedPtr< ImplicitShape3D > makeImplicitShape3D(const Parameters ¶ms=parametersImplicitShape3D())
DGtal is the top-level namespace which contains all DGtal functions and types.
std::pair< typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_iterator, typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_iterator > vertices(const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
Aim: Represents an embedded mesh as faces and a list of vertices. Vertices may be shared among faces ...
std::vector< Vertex > Vertices
The type that defines a list/range of vertices (e.g. to define faces)
const Vertices & incidentVertices(Face f) const
RealPoint & position(Vertex v)
int main(int argc, char **argv)