Skip to content

Commit 9cb2c26

Browse files
committed
Merge remote-tracking branch 'origin2/master' into documentation
2 parents ea0e4d8 + 0706e62 commit 9cb2c26

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3958
-1182
lines changed

compositemodel/src/SurfaceModelUtils.C

+6-1
Original file line numberDiff line numberDiff line change
@@ -2390,7 +2390,12 @@ void SurfaceModelUtils::tesselateOneSrf(shared_ptr<ParamSurface> surf,
23902390
else
23912391
{
23922392
ParametricSurfaceTesselator tesselator(*surf.get());
2393-
tesselator.changeRes(n, m);
2393+
int n2, m2;
2394+
tesselator.getRes(n2, m2);
2395+
if (n == n2 && m == m2)
2396+
tesselator.tesselate();
2397+
else
2398+
tesselator.changeRes(n, m);
23942399
mesh = tesselator.getMesh();
23952400
}
23962401
}

gotools-core/src/geometry/BoundedSurface.C

+4-3
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ BoundedSurface(shared_ptr<ParamSurface> surf,
331331
loop_fixed_ = bd_sf->loop_fixed_;
332332
iso_trim_= bd_sf->iso_trim_;
333333
iso_trim_tol_ = bd_sf->iso_trim_tol_;
334+
valid_state_ = bd_sf->valid_state_;
334335
}
335336
else
336337
{
@@ -346,10 +347,10 @@ BoundedSurface(shared_ptr<ParamSurface> surf,
346347
}
347348
iso_trim_ = true;
348349
iso_trim_tol_ = space_epsilon;
350+
351+
// We then analyze the loops and set valid_state_.
352+
analyzeLoops();
349353
}
350-
351-
// We then analyze the loops and set valid_state_.
352-
analyzeLoops();
353354
}
354355

355356
//===========================================================================

gotools-core/src/geometry/SplineUtils.C

+4
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ void SplineUtils::closest_on_rectgrid(const double* pt, const double* array,
220220
clo_v = best_v;
221221
int ii = min(int(floor(clo_u)), u_max - 1);
222222
int jj = min(int(floor(clo_v)), v_max - 1);
223+
if (ii < 0)
224+
ii = floor(0.5*u_max);
225+
if (jj < 0)
226+
jj = floor(0.5*v_max);
223227
p[0].setValue(array + (jj*nmb_coefs_u + ii)*3);
224228
p[1].setValue(array + (jj*nmb_coefs_u + ii+1)*3);
225229
p[2].setValue(array + ((jj+1)*nmb_coefs_u + ii+1)*3);

lrsplines2D/app/PointCloud2LR.C

+34-2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ void print_help_text()
102102
std::cout << "-toldoc: Documentation on file format for tolerance domains. \n";
103103
std::cout << "-featuredoc: Show feature documentation \n";
104104
std::cout << "-refstrat: Print parameter information to define refinement strategy. \n";
105+
std::cout << "-AIC <filename>: Compute AIC at each iteration level and output to the given file. Time consuming. Default: No AIC computations \n";
105106
std::cout << "-h or --help : Write this text\n";
106107
}
107108

@@ -231,6 +232,8 @@ int main(int argc, char *argv[])
231232
double minsize = -1.0;
232233
int feature_out = -1;
233234
int verbose = 0;
235+
int AIC = 0;
236+
char *AIC_file = 0;
234237

235238
int initncoef = 10;
236239
int distribute_ncoef = 0;
@@ -514,7 +517,14 @@ int main(int argc, char *argv[])
514517
if (stat < 0)
515518
return 1;
516519
}
517-
520+
else if (arg == "-AIC")
521+
{
522+
AIC = 1;
523+
int stat = fetchCharParameter(argc, argv, ki, AIC_file,
524+
nmb_par, par_read);
525+
if (stat < 0)
526+
return 1;
527+
}
518528
}
519529

520530
// Read remaining parameters
@@ -848,6 +858,10 @@ int main(int argc, char *argv[])
848858
approx->addUpperConstraint(extent[5] + zfac);
849859
approx->setLocalConstraint(zfac);
850860
}
861+
862+
if (AIC)
863+
approx->setAIC(true);
864+
851865
#ifdef DEBUG
852866
std::cout << "Range: " << extent[1]-extent[0] << ", " << extent[3]-extent[2];
853867
std::cout << ", " << extent[5]-extent[4] << std::endl;
@@ -930,7 +944,25 @@ int main(int argc, char *argv[])
930944
regular_cloud.write(ofr);
931945
}
932946

933-
947+
if (AIC)
948+
{
949+
// Fetch Mahalanobis distance and log likelyhood
950+
vector<double> AICinfo;
951+
vector<int> ncoef;
952+
approx->getAICInfo(AICinfo, ncoef);
953+
std::ofstream ofAIC(AIC_file);
954+
ofAIC.precision(10);
955+
ofAIC << "For each iteration level the following is reported: " << std::endl;
956+
ofAIC << "level, number of coefficients, Mahalanobix distance with students t-distribution, \n";
957+
ofAIC << "AIC student t-distribution, Mahalanobix distance normal distribution, AIC normal distribution" << std::endl;
958+
for (size_t ki=0; ki<ncoef.size(); ++ki)
959+
{
960+
ofAIC << ki << "\t" << ncoef[ki];
961+
for (size_t kj=0; kj<4; ++kj)
962+
ofAIC << "\t" << AICinfo[4*ki+kj];
963+
ofAIC << std::endl;
964+
}
965+
}
934966

935967
std::ofstream sfout(surffile); // Surface output stream
936968

lrsplines2D/app/getLRSfDomain.C

