[vtkusers] vtk c++ - using classes with VTK

Sebastien Jourdain sebastien.jourdain at kitware.com
Tue Nov 8 10:24:49 EST 2011


Instead of returning a smart pointer try to return a vtkActor* instead.


On Tue, Nov 8, 2011 at 9:38 AM, David Doria <daviddoria at gmail.com> wrote:
> On Tue, Nov 8, 2011 at 9:28 AM, Hikaruchan
> <Sandra.Schroetter.fl at ait.ac.at> wrote:
>> No, but it is interesting that it seems that you can't see it (I see it
>> above). Strange...post it again ;-)
>>
>> ==========================================================
>> previous message with code
>> ==========================================================
>> I made an VTK application which works great. But it is very long long code
>> in one class with many functions. So I tried to split up the VTK things into
>> serveral classes in my project. But then I got a problem with an access
>> violation error. As example what I am doing:
>>
>> //class BrainModelVisualizer
>> //and here a function in the class which is called out from another class
>> void BrainModelVisualizer::initBrainModel(){
>> ...
>> do some stuff here
>> ...
>> //objactor is a member variable in the class
>> objactor = vtkSmartPointer<vtkActor>::New();
>> objactor->SetMapper(objmapper);
>> objactor->GetProperty()->SetOpacity( 0.15 );
>> }
>>
>> //a getter is existing in the class BrainModelVisualizer
>> vtkSmartPointer<vtkActor> getBrainModelActor(){
>>        return this->objactor;
>> }
>>
>>
>> later I will need the "objactor" in another class, getting it via the
>> getBrainModelActor()-Function.
>>
>> So the Problem now is, that when I try this shorten code above, I get an
>> access violation error in the line
>>
>> objactor = vtkSmartPointer<vtkActor>::New();
>>
>>
>> I do not understand why. Is there anything wrong? I don't get it out. I hope
>> someone can help me, or tell me why it does not work.
>>
>> Dear Hikaru
>>
>> ==========================================================
>> end previous message with code
>
> Can you show us the declaration of objactor? I'd assume it is
>
> vtkSmartPointer<vtkActor> objactor
>
> ?
>
> David
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list