Dear Laurentiu,
I was actually writing the reply to your previous message, but I see that you
got past that point.
In any case, you always need the New method and the vtkStandardNewMacro, and
declare
constructor and descructor as protected (they are never called directly, only
through New and Delete).
This allows vtkObject to take care of the reference counting etc.
The issue you are having now is that contrib classes are available in
vtkvmtkcontrib, not vtkvmtk,
so just modify your script as
import vtkvmtkcontrib
...
val = vtkvmtkcontrib.vtkvmtkModuleCarotid()
It should work. Fingers crossed!
Luca
On Nov 9, 2011, at 1:39 PM, Lipsa Laurentiu Mihai wrote:
> Hi,
> Finally it compiles but when a execute my new vmtkscript calling the new
> class I have the next error:
>
> lau@lau-laptop:~/vmtk-build$ vmtkanewmodule
>
> Creating vmtkNewModule instance.
> Automatic piping
> Parsing options
> Explicit piping
> Input members:
> Id = 0
> Disabled = 0
> Executing ...
> Traceback (most recent call last):
> File "/home/lau/vmtk-build/Install/bin/vmtkanewmodule", line 64, in <module>
> main.Execute()
> File "/home/lau/vmtk-build/Install/lib/vmtk/vmtk/pypescript.py", line 562,
> in Execute
> pipe.Execute()
> File "/home/lau/vmtk-build/Install/lib/vmtk/vmtk/pype.py", line 274, in
> Execute
> scriptObject.Execute()
> File "/home/lau/vmtk-build/Install/lib/vmtk/vmtk/vmtkanewmodule.py", line
> 23, in Execute
> val = vtkvmtk.vtkvmtkModuleCarotid()
> AttributeError: 'module' object has no attribute 'vtkvmtkModuleCarotid'
>
>
> I also attach my .h file and the begining of .cxx :
>
>
> #ifndef __vtkvmtkModuleCarotid_h
> #define __vtkvmtkModuleCarotid_h
> #include "vtkPolyDataAlgorithm.h"
> #include "vtkvmtkWin32Header.h"
> #include <vtkstd/vector>
> //#include <math>
> #include <algorithm>
> #include <iostream>
> #include <fstream>
> #include <string.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include "vtkPolyData.h"
> #include "vtkImplicitFunction.h"
>
> class VTK_VMTK_CONTRIB_EXPORT vtkvmtkModuleCarotid : public
> vtkPolyDataAlgorithm
> {
> public:
> static vtkvmtkModuleCarotid* New();
> vtkTypeRevisionMacro(vtkvmtkModuleCarotid,vtkPolyDataAlgorithm);
>
> void Carotid(void);
>
> float Dotm(vtkstd::vector <float> &vector1, vtkstd::vector <float> &vector2,
> vtkstd::vector <float> &vector3, int step, double Arr[]);
>
> protected:
> vtkvmtkModuleCarotid();
> ~vtkvmtkModuleCarotid();
>
>
> private:
> vtkvmtkModuleCarotid(const vtkvmtkModuleCarotid&); // Not implemented.
> void operator=(const vtkvmtkModuleCarotid&); // Not implemented.
> };
>
> #endif
>
>
> the C++file:
>
> #include "vtkvmtkModuleCarotid.h"
>
> #include "vtkPointData.h"
> #include "vtkDoubleArray.h"
> #include "vtkMath.h"
> #include "vtkInformation.h"
> #include "vtkInformationVector.h"
> #include "vtkObjectFactory.h"
> #include "vtkIOStream.h"
>
> #include <vtkstd/vector>
> //#include <vtkstd/math>
> #include <iostream>
> #include <fstream>
> #include <vtkstd/string>
> #include <stdio.h>
> #include <stdlib.h>
>
>
> #include "vtkvmtkConstants.h"
>
> vtkCxxRevisionMacro(vtkvmtkModuleCarotid, "$Revision: 1 $");
> vtkStandardNewMacro(vtkvmtkModuleCarotid);
> //vtkCxxSetObjectMacro(vtkvmtkModuleCarotid,ImplicitFunction,vtkImplicitFunction);
>
>
> vtkvmtkModuleCarotid::vtkvmtkModuleCarotid()
> {
> /*this->SampleArrayName = NULL;
> this->ImplicitFunction = NULL;*/
> }
>
> vtkvmtkModuleCarotid::~vtkvmtkModuleCarotid()
> {
> /*if (this->SampleArrayName)
> {
> delete[] this->SampleArrayName;
> this->SampleArrayName = NULL;
> }
>
> this->ImplicitFunction = NULL;*/
> }
>
> float vtkvmtkModuleCarotid::Dotm(vtkstd::vector <float> &vector1,
> vtkstd::vector <float> &vector2, vtkstd::vector <float> &vector3, int step,
> double Arr[])
> {
> float Dotmt;
> Dotmt=vector1[step]*Arr[0]+vector2[step]*Arr[1]+vector3[step]*Arr[2];
>
>
> return Dotmt;
> }
>
> void vtkvmtkModuleCarotid::Carotid()
> {
>
>
> int lenLines,lenLines2,i,j;
> vtkstd::string str;
> vtkstd::vector <float> X, Y, Z , Abscissas , ParallelTransportNormal0 ,
> ParallelTransportNormal1 , ParallelTransportNormal2 , FrenetTangent0 ,
> FrenetTangent1 , FrenetTangent2 , FrenetNormal0 , FrenetNormal1
> ,FrenetNormal2 , FrenetBinormal0 , FrenetBinormal1 , FrenetBinormal2 ,
> CenterlineIds , TractIds , Blanking , GroupIds ;
> .............
> }
>
>
> My vmtk new script is:
>
>
> #!/usr/bin/env python
>
> import sys
> import os
> import vtk
> import vtkvmtk
> import pypes
> import vmtkscripts
>
> vmtkanewmodule = 'vmtkNewModule'
>
> class vmtkNewModule(pypes.pypeScript):
>
> def __init__(self):
>
> pypes.pypeScript.__init__(self)
> ## self.val = None
>
> def Execute(self):
> ## self.val = vtkvmtk.vtkvmtkModuleCarotid()
> ## self.val.Carotid()
> ## pass
> val = vtkvmtk.vtkvmtkModuleCarotid()
> val.Carotid()
>
> if __name__=='__main__':
> main = pypes.pypeMain()
> main.Arguments = sys.argv
> main.Execute()
>
> Cau you help me with this problem?
>
> Best regards.
> Laurentiu
>
> ------------------------------------------------------------------------------
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1_______________________________________________
> vmtk-users mailing list
> vmtk-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/vmtk-users
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
vmtk-users mailing list
vmtk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vmtk-users