DGtal  1.5.beta
dgtalCalculus-single.cpp File Reference
#include <iostream>
#include <DGtal/base/Common.h>
#include <DGtal/helpers/StdDefs.h>
#include <DGtal/helpers/Shortcuts.h>
#include <DGtal/helpers/ShortcutsGeometry.h>
#include <DGtal/shapes/SurfaceMesh.h>
#include <DGtal/geometry/surfaces/DigitalSurfaceRegularization.h>
#include <DGtal/dec/PolygonalCalculus.h>
#include <polyscope/polyscope.h>
#include <polyscope/surface_mesh.h>
#include <polyscope/point_cloud.h>
#include <polyscope/curve_network.h>
#include <Eigen/Dense>
#include <Eigen/Sparse>
Include dependency graph for dgtalCalculus-single.cpp:

Go to the source code of this file.

Typedefs

typedef Shortcuts< Z3i::KSpaceSH3
 
typedef ShortcutsGeometry< Z3i::KSpaceSHG3
 
typedef SurfaceMesh< RealPoint, RealVectorSurfMesh
 
typedef SurfMesh::Vertices Vertices
 
typedef SurfMesh::RealPoint RealPoint
 
typedef SurfMesh::Face Face
 
typedef SurfMesh::Vertex Vertex
 

Functions

void initPhi ()
 
void initQuantities ()
 
int main ()
 

Variables

polyscope::SurfaceMesh * psMesh
 
polyscope::PointCloud * psVertices
 
polyscope::CurveNetwork * psBoundary
 
SurfMesh surfmesh
 
PolygonalCalculus< SH3::RealPoint, SH3::RealVector >::Vector phiEigen
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systemes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2021/09/02

This file is part of the DGtal library.

Definition in file dgtalCalculus-single.cpp.

Typedef Documentation

◆ Face

Definition at line 53 of file dgtalCalculus-single.cpp.

◆ RealPoint

Definition at line 52 of file dgtalCalculus-single.cpp.

◆ SH3

Definition at line 47 of file dgtalCalculus-single.cpp.

◆ SHG3

Definition at line 48 of file dgtalCalculus-single.cpp.

◆ SurfMesh

Definition at line 50 of file dgtalCalculus-single.cpp.

◆ Vertex

Definition at line 54 of file dgtalCalculus-single.cpp.

◆ Vertices

Definition at line 51 of file dgtalCalculus-single.cpp.

Function Documentation

◆ initPhi()

void initPhi ( )

Definition at line 65 of file dgtalCalculus-single.cpp.

66 {
67  phiEigen.resize(5);
68  phiEigen << 1.0, 2.0, 0.0, 5.0 ,1.5;
69 
70  psMesh->addVertexScalarQuantity("Phi", phiEigen);
71  psVertices->addScalarQuantity("Phi", phiEigen);
72 }
PolygonalCalculus< SH3::RealPoint, SH3::RealVector >::Vector phiEigen
polyscope::SurfaceMesh * psMesh
polyscope::PointCloud * psVertices

References phiEigen, psMesh, and psVertices.

Referenced by main().

◆ initQuantities()

void initQuantities ( )

Definition at line 74 of file dgtalCalculus-single.cpp.

