<div dir="auto">Use vtkappendpolydata instead of vtkappendfilter.<div dir="auto"><br></div><div dir="auto">Alternatively you could extract surface on the unstructured grid you have now yo convert to polydata but that would be less direct.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sep 13, 2017 1:12 AM, "vinmean" <<a href="mailto:iamdpak@gmail.com" target="_blank">iamdpak@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Below is an c++ code I wrote for combining two polygon source. I tweaked an<br>
existing example so my code is at the end. Problem is, after combining two<br>
polygon data (using appendFilter),  I am not able to access the polyData of<br>
the combined actor. It throws a segmentation fault when I access the<br>
polyData points using GetPoints() function<br>
<br>
<br>
<br>
#include <vtkSmartPointer.h><br>
#include <vtkSphereSource.h><br>
#include <vtkPolyData.h><br>
#include <vtkTransform.h><br>
#include <vtkTransformPolyDataFilter.h><br>
#include <vtkPolyDataMapper.h><br>
#include <vtkDataSetMapper.h><br>
#include <vtkActor.h><br>
#include <vtkProperty.h><br>
#include <vtkRenderWindow.h><br>
#include <vtkRenderer.h><br>
#include <vtkAssembly.h><br>
#include <vtkAppendFilter.h><br>
#include <vtkUnstructuredGrid.h><br>
#include <vtkRenderWindowInteractor.h><br>
<br>
<br>
<br>
<br>
void merge_polyData_in_viz(int actor_strt_ID,vtkSmartPointer<<wbr>vtkRenderer><br>
renderer, vtkSmartPointer<<wbr>vtkAppendFilter> appendFilter<br>
,vtkSmartPointer<vtkAssembly> assembly)<br>
{<br>
        vtkSmartPointer<<wbr>vtkActorCollection> actors =<br>
vtkSmartPointer<<wbr>vtkActorCollection>::New();<br>
        actors = renderer->GetActors();<br>
        actors->InitTraversal();<br>
<br>
        //skip the first actor_strt_ID actors<br>
        for (vtkIdType a = 0; a < actor_strt_ID; ++a)<br>
        {<br>
          vtkActor * actor = actors->GetNextActor();<br>
        }<br>
<br>
        for (vtkIdType a = actor_strt_ID; a < actors->GetNumberOfItems(); ++a)<br>
        {<br>
          vtkActor * actor = actors->GetNextActor();<br>
          assembly->AddPart(actor);<br>
          vtkSmartPointer<vtkPolyData>  pd =<br>
vtkPolyData::SafeDownCast(<wbr>actor->GetMapper()->GetInput()<wbr>);<br>
          vtkSmartPointer<<wbr>vtkUnstructuredGrid> ug =<br>
vtkSmartPointer<<wbr>vtkUnstructuredGrid>::New();<br>
          ug->SetPoints(pd->GetPoints())<wbr>;<br>
          appendFilter->AddInputData(pd)<wbr>;<br>
          appendFilter->AddInputData(ug)<wbr>;<br>
          appendFilter->Update();<br>
        }<br>
<br>
<br>
}<br>
<br>
<br>
int main(int, char *[])<br>
{<br>
<br>
        // Create the polydata geometry<br>
<br>
  vtkSmartPointer<<wbr>vtkSphereSource> sphereSource =<br>
    vtkSmartPointer<<wbr>vtkSphereSource>::New();<br>
  sphereSource->Update();<br>
<br>
  // Set up the actor to display the untransformed polydata<br>
<br>
  vtkSmartPointer<<wbr>vtkPolyDataMapper> originalMapper =<br>
    vtkSmartPointer<<wbr>vtkPolyDataMapper>::New();<br>
  originalMapper-><wbr>SetInputConnection(<wbr>sphereSource->GetOutputPort())<wbr>;<br>
<br>
  vtkSmartPointer<vtkActor> originalActor =<br>
    vtkSmartPointer<vtkActor>::<wbr>New();<br>
  originalActor->SetMapper(<wbr>originalMapper);<br>
  originalActor->GetProperty()-><wbr>SetColor(1,0,0);<br>
<br>
  // Set up the transform filter<br>
<br>
  vtkSmartPointer<vtkTransform> translation =<br>
    vtkSmartPointer<vtkTransform>:<wbr>:New();<br>
  translation->Translate(1.0, 2.0, 3.0);<br>
<br>
  vtkSmartPointer<<wbr>vtkTransformPolyDataFilter> transformFilter =<br>
    vtkSmartPointer<<wbr>vtkTransformPolyDataFilter>::<wbr>New();<br>
  transformFilter-><wbr>SetInputConnection(<wbr>sphereSource->GetOutputPort())<wbr>;<br>
  transformFilter->SetTransform(<wbr>translation);<br>
  transformFilter->Update();<br>
<br>
  // Set up the actor to display the transformed polydata<br>
<br>
  vtkSmartPointer<<wbr>vtkPolyDataMapper> transformedMapper =<br>
    vtkSmartPointer<<wbr>vtkPolyDataMapper>::New();<br>
  transformedMapper-><wbr>SetInputConnection(<wbr>transformFilter-><wbr>GetOutputPort());<br>
<br>
  vtkSmartPointer<vtkActor> transformedActor =<br>
    vtkSmartPointer<vtkActor>::<wbr>New();<br>
  transformedActor->SetMapper(<wbr>transformedMapper);<br>
  transformedActor->GetProperty(<wbr>)->SetColor(0,1,0);<br>
<br>
<br>
  // Set up the rest of the visualization pipeline<br>
  vtkSmartPointer<vtkRenderer> renderer =<br>
     vtkSmartPointer<vtkRenderer>::<wbr>New();<br>
   renderer->AddActor(<wbr>originalActor);<br>
   renderer->AddActor(<wbr>transformedActor);<br>
   renderer->SetBackground(.3, .6, .3); // Set renderer's background color<br>
to green<br>
<br>
   vtkSmartPointer<<wbr>vtkRenderWindow> renderWindow =<br>
     vtkSmartPointer<<wbr>vtkRenderWindow>::New();<br>
   renderWindow->AddRenderer(<wbr>renderer);<br>
<br>
   vtkSmartPointer<<wbr>vtkRenderWindowInteractor> renderWindowInteractor =<br>
     vtkSmartPointer<<wbr>vtkRenderWindowInteractor>::<wbr>New();<br>
   renderWindowInteractor-><wbr>SetRenderWindow(renderWindow);<br>
<br>
   renderWindowInteractor->Start(<wbr>);<br>
<br>
   //////////////////////////////<wbr>///////////addional code<br>
//////////////////////////////<wbr>///////////////////<br>
<br>
   //merge two actors to create a new actor<br>
   vtkSmartPointer<vtkActor> merged_actor =<br>
vtkSmartPointer<vtkActor>::<wbr>New();<br>
   vtkSmartPointer<<wbr>vtkAppendFilter> appendFilter =<br>
vtkSmartPointer<<wbr>vtkAppendFilter>::New();<br>
   vtkSmartPointer<vtkAssembly> asmbly =<br>
vtkSmartPointer<vtkAssembly>::<wbr>New();<br>
   merge_polyData_in_viz(0,<wbr>renderer, appendFilter,asmbly);<br>
<br>
        //new actor and mapper<br>
        vtkSmartPointer<<wbr>vtkDataSetMapper> merged_mapper =<br>
vtkSmartPointer<<wbr>vtkDataSetMapper>::New();<br>
        merged_mapper-><wbr>SetInputConnection(<wbr>appendFilter->GetOutputPort())<wbr>;<br>
        merged_actor->SetMapper(<wbr>merged_mapper);<br>
<br>
        //trying to get points of new polyData<br>
        vtkSmartPointer<vtkPolyData>  pd =<br>
vtkPolyData::SafeDownCast(<wbr>merged_actor->GetMapper()-><wbr>GetInput());<br>
        pd->GetPoints();<br>
<br>
<br>
<br>
<br>
   return EXIT_SUCCESS;<br>
<br>
}<br>
<br>
<br>
<br>
--<br>
Sent from: <a href="http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.<wbr>com/VTK-Users-f1224199.html</a><br>
______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_<wbr>FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/vtkusers</a><br>
</blockquote></div></div>