Dear Utkarsh,
Finally, after visiting the paraview workshop in Lyon, I got my own paraview
plugin based on c++ for this old task to compile and link. However, already when
loading it as a module in paraview, paraview crashes with a symbol lookup error:
/opt/paraview-4.1.0_debug/bin/paraview
/opt/paraview-4.1.0_debug/lib/paraview-4.1/paraview: symbol lookup error:
/net/home/grothama/vtk/paraview_plugins/image-clipper/build/libmyImageClipper.so: undefined
symbol: _Z19myImageClipper_InitP26vtkClientServerInterpreter
What could be the problem for this? How can I debug this problem?
I tried to combine things from
ParaViewCore/VTKExtensions/Default/vtkPVMetaSliceDataSet.cxx and from Your XML
to use a vtkImplicitFunction as an input to a filter. I had to copy
cp ParaView-v4.1.0/VTK/Imaging/Stencil/*.h
ParaView-v4.1.0/build_141124/VTK/Imaging/Stencil/
and to add
CMAKE_CXX_FLAGS -I ParaView-v4.1.0/build_141124/VTK/Imaging/Stencil/
for vtkImplicitFunctionToImageStencil.h to be found by cmake. However, the error
does not seem to be caused by the stencil stuff. Attached are the files.
Thanks for any help or hints
Roman
On 26/08/13 15:06, Utkarsh Ayachit wrote:
Many thanks for Your reply, Your effort to create an XML-plugin and the bug
report. Would it help to compile paraview from source with
Module_vtkImagingStencil set to ON on our own platform for testing or is
there some code adjustment of paraview necessary to allow that?
No, it won't help. I did exactly that an ran into issues with
vtkImageStencil and ParaView. Evidently, we hadn't tried to use that
data-object in ParaView before.
I guess it would not help to specify the location of a separately compiled
vtk-5.10?
You are correct, it will not help. We need to track the issue down on
the ParaView side first.
Do I understand correctly that with using port_index= You specify which
output should go to which input?
That is correct. If not specified, 0 is assumed.
What is calling e.g. the vtkImplicitPlaneWidget to get the interaction
widget for specifying the implicit function parameters?
In this case, it's the "ProxyListDomain" associated with the
"ImplicitFunction" property. The domain refers to proxies viz.
("implicit_functions", "Plane"), etc. If you look at the xml
definitions for the same in ParaView
(ParaViewCore/ServerManager/SMApplication/Resources/utilities.xml),
you'll see that it provides a "<Hints>" section that suggests a
"PropertyGroup" of type "Plane". That's what's causing the GUI to show
the vtkImplicitPlaneWidget to control the Origin and Normal
properties.
Hope that clarifies things a bit.
Utkarsh
--
Dr. Roman Grothausmann
Tomographie und Digitale Bildverarbeitung
Tomography and Digital Image Analysis
Institut für Funktionelle und Angewandte Anatomie, OE 4120
Medizinische Hochschule Hannover
Carl-Neuberg-Str. 1
D-30625 Hannover
Tel. +49 511 532-9574
# This exercise demonstrates a filter plugin.
cmake_minimum_required(VERSION 2.6)
FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE})
# Use the PLUGIN macro to create a plugin.
ADD_PARAVIEW_PLUGIN(myImageClipper "1.0"
SERVER_MANAGER_SOURCES myImageClipper.cxx
SERVER_MANAGER_XML myImageClipper.xml)
#include "myImageClipper.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
//#include <vtkPlane.h>
#include <vtkImplicitFunction.h>
#include <vtkImageData.h>
#include <vtkImageClip.h>
#include <vtkImageStencilSource.h>
#include <vtkImplicitFunctionToImageStencil.h>
#include <vtkImageStencil.h>
#include <vtkImageMask.h>
#include <vtkSmartPointer.h>
vtkStandardNewMacro(vtkMyImageClipper);
//----------------------------------------------------------------------------
// Description:
vtkMyImageClipper::vtkMyImageClipper()
{
// this->origin = {0,0,0};
// this->normal = {0,0,0};
this->mask_value = 0;
}
//from ParaViewCore/VTKExtensions/Default/vtkPVMetaSliceDataSet.cxx
void vtkMyImageClipper::SetInputIF(vtkImplicitFunction* func)
{
this->inputIF= func;
this->Modified();
}
//----------------------------------------------------------------------------
int vtkMyImageClipper::RequestData(
vtkInformation *vtkNotUsed(request),
vtkInformationVector **inputVector,
vtkInformationVector *outputVector)
{
// get the info objects
vtkInformation *inInfo0 = inputVector[0]->GetInformationObject(0);
vtkInformation *inInfo1 = inputVector[0]->GetInformationObject(1);
vtkInformation *outInfo = outputVector->GetInformationObject(0);
// get the input and ouptut
vtkImageData *input = vtkImageData::SafeDownCast(
inInfo0->Get(vtkDataObject::DATA_OBJECT()));
//vtkImplicitFunction *inputIF = vtkImplicitFunction::SafeDownCast(inInfo1->Get(vtkDataObject::DATA_OBJECT()));
vtkImageData *output = vtkImageData::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
// vtkSmartPointer<vtkPlane> plane =
// vtkSmartPointer<vtkPlane>::New();
// plane->SetOrigin(this->origin[0],this->origin[1],this->origin[2]);
// plane->SetNormal(this->normal[0],this->normal[1],this->normal[2]);
// // Copy original points and point data
// output->CopyStructure( input );
// output->GetPointData()->PassData(input->GetPointData());
// output->GetCellData()->PassData(input->GetCellData());
vtkSmartPointer<vtkImplicitFunctionToImageStencil> filter =
vtkSmartPointer<vtkImplicitFunctionToImageStencil>::New();
// filter->SetInput(plane);
filter->SetInput(this->inputIF);
filter->SetInformationInput(input);
//// Create an empty (3D) image of appropriate size.
vtkSmartPointer<vtkImageData> image =
vtkSmartPointer<vtkImageData>::New();
//image->SetInformationInput(input);
image->SetSpacing(input->GetSpacing());
image->SetOrigin(input->GetOrigin());
image->SetExtent(input->GetExtent());
//image->SetScalarTypeToUnsignedChar();
//image->AllocateScalars(); // this causes blender to crash if not enough space can be allocated
image->AllocateScalars(VTK_UNSIGNED_CHAR,1);//vtk-6.1.0
//// apply the image stencil to the empty image
vtkSmartPointer<vtkImageStencil> stencil =
vtkSmartPointer<vtkImageStencil>::New();
stencil->SetInputData(image);
//stencil->SetStencil(filter->GetOutput());
stencil->SetStencilConnection(filter->GetOutputPort());
//stencil->ReverseStencilOn();
stencil->SetBackgroundValue(255);
//// mask the input image with the stencil
vtkSmartPointer<vtkImageMask> mask =
vtkSmartPointer<vtkImageMask>::New();
mask->SetImageInputData(input); //6.0.0
mask->SetMaskInputData(stencil->GetOutput()); //6.0.0
//mask->SetImageInput(input); //5.10.1
//mask->SetMaskInput(stencil->GetOutput()); //5.10.1
// mask->SetMaskedOutputValue(100,128,200);
mask->SetMaskedOutputValue(this->mask_value);
// mask->NotMaskOn();
// mask->ReleaseDataFlagOff();
mask->Update();
output->ShallowCopy(mask->GetOutput());
return 1;
}
//----------------------------------------------------------------------------
void vtkMyImageClipper::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "mask_value: " << this->mask_value << endl;
os << indent << endl;
}
// .NAME vtkMyImageClipper - sample filter for paraview
// .SECTION Description
// This filter demonstrates importing filters to paraview
#ifndef __vtkMyImageClipper_h
#define __vtkMyImageClipper_h
#include "vtkImageAlgorithm.h"
#include <vtkImplicitFunction.h>
class VTK_EXPORT vtkMyImageClipper : public vtkImageAlgorithm
{
public:
static vtkMyImageClipper *New();
vtkTypeMacro(vtkMyImageClipper,vtkImageAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
/* vtkSetVector3Macro(origin, double); */
/* vtkGetVector3Macro(origin, double); */
/* vtkSetVector3Macro(normal, double); */
/* vtkGetVector3Macro(normal, double); */
vtkSetMacro(mask_value, double);
vtkGetMacro(mask_value, double);
//from ParaViewCore/VTKExtensions/Default/vtkPVMetaSliceDataSet.h
void SetInputIF(vtkImplicitFunction* func);
/* void SetImplicitFunction(vtkImplicitFunction* func) */
/* { this->SetImplicitFunction(func); }; */
protected:
vtkMyImageClipper();
~vtkMyImageClipper() {};
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
//double origin[3], normal[3];
double mask_value;
private:
vtkMyImageClipper(const vtkMyImageClipper&); // Not implemented.
void operator=(const vtkMyImageClipper&); // Not implemented.
vtkImplicitFunction* inputIF;
};
#endif
<ServerManagerConfiguration>
<ProxyGroup name="filters">
<SourceProxy name="myImageClipper"
class="vtkMyImageClipper"
label="Image Clipper">
<InputProperty command="SetInputConnection" name="Input">
<DataTypeDomain name="input_type">
<DataType value="vtkImageData" />
</DataTypeDomain>
<Documentation>This property specifies the input image data.
</Documentation>
</InputProperty>
<ProxyProperty command="SetInputIF" name="ImplicitFunction">
<ProxyGroupDomain name="groups">
<Group name="implicit_functions" />
</ProxyGroupDomain>
<ProxyListDomain name="proxy_list">
<Proxy group="implicit_functions" name="Plane" />
<Proxy group="implicit_functions" name="Box" />
<Proxy group="implicit_functions" name="Sphere" />
</ProxyListDomain>
<Documentation>
Specify the implicit function to convert into a stencil.
</Documentation>
</ProxyProperty>
<!-- <IntVectorProperty name="ReverseStencil" -->
<!-- command="SetReverseStencil" -->
<!-- number_of_elements="1" -->
<!-- default_values="0"> -->
<!-- <BooleanDomain name="bool" /> -->
<!-- <Documentation>Reverse the stencil.</Documentation> -->
<!-- </IntVectorProperty> -->
<DoubleVectorProperty name="MaskedOutputValue"
command="SetMaskedOutputValue"
number_of_elements="1"
default_values="0">
<DoubleRangeDomain name="range" />
</DoubleVectorProperty>
</SourceProxy>
</ProxyGroup>
</ServerManagerConfiguration>
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the ParaView Wiki at:
http://paraview.org/Wiki/ParaView
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview