]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To implement result data assigning to Gauss Points
authorapo <apo@opencascade.com>
Thu, 28 Jul 2005 12:35:31 +0000 (12:35 +0000)
committerapo <apo@opencascade.com>
Thu, 28 Jul 2005 12:35:31 +0000 (12:35 +0000)
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_MedConvertor.cxx

index 72c0b92213263c9889be07df7f9f832f0cbee7f9..1828afac5670b98d66140bec33c6a2674bd9206a 100644 (file)
@@ -58,7 +58,7 @@ static int MYVTKDEBUG = 0;
 
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 1;
+static int MYDEBUGWITHFILES = 0;
 #else
 static int MYDEBUG = 0;
 static int MYDEBUGWITHFILES = 0;
@@ -681,16 +681,49 @@ namespace
   
   
   //---------------------------------------------------------------
-  void
-  GetTimeStampOnProfile2(vtkFloatArray *theFloatArray, 
-                        const vtkIdType& theNumberOfTuples,
-                        const std::string& theFieldName,
-                        VISU::PFieldImpl theField,
-                        VISU::PValForTimeImpl theValForTime)
+  std::string
+  GenerateFieldName(const VISU::PFieldImpl theField,
+                   const VISU::PValForTimeImpl theValForTime)
   {
-    //theFloatArray->DebugOn();
-    theFloatArray->SetNumberOfTuples(theNumberOfTuples);
-    theFloatArray->SetName(theFieldName.c_str());
+    const VISU::TTime& aTime = theValForTime->myTime;
+    string aFieldName = theField->myMeshName + ", " + theField->myName + ": " + 
+      VISU_Convertor::GenerateName(aTime);
+    return aFieldName;
+  }
+
+
+  //---------------------------------------------------------------
+  void 
+  GetTimeStampOnProfile(VISU::TVTKSource& theSource,
+                       const VISU::PFieldImpl theField, 
+                       const VISU::PValForTimeImpl theValForTime)
+  {
+    int aNbTuples = theField->myDataSize/theField->myNbComp;
+    string aFieldName = GenerateFieldName(theField,theValForTime);
+    INITMSG(MYDEBUG,"GetTimeStampOnProfile - aNbTuples = "<<aNbTuples<<endl);
+    
+    vtkDataSetAttributes* aDataSetAttributes;
+    switch(theField->myEntity){
+    case VISU::NODE_ENTITY : 
+      aDataSetAttributes = theSource->GetPointData();
+      break;
+    default: 
+      aDataSetAttributes = theSource->GetCellData();
+    }
+
+    vtkFloatArray *aFloatArray = vtkFloatArray::New();
+    switch(theField->myNbComp) {
+    case 1:
+      aFloatArray->SetNumberOfComponents(1);
+      aDataSetAttributes->SetScalars(aFloatArray);
+      break;
+    default:
+      aFloatArray->SetNumberOfComponents(3);
+      aDataSetAttributes->SetVectors(aFloatArray);
+    }
+
+    aFloatArray->SetNumberOfTuples(aNbTuples);
+    aFloatArray->SetName(aFieldName.c_str());
 
     TGeom2Value& aGeom2Value = theValForTime->myGeom2Value;
     TGeom2Value::const_iterator anIter = aGeom2Value.begin();
@@ -702,7 +735,8 @@ namespace
       int aNbGauss = aMeshValue.myNbGauss;
       int aNbComp = aMeshValue.myNbComp;
       
-      INITMSG(MYDEBUG,"GetTimeStampOnProfile2 - aGeom = "<<aGeom<<
+      INITMSG(MYDEBUG,
+             "- aGeom = "<<aGeom<<
              "; aNbElem = "<<aNbElem<<
              "; aNbComp = "<<aNbComp<<
              "; aNbGauss = "<<aNbGauss<<
@@ -723,7 +757,7 @@ namespace
            }
            aValue[iComp] /= aNbGauss;
          }
-         theFloatArray->SetTuple1(aTupleId++,aValue[0]);
+         aFloatArray->SetTuple1(aTupleId++,aValue[0]);
        }
        break;
       case 2:
@@ -737,7 +771,7 @@ namespace
            }
            aValue[iComp] /= aNbGauss;
          }
-         theFloatArray->SetTuple3(aTupleId++,aValue[0],aValue[1],0.0);
+         aFloatArray->SetTuple3(aTupleId++,aValue[0],aValue[1],0.0);
        }
        break;
       default:
@@ -751,63 +785,13 @@ namespace
            }
            aValue[iComp] /= aNbGauss;
          }
