]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To unify the assembling of the ELNO related data
authorapo <apo@opencascade.com>
Thu, 1 May 2008 13:13:41 +0000 (13:13 +0000)
committerapo <apo@opencascade.com>
Thu, 1 May 2008 13:13:41 +0000 (13:13 +0000)
src/CONVERTOR/VISU_ElnoMeshValue.hxx
src/CONVERTOR/VISU_MeshValue.cxx

index 2de6b424173c1d10510746a9bb5ef091f00bcab6..0130d90742278dfcd75b03ce753135668b17b7b6 100644 (file)
@@ -136,7 +136,7 @@ namespace VISU
     InsertNextCellData()
     {
       myElnoDataMapper->InsertNextTupleValue( myElemInfo );
-      myElemInfo[ 0 ] = myElemInfo[ 2 ];
+      myElemInfo[ 0 ] += myElemInfo[ 2 ] * myElemInfo[ 1 ];
       myElemInfo[ 2 ] = 0;
     }
 
index 42c3eb3daea1cd5effb544b55ad4124df73960f3..84719b36ae742973c4594bc3ae0ed83581793fd1 100644 (file)
@@ -25,6 +25,7 @@
 //  Module : VISU
 
 #include "VISU_MeshValue.hxx"
+#include "VISU_ElnoMeshValue.hxx"
 #include "VISU_Structures_impl.hxx"
 #include "VISU_ConvertorUtils.hxx"
 
@@ -267,88 +268,6 @@ namespace VISU
   };
 
 
-  //----------------------------------------------------------------------------
-  template<int EDataType>
-  struct TTimeStampOnElnoInitArray
-  {
-    typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
-    typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
-    typedef TTMeshValue<TVTKBasicType> TMeshValue;
-    typedef MED::SharedPtr<TMeshValue> TMeshValuePtr;
-
-    typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
-    typedef MED::SharedPtr<TTDataArrayHolder> PDataArrayHolder;
-    PDataArrayHolder myDataArrayHolder;
-    vtkIntArray *myComponentMapper;
-    vtkIdType myComponentStep;
-
-    TTimeStampOnElnoInitArray( const PDataArrayHolder& theDataArrayHolder, 
-                              vtkIntArray* theComponentMapper,
-                              vtkIdType theComponentStep )
-      : myDataArrayHolder(theDataArrayHolder)
-      , myComponentMapper( theComponentMapper )
-      , myComponentStep( theComponentStep )
-    {}
-
-    void
-    Execute( const PFieldImpl& theField,
-            const PValForTimeImpl& theValForTime )
-    {
-      TVector<TVTKBasicType> aDataValues( myComponentStep );
-      
-      vtkIdType aNextStartId = 0;
-      vtkIdType aNbComp = theField->myNbComp;
-      int aTuples[3] = { aNextStartId, aNbComp, -1 };
-
-      vtkIdType aComponentCount = 0, aTupleId = 0, aComponentTupleId = 0;
-      const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
-      TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin();
-      for ( ; anIter != aGeom2MeshValue.end(); anIter++ ) {
-       EGeometry aEGeom = anIter->first;
-       const TMeshValuePtr aMeshValue = anIter->second;
-       
-       vtkIdType aNbElem = aMeshValue->GetNbElem();
-       vtkIdType aNbGauss = aMeshValue->GetNbGauss();
-        aTuples[ 2 ] = aNbGauss;
-       
-       INITMSG(MYDEBUG,
-               "- aEGeom = "<<aEGeom<<
-               "; aNbElem = "<<aNbElem<<
-               "; aNbGauss = "<<aNbGauss<<
-               std::endl);
-
-       for ( vtkIdType iElem = 0; iElem < aNbElem; iElem++ ) {
-          const typename TMeshValue::TValueSliceArr& aValueSliceArr = aMeshValue->GetGaussValueSliceArr( iElem );
-          
-          for( vtkIdType iGauss = 0; iGauss < aNbGauss; iGauss++ ) {
-            const typename TMeshValue::TCValueSlice& aValueSlice = aValueSliceArr[ iGauss ];
-            
-            for( vtkIdType iComp = 0; iComp < aNbComp; iComp++ ) {
-              aDataValues[ aComponentCount ] = aValueSlice[ iComp ];
-              aComponentCount++;
-
-              if ( aComponentCount == myComponentStep ) {
-                this->myDataArrayHolder->SetTuple( aTupleId, &aDataValues[0] );
-                aComponentCount = 0;
-                aTupleId++;
-              }
-            }
-          }
-
-          aTuples[ 0 ] = aNextStartId;
-          aNextStartId = aTuples[ 0 ] + aNbGauss * aNbComp; 
-
-         this->myComponentMapper->InsertTupleValue( aComponentTupleId, aTuples );
-         aComponentTupleId++;
-       }
-
-        if ( aComponentCount > 0 )
-          this->myDataArrayHolder->SetTuple( aTupleId, &aDataValues[0] );
-      }
-    }
-  };
-
-
   //----------------------------------------------------------------------------
   template<int EDataType>
   void 
