[vtkusers] Structure grid visualization inside paraview

Слава Решетников skemobob at gmail.com
Mon Sep 3 04:21:05 EDT 2018


Hello,everyone!
Can someone help me with this problem.
I'm doing a plugin for paraview which read data from array.
I'm trying to use structured grid.Paraview read data right but didn't
visualize anything.
[image: props.png]

The code looks like this:

vtkInformation *outInfo = outputVector->GetInformationObject(0);
vtkStructuredGrid *output = vtkStructuredGrid::SafeDownCast(
        outInfo->Get(vtkDataObject::DATA_OBJECT()));
 vtkStructuredGrid *output = vtkStructuredGrid::SafeDownCast(
        outInfo->Get(vtkDataObject::DATA_OBJECT()));


    double x[3];
    vtkPoints *newPoints;
    vtkCellArray *newVerts;

    newPoints = vtkPoints::New();

    // Set the desired precision for the points in the output.
    if(this->OutputPointsPrecision == vtkAlgorithm::DOUBLE_PRECISION)
    {
      newPoints->SetDataType(VTK_DOUBLE);
    }
    else
    {
      newPoints->SetDataType(VTK_FLOAT);
    }

    vtkSmartPointer<vtkPoints> points =
      vtkSmartPointer<vtkPoints>::New();
    this->NumberOfPoints =firstzone[0]->data.at(0).array.size();

    newPoints->Allocate(NumberOfPoints);
    newVerts = vtkCellArray::New();
    newVerts->Allocate(newVerts->EstimateSize(1,NumberOfPoints));

    newVerts->InsertNextCell(NumberOfPoints);

    if (this->Distribution == VTK_POINT_UNIFORM )
    {  // only produce points on the surface of the sphere
      for (unsigned int i=0; i<NumberOfPoints; ++i)
      {

        x[0] = firstzone[0]->data.at(0).array.at(i);
        x[1] = firstzone[0]->data.at(1).array.at(i);
        x[2] = firstzone[0]->data.at(2).array.at(i);
        newVerts->InsertCellPoint(newPoints->InsertNextPoint(x));
      }
    }
    else
    { // uniform distribution throughout the sphere volume
      for (unsigned int i=0; i<this->NumberOfPoints;++i )
      {

          x[0] = firstzone[0]->data.at(0).array.at(i);
          x[1] = firstzone[0]->data.at(1).array.at(i);
          x[2] = firstzone[0]->data.at(2).array.at(i);
        newVerts->InsertCellPoint(newPoints->InsertNextPoint(x));
      }
    }
    //Get uniqe number of points
    std::set<double> uX;
    std::set<double> uY;
    std::set<double> uZ;
    for(size_t i=0;i<firstzone[0]->data.at(0).array.size();++i){
        uX.insert(firstzone[0]->data.at(0).array.at(i));
    }
    for(size_t i=0;i<firstzone[0]->data.at(1).array.size();++i){
        uY.insert(firstzone[0]->data.at(1).array.at(i));
    }
    for(size_t i=0;i<firstzone[0]->data.at(2).array.size();++i){
        uZ.insert(firstzone[0]->data.at(2).array.at(i));
    }
    std::cout<<endl<<uX.size()<<" "<<uY.size()<<" "<<uZ.size()<<std::endl;

    output->SetDimensions(uZ.size(),uY.size(),uX.size());
    std::cout<<"Dimensions set"<<std::endl;
    output->SetPoints(newPoints);
    std::cout<<"Points set"<<std::endl;

    newPoints->Delete();
    newVerts->Delete();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180903/18b5d129/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: props.png
Type: image/png
Size: 29429 bytes
Desc: not available
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180903/18b5d129/attachment.png>


More information about the vtkusers mailing list