-         theFloatArray->SetTuple3(aTupleId++,aValue[0],aValue[1],aValue[2]);
+         aFloatArray->SetTuple3(aTupleId++,aValue[0],aValue[1],aValue[2]);
        }
       }
     }
   }
 
 
-  //---------------------------------------------------------------
-  std::string
-  GenerateFieldName(const VISU::PFieldImpl theField,
-                   const VISU::PValForTimeImpl theValForTime)
-  {
-    const VISU::TTime& aTime = theValForTime->myTime;
-    string aFieldName = theField->myMeshName + ", " + theField->myName + ": " + 
-      VISU_Convertor::GenerateName(aTime);
-    return aFieldName;
-  }
-
-
-  //---------------------------------------------------------------
-  void 
-  GetTimeStampOnProfile(VISU::TVTKSource& theSource,
-                       const VISU::PFieldImpl theField, 
-                       const VISU::PValForTimeImpl theValForTime)
-  {
-    int aNbTuples = theField->myDataSize/theField->myNbComp;
-    string aFieldName = GenerateFieldName(theField,theValForTime);
-    INITMSG(MYDEBUG,"GetTimeStampOnProfile - aNbTuples = "<<aNbTuples<<endl);
-    
-    vtkDataSetAttributes* aDataSetAttributes;
-    switch(theField->myEntity){
-    case VISU::NODE_ENTITY : 
-      aDataSetAttributes = theSource->GetPointData();
-      break;
-    default: 
-      aDataSetAttributes = theSource->GetCellData();
-    }
-
-    vtkFloatArray *aFloatArray = vtkFloatArray::New();
-    switch(theField->myNbComp) {
-    case 1:
-      aFloatArray->SetNumberOfComponents(1);
-      aDataSetAttributes->SetScalars(aFloatArray);
-      break;
-    default:
-      aFloatArray->SetNumberOfComponents(3);
-      aDataSetAttributes->SetVectors(aFloatArray);
-    }
-
-    GetTimeStampOnProfile2(aFloatArray,
-                          aNbTuples,
-                          aFieldName,
-                          theField,
-                          theValForTime);
-  }
-
-
   //---------------------------------------------------------------
   void
   GetCells(VISU::TVTKSource& theSource,
@@ -928,6 +912,105 @@ namespace
   }
   
   
