From 0ab97a6bf94d523ae4157593144f9dc179257b6d Mon Sep 17 00:00:00 2001 From: Jean-Francois Remacle <jean-francois.remacle@uclouvain.be> Date: Fri, 26 Nov 2004 14:42:56 +0000 Subject: [PATCH] *** empty log message *** --- Common/AdaptiveViews.cpp | 352 ++++++++++++++++++++++++++++++++++++--- Common/Views.h | 42 +++++ Plugin/CutMap.cpp | 6 +- Plugin/CutPlane.cpp | 28 ++-- Plugin/Levelset.cpp | 17 +- Plugin/Levelset.h | 4 +- 6 files changed, 406 insertions(+), 43 deletions(-) diff --git a/Common/AdaptiveViews.cpp b/Common/AdaptiveViews.cpp index d237d4db77..5b9b3d3c9a 100644 --- a/Common/AdaptiveViews.cpp +++ b/Common/AdaptiveViews.cpp @@ -36,6 +36,7 @@ std::set<_point> _point::all_points; std::list<_triangle*> _triangle::all_triangles; std::list<_tet*> _tet::all_tets; std::list<_quad*> _quad::all_quads; +std::list<_hex*> _hex::all_hexes; _point * _point::New ( double x, double y, double z, Double_Matrix *coeffs, Double_Matrix *eexps) { @@ -89,6 +90,18 @@ void _tet::clean () _point::all_points.clear(); } +void _hex::clean () +{ + std::list<_hex*>::iterator it = all_hexes.begin(); + std::list<_hex*>::iterator ite = all_hexes.end(); + for (;it!=ite;++it) + { + delete *it; + } + all_hexes.clear(); + _point::all_points.clear(); +} + void _triangle::Create (int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps) { @@ -100,8 +113,6 @@ void _triangle::Create (int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexp _point *p3 = _point::New ( 1,0,0, coeffs, eexps); _triangle *t = new _triangle(p1,p2,p3); Recur_Create (t, maxlevel,level,coeffs,eexps) ; - - printf("%d _triangle and %d _point created\n",(int)_triangle::all_triangles.size(),(int)_point::all_points.size()); } void _quad::Create (int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps) @@ -115,8 +126,6 @@ void _quad::Create (int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps) _point *p4 = _point::New ( 1,-1,0, coeffs, eexps); _quad *q = new _quad(p1,p2,p3,p4); Recur_Create (q, maxlevel,level,coeffs,eexps) ; - - printf("%d _triangle and %d _point created\n",(int)_triangle::all_triangles.size(),(int)_point::all_points.size()); } void _tet::Create (int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps) @@ -130,7 +139,23 @@ void _tet::Create (int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps) _point *p4 = _point::New ( 0,0,1, coeffs, eexps); _tet *t = new _tet(p1,p2,p3,p4); Recur_Create (t, maxlevel,level,coeffs,eexps) ; - Msg(INFO, "%d _triangle and %d _point created\n",(int)_tet::all_tets.size(),(int)_point::all_points.size()); +} + +void _hex::Create (int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps) +{ + Msg(INFO, "creating sub-elements"); + int level = 0; + clean(); + _point *p1 = _point::New ( -1,-1,0, coeffs, eexps); + _point *p2 = _point::New ( -1,1,0, coeffs, eexps); + _point *p3 = _point::New ( 1,1,0, coeffs, eexps); + _point *p4 = _point::New ( 1,-1,0, coeffs, eexps); + _point *p11 = _point::New ( -1,-1,1, coeffs, eexps); + _point *p21 = _point::New ( -1,1,1, coeffs, eexps); + _point *p31 = _point::New ( 1,1,1, coeffs, eexps); + _point *p41= _point::New ( 1,-1,1, coeffs, eexps); + _hex *h = new _hex(p1,p2,p3,p4,p11,p21,p31,p41); + Recur_Create (h, maxlevel,level,coeffs,eexps) ; } void _triangle::Recur_Create (_triangle *t, int maxlevel, int level , Double_Matrix *coeffs, Double_Matrix *eexps) @@ -250,6 +275,67 @@ void _tet::Recur_Create (_tet *t, int maxlevel, int level , Double_Matrix *coeff } +void _hex::Recur_Create (_hex *h, int maxlevel, int level , Double_Matrix *coeffs, Double_Matrix *eexps) +{ + all_hexes.push_back(h); + if (level++ >= maxlevel) + return; + + _point *p0 = h->p[0]; + _point *p1 = h->p[1]; + _point *p2 = h->p[2]; + _point *p3 = h->p[3]; + _point *p4 = h->p[4]; + _point *p5 = h->p[5]; + _point *p6 = h->p[6]; + _point *p7 = h->p[7]; + _point *p01 = _point::New ( (p0->x+p1->x)*0.5,(p0->y+p1->y)*0.5,(p0->z+p1->z)*0.5,coeffs, eexps); + _point *p12 = _point::New ( (p1->x+p2->x)*0.5,(p1->y+p2->y)*0.5,(p1->z+p2->z)*0.5,coeffs, eexps); + _point *p23 = _point::New ( (p2->x+p3->x)*0.5,(p2->y+p3->y)*0.5,(p2->z+p3->z)*0.5,coeffs, eexps); + _point *p03 = _point::New ( (p3->x+p0->x)*0.5,(p3->y+p0->y)*0.5,(p3->z+p0->z)*0.5,coeffs, eexps); + _point *p45 = _point::New ( (p4->x+p5->x)*0.5,(p4->y+p5->y)*0.5,(p4->z+p5->z)*0.5,coeffs, eexps); + _point *p56 = _point::New ( (p5->x+p6->x)*0.5,(p5->y+p6->y)*0.5,(p5->z+p6->z)*0.5,coeffs, eexps); + _point *p67 = _point::New ( (p6->x+p7->x)*0.5,(p6->y+p7->y)*0.5,(p6->z+p7->z)*0.5,coeffs, eexps); + _point *p47 = _point::New ( (p7->x+p4->x)*0.5,(p7->y+p4->y)*0.5,(p7->z+p4->z)*0.5,coeffs, eexps); + _point *p04 = _point::New ( (p4->x+p0->x)*0.5,(p4->y+p0->y)*0.5,(p4->z+p0->z)*0.5,coeffs, eexps); + _point *p15 = _point::New ( (p5->x+p1->x)*0.5,(p5->y+p1->y)*0.5,(p5->z+p1->z)*0.5,coeffs, eexps); + _point *p26 = _point::New ( (p6->x+p2->x)*0.5,(p6->y+p2->y)*0.5,(p6->z+p2->z)*0.5,coeffs, eexps); + _point *p37 = _point::New ( (p7->x+p3->x)*0.5,(p7->y+p3->y)*0.5,(p7->z+p3->z)*0.5,coeffs, eexps); + + _point *p0145 = _point::New ( (p45->x+p01->x)*0.5,(p45->y+p01->y)*0.5,(p45->z+p01->z)*0.5,coeffs, eexps); + _point *p1256 = _point::New ( (p12->x+p56->x)*0.5,(p12->y+p56->y)*0.5,(p12->z+p56->z)*0.5,coeffs, eexps); + _point *p2367 = _point::New ( (p23->x+p67->x)*0.5,(p23->y+p67->y)*0.5,(p23->z+p67->z)*0.5,coeffs, eexps); + _point *p0347 = _point::New ( (p03->x+p47->x)*0.5,(p03->y+p47->y)*0.5,(p03->z+p47->z)*0.5,coeffs, eexps); + _point *p4756 = _point::New ( (p47->x+p56->x)*0.5,(p47->y+p56->y)*0.5,(p47->z+p56->z)*0.5,coeffs, eexps); + _point *p0312 = _point::New ( (p03->x+p12->x)*0.5,(p03->y+p12->y)*0.5,(p03->z+p12->z)*0.5,coeffs, eexps); + + _point *pc = _point::New ( (p0->x+p1->x+p2->x+p3->x+p4->x+p5->x+p6->x+p7->x)*0.125, + (p0->y+p1->y+p2->y+p3->y+p4->y+p5->y+p6->y+p7->y)*0.125, + (p0->z+p1->z+p2->z+p3->z+p4->z+p5->z+p6->z+p7->z)*0.125, + coeffs, eexps); + + _hex *h1 = new _hex (p0,p01,p0312,p03,p04,p0145,pc,p0347);//p0 + Recur_Create (h1, maxlevel,level,coeffs,eexps); + _hex *h2 = new _hex (p01,p0145,p15,p1,p0312,pc,p1256,p12);//p1 + Recur_Create (h2, maxlevel,level,coeffs,eexps); + _hex *h3 = new _hex (p04,p4,p45,p0145,p0347,p47,p4756,pc);//p4 + Recur_Create (h3, maxlevel,level,coeffs,eexps); + _hex *h4 = new _hex (p0145,p45,p5,p15,pc,p4756,p56,p1256);//p5 + Recur_Create (h4, maxlevel,level,coeffs,eexps); + _hex *h5 = new _hex (p0347,p47,p4756,pc,p37,p7,p67,p2367);//p7 + Recur_Create (h4, maxlevel,level,coeffs,eexps); + _hex *h6 = new _hex (pc,p4756,p56,p1256,p2367,p67,p6,p26);//p6 + Recur_Create (h6, maxlevel,level,coeffs,eexps); + _hex *h7 = new _hex (p03,p0347,pc,p0312,p3,p37,p2367,p23);//p3 + Recur_Create (h7, maxlevel,level,coeffs,eexps); + _hex *h8 = new _hex (p0312,pc,p1256,p12,p23,p2367,p26,p2);//p2 + Recur_Create (h7, maxlevel,level,coeffs,eexps); + + h->h[0]=h1;h->h[1]=h2;h->h[2]=h3;h->h[3]=h4; + h->h[4]=h5;h->h[5]=h6;h->h[6]=h7;h->h[7]=h8; +} + + void _triangle::Error ( double AVG , double tol ) { _triangle *t = *all_triangles.begin(); @@ -267,6 +353,11 @@ void _tet::Error ( double AVG , double tol ) _tet *t = *all_tets.begin(); Recur_Error (t,AVG,tol); } +void _hex::Error ( double AVG , double tol ) +{ + _hex *h = *all_hexes.begin(); + Recur_Error (h,AVG,tol); +} void _triangle::Recur_Error ( _triangle *t, double AVG, double tol ) { @@ -446,6 +537,39 @@ void _tet::Recur_Error ( _tet *t, double AVG, double tol ) } } +void _hex::Recur_Error ( _hex *h, double AVG, double tol ) +{ + if(!h->h[0])h->visible = true; + else + { + double vr; + double v1 = h->h[0]->V(); + double v2 = h->h[1]->V(); + double v3 = h->h[2]->V(); + double v4 = h->h[3]->V(); + double v5 = h->h[4]->V(); + double v6 = h->h[5]->V(); + double v7 = h->h[6]->V(); + double v8 = h->h[7]->V(); + vr = (v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8)*.125; + double v = h->V(); + if ( fabs(v - vr) > AVG * tol ) + { + h->visible = false; + Recur_Error (h->h[0],AVG,tol); + Recur_Error (h->h[1],AVG,tol); + Recur_Error (h->h[2],AVG,tol); + Recur_Error (h->h[3],AVG,tol); + Recur_Error (h->h[4],AVG,tol); + Recur_Error (h->h[5],AVG,tol); + Recur_Error (h->h[6],AVG,tol); + Recur_Error (h->h[7],AVG,tol); + } + else + h->visible = true; + } +} + static double t0,t1,t2,t3; void Adaptive_Post_View:: zoomTriangle (Post_View * view , @@ -503,12 +627,14 @@ void Adaptive_Post_View:: zoomTriangle (Post_View * view , } - if (plug) - plug->assign_specific_visibility (); - else - { + if (!plug || tol != 0.0) + { _triangle::Error ( max-min, tol ); - } + } + if (plug) + plug->assign_specific_visibility (); + + double c3 = Cpu(); itt = _triangle::all_triangles.begin(); for ( ;itt != itte ; itt++) @@ -594,15 +720,15 @@ void Adaptive_Post_View:: zoomQuad (Post_View * view , for ( ;itt != itte ; itt++) { (*itt)->visible = false; - } - + } - if (plug) - plug->assign_specific_visibility (); - else + if (!plug || tol != 0.0) { _quad::Error ( max-min, tol ); } + if (plug) + plug->assign_specific_visibility (); + double c3 = Cpu(); itt = _quad::all_quads.begin(); for ( ;itt != itte ; itt++) @@ -704,12 +830,13 @@ void Adaptive_Post_View:: zoomTet (Post_View * view , } - if (plug) - plug->assign_specific_visibility (); - else - { + if (!plug || tol != 0.0) + { _tet::Error ( max-min, tol ); - } + } + if (plug) + plug->assign_specific_visibility (); + double c3 = Cpu(); itt = _tet::all_tets.begin(); for ( ;itt != itte ; itt++) @@ -749,6 +876,132 @@ void Adaptive_Post_View:: zoomTet (Post_View * view , } +void Adaptive_Post_View:: zoomHex (Post_View * view , + int ielem , + int level, + GMSH_Post_Plugin *plug, + Double_Vector & va2l, + Double_Vector & re2s, + Double_Matrix & XY2Z) +{ + std::set<_point>::iterator it = _point::all_points.begin(); + std::set<_point>::iterator ite = _point::all_points.end(); + + double c0 = Cpu(); + + Double_Matrix xyz (8,3); + + for ( int k=0;k<8;++k) + { + xyz(k,0) = (*_STposX) ( ielem , k ); + xyz(k,1) = (*_STposY) ( ielem , k ); + xyz(k,2) = (*_STposZ) ( ielem , k ); + } + + const int N = _coefs->size1(); + Double_Vector val ( N ), res(_point::all_points.size()); + Double_Matrix XYZ (_point::all_points.size(),3); + + for ( int k=0;k<N;++k) + { + val(k) = (*_STval )( ielem , k ); + } + + _Interpolate->mult(val,res); + _Geometry->mult(xyz,XYZ); + + double c1 = Cpu(); + + int kk=0; + for ( ; it !=ite ; ++it) + { + _point *p = (_point*) &(*it); + p->val = res(kk); + p->X = XYZ(kk,0); + p->Y = XYZ(kk,1); + p->Z = XYZ(kk,2); + if (min > p->val) min = p->val; + if (max < p->val) max = p->val; + kk++; + } + + double c2 = Cpu(); + + std::list<_hex*>::iterator itt = _hex::all_hexes.begin(); + std::list<_hex*>::iterator itte = _hex::all_hexes.end(); + + for ( ;itt != itte ; itt++) + { + (*itt)->visible = false; + } + + + if (!plug || tol != 0.0) + { + _hex::Error ( max-min, tol ); + } + if (plug) + plug->assign_specific_visibility (); + + double c3 = Cpu(); + itt = _hex::all_hexes.begin(); + for ( ;itt != itte ; itt++) + { + if ((*itt)->visible) + { + _point *p1 = (*itt)->p[0]; + _point *p2 = (*itt)->p[1]; + _point *p3 = (*itt)->p[2]; + _point *p4 = (*itt)->p[3]; + _point *p5 = (*itt)->p[4]; + _point *p6 = (*itt)->p[5]; + _point *p7 = (*itt)->p[6]; + _point *p8 = (*itt)->p[7]; + List_Add ( view->SH , &p1->X ); + List_Add ( view->SH , &p2->X ); + List_Add ( view->SH , &p3->X ); + List_Add ( view->SH , &p4->X ); + List_Add ( view->SH , &p5->X ); + List_Add ( view->SH , &p6->X ); + List_Add ( view->SH , &p7->X ); + List_Add ( view->SH , &p8->X ); + List_Add ( view->SH , &p1->Y ); + List_Add ( view->SH , &p2->Y ); + List_Add ( view->SH , &p3->Y ); + List_Add ( view->SH , &p4->Y ); + List_Add ( view->SH , &p5->Y ); + List_Add ( view->SH , &p6->Y ); + List_Add ( view->SH , &p7->Y ); + List_Add ( view->SH , &p8->Y ); + List_Add ( view->SH , &p1->Z ); + List_Add ( view->SH , &p2->Z ); + List_Add ( view->SH , &p3->Z ); + List_Add ( view->SH , &p4->Z ); + List_Add ( view->SH , &p5->Z ); + List_Add ( view->SH , &p6->Z ); + List_Add ( view->SH , &p7->Z ); + List_Add ( view->SH , &p8->Z ); + List_Add ( view->SH , &p1->val ); + List_Add ( view->SH , &p2->val ); + List_Add ( view->SH , &p3->val ); + List_Add ( view->SH , &p4->val ); + List_Add ( view->SH , &p5->val ); + List_Add ( view->SH , &p6->val ); + List_Add ( view->SH , &p7->val ); + List_Add ( view->SH , &p8->val ); + view->NbSH++; + } + } + double c4 = Cpu(); + + t0 += c1-c0; + t1 += c2-c1; + t2 += c3-c2; + t3 += c4-c3; + +} + + void Adaptive_Post_View:: setAdaptiveResolutionLevel (Post_View * view , int level, GMSH_Post_Plugin *plug) { const int N = _coefs->size1(); @@ -847,6 +1100,59 @@ void Adaptive_Post_View:: setAdaptiveResolutionLevel (Post_View * view , int lev printf("finished B %g %g %g %g\n",t0,t1,t2,t3); } + + else if (view->NbSH) + { + _hex::Create ( level, _coefs, _eexps ); + std::set<_point>::iterator it = _point::all_points.begin(); + std::set<_point>::iterator ite = _point::all_points.end(); + + if (_Interpolate) + delete _Interpolate; + if (_Geometry) + delete _Geometry; + _Interpolate = new Double_Matrix ( _point::all_points.size(), N); + _Geometry = new Double_Matrix ( _point::all_points.size(), 8); + + int kk=0; + for ( ; it !=ite ; ++it) + { + _point *p = (_point*) &(*it); + for ( int k=0;k<N;++k) + { + (*_Interpolate)(kk,k) = p->shape_functions[k]; + } + (*_Geometry)(kk,0) = ( 1.-p->x) * ( 1.-p->y) * ( 1.-p->z) * .125; + (*_Geometry)(kk,1) = ( 1.+p->x) * ( 1.-p->y) * ( 1.-p->z) * .125; + (*_Geometry)(kk,2) = ( 1.+p->x) * ( 1.+p->y) * ( 1.-p->z) * .125; + (*_Geometry)(kk,3) = ( 1.-p->x) * ( 1.+p->y) * ( 1.-p->z) * .125; + (*_Geometry)(kk,4) = ( 1.-p->x) * ( 1.-p->y) * ( 1.+p->z) * .125; + (*_Geometry)(kk,5) = ( 1.+p->x) * ( 1.-p->y) * ( 1.+p->z) * .125; + (*_Geometry)(kk,6) = ( 1.+p->x) * ( 1.+p->y) * ( 1.+p->z) * .125; + (*_Geometry)(kk,7) = ( 1.-p->x) * ( 1.+p->y) * ( 1.+p->z) * .125; + kk++; + } + + List_Delete(view->SH); view->SH = 0; + view->NbSS = 0; + /// for now, that's all we do, 1 TS + view->NbTimeStep=1; + int nbelm = _STposX->size1(); + view->SS = List_Create ( nbelm * 4, nbelm , sizeof(double)); + + t0=t1 = t2 = t3 = 0; + + Double_Vector val ( N ), res(_point::all_points.size()); + Double_Matrix XYZ (_point::all_points.size(),3); + + for ( int i=0;i<nbelm;++i) + { + zoomHex ( view , i , level, plug,val,res,XYZ); + } + + printf("finished B %g %g %g %g\n",t0,t1,t2,t3); + } + else if (view->NbSQ) { _quad::Create ( level, _coefs, _eexps ); @@ -946,6 +1252,12 @@ void Adaptive_Post_View:: initWithLowResolution (Post_View *view) nbelm = view->NbSQ; nbnod = 4; } + else if (view->NbSH) + { + myList = view->SH; + nbelm = view->NbSH; + nbnod = 8; + } else return; min = VAL_INF; diff --git a/Common/Views.h b/Common/Views.h index 3edaa691dd..4917c70a64 100644 --- a/Common/Views.h +++ b/Common/Views.h @@ -160,6 +160,43 @@ public: static std::list<_tet*> all_tets; }; +class _hex +{ +public: + _hex (_point *p1,_point *p2,_point *p3,_point *p4,_point *p5,_point *p6,_point *p7,_point *p8) + : visible (false) + { + p[0] = p1; + p[1] = p2; + p[2] = p3; + p[3] = p4; + p[4] = p5; + p[5] = p6; + p[6] = p7; + p[7] = p8; + h[0]=h[1]=h[2]=h[3]=0; + h[4]=h[5]=h[6]=h[7]=0; + } + + inline double V () const + { + return (p[0]->val + p[1]->val + p[2]->val+ p[3]->val+p[4]->val + p[5]->val + p[6]->val+ p[7]->val)/8.; + } + void print () + { + printf ("p1 %g %g p2 %g %g p3 %g %g \n",p[0]->x,p[0]->y,p[1]->x,p[1]->y,p[2]->x,p[2]->y); + } + static void clean (); + static void Create (int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps) ; + static void Recur_Create (_hex *h, int maxlevel, int level , Double_Matrix *coeffs, Double_Matrix *eexps); + static void Error ( double AVG , double tol ); + static void Recur_Error ( _hex *h, double AVG, double tol ); + bool visible; + _point *p[8]; + _hex *h[8]; + static std::list<_hex*> all_hexes; +}; + class Adaptive_Post_View { @@ -196,6 +233,11 @@ public: Double_Vector & val, Double_Vector & res, Double_Matrix & XYZ); + void zoomHex (Post_View * view , + int ielem, int level, GMSH_Post_Plugin *plug, + Double_Vector & val, + Double_Vector & res, + Double_Matrix & XYZ); }; class Post_View{ diff --git a/Plugin/CutMap.cpp b/Plugin/CutMap.cpp index e9ddd21212..0328397a78 100644 --- a/Plugin/CutMap.cpp +++ b/Plugin/CutMap.cpp @@ -1,4 +1,4 @@ -// $Id: CutMap.cpp,v 1.42 2004-11-25 02:10:40 geuzaine Exp $ +// $Id: CutMap.cpp,v 1.43 2004-11-26 14:42:56 remacle Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -30,7 +30,8 @@ StringXNumber CutMapOptions_Number[] = { {GMSH_FULLRC, "dTimeStep", NULL, -1.}, {GMSH_FULLRC, "dView", NULL, -1.}, {GMSH_FULLRC, "iView", NULL, -1.}, - {GMSH_FULLRC, "recurLevel", NULL, 4} + {GMSH_FULLRC, "recurLevel", NULL, 4}, + {GMSH_FULLRC, "targetError", NULL, 0} }; extern "C" @@ -121,6 +122,7 @@ Post_View *GMSH_CutMapPlugin::execute(Post_View * v) _valueView = (int)CutMapOptions_Number[2].def; _valueTimeStep = (int)CutMapOptions_Number[1].def; _recurLevel = (int)CutMapOptions_Number[4].def; + _targetError = CutMapOptions_Number[5].def; _orientation = GMSH_LevelsetPlugin::MAP; if(iView < 0) diff --git a/Plugin/CutPlane.cpp b/Plugin/CutPlane.cpp index 8531890932..532af71537 100644 --- a/Plugin/CutPlane.cpp +++ b/Plugin/CutPlane.cpp @@ -1,4 +1,4 @@ -// $Id: CutPlane.cpp,v 1.38 2004-11-25 02:10:40 geuzaine Exp $ +// $Id: CutPlane.cpp,v 1.39 2004-11-26 14:42:56 remacle Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -38,7 +38,8 @@ StringXNumber CutPlaneOptions_Number[] = { {GMSH_FULLRC, "C", GMSH_CutPlanePlugin::callbackC, 0.}, {GMSH_FULLRC, "D", GMSH_CutPlanePlugin::callbackD, -0.01}, {GMSH_FULLRC, "iView", NULL, -1.}, - {GMSH_FULLRC, "recurLevel", NULL, 4} + {GMSH_FULLRC, "recurLevel", NULL, 4}, + {GMSH_FULLRC, "targetError", NULL, 0} }; extern "C" @@ -93,10 +94,10 @@ double GMSH_CutPlanePlugin::callbackA(int num, int action, double value) { if(action > 0) iview = num; switch(action){ // configure the input field - case 1: return 0.01; - case 2: return -1.; - case 3: return 1.; - default: break; + case 1: return 0.01; + case 2: return -1; + case 3: return 1; + default: break; } CutPlaneOptions_Number[0].def = value; callback(); @@ -197,16 +198,17 @@ Post_View *GMSH_CutPlanePlugin::execute(Post_View * v) _valueTimeStep = -1; _orientation = GMSH_LevelsetPlugin::PLANE; _recurLevel = (int)CutPlaneOptions_Number[5].def; - + _targetError = CutPlaneOptions_Number[6].def; + if(iView < 0) - iView = v ? v->Index : 0; - + iView = v ? v->Index : 0; + if(!List_Pointer_Test(CTX.post.list, iView)) { - Msg(GERROR, "View[%d] does not exist", iView); - return v; + Msg(GERROR, "View[%d] does not exist", iView); + return v; } - + Post_View *v1 = *(Post_View **)List_Pointer(CTX.post.list, iView); - + return GMSH_LevelsetPlugin::execute(v1); } diff --git a/Plugin/Levelset.cpp b/Plugin/Levelset.cpp index 0a079c09fc..ecad0ae210 100644 --- a/Plugin/Levelset.cpp +++ b/Plugin/Levelset.cpp @@ -1,4 +1,4 @@ -// $Id: Levelset.cpp,v 1.19 2004-11-25 16:22:48 remacle Exp $ +// $Id: Levelset.cpp,v 1.20 2004-11-26 14:42:56 remacle Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -39,6 +39,7 @@ GMSH_LevelsetPlugin::GMSH_LevelsetPlugin() _valueView = -1; // use same view for levelset and field data _valueTimeStep = -1; // use same time step in levelset and field data views _recurLevel = 4; + _targetError = 0; _orientation = GMSH_LevelsetPlugin::NONE; } @@ -339,13 +340,17 @@ Post_View *GMSH_LevelsetPlugin::execute(Post_View * v) Post_View *w; vector<Post_View *> out; + if(v->adaptive) + v->adaptive->setTolerance(_targetError); if (v->adaptive && v->NbST) - v->setAdaptiveResolutionLevel ( _recurLevel , this ); + v->setAdaptiveResolutionLevel ( _recurLevel , this ); if (v->adaptive && v->NbSS) - v->setAdaptiveResolutionLevel ( _recurLevel , this ); + v->setAdaptiveResolutionLevel ( _recurLevel , this ); if (v->adaptive && v->NbSQ) - v->setAdaptiveResolutionLevel ( _recurLevel , this ); - + v->setAdaptiveResolutionLevel ( _recurLevel , this ); + if (v->adaptive && v->NbSH) + v->setAdaptiveResolutionLevel ( _recurLevel , this ); + if(_valueView < 0) { w = v; @@ -626,7 +631,7 @@ static bool recur_sign_change (_tet *t, double val, const GMSH_LevelsetPlugin *p static bool recur_sign_change (_quad *q, double val, const GMSH_LevelsetPlugin *plug) { - if (!q->q[0]) + if (!q->q[0]|| q->visible) { double v1 = plug->levelset (q->p[0]->X,q->p[0]->Y,q->p[0]->Z,q->p[0]->val); double v2 = plug->levelset (q->p[1]->X,q->p[1]->Y,q->p[1]->Z,q->p[1]->val); diff --git a/Plugin/Levelset.h b/Plugin/Levelset.h index 3e496954d8..7a88a39cf9 100644 --- a/Plugin/Levelset.h +++ b/Plugin/Levelset.h @@ -31,8 +31,8 @@ public: typedef enum {NONE, PLANE, SPHERE, MAP} ORIENTATION ; virtual double levelset(double x, double y, double z, double val) const = 0; protected: - double _ref[3]; - int _valueTimeStep, _valueView, _valueIndependent, _recurLevel; + double _ref[3], _targetError; + int _valueTimeStep, _valueView, _valueIndependent, _recurLevel; ORIENTATION _orientation; private: double _invert; -- GitLab