Skip to content

Commit 306babd

Browse files
authored
Merge pull request #325 from VibekeSkytt/feature3D
Feature3 d
2 parents 06a2304 + 9bd0ef8 commit 306babd

File tree

7 files changed

+842
-7
lines changed

7 files changed

+842
-7
lines changed

lrsplines3D/app/PointCloud2LRVol.C

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "GoTools/lrsplines3D/LRVolApprox.h"
55
#include "GoTools/geometry/ObjectHeader.h"
66
#include "GoTools/lrsplines3D/LRSpline3DBezierCoefs.h"
7+
#include <boost/timer.hpp>
8+
#include <time.h>
79

810
using namespace std;
911
using namespace Go;
@@ -33,6 +35,9 @@ void print_help_text()
3335
std::cout << "-tolfile: File specifying domains with specific tolerances, global tolerance apply outside domains. PointCloud2LR -tolfile for file format \n";
3436
std::cout << "-toldoc: Documentation on file format for tolerance domains. \n";
3537
std::cout << "-outfrac <percentage>: Local measure for when the fraction of points outside the tolerance should lead to volume splitting \n";
38+
std::cout << "-feature <ncell1> <ncell2> <ncell3>: Specify 3D grid for feature output \n";
39+
std::cout << "-featurelevels <number of levels> <level 1> ... <level n> \n";
40+
std::cout << "-featuredoc: Show feature documentation \n";
3641
std::cout << "-h or --help : Write this text\n";
3742
}
3843

@@ -50,6 +55,38 @@ void print_tol_file_format()
5055
std::cout << "Ensure non-overlapping boxes. No test applied. \n";
5156
}
5257