+  //---------------------------------------------------------------
+  void 
+  GetTimeStampOnGaussMesh(VISU::TVTKSource& theSource,
+                         const VISU::PFieldImpl theField, 
+                         const VISU::PValForTimeImpl theValForTime)
+  {
+    int aNbTuples = theSource->GetNumberOfPoints();
+    std::string aFieldName = GenerateFieldName(theField,theValForTime);
+    INITMSG(MYDEBUG,"GetTimeStampOnGaussMesh - aNbTuples = "<<aNbTuples<<endl);
+    
+    vtkDataSetAttributes* aDataSetAttributes;
+    switch(theField->myEntity){
+    case VISU::NODE_ENTITY : 
+      aDataSetAttributes = theSource->GetPointData();
+      break;
+    default: 
+      aDataSetAttributes = theSource->GetCellData();
+    }
+
+    vtkFloatArray *aFloatArray = vtkFloatArray::New();
+    switch(theField->myNbComp) {
+    case 1:
+      aFloatArray->SetNumberOfComponents(1);
+      aDataSetAttributes->SetScalars(aFloatArray);
+      break;
+    default:
+      aFloatArray->SetNumberOfComponents(3);
+      aDataSetAttributes->SetVectors(aFloatArray);
+    }
+
+    aFloatArray->SetNumberOfTuples(aNbTuples);
+    aFloatArray->SetName(aFieldName.c_str());
+    
+    TGeom2Value& aGeom2Value = theValForTime->myGeom2Value;
+    TGeom2Value::const_iterator anIter = aGeom2Value.begin();
+    for(int aTupleId = 0; anIter != aGeom2Value.end(); anIter++){
+      const TMeshValue& aMeshValue = anIter->second;
+      int aGeom = anIter->first;
+
+      int aNbElem = aMeshValue.myNbElem;
+      int aNbGauss = aMeshValue.myNbGauss;
+      int aNbComp = aMeshValue.myNbComp;
+      
+      if(aNbGauss <= 1)
+       continue;
+
+      INITMSG(MYDEBUG,"- aGeom = "<<aGeom<<
+             "; aNbElem = "<<aNbElem<<
+             "; aNbComp = "<<aNbComp<<
+             "; aNbGauss = "<<aNbGauss<<
+             endl);
+
+      if(aNbComp == 4)
+       aNbComp = 2;
+
+      switch(aNbComp){
+      case 1:
+       for(int iElem = 0; iElem < aNbElem; iElem++){
+         float aValue[] = {0.0, 0.0, 0.0};
+         TCValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem);
+         for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
+           const TCValueSlice& aValueSlice = aValueSliceArr[iGauss];
+           for(int iComp = 0; iComp < aNbComp; iComp++){
+             aValue[iComp] += aValueSlice[iComp];
+           }
+           aFloatArray->SetTuple1(aTupleId++,aValue[0]);
+         }
+       }
+       break;
+      case 2:
+       for(int iElem = 0; iElem < aNbElem; iElem++){
+         float aValue[] = {0.0, 0.0, 0.0};
+         TCValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem);
+         for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
+           const TCValueSlice& aValueSlice = aValueSliceArr[iGauss];
+           for(int iComp = 0; iComp < aNbComp; iComp++){
+             aValue[iComp] += aValueSlice[iComp];
+           }
+           aFloatArray->SetTuple3(aTupleId++,aValue[0],aValue[1],0.0);
+         }
+       }
+       break;
+      default:
+       for(int iElem = 0; iElem < aNbElem; iElem++){
+         float aValue[] = {0.0, 0.0, 0.0};
+         TCValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem);
+         for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
+           const TCValueSlice& aValueSlice = aValueSliceArr[iGauss];
+           for(int iComp = 0; iComp < aNbComp; iComp++){
+             aValue[iComp] += aValueSlice[iComp];
+           }
+           aFloatArray->SetTuple3(aTupleId++,aValue[0],aValue[1],aValue[2]);
+         }
+       }
+      }
+    }
+  }
+
+
   //---------------------------------------------------------------
   void
   GetSource(VISU::TVTKSource& theSource,
@@ -994,10 +1077,10 @@ namespace
     PGaussImpl aGauss = theGaussSubMesh->myGauss;
     INITMSG(MYDEBUG,"GetGaussSubMesh - aGeom = "<<aGauss->myGeom<<endl);
     
-    TVTKSource& aSource = theGaussSubMesh->mySource;
     if(theGaussSubMesh->myIsVTKDone)
       return;
     
+    TVTKSource& aSource = theGaussSubMesh->mySource;
     GetSource(aSource,theGaussSubMesh,theMeshOnEntity);
     INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
     BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
@@ -1015,6 +1098,7 @@ namespace
     if(theGaussMesh->myIsVTKDone)
       return;
     
+    INITMSG(MYDEBUG,"GetGaussMesh"<<endl);
     TVTKAppendFilter& anAppendFilter = theGaussMesh->myFilter;
     const TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh;
     TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
@@ -1032,6 +1116,10 @@ namespace
       anAppendFilter->AddInput(aSource.GetPointer());
     }
     anAppendFilter->Update(); // Fix on VTK
+
+    vtkDataSet* aSource = anAppendFilter->GetOutput();
+    INITMSGA(MYDEBUG,0,"aNbPoints - "<<aSource->GetNumberOfPoints()<<endl);
+    BEGMSG(MYDEBUG,"aNbCells - "<<aSource->GetNumberOfCells()<<endl);
     
     theGaussMesh->myIsVTKDone = true;
   }
@@ -1233,7 +1321,7 @@ VISU_Convertor_impl
      
        TVTKAppendFilter& anAppendFilter = aGaussMesh->myFilter;
        aSource->ShallowCopy(anAppendFilter->GetOutput());
-       //GetTimeStampOnProfile(aSource,aField,aValForTime);
+       GetTimeStampOnGaussMesh(aSource,aField,aValForTime);
       }
 
       aValForTime->myIsVTKDone = true;
index 0b6f084f74cd7abb038be661cb4bfe32b003b782..7be4fb06ccf6a0313bde0947d6d306e9bde61b37 100644 (file)
@@ -45,7 +45,7 @@ using MED::TFloat;
 using MED::EBooleen;
 
 #ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
 static int MY_FAMILY_DEBUG = 0;
 static int MY_GROUP_DEBUG = 0;
 #else
@@ -628,7 +628,7 @@ VISU_MedConvertor
        }
       }
 
-      continue;
+      //continue;
 
       MED::TFamilyGroup aFamilyGroup = MED::GetFamilies(aMed,aMeshInfo);
       MED::TFamilyByEntity aFamilyByEntity = MED::GetFamiliesByEntity(aMed,aElemGroup,aFamilyGroup);