AddInputConnection is a public interface provided by vtkAlgorithm. We can use it to combine multiple input sources to get a final 3D model with some special algorithm class.
The following example has two VTK algorithm classes which show us the multiple source connections.

int main()
{
    vtkSmartPointer<vtkSphereSource> sphereSource =
        vtkSmartPointer<vtkSphereSource>::New();
    vtkSmartPointer<vtkConeSource> cone =
        vtkSmartPointer<vtkConeSource>::New();
    vtkSmartPointer<vtkGlyph3D> glyph =
        vtkSmartPointer<vtkGlyph3D>::New();
    //glyph->SetInputConnection(sphereSource->GetOutputPort());
    //glyph->SetSourceConnection(cone->GetOutputPort());
    glyph->AddInputConnection(0, sphereSource->GetOutputPort());
    glyph->AddInputConnection(1, cone->GetOutputPort());
    glyph->SetVectorModeToUseNormal();
    glyph->SetScaleModeToScaleByVector();
    glyph->SetScaleFactor(0.25);

    vtkSmartPointer<vtkAppendPolyData> apd =
      vtkSmartPointer<vtkAppendPolyData>::New();
    apd->AddInputConnection(glyph->GetOutputPort());
    //apd->AddInputConnection(sphereSource->GetOutputPort());

    vtkSmartPointer<vtkPolyDataMapper> maceMapper =
      vtkSmartPointer<vtkPolyDataMapper>::New();
    maceMapper->SetInputConnection(apd->GetOutputPort());

    vtkSmartPointer<vtkLODActor> maceActor =
      vtkSmartPointer<vtkLODActor>::New();
    maceActor->SetMapper(maceMapper);
    maceActor->VisibilityOn();
    maceActor->SetPosition(1,1,1);

    vtkSmartPointer<vtkRenderer> renderer =
      vtkSmartPointer<vtkRenderer>::New();
    vtkSmartPointer<vtkRenderWindow> renWin =
      vtkSmartPointer<vtkRenderWindow>::New();
    renWin->AddRenderer(renderer);

    vtkSmartPointer<vtkRenderWindowInteractor> iren =
      vtkSmartPointer<vtkRenderWindowInteractor>::New();
    iren->SetRenderWindow(renWin);

    renderer->AddActor(maceActor);
    renderer->SetBackground(0.1, 0.2, 0.4);
    renWin->SetSize(300, 300);
    iren->Initialize();
    renWin->Render();
    iren->Start();
    return 0;
}



SetSourceConnection is equivalent to SetInputConnection(1, id, outputPort) at the above example code.
We can get a mace model if use vtkAppendPolyData object to add glyph and sphere.

    vtkSmartPointer<vtkAppendPolyData> apd =
      vtkSmartPointer<vtkAppendPolyData>::New();
    apd->AddInputConnection(glyph->GetOutputPort());
    apd->AddInputConnection(sphereSource->GetOutputPort());




0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Content Summary
: Input your strings, the tool can get a brief summary of the content for you.

X
0
Would love your thoughts, please comment.x
()
x