Changeset 2847
- Timestamp:
- 01/14/10 17:38:36 (15 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Bamgx/Mesh2.cpp
r2843 r2847 220 220 } 221 221 222 223 224 225 Real8 Vertex::Smoothing(Triangles & Th,const Triangles & BTh,Triangle * & tstart ,Real8 omega)226 {227 register Vertex * s = this;228 Vertex &vP = *s,vPsave=vP;229 // if (vP.on) return 0;// Don't move boundary vertex230 231 register Triangle * tbegin= t , *tria = t , *ttc;232 233 register int k=0,kk=0,j = EdgesVertexTriangle[vint][0],jc;234 R2 P(s->r),PNew(0,0);235 // cout << BTh.quadtree << " " << BTh.quadtree->root << endl;236 // assert(BTh.quadtree && BTh.quadtree->root);237 do {238 k++;239 240 if (!tria->Hidden(j))241 {242 Vertex &vQ = (*tria)[VerticesOfTriangularEdge[j][0]];243 244 R2 Q = vQ,QP(P-Q);245 Real8 lQP = LengthInterpole(vP,vQ,QP);246 PNew += Q+QP/Max(lQP,1e-20);247 kk ++;248 }249 ttc = tria->TriangleAdj(j);250 jc = NextEdge[tria->NuEdgeTriangleAdj(j)];251 tria = ttc;252 j = NextEdge[jc];253 assert(k<2000);254 } while ( tbegin != tria);255 if (kk<4) return 0;256 PNew = PNew/(Real8)kk;257 R2 Xmove((PNew-P)*omega);258 PNew = P+Xmove;259 Real8 delta=Norme2_2(Xmove);260 261 262 //263 Icoor2 deta[3];264 I2 IBTh = BTh.toI2(PNew);265 266 tstart=BTh.FindTriangleContening(IBTh,deta,tstart);267 268 if (tstart->det <0)269 { // outside270 double ba,bb;271 TriangleAdjacent edge= CloseBoundaryEdge(IBTh,tstart,ba,bb) ;272 tstart = edge;273 vP.m= Metric(ba,*edge.EdgeVertex(0),bb,*edge.EdgeVertex(1));274 }275 else276 { // inside277 Real8 aa[3];278 Real8 s = deta[0]+deta[1]+deta[2];279 aa[0]=deta[0]/s;280 aa[1]=deta[1]/s;281 aa[2]=deta[2]/s;282 vP.m = Metric(aa,(*tstart)[0],(*tstart)[1],(*tstart)[2]);283 }284 285 // recompute the det of the triangle286 vP.r = PNew;287 288 vP.i = Th.toI2(PNew);289 290 Vertex vPnew = vP;291 292 int ok=1;293 int loop=1;294 k=0;295 while (ok)296 {297 ok =0;298 do {299 k++;300 double detold = tria->det;301 tria->det = bamg::det( (*tria)[0],(*tria)[1] ,(*tria)[2]);302 if (loop)303 {304 Vertex *v0,*v1,*v2,*v3;305 if (tria->det<0) ok =1;306 else if (tria->Quadrangle(v0,v1,v2,v3))307 {308 vP = vPsave;309 Real8 qold =QuadQuality(*v0,*v1,*v2,*v3);310 vP = vPnew;311 Real8 qnew = QuadQuality(*v0,*v1,*v2,*v3);312 if (qnew<qold) ok = 1;313 }314 else if ( (double)tria->det < detold/2 ) ok=1;315 316 }317 tria->SetUnMarkUnSwap(0);318 tria->SetUnMarkUnSwap(1);319 tria->SetUnMarkUnSwap(2);320 ttc = tria->TriangleAdj(j);321 jc = NextEdge[tria->NuEdgeTriangleAdj(j)];322 tria = ttc;323 j = NextEdge[jc];324 assert(k<2000);325 } while ( tbegin != tria);326 if (ok && loop) vP=vPsave; // no move327 loop=0;328 }329 return delta;330 }331 332 333 double QuadQuality(const Vertex & a,const Vertex &b,const Vertex &c,const Vertex &d) {334 // calcul de 4 angles --335 R2 A((R2)a),B((R2)b),C((R2)c),D((R2)d);336 R2 AB(B-A),BC(C-B),CD(D-C),DA(A-D);337 // Move(A),Line(B),Line(C),Line(D),Line(A);338 const Metric & Ma = a;339 const Metric & Mb = b;340 const Metric & Mc = c;341 const Metric & Md = d;342 343 double lAB=Norme2(AB);344 double lBC=Norme2(BC);345 double lCD=Norme2(CD);346 double lDA=Norme2(DA);347 AB /= lAB; BC /= lBC; CD /= lCD; DA /= lDA;348 // version aniso349 double cosDAB= Ma(DA,AB)/(Ma(DA)*Ma(AB)),sinDAB= Det(DA,AB);350 double cosABC= Mb(AB,BC)/(Mb(AB)*Mb(BC)),sinABC= Det(AB,BC);351 double cosBCD= Mc(BC,CD)/(Mc(BC)*Mc(CD)),sinBCD= Det(BC,CD);352 double cosCDA= Md(CD,DA)/(Md(CD)*Md(DA)),sinCDA= Det(CD,DA);353 double sinmin=Min(Min(sinDAB,sinABC),Min(sinBCD,sinCDA));354 if (sinmin<=0) return sinmin;355 return 1.0-Max(Max(Abs(cosDAB),Abs(cosABC)),Max(Abs(cosBCD),Abs(cosCDA)));356 222 } 357 223 358 }359 -
issm/trunk/src/c/Makefile.am
r2843 r2847 329 329 ./Bamgx/objects/Triangles.cpp \ 330 330 ./Bamgx/objects/Triangle.cpp \ 331 ./Bamgx/objects/Vertex.cpp \ 331 332 ./Bamgx/objects/Geometry.cpp \ 332 333 ./Bamgx/objects/QuadTree.cpp \ … … 670 671 ./Bamgx/objects/Triangles.cpp \ 671 672 ./Bamgx/objects/Triangle.cpp \ 673 ./Bamgx/objects/Vertex.cpp \ 672 674 ./Bamgx/objects/Geometry.cpp \ 673 675 ./Bamgx/objects/QuadTree.cpp \
Note:
See TracChangeset
for help on using the changeset viewer.