]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
*** empty log message ***
authorenk <enk@opencascade.com>
Fri, 27 Oct 2006 14:22:39 +0000 (14:22 +0000)
committerenk <enk@opencascade.com>
Fri, 27 Oct 2006 14:22:39 +0000 (14:22 +0000)
src/PIPELINE/VISU_PrsMergerPL.cxx
src/PIPELINE/VISU_PrsMergerPL.hxx
src/VISUGUI/VisuGUI_ScalarBarDlg.cxx
src/VISU_I/VISU_PrsMerger_i.cc
src/VISU_I/VISU_PrsMerger_i.hh

index 6d592227cb6d649ccfb61a5c4f5eeabf9a573351..8e5ab8ca0e8688cadc7d03fe3cb0c2b148777e4e 100644 (file)
@@ -61,13 +61,11 @@ using namespace std;
 vtkStandardNewMacro(VISU_PrsMergerPL);
 
 VISU_PrsMergerPL
-::VISU_PrsMergerPL():
-  myMergeFilter(VISU_MergeFilter::New())
+::VISU_PrsMergerPL()
 {
   myScalars = NULL;
-  myIsModified = true;
   
-  myMergeFilter->Delete();
+  //myMergeFilter->Delete();
   myMeshGeometryList.clear();
 }
 
