]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
*** empty log message ***
authorenk <enk@opencascade.com>
Tue, 24 Oct 2006 11:42:58 +0000 (11:42 +0000)
committerenk <enk@opencascade.com>
Tue, 24 Oct 2006 11:42:58 +0000 (11:42 +0000)
src/PIPELINE/VISU_PrsMergerPL.cxx
src/PIPELINE/VISU_PrsMergerPL.hxx

index 1c4ac8253f7595cf4a777d88a2e48a8344c88d86..f91d186568c0f549da2daea968ce4de402dda001 100644 (file)
@@ -116,6 +116,9 @@ VISU_PrsMergerPL
     myMeshGeometryList.push_back(theGeometry);
     if (MYDEBUG) MESSAGE("this->GetGeometry(0)->GetIDMapper()="<<this->GetGeometry(0)->GetIDMapper());
     myIsModified = true;
+
+    this->Execute();
+
     return true;
   } else
     return false;
@@ -132,6 +135,9 @@ VISU_PrsMergerPL
     if(this->checkGeometry(theGeometry)){
       myMeshGeometryList.push_back(theGeometry);
       myIsModified = true;
+
+      this->Execute();
+
       return (myMeshGeometryList.size()-1);
     } else {
       return -1;
@@ -164,6 +170,7 @@ VISU_PrsMergerPL
     for(;aIter != myMeshGeometryList.end();aIter++){
       if( myMeshGeometryList[theId] == (*aIter)){
        myMeshGeometryList.erase(aIter);
+       this->Execute();
        break;
       }
     }
@@ -199,29 +206,40 @@ bool
 VISU_PrsMergerPL
 ::SetScalars(VISU_PipeLine* theInput)
 {
+  if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::SetScalars()");
   if ( this->checkScalars( theInput ) ){
     myScalars = theInput;
     VISU_ScalarMapPL* aScalarMap = dynamic_cast<VISU_ScalarMapPL*>(this->GetScalars());
-    aScalarMap->Build();
-    aScalarMap->Init();
-    aScalarMap->Update();
-    myIsModified = true;
-    //SetInput(theInput->GetInput());
+    myScalarRanges = aScalarMap->GetScalarRange();
     return true;
   } else
     return false;
 }
 
+void
+VISU_PrsMergerPL
+::Init()
+{
+  Superclass::Init();
+  if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Init() this="<<this);
+  this->Execute();
+}
+
 void
 VISU_PrsMergerPL
 ::Update()
 {
-  VISU_ScalarMapPL* aScalarMap = dynamic_cast<VISU_ScalarMapPL*>(this->GetScalars());
-  VISU_PrsMergerPL* aPrsMerger = dynamic_cast<VISU_PrsMergerPL*>(this->GetScalars());
-  if(aScalarMap != NULL && aPrsMerger == NULL){
-     SetInput(myScalars->GetInput());
-     Superclass::Update();
-  }
+  if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Update()");
+  Superclass::Update();
+}
+
+void
+VISU_PrsMergerPL
+::Build()
+{
+  if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Build()");
+  //this->Execute();
+  TSupperClass::Build(); // call DoHook method
 }
 
 void
@@ -229,21 +247,57 @@ VISU_PrsMergerPL
 ::SetInitialRange()
 {
   myMapper->UseLookupTableScalarRangeOff();
-  VISU_ScalarMapPL* aScalarMap = dynamic_cast<VISU_ScalarMapPL*>(this->GetScalars());
-  if(aScalarMap != NULL){
-    myScalarRanges = aScalarMap->GetScalarRange();
+}
+
+// VISU_ScalarMapPL::THook*
+// VISU_PrsMergerPL
+// ::DoHook() 
+// {
+//   if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::DoHook()");
+//   Execute();
+//   return myOutput;
+// }
+
+bool
+VISU_PrsMergerPL
+::checkGeometry(const VISU_PipeLine* thePipeLine)
+{
+  const VISU::PIDMapper& aMapper  = thePipeLine->GetIDMapper();
+  int aNbPoints = aMapper->GetVTKOutput()->GetNumberOfPoints();
+  if (this->GetNbGeometry() > 0){
+    const VISU::PIDMapper& aMapper2 = this->GetGeometry(0)->GetIDMapper();
+    int aNbPoints2 = aMapper2->GetVTKOutput()->GetNumberOfPoints();
+    if(aNbPoints2 != aNbPoints)
+      return false;
+  } else if (this->GetScalars()) {
+    const VISU::PIDMapper& aMapper2 = this->GetScalars()->GetIDMapper();
+    int aNbPoints2 = aMapper2->GetVTKOutput()->GetNumberOfPoints();
+    if(aNbPoints2 != aNbPoints)
+      return false;
   }
+  return true;
 }
 
-VISU_ScalarMapPL::THook*
+bool
 VISU_PrsMergerPL
-::DoHook() 
+::checkScalars(const VISU_PipeLine* thePipeLine)
 {
-  if(!myIsModified) return myOutput;
+  const VISU::PIDMapper& aMapper  = thePipeLine->GetIDMapper();
+  int aNbPoints = aMapper->GetVTKOutput()->GetNumberOfPoints();
+  if (this->GetNbGeometry() > 0){
+    const VISU::PIDMapper& aMapper2 = this->GetGeometry(0)->GetIDMapper();
+    int aNbPoints2 = aMapper2->GetVTKOutput()->GetNumberOfPoints();
+    if(aNbPoints2 != aNbPoints)
+      return false;
+  }
+  return true;
+}
+
+void
+VISU_PrsMergerPL
+::Execute(){
+  if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Execute()");
 
-  myOutput = NULL;
-  myIsModified = false;
-  
   if(myMeshGeometryList.size() != 0)
     {
       // Build mesh
@@ -252,14 +306,18 @@ VISU_PrsMergerPL
       TVec aObjIds;// object ids from geometries
       int anbGeoms;
       int aGeomNbCells,aAllGeomNbCells,aScalarNbCells;
-      int aScalarNodeTuplesNum,aScalarCellTuplesNum;
+      int aScalarNodeTuplesNum,aScalarCellTuplesNum,aScalarCellComponentNum;
       vtkFloatArray* aOutputCellScalars;
       VTKViewer_AppendFilter* aMergeGeoms;
       
       aAllGeomNbCells = 0;
       
+      myMergeFilter->RemoveAllInputs();
+      
       aMergeGeoms = VTKViewer_AppendFilter::New();
+      
       myMergeFilter->SetGeometry(aMergeGeoms->GetOutput());
+      
       VISU_ScalarMapPL* aScalarMap = dynamic_cast<VISU_ScalarMapPL*>(this->GetScalars());
       VISU_PrsMergerPL* aPrsMergerPL = dynamic_cast<VISU_PrsMergerPL*>(this->GetScalars());
       if (aPrsMergerPL) {
@@ -267,7 +325,7 @@ VISU_PrsMergerPL
        if (MYDEBUG) MESSAGE("\t this=" << this << "  aPrsMergerPL=" << aPrsMergerPL);
       }
       if(aScalarMap != NULL){
-       myMergeFilter->SetScalars(aScalarMap->GetOutput());
+       myMergeFilter->GetOutput()->GetPointData()->SetScalars(aScalarMap->GetOutput()->GetPointData()->GetScalars());
       }
 
       anbGeoms = this->GetNbGeometry();
@@ -278,6 +336,7 @@ VISU_PrsMergerPL
          aCurrGeometry->Update();
          const VISU::PIDMapper& aGM  = aCurrGeometry->GetIDMapper();
          int aNbCells                = aGM->GetVTKOutput()->GetNumberOfCells();
+         if(MYDEBUG) MESSAGE("Geom["<<i<<"]  aNbCells="<<aNbCells);
          if (aNbCells >0 )
            if (aGM->GetVTKOutput()->GetCell(0)->GetCellType() == VTK_VERTEX )
              continue;
@@ -287,7 +346,7 @@ VISU_PrsMergerPL
            aObjIds.push_back(aGM->GetElemObjID(j));
        }
       }
-      aMergeGeoms->Update();
+
       myMergeFilter->Update();
 
       if (MYDEBUG){
@@ -323,7 +382,13 @@ VISU_PrsMergerPL
        }
       }
 
-      aScalarCellTuplesNum = aScalarMapper->GetVTKOutput()->GetCellData()->GetNumberOfTuples();
+      aScalarCellTuplesNum    = aScalarMapper->GetVTKOutput()->GetCellData()->GetNumberOfTuples();
+      aScalarCellComponentNum = aScalarMapper->GetVTKOutput()->GetCellData()->GetNumberOfComponents();
+
+
+      if(MYDEBUG) MESSAGE("aScalarMapper NumberOfTuples    ="<<aScalarCellTuplesNum);
+      if(MYDEBUG) MESSAGE("aScalarMapper NumberOfArrays    ="<<aScalarMapper->GetVTKOutput()->GetCellData()->GetNumberOfArrays());
+      if(MYDEBUG) MESSAGE("aScalarMapper NumberOfComponents="<<aScalarCellComponentNum);
       
       if (aScalarCellTuplesNum > 0) {
        // copy scalars from cell data
@@ -333,15 +398,19 @@ VISU_PrsMergerPL
          aOutputCellScalars = vtkFloatArray::New();
          aOutputCellScalars->SetNumberOfTuples(aAllGeomNbCells);
 
-         if(MYDEBUG) cout << "Output:" << endl;
+         if(MYDEBUG) cout << "Output: ObjId,VtkId,newId" << endl;
          
          TVec::const_iterator aIdsIter = aObjIds.begin();
          for(int i=0; aIdsIter != aObjIds.end(); aIdsIter++){
            int anObjID = *aIdsIter;
            int aVTKID  = aScalarMapper->GetElemVTKID(anObjID);
            float* aTuple = aScalarMapper->GetVTKOutput()->GetCellData()->GetTuple(aVTKID);
-           if(MYDEBUG)
-             cout <<"\t\t" <<  anObjID << ";"<<aVTKID<<";"<<i<<endl;
+           if(MYDEBUG){
+             cout <<"\t\t" <<  anObjID << ";"<<aVTKID<<";"<<i<<" tuples:";
+             for(int k=0;k<aScalarCellComponentNum;k++)
+               cout << aTuple[i] << ",";
+             cout << endl;
+           }
            aOutputCellScalars->SetTuple(i,aTuple);
            i++;
          }
@@ -354,6 +423,10 @@ VISU_PrsMergerPL
       if (MYDEBUG) cout << "\tmyMergeFilter->GetUnstructuredGridOutput()="
                        <<myMergeFilter->GetUnstructuredGridOutput()<<endl;
       
+      if(MYDEBUG) MESSAGE("myMergeFilter NumberOfTuples    ="<<myMergeFilter->GetUnstructuredGridOutput()->GetCellData()->GetNumberOfTuples());
+      if(MYDEBUG) MESSAGE("myMergeFilter NumberOfArrays    ="<<myMergeFilter->GetUnstructuredGridOutput()->GetCellData()->GetNumberOfArrays());
+      if(MYDEBUG) MESSAGE("myMergeFilter NumberOfComponents="<<myMergeFilter->GetUnstructuredGridOutput()->GetCellData()->GetNumberOfComponents());
+
       SetInput(myMergeFilter->GetUnstructuredGridOutput());
       
       if (MYDEBUG) cout << "\tmyMergeFilter->GetOutput()="
@@ -362,7 +435,6 @@ VISU_PrsMergerPL
       aMergeGeoms->Delete();
       myOutput = myMergeFilter->GetOutput();
 
-      return myOutput;
     }
   else
     {
@@ -372,56 +444,14 @@ VISU_PrsMergerPL
          VISU_PrsMergerPL* aPrsMerger = dynamic_cast<VISU_PrsMergerPL*>(this->GetScalars());
          if(aPrsMerger != NULL){
            myOutput = NULL;
-           return myOutput;
          }
          if(aScalarMap != NULL){
            SetInput(aScalarMap->GetInput());
            vtkDataSet* aOut = aScalarMap->GetOutput();
            myOutput = aOut;
            
-           return myOutput;
          }
          
-         return myOutput;
        }
-      else
-       return myOutput;
     }
-
-  return myOutput;
-}
-
-bool
-VISU_PrsMergerPL
-::checkGeometry(const VISU_PipeLine* thePipeLine)
-{
-  const VISU::PIDMapper& aMapper  = thePipeLine->GetIDMapper();
-  int aNbPoints = aMapper->GetVTKOutput()->GetNumberOfPoints();
-  if (this->GetNbGeometry() > 0){
-    const VISU::PIDMapper& aMapper2 = this->GetGeometry(0)->GetIDMapper();
-    int aNbPoints2 = aMapper2->GetVTKOutput()->GetNumberOfPoints();
-    if(aNbPoints2 != aNbPoints)
-      return false;
-  } else if (this->GetScalars()) {
-    const VISU::PIDMapper& aMapper2 = this->GetScalars()->GetIDMapper();
-    int aNbPoints2 = aMapper2->GetVTKOutput()->GetNumberOfPoints();
-    if(aNbPoints2 != aNbPoints)
-      return false;
-  }
-  return true;
-}
-
-bool
-VISU_PrsMergerPL
-::checkScalars(const VISU_PipeLine* thePipeLine)
-{
-  const VISU::PIDMapper& aMapper  = thePipeLine->GetIDMapper();
-  int aNbPoints = aMapper->GetVTKOutput()->GetNumberOfPoints();
-  if (this->GetNbGeometry() > 0){
-    const VISU::PIDMapper& aMapper2 = this->GetGeometry(0)->GetIDMapper();
-    int aNbPoints2 = aMapper2->GetVTKOutput()->GetNumberOfPoints();
-    if(aNbPoints2 != aNbPoints)
-      return false;
-  }
-  return true;
 }
