lundi 4 septembre 2017

how to subclass vtkActor?

I am trying to subclass the vtkActor class. But my class keeps getting the error "undefined reference to `vtkIntraLatticeObject::New()"

I found this link. I tried it but I get "undefined reference to vtkIntraLatticeObject::vtkIntraLatticeObject()". I am also not 100% convinced this is the way to go. I managed to get the following example to work. So I have difficulty understanding what's so different with my code.

So here's my code class.
vtkIntraLatticeObject.h

#ifndef VTKINTRALATTICEOBJECT_H
#define VTKINTRALATTICEOBJECT_H


#include <vtkSmartPointer.h>
#include <vtkRenderer.h>
#include <vtkObjectFactory.h>
#include <vtkRenderingCoreModule.h>
#include <vtkProperty.h>
#include <string.h>
#include <vtkActor.h>

class VTKRENDERINGCORE_EXPORT vtkIntraLatticeObject : public vtkActor
{
    public:

        vtkTypeRevisionMacro(vtkIntraLatticeObject, vtkActor);
        static vtkIntraLatticeObject* New();

        int assignID();

        std::string getObjectTypeName();


    protected:
        int ID;
        static int intralatticeActorCounter;

        vtkActor* Device;

        vtkIntraLatticeObject();
        ~vtkIntraLatticeObject();

};


#endif

vtkIntraLatticeObject.cc

#include "vtkIntraLatticeObject.h"

vtkStandardNewMacro(vtkIntraLatticeObject);

int vtkIntraLatticeObject::intralatticeActorCounter = 0;

vtkIntraLatticeObject::vtkIntraLatticeObject()
{
    int ID = -1;
    this -> Device = vtkActor::New();
}

vtkIntraLatticeObject::~vtkIntraLatticeObject()
{
    this -> Device -> Delete();
}

int vtkIntraLatticeObject::assignID()
{
    ID = intralatticeActorCounter;
    intralatticeActorCounter++;
    return ID;
}

std::string vtkIntraLatticeObject::getObjectTypeName()
{
    return "generic intralattice Object";
}

Aucun commentaire:

Enregistrer un commentaire