[vtkusers] Build vtk classes - HELP!!!

Charl P. Botha c.p.botha at ewi.tudelft.nl
Tue Jan 13 17:03:22 EST 2004


Yi-Yu Chou wrote:

> Hi all vtk users,
> 
> I am trying t build my own vtk classes but I encounter some problems.
> I tried to change the example a little bit in 
> VTK/Example/Build/vtkMy/Common/
> 
> // vtkBar.h
> #ifndef __vtkBar_h
> #define __vtkBar_h
> #include "vtkObject.h"
> #include "vtkmyCommonWin32Header.h"
> 
> class VTK_MY_COMMON_EXPORT vtkBar : public vtkObject
> {
> public:
>  static vtkBar *New();
>  vtkTypeRevisionMacro(vtkBar,vtkObject);
>  int inData;
>  int outData;
> protected:
>  vtkBar() ;
>  ~vtkBar() ;
> private:
>  vtkBar(const vtkBar&);  // Not implemented.
>  void operator=(const vtkBar&);  // Not implemented.
> };
> #endif
> // vtkBar.cxx
> #include "vtkBar.h"
> #include "vtkObjectFactory.h"
> 
> vtkCxxRevisionMacro(vtkBar, "$Revision: 1.3 $");
> vtkStandardNewMacro(vtkBar);
> vtkBar::vtkBar()
> {
>  this->inData = 0;
>  this->outData = 0;
> }
> 
> vtkBar::~vtkBar()
> {
> }
> ............................................................................................................................... 
> 
> 
> Under /VTK/Example/Build/vtkMy
> I ran : ccmake . Press "c" twice, then press "g"
> Enter : make
> Go to /vtkMy/bin
> Ran : python
> 
>>>> from vtk import *
>>>> from libvtkmyCommonPython import *
>>>> A = vtkBar()
>>>> A.inData
> 
> Then I got the following error message :
> AttributeError: inData What's wrong with my procedure.....??????
> Please help me !!!

You have to write getters and setters for inData, e.g. GetInData() and
SetInData().  You can use VTK macros to do this easily and correctly.
The VTK wrapping system does not wrap instance variables.

-- 
charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/






More information about the vtkusers mailing list