@@ -431,35 +350,63 @@ namespace VISU
     aFullDataArray->Delete();
 
     // Process the case for ELNO data
+    //-------------------------------
     if ( theField->myIsELNO ) {
+      // To calculate effective number of components for the VTK compatibel ELNO data representation
       vtkIdType aEffectNbTuples = 0;
       TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin();
       for ( ; anIter != aGeom2MeshValue.end(); anIter++ ) {
        const PMeshValue& aMeshValue = anIter->second;
        aEffectNbTuples += aMeshValue->GetNbElem() * aMeshValue->GetNbGauss();
       }
-      vtkIdType aEffectNbComp = ( aEffectNbTuples * aNbComp ) / aNbTuples + 1;
+
+      vtkIdType anEffectNbComp = ( aEffectNbTuples * aNbComp ) / aNbTuples + 1;
     
-      vtkIntArray *aComponentMapper = vtkIntArray::New();
-      aComponentMapper->SetNumberOfComponents( 3 );
-      aComponentMapper->SetNumberOfTuples( aNbTuples );
-      //{ [ aStartId , aNbComp, aNbRefPoints ], ..., ... , [ ... ] }
-      aComponentMapper->SetName( "ELNO_COMPONENT_MAPPER" );
-      aDataSetAttributes->AddArray( aComponentMapper );    
+      // To create corresponding VTK representation for the ELNO data
+      TSetElnoNodeData< EDataType > aSetElnoNodeData( anEffectNbComp,
+                                                     aNbComp,
+                                                     aNbTuples,
+                                                     "ELNO_FIELD",
+                                                     "ELNO_COMPONENT_MAPPER" );
+
+      std::vector< TVTKBasicType > aDataValues( aNbComp ); // To reserve a temproary value holder
+
+      // To initilize these VTK representation for the ELNO data from the MED
+      anIter = aGeom2MeshValue.begin();
+      for ( ; anIter != aGeom2MeshValue.end(); anIter++ ) {
+       EGeometry aEGeom = anIter->first;
+       const TMeshValuePtr aMeshValue = anIter->second;
+       
+       vtkIdType aNbElem = aMeshValue->GetNbElem();
+       vtkIdType aNbGauss = aMeshValue->GetNbGauss();
+       
+       INITMSG(MYDEBUG,
+               "- aEGeom = "<<aEGeom<<
+               "; aNbElem = "<<aNbElem<<
+               "; aNbGauss = "<<aNbGauss<<
+               std::endl);
+
+       for ( vtkIdType iElem = 0; iElem < aNbElem; iElem++ ) {
+          const typename TMeshValue::TValueSliceArr& aValueSliceArr = aMeshValue->GetGaussValueSliceArr( iElem );          
+
+          for( vtkIdType iGauss = 0; iGauss < aNbGauss; iGauss++ ) {
+            const typename TMeshValue::TCValueSlice& aValueSlice = aValueSliceArr[ iGauss ];
+
+            for( vtkIdType iComp = 0; iComp < aNbComp; iComp++ ) {
+              aDataValues[ iComp ] = aValueSlice[ iComp ];
+            }
+
+           aSetElnoNodeData.AddNextPointData( &aDataValues[ 0 ] );
+          }
+
+         aSetElnoNodeData.InsertNextCellData();
+       }
+      }
       
-      TVTKDataArray *aFullDataArray = TVTKDataArray::New();
-      aFullDataArray->SetNumberOfComponents( aEffectNbComp );
-      aFullDataArray->SetNumberOfTuples( aNbTuples );
-      aFullDataArray->SetName( "ELNO_FIELD" );
-      aDataSetAttributes->AddArray( aFullDataArray );    
-
-      typedef TDataArrayHolder< EDataType > TTDataArrayHolder;
-      PDataArrayHolder aDataArrayHolder( new TTDataArrayHolder( aFullDataArray ) );
-      TTimeStampOnElnoInitArray< EDataType >( aDataArrayHolder, aComponentMapper, aEffectNbComp ).Execute(theField, theValForTime);
-
-      aComponentMapper->Delete();
-      aFullDataArray->Delete();
+      // Assign the ELNO data on the corresponding VTK data set attribute 
+      aSetElnoNodeData.AddData( aDataSetAttributes );
     }
+    //-------------------------------
   }