34#include "DGtal/base/Common.h"
35#include "DGtal/helpers/StdDefs.h"
36#include "DGtal/io/viewers/PolyscopeViewer.h"
37#include "DGtal/io/readers/PointListReader.h"
38#include "DGtal/io/readers/MeshReader.h"
39#include "DGtal/io/colormaps/GradientColorMap.h"
41#include "DGtal/topology/helpers/Surfaces.h"
42#include "DGtal/topology/SurfelAdjacency.h"
43#include "DGtal/topology/CanonicCellEmbedder.h"
44#include "DGtal/math/Statistic.h"
46#include "DGtal/io/Color.h"
47#include "DGtal/io/colormaps/GradientColorMap.h"
48#include "DGtal/io/readers/GenericReader.h"
111template <
typename Po
int>
113getBoundingUpperAndLowerPoint(
const std::vector<Point> &vectorPt, Point &ptLower, Point &ptUpper){
114 for(
unsigned int i =1; i<vectorPt.size(); i++)
116 if(vectorPt.at(i)[0] < ptLower[0])
118 ptLower[0] = vectorPt.at(i)[0];
120 if(vectorPt.at(i)[1] < ptLower[1])
122 ptLower[1] = vectorPt.at(i)[1];
124 if(vectorPt.at(i)[2] < ptLower[2])
126 ptLower[2] =vectorPt.at(i)[2];
128 if(vectorPt.at(i)[0] > ptUpper[0])
130 ptUpper[0] = vectorPt.at(i)[0];
132 if(vectorPt.at(i)[1] > ptUpper[1])
134 ptUpper[1] = vectorPt.at(i)[1];
136 if(vectorPt.at(i)[2] > ptUpper[2])
138 ptUpper[2] =vectorPt.at(i)[2];
144int main(
int argc,
char** argv )
146 typedef PointVector<4, double> Point4D;
147 typedef PointVector<1, int> Point1D;
151 std::string inputFileName;
152 unsigned int labelIndex;
153 std::vector<unsigned int> vectSDPindex {0, 1, 2, 3};
155 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");
156 app.add_option(
"-i,--input,1", inputFileName,
"input file: sdp (sequence of discrete points with attribute)" )
158 ->check(CLI::ExistingFile);
159 app.add_option(
"--labelIndex", labelIndex ,
"set the index of the label.");
160 app.add_option(
"--SDPindex", vectSDPindex,
"specify the sdp index.");
162 app.get_formatter()->column_width(40);
163 CLI11_PARSE(app, argc, argv);
166 std::vector<Point4D> surfelAndScalarInput;
169 surfelAndScalarInput = PointListReader<Point4D>::getPointsFromFile(inputFileName, vectSDPindex);
171 Point4D ptLower = surfelAndScalarInput.at(0);
172 Point4D ptUpper = surfelAndScalarInput.at(0);
173 getBoundingUpperAndLowerPoint(surfelAndScalarInput, ptLower, ptUpper);
175 K.init(Z3i::Point(2*ptLower[0]+1, 2*ptLower[1]+1, 2*ptLower[2]+1),
176 Z3i::Point(2*ptUpper[0]+1, 2*ptUpper[1]+1, 2*ptUpper[2]+1),
true);
178 std::vector<Cell> vectSurfelsInput;
181 for(
unsigned int i =0; i<surfelAndScalarInput.size(); i++){
182 Point4D pt4d = surfelAndScalarInput.at(i);
183 Cell c = K.uCell(Z3i::Point(pt4d[0], pt4d[1], pt4d[2]));
184 vectSurfelsInput.push_back(c);
187 CanonicCellEmbedder<KSpace> embeder(K);
188 std::vector<unsigned int> vectIndexMinToReference;
194 s <<
"3dDisplaySurfelData - DGtalTools";
196 polyscope::options::programName = s.str();
197 polyscope::view::setNavigateStyle(polyscope::NavigateStyle::Free);
199 typedef PolyscopeViewer<> Viewer;
203 for(
unsigned int i=0; i <surfelAndScalarInput.size(); i++)
205 double valInput = surfelAndScalarInput.at(i)[3];
206 viewer << WithQuantity(vectSurfelsInput.at(i),
"value", valInput);