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"
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"
45#include "DGtal/io/Color.h"
46#include "DGtal/io/colormaps/GradientColorMap.h"
47#include "DGtal/io/readers/GenericReader.h"
109template <
typename Po
int>
111getBoundingUpperAndLowerPoint(
const std::vector<Point> &vectorPt, Point &ptLower, Point &ptUpper){
112 for(
unsigned int i =1; i<vectorPt.size(); i++)
114 if(vectorPt.at(i)[0] < ptLower[0])
116 ptLower[0] = vectorPt.at(i)[0];
118 if(vectorPt.at(i)[1] < ptLower[1])
120 ptLower[1] = vectorPt.at(i)[1];
122 if(vectorPt.at(i)[2] < ptLower[2])
124 ptLower[2] =vectorPt.at(i)[2];
126 if(vectorPt.at(i)[0] < ptLower[0])
128 ptLower[0] = vectorPt.at(i)[0];
130 if(vectorPt.at(i)[1] < ptLower[1])
132 ptLower[1] = vectorPt.at(i)[1];
134 if(vectorPt.at(i)[2] < ptLower[2])
136 ptLower[2] =vectorPt.at(i)[2];
142int main(
int argc,
char** argv )
144 typedef PointVector<4, double> Point4D;
145 typedef PointVector<1, int> Point1D;
149 std::string inputFileName;
150 unsigned int labelIndex;
151 std::vector<unsigned int> vectSDPindex {0, 1, 2};
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)" )
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.");
160 app.get_formatter()->column_width(40);
161 CLI11_PARSE(app, argc, argv);
164 std::vector<Point4D> surfelAndScalarInput;
167 surfelAndScalarInput = PointListReader<Point4D>::getPointsFromFile(inputFileName, vectSDPindex);
169 Point4D ptLower = surfelAndScalarInput.at(0);
170 Point4D ptUpper = surfelAndScalarInput.at(0);
171 getBoundingUpperAndLowerPoint(surfelAndScalarInput, ptLower, ptUpper);
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);
176 std::vector<Cell> vectSurfelsInput;
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);
185 CanonicCellEmbedder<KSpace> embeder(K);
186 std::vector<unsigned int> vectIndexMinToReference;
191 typedef PolyscopeViewer<> Viewer;
195 for(
unsigned int i=0; i <surfelAndScalarInput.size(); i++)
197 double valInput = surfelAndScalarInput.at(i)[3];
198 viewer << WithQuantity(vectSurfelsInput.at(i),
"value", valInput);