[vtkusers] help with contouring selected cells using vtkContourFilter

Subha smahaade at essence.utsi.edu
Fri Apr 18 15:44:27 EDT 2003


Hi,
I want to contour a huge structured grid. I wanted to speed up the 
contouring in vtkContourFilter. I already know the cells that I want to 
contour. They are sporadic and distributed all over the structured grid. 

So I supplied an additional data member, a vtkIdList, to the vtkContourFilter 
class that helps to check whether a cell in the grid needs to be contoured or 
not. Each number contained in the vtkIdList is either a 1 or 0 depending on 
whether the corresponding cell in the structured grid is a cell that needs to 
be contoured or not. (if out of 10 cells cells 0,1,5,7 are the only cells 
that need to be contoured then the vtkIdList will contain the numbers 
1,1,0,0,0,1,0,1,0,0 ).


class VTK_EXPORT vtkContourFilter : public vtkDataSetToPolyDataFilter
{
public:
 ......
	vtkIdList *cList;
.......
}

void vtkContourFilter::SetIdList(vtkIdList *celList)
{
	this->cList = celList;
// for use in the Execute function later
}

void vtkContourFilter::Execute()
{
.........
      for (int j=0; j < numCells && !abortExecute&& this->cList->GetId(j)
==1 ; j++)
      {
/*** cell selection in the for loop condition          *********/
      
          for (i=0; i < numContours; i++)
          {	
           cell->Contour(values[i], cellScalars, this->Locator, 
                        newVerts, newLines, newPolys, inPd, outPd,
                        inCd, cellId, outCd);

          
          } // for all contour values
        } // for all cells
      } //if using scalar tree

I thought that this would speed up the contouring process. Instead it 
slows it down. The result is 2 TIMES slower than contouring all the cells in 
the entire grid. (even though I am contouring only half the number of cells 
in the entire grid).

I am unable to understand the cause for this. 
Does anyone know what is going wrong here ? 
Does anyone know a better way to contour selected cells using ContourFilter ? 

I have been stuck at this for a long time. 
Any help is greatly appreciated.

Thanks,
S.




More information about the vtkusers mailing list