/* This file is part of Lemma, a geophysical modelling and inversion API. * More information is available at http://lemmasoftware.org */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /** * @file * @date 07/29/2014 02:01:21 PM * @version $Id$ * @author Trevor Irons (ti) * @email Trevor.Irons@xri-geo.com * @copyright Copyright (c) 2014, XRI Geophysics, LLC * @copyright Copyright (c) 2014, Trevor Irons */ #include #include #include #include #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { vtkSmartPointer input1 = vtkSmartPointer::New(); vtkSmartPointer input2 = vtkSmartPointer::New(); if(argc == 1) //command line arguments not specified { vtkSmartPointer sphereSource = vtkSmartPointer::New(); sphereSource->SetCenter(5,0,0); sphereSource->Update(); input1->ShallowCopy(sphereSource->GetOutput()); vtkSmartPointer coneSource = vtkSmartPointer::New(); coneSource->Update(); input2->ShallowCopy(coneSource->GetOutput()); } else { if(argc != 3) { std::cout << "argc = " << argc << std::endl; std::cout << "Required arguments: File1 File2" << std::endl; return EXIT_FAILURE; } std::string inputFilename1 = argv[1]; std::string inputFilename2 = argv[2]; vtkSmartPointer reader1 = vtkSmartPointer::New(); reader1->SetFileName(inputFilename1.c_str()); reader1->Update(); input1->ShallowCopy(reader1->GetOutput()); vtkSmartPointer reader2 = vtkSmartPointer::New(); reader2->SetFileName(inputFilename2.c_str()); reader2->Update(); input2->ShallowCopy(reader2->GetOutput()); } //Append the two meshes vtkSmartPointer appendFilter = vtkSmartPointer::New(); #if VTK_MAJOR_VERSION <= 5 appendFilter->AddInputConnection(input1->GetProducerPort()); appendFilter->AddInputConnection(input2->GetProducerPort()); #else appendFilter->AddInputData(input1); appendFilter->AddInputData(input2); #endif appendFilter->Update(); // Remove any duplicate points. vtkSmartPointer cleanFilter = vtkSmartPointer::New(); cleanFilter->SetInputConnection(appendFilter->GetOutputPort()); cleanFilter->Update(); //Create a mapper and actor vtkSmartPointer mapper = vtkSmartPointer::New(); mapper->SetInputConnection(cleanFilter->GetOutputPort()); vtkSmartPointer actor = vtkSmartPointer::New(); actor->SetMapper(mapper); //Create a renderer, render window, and interactor vtkSmartPointer renderer = vtkSmartPointer::New(); vtkSmartPointer renderWindow = vtkSmartPointer::New(); renderWindow->AddRenderer(renderer); vtkSmartPointer renderWindowInteractor = vtkSmartPointer::New(); renderWindowInteractor->SetRenderWindow(renderWindow); //Add the actors to the scene renderer->AddActor(actor); renderer->SetBackground(.3, .2, .1); // Background color dark red //Render and interact renderWindow->Render(); renderWindowInteractor->Start(); return EXIT_SUCCESS; }