[vtkusers] Help porting to vtk 4

stefano perticoni perticoni at tecno.ior.it
Tue Mar 19 04:59:40 EST 2002


Could you please give me some hints on porting this code fragment (vtk 
3.3) to vtk  4.

Regards,
Stefano

//...........................................................................................................................

               
                vtkScalars *oldScalars= input->GetCellData()->GetScalars();
                vtkScalars *newScalars = vtkScalars::New();


          if (this->GenerateScalars)
    {

                  if (oldScalars)
                  {
                          newScalars->DeepCopy(oldScalars);
                  }
                  else
                  {
                          newScalars->SetDataTypeToUnsignedChar();
                          
newScalars->SetNumberOfScalars(input->GetPolys()->GetNumberOfCells());
                          for (int 
i=0;i<newScalars->GetNumberOfScalars();i++)
                                  newScalars->SetScalar(i,this->OutValue);
                  }

                 

                  // Verify which cells collide
                  //...
                  for (int j=0;j<this->NumberOfPairs;j++)
                  {
                          // If one of the objects colliding is our 
object, set
                          // the scalars corresponding to the hitting 
trinagles
                          if (Report.obj1ID(j)==Id)
                          {
                                  for ( int k = 0; k < 
Report.numTriPairs(j); k++ )
                                  {
                                          
newScalars->SetScalar(Report.tri1ID(j, k), this->Value);
                                  }
                          }
                          if (Report.obj2ID(j)==Id)
                          {
                                  for ( int k = 0; k < 
Report.numTriPairs(j); k++ )
                                  {
                                          
newScalars->SetScalar(Report.tri2ID(j, k), this->Value);
                                  }
                          }

                  }

      this->GetOutput()->GetCellData()->CopyScalarsOff();
    }

                // Update self
                //
                
this->GetOutput()->GetPointData()->PassData(input->GetPointData());
                
this->GetOutput()->GetCellData()->PassData(input->GetCellData());


    if (this->GenerateScalars)
    {
                output->GetCellData()->SetScalars(newScalars);
                newScalars->Delete();
    }
        }
}

//.........................................................................................................




More information about the vtkusers mailing list