@@ -91,7 +89,6 @@ VISU_PrsMergerPL
 {
   VISU_PrsMergerPL* aPipeLine = dynamic_cast<VISU_PrsMergerPL*>(thePipeLine);
   if(this == aPipeLine){
-    myIsModified = true;
     Superclass::ShallowCopy(thePipeLine);
     return;
   }
@@ -115,7 +112,6 @@ VISU_PrsMergerPL
   if(this->checkGeometry(theGeometry)){
     myMeshGeometryList.push_back(theGeometry);
     if (MYDEBUG) MESSAGE("this->GetGeometry(0)->GetIDMapper()="<<this->GetGeometry(0)->GetIDMapper());
-    myIsModified = true;
 
     this->Execute();
 
@@ -134,7 +130,6 @@ VISU_PrsMergerPL
   if(aGeomNum == -1){
     if(this->checkGeometry(theGeometry)){
       myMeshGeometryList.push_back(theGeometry);
-      myIsModified = true;
 
       this->Execute();
 
@@ -238,7 +233,6 @@ VISU_PrsMergerPL
 ::Build()
 {
   if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Build()");
-  //this->Execute();
   TSupperClass::Build(); // call DoHook method
 }
 
@@ -249,15 +243,6 @@ VISU_PrsMergerPL
   myMapper->UseLookupTableScalarRangeOff();
 }
 
-// VISU_ScalarMapPL::THook*
-// VISU_PrsMergerPL
-// ::DoHook() 
-// {
-//   if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::DoHook()");
-//   Execute();
-//   return myOutput;
-// }
-
 bool
 VISU_PrsMergerPL
 ::checkGeometry(const VISU_PipeLine* thePipeLine)
@@ -296,10 +281,24 @@ VISU_PrsMergerPL
 void
 VISU_PrsMergerPL
 ::Execute(){
+  /* Where are next situations:
+   * 1. Timestamp on entity=NODE
+   * 1.1 Group Cell         - OK
+   * 1.2 Group Cell + Point - ERR (remove points groups)
+   * 1.3 Group Node         - ERR (remove points groups)
+   * 2. Timesatamp on entity=CELL
+   * 2.1 Group Cell         - OK
+   * 2.2 Group Point        - ERR (remove points groups)
+   */
+
+
+
   if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Execute()");
 
   if(myMeshGeometryList.size() != 0)
     {
+
+      VISU_MergeFilter* aMergeFilter = VISU_MergeFilter::New();
       // Build mesh
       typedef std::vector<int> TVec;
       
@@ -307,29 +306,16 @@ VISU_PrsMergerPL
       int anbGeoms;
       int aGeomNbCells,aAllGeomNbCells,aScalarNbCells;
       int aScalarNodeTuplesNum,aScalarCellTuplesNum,aScalarCellComponentNum;
-      vtkFloatArray* aOutputCellScalars;
-      VTKViewer_AppendFilter* aMergeGeoms;
+      VTKViewer_AppendFilter* aMergeGeoms = VTKViewer_AppendFilter::New();
       
       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) {
-       if (MYDEBUG) MESSAGE("ERROR...");
-       if (MYDEBUG) MESSAGE("\t this=" << this << "  aPrsMergerPL=" << aPrsMergerPL);
-      }
-      if(aScalarMap != NULL){
-       myMergeFilter->GetOutput()->GetPointData()->SetScalars(aScalarMap->GetOutput()->GetPointData()->GetScalars());
-      }
+      const VISU::PIDMapper& aScalarMapper  = myScalars->GetIDMapper();
 
       anbGeoms = this->GetNbGeometry();
-      
+
+      // aObjIds follows.
       for(int i=0; i < anbGeoms; i++) {
        VISU_PipeLine* aCurrGeometry  = this->GetGeometry(i);
        if (aCurrGeometry) {
@@ -347,8 +333,6 @@ VISU_PrsMergerPL
        }
       }
 
-      myMergeFilter->Update();
-
       if (MYDEBUG){
        // Geometry debug information
        for(int i=0; i< anbGeoms; i++){
@@ -365,12 +349,7 @@ VISU_PrsMergerPL
            cout <<"\t\t" <<  anObjID << ";"<<aVTKID<<endl;
          }
        }
-      }
-      
-      const VISU::PIDMapper& aScalarMapper  = myScalars->GetIDMapper();
-
-      // Scalars debug information
-      if (MYDEBUG){
+       // Scalars debug information
        int aNbCells = aScalarMapper->GetVTKOutput()->GetNumberOfCells();
        cout << "myScalars:" << endl;
        cout << "\tnumber of points:" << aScalarMapper->GetVTKOutput()->GetNumberOfPoints() << endl;
@@ -382,59 +361,198 @@ VISU_PrsMergerPL
        }
       }
 
-      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);
+      vtkCellData* aScalarMapCD = aScalarMapper->GetVTKOutput()->GetCellData();
+
+      vtkUnstructuredGrid* aDSScalars   = vtkUnstructuredGrid::New();
+      vtkUnstructuredGrid* aDSVectors   = vtkUnstructuredGrid::New();
+      vtkCellData* aCDScalars   = aDSScalars->GetCellData();
+      vtkCellData* aCDVectors   = aDSVectors->GetCellData();
+      vtkPointData* aPDScalars   = aDSScalars->GetPointData();
+      vtkPointData* aPDVectors   = aDSVectors->GetPointData();
+      vtkUnstructuredGrid* aDSArrays    = vtkUnstructuredGrid::New();
+      vtkFloatArray* aArrays    = vtkFloatArray::New();
+      vtkFloatArray *aVISU_FIELD_Array = NULL;
       
-      if (aScalarCellTuplesNum > 0) {
-       // copy scalars from cell data
-       if(myMergeFilter->GetOutput()->GetCellData()->GetNumberOfTuples() == 0 ){
+      // shallow copy of point data
+      if(aScalarMap != NULL){
+       aPDScalars->ShallowCopy(aScalarMap->GetOutput()->GetPointData());
+       aPDVectors->ShallowCopy(aScalarMap->GetOutput()->GetPointData());
+      }
 
-         vtkCellData* cdM = myMergeFilter->GetOutput()->GetCellData();
-         aOutputCellScalars = vtkFloatArray::New();
-         aOutputCellScalars->SetNumberOfTuples(aAllGeomNbCells);
+      aCDScalars->Initialize();
+      aCDVectors->Initialize();
+
+
+      /*
+       *copy arrays from point data
+       */
+      vtkPointData* aPDInput = aScalarMapper->GetVTKOutput()->GetPointData();
+      aDSArrays->GetPointData()->SetScalars(aPDInput->GetScalars());
+      aDSArrays->GetPointData()->SetVectors(aPDInput->GetVectors());
+      int anbPArr = aPDInput->GetNumberOfArrays();
+      if(anbPArr>0){
+       vtkDataArray* aFieldArray = aPDInput->GetArray("VISU_FIELD");
+       if(vtkFloatArray* aArr = dynamic_cast<vtkFloatArray*>(aFieldArray))
+         aDSArrays->GetPointData()->AddArray(aArr);
+      }
 
-         if(MYDEBUG) cout << "Output: ObjId,VtkId,newId" << endl;
-         
+      /*
+       *copy array VISU_FIELD from cell data
+       */
+      int anbArr = aScalarMapCD->GetNumberOfArrays();
+      if(anbArr>0){
+       vtkDataArray* aFieldArray = aScalarMapCD->GetArray("VISU_FIELD");
+       if(aVISU_FIELD_Array = dynamic_cast<vtkFloatArray*>(aFieldArray)){
+         if(MYDEBUG) MESSAGE("Copy VISU_FIELD .........");
+         int aNbComp = aVISU_FIELD_Array->GetNumberOfComponents();
+         int nbTuple = aVISU_FIELD_Array->GetNumberOfTuples();
+         aArrays->SetName(aVISU_FIELD_Array->GetName());
+         aArrays->SetNumberOfComponents(aNbComp);
+         aArrays->SetNumberOfTuples(aAllGeomNbCells);
+           
          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);
+           float* aTuple = aVISU_FIELD_Array->GetTuple(aVTKID);
            if(MYDEBUG){
              cout <<"\t\t" <<  anObjID << ";"<<aVTKID<<";"<<i<<" tuples:";
-             for(int k=0;k<aScalarCellComponentNum;k++)
+             for(int k=0;k<aNbComp;k++)
                cout << aTuple[i] << ",";
              cout << endl;
            }
-           aOutputCellScalars->SetTuple(i,aTuple);
+           aArrays->SetTuple(i,aTuple);
            i++;
          }
-         cdM->SetScalars(aOutputCellScalars);
-         aOutputCellScalars->Delete();
+         aDSArrays->GetCellData()->AddArray(aArrays);
+         if(MYDEBUG) MESSAGE("Copy VISU_FIELD .........done");
        }
       }
-      
 
-      if (MYDEBUG) cout << "\tmyMergeFilter->GetUnstructuredGridOutput()="
-                       <<myMergeFilter->GetUnstructuredGridOutput()<<endl;
+
+      /*
+       *copy scalars from cell data
+       */
+      aScalarCellTuplesNum = 0;
+      int compNum = 0;
+      if(aScalarMapCD->GetScalars()){
+       aScalarCellTuplesNum    = aScalarMapCD->GetScalars()->GetNumberOfTuples();
+       compNum                 = aScalarMapCD->GetScalars()->GetNumberOfComponents();
+      }
+      if (aScalarCellTuplesNum > 0) {
+       if(MYDEBUG) MESSAGE("Copy Scalars .........");
+       if(MYDEBUG) MESSAGE("\taScalarCellTuplesNum="<<aScalarCellTuplesNum);
+       if(MYDEBUG) MESSAGE("\tcompNum             ="<<compNum);
+       if(MYDEBUG) MESSAGE("\taAllGeomNbCells="<<aAllGeomNbCells);
+       vtkFloatArray* aNewScalars = vtkFloatArray::New();
+       aNewScalars->SetNumberOfComponents(compNum);
+       aNewScalars->SetNumberOfTuples(aObjIds.size());
+       aNewScalars->SetName(aScalarMapCD->GetScalars()->GetName());
+       
+       if(MYDEBUG) cout << "\tOutput: 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 = aScalarMapCD->GetScalars()->GetTuple(aVTKID);
+         if(MYDEBUG){
+           cout <<"\t\t" <<  anObjID << ";"<<aVTKID<<";"<<i<<" tuples:";
+           for(int k=0;k<compNum;k++)
+             cout << aTuple[i] << ",";
+             cout << endl;
+         }
+         aNewScalars->SetTuple(i,aTuple);
+         i++;
+       }
+       aCDScalars->SetScalars(aNewScalars);
+       aCDScalars->AddArray(aArrays);
+       aNewScalars->Delete();
+       if(MYDEBUG) MESSAGE("Copy Scalars .........Done");
+      }
       
