From 06b22738236b77f22bcd6bdbed1fab0152c32276 Mon Sep 17 00:00:00 2001 From: goodale Date: Mon, 17 May 2004 12:28:58 +0000 Subject: Untabified. Please try to adhere to the Cactus coding guidelines when modifying or adding files. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IsoSurfacer/trunk@79 bfcf8e34-485d-4d46-a995-1fd6fa6fb178 --- src/IsoSurfacerInit.c | 6 +-- src/NuSurfacer.c | 126 +++++++++++++++++++++++++------------------------- 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/IsoSurfacerInit.c b/src/IsoSurfacerInit.c index ee48974..6fbe675 100644 --- a/src/IsoSurfacerInit.c +++ b/src/IsoSurfacerInit.c @@ -2,7 +2,7 @@ #include #include -#ifndef _WIN32 +#ifndef _WIN32 #include #include #endif @@ -23,8 +23,8 @@ static int IsoSurfacer_ParseIsoString(const char *isostring,isosurfacerGH *myGH) /***************************************************************/ void *IsoSurfacer_SetupGH (tFleshConfig *config, - int convergence_level, - cGH *GH){ + int convergence_level, + cGH *GH){ isosurfacerGH *myGH=(isosurfacerGH*)malloc(sizeof(isosurfacerGH)); /* initialize values */ diff --git a/src/NuSurfacer.c b/src/NuSurfacer.c index d8377f1..756423e 100644 --- a/src/NuSurfacer.c +++ b/src/NuSurfacer.c @@ -282,15 +282,15 @@ static TRIANGLE_CASES triCases[] = { #define ResetArray(lst) lst->nelem=0 #define ArraySize(lst) (lst->nelem) #define ArrayAddElem(typ,lst,val) { if(lst->maxelem<=lst->nelem) \ - GrowArray(typ,lst); \ - lst->array[lst->nelem]=val; \ - lst->nelem++;} + GrowArray(typ,lst); \ + lst->array[lst->nelem]=val; \ + lst->nelem++;} #define ArrayAddNumElem(typ,lst,vals,nvals) { \ - if(lst->maxelem<=(lst->nelem+nvals)) \ - GrowArray(typ,lst); \ - for(nvals+=lst->nelem;lst->nelemnelem++) \ - lst->array[lst->nelem] = vals[lst->nelem]; } + if(lst->maxelem<=(lst->nelem+nvals)) \ + GrowArray(typ,lst); \ + for(nvals+=lst->nelem;lst->nelemnelem++) \ + lst->array[lst->nelem] = vals[lst->nelem]; } #define ComputePoints(xcoords,ycoords,zcoords,pindex,p1,p2,xl,yl) { \ int pointindex=pindex[0]; \ @@ -312,16 +312,16 @@ p2[1]=(CCTK_REAL)ycoords[_idx];\ p2[2]=(CCTK_REAL)zcoords[_idx];} #define SetEdgeMaskP(idx_,data_,value_,mask_) { \ - register int _cmask=1; \ - mask_=0; \ + register int _cmask=1; \ + mask_=0; \ if(data_[idx_+cellOffset[0]]>=value_) mask_|=_cmask; _cmask<<=1; \ - if(data_[idx_+cellOffset[1]]>=value_) mask_|=_cmask; _cmask<<=1; \ - if(data_[idx_+cellOffset[2]]>=value_) mask_|=_cmask; _cmask<<=1; \ - if(data_[idx_+cellOffset[3]]>=value_) mask_|=_cmask; _cmask<<=1; \ - if(data_[idx_+cellOffset[4]]>=value_) mask_|=_cmask; _cmask<<=1; \ - if(data_[idx_+cellOffset[5]]>=value_) mask_|=_cmask; _cmask<<=1; \ - if(data_[idx_+cellOffset[6]]>=value_) mask_|=_cmask; _cmask<<=1; \ - if(data_[idx_+cellOffset[7]]>=value_) mask_|=_cmask; \ + if(data_[idx_+cellOffset[1]]>=value_) mask_|=_cmask; _cmask<<=1; \ + if(data_[idx_+cellOffset[2]]>=value_) mask_|=_cmask; _cmask<<=1; \ + if(data_[idx_+cellOffset[3]]>=value_) mask_|=_cmask; _cmask<<=1; \ + if(data_[idx_+cellOffset[4]]>=value_) mask_|=_cmask; _cmask<<=1; \ + if(data_[idx_+cellOffset[5]]>=value_) mask_|=_cmask; _cmask<<=1; \ + if(data_[idx_+cellOffset[6]]>=value_) mask_|=_cmask; _cmask<<=1; \ + if(data_[idx_+cellOffset[7]]>=value_) mask_|=_cmask; \ } /* @@ -403,25 +403,25 @@ static int yMapOffset[8]={0,0,1,1,0,0,1,1}; static int zMapOffset[8]={0,0,0,0,1,1,1,1}; static int cellOffset[8]={0,0,0,0,0,0,0,0}; /* cell Offsets should be initialized to - 0 = 0 - 1 = 1 - 2 = 1 + GH->cctk_lsh [0] - 3 = GH->cctk_lsh [0] - 4 = GH->cctk_lsh [0]*GH->cctk_lsh [1] - 5 = 1 + GH->cctk_lsh [0]*GH->cctk_lsh [1] - 6 = 1+ GH->cctk_lsh [0] + GH->cctk_lsh [0]*GH->cctk_lsh [1] - 7 = GH->cctk_lsh [0] + GH->cctk_lsh [0]*GH->cctk_lsh [1] - */ + 0 = 0 + 1 = 1 + 2 = 1 + GH->cctk_lsh [0] + 3 = GH->cctk_lsh [0] + 4 = GH->cctk_lsh [0]*GH->cctk_lsh [1] + 5 = 1 + GH->cctk_lsh [0]*GH->cctk_lsh [1] + 6 = 1+ GH->cctk_lsh [0] + GH->cctk_lsh [0]*GH->cctk_lsh [1] + 7 = GH->cctk_lsh [0] + GH->cctk_lsh [0]*GH->cctk_lsh [1] + */ void InitCellArrays(int nx,int ny); static int isoCellOffset[12]={0,0,0,0, /* -zy,-z,-z,-zx, */ - 0,0,0,0, /* -y,0,0,-x, */ - 0,0,0,0};/* -yx,-y,-x,0 */ + 0,0,0,0, /* -y,0,0,-x, */ + 0,0,0,0};/* -yx,-y,-x,0 */ static int isoCellVindex[12]={1,0,1,0, - 1,0,1,0, - 2,2,2,2}; + 1,0,1,0, + 2,2,2,2}; /* cell vector orientation? */ - + void InitCellArrays(int nx,int ny){ int i,j; int ix=1,iy=nx,iz=nx*ny; @@ -450,9 +450,9 @@ void InitCellArrays(int nx,int ny){ } void NuFindSurface(CCTK_REAL *data, - int nx,int ny,int nz, - CCTK_REAL *xcoords, CCTK_REAL *ycoords, CCTK_REAL *zcoords, - CCTK_REAL isovalue, int compute_normals, polypatch *results){ + int nx,int ny,int nz, + CCTK_REAL *xcoords, CCTK_REAL *ycoords, CCTK_REAL *zcoords, + CCTK_REAL isovalue, int compute_normals, polypatch *results){ static int initialized_nusurf=0; TRIANGLE_CASES *triCase; EDGE_LIST *edge; @@ -489,35 +489,35 @@ void NuFindSurface(CCTK_REAL *data, for(j=0,jmax=ny-1;jedges,ii=0;edge[ii]>=0;ii++){ - edgenumber = edge[ii]; - /* map to a new isocelloffset based on edge - full 3d offsets into cell array based on edge pair */ - isocellnum = (isocellidx +isoCellOffset[edgenumber] + slicemodulo)%slicemodulo; - /* for 12 edges maps to neg offsets - just a 3 element offset based on edge pair */ - isocellvindex = isoCellVindex[edgenumber]; /* 12 maps to 3 */ - elemp = &(cellslice[isocellnum].v[isocellvindex]); - elem=*elemp; - if(elem<0){ /* add that vertex */ - elem=*elemp=nverts; - ComputePoints(xcoords,ycoords,zcoords, edges[edgenumber],p1,p2,nx,slicesize); - AddInterpolatedVertex(isovalue,idx,edges[edgenumber],p1,p2,vertexlist); - if(compute_normals) - AddGradientNormal(isovalue,idx,edges[edgenumber],p1,p2,normallist); - nverts++; - } - ArrayAddElem(CCTK_INT4,trianglelist,elem); /* this is just one vertex! */ - } + idx=i+joff; + isocellidx=idx%slicemodulo; + /* Here we clear the cellslice (vertex mapping) array for current cell */ + cellslice[isocellidx].v[0]=cellslice[isocellidx].v[1]=cellslice[isocellidx].v[2]=-1; + SetEdgeMaskP(idx,data,isovalue,mask); + if ( mask == 0 || mask == 255 ) continue; /* no surface */ + triCase = triCases + mask; + /* Only 3 edges (must scan for them) and set the values + So this is adding the verts as well as storing. */ + for(edge=triCase->edges,ii=0;edge[ii]>=0;ii++){ + edgenumber = edge[ii]; + /* map to a new isocelloffset based on edge + full 3d offsets into cell array based on edge pair */ + isocellnum = (isocellidx +isoCellOffset[edgenumber] + slicemodulo)%slicemodulo; + /* for 12 edges maps to neg offsets + just a 3 element offset based on edge pair */ + isocellvindex = isoCellVindex[edgenumber]; /* 12 maps to 3 */ + elemp = &(cellslice[isocellnum].v[isocellvindex]); + elem=*elemp; + if(elem<0){ /* add that vertex */ + elem=*elemp=nverts; + ComputePoints(xcoords,ycoords,zcoords, edges[edgenumber],p1,p2,nx,slicesize); + AddInterpolatedVertex(isovalue,idx,edges[edgenumber],p1,p2,vertexlist); + if(compute_normals) + AddGradientNormal(isovalue,idx,edges[edgenumber],p1,p2,normallist); + nverts++; + } + ArrayAddElem(CCTK_INT4,trianglelist,elem); /* this is just one vertex! */ + } } } } @@ -533,5 +533,5 @@ void NuFindSurface(CCTK_REAL *data, results->nnorms=0; results->norms=NULL; } -} +} -- cgit v1.2.3