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