[vtkusers] Connected Components
Michael Jackson
mike.jackson at bluequartz.net
Tue Nov 25 09:24:52 EST 2008
I don't really understand as I never saw the original data set. The
triangulation looks technically correct, but not very "smooth" Maybe
you need to run a smoothing filter on the data?
Mike
On Nov 25, 2008, at 3:57 AM, prabhat246 wrote:
>
> Hi Mike,
> But there seems to be some problem. I am not getting the accurate
> triangulation that it should be.
> I cant see smooth surface, rather it is displaying uniform patches.
> I am
> attaching a screenshot. http://www.nabble.com/file/p20677309/surface.JPG
> surface.JPG
>
> Can you suggest what might be wrong?
>
> Thanks
> Regards,
> Prabhat
>
>
> prabhat246 wrote:
>>
>> Hi Mike,
>> Thanks a million.... It worked. :)
>>
>> Regards,
>> Prabhat
>>
>> Mike Jackson-19 wrote:
>>>
>>> First off you need a matching con->Delete() for the
>>> vtkPolyDataConnectivityFilter * con =
>>> vtkPolyDataConnectivityFilter::New(); function otherwise you are
>>> leaking that filter object.
>>>
>>> Next, I bet this takes a really long time to run because for 10,000
>>> components, you have to run the same filter 10,000 times. How about
>>> this filter instead:
>>>
>>> //Find all the discrete components
>>> vtkSmartPointer<DiscreteParticleFilter> connectivity =
>>> vtkSmartPointer<DiscreteParticleFilter>::New();
>>> connectivity->SetInput( mc->GetOutput() );
>>> connectivity->Update(); //Force the pipeline to execute ...
>>> vtkPolyData* currentComponent = NULL;
>>> vtkPolyDataCollection* components = connectivity->GetPolyRegions();
>>> components->InitTraversal(); //Init the enumeration
>>> int count = components->GetNumberOfItems();
>>>
>>> //Iterate over each PolyLoop and decide how to triangulate it
>>> for (int i = 0; i < count; ++i) {
>>> currentComponent = components->GetNextItem();
>>> // Add Mapper and Actor code from below
>>> vtkPolyDataMapper *polymap;
>>> vtkActor * polyact;
>>>
>>> //std::cout<<connect->GetOutput()->GetNumberOfCells()<<std::endl;
>>>
>>> polymap = vtkPolyDataMapper::New();
>>> polymap->SetInput(currentComponent);
>>> polyact = vtkActor::New();
>>> polyact->SetMapper(polymap);
>>> renderer->AddActor(polyact);
>>>
>>> vtkBoxWidget *boxWidget = vtkBoxWidget::New();
>>> boxWidget->SetInteractor(iren);
>>> boxWidget->SetPlaceFactor(1);
>>> boxWidget->SetProp3D(polyact);
>>> boxWidget->PlaceWidget();
>>> boxWidget->SetOutlineFaceWires(1);
>>> boxWidget->SetScalingEnabled(0);
>>> boxWidget->SetRotationEnabled(1);
>>> boxWidget->OutlineFaceWiresOff();
>>> boxWidget->OutlineCursorWiresOff();
>>> boxWidget->HandlesOff();
>>> boxWidget->On();
>>>
>>> vtkMyCallback *callback = vtkMyCallback::New();
>>> boxWidget->AddObserver(vtkCommand::InteractionEvent, callback);
>>> }
>>>
>>> I am attaching the source files.
>>>
>>> _________________________________________________________
>>> Mike Jackson mike.jackson at bluequartz.net
>>> BlueQuartz Software www.bluequartz.net
>>> Principal Software Engineer Dayton, Ohio
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Nov 24, 2008, at 9:13 AM, prabhat246 wrote:
>>>
>>>>
>>>> Hi,
>>>>
>>>> I have a object containing large no. of multiple connected
>>>> components(say
>>>> 10,000). I want to be able to transform each component seperately.
>>>> I am
>>>> doing it in following way.
>>>>
>>>> for(int i = 0; i< NoOfRegions; i++)
>>>> {
>>>> vtkPolyDataConnectivityFilter * con =
>>>> vtkPolyDataConnectivityFilter::New();
>>>> con->SetInput(mc->GetOutput());
>>>> con->SetExtractionModeToSpecifiedRegions();
>>>> con->AddSpecifiedRegion(i);
>>>> connect->Update();
>>>>
>>>> vtkPolyDataMapper *polymap;
>>>> vtkActor * polyact;
>>>>
>>>> //std::cout<<connect->GetOutput()->GetNumberOfCells()<<std::endl;
>>>>
>>>> polymap = vtkPolyDataMapper::New();
>>>> polymap->SetInput(con->GetOutput());
>>>> polyact = vtkActor::New();
>>>> polyact->SetMapper(polymap);
>>>> renderer->AddActor(polyact);
>>>>
>>>> vtkBoxWidget *boxWidget = vtkBoxWidget::New();
>>>> boxWidget->SetInteractor(iren);
>>>> boxWidget->SetPlaceFactor(1);
>>>> boxWidget->SetProp3D(polyact);
>>>> boxWidget->PlaceWidget();
>>>> boxWidget->SetOutlineFaceWires(1);
>>>> boxWidget->SetScalingEnabled(0);
>>>> boxWidget->SetRotationEnabled(1);
>>>> boxWidget->OutlineFaceWiresOff();
>>>> boxWidget->OutlineCursorWiresOff();
>>>> boxWidget->HandlesOff();
>>>> boxWidget->On();
>>>>
>>>> vtkMyCallback *callback = vtkMyCallback::New();
>>>> boxWidget->AddObserver(vtkCommand::InteractionEvent, callback);
>>>> }
>>>>
>>>>
>>>> But It runs successfully if I have less no. of components say 10
>>>> but
>>>> it
>>>> crashes on large no of componenets.. I feel that It is due to
>>>> memory
>>>> crash.
>>>> Of course all these objects inside loop are not being deleted.
>>>>
>>>> is there anything that can be avoided to save memory?? or Is there
>>>> any other
>>>> lighter way to do this???
>>>> Please help me out.
>>>>
>>>> Thanks a lot
>>>> Prabhat Kumar Gupta
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Connected-Components-tp20661092p20661092.html
>>>> Sent from the VTK - Users mailing list archive at Nabble.com.
>>>>
>>>> _______________________________________________
>>>> This is the private VTK discussion list.
>>>> Please keep messages on-topic. Check the FAQ at:
>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> This is the private VTK discussion list.
>>> Please keep messages on-topic. Check the FAQ at:
>>> http://www.vtk.org/Wiki/VTK_FAQ
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Connected-Components-tp20661092p20677309.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the 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