[Paraview] problems with defining the New()-Method
Natalie Happenhofer
nataliehapp at hotmail.com
Tue Sep 9 04:17:05 EDT 2008
Hi!
I´m trying to write a new filter, but I´m encountering major difficulties defining the New()-method of my class:
I´m deriving from "vtkDataSetToStructuredFilter.h" and my .h-file looks like this:
vtkHorizontalAverage.h:
#ifndef __vtkHorizontalAverage_h
#define __vtkHorizontalAverage_h
#include <vtkDataSetToStructuredGridFilter.h>
#include <vtkObjectFactory.h>
#include <vtkObject.h>
class VTK_EXPORT vtkHorizontalAverage : public vtkDataSetToStructuredGridFilter
{ public:
static vtkHorizontalAverage *New() {return new vtkHorizontalAverage;}
//vtkStandardNewMacro(vtkHorizontalAverage);
vtkTypeMacro(vtkHorizontalAverage,vtkDataSetToStructuredGridFilter);
vtkSetMacro(Normalize,int);
vtkGetMacro(Normalize,int);
vtkBooleanMacro(Normalize, int);
void PrintSelf(ostream&, vtkIndent);
protected: vtkHorizontalAverage();
~vtkHorizontalAverage(){};
int Normalize;
void operator=(const vtkHorizontalAverage&) {};
void Execute();
};
#endif
and the corresponding .cxx - File:
#include <vtkHorizontalAverage.h>
vtkHorizontalAverage::vtkHorizontalAverage()
{
this -> Normalize = 0;
}
void vtkHorizontalAverage::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "Normalize: "
<< (this->Normalize ? this->Normalize : 0) << endl;
}
void vtkHorizontalAverage::Execute(){}
I´m still going to define the Execute() Method. it is just that I want to try out the linking!
Well, I get the following errors:
..\..\..\..\bin\libvtkPVFilters.a(vtkPVFiltersInstantiator.obj):vtkPVFiltersInstantiator.cxx(.text+0x2c0): undefined reference to 'vtkInstantiatorvtkHorizontalAverageNew()'
..\..\..\..\bin\libvtkPVFilters.a(vtkPVFiltersInstantiator.obj):vtkPVFiltersInstantiator.cxx(.text+0x3c0):
undefined reference to 'vtkInstantiatorvtkHorizontalAverageNew()'
I don´t understand, my New() IS defined as {return new vtkHorizontalAverage;}!!!
Second try: If I really do not define the New() -method, i.e. instead of
"static vtkHorizontalAverage *New() {return new vtkHorizontalAverage;}"
I just write
"static vtkHorizontalAverage *New();"
I get the same errors as above, but not just two times, I get them four times. !??
Third try: using vtkMacros:
I used vtkStandardNewMacro, the code looks like this:
#ifndef
...
#include <vtkObjectFactory.h>
...
class VTK_EXPORT vtkHorizontalAverage : public vtkDataSetToStructuredGridFilter
{ public:
//static vtkHorizontalAverage *New() {return new vtkHorizontalAverage;}
vtkStandardNewMacro(vtkHorizontalAverage);
..
and I get the following errors, now while building the vtkHorizontalAverage.obj file:
In file included from D:\ParaView3\Servers\Filters\vtkHorizontalAverage.cxx:1:
D:\ParaView3\Servers\Filters\vtkHorizontalAverage.h:11: error: storage class specified for field `vtkInstantiatorvtkHorizontalAverageNew´
D:\ParaView3\Servers\Filters\vtkHorizontalAverage.h:11: error: `vtkObject* vtkHorizontalAverage::vtkInstantiatorvtkHorizontalAverageNew()´
and `vtkObject* vtkHorizontalAverage::vtkInstantiatorvtkHorizontalAverageNew()´cannot be overloaded
D:\ParaView3\Servers\Filters\vtkHorizontalAverage.h: In member function `virtual vtkObjectBase* vtkHorizontalAverage::NewInstanceInternal() const`:
D:\ParaView3\Servers\Filters\vtkHorizontalAverage.h:12: error:error:passing ´const vtkHorizontalAverage´as `this´argument of `vtkHorizontalAverage* vtkHorizontalAverage::New() discards qualifiers
Does anyone have an idea what to do?
Thx very much,
NH
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20080909/cc565b6c/attachment.htm>
More information about the ParaView
mailing list