]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Added support of visualization of STRUCTURE mesh.
authorenk <enk@opencascade.com>
Thu, 25 May 2006 13:22:04 +0000 (13:22 +0000)
committerenk <enk@opencascade.com>
Thu, 25 May 2006 13:22:04 +0000 (13:22 +0000)
Bug PAL11384.

src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx
src/DriverMED/DriverMED_R_SMESHDS_Mesh.h

index ac423b45110d2c3d9e7843db87b488b173074a17..4d466f8f5343eb364159dc22226d11fc082b8637 100644 (file)
@@ -84,9 +84,6 @@ DriverMED_R_SMESHDS_Mesh
        //---------------------
        PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh+1);
 
-       if (aMeshInfo->GetType() != MED::eNON_STRUCTURE)
-         continue; // not implemented yet
-
         string aMeshName;
         if (myMeshId != -1) {
           ostringstream aMeshNameStr;
@@ -126,9 +123,14 @@ DriverMED_R_SMESHDS_Mesh
          }
         }
 
+       if (aMeshInfo->GetType() == MED::eSTRUCTURE){
+         bool aRes = buildMeshGrille(aMed,aMeshInfo);
+         continue;
+       }
+
         // Reading MED nodes to the corresponding SMDS structure
        //------------------------------------------------------
-       PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
+      PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
        if(!aNodeInfo)
          continue;
 
@@ -890,3 +892,86 @@ bool DriverMED_R_SMESHDS_Mesh::checkFamilyID(DriverMED_FamilyPtr & aFamily, int
   return ( aFamily->GetId() == anID );
 }
 
+
+/*! \brief Reading the structured mesh and convert to non structured (by filling of smesh structure for non structured mesh)
+ * \param theWrapper  - PWrapper const pointer
+ * \param theMeshInfo - PMeshInfo const pointer
+ * \return TRUE, if successfully. Else FALSE
+ */
+bool DriverMED_R_SMESHDS_Mesh::buildMeshGrille(const MED::PWrapper& theWrapper,
+                                              const MED::PMeshInfo& theMeshInfo)
+{
+  bool res = true;
+
+  MED::PGrilleInfo aGrilleInfo = theWrapper->GetPGrilleInfo(theMeshInfo);
+  MED::TInt aNbNodes = aGrilleInfo->GetNbNodes();
+  MED::TInt aNbCells = aGrilleInfo->GetNbCells();
+  MED::TInt aMeshDim = theMeshInfo->GetDim();
+  DriverMED_FamilyPtr aFamily;
+  for(MED::TInt iNode=0;iNode < aNbNodes; iNode++){
+    double aCoords[3] = {0.0, 0.0, 0.0};
+    const SMDS_MeshNode* aNode;
+    MED::TNodeCoord aMEDNodeCoord = aGrilleInfo->GetCoord(iNode);
+    for(MED::TInt iDim=0;iDim<aMeshDim;iDim++)
+      aCoords[(int)iDim] = aMEDNodeCoord[(int)iDim];
+    aNode = myMesh->AddNodeWithID(aCoords[0],aCoords[1],aCoords[2],(int)iNode);
+  }
+
+  /* not implemented FAMILY
+     
+  TInt aFamNum = aNodeInfo->GetFamNum(iElem);
+  if ( checkFamilyID ( aFamily, aFamNum ))
+    {
+      aFamily->AddElement(aNode);
+      aFamily->SetType(SMDSAbs_Node);
+    }
+    
+  */
+
+  SMDS_MeshElement* anElement = NULL;
+  MED::TIntVector aNodeIds;
+  for(MED::TInt iCell=0;iCell < aNbCells; iCell++){
+    aNodeIds = aGrilleInfo->GetConn(iCell);
+    switch(aGrilleInfo->GetGeom()){
+    case MED::eSEG2:
+      if(aNodeIds.size() != 2){
+       aRes = false;
+       EXCEPTION(runtime_error,"buildMeshGrille Error. Incorrect size of ids 2!="<<aNodeIds.size());
+      }
+      anElement = myMesh->AddEdgeWithID(aNodeIds[0],
+                                       aNodeIds[1],
+                                       iCell);
+      break;
+    case MED::eQUAD4:
+      if(aNodeIds.size() != 4){
+       aRes = false;
+       EXCEPTION(runtime_error,"buildMeshGrille Error. Incorrect size of ids 4!="<<aNodeIds.size());
+      }
+      anElement = myMesh->AddFaceWithID(aNodeIds[0],
+                                       aNodeIds[2],
+                                       aNodeIds[3],
+                                       aNodeIds[1],
+                                       iCell);
+      break;
+    case MED::eHEXA8:
+      if(aNodeIds.size() != 8){
+       aRes = false;
+       EXCEPTION(runtime_error,"buildMeshGrille Error. Incorrect size of ids 8!="<<aNodeIds.size());
+      }
+      anElement = myMesh->AddVolumeWithID(aNodeIds[0],
+                                         aNodeIds[2],
+                                         aNodeIds[3],
+                                         aNodeIds[1],
+                                         aNodeIds[4],
+                                         aNodeIds[6],
+                                         aNodeIds[7],
+                                         aNodeIds[5],
+                                         iCell);
+      break;
+    default:
+      break;
+    }
+  }
+
+  return res;
+}
index cb72bccdfb911e3ad16cb42ee7ed462d4c71501b..268a7089662d25bdf1df256dc981069d234f03d1 100644 (file)
@@ -60,6 +60,9 @@ class DriverMED_R_SMESHDS_Mesh: public Driver_SMESHDS_Mesh
    */
   bool checkFamilyID(DriverMED_FamilyPtr & aFamily, int anID) const;
 
+  bool buildMeshGrille(const MED::PWrapper& theWrapper,
+                      const MED::PMeshInfo& theMeshInfo);
+
  private:
   std::string myMeshName;
   std::map<int, DriverMED_FamilyPtr> myFamilies;