]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
MPV: Merge V1_2d
authorsmh <smh@opencascade.com>
Thu, 29 Jan 2004 13:03:19 +0000 (13:03 +0000)
committersmh <smh@opencascade.com>
Thu, 29 Jan 2004 13:03:19 +0000 (13:03 +0000)
21 files changed:
src/PIPELINE/Makefile.in
src/PIPELINE/VISUPipeLine.cxx
src/PIPELINE/VISU_CutLinesPL.cxx
src/PIPELINE/VISU_CutPlanesPL.cxx
src/PIPELINE/VISU_CutPlanesPL.hxx
src/PIPELINE/VISU_DeformedShapePL.cxx
src/PIPELINE/VISU_DeformedShapePL.hxx
src/PIPELINE/VISU_Extractor.cxx
src/PIPELINE/VISU_Extractor.hxx
src/PIPELINE/VISU_FieldTransform.cxx
src/PIPELINE/VISU_IsoSurfacesPL.cxx
src/PIPELINE/VISU_IsoSurfacesPL.hxx
src/PIPELINE/VISU_PipeLine.cxx
src/PIPELINE/VISU_PipeLine.hxx
src/PIPELINE/VISU_PipeLineUtils.hxx
src/PIPELINE/VISU_ScalarMapPL.cxx
src/PIPELINE/VISU_StreamLinesPL.cxx
src/PIPELINE/VISU_StreamLinesPL.hxx
src/PIPELINE/VISU_UsedPointsFilter.cxx
src/PIPELINE/VISU_VectorsPL.cxx
src/PIPELINE/VISU_VectorsPL.hxx

index 7cdd24fbe23f89a56a4830cacf7d50b03476a090..81cbfc2698eaeb5534baf90bfade135e828787a1 100644 (file)
@@ -60,6 +60,6 @@ BIN_SRC       =
 
 CPPFLAGS+= $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
 LDFLAGS+= $(VTK_LIBS) -lSalomeVTKFilter -lVisuConvertor \
-        -L${KERNEL_ROOT_DIR}/lib/salome
+       -L${KERNEL_ROOT_DIR}/lib/salome
 
 @CONCLUDE@
index 1b5181a6e71c9ff583b58cabaa1001e61e760281..f89dc7ef9375aa9c6641d1a0210f0eb49de1b365 100644 (file)
@@ -34,7 +34,7 @@
 #include "VISU_VectorsPL.hxx"
 #include "VISU_StreamLinesPL.hxx"
 
-typedef VISU_StreamLinesPL TPresent;
+typedef VISU_ScalarMapPL TPresent;
 
 #include <vtkUnstructuredGrid.h>
 #include <vtkDataSetMapper.h>
@@ -107,6 +107,7 @@ int main(int argc, char** argv){
          aPresent->SetInput(aDataSet);
          aPresent->Build();
          aPresent->Init();
+         aPresent->SetSourceRange();
          //aPresent->SetPartDefault(0);
          //aPresent->SetScalarMin(0.01);
          //aPresent->SetScaling(VTK_SCALE_LOG10);
index 367139faf2fd350fc966431e407a823da1738127..21b5004f6b690caee57f7ef3ea621cf650455019 100644 (file)
@@ -39,12 +39,11 @@ VISU_CutLinesPL::VISU_CutLinesPL(){}
 void VISU_CutLinesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
   VISU_CutPlanesPL::ShallowCopy(thePipeLine);
   if(VISU_CutLinesPL *aPipeLine = dynamic_cast<VISU_CutLinesPL*>(thePipeLine)){
-    SetPlaneOrientation(aPipeLine->GetPlaneOrientation(1),1);
+    SetOrientation(aPipeLine->GetPlaneOrientation(1),
+                  aPipeLine->GetRotateX(1),aPipeLine->GetRotateY(1),1);
     SetDisplacement(aPipeLine->GetDisplacement(1),1);
     SetDefault(); 
     if (!aPipeLine->IsDefault()) SetPosition(aPipeLine->GetPosition());
-    SetRotateX(aPipeLine->GetRotateX(1),1);
-    SetRotateY(aPipeLine->GetRotateY(1),1);
   }
 }
 
index a6cb0665877de8c077a48367cc21ea1ec8c13f5c..2cbdba5744354669518e4c04c10124b18db17737 100644 (file)
@@ -50,13 +50,12 @@ VISU_CutPlanesPL::~VISU_CutPlanesPL(){
 void VISU_CutPlanesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
   VISU_ScalarMapPL::ShallowCopy(thePipeLine);
   if(VISU_CutPlanesPL *aPipeLine = dynamic_cast<VISU_CutPlanesPL*>(thePipeLine)){
-    SetPlaneOrientation(aPipeLine->GetPlaneOrientation());
+    SetOrientation(aPipeLine->GetPlaneOrientation(),
+                  aPipeLine->GetRotateX(),aPipeLine->GetRotateY());
     SetDisplacement(aPipeLine->GetDisplacement());
     SetNbParts(aPipeLine->GetNbParts());
     for (int i = 0, iend = GetNbParts(); i < iend; i++)
       if(!aPipeLine->IsPartDefault(i))         SetPartPosition(i, aPipeLine->GetPartPosition(i));
-    SetRotateX(aPipeLine->GetRotateX());
-    SetRotateY(aPipeLine->GetRotateY());
   }
 }
 
