00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "g-map-vertex.hh"
00026 using namespace GMap3d;
00027
00028 bool CGMapVertex::canPlate(CDart * ADart1, CDart * ADart2)
00029 {
00030 assert(ADart1!=NULL && ADart2!=NULL);
00031 return !isSameOrbit(ADart1,ADart2, ORBIT_CC);
00032 }
00033
00034 int CGMapVertex::getPlateDimension(CDart * ADart1, CDart * ADart2)
00035 {
00036 assert(ADart1!=NULL && ADart2!=NULL);
00037
00038 if (!canPlate(ADart1,ADart2))
00039 return -1;
00040
00041 if (isFree1(ADart1) && isFree1(ADart2)) return 0;
00042 if (isFree2(ADart1) && isFree2(ADart2)) return 1;
00043 if (isFree3(ADart1) && isFree3(ADart2)) return 2;
00044
00045 return -1;
00046 }
00047
00048 void CGMapVertex::plate(CDart * ADart1, CDart * ADart2, int ADim,
00049 bool ARotateCells,
00050 bool AScaleCells,
00051 bool ATranslateCells)
00052 {
00053 assert(ADart1!=NULL && ADart2!=NULL);
00054 assert(ADim>=0 && ADim<3);
00055 assert(canPlate(ADart1,ADart2));
00056
00057 CVertex origin1, origin2;
00058 CVertex U1,V1, U2,V2;
00059 TCoordinate kHomothety;
00060
00061
00062 origin1= barycenter(ADart1, ORBIT_INF[ADim]);
00063
00064 if (ATranslateCells)
00065 origin2= barycenter(ADart2, ORBIT_INF[ADim]);
00066 else
00067 origin2= origin1;
00068
00069
00070 if (ADim==0 || !ARotateCells)
00071 {
00072 U1= U2= OZ;
00073 V1= V2= OX;
00074 }
00075 else
00076 {
00077 U1= faceNormalVector(ADart1); if (U1.isNull()) U1= OZ;
00078 U2= faceNormalVector(ADart2); if (U2.isNull()) U2= OZ;
00079
00080 V1= barycenter(ADart1, ORBIT_EDGE) - barycenter(ADart1, ORBIT_FACE);
00081 if (V1.isNull()) V1= OX;
00082 V2= barycenter(ADart2, ORBIT_EDGE) - barycenter(ADart2, ORBIT_FACE);
00083 if (V2.isNull()) V2= OX;
00084
00085 if ((U1*V1).isNull() || (U2*V2).isNull())
00086 { U1= U2= OZ; V1= V2= OX; }
00087 else
00088 if (ADim==1)
00089 { U2= -U2; V2= -V2; }
00090 }
00091
00092
00093 if (ADim==0 || !AScaleCells)
00094 kHomothety = 1;
00095 else
00096 {
00097 TCoordinate length1=
00098 ADim==1 ? edgeLength(ADart1) : facePerimeter(ADart1);
00099
00100 TCoordinate length2=
00101 ADim==1 ? edgeLength(ADart2) : facePerimeter(ADart2);
00102
00103 kHomothety = isZero(length1) ? 1 : length2/length1;
00104 }
00105
00106 {
00107
00108 CTransformationMatrix platingMatrix(CTransformationMatrix::IdentityMatrix);
00109
00110 platingMatrix.transform(origin1, U1, V1,
00111 origin2, U2, V2,
00112 CVertex(kHomothety, kHomothety, kHomothety));
00113
00114
00115 applyMatrix(platingMatrix, ADart1,ORBIT_CC);
00116 }
00117 }
00118
00119 bool CGMapVertex::intuitivePlate(CDart * ADart1, CDart * ADart2,
00120 bool ARotateCells, bool AScaleCells,
00121 bool ATranslateCells)
00122 {
00123 assert(ADart1!=NULL && ADart2!=NULL);
00124
00125 int dim= getPlateDimension(ADart1,ADart2);
00126
00127 if (dim>0)
00128 plate(ADart1,ADart2, dim, ARotateCells, AScaleCells, ATranslateCells);
00129
00130 return dim>0;
00131 }
00132
00133 void CGMapVertex::borderPlate(CDart * ADart1, CDart * ADart2, int ADim,
00134 bool ARotateCells, bool AScaleCells,
00135 bool ATranslateCells)
00136 {
00137 assert(ADart1!=NULL && ADart2!=NULL);
00138 assert(ADim>=0 && ADim<3);
00139
00140 assert(canPlate(ADart1,ADart2));
00141
00142 CVertex origin1, origin2;
00143 CVertex U1,V1, U2,V2;
00144 TCoordinate kHomothety;
00145
00146
00147 origin1= barycenter(ADart1, ORBIT_BORDER[ADim]);
00148
00149 if (ATranslateCells)
00150 origin2= barycenter(ADart2, ORBIT_BORDER[ADim]);
00151 else
00152 origin2= origin1;
00153
00154
00155 if (ADim==0 || !ARotateCells)
00156 {
00157 U1= U2= OZ;
00158 V1= V2= OX;
00159 }
00160 else
00161 {
00162 if (ADim==1)
00163 {
00164 U1= faceNormalVector(ADart1);
00165 U2= faceNormalVector(ADart2);
00166 V1= barycenter(ADart1, ORBIT_BORDER_1)
00167 - barycenter(ADart1, ORBIT_FACE);
00168 V2= barycenter(ADart2, ORBIT_BORDER_1)
00169 - barycenter(ADart2, ORBIT_FACE);
00170 }
00171 else
00172 {
00173 U1= border2NormalVector(ADart1);
00174 U2= border2NormalVector(ADart2);
00175 V1= barycenter(ADart1, ORBIT_EDGE)
00176 - barycenter(ADart1, ORBIT_BORDER[ADim]);
00177 V2= barycenter(ADart2, ORBIT_EDGE)
00178 - barycenter(ADart2, ORBIT_BORDER[ADim]);
00179 }
00180
00181 if (U1.isNull()) U1= OZ;
00182 if (U2.isNull()) U2= OZ;
00183
00184 if (V1.isNull()) V1= OX;
00185 if (V2.isNull()) V2= OX;
00186
00187 if ((U1*V1).isNull() || (U2*V2).isNull())
00188 { U1= U2= OZ; V1= V2= OX; }
00189 else
00190 if (ADim==1)
00191 { U2= -U2; V2= -V2; }
00192 }
00193
00194
00195 if (ADim==0 || !AScaleCells)
00196 kHomothety = 1;
00197 else
00198 {
00199 TCoordinate length1= orbitLength(ADart1, ORBIT_BORDER[ADim]);
00200 TCoordinate length2= orbitLength(ADart2, ORBIT_BORDER[ADim]);
00201
00202 kHomothety = isZero(length1) ? 1 : length2/length1;
00203 }
00204
00205 {
00206
00207 CTransformationMatrix platingMatrix(CTransformationMatrix::IdentityMatrix);
00208
00209 platingMatrix.transform(origin1, U1, V1,
00210 origin2, U2, V2,
00211 CVertex(kHomothety, kHomothety, kHomothety));
00212
00213
00214 applyMatrix(platingMatrix, ADart1,ORBIT_CC);
00215 }
00216 }
00217