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