-      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());
+      /*
+       * copy vectors from cell data
+       */
+      aScalarCellTuplesNum = 0;
+      if(aScalarMapCD->GetVectors()) {
+       aScalarCellTuplesNum  = aScalarMapCD->GetVectors()->GetNumberOfTuples();
+       compNum               = aScalarMapCD->GetVectors()->GetNumberOfComponents();
+      }
+      if (aScalarCellTuplesNum > 0) {
+       if(MYDEBUG) MESSAGE("Copy Vectors .........");
+       if(MYDEBUG) MESSAGE("\taScalarCellTuplesNum="<<aScalarCellTuplesNum);
+       if(MYDEBUG) MESSAGE("\tcompNum             ="<<compNum);
+       if(MYDEBUG) MESSAGE("\taAllGeomNbCells="<<aAllGeomNbCells);
+       vtkFloatArray* aNewVectors = vtkFloatArray::New();
+       aNewVectors->SetNumberOfComponents(compNum);
+       aNewVectors->SetNumberOfTuples(aAllGeomNbCells);
+       aNewVectors->SetName(aScalarMapCD->GetVectors()->GetName());
+       
+       TVec::const_iterator aIdsIter = aObjIds.begin();
+       for(int i=0; aIdsIter != aObjIds.end(); aIdsIter++){
+         int anObjID = *aIdsIter;
+         int aVTKID  = aScalarMapper->GetElemVTKID(anObjID);
+         float* aTuple = aScalarMapCD->GetVectors()->GetTuple(aVTKID);
+         if(MYDEBUG){
+           cout <<"\t\t" <<  anObjID << ";"<<aVTKID<<";"<<i<<" tuples:";
+           for(int k=0;k<compNum;k++)
+             cout << aTuple[i] << ",";
+             cout << endl;
+         }
+         aNewVectors->SetTuple(i,aTuple);
+         i++;
+       }
+       aCDVectors->SetVectors(aNewVectors);
+       aCDVectors->AddArray(aArrays);
+       aDSArrays->GetCellData()->AddArray(aArrays);
+       aNewVectors->Delete();
+       if(MYDEBUG) MESSAGE("Copy Vectors .........Done");
+      }
+
+      aMergeFilter->SetGeometry(aMergeGeoms->GetOutput());
+
+      aMergeGeoms->AddInput(aDSScalars);
+      aMergeGeoms->AddInput(aDSVectors);
+       
+      if(aArrays->GetNumberOfTuples()>0)
+       aMergeFilter->AddField("VISU_FIELD",aDSArrays);
+
+      if(MYDEBUG){
+       MESSAGE("PointData:");
+       aDSArrays->GetPointData()->Print(cout);
+       MESSAGE("CellData:");
+       aDSArrays->GetCellData()->Print(cout);
+      }
+      aMergeFilter->SetScalars(aDSScalars);
+      aMergeFilter->SetVectors(aDSVectors);
+      aMergeFilter->Update();
+
+      if(MYDEBUG){
+       MESSAGE("Output tuples:");
+       int nbTuples = aMergeFilter->GetUnstructuredGridOutput()->GetCellData()->GetNumberOfTuples();
+       for(int i=0;i<nbTuples;i++){
+         int nc = aMergeFilter->GetUnstructuredGridOutput()->GetCellData()->GetNumberOfComponents();
+         float* aTuple = aMergeFilter->GetUnstructuredGridOutput()->GetCellData()->GetTuple(i);
+         cout << "\t\tTuple["<<i<<"]:";
+         for(int k=0;k<nc;k++)
+           cout << aTuple[k]<<",";
+         cout << endl;
+       }
+         
+      }
 
