Salome HOME
Update copyright information
[modules/visu.git] / src / PIPELINE / VISU_StreamLinesPL.cxx
1 // Copyright (C) 2007-2012  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_StreamLinesPL.cxx
25 // Author:  Alexey PETROV
26 // Module : VISU
27 //
28 #include "VISU_StreamLinesPL.hxx"
29
30 #include "VISU_Extractor.hxx"
31 //#include "VISU_FieldTransform.hxx"
32 //#include "VISU_UsedPointsFilter.hxx"
33 #include "VISU_MaskPointsFilter.hxx"
34 #include "VISU_PipeLineUtils.hxx"
35
36 #include "VTKViewer_CellCenters.h"
37 #include "VTKViewer_GeometryFilter.h"
38
39 #include <SUIT_Session.h>
40 #include <SUIT_ResourceMgr.h>
41
42 #include <algorithm>
43
44 #include <vtkCell.h>
45 #include <vtkDataSet.h>
46 #include <vtkStreamLine.h>
47
48 #ifdef _DEBUG_
49 static int MYDEBUG = 0;
50 #else
51 static int MYDEBUG = 0;
52 #endif
53
54 static vtkFloatingPointType EPS = 1.0e-7;
55 static vtkFloatingPointType aMinNbOfSteps = 1.0E+2;
56 //static vtkFloatingPointType aMaxNbOfSteps = 1.0E+3;
57 static vtkFloatingPointType aCoeffOfIntStep = 1.0E+1;
58
59
60 //----------------------------------------------------------------------------
61 vtkStandardNewMacro(VISU_StreamLinesPL);
62
63
64 //----------------------------------------------------------------------------
65 VISU_StreamLinesPL
66 ::VISU_StreamLinesPL()
67 {
68   SetIsShrinkable(false);
69   SetIsFeatureEdgesAllowed(false);
70
71   myStream = vtkStreamLine::New();
72   myCenters = VTKViewer_CellCenters::New();
73   myGeomFilter = VTKViewer_GeometryFilter::New();
74   myPointsFilter = VISU_MaskPointsFilter::New();
75   mySource = NULL;
76
77   myPercents = GetUsedPointsDefault();
78 }
79
80
81 //----------------------------------------------------------------------------
82 VISU_StreamLinesPL
83 ::~VISU_StreamLinesPL()
84 {
85   myPointsFilter->Delete();
86   myPointsFilter = NULL;
87
88   myCenters->Delete();
89   myCenters = NULL;
90
91   myGeomFilter->Delete();
92   myGeomFilter = NULL;
93
94   myStream->Delete();
95   myStream = NULL;
96 }
97
98
99 //----------------------------------------------------------------------------
100 unsigned long int 
101 VISU_StreamLinesPL
102 ::GetMTime()
103 {
104   unsigned long int aTime = Superclass::GetMTime();
105
106   aTime = std::max(aTime, myStream->GetMTime());
107   aTime = std::max(aTime, myCenters->GetMTime());
108   aTime = std::max(aTime, myGeomFilter->GetMTime());
109   aTime = std::max(aTime, myPointsFilter->GetMTime());
110
111   if ( mySource )
112     aTime = std::max(aTime, mySource->GetMTime());
113
114   return aTime;
115 }
116
117
118 //----------------------------------------------------------------------------
119 void
120 VISU_StreamLinesPL
121 ::DoShallowCopy(VISU_PipeLine *thePipeLine,
122                 bool theIsCopyInput)
123 {
124   Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
125
126   if(VISU_StreamLinesPL *aPipeLine = dynamic_cast<VISU_StreamLinesPL*>(thePipeLine)){
127     SetParams(aPipeLine->GetIntegrationStep(),
128               aPipeLine->GetPropagationTime(),
129               aPipeLine->GetStepLength(),
130               aPipeLine->GetSource(),
131               aPipeLine->GetUsedPoints(),
132               aPipeLine->GetDirection());
133   }
134 }
135
136
137 //----------------------------------------------------------------------------
138 vtkFloatingPointType
139 VISU_StreamLinesPL
140 ::GetNecasseryMemorySize(vtkIdType theNbOfPoints, 
141                          vtkFloatingPointType theStepLength,
142                          vtkFloatingPointType thePropogationTime, 
143                          vtkFloatingPointType thePercents)
144 {
145   static vtkFloatingPointType aStreamPointSize = sizeof(vtkFloatingPointType)*15 + sizeof(vtkIdType)*2;
146   static vtkFloatingPointType aStreamArraySize = aStreamPointSize*1024; // == 69632
147
148   vtkFloatingPointType aNbCells = thePercents*theNbOfPoints*2.0;
149   vtkFloatingPointType aNbPointsPerCell = thePropogationTime/theStepLength;
150   vtkFloatingPointType aCellsSize = aNbCells*(1+aNbPointsPerCell);
151   vtkFloatingPointType aPointsSize = aCellsSize*3.0*sizeof(vtkFloatingPointType);
152
153   vtkFloatingPointType aConnectivitySize = aCellsSize*sizeof(vtkIdType);
154   vtkFloatingPointType aTypesSize = aNbCells*sizeof(char);
155   vtkFloatingPointType aLocationsSize = aNbCells*sizeof(int);
156   //vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
157   vtkFloatingPointType aMeshSize = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize;
158
159   vtkFloatingPointType anAssignedDataSize = aCellsSize*4.0*sizeof(vtkFloatingPointType);
160   vtkFloatingPointType anOutputDataSetSize = aMeshSize + anAssignedDataSize;
161
162   vtkFloatingPointType aResult = aStreamArraySize*aNbCells + anOutputDataSetSize;
163   return aResult;
164 }
165
166
167 //----------------------------------------------------------------------------
168 size_t
169 VISU_StreamLinesPL
170 ::FindPossibleParams(vtkDataSet* theDataSet, 
171                      vtkFloatingPointType& theStepLength,
172                      vtkFloatingPointType& thePropogationTime, 
173                      vtkFloatingPointType& thePercents)
174 {
175   static vtkFloatingPointType aPercentsDecrease = 3.0, aStepLengthIncrease = 9.0;
176   vtkIdType aNbOfPoints = theDataSet->GetNumberOfPoints();
177   vtkFloatingPointType aSize = GetNecasseryMemorySize(aNbOfPoints,theStepLength,thePropogationTime,thePercents);
178   size_t anIsPossible = CheckAvailableMemory(aSize);
179   if(!anIsPossible){
180     vtkFloatingPointType aMaxStepLength = std::max(GetMaxStepLength(theDataSet),thePropogationTime);
181     vtkFloatingPointType aMinStepLength = GetMinStepLength(theDataSet,thePercents);
182     vtkFloatingPointType aDeltaStepLength = (aMaxStepLength - aMinStepLength)/aStepLengthIncrease;
183     for(int i = 2, aStepChanged = 1, aPerecentsChanged = 1; aStepChanged || aPerecentsChanged; i++){
184       vtkFloatingPointType aStepLength = theStepLength + aDeltaStepLength;
185       if(aStepLength < aMaxStepLength) theStepLength = aStepLength;
186       else if(aStepChanged){
187         aStepLength = aMaxStepLength;
188         aStepChanged = 0;
189       }
190       vtkFloatingPointType aPercents = thePercents /= aPercentsDecrease;
191       if(aPercents*aNbOfPoints > 1) thePercents = aPercents;
192       else if(aPerecentsChanged) {
193         thePercents = 1.1 / aNbOfPoints;
194         aPerecentsChanged = 0;
195       }
196       aSize = GetNecasseryMemorySize(aNbOfPoints,theStepLength,thePropogationTime,thePercents);
197       if(CheckAvailableMemory(aSize)){
198         anIsPossible = i;
199         break;
200       }
201     }
202   }
203   if(MYDEBUG) MESSAGE("FindPossibleParams - aSize = "<<aSize<<"; anIsPossible = "<<anIsPossible);
204   return anIsPossible;
205 }
206
207
208 //----------------------------------------------------------------------------
209 size_t
210 VISU_StreamLinesPL
211 ::SetParams(vtkFloatingPointType theIntStep,
212             vtkFloatingPointType thePropogationTime,
213             vtkFloatingPointType theStepLength,
214             vtkPointSet* theSource,
215             vtkFloatingPointType thePercents,
216             int theDirection)
217 {
218   vtkPointSet* aDataSet = theSource? theSource: GetMergedInput();
219   aDataSet->Update();
220
221   vtkIdType aNbOfPoints = aDataSet->GetNumberOfPoints();
222   vtkDataSet* aPointSet = GetExtractorFilter()->GetOutput();
223   if (thePercents * aNbOfPoints < 1)
224     thePercents = 2.0 / aNbOfPoints;
225
226   theIntStep = CorrectIntegrationStep(theIntStep,
227                                       aPointSet,
228                                       thePercents);
229
230   thePropogationTime = CorrectPropagationTime(thePropogationTime,
231                                               aPointSet,
232                                               thePercents);
233
234   theStepLength = CorrectStepLength(theStepLength,
235                                     aPointSet,
236                                     thePercents);
237
238   size_t anIsAccepted = FindPossibleParams(aPointSet,
239                                            theStepLength,
240                                            thePropogationTime,
241                                            thePercents);
242
243   if (anIsAccepted) {
244     mySource = theSource;
245     myPercents = thePercents;
246     if(VISU::IsDataOnCells(GetMergedInput())){
247       myCenters->SetInput(aDataSet);
248       myCenters->VertexCellsOn();
249       aDataSet = myCenters->GetOutput();
250     }
251     myPointsFilter->SetInput(aDataSet);
252     myPointsFilter->SetPercentsOfUsedPoints(thePercents);
253     aDataSet = myPointsFilter->GetOutput();
254     myStream->SetSource(aDataSet);
255     myStream->SetIntegrationStepLength(theIntStep);
256     myStream->SetMaximumPropagationTime(thePropogationTime);
257     myStream->SetStepLength(theStepLength);
258     myStream->SetSavePointInterval(theIntStep*aMinNbOfSteps);
259     myStream->SetIntegrationDirection(theDirection);
260     myStream->Modified();
261     Modified();
262   }
263   return anIsAccepted;
264 }
265
266
267 //----------------------------------------------------------------------------
268 vtkPointSet* 
269 VISU_StreamLinesPL
270 ::GetSource() 
271 {
272   return mySource;
273 }
274
275
276 //----------------------------------------------------------------------------
277 vtkFloatingPointType
278 VISU_StreamLinesPL
279 ::GetUsedPoints() 
280 {
281   return myPercents;
282 }
283
284
285 //----------------------------------------------------------------------------
286 vtkDataSet* 
287 VISU_StreamLinesPL
288 ::GetStreamerSource()
289 {
290   return myStream->GetSource();
291 }
292
293
294 //----------------------------------------------------------------------------
295 vtkFloatingPointType 
296 VISU_StreamLinesPL
297 ::GetVelocityCoeff()
298 {
299   return GetVelocityCoeff(GetExtractorFilter()->GetOutput());
300 }
301
302
303 //----------------------------------------------------------------------------
304 vtkFloatingPointType 
305 VISU_StreamLinesPL
306 ::GetVelocityCoeff(vtkDataSet* theDataSet)
307 {
308   vtkFloatingPointType* aScalarRange = theDataSet->GetScalarRange();
309   vtkFloatingPointType aVelocity = (fabs(aScalarRange[1]) + fabs(aScalarRange[0]))/2.0;
310   if (aVelocity < EPS)
311     return EPS;
312
313   return aVelocity;
314 }
315
316
317 //----------------------------------------------------------------------------
318 size_t
319 VISU_StreamLinesPL
320 ::IsPossible(vtkPointSet* theDataSet)
321 {
322   vtkFloatingPointType aPercents = GetUsedPointsDefault();
323   vtkFloatingPointType aStepLength = GetBaseStepLength(theDataSet,
324                                                        aPercents);
325   vtkFloatingPointType aBasePropTime = GetBasePropagationTime(theDataSet);
326   VISU_MaskPointsFilter *aPointsFilter = VISU_MaskPointsFilter::New();
327   aPointsFilter->SetInput(theDataSet);
328   vtkDataSet* aDataSet = aPointsFilter->GetOutput();
329   aDataSet->Update();
330   size_t aRes = FindPossibleParams(aDataSet,
331                                    aStepLength,
332                                    aBasePropTime,
333                                    aPercents);
334   aPointsFilter->Delete();
335   return aRes;
336 }
337
338
339 //----------------------------------------------------------------------------
340 vtkFloatingPointType
341 VISU_StreamLinesPL
342 ::GetIntegrationStep()
343 {
344   return myStream->GetIntegrationStepLength();
345 }
346
347
348 //----------------------------------------------------------------------------
349 vtkFloatingPointType
350 VISU_StreamLinesPL
351 ::GetStepLength() 
352 {
353   return myStream->GetStepLength();
354 }
355
356
357 //----------------------------------------------------------------------------
358 vtkFloatingPointType
359 VISU_StreamLinesPL
360 ::GetPropagationTime() 
361 {
362   return myStream->GetMaximumPropagationTime();
363 }
364
365
366 //----------------------------------------------------------------------------
367 int
368 VISU_StreamLinesPL
369 ::GetDirection()
370 {
371   return myStream->GetIntegrationDirection();
372 }
373
374
375 //----------------------------------------------------------------------------
376 vtkFloatingPointType
377 VISU_StreamLinesPL
378 ::GetMinIntegrationStep(vtkDataSet* theDataSet, 
379                         vtkFloatingPointType thePercents) 
380 {
381   if(!theDataSet) 
382     return -1.0;
383
384   theDataSet->Update();
385
386   int degree = 0;
387   vtkFloatingPointType aVolume = 1.0;
388   vtkFloatingPointType* aBounds = theDataSet->GetBounds();
389   for(int i = 0, j = 0; i < 3; ++i, j = 2*i){
390     vtkFloatingPointType tmp = aBounds[j+1] - aBounds[j];
391     if (tmp > EPS ) {
392       aVolume *= tmp;
393       degree += 1;
394     }
395   }
396
397   if (degree < 1) 
398     return 0.0; // absolutely empty object
399
400   vtkFloatingPointType anStepLength = GetMaxIntegrationStep(theDataSet)/aCoeffOfIntStep;
401   // 0020724: last division has been commented, seems to be a logical mistake (to discuss with APO)
402   vtkFloatingPointType aBasePropTime = GetBasePropagationTime(theDataSet); // /GetVelocityCoeff(theDataSet)
403   thePercents = 1.0;
404   vtkIdType aNbOfPoints = theDataSet->GetNumberOfPoints();
405   vtkFloatingPointType aSize = GetNecasseryMemorySize(aNbOfPoints,anStepLength,aBasePropTime,thePercents);
406   size_t aRealSize = GetAvailableMemory(aSize);
407   vtkFloatingPointType anAverageVolume = aVolume / aRealSize;
408   vtkFloatingPointType aStep = pow(double(anAverageVolume), double(1.0/double(degree)));
409   return aStep;
410 }
411
412
413 //----------------------------------------------------------------------------
414 vtkFloatingPointType
415 VISU_StreamLinesPL
416 ::GetMinIntegrationStep()
417 {
418   return GetMinIntegrationStep(GetExtractorFilter()->GetOutput(), GetUsedPoints());
419 }
420
421
422 //----------------------------------------------------------------------------
423 vtkFloatingPointType
424 VISU_StreamLinesPL
425 ::GetMaxIntegrationStep(vtkDataSet* theDataSet) 
426 {
427   if(!theDataSet) 
428     return -1.0;
429
430   theDataSet->Update();
431
432   vtkFloatingPointType aLength = theDataSet->GetLength();
433   vtkFloatingPointType* aBounds = theDataSet->GetBounds();
434   vtkFloatingPointType aMaxSizeY = (aBounds[3]-aBounds[2])/aLength;
435   vtkFloatingPointType aMaxSizeZ = (aBounds[5]-aBounds[4])/aLength;
436   vtkFloatingPointType aMinMax = (aBounds[1] - aBounds[0])/aLength;
437   if (aMinMax < EPS || (aMaxSizeY < aMinMax && aMaxSizeY > EPS)) 
438     aMinMax = aMaxSizeY;
439   if (aMinMax < EPS || (aMaxSizeZ < aMinMax && aMaxSizeZ > EPS)) 
440     aMinMax = aMaxSizeZ;
441   return aMinMax*aLength/2.0;
442 }
443
444
445 //----------------------------------------------------------------------------
446 vtkFloatingPointType
447 VISU_StreamLinesPL
448 ::GetMaxIntegrationStep()
449 {
450   return GetMaxIntegrationStep(GetExtractorFilter()->GetOutput());
451 }
452
453
454 //----------------------------------------------------------------------------
455 vtkFloatingPointType
456 VISU_StreamLinesPL
457 ::GetBaseIntegrationStep(vtkDataSet* theDataSet, 
458                          vtkFloatingPointType thePercents)
459 {
460   theDataSet->Update();
461
462   vtkFloatingPointType aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet);
463   vtkFloatingPointType anIntegrationStep = aMaxIntegrationStep / aCoeffOfIntStep;
464   vtkFloatingPointType aMinMax = theDataSet->GetLength() / theDataSet->GetNumberOfPoints();
465   if(aMinMax > anIntegrationStep)
466     anIntegrationStep = (anIntegrationStep*aCoeffOfIntStep*0.9+aMinMax)/aCoeffOfIntStep;
467
468   vtkFloatingPointType aMinIntegrationStep = GetMinIntegrationStep(theDataSet, thePercents);
469   if(aMinIntegrationStep > anIntegrationStep)
470     anIntegrationStep = aMinIntegrationStep;
471
472   return anIntegrationStep;
473 }
474
475
476 //----------------------------------------------------------------------------
477 vtkFloatingPointType
478 VISU_StreamLinesPL
479 ::CorrectIntegrationStep(vtkFloatingPointType theStep, 
480                          vtkDataSet* theDataSet, 
481                          vtkFloatingPointType thePercents)
482 {
483   theDataSet->Update();
484
485   vtkFloatingPointType aMinIntegrationStep = GetMinIntegrationStep(theDataSet, thePercents);
486   if(aMinIntegrationStep > theStep)
487     theStep = aMinIntegrationStep;
488
489   vtkFloatingPointType aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet);
490   if(aMaxIntegrationStep < theStep)
491     theStep = aMaxIntegrationStep;
492
493   return theStep;
494 }
495
496
497 //----------------------------------------------------------------------------
498 vtkFloatingPointType
499 VISU_StreamLinesPL
500 ::GetMinPropagationTime(vtkDataSet* theDataSet, 
501                         vtkFloatingPointType thePercents)
502 {
503   if(!theDataSet) 
504     return -1.0;
505
506   return GetMinStepLength(theDataSet, thePercents);
507 }
508
509
510 //----------------------------------------------------------------------------
511 vtkFloatingPointType
512 VISU_StreamLinesPL
513 ::GetMinPropagationTime()
514 {
515   return GetMinPropagationTime(GetExtractorFilter()->GetOutput(), GetUsedPoints());
516 }
517
518
519 //----------------------------------------------------------------------------
520 vtkFloatingPointType
521 VISU_StreamLinesPL
522 ::GetMaxPropagationTime(vtkDataSet* theDataSet)
523 {
524   if(!theDataSet) 
525     return -1.0;
526
527   return GetBasePropagationTime(theDataSet)*aMinNbOfSteps;
528 }
529
530
531 //----------------------------------------------------------------------------
532 vtkFloatingPointType
533 VISU_StreamLinesPL
534 ::GetMaxPropagationTime()
535 {
536   return GetMaxPropagationTime(GetExtractorFilter()->GetOutput());
537 }
538
539
540 //----------------------------------------------------------------------------
541 vtkFloatingPointType
542 VISU_StreamLinesPL
543 ::CorrectPropagationTime(vtkFloatingPointType thePropagationTime, 
544                          vtkDataSet* theDataSet, 
545                          vtkFloatingPointType thePercents)
546 {
547   vtkFloatingPointType aMinPropagationTime = GetMinPropagationTime(theDataSet, thePercents);
548   if(aMinPropagationTime > thePropagationTime)
549     thePropagationTime = aMinPropagationTime;
550
551   vtkFloatingPointType aMaxPropagationTime = GetMaxPropagationTime(theDataSet);
552   if(aMaxPropagationTime < thePropagationTime)
553     thePropagationTime = aMaxPropagationTime;
554
555   return thePropagationTime;
556 }
557
558
559 //----------------------------------------------------------------------------
560 vtkFloatingPointType 
561 VISU_StreamLinesPL
562 ::GetBasePropagationTime(vtkDataSet* theDataSet)
563 {
564   if(!theDataSet) 
565     return -1.0;
566
567   theDataSet->Update();
568   vtkFloatingPointType aPropagationTime = theDataSet->GetLength() / GetVelocityCoeff(theDataSet);
569
570   return aPropagationTime;
571 }
572
573
574 //----------------------------------------------------------------------------
575 vtkFloatingPointType 
576 VISU_StreamLinesPL
577 ::GetBasePropagationTime()
578 {
579   return GetBasePropagationTime(GetExtractorFilter()->GetOutput());
580 }
581
582
583 //----------------------------------------------------------------------------
584 vtkFloatingPointType 
585 VISU_StreamLinesPL
586 ::GetMinStepLength(vtkDataSet* theDataSet, 
587                    vtkFloatingPointType thePercents)
588 {
589   static vtkFloatingPointType aNbOfStepsOfIntStep = 1.0E+1;
590   vtkFloatingPointType anIntStep = GetMinIntegrationStep(theDataSet, thePercents);
591   vtkFloatingPointType aStepLength = anIntStep * aNbOfStepsOfIntStep / GetVelocityCoeff(theDataSet);
592   return aStepLength;
593 }
594
595
596 //----------------------------------------------------------------------------
597 vtkFloatingPointType
598 VISU_StreamLinesPL
599 ::GetMinStepLength()
600 {
601   return GetMinStepLength(GetExtractorFilter()->GetOutput(), GetUsedPoints());
602 }
603
604
605 //----------------------------------------------------------------------------
606 vtkFloatingPointType
607 VISU_StreamLinesPL
608 ::GetMaxStepLength(vtkDataSet* theDataSet)
609 {
610   vtkFloatingPointType aStepLength = GetBasePropagationTime(theDataSet);
611   return aStepLength;
612 }
613
614
615 //----------------------------------------------------------------------------
616 vtkFloatingPointType
617 VISU_StreamLinesPL
618 ::GetMaxStepLength()
619 {
620   return GetMaxStepLength(GetExtractorFilter()->GetOutput());
621 }
622
623
624 //----------------------------------------------------------------------------
625 vtkFloatingPointType
626 VISU_StreamLinesPL
627 ::CorrectStepLength(vtkFloatingPointType theStep, 
628                     vtkDataSet* theDataSet, 
629                     vtkFloatingPointType thePercents)
630 {
631   vtkFloatingPointType aMinStep = GetMinStepLength(theDataSet, thePercents);
632   if(theStep < aMinStep) 
633     theStep = aMinStep;
634
635   vtkFloatingPointType aMaxStep = GetMaxStepLength(theDataSet);
636   if(theStep > aMaxStep) 
637     theStep = aMaxStep;
638
639   return theStep;
640 }
641
642
643 //----------------------------------------------------------------------------
644 vtkFloatingPointType
645 VISU_StreamLinesPL
646 ::GetBaseStepLength(vtkDataSet* theDataSet, 
647                     vtkFloatingPointType thePercents)
648 {
649   static vtkFloatingPointType anAvgNbOfSteps = 1.0E+2;
650   vtkFloatingPointType aPropagationTime = GetBasePropagationTime(theDataSet);
651   vtkFloatingPointType aStepLength = aPropagationTime/anAvgNbOfSteps;
652   aStepLength = CorrectStepLength(aStepLength,theDataSet,thePercents);
653
654   return aStepLength;
655 }
656
657
658 //----------------------------------------------------------------------------
659 vtkFloatingPointType
660 VISU_StreamLinesPL
661 ::GetUsedPointsDefault()
662 {
663   SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
664   return aResourceMgr->doubleValue("VISU", "stream_lines_used_points", 0.01);
665 }
666
667
668 //----------------------------------------------------------------------------
669 void
670 VISU_StreamLinesPL
671 ::Init()
672 {
673   Superclass::Init();
674
675   vtkDataSet* aDataSet = GetExtractorFilter()->GetOutput();
676   vtkFloatingPointType anIntStep = GetBaseIntegrationStep(aDataSet, GetUsedPoints());
677   vtkFloatingPointType aPropagationTime = GetBasePropagationTime(aDataSet);
678   vtkFloatingPointType aStepLength = GetBaseStepLength(aDataSet, GetUsedPoints());
679   SetParams(anIntStep,
680             aPropagationTime,
681             aStepLength,
682             NULL,
683             GetUsedPoints());
684 }
685
686
687 //----------------------------------------------------------------------------
688 void
689 VISU_StreamLinesPL
690 ::Build()
691 {
692   Superclass::Build();
693
694   VISU::CellDataToPoint(myStream,
695                         myCellDataToPointData,
696                         GetMergedInput());
697
698   myGeomFilter->SetInput(myStream->GetOutput());
699   myGeomFilter->ExtentClippingOn();
700 }
701
702
703 //----------------------------------------------------------------------------
704 vtkDataSet* 
705 VISU_StreamLinesPL
706 ::InsertCustomPL()
707 {
708   return myGeomFilter->GetOutput();
709 }
710
711
712 //----------------------------------------------------------------------------
713 void
714 VISU_StreamLinesPL
715 ::Update()
716 {
717   try{
718     Superclass::Update();
719
720     vtkFloatingPointType aBounds[6];
721     GetMergedInput()->GetBounds(aBounds);
722     myGeomFilter->SetExtent(aBounds);
723     //{
724     //  std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myStream.vtk";
725     //  VISU::WriteToFile(myStream->GetOutput(), aFileName);
726     //}
727   }catch(std::exception& exc){
728     MSG(true, "Follow exception was occured :\n"<<exc.what());
729   }catch(...){
730     MSG(MYDEBUG,"Unknown exception was occured\n");
731   }
732 }
733
734
735 //----------------------------------------------------------------------------
736 unsigned long int
737 VISU_StreamLinesPL
738 ::GetMemorySize()
739 {
740   unsigned long int aSize = Superclass::GetMemorySize();
741
742   if(vtkDataSet* aDataSet = myStream->GetOutput())
743     aSize += aDataSet->GetActualMemorySize() * 1024;
744   
745   if(vtkDataSet* aDataSet = myGeomFilter->GetOutput())
746     aSize += aDataSet->GetActualMemorySize() * 1024;
747
748   if(myCellDataToPointData->GetInput())
749     if(vtkDataSet* aDataSet = myCellDataToPointData->GetOutput())
750       aSize += aDataSet->GetActualMemorySize() * 1024;
751
752   return aSize;
753 }
754
755
756 //----------------------------------------------------------------------------
757 void
758 VISU_StreamLinesPL
759 ::SetMapScale(vtkFloatingPointType theMapScale)
760 {
761   Superclass::SetMapScale(theMapScale);
762 }
763
764
765 //----------------------------------------------------------------------------