DGtalTools 2.0.0
Loading...
Searching...
No Matches
3dDisplaySurfelData.cpp
1
29
30#include <iostream>
31#include <stdio.h>
32
33#include "DGtal/base/Common.h"
34#include "DGtal/helpers/StdDefs.h"
35#include "DGtal/io/viewers/PolyscopeViewer.h"
36#include "DGtal/io/readers/PointListReader.h"
37#include "DGtal/io/readers/MeshReader.h"
38#include "DGtal/io/colormaps/GradientColorMap.h"
39
40#include "DGtal/topology/helpers/Surfaces.h"
41#include "DGtal/topology/SurfelAdjacency.h"
42#include "DGtal/topology/CanonicCellEmbedder.h"
43#include "DGtal/math/Statistic.h"
44
45#include "DGtal/io/Color.h"
46#include "DGtal/io/colormaps/GradientColorMap.h"
47#include "DGtal/io/readers/GenericReader.h"
48
49#include "CLI11.hpp"
50
51#include <limits>
52
53using namespace std;
54using namespace DGtal;
55using namespace Z3i;
56
57
109template < typename Point>
110void
111getBoundingUpperAndLowerPoint(const std::vector<Point> &vectorPt, Point &ptLower, Point &ptUpper){
112 for(unsigned int i =1; i<vectorPt.size(); i++)
113 {
114 if(vectorPt.at(i)[0] < ptLower[0])
115 {
116 ptLower[0] = vectorPt.at(i)[0];
117 }
118 if(vectorPt.at(i)[1] < ptLower[1])
119 {
120 ptLower[1] = vectorPt.at(i)[1];
121 }
122 if(vectorPt.at(i)[2] < ptLower[2])
123 {
124 ptLower[2] =vectorPt.at(i)[2];
125 }
126 if(vectorPt.at(i)[0] < ptLower[0])
127 {
128 ptLower[0] = vectorPt.at(i)[0];
129 }
130 if(vectorPt.at(i)[1] < ptLower[1])
131 {
132 ptLower[1] = vectorPt.at(i)[1];
133 }
134 if(vectorPt.at(i)[2] < ptLower[2])
135 {
136 ptLower[2] =vectorPt.at(i)[2];
137 }
138 }
139}
140
141
142int main( int argc, char** argv )
143{
144 typedef PointVector<4, double> Point4D;
145 typedef PointVector<1, int> Point1D;
146
147 // parse command line using CLI ----------------------------------------------
148 CLI::App app;
149 std::string inputFileName;
150 unsigned int labelIndex;
151 std::vector<unsigned int> vectSDPindex {0, 1, 2};
152
153 app.description("Display surfel data from SDP file with color attributes given as scalar interpreted as color. \n Example of use: \n First you have to generate a file containing a set of surfels with, for instance, their associated curvature values: \n 3dCurvatureViewer -i $DGtal/examples/samples/cat10.vol -r 3 --exportOnly -d curvatureCat10R3.dat \n Then, we can use this tool to display the set of surfel with their associated values: 3dDisplaySurfelData -i curvatureCat10R3.dat");
154 app.add_option("-i,--input,1", inputFileName, "input file: sdp (sequence of discrete points with attribute)" )
155 ->required()
156 ->check(CLI::ExistingFile);
157 app.add_option("--labelIndex", labelIndex , "set the index of the label.");
158 app.add_option("--SDPindex", vectSDPindex, "specify the sdp index.");
159
160 app.get_formatter()->column_width(40);
161 CLI11_PARSE(app, argc, argv);
162 // END parse command line using CLI ----------------------------------------------
163
164 std::vector<Point4D> surfelAndScalarInput;
165 Z3i::KSpace K;
166
167 surfelAndScalarInput = PointListReader<Point4D>::getPointsFromFile(inputFileName, vectSDPindex);
168
169 Point4D ptLower = surfelAndScalarInput.at(0);
170 Point4D ptUpper = surfelAndScalarInput.at(0);
171 getBoundingUpperAndLowerPoint(surfelAndScalarInput, ptLower, ptUpper);
172
173 K.init(Z3i::Point(2*ptLower[0]+1, 2*ptLower[1]+1, 2*ptLower[2]+1),
174 Z3i::Point(2*ptUpper[0]+1, 2*ptUpper[1]+1, 2*ptUpper[2]+1), true);
175
176 std::vector<Cell> vectSurfelsInput;
177
178 // Construction of the set of surfels
179 for(unsigned int i =0; i<surfelAndScalarInput.size(); i++){
180 Point4D pt4d = surfelAndScalarInput.at(i);
181 Cell c = K.uCell(Z3i::Point(pt4d[0], pt4d[1], pt4d[2]));
182 vectSurfelsInput.push_back(c);
183 }
184
185 CanonicCellEmbedder<KSpace> embeder(K);
186 std::vector<unsigned int> vectIndexMinToReference;
187
188 //-------------------------
189 // Displaying input with color given from scalar values
190
191 typedef PolyscopeViewer<> Viewer;
192
193 Viewer viewer(K);
194
195 for(unsigned int i=0; i <surfelAndScalarInput.size(); i++)
196 {
197 double valInput = surfelAndScalarInput.at(i)[3];
198 viewer << WithQuantity(vectSurfelsInput.at(i), "value", valInput);
199 }
200
201 viewer.show();
202 return 0;
203}
Definition ATu0v1.h:57