[Paraview-developers] object not displaying in the paraview window
Chiranjib Sur
sur.chiranjib at gmail.com
Thu Apr 14 05:34:33 EDT 2016
Utkarsh and team,
Here I come again with a very similar question.
I am creating a object using a C++ class in ParaView. I have implemented
the RequestData function in the following way but I keep getting the error
message :
Input port 0 of algorithm MyClass(0x4961fc0) has 0 connections but is not
optional.
What is going wrong here?
Below is my implementation of RequestData
Thanks in advance,
Chiranjib
int MyClass::RequestData( vtkInformation* vtkNotUsed( request ),
vtkInformationVector** vtkNotUsed(
inputVector ),
vtkInformationVector* outputVector )
{
// get the info object
vtkInformation* outInfo = outputVector->GetInformationObject( 0 );
// get the output
vtkPolyData* output = vtkPolyData::SafeDownCast( outInfo->Get(
vtkDataObject::DATA_OBJECT()));
vtkSmartPointer<vtkPolyData> polydata =
vtkSmartPointer<vtkPolyData>::New();
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
points->SetDataType( VTK_DOUBLE ); // Set precision for the vtk points
// generate my polydata with points etc.
....
// at this stage polydata is generated
output->ShallowCopy(polydata);
output->Squeeze();
return 1;
}
On Mon, Apr 27, 2015 at 3:37 PM, Chiranjib Sur <sur.chiranjib at gmail.com>
wrote:
> Wow, This works like a magic !
>
> Thank you very much for the solution and sorry for my delay in updating
> about the problem I mentioned.
>
> Chiranjib
>
> On Fri, Apr 17, 2015 at 5:54 PM, Utkarsh Ayachit <
> utkarsh.ayachit at kitware.com> wrote:
>
>> You're missing a call to `transformModel->Update()` before calling
>> `transformModel->GetOutput()`. The filter never updated, and hence its
>> output is empty.
>>
>> Utkarsh
>>
>> On Fri, Apr 17, 2015 at 6:34 AM, Chiranjib Sur <sur.chiranjib at gmail.com>
>> wrote:
>> > Hi All,
>> > I want to apply the tranform filter while I create an object in
>> paraview. TO
>> > try with I have overloaded vtkCubeSource class and can create the object
>> > which appears in the paraview pipeline and I can visualize the object
>> in the
>> > PV window.
>> >
>> > Now I want to apply the transformation filter (vtkTransform) to the
>> objct
>> > when I create it. To do that I have overloaded the RequestData function
>> like
>> > the following.
>> >
>> > The code is compiling and executing but when I create the object and
>> apply
>> > transform, nothing is appearing in the PV visualization window.
>> >
>> > Can anybody help me pointing out what is going wrong with my
>> implementation.
>> >
>> > I cam copying my code below
>> >
>> > Thanks,
>> > Chiranjib
>> >
>> >
>> > ------
>> >
>> >
>> >
>> > int MyOwnCubeSource::RequestData( vtkInformation *vtkNotUsed(request),
>> >
>> > vtkInformationVector **vtkNotUsed(inputVector),
>> >
>> > vtkInformationVector *outputVector)
>> >
>> > {
>> >
>> > // get the info object
>> >
>> > vtkInformation *outInfo = outputVector->GetInformationObject(0);
>> >
>> >
>> >
>> > // get the ouptut
>> >
>> > vtkPolyData *output = vtkPolyData::SafeDownCast(
>> >
>> > outInfo->Get(vtkDataObject::DATA_OBJECT()));
>> >
>> > ....
>> >
>> > ....
>> >
>> >
>> >
>> > // output (type vtkPolyData) is already ready at this stage
>> >
>> >
>> >
>> > // If I don’t appy transform operation afterwards, I can visualize the
>> > object in the PV pipeline
>> >
>> >
>> >
>> >
>> >
>> > // -----------------------------------------------//
>> >
>> >
>> >
>> > // Implementation of vtkTransform starts here
>> >
>> >
>> >
>> > double _rotationZ = 30.0;
>> >
>> >
>> >
>> > // Define transform
>> >
>> > vtkSmartPointer<vtkTransform> transform =
>> > vtkSmartPointer<vtkTransform>::New();
>> >
>> >
>> >
>> > // Define transformModel : transform filter
>> >
>> > vtkSmartPointer<vtkTransformFilter> transformModel =
>> > vtkSmartPointer<vtkTransformFilter>::New();
>> >
>> > transformModel->SetTransform(transform);
>> >
>> >
>> >
>> > //Decoupling the pipeline and asking the transformfilter to update
>> the
>> > newpipeline (created out of shallowcopy)
>> >
>> > vtkNew<vtkPolyData> cubeCopy;
>> >
>> > cubeCopy->ShallowCopy(output);
>> >
>> > transformModel->SetInputData(cubeCopy.GetPointer());
>> >
>> >
>> >
>> > // Describe all the transform operations
>> >
>> > transform->PostMultiply();
>> >
>> > transform->RotateZ(10*_rotationZ);
>> >
>> > transform->Update();
>> >
>> >
>> >
>> > // getting the transformed output
>> >
>> > vtkSmartPointer<vtkDataSet> transformedOutput =
>> > transformModel->GetOutput();
>> >
>> >
>> >
>> > // Shallowcopy the transformed output to the old pipeline
>> >
>> >
>> >
>> > output->ShallowCopy(transformedOutput);
>> >
>> >
>> >
>> > // A this stage "output" should be updated and the visualization
>> pipeline
>> > should show the transformed object
>> >
>> >
>> > _______________________________________________
>> > Powered by www.kitware.com
>> >
>> > Visit other Kitware open-source projects at
>> > http://www.kitware.com/opensource/opensource.html
>> >
>> > Search the list archives at:
>> > http://markmail.org/search/?q=Paraview-developers
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > http://public.kitware.com/mailman/listinfo/paraview-developers
>> >
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20160414/452a8f7b/attachment.html>
More information about the Paraview-developers
mailing list