-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexamplePolyscope.cpp
45 lines (35 loc) · 1.46 KB
/
examplePolyscope.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <DGtal/base/Common.h>
#include <DGtal/helpers/StdDefs.h>
#include <DGtal/helpers/Shortcuts.h>
#include <DGtal/helpers/ShortcutsGeometry.h>
#include <polyscope/polyscope.h>
#include <polyscope/surface_mesh.h>
using namespace DGtal;
using namespace Z3i;
// Using standard 3D digital space.
typedef Shortcuts<Z3i::KSpace> SH3;
typedef ShortcutsGeometry<Z3i::KSpace> SHG3;
int main()
{
polyscope::init();
auto params = SH3::defaultParameters() | SHG3::defaultParameters() | SHG3::parametersGeometryEstimation();
auto h=0.5; //gridstep
params( "polynomial", "goursat" )( "gridstep", h );
auto implicit_shape = SH3::makeImplicitShape3D ( params );
auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
auto K = SH3::getKSpace( params );
auto binary_image = SH3::makeBinaryImage( digitized_shape, params );
auto surface = SH3::makeLightDigitalSurface( binary_image, K, params );
SH3::Cell2Index c2i;
auto primalSurface = SH3::makePrimalPolygonalSurface(c2i, surface);
//Need to convert the faces
std::vector<std::vector<std::size_t>> faces;
for(auto &face: primalSurface->allFaces())
faces.push_back(primalSurface->verticesAroundFace( face ));
auto digsurf = polyscope::registerSurfaceMesh("Primal surface", primalSurface->positions(), faces);
digsurf->setEdgeWidth(1.0);
digsurf->setEdgeColor({1.,1.,1.});
polyscope::show();
return 0;
}