- // 2 --- load 2d edge points (u,v) with orientation and value on unit square
-
- for (int i=0; i<2; i++)
- {
- quad->uv_edges[i] = LoadEdgePoints(aMesh, F,
- quad->edge[i],
- quad->first[i],
- quad->last[i]);
-
- // quad->isEdgeForward[i]);
- }
- for (int i=2; i<4; i++)
- {
- quad->uv_edges[i] = LoadEdgePoints(aMesh, F,
- quad->edge[i],
- quad->last[i],
- quad->first[i]);
-
- // !quad->isEdgeForward[i]);
- }
-
- // 3 --- 2D normalized values on unit square [0..1][0..1]
-
- int nbdown = quad->nbPts[0];
- int nbright = quad->nbPts[1];
- quad->uv_grid = new UVPtStruct[nbright*nbdown];
-
- UVPtStruct* uv_grid = quad->uv_grid;
- UVPtStruct* uv_e0 = quad->uv_edges[0];
- UVPtStruct* uv_e1 = quad->uv_edges[1];
- UVPtStruct* uv_e2 = quad->uv_edges[2];
- UVPtStruct* uv_e3 = quad->uv_edges[3];
- gp_Pnt2d a0 = pf[0];
- gp_Pnt2d a1 = pf[1];
- gp_Pnt2d a2 = pf[2];
- gp_Pnt2d a3 = pf[3];
-
- // nodes Id on edges
-
- int j = 0;
- for (int i=0; i<nbdown; i++)
- {
- int ij = j*nbdown +i;
- uv_grid[ij].nodeId = uv_e0[i].nodeId;
- }
- i = nbdown-1;
- for (int j=0; j<nbright; j++)
- {
- int ij = j*nbdown +i;
- uv_grid[ij].nodeId = uv_e1[j].nodeId;
- }
- j = nbright -1;
- for (int i=0; i<nbdown; i++)
- {
- int ij = j*nbdown +i;
- uv_grid[ij].nodeId = uv_e2[i].nodeId;
- }
- i = 0;
- for (int j=0; j<nbright; j++)
- {
- int ij = j*nbdown +i;
- uv_grid[ij].nodeId = uv_e3[j].nodeId;
- }
-
- // normalized 2d values on grid
-
- for (int i=0; i<nbdown; i++)
- for (int j=0; j<nbright; j++)
- {
- int ij = j*nbdown +i;
- // --- droite i cste : x = x0 + y(x1-x0)
- double x0 = uv_e0[i].normParam; // bas - sud
- double x1 = uv_e2[i].normParam; // haut - nord
- // --- droite j cste : y = y0 + x(y1-y0)
- double y0 = uv_e3[j].normParam; // gauche-ouest
- double y1 = uv_e1[j].normParam; // droite - est
- // --- intersection : x=x0+(y0+x(y1-y0))(x1-x0)
- double x=(x0+y0*(x1-x0))/(1-(y1-y0)*(x1-x0));
- double y=y0+x*(y1-y0);
- uv_grid[ij].x = x;
- uv_grid[ij].y = y;
- //MESSAGE("-xy-01 "<<x0<<" "<<x1<<" "<<y0<<" "<<y1);
- //MESSAGE("-xy-norm "<<i<<" "<<j<<" "<<x<<" "<<y);
- }
-
- // 4 --- projection on 2d domain (u,v)
-
- for (int i=0; i<nbdown; i++)
- for (int j=0; j<nbright; j++)
- {
- int ij = j*nbdown +i;
- double x = uv_grid[ij].x;
- double y = uv_grid[ij].y;
- double param_0 = uv_e0[0].param
- + x*(uv_e0[nbdown-1].param -uv_e0[0].param); // sud
- double param_2 = uv_e2[0].param
- + x*(uv_e2[nbdown-1].param -uv_e2[0].param); // nord
- double param_1 = uv_e1[0].param
- + y*(uv_e1[nbright-1].param -uv_e1[0].param); // est
- double param_3 = uv_e3[0].param
- + y*(uv_e3[nbright-1].param -uv_e3[0].param); // ouest
-
- //MESSAGE("params "<<param_0<<" "<<param_1<<" "<<param_2<<" "<<param_3);
- gp_Pnt2d p0 = c2d[0]->Value(param_0);
- gp_Pnt2d p1 = c2d[1]->Value(param_1);
- gp_Pnt2d p2 = c2d[2]->Value(param_2);
- gp_Pnt2d p3 = c2d[3]->Value(param_3);
-
- double u = (1-y)*p0.X() + x*p1.X() + y*p2.X() + (1-x)*p3.X();
- double v = (1-y)*p0.Y() + x*p1.Y() + y*p2.Y() + (1-x)*p3.Y();
-
- u -= (1-x)*(1-y)*a0.X() + x*(1-y)*a1.X() + x*y*a2.X() + (1-x)*y*a3.X();
- v -= (1-x)*(1-y)*a0.Y() + x*(1-y)*a1.Y() + x*y*a2.Y() + (1-x)*y*a3.Y();
-
- uv_grid[ij].u = u;
- uv_grid[ij].v = v;
-
- //MESSAGE("-uv- "<<i<<" "<<j<<" "<<uv_grid[ij].u<<" "<<uv_grid[ij].v);
- }
+ // 2 --- load 2d edge points (u,v) with orientation and value on unit square
+
+ for (int i = 0; i < 2; i++)
+ {
+ quad->uv_edges[i] = LoadEdgePoints(aMesh, F,
+ quad->edge[i], quad->first[i], quad->last[i]);
+
+ // quad->isEdgeForward[i]);
+ }
+ for (int i = 2; i < 4; i++)
+ {
+ quad->uv_edges[i] = LoadEdgePoints(aMesh, F,
+ quad->edge[i], quad->last[i], quad->first[i]);
+
+ // !quad->isEdgeForward[i]);
+ }
+
+ // 3 --- 2D normalized values on unit square [0..1][0..1]
+
+ int nbdown = quad->nbPts[0];
+ int nbright = quad->nbPts[1];
+ quad->uv_grid = new UVPtStruct[nbright * nbdown];
+
+ UVPtStruct *uv_grid = quad->uv_grid;
+ UVPtStruct *uv_e0 = quad->uv_edges[0];
+ UVPtStruct *uv_e1 = quad->uv_edges[1];
+ UVPtStruct *uv_e2 = quad->uv_edges[2];
+ UVPtStruct *uv_e3 = quad->uv_edges[3];
+ gp_Pnt2d a0 = pf[0];
+ gp_Pnt2d a1 = pf[1];
+ gp_Pnt2d a2 = pf[2];
+ gp_Pnt2d a3 = pf[3];
+
+ // nodes Id on edges
+
+ int j = 0;
+ for (int i = 0; i < nbdown; i++)
+ {
+ int ij = j * nbdown + i;
+ uv_grid[ij].node = uv_e0[i].node;
+ }
+ i = nbdown - 1;
+ for (int j = 0; j < nbright; j++)
+ {
+ int ij = j * nbdown + i;
+ uv_grid[ij].node = uv_e1[j].node;
+ }
+ j = nbright - 1;
+ for (int i = 0; i < nbdown; i++)
+ {
+ int ij = j * nbdown + i;
+ uv_grid[ij].node = uv_e2[i].node;
+ }
+ i = 0;
+ for (int j = 0; j < nbright; j++)
+ {
+ int ij = j * nbdown + i;
+ uv_grid[ij].node = uv_e3[j].node;
+ }
+
+ // normalized 2d values on grid
+
+ for (int i = 0; i < nbdown; i++)
+ for (int j = 0; j < nbright; j++)
+ {
+ int ij = j * nbdown + i;
+ // --- droite i cste : x = x0 + y(x1-x0)
+ double x0 = uv_e0[i].normParam; // bas - sud
+ double x1 = uv_e2[i].normParam; // haut - nord
+ // --- droite j cste : y = y0 + x(y1-y0)
+ double y0 = uv_e3[j].normParam; // gauche-ouest
+ double y1 = uv_e1[j].normParam; // droite - est
+ // --- intersection : x=x0+(y0+x(y1-y0))(x1-x0)
+ double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0));
+ double y = y0 + x * (y1 - y0);
+ uv_grid[ij].x = x;
+ uv_grid[ij].y = y;
+ //MESSAGE("-xy-01 "<<x0<<" "<<x1<<" "<<y0<<" "<<y1);
+ //MESSAGE("-xy-norm "<<i<<" "<<j<<" "<<x<<" "<<y);
+ }
+
+ // 4 --- projection on 2d domain (u,v)
+
+ for (int i = 0; i < nbdown; i++)
+ for (int j = 0; j < nbright; j++)
+ {
+ int ij = j * nbdown + i;
+ double x = uv_grid[ij].x;
+ double y = uv_grid[ij].y;
+ double param_0 = uv_e0[0].param + x * (uv_e0[nbdown - 1].param - uv_e0[0].param); // sud
+ double param_2 = uv_e2[0].param + x * (uv_e2[nbdown - 1].param - uv_e2[0].param); // nord
+ double param_1 = uv_e1[0].param + y * (uv_e1[nbright - 1].param - uv_e1[0].param); // est
+ double param_3 = uv_e3[0].param + y * (uv_e3[nbright - 1].param - uv_e3[0].param); // ouest
+
+ //MESSAGE("params "<<param_0<<" "<<param_1<<" "<<param_2<<" "<<param_3);
+ gp_Pnt2d p0 = c2d[0]->Value(param_0);
+ gp_Pnt2d p1 = c2d[1]->Value(param_1);
+ gp_Pnt2d p2 = c2d[2]->Value(param_2);
+ gp_Pnt2d p3 = c2d[3]->Value(param_3);
+
+ double u =
+ (1 - y) * p0.X() + x * p1.X() + y * p2.X() + (1 - x) * p3.X();
+ double v =
+ (1 - y) * p0.Y() + x * p1.Y() + y * p2.Y() + (1 - x) * p3.Y();
+
+ u -= (1 - x) * (1 - y) * a0.X() + x * (1 - y) * a1.X() +
+ x * y * a2.X() + (1 - x) * y * a3.X();
+ v -= (1 - x) * (1 - y) * a0.Y() + x * (1 - y) * a1.Y() +
+ x * y * a2.Y() + (1 - x) * y * a3.Y();
+
+ uv_grid[ij].u = u;
+ uv_grid[ij].v = v;
+
+ //MESSAGE("-uv- "<<i<<" "<<j<<" "<<uv_grid[ij].u<<" "<<uv_grid[ij].v);
+ }