X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FDriverMED%2FDriverMED_R_SMESHDS_Mesh.cxx;h=513454316ef57da8f9328384f0d6a4469eae7aad;hb=e4737e85f0da6d3f90fd08f6be1c2825195fe16f;hp=5ae85bd8b46e8e0b4f6140f96d5759e2bfca8fef;hpb=51569f091c2d18be76ea9bd3e68ca0247cc731c3;p=modules%2Fsmesh.git diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx index 5ae85bd8b..513454316 100644 --- a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx @@ -26,6 +26,7 @@ #include "DriverMED_R_SMESHDS_Mesh.h" #include "DriverMED_R_SMDS_Mesh.h" +#include "SMESHDS_Mesh.hxx" #include "utilities.h" #include "DriverMED_Family.h" @@ -39,82 +40,11 @@ #define _EDF_NODE_IDS_ -DriverMED_R_SMESHDS_Mesh::DriverMED_R_SMESHDS_Mesh() - : - myMesh (NULL), - myFile (""), - myFileId (-1), - myMeshId (-1) -{ -} - -DriverMED_R_SMESHDS_Mesh::~DriverMED_R_SMESHDS_Mesh() -{ -// map::iterator aFamsIter = myFamilies.begin(); -// for (; aFamsIter != myFamilies.end(); aFamsIter++) -// { -// delete (*aFamsIter).second; -// } -} - -void DriverMED_R_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh) -{ - myMesh = aMesh; -} - -void DriverMED_R_SMESHDS_Mesh::SetFile(string aFile) -{ - myFile = aFile; -} - -void DriverMED_R_SMESHDS_Mesh::SetFileId(med_idt aFileId) -{ - myFileId = aFileId; -} - -void DriverMED_R_SMESHDS_Mesh::SetMeshId(int aMeshId) -{ - myMeshId = aMeshId; -} - void DriverMED_R_SMESHDS_Mesh::SetMeshName(string theMeshName) { myMeshName = theMeshName; } -void DriverMED_R_SMESHDS_Mesh::Read() -{ - - string myClass = string("SMDS_Mesh"); - string myExtension = string("MED"); - - DriverMED_R_SMDS_Mesh *myReader = new DriverMED_R_SMDS_Mesh; - - myReader->SetMesh(myMesh); - myReader->SetMeshId(myMeshId); - myReader->SetFile(myFile); - myReader->SetFileId(-1); - - myReader->Read(); -} - -void DriverMED_R_SMESHDS_Mesh::Add() -{ - string myClass = string("SMDS_Mesh"); - string myExtension = string("MED"); - - DriverMED_R_SMDS_Mesh *myReader = new DriverMED_R_SMDS_Mesh; - - myReader->SetMesh(myMesh); - myReader->SetMeshId(myMeshId); - - SCRUTE(myFileId); - myReader->SetFileId(myFileId); - - myReader->Read(); -} - - static const SMDS_MeshNode* FindNode(const SMDS_Mesh* theMesh, med_int theId){ const SMDS_MeshNode* aNode = theMesh->FindNode(theId); @@ -199,17 +129,17 @@ public: typedef boost::shared_ptr TCoordHelperPtr; -DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf() +Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() { - ReadStatus result = DRS_FAIL; + Status aResult = DRS_FAIL; try{ using namespace MEDA; myFamilies.clear(); - MESSAGE("ReadMySelf - myFile : "<GetName()); + MESSAGE("Perform - aMeshName : "<GetName()); if(aMeshName != aMeshInfo->GetName()) continue; - result = DRS_OK; - + aResult = DRS_OK; + med_int aMeshDim = aMeshInfo->GetDim(); + // Reading MED families to the temporary structure //------------------------------------------------ med_int aNbFams = aMed.GetNbFamilies(aMeshInfo); @@ -290,7 +221,7 @@ DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf() med_booleen anIsNodeNum = aNodeInfo->IsElemNum(); med_int aNbElems = aNodeInfo->GetNbElem(); - MESSAGE("ReadMySelf - aNodeInfo->GetNbElem() = "<GetNbElem() = "< DriverMED_R_SMESHDS_Mesh::GetMeshNames() } }catch(const std::exception& exc){ INFOS("Follow exception was cought:\n\t"<& anElements = aFamily->GetElements(); set::iterator anElemsIter = anElements.begin(); + const SMDS_MeshElement * element = 0; for (; anElemsIter != anElements.end(); anElemsIter++) { - theGroup->SMDS_MeshGroup::Add(*anElemsIter); + element = *anElemsIter; + theGroup->SMDSGroup().Add(element); } + if ( element ) + theGroup->SetType( element->GetType() ); } } } @@ -670,10 +608,6 @@ void DriverMED_R_SMESHDS_Mesh::GetSubMesh (SMESHDS_SubMesh* theSubMesh, void DriverMED_R_SMESHDS_Mesh::CreateAllSubMeshes () { - SMESHDS_Mesh* aSMESHDSMesh = dynamic_cast(myMesh); - if (!aSMESHDSMesh) { - EXCEPTION(runtime_error,"Can not cast SMDS_Mesh to SMESHDS_Mesh"); - } map::iterator aFamsIter = myFamilies.begin(); for (; aFamsIter != myFamilies.end(); aFamsIter++) { @@ -693,18 +627,28 @@ void DriverMED_R_SMESHDS_Mesh::CreateAllSubMeshes () { for (; anElemsIter != anElements.end(); anElemsIter++) { - const SMDS_MeshNode* node = static_cast(*anElemsIter); - aSMESHDSMesh->SetNodeInVolume(node, Id); -// aSMESHDSMesh->SetNodeOnFace(node, Id); -// aSMESHDSMesh->SetNodeOnEdge(node, Id); -// aSMESHDSMesh->SetNodeOnVertex(node, Id); + SMDS_MeshNode* node = const_cast + ( static_cast( *anElemsIter )); + // find out a shape type + TopoDS_Shape aShape = myMesh->IndexToShape( Id ); + int aShapeType = ( aShape.IsNull() ? -1 : aShape.ShapeType() ); + switch ( aShapeType ) { + case TopAbs_FACE: + myMesh->SetNodeOnFace(node, Id); break; + case TopAbs_EDGE: + myMesh->SetNodeOnEdge(node, Id); break; + case TopAbs_VERTEX: + myMesh->SetNodeOnVertex(node, Id); break; + default: + myMesh->SetNodeInVolume(node, Id); + } } } else { for (; anElemsIter != anElements.end(); anElemsIter++) { - aSMESHDSMesh->SetMeshElementOnShape(*anElemsIter, Id); + myMesh->SetMeshElementOnShape(*anElemsIter, Id); } } }