-      SetInput(myMergeFilter->GetUnstructuredGridOutput());
+      SetInput(aMergeFilter->GetUnstructuredGridOutput());
+
+      aMergeGeoms->Delete();
+      aDSScalars->Delete();
+      aDSVectors->Delete();
       
-      if (MYDEBUG) cout << "\tmyMergeFilter->GetOutput()="
-                       <<myMergeFilter->GetOutput()<<endl;
+      aDSArrays->Delete();
+      aArrays->Delete();
       
-      aMergeGeoms->Delete();
-      myOutput = myMergeFilter->GetOutput();
-
+      myOutput->ShallowCopy(aMergeFilter->GetOutput());
+      
+      aMergeFilter->Delete();
     }
   else
     {
index 7c09daea58f478e38aa28c80672e63c4ade0d129..6d76830e6b7c83d780ee233745be37a7cc159197 100644 (file)
@@ -29,8 +29,6 @@
 
 #include "VISU_ScalarMapPL.hxx"
 
-class VISU_MergeFilter;
-
 class VISU_PrsMergerPL : public VISU_ScalarMapPL
 {
   typedef VISU_ScalarMapPL TSupperClass;
@@ -150,16 +148,10 @@ public:
   void SetInitialRange();
 
 protected:
-//   virtual
-//   THook* 
-//   DoHook();
-  
   TPipeLines     myMeshGeometryList;
   
   TPipeLine      myScalars;
 
-  TVTKSmartPtr<VISU_MergeFilter>   myMergeFilter;
-
   vtkFloatingPointType* myScalarRanges;
 
   VISU_ScalarMapPL::THook* myOutput;
@@ -187,8 +179,6 @@ private:
   void
   Execute();
 
-  bool myIsModified;
-
 };
 
 #endif
index 5e91fa8e94fb057be087aaca0a25611d32433c41..136d539962dc6ae1608a93a3cde397e7c73b4000 100644 (file)
@@ -614,7 +614,8 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::PrsMerger_i* thePrs) {
     for(;aGroupIter!=aGroupMap.end();aGroupIter++)
       {
        const string& aGroupName = aGroupIter->first;
-       myAllGroups->insertItem( QString(aGroupName) );
+       if(thePrs->CheckGroup(&aGroupName[0]))
+         myAllGroups->insertItem( QString(aGroupName) );
       }
   }
 
index f6e049cec2598fe6ad96596f71735190438bcdac..8450d072a4390f50bd8bc6bdb8d8a002efcc855a 100644 (file)
@@ -429,3 +429,26 @@ VISU::PrsMerger_i
   }
   return myseq._retn();
 }
+
+bool
+VISU::PrsMerger_i
+::CheckGroup(const char* theGroupName)
+{
+  if (MYDEBUG) MESSAGE("PrsMerger_i::CheckGroup :|"<<theGroupName<<"|");
+  string aMeshName  = myMeshName;
+  string aGroupName = theGroupName;
+
+  VISU::PIDMapper anIDMapper;
+  anIDMapper = myResult->GetInput()->GetMeshOnGroup(aMeshName,theGroupName);
+  if (MYDEBUG) MESSAGE("anIDMapper="<<anIDMapper);
+  if(!anIDMapper) return false;
+  
+  bool aAllPoints = true;
+  for(int i=0;i<anIDMapper->GetVTKOutput()->GetNumberOfCells();i++)
+    if(anIDMapper->GetVTKOutput()->GetCellType(i) != 1){
+      aAllPoints = false;
+      break;
+    }
+
+  return (!aAllPoints);
+}
index 52edb3e39951fd055fc72dd4c25a91f4667d552a..861e4b34b8ba3d95bc99cb3450079de61086e21c 100644 (file)
@@ -197,6 +197,12 @@ namespace VISU{
      */
     virtual CORBA::Long GetMeshGeometryPlace(CORBA::Long theId){return CORBA::Long(1);};// must bee filled
 
+    /*!
+     * Return true, if group is good, esle false.
+     * May be used, if SetScalarMap(...) olready .
+     */
+    bool CheckGroup(const char* theGroupName);
+    
   };
   
 }