index 75f3427cc22cb2f001a0e96722eeaefc0ab17d2c..7c09daea58f478e38aa28c80672e63c4ade0d129 100644 (file)
@@ -129,6 +129,14 @@ public:
   VISU_PipeLine*
   GetScalars();
   
+  virtual
+  void
+  Init();
+
+  virtual
+  void
+  Build();
+  
   /*!
    * Calculate presentation, by merging of Geometry and Scalar Values.
    */
@@ -142,11 +150,11 @@ public:
   void SetInitialRange();
 
 protected:
-  virtual
-  THook* 
-  DoHook();
+//   virtual
+//   THook* 
+//   DoHook();
   
-  TPipeLines      myMeshGeometryList;
+  TPipeLines     myMeshGeometryList;
   
   TPipeLine      myScalars;
 
@@ -154,6 +162,8 @@ protected:
 
   vtkFloatingPointType* myScalarRanges;
 
+  VISU_ScalarMapPL::THook* myOutput;
+  
 private:
   
   /*!
@@ -174,9 +184,11 @@ private:
   bool
   checkScalars(const VISU_PipeLine* thePipeLine);
 
+  void
+  Execute();
+
   bool myIsModified;
-  VISU_ScalarMapPL::THook* myOutput;
-  
+
 };
 
 #endif