-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// SMESH DriverMED : driver to read and write 'med' files
// File : DriverMED_R_SMESHDS_Mesh.cxx
// Module : SMESH
//
#include "DriverMED_R_SMESHDS_Mesh.h"
-#include "DriverMED_R_SMDS_Mesh.h"
#include "SMESHDS_Mesh.hxx"
#include "utilities.h"
#include <stdlib.h>
#ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
//#define _DEXCEPT_
#else
static int MYDEBUG = 0;
aResult = DRS_FAIL;
continue;
}
-
+ aMeshInfo->myDim=aMeshInfo->mySpaceDim;//Bug correction to ignore meshdim in MEDFile because can be false.
PCoordHelper aCoordHelper = GetCoordHelper(aNodeInfo);
EBooleen anIsNodeNum = aNodeInfo->IsElemNum();
if(anIsNodeNum) {
aNode = myMesh->AddNodeWithID
(aCoords[0],aCoords[1],aCoords[2],aNodeInfo->GetElemNum(iElem));
+ //MESSAGE("AddNodeWithID " << aNodeInfo->GetElemNum(iElem));
} else {
- aNode = myMesh->AddNode
- (aCoords[0],aCoords[1],aCoords[2]);
+ aNode = myMesh->AddNodeWithID
+ (aCoords[0],aCoords[1],aCoords[2], iElem+1);
+ //MESSAGE("AddNode " << aNode->GetID());
}
//cout<<aNode->GetID()<<": "<<aNode->X()<<", "<<aNode->Y()<<", "<<aNode->Z()<<endl;
if(anIsElemNum){
TInt anElemId = aPolygoneInfo->GetElemNum(iElem);
anElement = myMesh->AddPolygonalFaceWithID(aNodeIds,anElemId);
+ //MESSAGE("AddPolygonalFaceWithID " << anElemId);
}
if(!anElement){
vector<const SMDS_MeshNode*> aNodes(aNbConn);
for(TInt iConn = 0; iConn < aNbConn; iConn++)
aNodes[iConn] = FindNode(myMesh,aNodeIds[iConn]);
anElement = myMesh->AddPolygonalFace(aNodes);
+ //MESSAGE("AddPolygonalFace " << anElement->GetID());
isRenum = anIsElemNum;
}
#ifndef _DEXCEPT_
typedef MED::TVector<int> TQuantities;
TQuantities aQuantities(aNbFaces);
TInt aNbNodes = aPolyedreInfo->GetNbNodes(iElem);
+ //MESSAGE("--- aNbNodes " << aNbNodes);
TNodeIds aNodeIds(aNbNodes);
for(TInt iFace = 0, iNode = 0; iFace < aNbFaces; iFace++){
+ //MESSAGE("--- iface " << aNbFaces << " " << iFace);
MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
TInt aNbConn = aConnSlice.size();
aQuantities[iFace] = aNbConn;
#ifdef _EDF_NODE_IDS_
+ //MESSAGE(anIsNodeNum);
if(anIsNodeNum)
for(TInt iConn = 0; iConn < aNbConn; iConn++)
- aNodeIds[iNode++] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1);
+ {
+ //MESSAGE("iConn " << iConn << " aConnSlice[iConn] " << aConnSlice[iConn]);
+ aNodeIds[iNode] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1);
+ //MESSAGE("aNodeIds[" << iNode << "]=" << aNodeIds[iNode]);
+ iNode++;
+ }
else
for(TInt iConn = 0; iConn < aNbConn; iConn++)
+ {
+ //MESSAGE("iConn " << iConn);
aNodeIds[iNode++] = aConnSlice[iConn];
+ }
#else
for(TInt iConn = 0; iConn < aNbConn; iConn++)
+ {
+ //MESSAGE("iConn " << iConn);
aNodeIds[iNode++] = aConnSlice[iConn];
+ }
#endif
}
if(anIsElemNum){
TInt anElemId = aPolyedreInfo->GetElemNum(iElem);
anElement = myMesh->AddPolyhedralVolumeWithID(aNodeIds,aQuantities,anElemId);
+ //MESSAGE("AddPolyhedralVolumeWithID " << anElemId);
}
if(!anElement){
vector<const SMDS_MeshNode*> aNodes(aNbNodes);
for(TInt iConn = 0; iConn < aNbNodes; iConn++)
aNodes[iConn] = FindNode(myMesh,aNodeIds[iConn]);
anElement = myMesh->AddPolyhedralVolume(aNodes,aQuantities);
+ //MESSAGE("AddPolyhedralVolume " << anElement->GetID());
isRenum = anIsElemNum;
}
#ifndef _DEXCEPT_
anIsValidConnect = true;
#ifndef _DEXCEPT_
}catch(const std::exception& exc){
- //INFOS("Follow exception was cought:\n\t"<<exc.what());
+ INFOS("Following exception was caught:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
- //INFOS("Unknown exception was cought !!!");
+ INFOS("Unknown exception was cought !!!");
aResult = DRS_FAIL;
}
#endif
break;
case ePYRA13:
aNbNodes = 13;
- // There is some differnce between SMDS and MED
+ // There is some difference between SMDS and MED
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
aNodeIds[2], aNodeIds[3],
}
break;
}
-
+// if (anIsElemNum) {
+// MESSAGE("add element with id " << aCellInfo->GetElemNum(iElem));
+// }
+// else {
+// MESSAGE("add element "<< anElement->GetID());
+// }
#ifndef _DEXCEPT_
}catch(const std::exception& exc){
- //INFOS("Follow exception was cought:\n\t"<<exc.what());
+ INFOS("The following exception was caught:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
- //INFOS("Unknown exception was cought !!!");
+ INFOS("Unknown exception was caught !!!");
aResult = DRS_FAIL;
}
#endif
}
#ifndef _DEXCEPT_
}catch(const std::exception& exc){
- INFOS("Follow exception was cought:\n\t"<<exc.what());
+ INFOS("The following exception was caught:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
- INFOS("Unknown exception was cought !!!");
+ INFOS("Unknown exception was caught !!!");
aResult = DRS_FAIL;
}
#endif
+ if (myMesh)
+ myMesh->compactMesh();
if(MYDEBUG) MESSAGE("Perform - aResult status = "<<aResult);
return aResult;
}
}
}
}catch(const std::exception& exc){
- INFOS("Follow exception was cought:\n\t"<<exc.what());
+ INFOS("Following exception was caught:\n\t"<<exc.what());
theStatus = DRS_FAIL;
}catch(...){
- INFOS("Unknown exception was cought !!!");
+ INFOS("Unknown exception was caught !!!");
theStatus = DRS_FAIL;
}
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);
+ aNode = myMesh->AddNodeWithID(aCoords[0],aCoords[1],aCoords[2],iNode+1);
+ if (!aNode) {
+ EXCEPTION(runtime_error,"buildMeshGrille Error. Node not created! "<<(int)iNode);
+ }
if((aGrilleInfo->myFamNumNode).size() > 0){
TInt aFamNum = aGrilleInfo->GetFamNumNode(iNode);
res = false;
EXCEPTION(runtime_error,"buildMeshGrille Error. Incorrect size of ids 2!="<<aNodeIds.size());
}
- anElement = myMesh->AddEdgeWithID(aNodeIds[0],
- aNodeIds[1],
- iCell);
+ anElement = myMesh->AddEdgeWithID(aNodeIds[0]+1,
+ aNodeIds[1]+1,
+ iCell+1);
break;
case MED::eQUAD4:
if(aNodeIds.size() != 4){
res = 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);
+ anElement = myMesh->AddFaceWithID(aNodeIds[0]+1,
+ aNodeIds[2]+1,
+ aNodeIds[3]+1,
+ aNodeIds[1]+1,
+ iCell+1);
break;
case MED::eHEXA8:
if(aNodeIds.size() != 8){
res = 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);
+ anElement = myMesh->AddVolumeWithID(aNodeIds[0]+1,
+ aNodeIds[2]+1,
+ aNodeIds[3]+1,
+ aNodeIds[1]+1,
+ aNodeIds[4]+1,
+ aNodeIds[6]+1,
+ aNodeIds[7]+1,
+ aNodeIds[5]+1,
+ iCell+1);
break;
default:
break;
}
-
+ if (!anElement) {
+ EXCEPTION(runtime_error,"buildMeshGrille Error. Element not created! "<<iCell);
+ }
if((aGrilleInfo->myFamNum).size() > 0){
TInt aFamNum = aGrilleInfo->GetFamNum(iCell);
if ( checkFamilyID ( aFamily, aFamNum )){