]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_CutLines_i.cc
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/visu.git] / src / VISU_I / VISU_CutLines_i.cc
1 //  VISU OBJECT : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  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 //  File   : VISU_PrsObject_i.cxx
24 //  Author : Alexey PETROV
25 //  Module : VISU
26
27 #include "VISU_CutLines_i.hh"
28 #include "VISU_Prs3dUtils.hh"
29 #include "VISU_Result_i.hh"
30
31 #include "VISU_Actor.h"
32 #include "VISU_CutLinesPL.hxx"
33 #include "VISU_Convertor.hxx"
34 #include "VISU_PipeLineUtils.hxx"
35
36 #include "SUIT_ResourceMgr.h"
37 #include "SALOME_Event.hxx"
38
39 #include <vtkAppendPolyData.h>
40
41 static vtkFloatingPointType EPS_machine = 1.0E-7;
42
43 #ifdef _DEBUG_
44 static int MYDEBUG = 0;
45 #else
46 static int MYDEBUG = 0;
47 #endif
48
49
50 //---------------------------------------------------------------
51 size_t
52 VISU::CutLines_i
53 ::IsPossible(Result_i* theResult, 
54              const std::string& theMeshName, 
55              VISU::Entity theEntity, 
56              const std::string& theFieldName, 
57              CORBA::Long theTimeStampNumber, 
58              bool theIsMemoryCheck)
59 {
60   return TSuperClass::IsPossible(theResult,
61                                  theMeshName,
62                                  theEntity,
63                                  theFieldName,
64                                  theTimeStampNumber,
65                                  theIsMemoryCheck);
66 }
67
68 //---------------------------------------------------------------
69 int VISU::CutLines_i::myNbPresent = 0;
70
71 //---------------------------------------------------------------
72 QString 
73 VISU::CutLines_i::GenerateName() 
74
75   return VISU::GenerateName("CutLines",myNbPresent++);
76 }
77
78 //---------------------------------------------------------------
79 const string VISU::CutLines_i::myComment = "CUTLINES";
80
81 //---------------------------------------------------------------
82 const char* 
83 VISU::CutLines_i
84 ::GetComment() const 
85
86   return myComment.c_str();
87 }
88
89 //----------------------------------------------------------------------------
90 const char*
91 VISU::CutLines_i
92 ::GetIconName()
93 {
94   if (!IsGroupsUsed())
95     return "ICON_TREE_CUT_LINES";
96   else
97     return "ICON_TREE_CUT_LINES_GROUPS";
98 }
99
100 //---------------------------------------------------------------
101 VISU::CutLines_i::
102 CutLines_i(EPublishInStudyMode thePublishInStudyMode) :
103   ColoredPrs3d_i(thePublishInStudyMode),
104   ScalarMap_i(thePublishInStudyMode),
105   myCutLinesPL(NULL)
106 {}
107
108
109 //---------------------------------------------------------------
110 void
111 VISU::CutLines_i
112 ::SameAs(const Prs3d_i* theOrigin)
113 {
114   TSuperClass::SameAs(theOrigin);
115
116   if(const CutLines_i* aPrs3d = dynamic_cast<const CutLines_i*>(theOrigin)){
117     CutLines_i* anOrigin = const_cast<CutLines_i*>(aPrs3d);
118     myUseAbsLength = anOrigin->IsUseAbsoluteLength();
119     CopyCurvesInverted(anOrigin->GetCurvesInverted());
120   }
121 }
122
123
124 //---------------------------------------------------------------
125 /*! Copy map to /a myMapCurvesInverted.
126  * \param theCurves - map
127  */
128 void 
129 VISU::CutLines_i
130 ::CopyCurvesInverted(const TCurvesInv& theCurves)
131 {
132   myMapCurvesInverted = theCurves;
133 }
134
135
136 //---------------------------------------------------------------
137 VISU::Storable* 
138 VISU::CutLines_i
139 ::Create(const std::string& theMeshName, 
140          VISU::Entity theEntity,
141          const std::string& theFieldName, 
142          CORBA::Long theTimeStampNumber)
143 {
144   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
145   SetUseAbsoluteLength( aResourceMgr->booleanValue( "VISU", "use_absolute_length", false ) );
146   SetAllCurvesInverted( aResourceMgr->booleanValue( "VISU", "invert_all_curves", false ) );
147   return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
148 }
149
150
151 //---------------------------------------------------------------
152 VISU::Storable* 
153 VISU::CutLines_i
154 ::Restore(SALOMEDS::SObject_ptr theSObject,
155           const Storable::TRestoringMap& theMap)
156 {
157   if(!TSuperClass::Restore(theSObject, theMap))
158     return NULL;
159
160   SetNbLines(VISU::Storable::FindValue(theMap,"myNbLines").toInt());
161   SetDisplacement(VISU::Storable::FindValue(theMap,"myDisplacement[0]").toDouble());
162   SetDisplacement2(VISU::Storable::FindValue(theMap,"myDisplacement[1]").toDouble());
163   SetOrientation(CutPlanes::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane[0]").toInt()),
164                  Storable::FindValue(theMap,"aRot[0][0]").toDouble(),
165                  Storable::FindValue(theMap,"aRot[0][1]").toDouble());
166   SetOrientation2(CutPlanes::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane[1]").toInt()),
167                   Storable::FindValue(theMap,"aRot[1][0]").toDouble(),
168                   Storable::FindValue(theMap,"aRot[1][1]").toDouble());
169   SetUseAbsoluteLength(VISU::Storable::FindValue(theMap,"myUseAbsLength").toInt());
170
171   if (VISU::Storable::FindValue(theMap,"myBasePlaneCondition").toInt())
172     SetDefault();
173   else
174     SetBasePlanePosition(VISU::Storable::FindValue(theMap,"myBasePlanePosition").toDouble());
175   
176   QStringList aPosList = QStringList::split("|",VISU::Storable::FindValue(theMap,"myLinePosition") );
177   QStringList aCondList = QStringList::split("|",VISU::Storable::FindValue(theMap,"myLineCondition") );
178   for(int i = 0, iEnd = GetNbLines(); i < iEnd; i++)
179     if(aCondList[i].toInt() == 0)
180       SetLinePosition(i,aPosList[i].toDouble());
181
182   // Restoring the map - \a myMapCurvesInverted
183   QStringList aMapCurvesInverted = QStringList::split("|",VISU::Storable::FindValue(theMap,"myMapCurvesInverted") );
184   if (aMapCurvesInverted.count() == GetNbLines()){
185     for(int i = 0, iEnd = GetNbLines(); i < iEnd ; i++){
186       if(aMapCurvesInverted[i].toInt())
187         SetCurveInverted(i,true);
188       else
189         SetCurveInverted(i,false);
190     }
191   } else {
192     for(int i = 0, iEnd = GetNbLines(); i < iEnd ; i++)
193       SetCurveInverted(i,false);
194   }
195       
196   return this;
197 }
198
199
200 //---------------------------------------------------------------
201 void
202 VISU::CutLines_i
203 ::ToStream(std::ostringstream& theStr)
204 {
205   TSuperClass::ToStream(theStr);
206
207   int aNbLines = GetNbLines();
208   
209   Storable::DataToStream( theStr, "myNbLines",         aNbLines );
210   Storable::DataToStream( theStr, "myDisplacement[0]", GetDisplacement() );
211   Storable::DataToStream( theStr, "myDisplacement[1]", GetDisplacement2() );
212   Storable::DataToStream( theStr, "myBasePlane[0]",    int(GetOrientationType()) );
213   Storable::DataToStream( theStr, "myBasePlane[1]",    int(GetOrientationType2()) );
214   Storable::DataToStream( theStr, "aRot[0][0]",        GetRotateX() );
215   Storable::DataToStream( theStr, "aRot[0][1]",        GetRotateY() );
216   Storable::DataToStream( theStr, "aRot[1][0]",        GetRotateX2() );
217   Storable::DataToStream( theStr, "aRot[1][1]",        GetRotateY2() );
218   Storable::DataToStream( theStr, "myBasePlanePosition", GetBasePlanePosition() );
219   Storable::DataToStream( theStr, "myBasePlaneCondition", IsDefault() );
220
221   QString aStrPos, aStrCon;
222   for(int i = 0, iEnd = GetNbLines(); i < iEnd; i++){
223     aStrPos.append(QString::number(GetLinePosition(i)) + "|");
224     aStrCon.append(QString::number(IsDefaultPosition(i)) + "|");
225   }
226
227   Storable::DataToStream( theStr, "myLinePosition",  aStrPos.latin1());
228   Storable::DataToStream( theStr, "myLineCondition", aStrCon.latin1());
229   Storable::DataToStream( theStr,"myUseAbsLength", IsUseAbsoluteLength());
230
231   // Storing the map - \a myMapCurvesInverted
232   QString aStrCurvesInverted;
233   for(int i = 0, iEnd = GetNbLines(); i < iEnd; i++) 
234     aStrCurvesInverted.append(QString::number(IsCurveInverted(i)) + "|");
235   Storable::DataToStream( theStr, "myMapCurvesInverted", aStrCurvesInverted.latin1());
236 }
237
238
239 //---------------------------------------------------------------
240 VISU::CutLines_i
241 ::~CutLines_i()
242 {
243   if(MYDEBUG) MESSAGE("CutLines_i::~CutLines_i()");
244 }
245
246
247 //---------------------------------------------------------------
248 void
249 VISU::CutLines_i
250 ::SetOrientation(VISU::CutPlanes::Orientation theOrient,
251                  CORBA::Double theXAngle, 
252                  CORBA::Double theYAngle)
253 {
254   struct TEvent: public SALOME_Event 
255   {
256     VISU_CutLinesPL* myCutLinesPL;
257     CORBA::Double myXAngle, myYAngle;
258     VISU::CutPlanes::Orientation myOrient;
259     TEvent(VISU_CutLinesPL* theCutLines, 
260            VISU::CutPlanes::Orientation theOrient,
261            CORBA::Double theXAngle, 
262            CORBA::Double theYAngle):
263       myCutLinesPL(theCutLines), 
264       myOrient(theOrient), 
265       myXAngle(theXAngle), 
266       myYAngle(theYAngle)
267     {}
268
269     virtual
270     void
271     Execute()
272     {
273       myCutLinesPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(myOrient),
274                                    myXAngle, 
275                                    myYAngle);
276     }
277   };
278
279   VISU::TSetModified aModified(this);
280
281   ProcessVoidEvent(new TEvent(myCutLinesPL, theOrient, theXAngle, theYAngle));
282 }
283
284 //---------------------------------------------------------------
285 void 
286 VISU::CutLines_i
287 ::SetOrientation2(VISU::CutPlanes::Orientation theOrient,
288                   CORBA::Double theXAngle, 
289                   CORBA::Double theYAngle)
290 {
291   struct TEvent: public SALOME_Event 
292   {
293     VISU_CutLinesPL* myCutLinesPL;
294     CORBA::Double myXAngle, myYAngle;
295     VISU::CutPlanes::Orientation myOrient;
296     TEvent(VISU_CutLinesPL* theCutLines, 
297            VISU::CutPlanes::Orientation theOrient,
298            CORBA::Double theXAngle, 
299            CORBA::Double theYAngle):
300       myCutLinesPL(theCutLines), 
301       myOrient(theOrient), 
302       myXAngle(theXAngle), 
303       myYAngle(theYAngle)
304     {}
305
306     virtual
307     void
308     Execute()
309     {
310       myCutLinesPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(myOrient),
311                                    myXAngle, 
312                                    myYAngle,
313                                    1);
314     }
315   };
316
317   VISU::TSetModified aModified(this);
318
319   ProcessVoidEvent(new TEvent(myCutLinesPL, theOrient, theXAngle, theYAngle));
320 }
321
322 //---------------------------------------------------------------
323 VISU::CutPlanes::Orientation 
324 VISU::CutLines_i
325 ::GetOrientationType() 
326
327   return VISU::CutPlanes::Orientation(myCutLinesPL->GetPlaneOrientation());
328 }
329
330 //---------------------------------------------------------------
331 VISU::CutPlanes::Orientation 
332 VISU::CutLines_i
333 ::GetOrientationType2() 
334
335   return VISU::CutPlanes::Orientation(myCutLinesPL->GetPlaneOrientation(1));
336 }
337
338 //---------------------------------------------------------------
339 CORBA::Double
340 VISU::CutLines_i
341 ::GetRotateX()
342 {
343   return myCutLinesPL->GetRotateX();
344 }
345
346 //---------------------------------------------------------------
347 CORBA::Double 
348 VISU::CutLines_i
349 ::GetRotateY()
350 {
351   return myCutLinesPL->GetRotateY();
352 }
353
354
355 //---------------------------------------------------------------
356 CORBA::Double 
357 VISU::CutLines_i
358 ::GetRotateX2()
359 {
360   return myCutLinesPL->GetRotateX(1);
361 }
362
363 //---------------------------------------------------------------
364 CORBA::Double 
365 VISU::CutLines_i
366 ::GetRotateY2()
367 {
368   return myCutLinesPL->GetRotateY(1);
369 }
370
371
372 //---------------------------------------------------------------
373 void
374 VISU::CutLines_i
375 ::SetDisplacement(CORBA::Double theDisp) 
376
377   VISU::TSetModified aModified(this);
378
379   ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_CutLinesPL, vtkFloatingPointType, int>
380                    (GetSpecificPL(), &VISU_CutLinesPL::SetDisplacement, theDisp, 0));
381 }
382
383 //---------------------------------------------------------------
384 void
385 VISU::CutLines_i
386 ::SetDisplacement2(CORBA::Double theDisp) 
387
388   VISU::TSetModified aModified(this);
389
390   ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_CutLinesPL, vtkFloatingPointType, int>
391                    (GetSpecificPL(), &VISU_CutLinesPL::SetDisplacement, theDisp, 1));
392 }
393
394
395 //---------------------------------------------------------------
396 CORBA::Double 
397 VISU::CutLines_i
398 ::GetDisplacement() 
399
400   return myCutLinesPL->GetDisplacement();
401 }
402
403 //---------------------------------------------------------------
404 CORBA::Double 
405 VISU::CutLines_i
406 ::GetDisplacement2() 
407
408   return myCutLinesPL->GetDisplacement(1);
409 }
410
411
412 //---------------------------------------------------------------
413 void 
414 VISU::CutLines_i
415 ::SetBasePlanePosition(CORBA::Double thePlanePosition)
416 {
417   VISU::TSetModified aModified(this);
418
419   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_CutLinesPL, vtkFloatingPointType>
420                    (GetSpecificPL(), &VISU_CutLinesPL::SetPosition, thePlanePosition));
421 }
422
423 //---------------------------------------------------------------
424 CORBA::Double 
425 VISU::CutLines_i
426 ::GetBasePlanePosition()
427
428   return myCutLinesPL->GetPosition();
429 }
430
431 //---------------------------------------------------------------
432 void 
433 VISU::CutLines_i
434 ::SetLinePosition(CORBA::Long thePlaneNumber, 
435                   CORBA::Double thePlanePosition)
436 {
437   VISU::TSetModified aModified(this);
438
439   ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_CutLinesPL, int, vtkFloatingPointType>
440                    (GetSpecificPL(), &VISU_CutLinesPL::SetPartPosition, thePlaneNumber, thePlanePosition));
441 }
442
443 //---------------------------------------------------------------
444 CORBA::Double 
445 VISU::CutLines_i
446 ::GetLinePosition(CORBA::Long thePlaneNumber)
447
448   return myCutLinesPL->GetPartPosition(thePlaneNumber,1);
449 }
450
451
452 //---------------------------------------------------------------
453 void
454 VISU::CutLines_i
455 ::SetDefault()
456 {
457   VISU::TSetModified aModified(this);
458
459   ProcessVoidEvent(new TVoidMemFunEvent<VISU_CutLinesPL>
460                    (GetSpecificPL(), &VISU_CutLinesPL::SetDefault));
461 }
462
463 //---------------------------------------------------------------
464 CORBA::Boolean
465 VISU::CutLines_i
466 ::IsDefault()
467
468   return myCutLinesPL->IsDefault();
469 }
470
471 //---------------------------------------------------------------
472 void
473 VISU::CutLines_i
474 ::SetDefaultPosition(CORBA::Long thePlaneNumber)
475 {
476   VISU::TSetModified aModified(this);
477
478   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_CutLinesPL, int>
479                    (GetSpecificPL(), &VISU_CutLinesPL::SetPartDefault, thePlaneNumber));
480 }
481
482 //---------------------------------------------------------------
483 CORBA::Boolean
484 VISU::CutLines_i
485 ::IsDefaultPosition(CORBA::Long thePlaneNumber)
486
487   return myCutLinesPL->IsPartDefault(thePlaneNumber);
488 }
489
490 //---------------------------------------------------------------
491 /*! Invert all curves of corresponding table
492  * see void VISU::CutLines_i::SetCurveInverted(CORBA::Long theCurveNumber,CORBA::Boolean theInvert)
493  * \param theInvert - Invert all curves, if value is TRUE, else not.
494  */
495 void
496 VISU::CutLines_i
497 ::SetAllCurvesInverted(CORBA::Boolean theInvert)
498 {
499   for(int i=0; i < GetNbLines(); i++)
500     SetCurveInverted(i, theInvert);
501 }
502
503 //---------------------------------------------------------------
504 /*! Checks the orientation of all curves
505  * \retval TRUE - if all curves are inverted, else FALSE
506  */
507 CORBA::Boolean 
508 VISU::CutLines_i
509 ::IsAllCurvesInverted()
510 {
511   for (int i=0; i<GetNbLines(); i++)
512     if (!IsCurveInverted(i)) return false;
513   return true;
514 }
515
516 //---------------------------------------------------------------
517 /*! Sets orientation of curve
518  * \param theCurveNumber - integer value, number of cut line.
519  * \param theInvert      - boolean value, TRUE or false.
520  */
521 void
522 VISU::CutLines_i
523 ::SetCurveInverted(CORBA::Long theCurveNumber, CORBA::Boolean theInvert)
524 {
525   if(myMapCurvesInverted[theCurveNumber] == theInvert)
526     return;
527
528   VISU::TSetModified aModified(this);
529
530   myMapCurvesInverted[theCurveNumber] = theInvert;
531   myParamsTime.Modified();
532 }
533
534 //---------------------------------------------------------------
535 /*! Checks orientation of curve.
536  * \param theCurveNumber - integer value, number of cut line.
537  * \retval TRUE - if line in the table is inverted, else FALSE.
538  */
539 CORBA::Boolean
540 VISU::CutLines_i
541 ::IsCurveInverted(CORBA::Long theCurveNumber)
542 {
543   return myMapCurvesInverted[theCurveNumber];
544 }
545
546 //---------------------------------------------------------------
547 /*! It control the way the length of cutlines is shown: using aboslute or relative values
548 * \param theAbsLength - boolean value, TRUE or false.
549 */
550 void
551 VISU::CutLines_i
552 ::SetUseAbsoluteLength(CORBA::Boolean theAbsLength)
553 {
554   if(myUseAbsLength == theAbsLength)
555     return;
556
557   VISU::TSetModified aModified(this);
558
559   myUseAbsLength = theAbsLength;
560   myParamsTime.Modified();
561 }
562
563 //---------------------------------------------------------------
564 CORBA::Boolean
565 VISU::CutLines_i
566 ::IsUseAbsoluteLength()
567 {
568   return myUseAbsLength;
569 }
570
571 //---------------------------------------------------------------
572 void
573 VISU::CutLines_i
574 ::SetNbLines(CORBA::Long theNb) 
575
576   VISU::TSetModified aModified(this);
577
578   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_CutLinesPL, int>
579                    (GetSpecificPL(), &VISU_CutLinesPL::SetNbParts, theNb));
580 }
581
582 //---------------------------------------------------------------
583 CORBA::Long
584 VISU::CutLines_i
585 ::GetNbLines() 
586
587   return myCutLinesPL->GetNbParts();
588 }
589
590
591 //---------------------------------------------------------------
592 void
593 VISU::CutLines_i
594 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
595 {
596   if(!thePipeLine){
597     myCutLinesPL = VISU_CutLinesPL::New();
598   }else
599     myCutLinesPL = dynamic_cast<VISU_CutLinesPL*>(thePipeLine);
600
601   TSuperClass::CreatePipeLine(myCutLinesPL);
602 }
603
604
605 //----------------------------------------------------------------------------
606 bool
607 VISU::CutLines_i
608 ::CheckIsPossible() 
609 {
610   return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
611 }
612
613
614 //---------------------------------------------------------------
615 VISU_Actor* 
616 VISU::CutLines_i
617 ::CreateActor()
618 {
619   if(VISU_Actor* anActor = TSuperClass::CreateActor()){
620     anActor->SetVTKMapping(true);
621     SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
622     int aDispMode = aResourceMgr->integerValue("VISU" , "cut_lines_represent", 2);
623     anActor->SetRepresentation(aDispMode);
624     return anActor;
625   }
626   return NULL;
627 }
628
629 //---------------------------------------------------------------
630 void
631 VISU::CutLines_i
632 ::BuildTableOfReal(SALOMEDS::SObject_var theSObject)
633 {
634   try{
635     if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal");
636     Update();
637     SALOMEDS::GenericAttribute_var anAttr;
638     SALOMEDS::StudyBuilder_var aStudyBuilder = GetStudyDocument()->NewBuilder();
639     anAttr = aStudyBuilder->FindOrCreateAttribute(theSObject, "AttributeTableOfReal");
640     SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
641     
642     typedef set<vtkFloatingPointType> TXCont;
643     typedef map<vtkFloatingPointType,vtkFloatingPointType> TXYMap;
644     typedef map<int,TXYMap> TXYMapCont;
645     typedef map<long,long> TLineIdCont;
646     
647     QString aTitle( GetScalarBarTitle().c_str() );
648     aTitle = aTitle.simplifyWhiteSpace();
649     aTableOfReal->SetTitle( aTitle.latin1() );
650     
651     int iLineEnd = myCutLinesPL->GetAppendPolyData()->GetNumberOfInputConnections(0);
652     if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal iLineEnd = "<<iLineEnd);
653     TXCont aXCont;
654     TXYMapCont aXYMapCont; 
655     TLineIdCont aLineIdCont;  // Define internal numeration of lines
656     const vtkFloatingPointType *aDirLn = myCutLinesPL->GetDirLn();
657     const vtkFloatingPointType *aBasePnt = myCutLinesPL->GetBasePnt();
658     const vtkFloatingPointType *aBoundPrjLn = myCutLinesPL->GetBoundPrjLn();
659     for(int iLine = 0, jLine = 0; iLine < iLineEnd; iLine++){
660       vtkDataSet *aDataSet = myCutLinesPL->GetAppendPolyData()->GetInput(iLine);
661       aDataSet->Update();
662       int aNbPoints = aDataSet->GetNumberOfPoints();
663       if(!aNbPoints) continue;
664       vtkPointData *aPointData = aDataSet->GetPointData();
665       vtkDataArray *aScalars = aPointData->GetScalars();
666       vtkCellDataToPointData *aFilter = NULL;
667       if(!aScalars) {
668         aFilter = vtkCellDataToPointData::New();
669         aFilter->SetInput(aDataSet);
670         aFilter->PassCellDataOn();
671         aDataSet = aFilter->GetOutput();
672         aDataSet->Update();
673       }
674       aPointData = aDataSet->GetPointData();
675       aScalars = aPointData->GetScalars();
676       if(!aScalars) continue;
677       if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal iLine = "<<iLine<<"; aNbPoints = "<<aNbPoints);
678       aLineIdCont[iLine] = jLine++;
679       TXYMap& aXYMap = aXYMapCont[iLine];
680       vtkFloatingPointType aPnt[3], aVect[3], aDist, aTopBnd, aDivide;
681       aTopBnd = aBoundPrjLn[2];
682       aDivide = aBoundPrjLn[2];
683       if( !IsUseAbsoluteLength() ){
684         aTopBnd = 1.0;
685       }
686       else aDivide = 1.0;
687
688       for(int i = 0; i < aNbPoints; i++){
689         aDataSet->GetPoint(i,aPnt);
690         for(int j = 0; j < 3; j++)
691           aVect[j] = aPnt[j] - aBasePnt[j];
692         //VISU::Sub(aPnt,aBasePnt,aVect);
693         if ( fabs(aBoundPrjLn[2]) < EPS_machine )
694           aDist = 0.5;
695         else
696           {
697             aDist = vtkMath::Dot(aVect,aDirLn)/aDivide; 
698             // the workaround
699             if(aDist < 0.0) aDist = 0.0; 
700             if(aDist > aTopBnd) aDist = aTopBnd;
701           }
702         aXYMap[aDist] = aScalars->GetTuple1(i);
703       }
704       if(aFilter)
705         aFilter->Delete();
706     }
707     if(aXYMapCont.size() == 0)
708       throw std::runtime_error("CutPlanes_i::BuildTableOfReal aXYMapCont.size() == 0 !!!");
709
710     {
711       // Invertion all curves in the table, which has inversion flag is TRUE (see \a myMapCurvesInverted)
712       for(int iLine=0; iLine < iLineEnd; iLine++){
713         if (!IsCurveInverted(iLine)) continue;
714         TXYMap aNewXYMap;
715         TXYMap& aXYMap = aXYMapCont[iLine];
716         TXYMap::const_iterator aXYMapIter = aXYMap.begin();
717         std::list<vtkFloatingPointType> XKeys;
718         for (;aXYMapIter != aXYMap.end() ; aXYMapIter++) XKeys.push_back(aXYMapIter->first);
719         XKeys.sort();
720         if (XKeys.size() > 1) {
721           vtkFloatingPointType a_first_indx = XKeys.front();
722           vtkFloatingPointType a_last_indx = XKeys.back();
723           if (a_first_indx > a_last_indx){
724             XKeys.reverse();
725             vtkFloatingPointType tmp = a_first_indx;
726             a_first_indx = a_last_indx;
727             a_last_indx = tmp;
728           }
729           std::list<vtkFloatingPointType>::const_iterator aIter = XKeys.begin();
730           for (int k=0;k<XKeys.size() && aIter != XKeys.end();k++,aIter++){
731             // Warning: value '1.0' come from workaround:
732             // see also aDist = vtkMath::Dot(aVect,aDirLn) / aBoundPrjLn[2];
733             // aDist >= 0 and aDist<=1.0
734             vtkFloatingPointType aTopBnd = aBoundPrjLn[2];
735             if( !IsUseAbsoluteLength() ){
736               aTopBnd = 1.0;
737             }
738             aNewXYMap[aTopBnd - *aIter] = aXYMap[*aIter];
739           }
740           TXYMap::const_iterator aNewXYMapIter = aNewXYMap.begin();
741           aXYMap.clear();
742           for (;aNewXYMapIter != aNewXYMap.end();aNewXYMapIter++) {
743             aXYMap[aNewXYMapIter->first] = aNewXYMapIter->second;
744           }
745         }
746       }
747     }
748     //Resorting of theXYMap
749     TXYMapCont::iterator aXYMapContIter = aXYMapCont.begin();
750     for(; aXYMapContIter != aXYMapCont.end(); aXYMapContIter++){
751       TXYMap& aXYMap = aXYMapContIter->second, aNewXYMap;
752       if(aXYMap.size() > 2){  
753         // Try to smooth the values of the line by applying linear approximation
754         TXYMap::const_iterator aXYMapIter[2] = {aXYMap.begin(), ++aXYMap.begin()};
755         aNewXYMap[aXYMapIter[0]->first] = aXYMapIter[0]->second;
756         aXCont.insert(aXYMapIter[0]->first);
757         for(; aXYMapIter[1] != aXYMap.end(); aXYMapIter[0]++, aXYMapIter[1]++){
758           vtkFloatingPointType aY[3] = {aXYMapIter[0]->second, aXYMapIter[1]->second, 0.0};
759           aY[2] = (aY[0] + aY[1])/2.0;
760           vtkFloatingPointType aX[3] = {aXYMapIter[0]->first, aXYMapIter[1]->first, 0.0};
761           aX[2] = (aX[0] + aX[1])/2.0;
762           aNewXYMap[aX[2]] = aY[2];
763           aXCont.insert(aX[2]);
764         }
765         aNewXYMap[aXYMapIter[0]->first] = aXYMapIter[0]->second;
766         aXCont.insert(aXYMapIter[0]->first);
767         aXYMap = aNewXYMap;
768       }else{
769         TXYMap::const_iterator aXYMapIter = aXYMap.begin();
770         for(; aXYMapIter != aXYMap.end(); aXYMapIter++)
771           aXCont.insert(aXYMapIter->first);
772       }
773     }
774     if(aXCont.size() == 0)
775       throw std::runtime_error("CutPlanes_i::BuildTableOfReal aXCont.size() == 0 !!!");
776     QString aString;
777     int iEnd = aXCont.size();
778     aTableOfReal->SetNbColumns(iEnd);
779     TXCont::const_iterator aXContIter = aXCont.begin();
780     for(long i = 0; aXContIter != aXCont.end(); aXContIter++, i++){
781       vtkFloatingPointType aDist = *aXContIter; 
782       aTableOfReal->PutValue(aDist,1,i+1);
783       aString.sprintf("%d",i);
784       aTableOfReal->SetColumnTitle(i+1,aString.latin1());
785       if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal aDist = "<<aDist);
786       TXYMapCont::const_iterator aXYMapContIter = aXYMapCont.begin();
787       for(; aXYMapContIter != aXYMapCont.end(); aXYMapContIter++){
788         long iLine = aXYMapContIter->first;
789         long iLineId = aLineIdCont[iLine];
790         const TXYMap& aXYMap = aXYMapCont[iLine];
791         TXYMap::const_iterator aXYMapIter = aXYMap.find(aDist);
792         // Can we find some value that belong to the line and have the same X coordinate?
793         if(aXYMapIter == aXYMap.end()) continue;
794         vtkFloatingPointType aVal = aXYMapIter->second;
795         aTableOfReal->PutValue(aVal,iLineId+2,i+1);
796       }
797     }
798     {
799       aTableOfReal->SetRowTitle(1,"X");
800       aTableOfReal->SetRowUnit(1,"-");
801       QString aUnitName = GetField()->myUnitNames[0].c_str();
802       int aScalarMode = myCutLinesPL->GetScalarMode();
803       if(aScalarMode != 0) 
804         aUnitName = GetField()->myUnitNames[aScalarMode-1].c_str();
805       aUnitName = aUnitName.simplifyWhiteSpace();
806       if(aUnitName.isEmpty()) aUnitName = "-";
807       TXYMapCont::const_iterator aXYMapContIter = aXYMapCont.begin();
808       for(; aXYMapContIter != aXYMapCont.end(); aXYMapContIter++){
809         long iLine = aXYMapContIter->first;
810         long iLineId = aLineIdCont[iLine];
811         aString.sprintf("Y%d",iLine);
812         if(MYDEBUG) 
813           MESSAGE("CutPlanes_i::BuildTableOfReal - SetRowTitle("<<iLineId+2<<",'"<<aString<<"')");
814         aTableOfReal->SetRowTitle(iLineId+2,aString.latin1());
815         aTableOfReal->SetRowUnit(iLineId+2,aUnitName.latin1());
816       }
817     }
818   }catch(std::exception& exc){
819     INFOS("Follow exception was occured :\n"<<exc.what());
820   }catch (...){
821     INFOS("Unknown exception was occured !!!");
822   }
823 }