@@ -150,14 +149,28 @@ void VISU_CutPlanesPL::GetBoundProject(float BoundPrj[3], const float BoundBox[6
   BoundPrj[2] = BoundPrj[1] - BoundPrj[0];
 }
 
-void VISU_CutPlanesPL::SetRotateX(float theAng, int theNum){
+
+void VISU_CutPlanesPL::SetOrientation(const VISU_CutPlanesPL::PlaneOrientation& theOrient, 
+                                     float theXAng, float theYAng, int theNum)
+{ 
+  myBasePlane[theNum] = theOrient;
+  switch(myBasePlane[theNum]){
+  case XY: myAng[theNum][0] = theXAng; break;
+  case YZ: myAng[theNum][1] = theXAng; break;
+  case ZX: myAng[theNum][2] = theXAng; break;
+  }
   switch(myBasePlane[theNum]){
-  case XY: myAng[theNum][0] = theAng; break;
-  case YZ: myAng[theNum][1] = theAng; break;
-  case ZX: myAng[theNum][2] = theAng; break;
+  case XY: myAng[theNum][1] = theYAng; break;
+  case YZ: myAng[theNum][2] = theYAng; break;
+  case ZX: myAng[theNum][0] = theYAng; break;
   }
 }
 
+
+const VISU_CutPlanesPL::PlaneOrientation& VISU_CutPlanesPL::GetPlaneOrientation(int theNum){ 
+  return myBasePlane[theNum];
+}
+
 float VISU_CutPlanesPL::GetRotateX(int theNum){
   switch(myBasePlane[theNum]){
   case XY: return myAng[theNum][0];
@@ -166,14 +179,6 @@ float VISU_CutPlanesPL::GetRotateX(int theNum){
   }
 }
 
-void VISU_CutPlanesPL::SetRotateY(float theAng, int theNum){
-  switch(myBasePlane[theNum]){
-  case XY: myAng[theNum][1] = theAng; break;
-  case YZ: myAng[theNum][2] = theAng; break;
-  case ZX: myAng[theNum][0] = theAng; break;
-  }
-}
-
 float VISU_CutPlanesPL::GetRotateY(int theNum){
   switch(myBasePlane[theNum]){
   case XY: return myAng[theNum][1];
index 73b42cdffdfaff8ddfc253d685654de55f01b4d8..094c9463b34fe179e0b2be47ff41c28b3c051c15 100644 (file)
@@ -44,11 +44,13 @@ public:
   virtual void ShallowCopy(VISU_PipeLine *thePipeLine);
 
   enum PlaneOrientation {XY, YZ, ZX};
-  virtual const PlaneOrientation& GetPlaneOrientation(int theNum = 0) { return myBasePlane[theNum];}
-  virtual void SetPlaneOrientation(const PlaneOrientation& theOrient, int theNum = 0) { 
-    myBasePlane[theNum] = theOrient;
-  }
+  virtual void SetOrientation(const VISU_CutPlanesPL::PlaneOrientation& theOrient, 
+                             float theXAng, float theYAng, int theNum = 0);
 
+  virtual const PlaneOrientation& GetPlaneOrientation(int theNum = 0);
+  virtual float GetRotateX(int theNum = 0);
+  virtual float GetRotateY(int theNum = 0);
+  
   virtual float GetDisplacement(int theNum = 0) { return myDisplacement[theNum];}
   virtual void SetDisplacement(float theDisp, int theNum = 0) { myDisplacement[theNum] = theDisp;}
 
@@ -58,11 +60,6 @@ public:
   virtual void SetPartDefault(int thePartNumber);
   virtual int IsPartDefault(int thePartNumber);
 
-  virtual void SetRotateX(float theAngle, int theNum = 0);
-  virtual float GetRotateX(int theNum = 0);
-  virtual void SetRotateY(float theAngle, int theNum = 0);
-  virtual float GetRotateY(int theNum = 0);
-      
   virtual void SetNbParts(int theNb);
   virtual int GetNbParts(){ return myNbParts;}
     
index e125c4f98fd20727ac805137e2c17e11a5797fcc..9b200331a11350a366748ed4aa4ae466eb48accf 100644 (file)
@@ -41,10 +41,15 @@ vtkStandardNewMacro(VISU_DeformedShapePL);
 
 VISU_DeformedShapePL::VISU_DeformedShapePL(){
   myWarpVector = vtkWarpVector::New();
+  myCellDataToPointData = vtkCellDataToPointData::New();
 }
 
 VISU_DeformedShapePL::~VISU_DeformedShapePL(){
+  myWarpVector->UnRegisterAllOutputs();
   myWarpVector->Delete();
+
+  myCellDataToPointData->UnRegisterAllOutputs();
+  myCellDataToPointData->Delete();
 }
 
 void VISU_DeformedShapePL::ShallowCopy(VISU_PipeLine *thePipeLine){
@@ -92,7 +97,7 @@ void VISU_DeformedShapePL::Init(){
 }
 
 VISU_ScalarMapPL::THook* VISU_DeformedShapePL::DoHook(){
-  VISU::CellDataToPoint(myWarpVector,myInput,myFieldTransform);
+  VISU::CellDataToPoint(myWarpVector,myCellDataToPointData,myInput,myFieldTransform);
   return myWarpVector->GetOutput();
 }
 
index f555faef6e6491d47246ebc9425fc6a4c2f0c5a3..9c2f95a703e043f81b1352e7c0166c12c1d623ce 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "VISU_ScalarMapPL.hxx"
 
+class vtkCellDataToPointData;
 class SALOME_Transform;
 class vtkWarpVector;
 
@@ -55,8 +56,9 @@ public:
 protected:
   virtual THook* DoHook();
 
-  vtkWarpVector *myWarpVector;
   float myScaleFactor;
+  vtkWarpVector *myWarpVector;
+  vtkCellDataToPointData* myCellDataToPointData;
 };
 
 
index 0b3f78595054571e00556ba720df1e3483060dce..683f8d6fc736b4bba25fb883ab78ccc87876757c 100644 (file)
@@ -24,6 +24,9 @@
 //  Module : VISU
 
 #include "VISU_Extractor.hxx"   
+#include "VISU_PipeLineUtils.hxx"
+
+#include <sstream>     
 
 #include <vtkObjectFactory.h>
 #include <vtkUnstructuredGrid.h>
@@ -33,7 +36,7 @@
 
 using namespace std;
 
-#ifdef DEBUG
+#ifdef _DEBUG_
 static int MYDEBUG = 0;
 #else
 static int MYDEBUG = 0;
@@ -46,7 +49,8 @@ VISU_Extractor::VISU_Extractor(){
   myScalarMode = 0;
 }
 
-VISU_Extractor::~VISU_Extractor() {}
+VISU_Extractor::~VISU_Extractor(){
+}
 
 void VISU_Extractor::SetScalarMode(int theScalarMode){
   if(myScalarMode != theScalarMode){
@@ -62,7 +66,9 @@ execute(int theNbComp, int theScalarMode, TypeData* theInputData, TypeData* theO
   if ( !inVectors || theNbComp < 1 ) 
     return; 
   vtkFloatArray *newScalars = vtkFloatArray::New();
-  //newScalars->SetName(inVectors->GetName());
+  ostringstream aName;
+  aName<<inVectors->GetName();  aName<<", ";  aName<<theScalarMode;
+  newScalars->SetName(aName.str().c_str());
   newScalars->SetNumberOfComponents(1);
   newScalars->SetNumberOfTuples(theNbComp);
   for (int ptId = 0; ptId < theNbComp; ptId++) {
index 6889b7a92dab68ccc3c06e380f07fcab3b21ec23..7ab876d63a8060d742296b72f53ee63852f470dc 100644 (file)
@@ -33,7 +33,6 @@ class VTK_EXPORT VISU_Extractor : public vtkPointSetToPointSetFilter{
 public:
   vtkTypeMacro(VISU_Extractor,vtkPointSetToPointSetFilter);
   static VISU_Extractor *New();
-  ~VISU_Extractor();
 
   virtual int GetScalarMode(){ return myScalarMode;}
   virtual void SetScalarMode(int theScalarMode = 0);
@@ -41,6 +40,7 @@ public:
 protected:
   VISU_Extractor();
   VISU_Extractor(const VISU_Extractor&);
+  ~VISU_Extractor();
 
   virtual void Execute();
 
index ea239eb2f19f123330d43b39a5300b3648c4867f..2bb7f974f4802b2d9309b4777c3a7b5f3f35a478 100644 (file)
@@ -39,7 +39,9 @@ VISU_FieldTransform::VISU_FieldTransform(){
   myTransform = NULL;
 }
 
-VISU_FieldTransform::~VISU_FieldTransform() {}
+VISU_FieldTransform::~VISU_FieldTransform() {
+  SetSpaceTransform(NULL);
+}
 
 
 void VISU_FieldTransform::Update(){
@@ -84,6 +86,7 @@ void VISU_FieldTransform::SetScalarMax(float theValue){
   SetScalarRange(aScalarRange);
 }
 
+
 template<typename TypeData> void
 ExecVectors(VISU_FieldTransform::TTransformFun theFunction, 
            SALOME_Transform* theTransform,
@@ -103,15 +106,25 @@ ExecVectors(VISU_FieldTransform::TTransformFun theFunction,
     aScale[1] = theTransform->GetScale()[1];
     aScale[2] = theTransform->GetScale()[2];
   }
-  for (int ptId = 0; ptId < theNbComponent; ptId++) {
-    V = inVectors->GetTuple3(ptId);
-    vMag = vtkMath::Norm(V);
-    vMag = ((*theFunction)(vMag) - aScalarRange[0]) / aDelta * theScalarRange[1] / vMag;
-    if(vMag <= 0.0) vMag = 0.0;
-    v[0] = V[0]*vMag*aScale[0];
-    v[1] = V[1]*vMag*aScale[1];
-    v[2] = V[2]*vMag*aScale[2];
-    newVectors->SetTuple3(ptId, v[0], v[1], v[2]);
+  if(theFunction == &(VISU_FieldTransform::Ident)){
+    for (int ptId = 0; ptId < theNbComponent; ptId++) {
+      V = inVectors->GetTuple3(ptId);
+      v[0] = V[0]*aScale[0];
+      v[1] = V[1]*aScale[1];
+      v[2] = V[2]*aScale[2];
+      newVectors->SetTuple3(ptId, v[0], v[1], v[2]);
+    }
+  }else{
+    for (int ptId = 0; ptId < theNbComponent; ptId++) {
+      V = inVectors->GetTuple3(ptId);
+      vMag = vtkMath::Norm(V);
+      vMag = ((*theFunction)(vMag) - aScalarRange[0]) / aDelta * theScalarRange[1] / vMag;
+      if(vMag <= 0.0) vMag = 0.0;
+      v[0] = V[0]*vMag*aScale[0];
+      v[1] = V[1]*vMag*aScale[1];
+      v[2] = V[2]*vMag*aScale[2];
+      newVectors->SetTuple3(ptId, v[0], v[1], v[2]);
+    }
   }
   theOutputData->SetVectors(newVectors);
   newVectors->Delete();
index ecd27659f5064ba8483d24a877f61452aec6dfc9..b6bbb6433a3d70ece89a5f7db1ef39a60b7808bd 100644 (file)
 
 #include <vtkContourFilter.h>
 
-VISU_IsoSurfacesPL* VISU_IsoSurfacesPL::New(){
-  vtkObject* ret = vtkObjectFactory::CreateInstance("VISU_IsoSurfacesPL");
-  if(ret) return (VISU_IsoSurfacesPL*)ret;
-  return new VISU_IsoSurfacesPL;
-} 
+vtkStandardNewMacro(VISU_IsoSurfacesPL);
 
 VISU_IsoSurfacesPL::VISU_IsoSurfacesPL(){
   myContourFilter = vtkContourFilter::New();
+  myCellDataToPointData = vtkCellDataToPointData::New();
 }
 
 VISU_IsoSurfacesPL::~VISU_IsoSurfacesPL(){
+  myContourFilter->UnRegisterAllOutputs();
   myContourFilter->Delete();
+
+  myCellDataToPointData->UnRegisterAllOutputs();
+  myCellDataToPointData->Delete();
 }
 
 void VISU_IsoSurfacesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
@@ -100,7 +101,7 @@ VISU_ScalarMapPL::THook* VISU_IsoSurfacesPL::DoHook(){
 
 
 void VISU_IsoSurfacesPL::Update(){
-  VISU::CellDataToPoint(myContourFilter,myInput,myFieldTransform);
+  VISU::CellDataToPoint(myContourFilter,myCellDataToPointData,myInput,myFieldTransform);
   SetMapScale();
 
   VISU_ScalarMapPL::Update();
index 6eeb4564efe85dabfef9900ee1af0ee5d02e0f5a..68732e377d1abe0688041a5e0aadd98301a7a84e 100644 (file)
@@ -30,6 +30,7 @@
 #include "VISU_ScalarMapPL.hxx"
 
 class vtkContourFilter;
+class vtkCellDataToPointData;
 
 class VISU_IsoSurfacesPL : public VISU_ScalarMapPL{
 protected:
@@ -58,6 +59,7 @@ public:
 protected:
   int myNbParts;
   float myRange[2];
+  vtkCellDataToPointData* myCellDataToPointData;
   vtkContourFilter *myContourFilter;
 };
 
index d4354e35bed350edc3bc6a5d6071abc8c3b456b7..e128b7083f4cf28fbfb4dec3f1d4c111d41c36bc 100644 (file)
 
 
 #include "VISU_PipeLine.hxx"
+#include "VISU_PipeLineUtils.hxx"
+
+#include <limits.h>
 
 #include <vtkObjectFactory.h>
 #include <vtkDataSetMapper.h>
 #include <vtkUnstructuredGrid.h>
 
+static int MYVTKDEBUG = 0;
+
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
 static int MYDEBUGWITHFILES = 0;
@@ -43,11 +48,14 @@ static int MYDEBUGWITHFILES = 0;
 VISU_PipeLine::VISU_PipeLine(){
   myMapper = TMapper::New();
   myInput = NULL;
+  SetDebug(MYVTKDEBUG);
 }
 
 VISU_PipeLine::~VISU_PipeLine(){
-  myMapper->Delete();
+  if(MYDEBUG) MESSAGE("~VISU_PipeLine - myInput = "<<myInput->GetReferenceCount());
   SetInput(NULL);
+  myMapper->RemoveAllInputs();
+  myMapper->Delete();
 }
 
 void VISU_PipeLine::ShallowCopy(VISU_PipeLine *thePipeLine){
@@ -57,13 +65,14 @@ void VISU_PipeLine::ShallowCopy(VISU_PipeLine *thePipeLine){
 }
 
 void VISU_PipeLine::SetInput(TInput* theInput){
-  if (myInput != theInput){
+  if(myInput != theInput){
     if (myInput != NULL) myInput->UnRegister(this);
     myInput = theInput;
-    if (myInput != NULL) {
+    if(myInput != NULL){
       myInput->Register(this);
       myInput->Update();
-    }
+    }else
+      myMapper->SetInput(NULL);
     Modified();
   }
 }
@@ -84,23 +93,25 @@ void VISU_PipeLine::Update(){
 }
 
 
-size_t VISU_PipeLine::CheckAvailableMemory(const size_t& theSize){
+int VISU_PipeLine::CheckAvailableMemory(const float& theSize){
   try{
-    char *aCheck = new char[theSize];
+    if(theSize > ULONG_MAX) return 0;
+    size_t aSize = size_t(theSize);
+    char *aCheck = new char[aSize];
     if(aCheck) delete [] aCheck;
     if(MYDEBUG && aCheck == NULL)
-      cout<<"VISU_PipeLine::CheckAvailableMemory("<<theSize<<") - cannot alloacate such amount of memory!!!\n";
+      MESSAGE("CheckAvailableMemory("<<theSize<<") - cannot alloacate such amount of memory!!!");
     return aCheck != NULL;
     //return theSize < 1000*1024*1024;
   }catch(...){
     if(MYDEBUG)
-      cout<<"VISU_PipeLine::CheckAvailableMemory("<<theSize<<") - unexpected exception was caught!!!\n";
+      MESSAGE("CheckAvailableMemory("<<theSize<<") - unexpected exception was caught!!!");
   }
   return 0;
 }
 
 
-size_t VISU_PipeLine::GetAvailableMemory(size_t theSize, size_t theMinSize){
+float VISU_PipeLine::GetAvailableMemory(float theSize, float theMinSize){
   while(!CheckAvailableMemory(theSize))
     if(theSize > theMinSize)
       theSize /= 2;
index 21a8b24d4b2ecb8e39f69f528b87e8f685d5914f..1a55be8eb25f94920ac807473e1d2a08424ef12f 100644 (file)
@@ -55,9 +55,9 @@ public:
   virtual void Init() = 0;
   virtual void Update();
 
-  static size_t CheckAvailableMemory(const size_t& theSize);
-  static size_t GetAvailableMemory(size_t theSize = 16*1024*1024, 
-                                  size_t theMinSize = 1024*1024);
+  static int CheckAvailableMemory(const float& theSize);
+  static float GetAvailableMemory(float theSize = 16*1024*1024.0,
+                                 float theMinSize = 1024*1024.0);
 protected:
   virtual void Build() = 0;
   
index a624239981f1a414c357893b5c237b2978d09cb1..df7c8219ec87a2b871fb97f06b51f06749939fac 100644 (file)
 
 #include <vtkMath.h>
 
+#ifndef MESSAGE
+#define MESSAGE(msg) std::cout<<__FILE__<<"["<<__LINE__<<"]::"<<msg<<endl
+
+#undef EXCEPT
+#define EXCEPT(msg) QString(QString(__FILE__) + "[" + QString::number(__LINE__) + "]::" + msg)
+
+#undef EXCEPTION
+#define EXCEPTION(msg) EXCEPT(msg).latin1()
+
+#endif
+
 namespace VISU{
   void Mul(const float A[3], float b, float C[3]); // C = A * b
   void Sub(const float A[3], const float B[3], float C[3]); // C = A - B
 
-  template<class TItem> void CellDataToPoint(TItem* theTItem, vtkDataSet* theDataSet,
+  template<class TItem> void CellDataToPoint(TItem* theTItem, 
+                                            vtkCellDataToPointData *theFilter,
+                                            vtkDataSet* theDataSet,
                                             VISU_FieldTransform *theFieldTransform)
   {
     if(theDataSet->GetCellData()->GetNumberOfArrays()){
-      vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New();
-      aFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
-      aFilter->PassCellDataOn();
-      theTItem->SetInput(aFilter->GetUnstructuredGridOutput());
-      aFilter->Register(theTItem);
-      aFilter->Delete();
+      theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
+      theFilter->PassCellDataOn();
+      theTItem->SetInput(theFilter->GetUnstructuredGridOutput());
     }else
       theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput());
   }
 
-  template<class TItem> void ToCellCenters(TItem* theTItem, vtkDataSet* theDataSet,
+  template<class TItem> void ToCellCenters(TItem* theTItem, 
+                                          vtkCellCenters *theFilter,
+                                          vtkDataSet* theDataSet,
                                           VISU_FieldTransform *theFieldTransform)
   {
     if(theDataSet->GetCellData()->GetNumberOfArrays()){
-      vtkCellCenters *aCenters = vtkCellCenters::New(); // for vectors on cells
-      aCenters->SetInput(theFieldTransform->GetUnstructuredGridOutput());
-      aCenters->VertexCellsOn();
-      theTItem->SetInput(aCenters->GetOutput());
-      aCenters->Register(theTItem);
-      aCenters->Delete();
+      theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
+      theFilter->VertexCellsOn();
+      theTItem->SetInput(theFilter->GetOutput());
     }else
       theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput());
   }
index 5025d98ec9b6a10f25da8fce87e58358f6e6b5a7..d7b7b4a6f43f1a7d7cbd8344423b7d25774c7725 100644 (file)
@@ -40,6 +40,7 @@ vtkStandardNewMacro(VISU_ScalarMapPL);
 
 VISU_ScalarMapPL::VISU_ScalarMapPL(){
   myFieldTransform = VISU_FieldTransform::New();
+  //myFieldTransform->DebugOn();
 
   myMapperTable = VISU_LookupTable::New();
   myMapperTable->SetScale(VTK_SCALE_LINEAR);
@@ -50,13 +51,16 @@ VISU_ScalarMapPL::VISU_ScalarMapPL(){
   myBarTable->SetHueRange(0.667,0.0);
 
   myExtractor = VISU_Extractor::New();
+  //myExtractor->DebugOn();
 }
 
 
 VISU_ScalarMapPL::~VISU_ScalarMapPL(){
+  myFieldTransform->UnRegisterAllOutputs();
   myFieldTransform->Delete();
   myMapperTable->Delete();;
   myBarTable->Delete();
+  myExtractor->UnRegisterAllOutputs();
   myExtractor->Delete();
 }
 
@@ -156,8 +160,6 @@ void VISU_ScalarMapPL::Update() {
   myMapper->SetLookupTable(myMapperTable);   
   myMapper->SetScalarRange(aScalarRange);
 
-  myFieldTransform->Update();
-
   VISU_PipeLine::Update();
 }
 
index fabf699384ec74d8e8c1147d45d3f875a3738bf2..f219d4a3ce9373255265ae874b469c24c7fc47bd 100644 (file)
 #include "VISU_UsedPointsFilter.hxx"
 #include "SALOME_GeometryFilter.h"
 
+#include <algo.h>
+
+#include <vtkCell.h>
 #include <vtkPointSet.h>
 #include <vtkStreamLine.h>
 
 #ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
 #else
 static int MYDEBUG = 0;
 #endif
 
-static float EPS = 1.0e-20;
-int VISU_StreamLinesPL::myMaxIncrementMemorySize = 64;
-
-void SetStreamerSource(vtkStreamer *theStreamer, vtkPointSet* theDataSet, float thePercents){
-  theDataSet->Update();
-  VISU_UsedPointsFilter* anUsedPointsFilter = VISU_UsedPointsFilter::New();
-  anUsedPointsFilter->SetInput(theDataSet);
-  anUsedPointsFilter->SetPercentsOfUsedPoints(thePercents);
-  theStreamer->SetSource(anUsedPointsFilter->GetOutput());
-  anUsedPointsFilter->Register(theStreamer);
-  anUsedPointsFilter->Delete();
-}
+static float EPS = 1.0e-7;
+static float aMinNbOfSteps = 1.0E+2;
+static float aMaxNbOfSteps = 1.0E+3;
+static float aCoeffOfIntStep = 1.0E+1;
 
 
 vtkStandardNewMacro(VISU_StreamLinesPL);
 
 VISU_StreamLinesPL::VISU_StreamLinesPL(){
   myStream = vtkStreamLine::New();
+  myCenters = vtkCellCenters::New();
   myGeomFilter = SALOME_GeometryFilter::New();
+  myPointsFilter = VISU_UsedPointsFilter::New();
+  myPercents = 0.3;
   mySource = NULL;
 }
 
 VISU_StreamLinesPL::~VISU_StreamLinesPL(){
-  myStream->Delete();
+  myPointsFilter->UnRegisterAllOutputs();
+  myPointsFilter->Delete();
+
+  myCenters->UnRegisterAllOutputs();
+  myCenters->Delete();
+
+  myGeomFilter->UnRegisterAllOutputs();
   myGeomFilter->Delete();
-  SetSource(NULL);
+
+  myStream->UnRegisterAllOutputs();
+  myStream->Delete();
 }
 
 void VISU_StreamLinesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
   VISU_DeformedShapePL::ShallowCopy(thePipeLine);
-  if(VISU_StreamLinesPL *aPipeLine = dynamic_cast<VISU_StreamLinesPL*>(thePipeLine)){
+  if(VISU_StreamLinesPL *aPipeLine = dynamic_cast<VISU_StreamLinesPL*>(thePipeLine))
+    SetParams(aPipeLine->GetIntegrationStep(),
+             aPipeLine->GetPropagationTime(),
+             aPipeLine->GetStepLength(),
+             aPipeLine->GetSource(),
+             aPipeLine->GetUsedPoints(),
+             aPipeLine->GetDirection());
+}
+
 
-    //Order of setting of the values are important 
-    SetUsedPoints(aPipeLine->GetUsedPoints());
-    SetSource(aPipeLine->GetSource());
+float VISU_StreamLinesPL::GetNecasseryMemorySize(vtkIdType theNbOfPoints, float theStepLength, 
+                                                float thePropogationTime, float thePercents)
+{
+  static float aStreamPointSize = sizeof(float)*15 + sizeof(vtkIdType)*2;
+  static float aStreamArraySize = aStreamPointSize*1024; // == 69632
 
-    SetDirection(aPipeLine->GetDirection());
+  float aNbCells = thePercents*theNbOfPoints*2.0;
+  float aNbPointsPerCell = thePropogationTime/theStepLength;
+  float aCellsSize = aNbCells*(1+aNbPointsPerCell);
+  float aPointsSize = aCellsSize*3.0*sizeof(float);
 
-    //Order of setting of the values are important 
-    SetIntegrationStep(aPipeLine->GetIntegrationStep());
-    SetPropagationTime(aPipeLine->GetPropagationTime());
-    SetStepLength(aPipeLine->GetStepLength());
+  float aConnectivitySize = aCellsSize*sizeof(vtkIdType);
+  float aTypesSize = aNbCells*sizeof(char);
+  float aLocationsSize = aNbCells*sizeof(int);
+  float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
+  float aMeshSize = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize;
+
+  float anAssignedDataSize = aCellsSize*4.0*sizeof(float);
+  float anOutputDataSetSize = aMeshSize + anAssignedDataSize;
+
+  float aResult = aStreamArraySize*aNbCells + anOutputDataSetSize;
+  return aResult;
+}
+
+int VISU_StreamLinesPL::FindPossibleParams(vtkPointSet* theDataSet, float& theStepLength, 
+                                          float& thePropogationTime, float& thePercents)
+{
+  static float aPercentsDecrease = 3.0, aStepLengthIncrease = 9.0;
+  vtkIdType aNbOfPoints = theDataSet->GetNumberOfPoints();
+  float aSize = GetNecasseryMemorySize(aNbOfPoints,theStepLength,thePropogationTime,thePercents);
+  int isPoss = CheckAvailableMemory(aSize);
+  if(!isPoss){
+    float aMaxStepLength = max(GetMaxStepLength(theDataSet),thePropogationTime);
+    float aMinStepLength = GetMinStepLength(theDataSet);
+    float aDeltaStepLength = (aMaxStepLength - aMinStepLength)/aStepLengthIncrease;
+    for(int i = 2, aStepChanged = 1, aPerecentsChanged = 1; aStepChanged || aPerecentsChanged; i++){
+      float aStepLength = theStepLength + aDeltaStepLength;
+      if(aStepLength < aMaxStepLength) theStepLength = aStepLength;
+      else if(aStepChanged){
+       aStepLength = aMaxStepLength;
+       aStepChanged = 0;
+      }
+      float aPercents = thePercents /= aPercentsDecrease;
+      if(aPercents*aNbOfPoints > 1) thePercents = aPercents;
+      else if(aPerecentsChanged) {
+       thePercents = 1.1 / aNbOfPoints;
+       aPerecentsChanged = 0;
+      }
+      aSize = GetNecasseryMemorySize(aNbOfPoints,theStepLength,thePropogationTime,thePercents);
+      if(CheckAvailableMemory(aSize)){
+       isPoss = i;
+       break;
+      }
+    }
   }
+  if(MYDEBUG) MESSAGE("FindPossibleParams - aSize = "<<aSize<<"; isPoss = "<<isPoss);
+  return isPoss;
 }
 
-void VISU_StreamLinesPL::SetSource(vtkPointSet* theSource){
-  if (mySource != NULL) mySource->UnRegister(this);
-  mySource = theSource;
-  if (mySource != NULL) mySource->Register(this);
-  if(myInput && myInput->GetCellData()->GetNumberOfArrays()){
-    vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New();
-    aFilter->SetInput(myFieldTransform->GetUnstructuredGridOutput());
-    aFilter->PassCellDataOn();
-    myStream->SetInput(aFilter->GetOutput());
-    aFilter->Register(myStream);
-    aFilter->Delete();
-    vtkCellCenters *centers = vtkCellCenters::New(); // for vectors on cells
-    centers->SetInput(myFieldTransform->GetUnstructuredGridOutput());
-    centers->VertexCellsOn();
-    mySource = mySource? mySource: centers->GetOutput();
-    SetStreamerSource(myStream,mySource,myPercents);
-    centers->Register(myStream);
-    centers->Delete();
-  }else{
-    myStream->SetInput(myFieldTransform->GetUnstructuredGridOutput());
-    mySource = mySource? mySource: myFieldTransform->GetUnstructuredGridOutput();
-    SetStreamerSource(myStream,mySource,myPercents);
+
+int VISU_StreamLinesPL::SetParams(float theIntStep, 
+                                 float thePropogationTime,
+                                 float theStepLength,
+                                 vtkPointSet* theSource, 
+                                 float thePercents,            
+                                 int theDirection,
+                                 int isOnlyTry)
+{
+  vtkPointSet* aDataSet = theSource? theSource: myFieldTransform->GetUnstructuredGridOutput();
+  aDataSet->Update();
+  vtkIdType aNbOfPoints = aDataSet->GetNumberOfPoints();
+  vtkPointSet* aPointSet = myExtractor->GetOutput();
+  if(thePercents*aNbOfPoints < 1) thePercents = 2.0/aNbOfPoints;
+  theIntStep = CorrectIntegrationStep(theIntStep,aPointSet,thePercents);
+  thePropogationTime = CorrectPropagationTime(thePropogationTime,aPointSet);
+  theStepLength = CorrectStepLength(theStepLength,aPointSet);
+  int isAccepted = FindPossibleParams(aPointSet,theStepLength,thePropogationTime,thePercents);
+  if((!isOnlyTry && isAccepted) || (isOnlyTry && isAccepted == 1)){
+    mySource = theSource;
+    myPercents = thePercents;
+    if(myInput->GetCellData()->GetNumberOfArrays()){
+      myCenters->SetInput(aDataSet);
+      myCenters->VertexCellsOn();
+      aDataSet = myCenters->GetOutput();
+    }
+    myPointsFilter->SetInput(aDataSet);
+    myPointsFilter->SetPercentsOfUsedPoints(thePercents);
+    aDataSet = myPointsFilter->GetOutput();
+    myStream->SetSource(aDataSet);
+    myStream->SetIntegrationStepLength(theIntStep);
+    myStream->SetMaximumPropagationTime(thePropogationTime);
+    myStream->SetStepLength(theStepLength);
+    myStream->SetSavePointInterval(theIntStep*aMinNbOfSteps);
+    myStream->SetIntegrationDirection(theDirection);
+    myStream->Modified();
+    Modified();
   }
-  myStream->Modified();
-  Modified();
+  return isAccepted;
 }
 
 
-float VISU_StreamLinesPL::GetMaxIntegrationStep(vtkPointSet* theDataSet) {
-  if(!theDataSet) return 0.0;
-  theDataSet->Update();
-  float* aBounds = theDataSet->GetBounds();
-  float aMaxSizeY = aBounds[3] - aBounds[2];
-  float aMaxSizeZ = aBounds[5] - aBounds[4];
-  float aMinMax = aBounds[1] - aBounds[0];
-  if (aMinMax < EPS || (aMaxSizeY < aMinMax && aMaxSizeY > EPS)) aMinMax = aMaxSizeY;
-  if (aMinMax < EPS || (aMaxSizeZ < aMinMax && aMaxSizeZ > EPS)) aMinMax = aMaxSizeZ;
-  return aMinMax / 2.0;
-} 
+vtkPointSet* VISU_StreamLinesPL::GetSource() {
+  return mySource;
+}
+
+float VISU_StreamLinesPL::GetUsedPoints() { 
+  return myPercents;
+}
+
+vtkDataSet* VISU_StreamLinesPL::GetStreamerSource(){
+  return myStream->GetSource();
+}
+
+float VISU_StreamLinesPL::GetVelocityCoeff(){
+  return GetVelocityCoeff(myExtractor->GetOutput());
+}
+
+float VISU_StreamLinesPL::GetVelocityCoeff(vtkPointSet* theDataSet){
+  float* aScalarRange = theDataSet->GetScalarRange();
+  return (fabs(aScalarRange[1]) + fabs(aScalarRange[0]))/2.0;
+}
+
+
+int VISU_StreamLinesPL::IsPossible(vtkPointSet* theDataSet, float thePercents){
+  float aStepLength = GetBaseStepLength(theDataSet);
+  float aBasePropTime = GetBasePropagationTime(theDataSet);
+  VISU_UsedPointsFilter *aPointsFilter = VISU_UsedPointsFilter::New();
+  aPointsFilter->SetInput(theDataSet);
+  vtkPointSet* aDataSet = aPointsFilter->GetOutput();
+  aDataSet->Update();
+  int aRes = FindPossibleParams(aDataSet,aStepLength,aBasePropTime,thePercents);
+  aPointsFilter->UnRegisterAllOutputs();
+  aPointsFilter->Delete();
+  return aRes;
+}
+
 
-float VISU_StreamLinesPL::GetMinIntegrationStep(vtkPointSet* theDataSet) {
-  if(!theDataSet) return 0.0;
+float VISU_StreamLinesPL::GetIntegrationStep(){
+  return myStream->GetIntegrationStepLength();
+}
+float VISU_StreamLinesPL::GetStepLength() { 
+  return myStream->GetStepLength();
+}
+float VISU_StreamLinesPL::GetPropagationTime() { 
+  return myStream->GetMaximumPropagationTime();
+}
+int VISU_StreamLinesPL::GetDirection(){
+  return myStream->GetIntegrationDirection();
+}
+
+
+float VISU_StreamLinesPL::GetMinIntegrationStep(vtkPointSet* theDataSet, float thePercents) {
+  if(!theDataSet) return -1.0;
   float aVolume = 1.0, tmp;
   int degree = 0;
   theDataSet->Update();
@@ -138,112 +250,144 @@ float VISU_StreamLinesPL::GetMinIntegrationStep(vtkPointSet* theDataSet) {
     }
   }
   if (degree < 1) return 0.0; // absolutely empty object
-  unsigned long aSize = 1024*theDataSet->GetActualMemorySize();
-  // we have to use no more, than myMaxIncrementMemorySize*aSize amount of memory
-  unsigned long aRealSize = GetAvailableMemory(myMaxIncrementMemorySize*aSize);
-  if(MYDEBUG) cout<<"GetMinIntegrationStep - GetActualMemorysize() = "<<aRealSize<<"; "<<aSize<<endl;
+  float anStepLength = GetMaxIntegrationStep(theDataSet)/aCoeffOfIntStep;
+  float aBasePropTime = GetBasePropagationTime(theDataSet)/GetVelocityCoeff(theDataSet);
+  thePercents = 1.0;
+  vtkIdType aNbOfPoints = theDataSet->GetNumberOfPoints();
+  float aSize = GetNecasseryMemorySize(aNbOfPoints,anStepLength,aBasePropTime,thePercents);
+  float aRealSize = GetAvailableMemory(aSize);
   float anAverageVolume = aVolume / aRealSize; 
   float aStep = pow(double(anAverageVolume), double(1.0/double(degree)));
   return aStep;
 }
+float VISU_StreamLinesPL::GetMinIntegrationStep(){ 
+  return GetMinIntegrationStep(myExtractor->GetOutput(),GetUsedPoints());
+}
 
-float VISU_StreamLinesPL::GetBasePropagationTime(vtkPointSet* theDataSet) {
-  if(!theDataSet) return 0.0;
+
+float VISU_StreamLinesPL::GetMaxIntegrationStep(vtkPointSet* theDataSet) {
+  if(!theDataSet) return -1.0;
   theDataSet->Update();
-  float* aScalarRange = theDataSet->GetScalarRange();
-  return theDataSet->GetLength()/fabs(aScalarRange[1] + aScalarRange[0])*2.0;
+  float aLength = theDataSet->GetLength();
+  float* aBounds = theDataSet->GetBounds();
+  float aMaxSizeY = (aBounds[3]-aBounds[2])/aLength;
+  float aMaxSizeZ = (aBounds[5]-aBounds[4])/aLength;
+  float aMinMax = (aBounds[1] - aBounds[0])/aLength;
+  if (aMinMax < EPS || (aMaxSizeY < aMinMax && aMaxSizeY > EPS)) aMinMax = aMaxSizeY;
+  if (aMinMax < EPS || (aMaxSizeZ < aMinMax && aMaxSizeZ > EPS)) aMinMax = aMaxSizeZ;
+  return aMinMax*aLength/2.0;
+} 
+float VISU_StreamLinesPL::GetMaxIntegrationStep(){ 
+  return GetMaxIntegrationStep(myExtractor->GetOutput());
 }
 
-
-int VISU_StreamLinesPL::GetDirection(){
-  return myStream->GetIntegrationDirection();
+float VISU_StreamLinesPL::GetBaseIntegrationStep(vtkPointSet* theDataSet, float thePercents){ 
+  theDataSet->Update();
+  float aMinIntegrationStep = GetMinIntegrationStep(theDataSet,thePercents);
+  float aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet);
+  float anIntegrationStep = aMaxIntegrationStep / aCoeffOfIntStep;
+  float aMinMax = theDataSet->GetLength()/theDataSet->GetNumberOfPoints();
+  if(aMinMax > anIntegrationStep) 
+    anIntegrationStep = (anIntegrationStep*aCoeffOfIntStep*0.9+aMinMax)/aCoeffOfIntStep;
+  if(aMinIntegrationStep > anIntegrationStep) 
+    anIntegrationStep = aMinIntegrationStep;
+  return anIntegrationStep;
 }
-void VISU_StreamLinesPL::SetDirection(int theDirection){
-  myStream->SetIntegrationDirection(theDirection);
-  Modified();
+
+float VISU_StreamLinesPL::CorrectIntegrationStep(float theStep, vtkPointSet* theDataSet, float thePercents){ 
+  theDataSet->Update();
+  float aMinIntegrationStep = GetMinIntegrationStep(theDataSet,thePercents);
+  float aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet);
+  if(aMinIntegrationStep > theStep)
+    theStep = aMinIntegrationStep;
+  if(aMaxIntegrationStep < theStep)
+    theStep = aMaxIntegrationStep;
+  return theStep;
 }
 
 
-float VISU_StreamLinesPL::GetPropagationTime() { 
-  return myStream->GetMaximumPropagationTime();
+float VISU_StreamLinesPL::GetMinPropagationTime(vtkPointSet* theDataSet){
+  if(!theDataSet) return -1.0;
+  return GetMinStepLength(theDataSet);
 }
-void VISU_StreamLinesPL::SetPropagationTime(float theTime) { 
-  if(myStream->GetMaximumPropagationTime() == theTime) return;
-  myStream->SetMaximumPropagationTime(theTime);
-  Modified();
+float VISU_StreamLinesPL::GetMinPropagationTime(){
+  return GetMinPropagationTime(myExtractor->GetOutput());
 }
 
+float VISU_StreamLinesPL::GetMaxPropagationTime(vtkPointSet* theDataSet){
+  if(!theDataSet) return -1.0;
+  return GetBasePropagationTime(theDataSet)*aMinNbOfSteps;
+}
+float VISU_StreamLinesPL::GetMaxPropagationTime(){
+  return GetMaxPropagationTime(myExtractor->GetOutput());
+}
 
-float VISU_StreamLinesPL::GetIntegrationStep(){
-  return myStream->GetIntegrationStepLength();
+float VISU_StreamLinesPL::CorrectPropagationTime(float thePropagationTime, vtkPointSet* theDataSet){
+  float aMinPropagationTime = GetMinPropagationTime(theDataSet);
+  float aMaxPropagationTime = GetMaxPropagationTime(theDataSet);
+  if(aMinPropagationTime > thePropagationTime)
+    thePropagationTime = aMinPropagationTime;
+  if(aMaxPropagationTime < thePropagationTime)
+    thePropagationTime = aMaxPropagationTime;
+  return thePropagationTime;
 }
-float VISU_StreamLinesPL::SetIntegrationStep(float theStep){ 
-  if(myStream->GetIntegrationStepLength() == theStep) return theStep;
-  myExtractor->Update();
-  vtkPointSet* aDataSet = GetSource();
-  aDataSet->Update();
-  float anIntegrationStep = theStep;
-  float aMinIntegrationStep = GetMinIntegrationStep(aDataSet);
-  float aMaxIntegrationStep = GetMaxIntegrationStep(aDataSet);
-  if(aMinIntegrationStep < anIntegrationStep && anIntegrationStep < aMaxIntegrationStep){
-    myStream->SetIntegrationStepLength(theStep);
-    Modified();
-  }else{
-    anIntegrationStep = aMaxIntegrationStep / 10.0;
-    float aMinMax = aDataSet->GetLength()/myInput->GetNumberOfPoints();
-    if(aMinMax > anIntegrationStep) 
-      anIntegrationStep = (anIntegrationStep*9.0+aMinMax)/10.0;
-    if(aMinIntegrationStep > anIntegrationStep) 
-      anIntegrationStep = aMinIntegrationStep;
-  }
-  return anIntegrationStep;
+float VISU_StreamLinesPL::GetBasePropagationTime(vtkPointSet* theDataSet){
+  if(!theDataSet) return -1.0;
+  theDataSet->Update();
+  float aPropagationTime = theDataSet->GetLength()/GetVelocityCoeff(theDataSet);
+  return aPropagationTime;
+}
+float VISU_StreamLinesPL::GetBasePropagationTime(){ 
+  return GetBasePropagationTime(myExtractor->GetOutput());
 }
 
 
-float VISU_StreamLinesPL::GetStepLength() { 
-  return myStream->GetStepLength();
+float VISU_StreamLinesPL::GetMinStepLength(vtkPointSet* theDataSet){
+  static float aNbOfStepsOfIntStep = 1.0E+1;
+  float anIntStep = GetMinIntegrationStep(theDataSet);
+  float aStepLength = anIntStep*aNbOfStepsOfIntStep/GetVelocityCoeff(theDataSet);
+  return aStepLength;
 }
-float VISU_StreamLinesPL::GetMinStepLength(float theIntegrationStep){
-  return theIntegrationStep*2.0;
+float VISU_StreamLinesPL::GetMinStepLength(){
+  return GetMinStepLength(myExtractor->GetOutput());
+}
+
+float VISU_StreamLinesPL::GetMaxStepLength(vtkPointSet* theDataSet){
+  float aStepLength = GetBasePropagationTime(theDataSet);
+  return aStepLength;
 }
-float VISU_StreamLinesPL::GetMaxStepLength(float thePropagationTime){
-  return thePropagationTime/100.0;
+float VISU_StreamLinesPL::GetMaxStepLength(){
+  return GetMaxStepLength(myExtractor->GetOutput());
 }
-float VISU_StreamLinesPL::CorrectStepLength(float theStep, float theIntegrationStep, float thePropagationTime){
-  float aMinStep = GetMinStepLength(theIntegrationStep);
+
+float VISU_StreamLinesPL::CorrectStepLength(float theStep, vtkPointSet* theDataSet){
+  float aMinStep = GetMinStepLength(theDataSet);
   if(theStep < aMinStep) theStep = aMinStep;
-  float aMaxStep = GetMaxStepLength(thePropagationTime);
+  float aMaxStep = GetMaxStepLength(theDataSet);
   if(theStep > aMaxStep) theStep = aMaxStep;
   return theStep;
 }
-float VISU_StreamLinesPL::SetStepLength(float theStep){
-  if(myStream->GetStepLength() == theStep) return theStep;
-  float aStepLength = CorrectStepLength(theStep,GetIntegrationStep(),GetPropagationTime());
-  if(aStepLength == theStep){
-    myStream->SetStepLength(theStep);
-    Modified();
-  }
+float VISU_StreamLinesPL::GetBaseStepLength(vtkPointSet* theDataSet){
+  static float anAvgNbOfSteps = 1.0E+2;
+  float aPropagationTime = GetBasePropagationTime(theDataSet);
+  float aStepLength = aPropagationTime/anAvgNbOfSteps;
+  aStepLength = CorrectStepLength(aStepLength,theDataSet);
   return aStepLength;
 }
 
 
 void VISU_StreamLinesPL::Init(){
   VISU_ScalarMapPL::Init();
-
-  SetDirection(VTK_INTEGRATE_BOTH_DIRECTIONS);
-  vtkPointSet* aDataSet = myExtractor->GetOutput();                                                    
-  //Order of setting of the values are important 
-  myPercents = 0.3;
-  SetSource(NULL);
-
-  SetIntegrationStep(SetIntegrationStep(GetMaxIntegrationStep(aDataSet)/10.0));
-  SetPropagationTime(GetBasePropagationTime(aDataSet));
-  SetStepLength(SetStepLength(GetPropagationTime()/20.));
+  vtkPointSet* aDataSet = myExtractor->GetOutput();
+  float anIntStep = GetBaseIntegrationStep(aDataSet);
+  float aPropagationTime = GetBasePropagationTime(aDataSet);
+  float aStepLength = GetBaseStepLength(aDataSet);
+  SetParams(anIntStep,aPropagationTime,aStepLength);
 }
 
 VISU_ScalarMapPL::THook* VISU_StreamLinesPL::DoHook(){
-  SetSource(NULL);
   myInput->Update();
+  VISU::CellDataToPoint(myStream,myCellDataToPointData,myInput,myFieldTransform);
   float *aBounds = myInput->GetBounds();
   myGeomFilter->SetExtent(aBounds);
   myGeomFilter->ExtentClippingOn();
index ab56a0411544bb7cf293cfaf3280495e101ae5c2..6e9bc4138fc3e8ca0743ad22ad855c1ed6545189 100644 (file)
@@ -31,7 +31,9 @@
 #include <vtkStreamLine.h>
 
 class vtkPointSet;
+class vtkCellCenters;
 class SALOME_GeometryFilter;
+class VISU_UsedPointsFilter;
 
 class VISU_StreamLinesPL : public VISU_DeformedShapePL{
 protected:
@@ -43,27 +45,32 @@ public:
   virtual ~VISU_StreamLinesPL();
   virtual void ShallowCopy(VISU_PipeLine *thePipeLine);
 
-  virtual int GetDirection();
-  virtual void SetDirection(int theDirection);
-
-  virtual float GetStepLength();
-  virtual float SetStepLength(float theStep);
-
+  virtual int SetParams(float theIntStep, 
+                       float thePropogationTime,
+                       float theStepLength,
+                       vtkPointSet* theSource = NULL, 
+                       float thePercents = 0.3,
+                       int theDirection = VTK_INTEGRATE_BOTH_DIRECTIONS,
+                       int isOnlyTry = false);
+  virtual vtkPointSet* GetSource();
+  virtual float GetUsedPoints();
+  virtual float GetIntegrationStep();
   virtual float GetPropagationTime();
-  virtual void SetPropagationTime(float theTime);
+  virtual float GetStepLength();
+  virtual int GetDirection();
 
-  virtual float GetIntegrationStep();
-  virtual float SetIntegrationStep(float theStep);
+  virtual vtkDataSet* GetStreamerSource();
+  virtual float GetVelocityCoeff();
 
-  virtual void SetSource(vtkPointSet* theSource);
-  virtual vtkPointSet* GetSource() {return mySource;}
+  virtual float GetMaxIntegrationStep();
+  virtual float GetMinIntegrationStep();
 
-  virtual void SetUsedPoints(float thePercents) { myPercents = thePercents;}
-  virtual float GetUsedPoints() { return myPercents;}
+  virtual float GetMinStepLength();
+  virtual float GetMaxStepLength();
 
-  virtual float GetMaxIntegrationStep(){ return GetMaxIntegrationStep(GetSource());}
-  virtual float GetMinIntegrationStep(){ return GetMinIntegrationStep(GetSource());}
-  virtual float GetBasePropagationTime(){ return GetBasePropagationTime(GetSource());};
+  virtual float GetMinPropagationTime();
+  virtual float GetMaxPropagationTime();
+  virtual float GetBasePropagationTime();
 
 public:
   virtual THook* DoHook();
@@ -72,22 +79,40 @@ public:
   virtual void SetMapScale(float theMapScale = 1.0);
 
 public:
-  static int myMaxIncrementMemorySize;
-
-  static float GetMinStepLength(float theIntegrationStep);
-  static float GetMaxStepLength(float thePropagationTime);
-  static float CorrectStepLength(float theStep, float theIntegrationStep, float thePropagationTime);
-
   static float GetMaxIntegrationStep(vtkPointSet* theDataSet);
-  static float GetMinIntegrationStep(vtkPointSet* theDataSet);
+  static float GetMinIntegrationStep(vtkPointSet* theDataSet, float thePercents = 0.3);
+  static float GetBaseIntegrationStep(vtkPointSet* theDataSet, float thePercents = 0.3);
+  
+  static float GetMinPropagationTime(vtkPointSet* theDataSet);
+  static float GetMaxPropagationTime(vtkPointSet* theDataSet);
   static float GetBasePropagationTime(vtkPointSet* theDataSet);
 
+  static float GetMinStepLength(vtkPointSet* theDataSet);
+  static float GetMaxStepLength(vtkPointSet* theDataSet);
+  static float GetBaseStepLength(vtkPointSet* theDataSet);
+
+  static float GetVelocityCoeff(vtkPointSet* theDataSet);
+
+  static int IsPossible(vtkPointSet* theDataSet, float thePercents = 0.3);
+
 protected:
+  static float GetNecasseryMemorySize(vtkIdType theNbOfPoints, float theStepLength, 
+                                     float thePropogationTime, float thePercents = 0.3);
+  static int FindPossibleParams(vtkPointSet* theDataSet, float& theStepLength, 
+                               float& thePropogationTime, float& thePercents);
+  
+  static float CorrectIntegrationStep(float theStep, vtkPointSet* theDataSet, float thePercents = 0.3);
+  static float CorrectPropagationTime(float thePropagationTime, vtkPointSet* theDataSet);
+  static float CorrectStepLength(float theStep, vtkPointSet* theDataSet);
+
   vtkStreamLine* myStream;
   vtkPointSet* mySource;
+  vtkCellCenters* myCenters;
   SALOME_GeometryFilter *myGeomFilter;
+  VISU_UsedPointsFilter *myPointsFilter;
   float myPercents;
 };
 
 
 #endif
index 9e2e261211f8ebbea0d298f72ea5f2a662088388..6c52da23b33269b32e4d29fe4116231572fd4952 100644 (file)
@@ -43,7 +43,7 @@ static int MYDEBUG = 0;
 vtkStandardNewMacro(VISU_UsedPointsFilter);
 
 VISU_UsedPointsFilter::VISU_UsedPointsFilter(){
-  PercentsOfUsedPoints = 0.1;
+  PercentsOfUsedPoints = 1.0;
 }
 
 VISU_UsedPointsFilter::~VISU_UsedPointsFilter(){}
@@ -52,6 +52,8 @@ void VISU_UsedPointsFilter::Execute(){
   vtkPointSet *anInput = this->GetInput(), *anOutput = this->GetOutput();
   anOutput->GetPointData()->CopyAllOff();
   anOutput->GetCellData()->CopyAllOff();
+  anOutput->CopyStructure(anInput);
+
   vtkPoints* aPoints = vtkPoints::New();
   vtkIdType aCellSize = anInput->GetMaxCellSize();
   vtkIdList *anIdList = vtkIdList::New(); 
@@ -61,18 +63,15 @@ void VISU_UsedPointsFilter::Execute(){
     if(anIdList->GetNumberOfIds() > 0)
       aPoints->InsertNextPoint(anInput->GetPoint(i));
   }
-  static float EPS = 1E-5;
-  if(PercentsOfUsedPoints < EPS){
-    anOutput->SetPoints(aPoints);
-  }else{
-    vtkPoints* aNewPoints = vtkPoints::New();
-    iEnd = aPoints->GetNumberOfPoints();
+  vtkPoints* aNewPoints = vtkPoints::New();
+  iEnd = aPoints->GetNumberOfPoints();
+  if (PercentsOfUsedPoints > 0){
     vtkIdType anOffset = vtkIdType(1.0/PercentsOfUsedPoints);
     if(anOffset < 1) anOffset = 1;
     for(vtkIdType i = 0; i < iEnd; i += anOffset)
       aNewPoints->InsertNextPoint(aPoints->GetPoint(i));
-    anOutput->SetPoints(aNewPoints);
-    aNewPoints->Delete();
   }
+  anOutput->SetPoints(aNewPoints);
+  aNewPoints->Delete();
   aPoints->Delete();
 }
index 786f7ec069a39870981bad7f1501f6a25ef0225f..ddb703b5afaa80c3a888148004e9b7144fb9568c 100644 (file)
@@ -39,11 +39,32 @@ vtkStandardNewMacro(VISU_VectorsPL);
 
 VISU_VectorsPL::VISU_VectorsPL(){
   myGlyph = vtkGlyph3D::New();
+
+  myGlyphSource = vtkGlyphSource2D::New();
+  myConeSource = vtkConeSource::New();
+  myLineSource = vtkLineSource::New();
+
+  myCenters = vtkCellCenters::New();
   myTransformFilter = SALOME_TransformFilter::New();
 }
 
 VISU_VectorsPL::~VISU_VectorsPL(){
+  myGlyph->UnRegisterAllOutputs();
   myGlyph->Delete();
+
+  myCenters->UnRegisterAllOutputs();
+  myCenters->Delete();
+
+  myGlyphSource->UnRegisterAllOutputs();
+  myGlyphSource->Delete();
+
+  myConeSource->UnRegisterAllOutputs();
+  myConeSource->Delete();
+
+  myLineSource->UnRegisterAllOutputs();
+  myLineSource->Delete();
+
+  myTransformFilter->UnRegisterAllOutputs();
   myTransformFilter->Delete();
 }
 
@@ -86,7 +107,7 @@ void VISU_VectorsPL::Init(){
 
 
 VISU_ScalarMapPL::THook* VISU_VectorsPL::DoHook(){
-  VISU::ToCellCenters(myTransformFilter,myInput,myFieldTransform);
+  VISU::ToCellCenters(myTransformFilter,myCenters,myInput,myFieldTransform);
   myGlyph->SetInput(myTransformFilter->GetOutput());
   myGlyph->SetVectorModeToUseVector();
   myGlyph->SetScaleModeToScaleByVector();
@@ -98,44 +119,54 @@ VISU_ScalarMapPL::THook* VISU_VectorsPL::DoHook(){
 void VISU_VectorsPL::Update(){
   switch (myTypeGlyph) {
   case ARROW: {
-    vtkGlyphSource2D *aGlyphSource = vtkGlyphSource2D::New();
-    aGlyphSource->SetGlyphTypeToArrow();
-    aGlyphSource->SetFilled(0);
-    if(myPosGlyph == TAIL)
-      aGlyphSource->SetCenter(0.5, 0.0, 0.0);
-    else if(myPosGlyph == HEAD)
-      aGlyphSource->SetCenter(-0.5, 0.0, 0.0);
-    myGlyph->SetSource(aGlyphSource->GetOutput());
-    aGlyphSource->Register(myGlyph);
-    aGlyphSource->Delete();
+    myGlyphSource->SetGlyphTypeToArrow();
+    myGlyphSource->SetFilled(0);
+    switch (myPosGlyph) {
+    case TAIL:
+      myGlyphSource->SetCenter(0.5, 0.0, 0.0);
+      break;
+    case HEAD:
+      myGlyphSource->SetCenter(-0.5, 0.0, 0.0);
+      break;
+    case CENTER:
+      myGlyphSource->SetCenter(0.0, 0.0, 0.0);
+    }
+//     if(myPosGlyph == TAIL)
+//       myGlyphSource->SetCenter(0.5, 0.0, 0.0);
+//     else if(myPosGlyph == HEAD)
+//       myGlyphSource->SetCenter(-0.5, 0.0, 0.0);
+    myGlyph->SetSource(myGlyphSource->GetOutput());
   }
     break;
   case CONE2:
   case CONE6: {
-    vtkConeSource *aGlyphSource = vtkConeSource::New(); //by default
     if (myTypeGlyph == CONE2)
-      aGlyphSource->SetResolution(3);
+      myConeSource->SetResolution(3);
     else
-      aGlyphSource->SetResolution(7);
-    aGlyphSource->SetHeight(1.0);
-    aGlyphSource->SetRadius(.1);
-    
-    if(myPosGlyph == TAIL)
-      aGlyphSource->SetCenter(0.5, 0.0, 0.0);
-    else if(myPosGlyph == HEAD)
-      aGlyphSource->SetCenter(-0.5, 0.0, 0.0);
+      myConeSource->SetResolution(7);
+    myConeSource->SetHeight(1.0);
+    myConeSource->SetRadius(.1);
     
-    myGlyph->SetSource(aGlyphSource->GetOutput());
-    aGlyphSource->Register(myGlyph);
-    aGlyphSource->Delete();
+    switch (myPosGlyph) {
+    case TAIL:
+      myConeSource->SetCenter(0.5, 0.0, 0.0);
+      break;
+    case HEAD:
+      myConeSource->SetCenter(-0.5, 0.0, 0.0);
+      break;
+    case CENTER:
+      myConeSource->SetCenter(0.0, 0.0, 0.0);
+    }
+//     if(myPosGlyph == TAIL)
+//       myConeSource->SetCenter(0.5, 0.0, 0.0);
+//     else if(myPosGlyph == HEAD)
+//       myConeSource->SetCenter(-0.5, 0.0, 0.0);
+    myGlyph->SetSource(myConeSource->GetOutput());
   }
     break;
   case NONE:
   default: {
-    vtkLineSource *aGlyphSource = vtkLineSource::New(); 
-    myGlyph->SetSource(aGlyphSource->GetOutput());
-    aGlyphSource->Register(myGlyph);
-    aGlyphSource->Delete();
+    myGlyph->SetSource(myLineSource->GetOutput());
   }
   }
 
index 81a1f33b5d3cacf2b45418c0021bd00ae3dd5db4..e4af6d6280fefa3aa1184c213075b323cc4c36f1 100644 (file)
 
 class SALOME_TransformFilter;
 class SALOME_Transform;
+class vtkCellCenters;
+
+class vtkGlyphSource2D;
+class vtkConeSource;
+class vtkLineSource;
+
 class vtkGlyph3D;
 
 class VISU_VectorsPL : public VISU_DeformedShapePL{
@@ -68,6 +74,12 @@ protected:
   GlyphType myTypeGlyph;
   GlyphPos myPosGlyph;
   vtkGlyph3D *myGlyph;
+
+  vtkGlyphSource2D *myGlyphSource;
+  vtkLineSource *myLineSource;
+  vtkConeSource *myConeSource;
+
+  vtkCellCenters* myCenters;
   SALOME_TransformFilter *myTransformFilter;
 };