1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 // File: VISU_PipeLine.hxx
24 // Author: Alexey PETROV
27 #include "VISU_Convertor.hxx"
28 #include "VISU_MeshPL.hxx"
29 #include "VISU_ScalarMapPL.hxx"
30 #include "VISU_IsoSurfacesPL.hxx"
31 #include "VISU_CutPlanesPL.hxx"
32 #include "VISU_CutLinesPL.hxx"
33 #include "VISU_DeformedShapePL.hxx"
34 #include "VISU_VectorsPL.hxx"
35 #include "VISU_StreamLinesPL.hxx"
37 typedef VISU_ScalarMapPL TPresent;
39 #include <vtkUnstructuredGrid.h>
40 #include <vtkDataSetMapper.h>
42 #include <vtkRenderWindowInteractor.h>
43 #include <vtkRenderWindow.h>
44 #include <vtkRenderer.h>
45 #include <vtkCamera.h>
48 #include "utilities.h"
52 static int isOnlyMesh = false;
54 int main(int argc, char** argv){
57 vtkRenderWindow *renWin = vtkRenderWindow::New();
58 vtkRenderer *ren = vtkRenderer::New();
59 renWin->AddRenderer(ren);
60 ren->GetActiveCamera()->ParallelProjectionOn();
61 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
62 iren->SetRenderWindow(renWin);
63 VISU_Convertor* aConvertor = CreateConvertor(argv[1]);
64 const VISU::TMeshMap& aMeshMap = aConvertor->GetMeshMap();
65 VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
66 if(aMeshMapIter == aMeshMap.end()) return 0;
67 const string& aMeshName = aMeshMapIter->first;
68 const VISU::TMesh& aMesh = aMeshMapIter->second;
69 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap;
70 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
72 const VISU::TEntity& anEntity = VISU::CELL_ENTITY;
73 aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity);
74 vtkUnstructuredGrid* aDataSet = aConvertor->GetMeshOnEntity(aMeshName,anEntity);
76 VISU_MeshPL* aPresent = VISU_MeshPL::New();
77 aPresent->SetInput(aDataSet);
80 vtkActor* aActor = vtkActor::New();
81 aActor->SetMapper(aPresent->GetMapper());
82 aActor->GetProperty()->SetRepresentation(VTK_WIREFRAME);
83 //ren->ResetCameraClippingRange();
85 ren->AddActor(aActor);
92 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
93 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++) {
94 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
95 const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
96 const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap;
97 VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
98 for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
99 const VISU::TField& aField = aFieldMapIter->second;
100 if(aField.myNbComp == 1) continue;
101 const string& aFieldName = aFieldMapIter->first;
102 const VISU::TField::TValField& aValField = aField.myValField;
103 VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin();
104 if(aValFieldIter == aValField.end()) return 0;
105 int aTimeStamp = aValFieldIter->first;
106 vtkUnstructuredGrid* aDataSet = aConvertor->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
108 TPresent* aPresent = TPresent::New();
109 aPresent->SetInput(aDataSet);
112 aPresent->SetSourceRange();
113 //aPresent->SetPartDefault(0);
114 //aPresent->SetScalarMin(0.01);
115 //aPresent->SetScaling(VTK_SCALE_LOG10);
118 vtkActor* anActor = vtkActor::New();
119 anActor->SetMapper(aPresent->GetMapper());
121 VISU_ScalarBarActor * aScalarBar = VISU_ScalarBarActor::New();
122 aScalarBar->SetLookupTable(aPresent->GetBarTable());
126 ren->AddActor(anActor);
127 ren->AddActor2D(aScalarBar);
128 ren->ResetCameraClippingRange();
136 }catch(std::exception& exc){
137 MESSAGE("Follow exception was occured :\n"<<exc.what());
139 MESSAGE("Unknown exception was occured in VISU_Convertor_impl");