DGtal 1.3.0
Loading...
Searching...
No Matches
dgtalCalculus-single.cpp
1
25#include <iostream>
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>
33
34#include <polyscope/polyscope.h>
35#include <polyscope/surface_mesh.h>
36#include <polyscope/point_cloud.h>
37#include <polyscope/curve_network.h>
38
39#include <Eigen/Dense>
40#include <Eigen/Sparse>
41
42using namespace DGtal;
43using namespace Z3i;
44
45// Using standard 3D digital space.
48// The following typedefs are useful
52typedef SurfMesh::Face Face;
54
55
56//Polyscope global
57polyscope::SurfaceMesh *psMesh;
58polyscope::PointCloud *psVertices;
59polyscope::CurveNetwork *psBoundary;
60
61SurfMesh surfmesh;
63
64void initPhi()
65{
66 phiEigen.resize(5);
67 phiEigen << 1.0, 2.0, 0.0, 5.0 ,1.5;
68
69 psMesh->addVertexScalarQuantity("Phi", phiEigen);
70 psVertices->addScalarQuantity("Phi", phiEigen);
71}
72
73void initQuantities()
74{
76
77 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Vector> gradients;
78 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Vector> cogradients;
79 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Real3dPoint> normals;
80 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Real3dPoint> vectorArea;
81 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Real3dPoint> centroids;
82 std::vector<double> faceArea;
83
85
87 gradients.push_back( grad );
88
90 cogradients.push_back( cograd );
91
92 normals.push_back(calculus.faceNormalAsDGtalVector(f));
93
95 vectorArea.push_back({vA(0) , vA(1), vA(2)});
96
97 faceArea.push_back( calculus.faceArea(f));
98 centroids.push_back( calculus.centroidAsDGtalPoint(f) );
99
102
103 psMesh->addFaceVectorQuantity("Gradients", gradients);
104 psMesh->addFaceVectorQuantity("co-Gradients", cogradients);
105 psMesh->addFaceVectorQuantity("Normals", normals);
106 psMesh->addFaceScalarQuantity("Face area", faceArea);
107 psMesh->addFaceVectorQuantity("Vector area", vectorArea);
108
109 psBoundary->addEdgeScalarQuantity("d0*phi", dPhi);
110 psBoundary->addEdgeScalarQuantity("A*phi", av);
111
112 //Face centroid
113 polyscope::registerPointCloud("Centroids", centroids);
114
115 //Flat Sharp
117 v << 50,-50,-100;
118 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Vector> someV={v};
119 psMesh->addFaceVectorQuantity("A vector", someV);
120
122 psBoundary->addEdgeScalarQuantity("flat (1-form)", flat);
123
125 std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Vector> sharpRes={sharp};
126 psMesh->addFaceVectorQuantity("Sharp", sharpRes);
127}
128
129int main()
130{
131 std::vector<RealPoint> positions={ {0,0,0},{20,0,0}, {20,10,0}, {10,8,5}, {0,15,1} };
132 std::vector<std::vector<size_t>> faces={ {0,1,2,3,4} };
133
134 surfmesh = SurfMesh(positions.begin(),
135 positions.end(),
136 faces.begin(),
137 faces.end());
138
139 psVertices = polyscope::registerPointCloud("Vertices", positions);
140
141 std::vector<std::array<size_t,2>> edges={{0,1},{1,2},{2,3},{3,4},{4,0} };
142 psBoundary = polyscope::registerCurveNetwork("Edges", positions, edges);
143
144 // Initialize polyscope
145 polyscope::init();
146
147 psMesh = polyscope::registerSurfaceMesh("Single face", positions, faces);
148
149 initPhi();
150 initQuantities();
151
152 polyscope::show();
153 return EXIT_SUCCESS;
154
155}
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
Implements differential operators on polygonal surfaces from .
DenseMatrix D(const Face f) const
Real3dVector faceNormalAsDGtalVector(const Face f) const
Real3dPoint centroidAsDGtalPoint(const Face f) const
Vector vectorArea(const Face f) const
DenseMatrix sharp(const Face f) const
double faceArea(const Face f) const
DenseMatrix coGradient(const Face f) const
DenseMatrix gradient(const Face f) const
MySurfaceMesh::Face Face
Face type.
LinAlg::DenseVector Vector
Type of Vector.
DenseMatrix A(const Face f) const
DenseMatrix flat(const Face f) const
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...
Definition: Shortcuts.h:105
SMesh::Vertices Vertices
DGtal is the top-level namespace which contains all DGtal functions and types.
std::pair< typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator, typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator > edges(const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
Aim: Represents an embedded mesh as faces and a list of vertices. Vertices may be shared among faces ...
Definition: SurfaceMesh.h:92
std::vector< Vertex > Vertices
The type that defines a list/range of vertices (e.g. to define faces)
Definition: SurfaceMesh.h:112
TRealPoint RealPoint
Definition: SurfaceMesh.h:93
int main(int argc, char **argv)
TriMesh::Face Face
TriMesh::Vertex Vertex