<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Hi!<br>I´m trying to write a new filter, but I´m encountering major difficulties defining the New()-method of my class:<br>I´m deriving from "vtkDataSetToStructuredFilter.h" and my .h-file looks like this:<br><br>vtkHorizontalAverage.h:<br>#ifndef __vtkHorizontalAverage_h<br>#define __vtkHorizontalAverage_h<br><br>#include <vtkDataSetToStructuredGridFilter.h><br>#include <vtkObjectFactory.h><br>#include <vtkObject.h><br><br>class VTK_EXPORT vtkHorizontalAverage : public vtkDataSetToStructuredGridFilter <br>{ public:<br> static vtkHorizontalAverage *New() {return new vtkHorizontalAverage;}<br> //vtkStandardNewMacro(vtkHorizontalAverage);<br> vtkTypeMacro(vtkHorizontalAverage,vtkDataSetToStructuredGridFilter);<br> vtkSetMacro(Normalize,int);<br> vtkGetMacro(Normalize,int);<br> vtkBooleanMacro(Normalize, int);<br> void PrintSelf(ostream&, vtkIndent);<br><br> protected: vtkHorizontalAverage();<br> ~vtkHorizontalAverage(){};<br> <br> int Normalize;<br> <br> void operator=(const vtkHorizontalAverage&) {};<br> void Execute();<br>};<br>#endif<br><br>and the corresponding .cxx - File:<br>#include <vtkHorizontalAverage.h><br>vtkHorizontalAverage::vtkHorizontalAverage()<br>{<br> this -> Normalize = 0;<br>}<br><br>void vtkHorizontalAverage::PrintSelf(ostream& os, vtkIndent indent)<br>{<br> this->Superclass::PrintSelf(os,indent);<br> <br> os << indent << "Normalize: " <br> << (this->Normalize ? this->Normalize : 0) << endl;<br>}<br><br>void vtkHorizontalAverage::Execute(){}<br><br><br>I´m still going to define the Execute() Method. it is just that I want to try out the linking!<br><br>Well, I get the following errors:<br><br>..\..\..\..\bin\libvtkPVFilters.a(vtkPVFiltersInstantiator.obj):vtkPVFiltersInstantiator.cxx(.text+0x2c0): undefined reference to 'vtkInstantiatorvtkHorizontalAverageNew()'<br>..\..\..\..\bin\libvtkPVFilters.a(vtkPVFiltersInstantiator.obj):vtkPVFiltersInstantiator.cxx(.text+0x3c0):
undefined reference to 'vtkInstantiatorvtkHorizontalAverageNew()'<br><br>I don´t understand, my New() IS defined as {return new vtkHorizontalAverage;}!!!<br><br><br>Second try: If I really do not define the New() -method, i.e. instead of <br>"static vtkHorizontalAverage *New() {return new vtkHorizontalAverage;}"<br>I just write <br>"static vtkHorizontalAverage *New();"<br>I get the same errors as above, but not just two times, I get them four times. !?? <br><br><br>Third try: using vtkMacros:<br>I used vtkStandardNewMacro, the code looks like this:<br><br>#ifndef<br>...<br>#include <vtkObjectFactory.h><br>...<br>class VTK_EXPORT vtkHorizontalAverage : public vtkDataSetToStructuredGridFilter <br>
{ public:<br>
//static vtkHorizontalAverage *New() {return new vtkHorizontalAverage;}<br>
vtkStandardNewMacro(vtkHorizontalAverage);<br>..<br><br>and I get the following errors, now while building the vtkHorizontalAverage.obj file:<br>In file included from D:\ParaView3\Servers\Filters\vtkHorizontalAverage.cxx:1:<br>D:\ParaView3\Servers\Filters\vtkHorizontalAverage.h:11: error: storage class specified for field `vtkInstantiatorvtkHorizontalAverageNew´<br>D:\ParaView3\Servers\Filters\vtkHorizontalAverage.h:11: error: `vtkObject* vtkHorizontalAverage::vtkInstantiatorvtkHorizontalAverageNew()´<br>and `vtkObject* vtkHorizontalAverage::vtkInstantiatorvtkHorizontalAverageNew()´cannot be overloaded<br>D:\ParaView3\Servers\Filters\vtkHorizontalAverage.h: In member function `virtual vtkObjectBase* vtkHorizontalAverage::NewInstanceInternal() const`:<br>D:\ParaView3\Servers\Filters\vtkHorizontalAverage.h:12: error:error:passing ´const vtkHorizontalAverage´as `this´argument of `vtkHorizontalAverage* vtkHorizontalAverage::New() discards qualifiers<br><br><br><br>Does anyone have an idea what to do?<br>Thx very much, <br>NH<br><br><br><br>
<br><br><br><br><br /><hr />Express yourself instantly with MSN Messenger! <a href='http://clk.atdmt.com/AVE/go/onm00200471ave/direct/01/' target='_new'>MSN Messenger</a></body>
</html>