+6
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,15 @@ int main( int argc, char* argv[] )
9494
// Fetch domain
9595
RectDomain domain = sf->containingDomain();
9696

97+
// Fetch box
98+
BoundingBox bb = sf->boundingBox();
99+
100+
97101
// Output
102+
int dim = sf->dimension();
98103
printf("Surface domain: %13.4f %13.4f %13.4f %13.4f \n", domain.umin(),
99104
domain.umax(), domain.vmin(), domain.vmax());
105+
printf("Bound z: %13.7f %13.7f \n", bb.low()[dim-1], bb.high()[dim-1]);
100106

101107
shared_ptr<LRSplineSurface> lrsf =
102108
dynamic_pointer_cast<LRSplineSurface, ParamSurface>(sf);

lrsplines2D/app/isoContours.C

+1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ namespace {
299299

300300
const double minval = bbox.low()[0];
301301
const double maxval = bbox.high()[0];
302+
std::cout << "Minval: " << minval << ", maxval: " << maxval << std::endl;
302303

303304
vector<double> result(num_contours, 0);
304305
for (int i = 0; i != num_contours; ++i)

lrsplines2D/app/liftSurfTo3D.C

+11
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
#include "GoTools/geometry/ObjectHeader.h"
4343
#include "GoTools/geometry/BoundedSurface.h"
44+
#include "GoTools/geometry/SplineSurface.h"
4445
#include "GoTools/lrsplines2D/LRSplineSurface.h"
4546
#include "GoTools/geometry/GoTools.h"
4647
#include "GoTools/geometry/Factory.h"
@@ -105,6 +106,16 @@ int main(int argc, char *argv[])
105106
MESSAGE("Surface type " << header.classType() << " in the underlying surface is not supported.");
106107
}
107108
}
109+
else if (header.classType() == Class_SplineSurface)
110+
{
111+
shared_ptr<SplineSurface> sf(new SplineSurface());
112+
sf->read(filein);
113+
shared_ptr<LRSplineSurface> lr_sf(new LRSplineSurface(sf.get(), 1.0e-8));
114+
lr_sf->to3D();
115+
shared_ptr<SplineSurface> splsf(lr_sf->asSplineSurface());
116+
splsf->writeStandardHeader(fileout);
117+
splsf->write(fileout);
118+
}
108119
else
109120
{
110121
MESSAGE("Surface type " << header.classType() << " is not supported.");

lrsplines2D/app/loglikelyhood.C

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
#include "GoTools/geometry/GoTools.h"
41+
#include "GoTools/geometry/FileUtils.h"
42+
#include "GoTools/lrsplines2D/LogLikelyhood.h"
43+
#include <iostream>
44+
#include <fstream>
45+
46+
using std::vector;
47+
using namespace Go;
48+
49+
int main(int argc, char *argv[])
50+
{
51+
52+
if (argc != 2)
53+
{
54+
std::cout << "Parameters: residuals (x,y,z,r)" << std::endl;
55+
return 1;
56+
}
57+
58+
std::ifstream input(argv[1]);
59+
double Tny = 10.0; // Guess value
60+
61+
// Read point cloud with residuals
62+
vector<double> data;
63+
vector<double> extent(8); // Limits for points in all coordinates
64+
int nmb_pts = 0;
65+
FileUtils::readTxtPointFile(input, 4, data, nmb_pts, extent);
66+
67+
std::cout << "Number of points: " << nmb_pts << std::endl;
68+
// Extract residuals
69+
vector<double> residuals(nmb_pts);
70+
for (size_t ki=0; ki<nmb_pts; ++ki)
71+
residuals[ki] = data[4*ki+3];
72+
std::cout << "Min: " << extent[6] << ", max: " << extent[7] << std::endl;
73+
74+
double loglh2 = 0.0;
75+
double loglh = LogLikelyhood::compute(residuals, Tny, true, loglh2);
76+
printf("Loglikelyhood: %7.13f, %7.13f \n",loglh, loglh2);
77+
}

lrsplines2D/app/loglikelyhoodFixed.C

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
#include "GoTools/geometry/GoTools.h"
41+
#include "GoTools/geometry/FileUtils.h"
42+
#include "GoTools/lrsplines2D/LogLikelyhood.h"
43+
#include <iostream>
44+
#include <fstream>
45+
46+
using std::vector;
47+
using namespace Go;
48+
49+
int main(int argc, char *argv[])
50+
{
51+
52+
if (argc != 3)
53+
{
54+
std::cout << "Parameters: residuals (x,y,z,r), degrees of freedom in T-distribution" << std::endl;
55+
return 1;
56+
}
57+
58+
std::ifstream input(argv[1]);
59+
double Tny = atof(argv[2]);
60+
61+
// Read point cloud with residuals
62+
vector<double> data;
63+
vector<double> extent(8); // Limits for points in all coordinates
64+
int nmb_pts = 0;
65+
FileUtils::readTxtPointFile(input, 4, data, nmb_pts, extent);
66+
67+
std::cout << "Number of points: " << nmb_pts << std::endl;
68+
// Extract residuals
69+
vector<double> residuals(nmb_pts);
70+
for (size_t ki=0; ki<nmb_pts; ++ki)
71+
residuals[ki] = data[4*ki+3];
72+
std::cout << "Min: " << extent[6] << ", max: " << extent[7] << std::endl;
73+
74+
double loglh2 = 0.0;
75+
double loglh = LogLikelyhood::compute(residuals, Tny, false, loglh2);
76+
printf("Loglikelyhood: %7.13f, %7.13f \n",loglh, loglh2);
77+
}

0 commit comments

Comments
 (0)