Back to index

salome-paravis  6.5.0
TestMedReader.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "vtkActor.h"
00021 #include "vtkCamera.h"
00022 #include "vtkProperty.h"
00023 #include "vtkCompositePolyDataMapper.h"
00024 #include "vtkRenderer.h"
00025 #include "vtkRenderWindow.h"
00026 #include "vtkRenderWindowInteractor.h"
00027 #include "vtkCylinderSource.h"
00028 #include "vtkMedReader.h"
00029 #include "vtkDataObject.h"
00030 #include "vtkDataSetAttributes.h"
00031 #include "vtkPolyDataNormals.h"
00032 #include "vtkMedReader.h"
00033 
00034 #include "vtkTestUtilities.h"
00035 #include "vtkRegressionTestImage.h"
00036 
00037 int main(int argc, char *argv[])
00038 {
00039   vtkMedReader* reader = vtkMedReader::New();
00040   reader->SetFileName(argv[1]);
00041   reader->Update();
00042 
00043   vtkCompositePolyDataMapper *mapper = vtkCompositePolyDataMapper::New();
00044   mapper->SetInputConnection(reader->GetOutputPort());
00045 
00046   vtkActor *actor = vtkActor::New();
00047   actor->SetMapper(mapper);
00048 
00049   vtkRenderer *renderer = vtkRenderer::New();
00050   renderer->AddActor(actor);
00051   renderer->SetBackground(0.5, 0.5, 0.5);
00052 
00053   vtkRenderWindow *renWin = vtkRenderWindow::New();
00054   renWin->AddRenderer(renderer);
00055 
00056   vtkRenderWindowInteractor *interactor = vtkRenderWindowInteractor::New();
00057   interactor->SetRenderWindow(renWin);
00058 
00059   renWin->SetSize(400,400);
00060   renWin->Render();
00061   interactor->Initialize();
00062   renderer->ResetCamera();
00063   renWin->Render();
00064   renderer->ResetCamera();
00065 
00066   int retVal = vtkRegressionTestImageThreshold(renWin,18);
00067   if( retVal == vtkRegressionTester::DO_INTERACTOR)
00068     {
00069     interactor->Start();
00070     }
00071 
00072   reader->Delete();
00073   mapper->Delete();
00074   actor->Delete();
00075   renderer->Delete();
00076   renWin->Delete();
00077   interactor->Delete();
00078 
00079   return !retVal;
00080 }