[vtkusers] How to delete a line ?

Jérôme jerome.velut at gmail.com
Thu May 14 09:00:32 EDT 2009


Hi,

The deletion with Delete( ) won't remove the line because... the line is
used by the renderer (Take a look at the object factory, garbage collector,
reference counter and all these stuff). I suggest you to remove the actor
from the renderer... With, for instance, ren->RemoveActor( actor1 );

Or, if you want, you can set the background color to the line color...

HTH

Jerome

2009/5/14 luciangoron <luciangoron at gmail.com>

>
> I have a simple code here:
>
> I "print" 2 lines, and than I want to "delete" the first one... (I want to
> NOT see it anymore)
>
> #include "../common/CommonVTKRoutines.h"
> #include "../common/CommonANNRoutines.h"
> #include "../common/Common3DGeomRoutines.h"
> #include "../common/CommonIORoutines.h"
> #include "../common/CommonTerminalRoutines.h"
> #include "../common/ANN-VTK.h"
>
> using namespace cANN;
> using namespace std;
>
> int main (int argc, char** argv)
> {
>  // create vtk renderer and vtk interactor //
>  vtkRenderer *ren = vtkRenderer::New ();
>  ren->SetBackground (0, 0, 0);
>  vtkRenderWindowInteractor *iren = CreateRenderWindowAndInteractor (ren,
> "TEST", argc, argv);
>
>  // first line //
>  vtkLineSource *line1 = vtkLineSource::New();
>  line1->SetPoint1 (1.0, 1.0, 1.0);
>  line1->SetPoint2 (1.5, 1.5, 1.5);
>  vtkActor *actor1 = createActorFromDataSet (line1->GetOutput(), false);
>  actor1->GetProperty()->SetColor (1, 0, 0);
>  ren->AddActor(actor1);
>
>  // do a refresh //
>  iren->Render();
>  iren->Start();
>
>  // second line //
>  vtkLineSource *line2 = vtkLineSource::New();
>  line2->SetPoint1 (0.5, 1.0, 1.5);
>  line2->SetPoint2 (1.5, 1.0, 0.5);
>  vtkActor *actor2 = createActorFromDataSet (line2->GetOutput(), false);
>  actor2->GetProperty()->SetColor (0, 1, 0);
>  ren->AddActor(actor2);
>
>  // do a refresh //
>  iren->Render();
>  iren->Start();
>
>  // suppose to delete de line //
>  line1->Delete();
>  actor1->Delete();
>
>  // do a refresh //
>  iren->Render();
>  iren->Start();
>
>  return 0;
> }
>
> PS : Please do not send me suggestions such as :
>
> " Why don't you color the line which you want to delete in black.. "
>
> Thanks in advance !
> --
> View this message in context:
> http://www.nabble.com/How-to-delete-a-line---tp23501139p23501139.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090514/ce2485cd/attachment.htm>


More information about the vtkusers mailing list