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 "mesh-generic.hh"
00026 #include "g-map-generic.hh"
00027 #include <cassert>
00028 using namespace GMap3d;
00029
00030 bool CMeshGeneric::canMesh1(CDart* ADart)
00031 {
00032 assert(ADart != NULL);
00033 return isTopoEdge(ADart);
00034 }
00035
00036 void CMeshGeneric::mesh1(CDart* ADart, int ASx,
00037 const CTransformationMatrix* ,
00038 bool AMeshWithMerges,
00039 bool AMeshWithAdjacentSews,
00040 bool AMeshAssociatedCells,
00041 int , int ADirectInfoAssoc)
00042 {
00043 assert(ADart!=NULL);
00044 assert(canMesh1(ADart));
00045 assert(ASx>0);
00046
00047 CDart* extremities[2];
00048
00049 if (AMeshWithMerges)
00050 {
00051 FMap->createTopoMesh1(ASx, extremities, ADart);
00052 mergeEdgeAndMesh1(ADart, extremities);
00053 }
00054 else
00055 {
00056 assert(ADirectInfoAssoc >= 0);
00057
00058 if (AMeshWithAdjacentSews)
00059 {
00060 CDart* assoc = FMap->getDirectInfoAsDart(ADart, ADirectInfoAssoc);
00061 FMap->createTopoMesh1(ASx, extremities, assoc);
00062 mergeEdgeAndMesh1(assoc, extremities);
00063 }
00064 else
00065 {
00066 if (AMeshAssociatedCells)
00067 {
00068 CDart* assoc = FMap->getDirectInfoAsDart(ADart, ADirectInfoAssoc);
00069
00070 FMap->createTopoMesh1(ASx, extremities, assoc);
00071 mergeEdgeAndMesh1(assoc, extremities);
00072 }
00073 else
00074 {
00075 FMap->createTopoMesh1(ASx, extremities, NULL);
00076 FMap->setDirectInfo( ADart , ADirectInfoAssoc, extremities[0]);
00077 FMap->setDirectInfo(FMap->alpha0(ADart), ADirectInfoAssoc, extremities[1]);
00078 }
00079 }
00080 }
00081 }
00082
00083 bool CMeshGeneric::canMesh2(CDart* ADart,
00084 int ASx, int ASy, int AInitialMeshDim)
00085 {
00086 assert(ADart!=NULL);
00087 assert(ASx>0);
00088 assert(ASy>0);
00089 assert(0<=AInitialMeshDim && AInitialMeshDim<=1);
00090
00091 return isTopoSquareIMeshed(AInitialMeshDim, ADart, ASx,ASy,
00092 true, ! FMap->isFree3(ADart));
00093 }
00094
00095 void CMeshGeneric::mesh2(CDart* ADart,
00096 int ASx, int ASy,
00097 const CTransformationMatrix * AMeshMatrix,
00098 bool AMeshWithMerges,
00099 bool AMeshWithAdjacentSews,
00100 bool AMeshAssociatedCells,
00101 bool ,
00102 int AInitialMeshDim, int AFinalMeshDim,
00103 int ADirectInfoAlpha0, int ADirectInfoAssoc)
00104 {
00105 assert(ADart!=NULL);
00106 assert(ASx>0);
00107 assert(ASy>0);
00108 assert(0<=AInitialMeshDim && AInitialMeshDim<=1);
00109 assert(1<=AFinalMeshDim && AFinalMeshDim <=2);
00110 assert(AInitialMeshDim < AFinalMeshDim);
00111
00112 assert(canMesh2(AMeshAssociatedCells
00113 ? FMap->getDirectInfoAsDart(ADart, ADirectInfoAssoc) : ADart,
00114 ASx,ASy, AInitialMeshDim));
00115
00116 bool isolated = !AMeshWithMerges && !AMeshWithAdjacentSews;
00117
00118
00119 if (AInitialMeshDim==0 && (AFinalMeshDim==1 || !isolated))
00120 {
00121 CDart* dart1 = ADart;
00122 CDart* dart2 = FMap->alpha0101(ADart);
00123
00124 mesh1( dart1, ASx, AMeshMatrix, AMeshWithMerges, AMeshWithAdjacentSews,
00125 AMeshAssociatedCells, ADirectInfoAlpha0, ADirectInfoAssoc);
00126 mesh1( FMap->alpha1(dart1), ASy, AMeshMatrix, AMeshWithMerges, AMeshWithAdjacentSews,
00127 AMeshAssociatedCells, ADirectInfoAlpha0, ADirectInfoAssoc);
00128 mesh1( dart2, ASx, AMeshMatrix, AMeshWithMerges, AMeshWithAdjacentSews,
00129 AMeshAssociatedCells, ADirectInfoAlpha0, ADirectInfoAssoc);
00130 mesh1( FMap->alpha1(dart2), ASy, AMeshMatrix, AMeshWithMerges, AMeshWithAdjacentSews,
00131 AMeshAssociatedCells, ADirectInfoAlpha0, ADirectInfoAssoc);
00132 }
00133
00134
00135 if (AFinalMeshDim==2)
00136 {
00137 CDart* first =
00138 AMeshAssociatedCells
00139 ? FMap->getDirectInfoAsDart(ADart, ADirectInfoAssoc)
00140 : ADart;
00141
00142 CDart* mesh = FMap->createTopoMesh2(ASx, ASy, !isolated &&
00143 ! FMap->isFree3(first));
00144
00145 mergeSquare1MeshedAndMesh2(first, mesh, ASx, ASy);
00146 }
00147 }
00148
00149 bool CMeshGeneric::canMesh3(CDart* ADart,
00150 int ASx, int ASy, int ASz, int AInitialMeshDim)
00151 {
00152 assert(ADart!=NULL);
00153 assert(ASx>0);
00154 assert(ASy>0);
00155 assert(ASz>0);
00156 assert(0<=AInitialMeshDim && AInitialMeshDim<=2);
00157
00158 return isTopoCubeIMeshed(AInitialMeshDim, ADart, ASx,ASy,ASz);
00159 }
00160
00161 void CMeshGeneric::mesh3(CDart* ADart,
00162 int ASx, int ASy, int ASz,
00163 const CTransformationMatrix * AMeshMatrix,
00164 bool AMeshWithMerges,
00165 bool AMeshWithAdjacentSews,
00166 bool AMeshAssociatedCells,
00167 int AInitialMeshDim, int AFinalMeshDim,
00168 int , int ADirectInfoAssoc)
00169 {
00170 assert(ADart!=NULL);
00171 assert(ASx>0);
00172 assert(ASy>0);
00173 assert(ASz>0);
00174 assert(0<=AInitialMeshDim && AInitialMeshDim<=2);
00175 assert(1<=AFinalMeshDim && AFinalMeshDim <=3);
00176 assert(AInitialMeshDim < AFinalMeshDim);
00177 assert(canMesh3(ADart, ASx,ASy,ASz, AInitialMeshDim));
00178
00179
00180 if (AInitialMeshDim==0)
00181 {
00182 CDart* dart1 = ADart;
00183 CDart* dart2 = FMap->alpha21012(FMap->alpha0101(ADart));
00184
00185 mesh1( FMap->alpha21 (dart1), ASz, AMeshMatrix, AMeshWithMerges,
00186 AMeshWithAdjacentSews, AMeshAssociatedCells, ADirectInfoAssoc);
00187 mesh1( FMap->alpha21 (dart2), ASz, AMeshMatrix, AMeshWithMerges,
00188 AMeshWithAdjacentSews, AMeshAssociatedCells, ADirectInfoAssoc);
00189 mesh1( FMap->alpha021(dart1), ASz, AMeshMatrix, AMeshWithMerges,
00190 AMeshWithAdjacentSews, AMeshAssociatedCells, ADirectInfoAssoc);
00191 mesh1( FMap->alpha021(dart2), ASz, AMeshMatrix, AMeshWithMerges,
00192 AMeshWithAdjacentSews, AMeshAssociatedCells, ADirectInfoAssoc);
00193 mesh1( FMap->alpha01 (dart1), ASy, AMeshMatrix, AMeshWithMerges,
00194 AMeshWithAdjacentSews, AMeshAssociatedCells, ADirectInfoAssoc);
00195 mesh1( FMap->alpha01 (dart2), ASy, AMeshMatrix, AMeshWithMerges,
00196 AMeshWithAdjacentSews, AMeshAssociatedCells, ADirectInfoAssoc);
00197 mesh1( FMap->alpha101(dart1), ASx, AMeshMatrix, AMeshWithMerges,
00198 AMeshWithAdjacentSews, AMeshAssociatedCells, ADirectInfoAssoc);
00199 mesh1( FMap->alpha101(dart2), ASx, AMeshMatrix, AMeshWithMerges,
00200 AMeshWithAdjacentSews, AMeshAssociatedCells, ADirectInfoAssoc);
00201 mesh1( FMap->alpha1 (dart1), ASy, AMeshMatrix, AMeshWithMerges,
00202 AMeshWithAdjacentSews, AMeshAssociatedCells, ADirectInfoAssoc);
00203 mesh1( FMap->alpha1 (dart2), ASy, AMeshMatrix, AMeshWithMerges,
00204 AMeshWithAdjacentSews, AMeshAssociatedCells, ADirectInfoAssoc);
00205 mesh1( dart1 , ASx, AMeshMatrix, AMeshWithMerges,
00206 AMeshWithAdjacentSews, AMeshAssociatedCells, ADirectInfoAssoc);
00207 mesh1( dart2 , ASx, AMeshMatrix, AMeshWithMerges,
00208 AMeshWithAdjacentSews, AMeshAssociatedCells, ADirectInfoAssoc);
00209 }
00210
00211 if (AFinalMeshDim>=2)
00212 {
00213
00214 if (AInitialMeshDim<2)
00215 {
00216 CDart* dart1 = ADart;
00217 CDart* dart2 = ADart;
00218
00219 for (int i=0; i<ASx; ++i)
00220 dart2 = FMap->alpha01(dart2);
00221
00222 for (int j=0; j<ASy; ++j)
00223 dart2 = FMap->alpha01(dart2);
00224
00225 dart2 = FMap->alpha21(dart2);
00226
00227 for (int k=0; k<ASz; ++k)
00228 dart2 = FMap->alpha01(dart2);
00229
00230 mesh2( dart1 , ASx,ASy, AMeshMatrix, AMeshWithMerges,
00231 AMeshWithAdjacentSews, AMeshAssociatedCells, false,
00232 1,2, ADirectInfoAssoc);
00233 mesh2( dart2 , ASx,ASy, AMeshMatrix, AMeshWithMerges,
00234 AMeshWithAdjacentSews, AMeshAssociatedCells, false,
00235 1,2, ADirectInfoAssoc);
00236 mesh2(FMap->alpha2 (dart1), ASx,ASz, AMeshMatrix, AMeshWithMerges,
00237 AMeshWithAdjacentSews, AMeshAssociatedCells, false,
00238 1,2, ADirectInfoAssoc);
00239 mesh2(FMap->alpha2 (dart2), ASx,ASz, AMeshMatrix, AMeshWithMerges,
00240 AMeshWithAdjacentSews, AMeshAssociatedCells, false,
00241 1,2, ADirectInfoAssoc);
00242 mesh2(FMap->alpha12(dart1), ASy,ASz, AMeshMatrix, AMeshWithMerges,
00243 AMeshWithAdjacentSews, AMeshAssociatedCells, false,
00244 1,2, ADirectInfoAssoc);
00245 mesh2(FMap->alpha12(dart2), ASy,ASz, AMeshMatrix, AMeshWithMerges,
00246 AMeshWithAdjacentSews, AMeshAssociatedCells, false,
00247 1,2, ADirectInfoAssoc);
00248 }
00249
00250
00251 if (AFinalMeshDim==3)
00252 mergeCube2MeshedAndMesh3(ADart,
00253 FMap->createTopoMesh3(ASx, ASy, ASz),
00254 ASx, ASy, ASz);
00255 }
00256 }
00257