#include "DriverMED_R_SMESHDS_Mesh.h"
#include "DriverMED_W_SMESHDS_Mesh.h"
+#include "MED_Factory.hxx"
#include "SMDS_EdgePosition.hxx"
#include "SMDS_ElemIterator.hxx"
#include "SMDS_FacePosition.hxx"
#include "SMESH_Gen_i.hxx"
#include "SMESH_Group.hxx"
#include "SMESH_Group_i.hxx"
-#include "SMESH_MEDMesh_i.hxx"
#include "SMESH_MeshEditor.hxx"
#include "SMESH_MeshEditor_i.hxx"
#include "SMESH_MeshPartDS.hxx"
int major, minor, release;
if( !MED::getMEDVersion( theFileName, major, minor, release ) )
major = minor = release = -1;
- _medFileInfo = new SALOME_MED::MedFileInfo();
+ _medFileInfo = new SMESH::MedFileInfo();
_medFileInfo->fileName = theFileName;
_medFileInfo->fileSize = 0;
#ifdef WIN32
if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status );
// Update Python script
- if(_impl->HasShapeToMesh()) {
+ //if(_impl->HasShapeToMesh()) {
TPythonDump() << "status = " << _this() << ".AddHypothesis( "
<< aSubShapeObject << ", " << anHyp << " )";
- }
- else {
- TPythonDump() << "status = " << _this() << ".AddHypothesis( "<< anHyp << " )";
- }
+ // }
+ // else {
+ // TPythonDump() << "status = " << _this() << ".AddHypothesis( "<< anHyp << " )";
+ // }
return ConvertHypothesisStatus(status);
}
// Python Dump
TPythonDump aPythonDump;
- if ( !_mapGroups.empty() ) // (IMP13463) avoid "SyntaxError: can't assign to []"
+ if ( !_mapGroups.empty() )
+ {
aPythonDump << "[ ";
-
- try {
- aList->length( _mapGroups.size() );
- int i = 0;
- map<int, SMESH::SMESH_GroupBase_ptr>::iterator it = _mapGroups.begin();
- for ( ; it != _mapGroups.end(); it++ ) {
- if ( CORBA::is_nil( it->second )) continue;
- aList[i++] = SMESH::SMESH_GroupBase::_duplicate( it->second );
- // Python Dump
- if (i > 1) aPythonDump << ", ";
- aPythonDump << it->second;
+ try {
+ aList->length( _mapGroups.size() );
+ int i = 0;
+ map<int, SMESH::SMESH_GroupBase_ptr>::iterator it = _mapGroups.begin();
+ for ( ; it != _mapGroups.end(); it++ ) {
+ if ( CORBA::is_nil( it->second )) continue;
+ aList[i++] = SMESH::SMESH_GroupBase::_duplicate( it->second );
+ // Python Dump
+ if (i > 1) aPythonDump << ", ";
+ aPythonDump << it->second;
+ }
+ aList->length( i );
+ }
+ catch(SALOME_Exception & S_ex) {
+ THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
}
- aList->length( i );
- }
- catch(SALOME_Exception & S_ex) {
- THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
- }
-
- // Update Python script
- if ( !_mapGroups.empty() ) // (IMP13463) avoid "SyntaxError: can't assign to []"
aPythonDump << " ] = " << _this() << ".GetGroups()";
-
+ }
return aList._retn();
}
// register CORBA object for persistence
int nextId = _gen_i->RegisterObject( subMesh );
- if(MYDEBUG) MESSAGE( "Add submesh to map with id = "<< nextId);
+ if(MYDEBUG) { MESSAGE( "Add submesh to map with id = "<< nextId); }
+ else { nextId = 0; } // avoid "unused variable" warning in release mode
// to track changes of GEOM groups
addGeomGroupData( theSubShapeObject, subMesh );
// register CORBA object for persistence
int nextId = _gen_i->RegisterObject( aGroup );
- if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId);
+ if(MYDEBUG) { MESSAGE( "Add group to map with id = "<< nextId); }
+ else { nextId = 0; } // avoid "unused variable" warning in release mode
// to track changes of GEOM groups
if ( !theShape.IsNull() ) {
void SMESH_Mesh_i::ExportToMEDX (const char* file,
CORBA::Boolean auto_groups,
SMESH::MED_VERSION theVersion,
- CORBA::Boolean overwrite)
+ CORBA::Boolean overwrite,
+ CORBA::Boolean autoDimension)
throw(SALOME::SALOME_Exception)
{
Unexpect aCatch(SALOME_SalomeException);
string aMeshName = prepareMeshNameAndGroups(file, overwrite);
TPythonDump() << _this() << ".ExportToMEDX( r'"
- << file << "', " << auto_groups << ", " << theVersion << ", " << overwrite << " )";
+ << file << "', " << auto_groups << ", "
+ << theVersion << ", " << overwrite << ", "
+ << autoDimension << " )";
- _impl->ExportMED( file, aMeshName.c_str(), auto_groups, theVersion );
+ _impl->ExportMED( file, aMeshName.c_str(), auto_groups, theVersion, 0, autoDimension );
}
//================================================================================
const char* file,
CORBA::Boolean auto_groups,
::SMESH::MED_VERSION version,
- ::CORBA::Boolean overwrite)
+ ::CORBA::Boolean overwrite,
+ ::CORBA::Boolean autoDimension)
throw (SALOME::SALOME_Exception)
{
Unexpect aCatch(SALOME_SalomeException);
- if ( _preMeshInfo )
- _preMeshInfo->FullLoadFromFile();
+ TPythonDump pyDump;
- PrepareForWriting(file, overwrite);
+ if ( SMESH_Mesh_i * mesh = SMESH::DownCast< SMESH_Mesh_i* >( meshPart ))
+ {
+ mesh->ExportToMEDX( file, auto_groups, version, autoDimension );
+ }
+ else
+ {
+ if ( _preMeshInfo )
+ _preMeshInfo->FullLoadFromFile();
- string aMeshName = "Mesh";
- SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
- if ( !aStudy->_is_nil() ) {
- SALOMEDS::SObject_wrap SO = _gen_i->ObjectToSObject( aStudy, meshPart );
- if ( !SO->_is_nil() ) {
- CORBA::String_var name = SO->GetName();
- aMeshName = name;
+ PrepareForWriting(file, overwrite);
+
+ string aMeshName = "Mesh";
+ SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
+ if ( !aStudy->_is_nil() ) {
+ SALOMEDS::SObject_wrap SO = _gen_i->ObjectToSObject( aStudy, meshPart );
+ if ( !SO->_is_nil() ) {
+ CORBA::String_var name = SO->GetName();
+ aMeshName = name;
+ }
}
+ SMESH_MeshPartDS partDS( meshPart );
+ _impl->ExportMED( file, aMeshName.c_str(), auto_groups, version, &partDS, autoDimension );
}
- SMESH_MeshPartDS partDS( meshPart );
- _impl->ExportMED( file, aMeshName.c_str(), auto_groups, version, &partDS );
-
- TPythonDump() << _this() << ".ExportPartToMED( " << meshPart << ", r'" << file << "', "
- << auto_groups << ", " << version << ", " << overwrite << " )";
+ pyDump << _this() << ".ExportPartToMED( " << meshPart << ", r'" << file << "', "
+ << auto_groups << ", " << version << ", " << overwrite << ", "
+ << autoDimension << " )";
}
//================================================================================
<< withRequiredGroups << ")";
}
-//=============================================================================
-/*!
- * Return implementation of SALOME_MED::MESH interfaces
- */
-//=============================================================================
-
-SALOME_MED::MESH_ptr SMESH_Mesh_i::GetMEDMesh()throw(SALOME::SALOME_Exception)
-{
- Unexpect aCatch(SALOME_SalomeException);
- if ( _preMeshInfo )
- _preMeshInfo->FullLoadFromFile();
-
- SMESH_MEDMesh_i *aMedMesh = new SMESH_MEDMesh_i(this);
- SALOME_MED::MESH_var aMesh = aMedMesh->_this();
- return aMesh._retn();
-}
-
//=============================================================================
CORBA::Long SMESH_Mesh_i::NbNodes()throw(SALOME::SALOME_Exception)
return aResult._retn();
}
+//================================================================================
+/*!
+ * \brief Create a group of elements preventing computation of a sub-shape
+ */
+//================================================================================
+
+SMESH::ListOfGroups*
+SMESH_Mesh_i::MakeGroupsOfBadInputElements( int theSubShapeID,
+ const char* theGroupName )
+ throw ( SALOME::SALOME_Exception )
+{
+ Unexpect aCatch(SALOME_SalomeException);
+
+ if ( !theGroupName || strlen( theGroupName) == 0 )
+ THROW_SALOME_CORBA_EXCEPTION( "empty group name",SALOME::BAD_PARAM );
+
+ SMESH::ListOfGroups_var groups = new SMESH::ListOfGroups;
+
+ // submesh by subshape id
+ if ( !_impl->HasShapeToMesh() ) theSubShapeID = 1;
+ if ( SMESH_subMesh * sm = _impl->GetSubMeshContaining( theSubShapeID ))
+ {
+ // compute error
+ SMESH_ComputeErrorPtr error = sm->GetComputeError();
+ if ( error && !error->myBadElements.empty())
+ {
+ // sort bad elements by type
+ vector< const SMDS_MeshElement* > elemsByType[ SMDSAbs_NbElementTypes ];
+ list<const SMDS_MeshElement*>::iterator elemIt = error->myBadElements.begin();
+ list<const SMDS_MeshElement*>::iterator elemEnd = error->myBadElements.end();
+ for ( ; elemIt != elemEnd; ++elemIt )
+ {
+ const SMDS_MeshElement* elem = *elemIt;
+ if ( !elem ) continue;
+
+ if ( elem->GetID() < 1 )
+ {
+ // elem is a temporary element, make a real element
+ vector< const SMDS_MeshNode* > nodes;
+ SMDS_NodeIteratorPtr nIt = elem->nodeIterator();
+ while ( nIt->more() && elem )
+ {
+ nodes.push_back( nIt->next() );
+ if ( nodes.back()->GetID() < 1 )
+ elem = 0; // a temporary element on temporary nodes
+ }
+ if ( elem )
+ {
+ ::SMESH_MeshEditor editor( _impl );
+ elem = editor.AddElement( nodes, elem->GetType(), elem->IsPoly() );
+ }
+ }
+ if ( elem )
+ elemsByType[ elem->GetType() ].push_back( elem );
+ }
+
+ // how many groups to create?
+ int nbTypes = 0;
+ for ( int i = 0; i < SMDSAbs_NbElementTypes; ++i )
+ nbTypes += int( !elemsByType[ i ].empty() );
+ groups->length( nbTypes );
+
+ // create groups
+ for ( int i = 0, iG = -1; i < SMDSAbs_NbElementTypes; ++i )
+ {
+ vector< const SMDS_MeshElement* >& elems = elemsByType[ i ];
+ if ( elems.empty() ) continue;
+
+ groups[ ++iG ] = createGroup( SMESH::ElementType(i), theGroupName );
+ if ( _gen_i->CanPublishInStudy( groups[ iG ] ))
+ {
+ SALOMEDS::SObject_wrap aSO =
+ _gen_i->PublishGroup(_gen_i->GetCurrentStudy(), _this(), groups[ iG ],
+ GEOM::GEOM_Object::_nil(), theGroupName);
+ aSO->_is_nil(); // avoid "unused variable" warning
+ }
+ SMESH_GroupBase_i* grp_i = SMESH::DownCast< SMESH_GroupBase_i* >( groups[ iG ]);
+ if ( !grp_i ) continue;
+
+ if ( SMESHDS_Group* grpDS = dynamic_cast< SMESHDS_Group* >( grp_i->GetGroupDS() ))
+ for ( size_t iE = 0; iE < elems.size(); ++iE )
+ grpDS->SMDSGroup().Add( elems[ iE ]);
+ }
+ }
+ }
+
+ return groups._retn();
+}
//=============================================================================
/*!
// register CORBA object for persistence
int nextId = _gen_i->RegisterObject( groupVar );
- if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId);
+ if(MYDEBUG) { MESSAGE( "Add group to map with id = "<< nextId); }
+ else { nextId = 0; } // avoid "unused variable" warning in release mode
// publishing the groups in the study
if ( !aStudy->_is_nil() ) {
*/
//=============================================================================
-SALOME_MED::MedFileInfo* SMESH_Mesh_i::GetMEDFileInfo()
+SMESH::MedFileInfo* SMESH_Mesh_i::GetMEDFileInfo()
{
- SALOME_MED::MedFileInfo_var res( _medFileInfo );
+ SMESH::MedFileInfo_var res( _medFileInfo );
if ( !res.operator->() ) {
- res = new SALOME_MED::MedFileInfo;
+ res = new SMESH::MedFileInfo;
res->fileName = "";
res->fileSize = res->major = res->minor = res->release = -1;
}