[Paraview] StructuredGrid Source

owen.arnold at stfc.ac.uk owen.arnold at stfc.ac.uk
Tue Jul 20 11:02:14 EDT 2010


Hi,

 

I am attempting to create a data source based on a
vtkStructuredGridAlgorithm.  Eventually I would like to represent the
grid in a hexahedron format
http://vtk.1045678.n5.nabble.com/Creating-a-structured-grid-of-250x250-c
ells-is-causing-MS-runtime-to-throw-an-exception-td1250336.html. While I
have been able to get this example running in vtk using the python API,
my Paraview plugin source does not work. 

 

I have the same problem attempting to write a plugin source using a
simpler example from the vtk guide:
http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/Examples/DataMa
nipulation/Cxx/SGrid.cxx?root=VTK&content-type=text/plain. According to
the information tab in Paraview, I have zero points and zero cells,
although debugging the datasource shows that for my vtkStructuredGrid
output, the points and cells have been created.

 

Can anyone spot what I might be doing, and suggest how I might fix the
problem (see below).

 

Thanks in advance,

 

Owen

 

int vtkStructuredHexahedronSource::RequestData(vtkInformation *request,
vtkInformationVector **inputVector, vtkInformationVector *outputVector)

{

      vtkInformation *outInfo = outputVector->GetInformationObject(0);

      vtkStructuredGrid *output =
vtkStructuredGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT(
)));

 

      int i, j, k, kOffset, jOffset, offset;

      float x[3], v[3], rMin=0.5, rMax=1.0, deltaRad, deltaZ;

      float radius, theta;

      static int dims[3]={13,11,11};

 

      // Create the structured grid.

 

      output->SetDimensions(dims);

 

      // We also create the points and vectors. The points

      // form a hemi-cylinder of data.

      vtkFloatArray *vectors = vtkFloatArray::New();

      vectors->SetNumberOfComponents(3);

      vectors->SetNumberOfTuples(dims[0]*dims[1]*dims[2]);

      vtkPoints *points = vtkPoints::New();

      points->Allocate(dims[0]*dims[1]*dims[2]);

 

      deltaZ = 2.0 / (dims[2]-1);

      deltaRad = (rMax-rMin) / (dims[1]-1);

      v[2]=0.0;

      for ( k=0; k<dims[2]; k++)

      {

            x[2] = -1.0 + k*deltaZ;

            kOffset = k * dims[0] * dims[1];

            for (j=0; j<dims[1]; j++) 

            {

                  radius = rMin + j*deltaRad;

                  jOffset = j * dims[0];

                  for (i=0; i<dims[0]; i++) 

                  {

                        theta = i * vtkMath::RadiansFromDegrees(15.0);

                        x[0] = radius * cos(theta);

                        x[1] = radius * sin(theta);

                        v[0] = -x[1];

                        v[1] = x[0];

                        offset = i + jOffset + kOffset;

                        points->InsertPoint(offset,x);

                        vectors->InsertTuple(offset,v);

                  }

            }

      }

      output->SetPoints(points);

      points->Delete();

      output->GetPointData()->SetVectors(vectors);

      vectors->Delete();

      return 1;

}


-- 
Scanned by iCritical.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20100720/0885de47/attachment-0001.htm>


More information about the ParaView mailing list