}
double BLSURFPlugin_Attractor::GetSize(double u, double v){
+
+// // calcul des coins du carre
+// int i_sup = floor ( (u - _u1) * _mapGrid / (_u2 - _u1) + 1. );
+// int j_sup = floor ( (v - _v1) * _mapGrid / (_v2 - _v1) + 1. );
+//
+// int i_inf = floor ( (u - _u1) * _mapGrid / (_u2 - _u1) );
+// int j_inf = floor ( (v - _v1) * _mapGrid / (_v2 - _v1) );
+//
+// double u_sup = _vectU[i_sup];
+// double v_sup = _vectV[j_sup];
+//
+// double u_inf = _vectU[i_inf];
+// double v_inf = _vectV[j_inf];
+//
+// double d1 = _DMap[i_sup][j_sup];
+// double d2 = _DMap[i_sup][j_inf];
+// double d3 = _DMap[i_inf][j_sup];
+// double d4 = _DMap[i_inf][j_inf];
+//
+// double P_inf = d4 * ( 1 + (u - u_inf) / (u_inf - u_sup) + (v - v_inf) / (v_inf - v_sup) )
+// + d3 * ( (v - v_inf) / (v_sup - v_inf) )
+// + d2 * ( (u - u_inf) / (u_sup - u_inf) ) ;
+//
+// double P_sup = d1 * ( 1 + (u - u_sup) / (u_sup - u_inf) + (v - v_sup) / (v_sup - v_inf) )
+// + d3 * ( (u - u_sup) / (u_inf - u_sup) )
+// + d2 * ( (v - v_sup) / (v_inf - v_sup) ) ;
+//
+// // calcul de la distance (interpolation lineaire)
+// bool P_switch = (u+v > u_sup+v_sup);
+// double d;
+// if (P_switch){
+// d = P_inf;
+// }
+// else {
+// d = P_sup;
+// }
+
int i = floor ( (u - _u1) * _mapGrid / (_u2 - _u1) + 0.5 );
int j = floor ( (v - _v1) * _mapGrid / (_v2 - _v1) + 0.5 );
- return 0.1 * ( 1. + ( 0.5 * (_DMap[i][j] - 20. + abs(_DMap[i][j] - 20.)) ) ); // more generally: function of _DMap
+
+ double d = _DMap[i][j];
+
+ return 1 + ( 0.5 * (d - 20. + abs(d - 20.)) ) ; // more generally: function of _DMap
}
int i0, j0;
gp_Pnt P;
gp_Vec D1U,D1V;
- double Guu, Gvv; //Diagonal components of the local metric tensor
+ double Guu, Gvv, Guv; // Components of the local metric tensor
double du, dv;
double D_Ref = 0.;
double Dist = 0.;
j++;
if (j<0){
MESSAGE("j = "<<j);
- break;
+ //break;
}
}
}
- //jp = (j + _mapGrid + 1) % (_mapGrid+1);
- jp=j;
+ jp = (j + _mapGrid + 1) % (_mapGrid+1);
+ //jp=j;
Current_Pnt[0] = ip; // Define the neighbour as current point
Current_Pnt[1] = jp;
//MESSAGE("i = "<<i<<" ; j = "<<j);
if (_known.find( Current_Pnt ) == _known.end()){ // If the distance is not known
//MESSAGE("Le voisin "<<ip<<","<<jp<<" de min(_trial) n'est pas dans _known");
aSurf->D1(_vectU[ip],_vectV[jp],P,D1U,D1V); // Calculate the metric at (i,j)
- Guu = D1U.X()*D1U.X() + D1U.Y()*D1U.Y() + D1U.Z()*D1U.Z(); // Guu = ||dS/du||**2 G(i,j)= | ||dS/du||**2 0 | assuming that the isolines are orthogonal in 3D space
- Gvv = D1V.X()*D1V.X() + D1V.Y()*D1V.Y() + D1V.Z()*D1V.Z(); // Gvv = ||dS/dv||**2 | 0 ||dS/dv||**2 |
+ Guu = D1U.X()*D1U.X() + D1U.Y()*D1U.Y() + D1U.Z()*D1U.Z(); // Guu = ||dS/du||**2 G(i,j)= | ||dS/du||**2 * |
+ Gvv = D1V.X()*D1V.X() + D1V.Y()*D1V.Y() + D1V.Z()*D1V.Z(); // Gvv = ||dS/dv||**2 | <dS/du,dS/dv> ||dS/dv||**2 |
+ Guv = D1U.X()*D1V.X() + D1U.Y()*D1V.Y() + D1U.Z()*D1V.Z(); // Guv = Gvu = < dS/du,dS/dv >
+ //Guv = 0; // test
+ if (Guv > 1e-15){
+ MESSAGE("WARNING : Guv != 0 ; Guv = "<<Guv);
+ }
//MESSAGE("u ("<<ip<<") = "<< _vectU[ip]<<"v ("<<jp<<") = "<< _vectV[jp]);
if (count == 2500) {
MESSAGE("Guu = " << Guu<<" , Gvv = "<<Gvv);
//MESSAGE("La distance du point ( "<<kp<<","<<np<<" ) de min(_trial) est connue");
du = (k-i) * (_u2 - _u1) / _mapGrid;
dv = (n-j) * (_v2 - _v1) / _mapGrid;
- Dist = _DMap[kp][np] + sqrt( Guu * du*du + Gvv * dv*dv ); // ds**2 = du'Gdu + dv'Gdv (we assume Guv=Gvu=0)
+ Dist = _DMap[kp][np] + sqrt( Guu * du*du + Gvv * dv*dv + 2*Guv * du*dv); // ds**2 = du'Gdu + dv'Gdv + 2*du'Gdv (G is symetrical)
//MESSAGE("D_Ref = "<<D_Ref);
//MESSAGE("Dist = "<<Dist);
//bool comp = Dist < D_Ref;
BLSURFPlugin_Attractor ();
// TODO ~BLSURFPlugin_Attractor ();
BLSURFPlugin_Attractor (TopoDS_Face Face, TopoDS_Shape Attractor);
- bool init(); // Calculates the discrete points correponding to attractor, initialises the map and calls _buildMap
+ bool init(); // Calculates the discrete points correponding to attractor, initialises the map and calls _buildMap
double GetSize (double u, double v);
- TopoDS_Face GetFace(){ return _face;}
- TopoDS_Shape GetAttractorShape(){ return _attractorShape;}
- bool SetAttractorShape(TopoDS_Shape Attractor){ _attractorShape = Attractor; }
-
+ TopoDS_Face GetFace(){ return _face; }
+ TopoDS_Shape GetAttractorShape(){ return _attractorShape; }
+// bool SetAttractorShape(TopoDS_Shape Attractor){
+// _attractorShape = Attractor;
+// }
+
typedef std::vector<double> TDiscreteParam;
typedef std::vector< std::vector<double> > TDistMap;
typedef std::set< std::vector<int> > TPointSet;
TDistMap _DMap;
TPointSet _known;
TTrialSet _trial;
- int _mapGrid; // Number of grid points in U and V directions
- double _u1, _u2, _v1, _v2; // Bounds of the parametric space of the face
- int _i0, _j0; // Indices of the starting point
+ int _mapGrid; // Number of grid points in U and V directions
+ double _u1, _u2, _v1, _v2; // Bounds of the parametric space of the face
+ int _i0, _j0; // Indices of the starting point
- bool _buildMap(); // Builds the map of distances between source point and any point (u,v)
+ bool _buildMap(); // Builds the map of distances between source point and any point P(u,v)
};