75 {
77 
80  std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Real3dPoint> normals;
81  std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Real3dPoint> vectorArea;
82  std::vector<PolygonalCalculus<SH3::RealPoint,SH3::RealVector>::Real3dPoint> centroids;
83  std::vector<double> faceArea;
84 
86 
88  gradients.push_back( grad );
89 
91  cogradients.push_back( cograd );
92 
93  normals.push_back(calculus.faceNormalAsDGtalVector(f));
94 
96  vectorArea.push_back({vA(0) , vA(1), vA(2)});
97 
98  faceArea.push_back( calculus.faceArea(f));
99  centroids.push_back( calculus.centroidAsDGtalPoint(f) );
100 
103 
104  psMesh->addFaceVectorQuantity("Gradients", gradients);
105  psMesh->addFaceVectorQuantity("co-Gradients", cogradients);
106  psMesh->addFaceVectorQuantity("Normals", normals);
107  psMesh->addFaceScalarQuantity("Face area", faceArea);
108  psMesh->addFaceVectorQuantity("Vector area", vectorArea);
109 
110  psBoundary->addEdgeScalarQuantity("d0*phi", dPhi);
111  psBoundary->addEdgeScalarQuantity("A*phi", av);
112 
113  //Face centroid
114  polyscope::registerPointCloud("Centroids", centroids);
115 
116  //Flat Sharp
118  v << 50,-50,-100;
120  psMesh->addFaceVectorQuantity("A vector", someV);
121 
123  psBoundary->addEdgeScalarQuantity("flat (1-form)", flat);
124 
127  psMesh->addFaceVectorQuantity("Sharp", sharpRes);
128 }
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
PolyCalculus * calculus
polyscope::CurveNetwork * psBoundary
SurfMesh surfmesh
DigitalPlane::Point Vector

References DGtal::PolygonalCalculus< TRealPoint, TRealVector >::A(), calculus, DGtal::PolygonalCalculus< TRealPoint, TRealVector >::centroidAsDGtalPoint(), DGtal::PolygonalCalculus< TRealPoint, TRealVector >::coGradient(), DGtal::PolygonalCalculus< TRealPoint, TRealVector >::D(), DGtal::PolygonalCalculus< TRealPoint, TRealVector >::faceArea(), DGtal::PolygonalCalculus< TRealPoint, TRealVector >::faceNormalAsDGtalVector(), DGtal::PolygonalCalculus< TRealPoint, TRealVector >::flat(), DGtal::PolygonalCalculus< TRealPoint, TRealVector >::gradient(), phiEigen, psBoundary, psMesh, DGtal::PolygonalCalculus< TRealPoint, TRealVector >::sharp(), surfmesh, and DGtal::PolygonalCalculus< TRealPoint, TRealVector >::vectorArea().

Referenced by main().

◆ main()

int main ( void  )

Definition at line 130 of file dgtalCalculus-single.cpp.

131 {
132  std::vector<RealPoint> positions={ {0,0,0},{20,0,0}, {20,10,0}, {10,8,5}, {0,15,1} };
133  std::vector<std::vector<size_t>> faces={ {0,1,2,3,4} };
134 
135  surfmesh = SurfMesh(positions.begin(),
136  positions.end(),
137  faces.begin(),
138  faces.end());
139 
140  psVertices = polyscope::registerPointCloud("Vertices", positions);
141 
142  std::vector<std::array<size_t,2>> edges={{0,1},{1,2},{2,3},{3,4},{4,0} };
143  psBoundary = polyscope::registerCurveNetwork("Edges", positions, edges);
144 
145  // Initialize polyscope
146  polyscope::init();
147 
148  psMesh = polyscope::registerSurfaceMesh("Single face", positions, faces);
149 
150  initPhi();
151  initQuantities();
152 
153  polyscope::show();
154  return EXIT_SUCCESS;
155 
156 }
SurfaceMesh< RealPoint, RealVector > SurfMesh
void initPhi()
void initQuantities()
std::pair< typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator, typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator > edges(const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
K init(Point(0, 0, 0), Point(512, 512, 512), true)

References init(), initPhi(), initQuantities(), psBoundary, psMesh, psVertices, and surfmesh.

Variable Documentation

◆ phiEigen

◆ psBoundary

polyscope::CurveNetwork* psBoundary

Definition at line 60 of file dgtalCalculus-single.cpp.

Referenced by initQuantities(), and main().

◆ psMesh

polyscope::SurfaceMesh* psMesh

Definition at line 58 of file dgtalCalculus-single.cpp.

Referenced by initPhi(), initQuantities(), and main().

◆ psVertices

polyscope::PointCloud* psVertices

Definition at line 59 of file dgtalCalculus-single.cpp.

Referenced by initPhi(), and main().

◆ surfmesh

SurfMesh surfmesh

Definition at line 62 of file dgtalCalculus-single.cpp.

Referenced by initQuantities(), and main().