| 1 | #include <stdio.h>
|
|---|
| 2 | #include "../../shared/shared.h"
|
|---|
| 3 | #include "../../include/include.h"
|
|---|
| 4 | #include "../objects.h"
|
|---|
| 5 | #include "../../io/io.h"
|
|---|
| 6 |
|
|---|
| 7 | /*Constructors/Destructors*/
|
|---|
| 8 | /*FUNCTION BamgOpts::BamgOpts() {{{1*/
|
|---|
| 9 | BamgOpts::BamgOpts(){
|
|---|
| 10 |
|
|---|
| 11 | this->anisomax=0;
|
|---|
| 12 | this->cutoff=0;
|
|---|
| 13 | this->coeff=0;
|
|---|
| 14 | this->errg=0;
|
|---|
| 15 | this->gradation=0;
|
|---|
| 16 | this->Hessiantype=0;
|
|---|
| 17 | this->MaxCornerAngle=0;
|
|---|
| 18 | this->maxnbv=0;
|
|---|
| 19 | this->maxsubdiv=0;
|
|---|
| 20 | this->Metrictype=0;
|
|---|
| 21 | this->nbjacobi=0;
|
|---|
| 22 | this->nbsmooth=0;
|
|---|
| 23 | this->omega=0;
|
|---|
| 24 | this->power=0;
|
|---|
| 25 | this->verbose=0;
|
|---|
| 26 |
|
|---|
| 27 | this->Crack=0;
|
|---|
| 28 | this->geometricalmetric=0;
|
|---|
| 29 | this->KeepVertices=0;
|
|---|
| 30 | this->splitcorners=0;
|
|---|
| 31 |
|
|---|
| 32 | this->hmin=0;
|
|---|
| 33 | this->hmax=0;
|
|---|
| 34 | this->hminVertices=NULL; this->hminVerticesSize[0]=this->hminVerticesSize[1]=0;
|
|---|
| 35 | this->hmaxVertices=NULL; this->hmaxVerticesSize[0]=this->hmaxVerticesSize[1]=0;
|
|---|
| 36 | this->hVertices=NULL; this->hVerticesSize[0]=this->hVerticesSize[1]=0;
|
|---|
| 37 | this->metric=NULL; this->metricSize[0]=this->metricSize[1]=0;
|
|---|
| 38 | this->field=NULL; this->fieldSize[0]=this->fieldSize[1]=0;
|
|---|
| 39 | this->err=NULL; this->errSize[0]=this->errSize[1]=0;
|
|---|
| 40 |
|
|---|
| 41 | }
|
|---|
| 42 | /*}}}*/
|
|---|
| 43 | /*FUNCTION BamgOpts::BamgOpts(mxArray* matlab_struct){{{1*/
|
|---|
| 44 | #ifdef _SERIAL_
|
|---|
| 45 | BamgOpts::BamgOpts(mxArray* matlab_struct){
|
|---|
| 46 |
|
|---|
| 47 | FetchMatlabData(&this->anisomax,mxGetField(matlab_struct,0,"anisomax"));
|
|---|
| 48 | FetchMatlabData(&this->cutoff,mxGetField(matlab_struct,0,"cutoff"));
|
|---|
| 49 | FetchMatlabData(&this->coeff,mxGetField(matlab_struct,0,"coeff"));
|
|---|
| 50 | FetchMatlabData(&this->errg,mxGetField(matlab_struct,0,"errg"));
|
|---|
| 51 | FetchMatlabData(&this->gradation,mxGetField(matlab_struct,0,"gradation"));
|
|---|
| 52 | FetchMatlabData(&this->Hessiantype,mxGetField(matlab_struct,0,"Hessiantype"));
|
|---|
| 53 | FetchMatlabData(&this->MaxCornerAngle,mxGetField(matlab_struct,0,"MaxCornerAngle"));
|
|---|
| 54 | FetchMatlabData(&this->maxnbv,mxGetField(matlab_struct,0,"maxnbv"));
|
|---|
| 55 | FetchMatlabData(&this->maxsubdiv,mxGetField(matlab_struct,0,"maxsubdiv"));
|
|---|
| 56 | FetchMatlabData(&this->Metrictype,mxGetField(matlab_struct,0,"Metrictype"));
|
|---|
| 57 | FetchMatlabData(&this->nbjacobi,mxGetField(matlab_struct,0,"nbjacobi"));
|
|---|
| 58 | FetchMatlabData(&this->nbsmooth,mxGetField(matlab_struct,0,"nbsmooth"));
|
|---|
| 59 | FetchMatlabData(&this->omega,mxGetField(matlab_struct,0,"omega"));
|
|---|
| 60 | FetchMatlabData(&this->power,mxGetField(matlab_struct,0,"power"));
|
|---|
| 61 | FetchMatlabData(&this->verbose,mxGetField(matlab_struct,0,"verbose"));
|
|---|
| 62 |
|
|---|
| 63 | FetchMatlabData(&this->Crack,mxGetField(matlab_struct,0,"Crack"));
|
|---|
| 64 | FetchMatlabData(&this->geometricalmetric,mxGetField(matlab_struct,0,"geometricalmetric"));
|
|---|
| 65 | FetchMatlabData(&this->KeepVertices,mxGetField(matlab_struct,0,"KeepVertices"));
|
|---|
| 66 | FetchMatlabData(&this->splitcorners,mxGetField(matlab_struct,0,"splitcorners"));
|
|---|
| 67 |
|
|---|
| 68 | FetchMatlabData(&this->hmin,mxGetField(matlab_struct,0,"hmin"));
|
|---|
| 69 | FetchMatlabData(&this->hmax,mxGetField(matlab_struct,0,"hmax"));
|
|---|
| 70 | FetchMatlabData(&this->hminVertices,&this->hminVerticesSize[0],&this->hminVerticesSize[1],mxGetField(matlab_struct,0,"hminVertices"));
|
|---|
| 71 | FetchMatlabData(&this->hmaxVertices,&this->hmaxVerticesSize[0],&this->hmaxVerticesSize[1],mxGetField(matlab_struct,0,"hmaxVertices"));
|
|---|
| 72 | FetchMatlabData(&this->hVertices,&this->hVerticesSize[0],&this->hVerticesSize[1],mxGetField(matlab_struct,0,"hVertices"));
|
|---|
| 73 | FetchMatlabData(&this->metric,&this->metricSize[0],&this->metricSize[1],mxGetField(matlab_struct,0,"metric"));
|
|---|
| 74 | FetchMatlabData(&this->field,&this->fieldSize[0],&this->fieldSize[1],mxGetField(matlab_struct,0,"field"));
|
|---|
| 75 | FetchMatlabData(&this->err,&this->errSize[0],&this->errSize[1],mxGetField(matlab_struct,0,"err"));
|
|---|
| 76 |
|
|---|
| 77 | /*Additional checks*/
|
|---|
| 78 | this->Check();
|
|---|
| 79 |
|
|---|
| 80 | }
|
|---|
| 81 | #endif
|
|---|
| 82 | /*}}}*/
|
|---|
| 83 | /*FUNCTION BamgOpts::~BamgOpts() {{{1*/
|
|---|
| 84 | BamgOpts::~BamgOpts(){
|
|---|
| 85 |
|
|---|
| 86 | xfree((void**)&this->hminVertices);
|
|---|
| 87 | xfree((void**)&this->hmaxVertices);
|
|---|
| 88 | xfree((void**)&this->hVertices);
|
|---|
| 89 | xfree((void**)&this->metric);
|
|---|
| 90 | xfree((void**)&this->field);
|
|---|
| 91 | xfree((void**)&this->err);
|
|---|
| 92 |
|
|---|
| 93 | }
|
|---|
| 94 | /*}}}*/
|
|---|
| 95 |
|
|---|
| 96 | /*Methods*/
|
|---|
| 97 | /*FUNCTION BamgOpts::Check{{{1*/
|
|---|
| 98 | void BamgOpts::Check(void){
|
|---|
| 99 |
|
|---|
| 100 | int i;
|
|---|
| 101 |
|
|---|
| 102 | if (this->anisomax<1) _error_("'anisomax' option should be >=1");
|
|---|
| 103 | if (this->coeff==0) _error_("'coeff' should be positive");
|
|---|
| 104 | if (this->errg<0) _error_("'errg' option should be >0");
|
|---|
| 105 | if (this->gradation<1) _error_("'gradation' option should be >=1");
|
|---|
| 106 | if (this->Hessiantype!=0 && this->Hessiantype!=1) _error_("'Hessiantype' supported options are 0 and 1");
|
|---|
| 107 | if (this->maxnbv<3) _error_("'maxnbv' option should be >3");
|
|---|
| 108 | if (this->maxsubdiv<=1) _error_("'maxsubdiv' should be >1");
|
|---|
| 109 | if (this->Metrictype!=0 && this->Metrictype!=1 && this->Metrictype!=2) _error_("'Metrictype' supported options are 0, 1 and 2");
|
|---|
| 110 | if (this->nbjacobi<=0) _error_("'nbjacobi' option should be >0");
|
|---|
| 111 | if (this->nbsmooth<=0) _error_("'nbsmooth' option should be >0");
|
|---|
| 112 |
|
|---|
| 113 | if (this->Crack!=0 && this->Crack!=1) _error_("'Crack' supported options are 0 and 1");
|
|---|
| 114 | if (this->KeepVertices!=0 && this->KeepVertices!=1) _error_("'KeepVertices' supported options are 0 and 1");
|
|---|
| 115 | if (this->geometricalmetric!=0 && this->geometricalmetric!=1) _error_("'geometricalmetric' supported options are 0 and 1");
|
|---|
| 116 |
|
|---|
| 117 | if (this->hmin<=0) _error_("'hmin' option should be >0");
|
|---|
| 118 | if (this->hmax<=0 || this->hmax<this->hmin) _error_("'hmax' option should be between 0 and hmin=%g",this->hmin);
|
|---|
| 119 | if (this->hminVertices && this->hminVerticesSize[1]!=1) _error_("'hminVertices' should be a column");
|
|---|
| 120 | if (this->hmaxVertices && this->hmaxVerticesSize[1]!=1) _error_("'hmaxVertices' should be a column");
|
|---|
| 121 | if (this->hVertices && this->hVerticesSize[1]!=1) _error_("'hVertices' should be a column");
|
|---|
| 122 | if (this->metric && (this->metricSize[1]!=1 && this->metricSize[1]!=3)) _error_("'metric' should have either 1 (iso) or 3 (aniso) columns.");
|
|---|
| 123 | if (this->field){
|
|---|
| 124 | if (this->errSize[0]!=1 || this->errSize[1]!=this->fieldSize[1]) _error_("'err' should be of size %i x %i",1,this->fieldSize[1]);
|
|---|
| 125 | for (i=0;i<this->fieldSize[1];i++) {if (this->err[i]<=0) _error_("'err' option should be >0");};
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | }
|
|---|
| 129 | /*}}}*/
|
|---|