Skip to content
Snippets Groups Projects
Commit 9d6c372c authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

Generalized the LevelSet class for views with more than one time step.
parent 93362af6
No related branches found
No related tags found
No related merge requests found
// $Id: LevelsetPlugin.cpp,v 1.25 2002-11-05 19:52:06 geuzaine Exp $ // $Id: LevelsetPlugin.cpp,v 1.26 2003-01-20 23:30:32 geuzaine Exp $
// //
// Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle
// //
...@@ -51,30 +51,49 @@ void GMSH_LevelsetPlugin::Run () ...@@ -51,30 +51,49 @@ void GMSH_LevelsetPlugin::Run ()
Post_View *GMSH_LevelsetPlugin::execute (Post_View *v) Post_View *GMSH_LevelsetPlugin::execute (Post_View *v)
{ {
/* // This plugin creates a new view which is the result of a cut of
This plugin creates a new view which is the result of // the actual view with a levelset.
a cut of the actual view with a levelset.
*/ int nb, singleOutputView=1, edtet[6][2] = {{0,1},{0,2},{0,3},{1,2},{1,3},{2,3}};
int k,i,j,nb,edtet[6][2] = {{0,1},{0,2},{0,3},{1,2},{1,3},{2,3}};
double *X, *Y, *Z, *Vals, levels[6], coef; double *X, *Y, *Z, *Vals, levels[6], coef;
double Xp[6], Yp[6], Zp[6], myVals[6]; double Xp[6], Yp[6], Zp[6], myVals[6];
double Xpi[6], Ypi[6], Zpi[6], myValsi[6]; double Xpi[6], Ypi[6], Zpi[6], myValsi[6];
Post_View *View; double test;
Post_View *View[v->NbTimeStep];
// for all scalar tets
if(v->NbSS){ if(v->NbSS){
View = BeginView(1);
switch(_orientation){
case ORIENT_PLANE:
case ORIENT_SPHERE:
// We know the levelset is spatially "fixed", so we can create a
// single view for all time steps
singleOutputView = 1;
View[0] = BeginView(1);
break;
case ORIENT_MAP:
default:
// Each time step will give rise to a new view
singleOutputView = 0;
for(int ts=0 ; ts<v->NbTimeStep ; ts++)
View[ts] = BeginView(1);
break;
}
// for all scalar tets
nb = List_Nbr(v->SS) / v->NbSS ; nb = List_Nbr(v->SS) / v->NbSS ;
for(i=0 ; i<List_Nbr(v->SS) ; i+=nb){ for(int i=0 ; i<List_Nbr(v->SS) ; i+=nb){
X = (double*)List_Pointer_Fast(v->SS,i); X = (double*)List_Pointer_Fast(v->SS,i);
Y = (double*)List_Pointer_Fast(v->SS,i+4); Y = (double*)List_Pointer_Fast(v->SS,i+4);
Z = (double*)List_Pointer_Fast(v->SS,i+8); Z = (double*)List_Pointer_Fast(v->SS,i+8);
Vals = (double*)List_Pointer_Fast(v->SS,i+12);
for(j=0 ; j<4 ; j++) // for all time steps
for(int ts=0 ; ts<v->NbTimeStep ; ts++){
Vals = (double*)List_Pointer_Fast(v->SS,i+12+(4*ts));
for(int j=0 ; j<4 ; j++)
levels[j] = levelset(X[j],Y[j],Z[j],Vals[j]); levels[j] = levelset(X[j],Y[j],Z[j],Vals[j]);
int nx = 0; int nx = 0;
for(k=0 ; k<6 ; k++){ for(int k=0 ; k<6 ; k++){
if(levels[edtet[k][0]] * levels[edtet[k][1]] <= 0.0){ if(levels[edtet[k][0]] * levels[edtet[k][1]] <= 0.0){
coef = InterpolateIso(X,Y,Z,levels,0.0, coef = InterpolateIso(X,Y,Z,levels,0.0,
edtet[k][0],edtet[k][1], edtet[k][0],edtet[k][1],
...@@ -101,12 +120,13 @@ Post_View *GMSH_LevelsetPlugin::execute (Post_View *v) ...@@ -101,12 +120,13 @@ Post_View *GMSH_LevelsetPlugin::execute (Post_View *v)
} }
if(nx == 3 || nx == 4){ if(nx == 3 || nx == 4){
if(!ts || !singleOutputView){ // test this only once for "fixed" views
double v1[3] = {Xp[2]-Xp[0],Yp[2]-Yp[0],Zp[2]-Zp[0]}; double v1[3] = {Xp[2]-Xp[0],Yp[2]-Yp[0],Zp[2]-Zp[0]};
double v2[3] = {Xp[1]-Xp[0],Yp[1]-Yp[0],Zp[1]-Zp[0]}; double v2[3] = {Xp[1]-Xp[0],Yp[1]-Yp[0],Zp[1]-Zp[0]};
double gr[3]; double gr[3];
double n[3],test; double n[3];
prodve(v1,v2,n); prodve(v1,v2,n);
switch(_orientation){ switch(_orientation){
case ORIENT_MAP: case ORIENT_MAP:
gradSimplex(X,Y,Z,Vals,gr); gradSimplex(X,Y,Z,Vals,gr);
...@@ -125,15 +145,16 @@ Post_View *GMSH_LevelsetPlugin::execute (Post_View *v) ...@@ -125,15 +145,16 @@ Post_View *GMSH_LevelsetPlugin::execute (Post_View *v)
test = 0.; test = 0.;
break; break;
} }
}
if(test>0){ if(test>0){
for(k=0;k<nx;k++){ for(int k=0;k<nx;k++){
Xpi[k] = Xp[k]; Xpi[k] = Xp[k];
Ypi[k] = Yp[k]; Ypi[k] = Yp[k];
Zpi[k] = Zp[k]; Zpi[k] = Zp[k];
myValsi[k] = myVals[k]; myValsi[k] = myVals[k];
} }
for(k=0;k<nx;k++){ for(int k=0;k<nx;k++){
Xp[k] = Xpi[nx-k-1]; Xp[k] = Xpi[nx-k-1];
Yp[k] = Ypi[nx-k-1]; Yp[k] = Ypi[nx-k-1];
Zp[k] = Zpi[nx-k-1]; Zp[k] = Zpi[nx-k-1];
...@@ -141,30 +162,64 @@ Post_View *GMSH_LevelsetPlugin::execute (Post_View *v) ...@@ -141,30 +162,64 @@ Post_View *GMSH_LevelsetPlugin::execute (Post_View *v)
} }
} }
for(k=0 ; k<3 ; k++) List_Add(View->ST, &Xp[k]); if(singleOutputView){
for(k=0 ; k<3 ; k++) List_Add(View->ST, &Yp[k]); if(nx == 3){
for(k=0 ; k<3 ; k++) List_Add(View->ST, &Zp[k]); if(!ts){ // for the first time step only
for(k=0 ; k<3 ; k++) List_Add(View->ST, &myVals[k]); for(int k=0 ; k<3 ; k++) List_Add(View[0]->ST, &Xp[k]);
View->NbST++; for(int k=0 ; k<3 ; k++) List_Add(View[0]->ST, &Yp[k]);
for(int k=0 ; k<3 ; k++) List_Add(View[0]->ST, &Zp[k]);
View[0]->NbST++;
}
for(int k=0 ; k<3 ; k++) List_Add(View[0]->ST, &myVals[k]);
}
if(nx == 4){
if(!ts){ // for the first time step only
for(int k=0 ; k<4 ; k++) List_Add(View[0]->SQ, &Xp[k]);
for(int k=0 ; k<4 ; k++) List_Add(View[0]->SQ, &Yp[k]);
for(int k=0 ; k<4 ; k++) List_Add(View[0]->SQ, &Zp[k]);
View[0]->NbSQ++;
}
for(int k=0 ; k<4 ; k++) List_Add(View[0]->SQ, &myVals[k]);
}
}
else{
if(nx == 3){
for(int k=0 ; k<3 ; k++) List_Add(View[ts]->ST, &Xp[k]);
for(int k=0 ; k<3 ; k++) List_Add(View[ts]->ST, &Yp[k]);
for(int k=0 ; k<3 ; k++) List_Add(View[ts]->ST, &Zp[k]);
for(int k=0 ; k<3 ; k++) List_Add(View[ts]->ST, &myVals[k]);
View[ts]->NbST++;
}
if(nx == 4){ if(nx == 4){
for(k=2 ; k<5 ; k++) List_Add(View->ST, &Xp[k % 4]); for(int k=0 ; k<4 ; k++) List_Add(View[ts]->SQ, &Xp[k]);
for(k=2 ; k<5 ; k++) List_Add(View->ST, &Yp[k % 4]); for(int k=0 ; k<4 ; k++) List_Add(View[ts]->SQ, &Yp[k]);
for(k=2 ; k<5 ; k++) List_Add(View->ST, &Zp[k % 4]); for(int k=0 ; k<4 ; k++) List_Add(View[ts]->SQ, &Zp[k]);
for(k=2 ; k<5 ; k++) List_Add(View->ST, &myVals[k % 4]); for(int k=0 ; k<4 ; k++) List_Add(View[ts]->SQ, &myVals[k]);
View->NbST++; View[ts]->NbSQ++;
}
}
} }
} }
} }
char name[1024],filename[1024]; char name[1024],filename[1024];
if(singleOutputView){
sprintf(name,"cut-%s",v->Name); sprintf(name,"cut-%s",v->Name);
sprintf(filename,"cut-%s",v->FileName); sprintf(filename,"cut-%s",v->FileName);
EndView(View, 1, filename, name); EndView(View[0], 1, filename, name);
}
else{
for(int ts=0 ; ts<v->NbTimeStep ; ts++){
sprintf(name,"cut-%s-%d",v->Name, ts);
sprintf(filename,"cut-%s-%d",v->FileName, ts);
EndView(View[ts], 1, filename, name);
}
}
Msg(INFO, "Created view '%s' (%d triangles)", name, View->NbST); // a little bogus if multiple output views, but we don't use it anyway
processed = View; processed = View[0];
return View; return View[0];
} }
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment