[Paraview-developers] Filter Plugin

Frank TT frank.tt at einseinself.org
Thu Oct 2 08:22:26 EDT 2014


On 2014-09-29 14:37, Utkarsh Ayachit wrote:
> Frank,
> 
> ParaView is based on VTK, and relies on VTK to provide the execution
> model and data model. Thus, when writing you a new data processing
> filter, you're basically going to wrote a VTK filter. The ParaView
> plugin infrastructure comes into play to make such a VTK filter
> available/accessible in ParaView.
> 
> I'd suggesting starting with a existing VTK filter that closely
> matches what you're doing e.g. vtkMarchingCubes [1].
> 
> [1] http://www.vtk.org/doc/nightly/html/classvtkImageMarchingCubes.html

Thx, the plugin is working, in basic. I have a problem to update the iso 
surface, when the iso value was changed by user. vtkPolyData has no 
Update() function.
How can I do an update on outputData?

Greetings,

Frank




### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### 
###
//marchingCubes.cxx

#include <iostream>

#include "vtkObjectFactory.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkSmartPointer.h"
#include "vtkDemandDrivenPipeline.h"
#include "vtkImageData.h"
#include "vtkPolyData.h"

#include "marchingCubes.h"

vtkStandardNewMacro(marchingCubes);

//----------------------------------------------------------------------------
marchingCubes::marchingCubes()
{
     inputInfo = vtkSmartPointer< vtkInformation >::New();
     outputInfo = vtkSmartPointer< vtkInformation >::New();

     inputData = vtkSmartPointer< vtkImageData >::New();
     outputData = vtkSmartPointer< vtkPolyData >::New();

     marchingData = vtkSmartPointer< vtkImageMarchingCubes >::New();

     firstRun = true;// Will be true, while ::RequestData(…) was not 
running. (When 'Apply' was already not pressed.)
}

//----------------------------------------------------------------------------
marchingCubes::~marchingCubes()
{

}

//----------------------------------------------------------------------------
void marchingCubes::PrintSelf(ostream& os, vtkIndent indent)
{
   this->Superclass::PrintSelf(os,indent);
}

//----------------------------------------------------------------------------
int marchingCubes::RequestData( vtkInformation *vtkNotUsed(request),
                                         vtkInformationVector 
**inputVector,
                                         vtkInformationVector 
*outputVector)
{
     inputInfo = inputVector[0]->GetInformationObject(0);
     outputInfo = outputVector->GetInformationObject(0);

     inputData = vtkImageData::SafeDownCast( inputInfo->Get( 
vtkDataObject::DATA_OBJECT() ) );
     outputData = vtkPolyData::SafeDownCast( 
outputInfo->Get(vtkDataObject::DATA_OBJECT() ) );

     this->updateMarchingData();

     firstRun = false;

     return 1;
}

//----------------------------------------------------------------------------
// From application.
void marchingCubes::setIsoValue(double value)
{
     isoValue = value;
     this->updateMarchingData();
}

double marchingCubes::getIsoValue()
{
     return isoValue;
}

//----------------------------------------------------------------------------
void marchingCubes::updateMarchingData()
{
//TODO: Implement all iso surface(s) creation modes by 
vtkImageMarchingCubes.

     if(!firstRun)
     {
         marchingData->SetValue(0, this->getIsoValue());
         marchingData->Update();

         //outputData = NULL;
         //outputData->Delete();
         outputData->CopyStructure(marchingData->GetOutput(0));
     }else
     {
             marchingData->SetInputData(inputData);
             marchingData->SetValue(0, this->getIsoValue());
             marchingData->Update();

             
//outputData->SetPolys(marchingData->GetOutput()->GetPolys());// Does 
not work.
             outputData->CopyStructure(marchingData->GetOutput(0));
     }
}



More information about the Paraview-developers mailing list