#include "SMESH_MEDMesh_i.hxx"
#include "SMESH_MeshEditor.hxx"
#include "SMESH_MeshEditor_i.hxx"
+#include "SMESH_MeshPartDS.hxx"
#include "SMESH_MesherHelper.hxx"
#include "SMESH_PreMeshInfo.hxx"
#include "SMESH_PythonDump.hxx"
#include <OSD_File.hxx>
#include <OSD_Path.hxx>
#include <OSD_Protection.hxx>
+#include <Standard_OutOfMemory.hxx>
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_SequenceOfInteger.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
-#include <TopoDS_Compound.hxx>
-#include <TopTools_MapOfShape.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopoDS_Compound.hxx>
// STL Includes
#include <algorithm>
//=============================================================================
/*!
- *
+ * Convert enum Driver_Mesh::Status to SMESH::DriverMED_ReadStatus
*/
//=============================================================================
return res;
}
+//=============================================================================
+/*!
+ * Convert ::SMESH_ComputeError to SMESH::ComputeError
+ */
+//=============================================================================
+
+static SMESH::ComputeError* ConvertComputeError( SMESH_ComputeErrorPtr errorPtr )
+{
+ SMESH::ComputeError_var errVar = new SMESH::ComputeError();
+ errVar->subShapeID = -1;
+ errVar->hasBadMesh = false;
+
+ if ( !errorPtr || errorPtr->IsOK() )
+ {
+ errVar->code = SMESH::COMPERR_OK;
+ }
+ else
+ {
+ errVar->code = ConvertDriverMEDReadStatus( errorPtr->myName );
+ errVar->comment = errorPtr->myComment.c_str();
+ }
+ return errVar._retn();
+}
+
//=============================================================================
/*!
* ImportMEDFile
return 1;
}
+//================================================================================
+/*!
+ * \brief Imports data from a GMF file and returns an error description
+ */
+//================================================================================
+
+SMESH::ComputeError* SMESH_Mesh_i::ImportGMFFile( const char* theFileName )
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_ComputeErrorPtr error;
+ try {
+ error = _impl->GMFToMesh( theFileName );
+ }
+ catch ( std::bad_alloc& exc ) {
+ error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, "std::bad_alloc raised" );
+ }
+ catch ( Standard_OutOfMemory& exc ) {
+ error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, "Standard_OutOfMemory raised" );
+ }
+ catch (Standard_Failure& ex) {
+ error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, ex.DynamicType()->Name() );
+ if ( ex.GetMessageString() && strlen( ex.GetMessageString() ))
+ error->myComment += string(": ") + ex.GetMessageString();
+ }
+ catch ( SALOME_Exception& S_ex ) {
+ error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, S_ex.what() );
+ }
+ catch ( std::exception& exc ) {
+ error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, exc.what() );
+ }
+ catch (...) {
+ error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, "Unknown exception" );
+ }
+
+ CreateGroupServants();
+
+ return ConvertComputeError( error );
+}
+
//=============================================================================
/*!
*
_impl->ExportSTL(file, isascii);
}
-//=============================================================================
-/*!
- * \brief Class providing SMESHDS_Mesh API to SMESH_IDSource.
- * It is used to export a part of mesh as a whole mesh.
- */
-class SMESH_MeshPartDS : public SMESHDS_Mesh
-{
-public:
- SMESH_MeshPartDS(SMESH::SMESH_IDSource_ptr meshPart);
-
- virtual SMDS_NodeIteratorPtr nodesIterator (bool idInceasingOrder=false) const;
- virtual SMDS_EdgeIteratorPtr edgesIterator (bool idInceasingOrder=false) const;
- virtual SMDS_FaceIteratorPtr facesIterator (bool idInceasingOrder=false) const;
- virtual SMDS_VolumeIteratorPtr volumesIterator (bool idInceasingOrder=false) const;
-
- virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type=SMDSAbs_All) const;
- virtual SMDS_ElemIteratorPtr elementGeomIterator(SMDSAbs_GeometryType type) const;
- virtual SMDS_ElemIteratorPtr elementEntityIterator(SMDSAbs_EntityType type) const;
-
-private:
- TIDSortedElemSet _elements[ SMDSAbs_NbElementTypes ];
- SMESHDS_Mesh* _meshDS;
- /*!
- * \brief Class used to access to protected data of SMDS_MeshInfo
- */
- struct TMeshInfo : public SMDS_MeshInfo
- {
- void Add(const SMDS_MeshElement* e) { SMDS_MeshInfo::addWithPoly( e ); }
- };
-};
-
//================================================================================
/*!
* \brief Export a part of mesh to a med file
#endif
}
+//================================================================================
+/*!
+ * \brief Export a part of mesh to a GMF file
+ */
+//================================================================================
+
+void SMESH_Mesh_i::ExportGMF(::SMESH::SMESH_IDSource_ptr meshPart,
+ const char* file)
+ throw (SALOME::SALOME_Exception)
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ if ( _preMeshInfo )
+ _preMeshInfo->FullLoadFromFile();
+
+ PrepareForWriting(file,/*overwrite=*/true);
+
+ SMESH_MeshPartDS partDS( meshPart );
+ _impl->ExportGMF(file, &partDS);
+
+ TPythonDump() << _this() << ".ExportGMF( " << meshPart<< ", r'" << file << "')";
+}
+
//=============================================================================
/*!
* Return implementation of SALOME_MED::MESH interfaces
*/
//=============================================================================
-void SMESH_Mesh_i::CreateGroupServants()
+void SMESH_Mesh_i::CreateGroupServants()
{
SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
}
}
// -------------------------------------------------------------------------------------
+SMESH_MeshPartDS::SMESH_MeshPartDS(const std::list< const SMDS_MeshElement* > & meshPart):
+ SMESHDS_Mesh( /*meshID=*/-1, /*isEmbeddedMode=*/true), _meshDS(0)
+{
+ TMeshInfo tmpInfo;
+ list< const SMDS_MeshElement* >::const_iterator partIt = meshPart.begin();
+ for ( ; partIt != meshPart.end(); ++partIt )
+ if ( const SMDS_MeshElement * e = *partIt )
+ if ( _elements[ e->GetType() ].insert( e ).second )
+ {
+ tmpInfo.Add( e );
+ SMDS_ElemIteratorPtr nIt = e->nodesIterator();
+ while ( nIt->more() )
+ {
+ const SMDS_MeshNode * n = (const SMDS_MeshNode*) nIt->next();
+ if ( _elements[ SMDSAbs_Node ].insert( n ).second )
+ tmpInfo.Add( n );
+ }
+ }
+ myInfo = tmpInfo;
+}
+// -------------------------------------------------------------------------------------
SMDS_ElemIteratorPtr SMESH_MeshPartDS::elementGeomIterator(SMDSAbs_GeometryType geomType) const
{
if ( _meshDS ) return _meshDS->elementGeomIterator( geomType );
// END Implementation of SMESH_MeshPartDS
//
//================================================================================
+
+