#include <DriverMED_R_SMESHDS_Mesh.h>

Public Types | |
| enum | Status { DRS_OK, DRS_EMPTY, DRS_WARN_RENUMBER, DRS_WARN_SKIP_ELEM, DRS_FAIL } |
Public Member Functions | |
| virtual Status | Perform () |
| std::list< TNameAndType > | GetGroupNamesAndTypes () |
| void | GetGroup (SMESHDS_Group *theGroup) |
| void | CreateAllSubMeshes () |
| void | GetSubMesh (SMESHDS_SubMesh *theSubMesh, const int theId) |
| std::list< std::string > | GetMeshNames (Status &theStatus) |
| void | SetMeshName (std::string theMeshName) |
| void | SetMesh (SMESHDS_Mesh *theMesh) |
| void | SetMeshId (int theMeshId) |
| void | SetFile (const std::string &theFileName) |
Protected Attributes | |
| SMESHDS_Mesh * | myMesh |
| std::string | myFile |
| int | myMeshId |
Private Member Functions | |
| bool | checkFamilyID (DriverMED_FamilyPtr &aFamily, int anID) const |
| Ensure aFamily has required ID. | |
| bool | buildMeshGrille (const MED::PWrapper &theWrapper, const MED::PMeshInfo &theMeshInfo) |
| Reading the structured mesh and convert to non structured (by filling of smesh structure for non structured mesh) | |
Private Attributes | |
| std::string | myMeshName |
| std::map< int, DriverMED_FamilyPtr > | myFamilies |
Definition at line 43 of file DriverMED_R_SMESHDS_Mesh.h.
enum Driver_Mesh::Status [inherited] |
Definition at line 48 of file Driver_Mesh.h.
{
DRS_OK,
DRS_EMPTY, // a file contains no mesh with the given name
DRS_WARN_RENUMBER, // a file has overlapped ranges of element numbers,
// so the numbers from the file are ignored
DRS_WARN_SKIP_ELEM, // some elements were skipped due to incorrect file data
DRS_FAIL // general failure (exception etc.)
};
| bool DriverMED_R_SMESHDS_Mesh::buildMeshGrille | ( | const MED::PWrapper & | theWrapper, |
| const MED::PMeshInfo & | theMeshInfo | ||
| ) | [private] |
Reading the structured mesh and convert to non structured (by filling of smesh structure for non structured mesh)
| theWrapper | - PWrapper const pointer |
| theMeshInfo | - PMeshInfo const pointer |
Definition at line 957 of file DriverMED_R_SMESHDS_Mesh.cxx.
References EXCEPTION, SMDS_MeshElement.GetType(), SMESH_AdvancedEditor.res, and SMDSAbs_Node.
{
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],iNode+1);
if (!aNode) {
EXCEPTION(runtime_error,"buildMeshGrille Error. Node not created! "<<(int)iNode);
}
if((aGrilleInfo->myFamNumNode).size() > 0){
TInt aFamNum = aGrilleInfo->GetFamNumNode(iNode);
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){
res = false;
EXCEPTION(runtime_error,"buildMeshGrille Error. Incorrect size of ids 2!="<<aNodeIds.size());
}
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]+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]+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 )){
aFamily->AddElement(anElement);
aFamily->SetType(anElement->GetType());
}
}
}
return res;
}
| bool DriverMED_R_SMESHDS_Mesh::checkFamilyID | ( | DriverMED_FamilyPtr & | aFamily, |
| int | anID | ||
| ) | const [private] |
Ensure aFamily has required ID.
Ensure aFamily to have required ID.
| aFamily | - a family to check |
| anID | - an ID aFamily should have |
| bool | - true if successful |
| aFamily | - a family to check and update |
| anID | - an ID aFamily should have |
| bool | - true if successful |
Definition at line 940 of file DriverMED_R_SMESHDS_Mesh.cxx.
{
if ( !aFamily || aFamily->GetId() != anID ) {
map<int, DriverMED_FamilyPtr>::const_iterator i_fam = myFamilies.find(anID);
if ( i_fam == myFamilies.end() )
return false;
aFamily = i_fam->second;
}
return ( aFamily->GetId() == anID );
}
| void DriverMED_R_SMESHDS_Mesh::CreateAllSubMeshes | ( | ) |
Definition at line 885 of file DriverMED_R_SMESHDS_Mesh.cxx.
References SMESH_fixation.aShape, ex29_refine.node(), and SMDSAbs_Node.
Referenced by SMESH_Gen_i.Load().
{
map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
for (; aFamsIter != myFamilies.end(); aFamsIter++)
{
DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
MED::TStringSet aGroupNames = aFamily->GetGroupNames();
set<string>::iterator aGrNamesIter = aGroupNames.begin();
for (; aGrNamesIter != aGroupNames.end(); aGrNamesIter++)
{
string aName = *aGrNamesIter;
// Check, if this is a Group or SubMesh name
if (aName.substr(0, 7) == string("SubMesh"))
{
int Id = atoi(string(aName).substr(7).c_str());
set<const SMDS_MeshElement *> anElements = aFamily->GetElements();
set<const SMDS_MeshElement *>::iterator anElemsIter = anElements.begin();
if (aFamily->GetType() == SMDSAbs_Node)
{
for (; anElemsIter != anElements.end(); anElemsIter++)
{
SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>
( static_cast<const SMDS_MeshNode*>( *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++)
{
myMesh->SetMeshElementOnShape(*anElemsIter, Id);
}
}
}
}
}
}
| void DriverMED_R_SMESHDS_Mesh::GetGroup | ( | SMESHDS_Group * | theGroup | ) |
Definition at line 824 of file DriverMED_R_SMESHDS_Mesh.cxx.
References SMDS_MeshGroup.Add(), SMESHDS_GroupBase.GetStoreName(), SMDS_MeshElement.GetType(), SMESHDS_GroupBase.GetType(), MESSAGE, SMESHDS_GroupBase.SetColorGroup(), and SMESHDS_Group.SMDSGroup().
Referenced by SMESH_Gen_i.Load(), and SMESH_Mesh.MEDToMesh().
{
string aGroupName (theGroup->GetStoreName());
if(MYDEBUG) MESSAGE("Get Group " << aGroupName);
map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
for (; aFamsIter != myFamilies.end(); aFamsIter++)
{
DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
if (aFamily->GetTypes().count( theGroup->GetType() ) && aFamily->MemberOf(aGroupName))
{
const set<const SMDS_MeshElement *>& anElements = aFamily->GetElements();
set<const SMDS_MeshElement *>::const_iterator anElemsIter = anElements.begin();
for (; anElemsIter != anElements.end(); anElemsIter++)
{
const SMDS_MeshElement * element = *anElemsIter;
if ( element->GetType() == theGroup->GetType() ) // Issue 0020576
theGroup->SMDSGroup().Add(element);
}
int aGroupAttrVal = aFamily->GetGroupAttributVal();
if( aGroupAttrVal != 0)
theGroup->SetColorGroup(aGroupAttrVal);
// if ( element ) -- Issue 0020576
// theGroup->SetType( theGroup->SMDSGroup().GetType() );
}
}
}
| list< TNameAndType > DriverMED_R_SMESHDS_Mesh::GetGroupNamesAndTypes | ( | ) |
Definition at line 796 of file DriverMED_R_SMESHDS_Mesh.cxx.
Referenced by SMESH_Mesh.MEDToMesh().
{
list<TNameAndType> aResult;
set<TNameAndType> aResGroupNames;
map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
for (; aFamsIter != myFamilies.end(); aFamsIter++)
{
DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
const MED::TStringSet& aGroupNames = aFamily->GetGroupNames();
set<string>::const_iterator aGrNamesIter = aGroupNames.begin();
for (; aGrNamesIter != aGroupNames.end(); aGrNamesIter++)
{
const set< SMDSAbs_ElementType >& types = aFamily->GetTypes();
set< SMDSAbs_ElementType >::const_iterator type = types.begin();
for ( ; type != types.end(); ++type )
{
TNameAndType aNameAndType = make_pair( *aGrNamesIter, *type );
if ( aResGroupNames.insert( aNameAndType ).second ) {
aResult.push_back( aNameAndType );
}
}
}
}
return aResult;
}
| list< string > DriverMED_R_SMESHDS_Mesh::GetMeshNames | ( | Status & | theStatus | ) |
Definition at line 768 of file DriverMED_R_SMESHDS_Mesh.cxx.
References SMESH.DRS_FAIL, SMESH.DRS_OK, and MESSAGE.
Referenced by SMESH_Gen_i.CreateMeshesFromMED().
{
list<string> aMeshNames;
try {
if(MYDEBUG) MESSAGE("GetMeshNames - myFile : " << myFile);
theStatus = DRS_OK;
PWrapper aMed = CrWrapper(myFile);
if (TInt aNbMeshes = aMed->GetNbMeshes()) {
for (int iMesh = 0; iMesh < aNbMeshes; iMesh++) {
// Reading the MED mesh
//---------------------
PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh+1);
aMeshNames.push_back(aMeshInfo->GetName());
}
}
}catch(const std::exception& exc){
INFOS("Following exception was caught:\n\t"<<exc.what());
theStatus = DRS_FAIL;
}catch(...){
INFOS("Unknown exception was caught !!!");
theStatus = DRS_FAIL;
}
return aMeshNames;
}
| void DriverMED_R_SMESHDS_Mesh::GetSubMesh | ( | SMESHDS_SubMesh * | theSubMesh, |
| const int | theId | ||
| ) |
Definition at line 852 of file DriverMED_R_SMESHDS_Mesh.cxx.
References SMESHDS_SubMesh.AddElement(), SMESHDS_SubMesh.AddNode(), ex29_refine.node(), and SMDSAbs_Node.
{
char submeshGrpName[ 30 ];
sprintf( submeshGrpName, "SubMesh %d", theId );
string aName (submeshGrpName);
map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
for (; aFamsIter != myFamilies.end(); aFamsIter++)
{
DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
if (aFamily->MemberOf(aName))
{
const set<const SMDS_MeshElement *>& anElements = aFamily->GetElements();
set<const SMDS_MeshElement *>::const_iterator anElemsIter = anElements.begin();
if (aFamily->GetType() == SMDSAbs_Node)
{
for (; anElemsIter != anElements.end(); anElemsIter++)
{
const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>(*anElemsIter);
theSubMesh->AddNode(node);
}
}
else
{
for (; anElemsIter != anElements.end(); anElemsIter++)
{
theSubMesh->AddElement(*anElemsIter);
}
}
}
}
}
| Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform | ( | ) | [virtual] |
Implements Driver_Mesh.
Definition at line 71 of file DriverMED_R_SMESHDS_Mesh.cxx.
References SMESH.DRS_EMPTY, SMESH.DRS_FAIL, SMESH.DRS_OK, SMESH.DRS_WARN_RENUMBER, SMESH.DRS_WARN_SKIP_ELEM, FindNode(), SMDS_MeshElement.GetType(), MESSAGE, and SMDSAbs_Node.
Referenced by SMESH_Gen_i.Load(), and SMESH_Mesh.MEDToMesh().
{
Status aResult = DRS_FAIL;
#ifndef _DEXCEPT_
try{
#endif
myFamilies.clear();
if(MYDEBUG) MESSAGE("Perform - myFile : "<<myFile);
PWrapper aMed = CrWrapper(myFile,true);
aResult = DRS_EMPTY;
if(TInt aNbMeshes = aMed->GetNbMeshes()){
for(int iMesh = 0; iMesh < aNbMeshes; iMesh++){
// Reading the MED mesh
//---------------------
PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh+1);
string aMeshName;
if (myMeshId != -1) {
ostringstream aMeshNameStr;
aMeshNameStr<<myMeshId;
aMeshName = aMeshNameStr.str();
} else {
aMeshName = myMeshName;
}
if(MYDEBUG) MESSAGE("Perform - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
if(aMeshName != aMeshInfo->GetName()) continue;
aResult = DRS_OK;
//TInt aMeshDim = aMeshInfo->GetDim();
// Reading MED families to the temporary structure
//------------------------------------------------
TErr anErr;
TInt aNbFams = aMed->GetNbFamilies(aMeshInfo);
if(MYDEBUG) MESSAGE("Read " << aNbFams << " families");
for (TInt iFam = 0; iFam < aNbFams; iFam++) {
PFamilyInfo aFamilyInfo = aMed->GetPFamilyInfo(aMeshInfo,iFam+1,&anErr);
if(anErr >= 0){
TInt aFamId = aFamilyInfo->GetId();
if(MYDEBUG) MESSAGE("Family " << aFamId << " :");
DriverMED_FamilyPtr aFamily (new DriverMED_Family);
TInt aNbGrp = aFamilyInfo->GetNbGroup();
if(MYDEBUG) MESSAGE("belong to " << aNbGrp << " groups");
bool isAttrOk = false;
if(aFamilyInfo->GetNbAttr() == aNbGrp)
isAttrOk = true;
for (TInt iGr = 0; iGr < aNbGrp; iGr++) {
string aGroupName = aFamilyInfo->GetGroupName(iGr);
if(isAttrOk){
TInt anAttrVal = aFamilyInfo->GetAttrVal(iGr);
aFamily->SetGroupAttributVal(anAttrVal);
}
if(MYDEBUG) MESSAGE(aGroupName);
aFamily->AddGroupName(aGroupName);
}
aFamily->SetId( aFamId );
myFamilies[aFamId] = aFamily;
}
}
if (aMeshInfo->GetType() == MED::eSTRUCTURE){
/*bool aRes = */buildMeshGrille(aMed,aMeshInfo);
continue;
}
// Reading MED nodes to the corresponding SMDS structure
//------------------------------------------------------
PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
if (!aNodeInfo) {
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();
TInt aNbElems = aNodeInfo->GetNbElem();
if(MYDEBUG) MESSAGE("Perform - aNodeInfo->GetNbElem() = "<<aNbElems<<"; anIsNodeNum = "<<anIsNodeNum);
DriverMED_FamilyPtr aFamily;
for(TInt iElem = 0; iElem < aNbElems; iElem++){
TCCoordSlice aCoordSlice = aNodeInfo->GetCoordSlice(iElem);
double aCoords[3] = {0.0, 0.0, 0.0};
for(TInt iDim = 0; iDim < 3; iDim++)
aCoords[iDim] = aCoordHelper->GetCoord(aCoordSlice,iDim);
const SMDS_MeshNode* aNode;
if(anIsNodeNum) {
aNode = myMesh->AddNodeWithID
(aCoords[0],aCoords[1],aCoords[2],aNodeInfo->GetElemNum(iElem));
//MESSAGE("AddNodeWithID " << aNodeInfo->GetElemNum(iElem));
} else {
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;
// Save reference to this node from its family
TInt aFamNum = aNodeInfo->GetFamNum(iElem);
if ( checkFamilyID ( aFamily, aFamNum ))
{
aFamily->AddElement(aNode);
aFamily->SetType(SMDSAbs_Node);
}
}
// Reading pre information about all MED cells
//--------------------------------------------
typedef MED::TVector<int> TNodeIds;
bool takeNumbers = true; // initially we trust the numbers from file
MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo);
MED::TEntityInfo::iterator anEntityIter = aEntityInfo.begin();
for(; anEntityIter != aEntityInfo.end(); anEntityIter++){
const EEntiteMaillage& anEntity = anEntityIter->first;
if(anEntity == eNOEUD) continue;
// Reading MED cells to the corresponding SMDS structure
//------------------------------------------------------
const MED::TGeom2Size& aGeom2Size = anEntityIter->second;
MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
const EGeometrieElement& aGeom = aGeom2SizeIter->first;
switch(aGeom) {
// case ePOINT1: ## PAL16410
// break;
case ePOLYGONE: {
PPolygoneInfo aPolygoneInfo = aMed->GetPPolygoneInfo(aMeshInfo,anEntity,aGeom);
EBooleen anIsElemNum = takeNumbers ? aPolygoneInfo->IsElemNum() : eFAUX;
TInt aNbElem = aPolygoneInfo->GetNbElem();
for(TInt iElem = 0; iElem < aNbElem; iElem++){
MED::TCConnSlice aConnSlice = aPolygoneInfo->GetConnSlice(iElem);
TInt aNbConn = aPolygoneInfo->GetNbConn(iElem);
TNodeIds aNodeIds(aNbConn);
#ifdef _EDF_NODE_IDS_
if(anIsNodeNum)
for(TInt iConn = 0; iConn < aNbConn; iConn++)
aNodeIds[iConn] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1);
else
for(TInt iConn = 0; iConn < aNbConn; iConn++)
aNodeIds[iConn] = aConnSlice[iConn];
#else
for(TInt iConn = 0; iConn < aNbConn; iConn++)
aNodeIds[iConn] = aConnSlice[iConn];
#endif
bool isRenum = false;
SMDS_MeshElement* anElement = NULL;
TInt aFamNum = aPolygoneInfo->GetFamNum(iElem);
#ifndef _DEXCEPT_
try{
#endif
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_
}catch(const std::exception& exc){
aResult = DRS_FAIL;
}catch (...){
aResult = DRS_FAIL;
}
#endif
if(!anElement){
aResult = DRS_WARN_SKIP_ELEM;
}else{
if(isRenum){
anIsElemNum = eFAUX;
takeNumbers = false;
if(aResult < DRS_WARN_RENUMBER)
aResult = DRS_WARN_RENUMBER;
}
if ( checkFamilyID ( aFamily, aFamNum ))
{
// Save reference to this element from its family
aFamily->AddElement(anElement);
aFamily->SetType(anElement->GetType());
}
}
}
break;
}
case ePOLYEDRE: {
PPolyedreInfo aPolyedreInfo = aMed->GetPPolyedreInfo(aMeshInfo,anEntity,aGeom);
EBooleen anIsElemNum = takeNumbers ? aPolyedreInfo->IsElemNum() : eFAUX;
TInt aNbElem = aPolyedreInfo->GetNbElem();
for(TInt iElem = 0; iElem < aNbElem; iElem++){
MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(iElem);
TInt aNbFaces = aConnSliceArr.size();
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++)
{
//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
}
bool isRenum = false;
SMDS_MeshElement* anElement = NULL;
TInt aFamNum = aPolyedreInfo->GetFamNum(iElem);
#ifndef _DEXCEPT_
try{
#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_
}catch(const std::exception& exc){
aResult = DRS_FAIL;
}catch(...){
aResult = DRS_FAIL;
}
#endif
if(!anElement){
aResult = DRS_WARN_SKIP_ELEM;
}else{
if(isRenum){
anIsElemNum = eFAUX;
takeNumbers = false;
if (aResult < DRS_WARN_RENUMBER)
aResult = DRS_WARN_RENUMBER;
}
if ( checkFamilyID ( aFamily, aFamNum )) {
// Save reference to this element from its family
aFamily->AddElement(anElement);
aFamily->SetType(anElement->GetType());
}
}
}
break;
}
default: {
PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,anEntity,aGeom);
EBooleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : eFAUX;
TInt aNbElems = aCellInfo->GetNbElem();
if(MYDEBUG) MESSAGE("Perform - anEntity = "<<anEntity<<"; anIsElemNum = "<<anIsElemNum);
if(MYDEBUG) MESSAGE("Perform - aGeom = "<<aGeom<<"; aNbElems = "<<aNbElems);
TInt aNbNodes = -1;
switch(aGeom){
case eSEG2: aNbNodes = 2; break;
case eSEG3: aNbNodes = 3; break;
case eTRIA3: aNbNodes = 3; break;
case eTRIA6: aNbNodes = 6; break;
case eQUAD4: aNbNodes = 4; break;
case eQUAD8: aNbNodes = 8; break;
case eTETRA4: aNbNodes = 4; break;
case eTETRA10: aNbNodes = 10; break;
case ePYRA5: aNbNodes = 5; break;
case ePYRA13: aNbNodes = 13; break;
case ePENTA6: aNbNodes = 6; break;
case ePENTA15: aNbNodes = 15; break;
case eHEXA8: aNbNodes = 8; break;
case eHEXA20: aNbNodes = 20; break;
case ePOINT1: aNbNodes = 1; break;
default:;
}
vector<TInt> aNodeIds(aNbNodes);
for(int iElem = 0; iElem < aNbElems; iElem++){
bool anIsValidConnect = false;
TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem);
#ifndef _DEXCEPT_
try{
#endif
#ifdef _EDF_NODE_IDS_
if(anIsNodeNum)
for(int iNode = 0; iNode < aNbNodes; iNode++)
aNodeIds[iNode] = aNodeInfo->GetElemNum(aConnSlice[iNode] - 1);
else
for(int iNode = 0; iNode < aNbNodes; iNode++)
aNodeIds[iNode] = aConnSlice[iNode];
#else
for(int iNode = 0; iNode < aNbNodes; iNode++)
aNodeIds[iNode] = aConnSlice[iNode];
#endif
anIsValidConnect = true;
#ifndef _DEXCEPT_
}catch(const std::exception& exc){
INFOS("Following exception was caught:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
INFOS("Unknown exception was cought !!!");
aResult = DRS_FAIL;
}
#endif
if(!anIsValidConnect)
continue;
bool isRenum = false;
const SMDS_MeshElement* anElement = NULL;
TInt aFamNum = aCellInfo->GetFamNum(iElem);
#ifndef _DEXCEPT_
try{
#endif
//MESSAGE("Try to create element # " << iElem << " with id = "
// << aCellInfo->GetElemNum(iElem));
switch(aGeom) {
case ePOINT1:
//anElement = FindNode(myMesh,aNodeIds[0]);
if(anIsElemNum)
anElement = myMesh->Add0DElementWithID
(aNodeIds[0], aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->Add0DElement(FindNode(myMesh,aNodeIds[0]));
isRenum = anIsElemNum;
}
break;
case eSEG2:
if(anIsElemNum)
anElement = myMesh->AddEdgeWithID(aNodeIds[0],
aNodeIds[1],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddEdge(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]));
isRenum = anIsElemNum;
}
break;
case eSEG3:
if(anIsElemNum)
anElement = myMesh->AddEdgeWithID(aNodeIds[0],
aNodeIds[1],
aNodeIds[2],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddEdge(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]));
isRenum = anIsElemNum;
}
break;
case eTRIA3:
aNbNodes = 3;
if(anIsElemNum)
anElement = myMesh->AddFaceWithID(aNodeIds[0],
aNodeIds[1],
aNodeIds[2],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]));
isRenum = anIsElemNum;
}
break;
case eTRIA6:
aNbNodes = 6;
if(anIsElemNum)
anElement = myMesh->AddFaceWithID(aNodeIds[0], aNodeIds[1],
aNodeIds[2], aNodeIds[3],
aNodeIds[4], aNodeIds[5],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[3]),
FindNode(myMesh,aNodeIds[4]),
FindNode(myMesh,aNodeIds[5]));
isRenum = anIsElemNum;
}
break;
case eQUAD4:
aNbNodes = 4;
if(anIsElemNum)
anElement = myMesh->AddFaceWithID(aNodeIds[0], aNodeIds[1],
aNodeIds[2], aNodeIds[3],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[3]));
isRenum = anIsElemNum;
}
break;
case eQUAD8:
aNbNodes = 8;
if(anIsElemNum)
anElement = myMesh->AddFaceWithID(aNodeIds[0], aNodeIds[1],
aNodeIds[2], aNodeIds[3],
aNodeIds[4], aNodeIds[5],
aNodeIds[6], aNodeIds[7],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[3]),
FindNode(myMesh,aNodeIds[4]),
FindNode(myMesh,aNodeIds[5]),
FindNode(myMesh,aNodeIds[6]),
FindNode(myMesh,aNodeIds[7]));
isRenum = anIsElemNum;
}
break;
case eTETRA4:
aNbNodes = 4;
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
aNodeIds[2], aNodeIds[3],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[3]));
isRenum = anIsElemNum;
}
break;
case eTETRA10:
aNbNodes = 10;
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
aNodeIds[2], aNodeIds[3],
aNodeIds[4], aNodeIds[5],
aNodeIds[6], aNodeIds[7],
aNodeIds[8], aNodeIds[9],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[3]),
FindNode(myMesh,aNodeIds[4]),
FindNode(myMesh,aNodeIds[5]),
FindNode(myMesh,aNodeIds[6]),
FindNode(myMesh,aNodeIds[7]),
FindNode(myMesh,aNodeIds[8]),
FindNode(myMesh,aNodeIds[9]));
isRenum = anIsElemNum;
}
break;
case ePYRA5:
aNbNodes = 5;
// There is some differnce between SMDS and MED
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
aNodeIds[2], aNodeIds[3],
aNodeIds[4],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[3]),
FindNode(myMesh,aNodeIds[4]));
isRenum = anIsElemNum;
}
break;
case ePYRA13:
aNbNodes = 13;
// There is some difference between SMDS and MED
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
aNodeIds[2], aNodeIds[3],
aNodeIds[4], aNodeIds[5],
aNodeIds[6], aNodeIds[7],
aNodeIds[8], aNodeIds[9],
aNodeIds[10], aNodeIds[11],
aNodeIds[12],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[3]),
FindNode(myMesh,aNodeIds[4]),
FindNode(myMesh,aNodeIds[5]),
FindNode(myMesh,aNodeIds[6]),
FindNode(myMesh,aNodeIds[7]),
FindNode(myMesh,aNodeIds[8]),
FindNode(myMesh,aNodeIds[9]),
FindNode(myMesh,aNodeIds[10]),
FindNode(myMesh,aNodeIds[11]),
FindNode(myMesh,aNodeIds[12]));
isRenum = anIsElemNum;
}
break;
case ePENTA6:
aNbNodes = 6;
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0],
aNodeIds[1],
aNodeIds[2],
aNodeIds[3],
aNodeIds[4],
aNodeIds[5],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[3]),
FindNode(myMesh,aNodeIds[4]),
FindNode(myMesh,aNodeIds[5]));
isRenum = anIsElemNum;
}
break;
case ePENTA15:
aNbNodes = 15;
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
aNodeIds[2], aNodeIds[3],
aNodeIds[4], aNodeIds[5],
aNodeIds[6], aNodeIds[7],
aNodeIds[8], aNodeIds[9],
aNodeIds[10], aNodeIds[11],
aNodeIds[12], aNodeIds[13],
aNodeIds[14],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[3]),
FindNode(myMesh,aNodeIds[4]),
FindNode(myMesh,aNodeIds[5]),
FindNode(myMesh,aNodeIds[6]),
FindNode(myMesh,aNodeIds[7]),
FindNode(myMesh,aNodeIds[8]),
FindNode(myMesh,aNodeIds[9]),
FindNode(myMesh,aNodeIds[10]),
FindNode(myMesh,aNodeIds[11]),
FindNode(myMesh,aNodeIds[12]),
FindNode(myMesh,aNodeIds[13]),
FindNode(myMesh,aNodeIds[14]));
isRenum = anIsElemNum;
}
break;
case eHEXA8:
aNbNodes = 8;
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0],
aNodeIds[1],
aNodeIds[2],
aNodeIds[3],
aNodeIds[4],
aNodeIds[5],
aNodeIds[6],
aNodeIds[7],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[3]),
FindNode(myMesh,aNodeIds[4]),
FindNode(myMesh,aNodeIds[5]),
FindNode(myMesh,aNodeIds[6]),
FindNode(myMesh,aNodeIds[7]));
isRenum = anIsElemNum;
}
break;
case eHEXA20:
aNbNodes = 20;
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
aNodeIds[2], aNodeIds[3],
aNodeIds[4], aNodeIds[5],
aNodeIds[6], aNodeIds[7],
aNodeIds[8], aNodeIds[9],
aNodeIds[10], aNodeIds[11],
aNodeIds[12], aNodeIds[13],
aNodeIds[14], aNodeIds[15],
aNodeIds[16], aNodeIds[17],
aNodeIds[18], aNodeIds[19],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[3]),
FindNode(myMesh,aNodeIds[4]),
FindNode(myMesh,aNodeIds[5]),
FindNode(myMesh,aNodeIds[6]),
FindNode(myMesh,aNodeIds[7]),
FindNode(myMesh,aNodeIds[8]),
FindNode(myMesh,aNodeIds[9]),
FindNode(myMesh,aNodeIds[10]),
FindNode(myMesh,aNodeIds[11]),
FindNode(myMesh,aNodeIds[12]),
FindNode(myMesh,aNodeIds[13]),
FindNode(myMesh,aNodeIds[14]),
FindNode(myMesh,aNodeIds[15]),
FindNode(myMesh,aNodeIds[16]),
FindNode(myMesh,aNodeIds[17]),
FindNode(myMesh,aNodeIds[18]),
FindNode(myMesh,aNodeIds[19]));
isRenum = anIsElemNum;
}
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("The following exception was caught:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
INFOS("Unknown exception was caught !!!");
aResult = DRS_FAIL;
}
#endif
if (!anElement) {
aResult = DRS_WARN_SKIP_ELEM;
}
else {
if (isRenum) {
anIsElemNum = eFAUX;
takeNumbers = false;
if (aResult < DRS_WARN_RENUMBER)
aResult = DRS_WARN_RENUMBER;
}
if ( checkFamilyID ( aFamily, aFamNum )) {
// Save reference to this element from its family
myFamilies[aFamNum]->AddElement(anElement);
myFamilies[aFamNum]->SetType(anElement->GetType());
}
}
}
}}
}
}
}
}
#ifndef _DEXCEPT_
}catch(const std::exception& exc){
INFOS("The following exception was caught:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
INFOS("Unknown exception was caught !!!");
aResult = DRS_FAIL;
}
#endif
if (myMesh)
myMesh->compactMesh();
if(MYDEBUG) MESSAGE("Perform - aResult status = "<<aResult);
return aResult;
}
| void Driver_Mesh::SetFile | ( | const std::string & | theFileName | ) | [inherited] |
Reimplemented in DriverMED_W_SMESHDS_Mesh.
Definition at line 43 of file Driver_Mesh.cxx.
References Driver_Mesh.myFile, and SMESH_Nut.theFileName.
Referenced by SMESH_Gen_i.CreateMeshesFromMED(), SMESH_Mesh.ExportDAT(), SMESH_Mesh.ExportSTL(), SMESH_Mesh.ExportUNV(), SMESH_Gen_i.Load(), SMESH_Mesh.MEDToMesh(), SMESH_Mesh.STLToMesh(), and SMESH_Mesh.UNVToMesh().
{
myFile = theFileName;
}
| void Driver_SMESHDS_Mesh::SetMesh | ( | SMESHDS_Mesh * | theMesh | ) | [inherited] |
Definition at line 31 of file Driver_SMESHDS_Mesh.cxx.
References Driver_SMESHDS_Mesh.myMesh.
Referenced by SMESH_Gen_i.Load(), and SMESH_Mesh.MEDToMesh().
{
myMesh = theMesh;
}
| void Driver_Mesh::SetMeshId | ( | int | theMeshId | ) | [inherited] |
Definition at line 37 of file Driver_Mesh.cxx.
References Driver_Mesh.myMeshId.
Referenced by SMESH_Gen_i.CreateMeshesFromMED(), SMESH_Mesh.ExportDAT(), SMESH_Mesh.ExportSTL(), SMESH_Mesh.ExportUNV(), SMESH_Gen_i.Load(), SMESH_Mesh.MEDToMesh(), SMESH_Mesh.STLToMesh(), and SMESH_Mesh.UNVToMesh().
{
myMeshId = theMeshId;
}
| void DriverMED_R_SMESHDS_Mesh::SetMeshName | ( | std::string | theMeshName | ) |
Definition at line 56 of file DriverMED_R_SMESHDS_Mesh.cxx.
Referenced by SMESH_Mesh.MEDToMesh().
{
myMeshName = theMeshName;
}
std::map<int, DriverMED_FamilyPtr> DriverMED_R_SMESHDS_Mesh.myFamilies [private] |
Definition at line 70 of file DriverMED_R_SMESHDS_Mesh.h.
std::string Driver_Mesh.myFile [protected, inherited] |
Definition at line 62 of file Driver_Mesh.h.
Referenced by DriverSTL_R_SMDS_Mesh.Perform(), DriverMED_W_SMESHDS_Mesh.Perform(), DriverSTL_R_SMDS_Mesh.readAscii(), DriverSTL_R_SMDS_Mesh.readBinary(), Driver_Mesh.SetFile(), DriverSTL_W_SMDS_Mesh.writeAscii(), and DriverSTL_W_SMDS_Mesh.writeBinary().
SMESHDS_Mesh* Driver_SMESHDS_Mesh.myMesh [protected, inherited] |
Definition at line 37 of file Driver_SMESHDS_Mesh.h.
Referenced by DriverMED_W_SMESHDS_Mesh.Perform(), and Driver_SMESHDS_Mesh.SetMesh().
int Driver_Mesh.myMeshId [protected, inherited] |
Definition at line 63 of file Driver_Mesh.h.
Referenced by DriverMED_W_SMESHDS_Mesh.Perform(), and Driver_Mesh.SetMeshId().
std::string DriverMED_R_SMESHDS_Mesh.myMeshName [private] |
Definition at line 69 of file DriverMED_R_SMESHDS_Mesh.h.