Salome HOME
c09963e7136a99eaf9b9e43719bcc7bfad3b359a
[modules/visu.git] / src / PIPELINE / VISUPipeLine.cxx
1 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  VISU OBJECT : interactive object for VISU entities implementation
24 // File:    VISU_PipeLine.hxx
25 // Author:  Alexey PETROV
26 // Module : VISU
27 // Salome includes
28 //
29 #include "VISU_Convertor.hxx"
30 #include "VISU_ConvertorUtils.hxx"
31
32 #include "VISU_MeshPL.hxx"
33 #include "VISU_ScalarMapPL.hxx"
34 #include "VISU_IsoSurfacesPL.hxx"
35 #include "VISU_CutPlanesPL.hxx"
36 #include "VISU_CutLinesPL.hxx"
37 #include "VISU_ColoredPL.hxx"
38 #include "VISU_DeformedShapePL.hxx"
39 #include "VISU_VectorsPL.hxx"
40 #include "VISU_StreamLinesPL.hxx"
41 #include "VISU_GaussPointsPL.hxx"
42 #include "VISU_DeformedShapeAndScalarMapPL.hxx"
43 #include "VISU_Plot3DPL.hxx"
44
45 #include "VISU_ScalarBarActor.hxx"
46 #include "VISU_OpenGLPointSpriteMapper.hxx"
47 #include "VTKViewer_GeometryFilter.h"
48
49 #include "VISU_ElnoDisassembleFilter.hxx"
50 #include "VISU_ElnoAssembleFilter.hxx"
51
52 //typedef VISU_CutPlanesPL TPresent;
53 //typedef VISU_ScalarMapPL TPresent;
54 typedef VISU_CutLinesPL TPresent;
55
56 // VTK includes
57 #include <vtkShrinkFilter.h>
58 #include <vtkPointLocator.h>
59 #include <vtkEDFCutter.h>
60 #include <vtkPlane.h>
61 #include <vtkWarpVector.h>
62 #include <vtkScalarBarActor.h>
63 #include <vtkScalarBarWidget.h>
64 #include <vtkMaskPoints.h>
65 #include <vtkUnstructuredGridReader.h>
66 #include <vtkUnstructuredGrid.h>
67 #include <vtkDataSetMapper.h>
68 #include <vtkInteractorStyleTrackballCamera.h>
69 #include <vtkRenderWindowInteractor.h>
70 #include <vtkRenderWindow.h>
71 #include <vtkImageData.h>
72 #include <vtkCellData.h>
73 #include <vtkRenderer.h>
74 #include <vtkCamera.h>
75 #include <vtkActor.h>
76 #include <vtk3DWidget.h>
77 #include <vtkProperty.h>
78
79 //RKV:Begin
80 #include <vtkLookupTable.h>
81 #include <vtkIntArray.h>
82 #include <vtkPointData.h>
83 #include <vtkCellData.h>
84 #include <vtkPointSet.h>
85 #include <vtkPolyData.h>
86 #include <vtkXYPlotActor.h>
87 #include <vtkProperty2D.h>
88 #include <vtkTextProperty.h>
89
90 #include <vtkXYPlotWidget.h>
91 #include <vtkScalarBarWidget.h>
92 #include <vtkScalarBarActor.h>
93 #include <vtkMatrix4x4.h>
94
95 /*#include <vtkBarChartActor.h>
96 #include <vtkFloatArray.h>
97 #include <vtkDataObject.h>
98 #include <vtkFieldData.h>
99 #include <vtkMath.h>
100 #include <vtkTextProperty.h>
101 #include <vtkPolyData.h>
102 #include <vtkPoints.h>
103 #include <vtkIdList.h>
104 #include <vtkProperty2D.h>
105 #include <vtkLegendBoxActor.h>
106 #include <vtkTestUtilities.h>
107 #include <vtkRegressionTestImage.h>
108 */
109 //RKV:End
110
111 #include "utilities.h"
112
113 static int isOnlyMesh = false;
114
115 void PrintMissing(){
116   MESSAGE(std::endl << "VISUPipeLine : missing operand after `VISUPipeLine'" <<
117           std::endl << "VISUPipeLine : Try `VISUPipeLine -h' for more information.");
118 }
119
120 void PrintHelp(){
121   MESSAGE_ADD(std::endl << " Usage: VISUPipeLine filename meshname fieldname [timestamp] [component] " <<
122               std::endl << "filename   - Name of the med file.                                       " <<
123               std::endl << "meshname   - Name of the mesh in the med file.                           " <<
124               std::endl << "fieldname  - Name of the mesh field.                                     " <<
125               std::endl << "timestamp  - Number of the time stamp in the field 1,2,3 ... (optionally)" <<
126               std::endl << "             by default used first time stamp.                           " <<
127               std::endl << "component  - Number of the component in the field 0,1,2,3 ...(optionally)" <<
128               std::endl << "             0 - modulus, 1 - first component, 2 - second component, ... " <<
129               std::endl << "             by default used modulus.                                    ");
130 }
131
132 void PrintErr(){
133   MESSAGE("***************************ERROR*****************************************");
134 }
135 //#define _DEBUG_ID_MAPPING_
136
137 //RKV:Begin
138 /*
139 vtkActor* barChartActor()
140 {
141   int numTuples = 6;
142
143   vtkFloatArray *bitter = vtkFloatArray::New();
144   bitter->SetNumberOfTuples(numTuples);
145   
146   for (int i=0; i<numTuples; i++)
147     {
148     bitter->SetTuple1(i, vtkMath::Random(7,100));
149     }
150
151   vtkDataObject *dobj = vtkDataObject::New();
152   dobj->GetFieldData()->AddArray(bitter);
153   
154   vtkBarChartActor *actor = vtkBarChartActor::New();
155   actor->SetInput(dobj);
156   actor->SetTitle("Bar Chart");
157   actor->GetPositionCoordinate()->SetValue(0.05,0.05,0.0);
158   actor->GetPosition2Coordinate()->SetValue(0.95,0.85,0.0);
159   actor->GetProperty()->SetColor(1,1,1);
160   actor->GetLegendActor()->SetNumberOfEntries(numTuples);
161   for (int i=0; i<numTuples; i++)
162     {
163     double red=vtkMath::Random(0,1);
164     double green=vtkMath::Random(0,1);
165     double blue=vtkMath::Random(0,1);
166     actor->SetBarColor(i,red,green,blue);
167     }
168   actor->SetBarLabel(0,"oil");
169   actor->SetBarLabel(1,"gas");
170   actor->SetBarLabel(2,"water");
171   actor->SetBarLabel(3,"snake oil");
172   actor->SetBarLabel(4,"tequila");
173   actor->SetBarLabel(5,"beer");
174   actor->LegendVisibilityOn();
175
176   // Set text colors (same as actor for backward compat with test)
177   actor->GetTitleTextProperty()->SetColor(1,1,0);
178   actor->GetLabelTextProperty()->SetColor(1,0,0);
179   return actor;
180 }
181 */
182 //RKV:End
183 //----------------------------------------------------------------------------
184 template<class TPipeLine>
185 VISU_ColoredPL*
186 CreateColoredPL(VISU_Convertor* theConvertor,
187                 const std::string& theMeshName,
188                 const VISU::TEntity& theEntity,
189                 const std::string& theFieldName,
190                 int theTimeStampNumber);
191
192
193 //----------------------------------------------------------------------------
194 template<>
195 VISU_ColoredPL*
196 CreateColoredPL<VISU_GaussPointsPL>(VISU_Convertor* theConvertor,
197                                     const std::string& theMeshName,
198                                     const VISU::TEntity& theEntity,
199                                     const std::string& theFieldName,
200                                     int theTimeStampNumber)
201 {
202   VISU_GaussPointsPL* aPresent = VISU_GaussPointsPL::New();
203   VISU::PGaussPtsIDMapper aGaussPtsIDMapper = 
204     theConvertor->GetTimeStampOnGaussPts(theMeshName,
205                                          theEntity,
206                                          theFieldName,
207                                          theTimeStampNumber);
208   aPresent->SetGaussPtsIDMapper(aGaussPtsIDMapper);
209
210   char aMainTexture[80];
211   strcpy( aMainTexture, getenv( "VISU_ROOT_DIR" ) );
212   strcat( aMainTexture, "/share/salome/resources/visu/sprite_texture.bmp" );
213   
214   char anAlphaTexture[80];
215   strcpy( anAlphaTexture, getenv( "VISU_ROOT_DIR" ) );
216   strcat( anAlphaTexture, "/share/salome/resources/visu/sprite_alpha.bmp" );
217   
218   vtkSmartPointer<vtkImageData> aTextureValue = 
219     VISU_GaussPointsPL::MakeTexture( aMainTexture, anAlphaTexture );
220   aPresent->SetImageData( aTextureValue.GetPointer() );
221
222   aPresent->Update();
223
224 #ifdef _DEBUG_ID_MAPPING_
225   vtkDataSet* aDataSet = aPresent->GetOutput();
226   aDataSet->Update();
227   int aNbCells = aDataSet->GetNumberOfCells();
228   cout<<"aNbCells = "<<aNbCells<<endl;
229   for(int anCellId = 0; anCellId < aNbCells; anCellId++){
230     vtkIdType anObjID = aPresent->GetNodeObjID(anCellId);
231     vtkIdType aVtkID = aPresent->GetNodeVTKID(anObjID);
232     cout<<anObjID<<"; "<<aVtkID<<"; - ";
233     vtkFloatingPointType* aCoord = aPresent->GetNodeCoord(anObjID);
234     cout<<aCoord[0]<<"; "<<aCoord[1]<<"; "<<aCoord[2]<<endl;
235   }
236 #endif
237   return aPresent;
238 }
239
240 //----------------------------------------------------------------------------
241 template<class TPipeLine>
242 VISU_ColoredPL*
243 CreateColoredPL(VISU_Convertor* theConvertor,
244                 const std::string& theMeshName,
245                 const VISU::TEntity& theEntity,
246                 const std::string& theFieldName,
247                 int theTimeStampNumber)
248 {
249   TPipeLine* aPresent = TPipeLine::New();
250   VISU::PUnstructuredGridIDMapper anUnstructuredGridIDMapper = 
251     theConvertor->GetTimeStampOnMesh(theMeshName,
252                                      theEntity,
253                                      theFieldName,
254                                      theTimeStampNumber);
255   aPresent->SetUnstructuredGridIDMapper(anUnstructuredGridIDMapper);
256
257   vtkFloatingPointType aRange[] = { 4, 5 };
258 cout << "before filter limits set" << endl;
259       vtkObject::GlobalWarningDisplayOn();
260       aPresent->DebugOn();
261   aPresent->SetScalarFilterRange( aRange );
262   aPresent->UseScalarFiltering( true );
263 cout << "after filter set" << endl;
264
265   //aPresent->ClearGeometry();
266   //{
267   //  VISU::PUnstructuredGridIDMapper anIDMapper = 
268   //    theConvertor->GetMeshOnGroup(theMeshName,
269   //                               "groupe1");
270   //  aPresent->AddGeometry(anIDMapper->GetOutput());
271   //}
272   //{
273   //  VISU::PUnstructuredGridIDMapper anIDMapper = 
274   //    theConvertor->GetMeshOnGroup(theMeshName,
275   //                               "TUBEH                                                                           ");
276   //  aPresent->AddGeometry(anIDMapper->GetOutput());
277   //}
278   //{
279   //  VISU::PUnstructuredGridIDMapper anIDMapper = 
280   //    theConvertor->GetMeshOnGroup(theMeshName,
281   //                               "STRI                                                                            ");
282   //  aPresent->AddGeometry(anIDMapper->GetOutput());
283   //}
284   aPresent->Update();
285 cout << "after update" << endl;
286   return aPresent;
287 }
288
289
290 //----------------------------------------------------------------------------
291 int
292 main(int argc, char** argv)
293 {
294   try{
295     if(argc == 1){
296       PrintMissing();
297       return 1;
298     }
299     if(argc == 2 && !strcmp(argv[1],"-h")) {
300       PrintHelp();
301       return 1;
302     }
303     
304     char* aFileName =0;
305     char* aMeshName =0;
306     char* aFieldName =0;
307     int aTimeStampNumber = 1;
308     int aComponentNumber  = 0;
309     bool allInit = false;
310     bool isMeshOk = false;
311     bool isFieldOk = false;
312     bool isTimeStampOk = false;
313     bool isComponentOk = false;
314
315     if(argc == 4 ){
316       aFileName = new char[static_cast<int>(strlen(argv[1])) + 1];
317       aMeshName = new char[static_cast<int>(strlen(argv[2])) + 1];
318       aFieldName = new char[static_cast<int>(strlen(argv[3])) + 1];
319       
320       strcpy(aFileName,argv[1]);
321       strcpy(aMeshName,argv[2]);
322       strcpy(aFieldName,argv[3]);
323       
324       allInit = true;
325     }
326
327     if(argc == 5) {
328       aFileName = new char[static_cast<int>(strlen(argv[1])) + 1];
329       aMeshName = new char[static_cast<int>(strlen(argv[2])) + 1];
330       aFieldName = new char[static_cast<int>(strlen(argv[3])) + 1];
331       
332       strcpy(aFileName,argv[1]);
333       strcpy(aMeshName,argv[2]);
334       strcpy(aFieldName,argv[3]);
335
336       aTimeStampNumber = atoi(argv[4]);
337       allInit = true;
338     }
339     
340     if(argc == 6) {
341       aFileName = new char[static_cast<int>(strlen(argv[1])) + 1];
342       aMeshName = new char[static_cast<int>(strlen(argv[2])) + 1];
343       aFieldName = new char[static_cast<int>(strlen(argv[3])) + 1];
344       
345       strcpy(aFileName,argv[1]);
346       strcpy(aMeshName,argv[2]);
347       strcpy(aFieldName,argv[3]);
348
349       aTimeStampNumber = atoi(argv[4]);
350       aComponentNumber = atoi(argv[5]);
351       allInit = true;
352     }
353     
354
355
356     if(allInit){
357             
358       vtkRenderWindow *aWindow = vtkRenderWindow::New();
359       vtkRenderer *aRenderer = vtkRenderer::New();
360
361       aWindow->AddRenderer(aRenderer);
362       aRenderer->GetActiveCamera()->ParallelProjectionOn();
363
364       vtkRenderWindowInteractor *anInteractor = vtkRenderWindowInteractor::New();
365       anInteractor->SetRenderWindow(aWindow);
366       aWindow->Delete();
367
368       vtkInteractorStyle* aStyle = vtkInteractorStyleTrackballCamera::New();
369       anInteractor->SetInteractorStyle(aStyle);
370       aStyle->Delete();
371
372       VISU_Convertor* aConvertor = CreateConvertor(aFileName);
373       aConvertor->BuildEntities();
374       aConvertor->BuildGroups();
375       aConvertor->BuildFields();
376       aConvertor->BuildMinMax();
377       const VISU::TMeshMap& aMeshMap = aConvertor->GetMeshMap();
378       VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
379       if(aMeshMapIter == aMeshMap.end()) return 0;
380       const std::string& aMeshName = aMeshMapIter->first;
381       const VISU::PMesh aMesh = aMeshMapIter->second;
382       const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
383       VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
384       if(isOnlyMesh){
385         const VISU::TEntity& anEntity = VISU::CELL_ENTITY;
386         aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity);
387
388         VISU::PNamedIDMapper anIDMapper = 
389           aConvertor->GetMeshOnEntity(aMeshName,anEntity);
390
391         VISU_MeshPL* aPresent = VISU_MeshPL::New();
392         aPresent->SetUnstructuredGridIDMapper(anIDMapper);
393
394         vtkActor* aActor = vtkActor::New();
395         aActor->SetMapper(aPresent->GetMapper());
396         aActor->GetProperty()->SetRepresentation(VTK_WIREFRAME);
397         //aRenderer->ResetCameraClippingRange();
398
399         aRenderer->AddActor(aActor);
400
401         aWindow->Render();
402         anInteractor->Start();
403         return 0;
404       }
405       //Import fields
406       aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
407       for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++) {
408         const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
409         const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
410         const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
411         VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
412         for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
413           const VISU::PField aField = aFieldMapIter->second;
414 //        if(aField->myNbComp == 1) 
415 //          continue;
416           const std::string& aFieldName = aFieldMapIter->first;
417           const VISU::TValField& aValField = aField->myValField;
418           VISU::TValField::const_reverse_iterator aValFieldIter = aValField.rbegin();
419           if(aValFieldIter == aValField.rend()) return 0;
420           int aTimeStamp = aValFieldIter->first;
421
422           vtkActor* anActor = vtkActor::New();
423           VISU_ColoredPL* aPresent = NULL;
424           if(anEntity == VISU::NODE_ENTITY){
425             aPresent = CreateColoredPL<TPresent>(aConvertor,
426                                                  aMeshName,
427                                                  anEntity,
428                                                  aFieldName,
429                                                  aTimeStamp);
430
431             anActor->SetMapper(aPresent->GetMapper());
432           }else{
433             continue;
434             aPresent = CreateColoredPL<TPresent>(aConvertor,
435                                                  aMeshName,
436                                                  anEntity,
437                                                  aFieldName,
438                                                  aTimeStamp);
439
440             VTKViewer_GeometryFilter* aGeometryFilter = VTKViewer_GeometryFilter::New();
441             aGeometryFilter->SetInput(aPresent->GetOutput());
442             aGeometryFilter->SetInside(true);
443
444             vtkMaskPoints* aMaskPoints = vtkMaskPoints::New();
445             aMaskPoints->SetInput(aGeometryFilter->GetOutput());
446             aMaskPoints->SetGenerateVertices(true);
447             aMaskPoints->SetOnRatio(1);
448
449             VISU_OpenGLPointSpriteMapper* aMapper = VISU_OpenGLPointSpriteMapper::New();
450             aMapper->SetAverageCellSize( VISU_DeformedShapePL::GetScaleFactor( aPresent->GetOutput() ) );
451   
452             char aMainTexture[80];
453             strcpy( aMainTexture, getenv( "VISU_ROOT_DIR" ) );
454             strcat( aMainTexture, "/share/salome/resources/visu/sprite_texture.vti" );
455             
456             char anAlphaTexture[80];
457             strcpy( anAlphaTexture, getenv( "VISU_ROOT_DIR" ) );
458             strcat( anAlphaTexture, "/share/salome/resources/visu/sprite_alpha.vti" );
459             
460             vtkSmartPointer<vtkImageData> aTextureValue = 
461               VISU_GaussPointsPL::MakeTexture( aMainTexture, anAlphaTexture );
462             aMapper->SetImageData( aTextureValue.GetPointer() );
463
464             //vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New();
465             aMapper->SetLookupTable(aPresent->GetMapperTable());
466             aMapper->SetUseLookupTableScalarRange(true);
467             aMapper->SetColorModeToMapScalars();
468             aMapper->SetScalarVisibility(true);
469
470             aMapper->SetInput(aMaskPoints->GetOutput());
471             aGeometryFilter->Delete();
472
473             anActor->SetMapper(aMapper);
474             aMapper->Delete();
475           }
476
477
478
479
480
481 //RKV:Begin
482   vtkLookupTable* lut = vtkLookupTable::New();
483   int nbColors = aPresent->GetNbColors();
484   lut->SetNumberOfTableValues(nbColors);
485   vtkDataArray* dataArr;
486     if(VISU::IsDataOnCells(aPresent->GetInput())) {
487         dataArr = aPresent->GetInput()->GetCellData()->GetScalars();
488     } else {
489         dataArr = aPresent->GetInput()->GetPointData()->GetScalars();
490     }
491   vtkFloatingPointType aRange[2];
492   dataArr->GetRange(aRange);
493   MSG(true, "Range[0]: "<<aRange[0]);
494   MSG(true, "Range[1]: "<<aRange[1]);
495
496   lut->SetTableRange(aRange);
497   lut->Build();
498     MSG(true, "1\n");
499   vtkIntArray* distr = vtkIntArray::New();
500   distr->SetNumberOfValues(nbColors);
501     MSG(true, "Number of colors: "<<nbColors);
502   distr->FillComponent(0, 0.);
503     MSG(true, "2\n");
504   int aNbVals = dataArr->GetNumberOfTuples();
505   int idx = 0, cnt = 0;
506   
507     MSG(true, "3\n");
508   for(vtkIdType aValId = 0; aValId < aNbVals; aValId++){
509 //    MSG(true, "Value: "<< *(dataArr->GetTuple(aValId)));
510         idx = lut->GetIndex(*(dataArr->GetTuple(aValId)));
511 //    MSG(true, "Value index "<<idx);
512         cnt = distr->GetValue(idx);
513         distr->SetValue(idx, cnt + 1);
514   }
515     MSG(true, "4\n");
516   distr->Modified();
517   double range[2];
518   distr->GetRange(range);
519   MSG(true, "DistrRange[0]: " << range[0]);
520   MSG(true, "DistrRange[1]: " << range[1]);
521     MSG(true, "5\n");
522 //  vtkPoints* points = vtkPoints::New();
523 //  aNbVals = distr->GetNumberOfTuples();
524 //  points->Allocate(aNbVals);
525 //  double x[3] = {0., 0., 0.};
526 /*  for(vtkIdType aValId = 0; aValId < aNbVals; aValId++){
527         x[0] = aValId;
528         points->InsertPoint(aValId, x);
529 *///    MSG(true, "Inserted point "<<aValId);
530 //    MSG(true, ": "<<distr->GetValue(aValId));
531 //  }
532 //  points->SetData(distr);
533   
534 /*  vtkPointSet* pset = vtkPolyData::New();
535   pset->SetPoints(points);
536   pset->GetPointData()->SetScalars(distr);
537 */    
538   vtkDataObject *dobj = vtkDataObject::New();
539   dobj->GetFieldData()->AddArray(distr);
540   
541   vtkXYPlotActor* xyplot = vtkXYPlotActor::New();
542 //  xyplot->AddInput(pset);
543   xyplot->AddDataObjectInput(dobj);
544   xyplot->GetPositionCoordinate()->SetValue(0.0, 0.67, 0);
545   xyplot->GetPosition2Coordinate()->SetValue(1.0, 0.33, 0); // #relative to Position
546   xyplot->SetXValuesToIndex();
547 //  xyplot->SetXValuesToNormalizedArcLength();
548 //  xyplot->SetXValuesToArcLength();
549 //  xyplot->SetNumberOfXLabels(0);
550   xyplot->SetTitle("");
551   xyplot->SetXTitle("");
552   xyplot->SetYTitle("Distribution");
553 //  xyplot->ReverseYAxisOn();
554 //  xyplot->SetDataObjectPlotModeToRows();
555   xyplot->SetLabelFormat("%.0f");
556   xyplot->SetXRange(0, nbColors-1);
557   xyplot->SetYRange(range[0], range[1]);
558 /*  int ny = floor(fabs(range[1] - range[0]));
559     MSG(true, "ny = "<<ny);
560     MSG(true, "nbYLabels = "<<xyplot->GetNumberOfYLabels());
561   if (ny < xyplot->GetNumberOfYLabels()) {
562     MSG(true, "5.1");
563         xyplot->SetNumberOfYLabels(ny);
564     MSG(true, "nbYLabels = "<<xyplot->GetNumberOfYLabels());
565   }
566 */  xyplot->GetProperty()->SetColor(1, 1, 1);
567   xyplot->GetProperty()->SetLineWidth(2);
568   xyplot->GetProperty()->SetDisplayLocationToForeground();
569 /*  vtkMatrix4x4 *m = vtkMatrix4x4::New();
570     MSG(true, "5.1\n");
571   m->Zero();
572     MSG(true, "5.2\n");
573   m->SetElement(0, 1, 1);
574   m->SetElement(1, 0, -1);
575   m->SetElement(2, 2, 1);
576   m->SetElement(3, 3, 1);
577     MSG(true, "5.3\n");
578   xyplot->PokeMatrix(m);
579 */  //# Set text prop color (same color for backward compat with test)
580   //# Assign same object to all text props
581   vtkTextProperty* tprop;
582   tprop = xyplot->GetTitleTextProperty();
583   tprop->SetColor(xyplot->GetProperty()->GetColor());
584   xyplot->SetAxisTitleTextProperty(tprop);
585   xyplot->SetAxisLabelTextProperty(tprop);
586   
587 //RKV:End  
588   
589
590     MSG(true, "6\n");
591
592 /*{
593   vtkXYPlotWidget* aWidget = vtkXYPlotWidget::New();
594   aWidget->SetInteractor( anInteractor );
595   aWidget->SetXYPlotActor( xyplot );
596   aWidget->SetEnabled( 1 );
597 }*/
598
599
600       vtkObject::GlobalWarningDisplayOn();
601
602           VISU_ScalarBarActor * aScalarBar = VISU_ScalarBarActor::New();
603           //vtkScalarBarActor * aScalarBar = vtkScalarBarActor::New();
604           aPresent->SetNbColors(5);
605           aPresent->DebugOn();
606           aPresent->Update();
607           aScalarBar->SetLookupTable(aPresent->GetBarTable());
608           aScalarBar->DebugOn();
609           aScalarBar->SetDistribution(aPresent->GetDistribution());
610           aScalarBar->DistributionVisibilityOn();
611 //        aScalarBar->SetOrientationToHorizontal();
612 //        aScalarBar->GetPositionCoordinate()->SetValue(.1, .6, 0);
613 //        aScalarBar->GetPosition2Coordinate()->SetValue(.8, .3, 0);
614
615 /*{
616   vtkScalarBarWidget* aWidget = vtkScalarBarWidget::New();
617   aWidget->SetInteractor( anInteractor );
618   aWidget->SetScalarBarActor( aScalarBar );
619   aWidget->SetEnabled( 1 );
620 }
621 */
622           aRenderer->AddActor(anActor);
623 //        aRenderer->AddActor2D(xyplot); //RKV
624           aRenderer->AddActor2D(aScalarBar);
625           
626           //aRenderer->AddActor2D(barChartActor()); //RKV
627
628           aWindow->Render();
629           aRenderer->ResetCamera();
630
631           anInteractor->Start();
632           return 0;
633         }
634       }
635     }
636     else{
637       PrintMissing();
638       return 1;
639     }
640
641     if(!isMeshOk) {
642       PrintErr();
643       MESSAGE("Can not find mesh with name `"<<aMeshName<<"' in the file `"<<aFileName<<"'");
644       PrintErr();
645       return 1;
646     }
647     if(!isFieldOk) {
648       PrintErr();
649       MESSAGE("Can not find field with name `"<<aFieldName<<"' on the mesh `"<<aMeshName<<"'");
650       PrintErr();
651       return 1; 
652     }
653     if(!isComponentOk) {
654       PrintErr();
655       MESSAGE("Field field with name `"<<aFieldName<<"' containt less then `"<<aComponentNumber<<"' component(s).");
656       PrintErr();
657       return 1;
658     }
659     if(!isTimeStampOk) {
660       PrintErr();
661       MESSAGE("Can not find time stamp with number `"<<aTimeStampNumber<<"' on the field `"<<aFieldName<<"'");
662       PrintErr();
663     }
664   }catch(std::exception& exc){
665     MSG(true, "Follow exception was occured :\n"<<exc.what());
666   }catch(...){
667     MSG(true, "Unknown exception was occured in VISU_Convertor_impl");
668   }
669   return 1;
670 }