58+
void print_feature_info()
59+
{
60+
std::cout << "-feature: <ncell1> <ncell2> <ncell3> : Command line parameter to write feature information to file according to given grid resolution \n \n";
61+
std::cout << "Compute grid based feature information for the specified iteration level. \n";
62+
std::cout << "As the computation can be time consuming (depending on the grid size), select the iteration levels carefully. \n";
63+
std::cout << "The information is stored in files called cellinfox where the number x represent the iteration level." << std::endl;
64+
std::cout << "The volume is parameterized on x, y and z and the volume value represents intensity/height" << std::endl;
65+
std::cout << "If rgb is given the values will be scaled in the range [0,255] and stored as unsigned int, \n";
66+
std::cout << "otherwise the values are represented as float in the range [0.0,10.0]" << std::endl;
67+
std::cout << "The indicies represents the following information" << std::endl;
68+
std::cout << "0: Average slope in cell (8 samples) \n";
69+
std::cout << "1: Average value of surface in cell (8 samples) \n";
70+
std::cout << "2: Maximum difference of surface values in cell (8 samples) \n";
71+
std::cout << "3: Average distance between surface and points for each cell \n";
72+
std::cout << "4: Maximum distance between surface and points in cell \n";
73+
std::cout << "5: Average intensity/height value of points in cell \n";
74+
std::cout << "6: Maximum difference of intensity values in cell \n";
75+
std::cout << "7: Standard deviation of distances between point cloud and surface in cell \n";
76+
std::cout << "8: Standard deviation of intensity values in cell \n";
77+
std::cout << "9: Average distance between surface and points in cell divided by maximum distance \n";
78+
std::cout << "10: Maximum difference between signed distances between points and surface in cell \n";
79+
std::cout << "11: Average distance between points with higher intensity than the surface and surface in cell \n";
80+
std::cout << "12: Average distance between points with lower intensity than the surface and surface in cell \n";
81+
std::cout << "13: Number of point with lower intensity than the surface where the intensity difference is larger than threshold divided by the number of points in the cell \n";
82+
std::cout << "14: Number of point with higher intensity than the surface where the intensity difference is larger than threshold divided by the number of points in the cell \n";
83+
std::cout << "15: Number of surface elements in cell \n";
84+
std::cout << "16: Average Lagrangian in cell (8 samples) " << std::endl;
85+
std::cout << "17: Average absolute value of z-derivative in cell (8 samples) \n";
86+
std::cout << "18: Maximum absolute value of z-derivative cell (8 samples) " << std::endl;
87+
}
88+
89+
5390
int fetchIntParameter(int argc, char *argv[], int ki, int& parameter,
5491
int& nmb_par, vector<bool>& par_read)
5592
{
@@ -112,6 +149,8 @@ int main (int argc, char *argv[]) {
112149
double minsize = -1.0;
113150
double outfrac = 0.0;
114151
int ncell1=0, ncell2=0, ncell3=0;
152+
bool features = false;
153+
vector<int> feature_levels;
115154

116155
int ki, kj;
117156
vector<bool> par_read(argc-1, false);
@@ -189,6 +228,44 @@ int main (int argc, char *argv[]) {
189228
outfrac = std::max(0.0, outfrac);
190229
outfrac /= 100.0;
191230
}
231+
else if (arg == "-feature")
232+
{
233+
if (ki == argc-1)
234+
{
235+
std::cout << "ERROR: Missing input" << std::endl;
236+
print_help_text();
237+
return 1;
238+
}
239+
features = true;
240+
ncell1 = atoi(argv[ki+1]);
241+
ncell2 = atoi(argv[ki+2]);
242+
ncell3 = atoi(argv[ki+3]);
243+
par_read[ki-1] = par_read[ki] = par_read[ki+1] = par_read[ki+2] = true;
244+
nmb_par -= 4;
245+
}
246+
else if (arg == "-featurelevels")
247+
{
248+
if (ki == argc-1)
249+
{
250+
std::cout << "ERROR: Missing input" << std::endl;
251+
print_help_text();
252+
return 1;
253+
}
254+
int fsize = atoi(argv[ki+1]);
255+
par_read[ki-1] = par_read[ki] = true;
256+
feature_levels.resize(fsize);
257+
for (int ka=0; ka<fsize; ++ka)
258+
{
259+
feature_levels[ka] = atoi(argv[ki+ka+2]);
260+
par_read[ki+ka+1] = true;
261+
}
262+
nmb_par -= (fsize+2);
263+
}
264+
else if (arg == "-featuredoc")
265+
{
266+
print_feature_info();
267+
exit(0);
268+
}
192269
}
193270

194271
// Read remaining parameters
@@ -312,6 +389,15 @@ int main (int argc, char *argv[]) {
312389
std::cout << "Standard deviation: " << stdd << std::endl;
313390
}
314391

392+
time_t start = time(NULL);
393+
394+
395+
396+
boost::timer t;
397+
double duration;
398+
399+
t.restart();
400+
315401
std::cout << "Domain: [" << domain[0] << "," << domain[1] << "]x[" << domain[2];
316402
std::cout << "," << domain[3] << "]x[" << domain[4] << "," << domain[5] << "]" << std::endl;
317403
std::cout << "Range: [" << minval << "," << maxval << "]" << std::endl;
@@ -348,6 +434,13 @@ int main (int argc, char *argv[]) {
348434
else
349435
vol_approx.setVerbose(false);
350436

437+
// Feature output
438+
if (features)
439+
{
440+
vol_approx.setFeatureOut(ncell1, ncell2, ncell3);
441+
vol_approx.setFeatureLevel(feature_levels);
442+
}
443+
351444
double max, average, av_all;
352445
double maxout, avout;
353446
int num_out;
@@ -357,6 +450,14 @@ int main (int argc, char *argv[]) {
357450

358451
vol_approx.fetchOutsideTolInfo(maxout, avout);
359452

453+
duration = t.elapsed();
454+
std::cout << "Duration: " << duration << std::endl;
455+
double min = floor(duration/60);
456+
double sec = duration - 60*min;
457+
std::cout << min << "m" << sec << "s" << std::endl;
458+
time_t end = time(NULL);
459+
std::cout<<"Execution Time: "<< (double)(end-start)<<" Seconds"<<std::endl;
460+
360461
if (infofile)
361462
{
362463
std::ofstream infoout(infofile); // Accuracy information output stream
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF ICT,
3+
* Applied Mathematics, Norway.
4+
*
5+
* Contact information: E-mail: [email protected]
6+
* SINTEF ICT, Department of Applied Mathematics,
7+
* P.O. Box 124 Blindern,
8+
* 0314 Oslo, Norway.
9+
*
10+
* This file is part of GoTools.
11+
*
12+
* GoTools is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Affero General Public License as
14+
* published by the Free Software Foundation, either version 3 of the
15+
* License, or (at your option) any later version.
16+
*
17+
* GoTools is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU Affero General Public
23+
* License along with GoTools. If not, see
24+
* <http://www.gnu.org/licenses/>.
25+
*
26+
* In accordance with Section 7(b) of the GNU Affero General Public
27+
* License, a covered work must retain the producer line in every data
28+
* file that is created or manipulated using GoTools.
29+
*
30+
* Other Usage
31+
* You can be released from the requirements of the license by purchasing
32+
* a commercial license. Buying such a license is mandatory as soon as you
33+
* develop commercial activities involving the GoTools library without
34+
* disclosing the source code of your own applications.
35+
*
36+
* This file may be used in accordance with the terms contained in a
37+
* written agreement between you and SINTEF ICT.
38+
*/
39+
40+
41+
#ifndef _LFEATURE3DUTILS_H
42+
#define _LRFEATUR3DEUTILS_H
43+
44+
45+
#include "GoTools/lrsplines3D/LRSplineVolume.h"
46+
#include <iostream>
47+
48+
49+
namespace Go
50+
{
51+
namespace LRFeature3DUtils
52+
{
53+
// Write accuracy features to file
54+
void writeCellInfo(const LRSplineVolume& vol,
55+
double tol, int ncell1, int ncell2, int ncell3,
56+
std::ostream &out);
57+
58+
};
59+
60+
}; // End namespace Go
61+
62+
63+
#endif // _LRFEATURE3DUTILS_H

lrsplines3D/include/GoTools/lrsplines3D/LRSpline3DEvalGrid.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ class LRSpline3DEvalGrid
130130
double par = ll_x;
131131
for (int ka=0; ka<order_U; ++ka, par+=du)
132132
{
133-
const bool on_end = (par == bfunctions[ki]->umax());
133+
if (ka == order_U-1)
134+
par = ur_x;
135+
const bool on_end = (par == orig_dom_[1]); //bfunctions[ki]->umax());
134136
val1[ki*order_U+ka] = uni1->evalBasisFunction(par, 0, on_end);
135137
}
136138
}
@@ -146,7 +148,9 @@ class LRSpline3DEvalGrid
146148
double par = ll_y;
147149
for (int ka=0; ka<order_V; ++ka, par+=dv)
148150
{
149-
const bool on_end = (par == bfunctions[ki]->vmax());
151+
if (ka == order_V-1)
152+
par = ur_y;
153+
const bool on_end = (par == orig_dom_[3]); //bfunctions[ki]->vmax());
150154
val2[ki*order_V+ka] = uni2->evalBasisFunction(par, 0, on_end);
151155
}
152156
}
@@ -162,7 +166,9 @@ class LRSpline3DEvalGrid
162166
double par = ll_z;
163167
for (int ka=0; ka<order_W; ++ka, par+=dw)
164168
{
165-
const bool on_end = (par == bfunctions[ki]->wmax());
169+
if (ka == order_W-1)
170+
par = ur_z;
171+
const bool on_end = (par == orig_dom_[5]); //bfunctions[ki]->wmax());
166172
val3[ki*order_W+ka] = uni3->evalBasisFunction(par, 0, on_end);
167173
}
168174
}

lrsplines3D/include/GoTools/lrsplines3D/LRVolApprox.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,25 @@ class LRVolApprox
373373
}
374374

375375

376+
/// Feature output
377+
void setFeatureOut(int ncell1, int ncell2, int ncell3)
378+
{
379+
write_feature_ = true;
380+
ncell1_ = ncell1;
381+
ncell2_ = ncell2;
382+
ncell3_ = ncell3;
383+
}
384+
385+
void unsetFeatureOut()
386+
{
387+
write_feature_ = false;
388+
}
389+
390+
void setFeatureLevel(std::vector<int>& levels)
391+
{
392+
feature_levels_ = levels;
393+
}
394+
376395
private:
377396
shared_ptr<LRSplineVolume> vol_;
378397
int nmb_pts_;
@@ -430,6 +449,11 @@ class LRVolApprox
430449
// Variable tolerance
431450
std::vector<TolBox> tolerances_;
432451

452+
// Features output
453+
bool write_feature_;
454+
int ncell1_, ncell2_, ncell3_;
455+
std::vector<int> feature_levels_;
456+
433457
// DEBUG
434458
int ref_x_, ref_y_, ref_z_;
435459
int nmb1_, nmb2_, nmb3_;

0 commit comments

Comments
 (0)