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-vertex.hh"
00026 #include "g-map-vertex.hh"
00027 #include "inter-smooth-diver.hh"
00028 #include <cassert>
00029 using namespace GMap3d;
00030
00031 void CMeshVertex::mesh1(CDart * ADart, int ASx,
00032 const CTransformationMatrix * AMeshMatrix,
00033 bool AMeshWithMerges,
00034 bool AMeshWithAdjacentSews,
00035 bool AMeshAssociatedCells,
00036 int ADirectInfoAlpha0, int ADirectInfoAssoc)
00037 {
00038 assert(ADart!=NULL);
00039 assert(canMesh1(ADart));
00040 assert(ASx>0);
00041 assert(!AMeshWithMerges || ADirectInfoAlpha0>=0);
00042 assert( AMeshWithMerges || ADirectInfoAssoc >=0);
00043
00044
00045 CMesh1Diver* diver;
00046
00047 if (AMeshMatrix == &COONS || AMeshMatrix == NULL)
00048 {
00049 CVertex & V1 = * FMap->findVertex(ADart);
00050 CVertex & V2 = * FMap->findVertex(FMap->alpha0(ADart));
00051 diver = new CMesh1LinearDiver(ASx, V1,V2);
00052 }
00053 else
00054 {
00055 CVertex CP[4];
00056
00057 get4ControlPoints(ADart, CP, ADirectInfoAlpha0);
00058 diver = new CMesh1SmoothingDiver(ASx, *AMeshMatrix, CP);
00059 }
00060
00061
00062 CMeshGeneric::mesh1(ADart, ASx, AMeshMatrix, AMeshWithMerges,
00063 AMeshWithAdjacentSews, AMeshAssociatedCells,
00064 ADirectInfoAlpha0, ADirectInfoAssoc);
00065
00066
00067 CDart * first = AMeshWithMerges
00068 ? ADart : FMap->getDirectInfoAsDart(ADart, ADirectInfoAssoc);
00069
00070 FMap->diveMesh1(first, *diver, CGMapVertex::GMV_CHECK);
00071
00072 delete diver;
00073 }
00074
00075 void CMeshVertex::mesh2(CDart* ADart,
00076 int ASx, int ASy,
00077 const CTransformationMatrix * AMeshMatrix,
00078 bool AMeshWithMerges,
00079 bool AMeshWithAdjacentSews,
00080 bool AMeshAssociatedCells,
00081 bool AGetAssociatedEmbeddings,
00082 int AInitialMeshDim, int AFinalMeshDim,
00083 int ADirectInfoAlpha0, int ADirectInfoAssoc)
00084 {
00085 assert(ADart!=NULL);
00086 assert(ASx>0);
00087 assert(ASy>0);
00088 assert(0<=AInitialMeshDim && AInitialMeshDim<=1);
00089 assert(1<=AFinalMeshDim && AFinalMeshDim <=2);
00090 assert(AInitialMeshDim < AFinalMeshDim);
00091 assert(canMesh2(AMeshAssociatedCells
00092 ? FMap->getDirectInfoAsDart(ADart, ADirectInfoAssoc) : ADart,
00093 ASx,ASy, AInitialMeshDim));
00094
00095 assert(FMap->findVertex(ADart)!=NULL);
00096
00097
00098 CMeshGeneric::mesh2(ADart, ASx,ASy, AMeshMatrix, AMeshWithMerges,
00099 AMeshWithAdjacentSews, AMeshAssociatedCells,
00100 AGetAssociatedEmbeddings,
00101 AInitialMeshDim, AFinalMeshDim,
00102 ADirectInfoAlpha0, ADirectInfoAssoc);
00103
00104 assert(FMap->findVertex(ADart)!=NULL);
00105
00106
00107 if (AFinalMeshDim==2)
00108 {
00109 CMesh2Diver* diver;
00110
00111 CDart* geo =
00112 AGetAssociatedEmbeddings
00113 ? FMap->getDirectInfoAsDart(ADart, ADirectInfoAssoc)
00114 : ADart;
00115
00116 assert(FMap->findVertex(geo)!=NULL);
00117
00118 if (AMeshMatrix == &COONS || AMeshMatrix == NULL)
00119 {
00120 CDart * current;
00121
00122 const CVertex ** bottom = new const CVertex * [ASx+1];
00123 const CVertex ** top = new const CVertex * [ASx+1];
00124 const CVertex ** left = new const CVertex * [ASy+1];
00125 const CVertex ** right = new const CVertex * [ASy+1];
00126
00127 bool already2Meshed = AInitialMeshDim!=1 || AMeshWithMerges;
00128
00129 current = getMesh1Dive(geo, ASx, bottom, already2Meshed);
00130 getMesh1Dive(FMap->alpha1(current), ASy, right, already2Meshed);
00131
00132 current = getMesh1Dive(FMap->alpha1(geo), ASy, left, already2Meshed);
00133 getMesh1Dive(FMap->alpha1(current), ASx, top, already2Meshed);
00134
00135 diver = new CMesh2LinearDiver(ASx,ASy, bottom,top,left,right);
00136
00137 delete [] bottom;
00138 delete [] top;
00139 delete [] left;
00140 delete [] right;
00141 }
00142 else
00143 {
00144 CVertex** CP = allocVertexArray2(4,4);
00145
00146 get16ControlPoints(ADart, CP, ADirectInfoAlpha0);
00147
00148 diver = new CMesh2SmoothingDiver(ASx,ASy, *AMeshMatrix,
00149 (const CVertex **) CP);
00150
00151 freeVertexArray2(CP, 4,4);
00152 }
00153
00154 CDart * first =
00155 AMeshAssociatedCells
00156 ? FMap->getDirectInfoAsDart(ADart, ADirectInfoAssoc)
00157 : ADart;
00158
00159 FMap->diveMesh2(first, *diver, CGMapVertex::GMV_CHECK);
00160
00161 delete diver;
00162 }
00163 }
00164
00165 void CMeshVertex::mesh3(CDart * ADart,
00166 int ASx, int ASy, int ASz,
00167 const CTransformationMatrix * AMeshMatrix,
00168 bool AMeshWithMerges,
00169 bool AMeshWithAdjacentSews,
00170 bool AMeshAssociatedCells,
00171 int AInitialMeshDim, int AFinalMeshDim,
00172 int , int ADirectInfoAssoc)
00173 {
00174 assert(ASx>0);
00175 assert(ASy>0);
00176 assert(ASz>0);
00177
00178 assert(0 <= AInitialMeshDim);
00179 assert(AInitialMeshDim < AFinalMeshDim);
00180 assert(AFinalMeshDim <= 3);
00181
00182 assert(canMesh3(ADart, ASx,ASy,ASz, AInitialMeshDim));
00183
00184
00185 CMeshGeneric::mesh3(ADart, ASx,ASy,ASz, AMeshMatrix, AMeshWithMerges,
00186 AMeshWithAdjacentSews, AMeshAssociatedCells,
00187 AInitialMeshDim,AFinalMeshDim, ADirectInfoAssoc);
00188
00189
00190 if (AFinalMeshDim==3)
00191 {
00192 const CVertex
00193 *** left = allocVertexPtrArray2(ASy+1, ASz+1),
00194 *** right = allocVertexPtrArray2(ASy+1, ASz+1),
00195 *** front = allocVertexPtrArray2(ASz+1, ASx+1),
00196 *** back = allocVertexPtrArray2(ASz+1, ASx+1),
00197 *** bottom = allocVertexPtrArray2(ASx+1, ASy+1),
00198 *** top = allocVertexPtrArray2(ASx+1, ASy+1);
00199
00200
00201 CDart * other;
00202
00203 other = getMesh2Dive( ADart , ASx,ASy, bottom, true, 1);
00204 getMesh2Dive(FMap->alpha12 (other), ASy,ASz, right , true );
00205 other = getMesh2Dive(FMap->alpha12 (ADart), ASy,ASz, left , true, 1);
00206 getMesh2Dive(FMap->alpha12 (other), ASz,ASx, back , true );
00207 other = getMesh2Dive(FMap->alpha1212(ADart), ASz,ASx, front , true, 1);
00208 getMesh2Dive(FMap->alpha12 (other), ASx,ASy, top , true );
00209
00210
00211 CMesh3LinearDiver diver(ASx,ASy,ASz, left,right,front,back,bottom,top);
00212 FMap->diveMesh3(ADart, diver, CGMapVertex::GMV_CHECK);
00213
00214
00215 freeVertexPtrArray2(left , ASy+1, ASz+1);
00216 freeVertexPtrArray2(right , ASy+1, ASz+1);
00217 freeVertexPtrArray2(front , ASz+1, ASx+1);
00218 freeVertexPtrArray2(back , ASz+1, ASx+1);
00219 freeVertexPtrArray2(bottom, ASx+1, ASy+1);
00220 freeVertexPtrArray2(top , ASx+1, ASy+1);
00221 }
00222 }
00223