-// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 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
#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_0DElementIteratorPtr elements0dIterator(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;
-
-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
if ( _preMeshInfo )
return _preMeshInfo->NbElements();
- return Nb0DElements() + NbEdges() + NbFaces() + NbVolumes();
+ return Nb0DElements() + NbEdges() + NbFaces() + NbVolumes() + NbBalls();
}
CORBA::Long SMESH_Mesh_i::Nb0DElements()throw (SALOME::SALOME_Exception)
return _impl->Nb0DElements();
}
+CORBA::Long SMESH_Mesh_i::NbBalls() throw (SALOME::SALOME_Exception)
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ if ( _preMeshInfo )
+ return _preMeshInfo->NbBalls();
+
+ return _impl->NbBalls();
+}
+
CORBA::Long SMESH_Mesh_i::NbEdges()throw(SALOME::SALOME_Exception)
{
Unexpect aCatch(SALOME_SalomeException);
return elem->IsQuadratic();
}
+//=============================================================================
+/*!
+ * Returns diameter of ball discrete element or zero in case of an invalid \a id
+ */
+//=============================================================================
+
+CORBA::Double SMESH_Mesh_i::GetBallDiameter(CORBA::Long id)
+{
+ if ( _preMeshInfo )
+ _preMeshInfo->FullLoadFromFile();
+
+ if ( const SMDS_BallElement* ball =
+ dynamic_cast<const SMDS_BallElement*>( _impl->GetMeshDS()->FindElement( id )))
+ return ball->GetDiameter();
+
+ return 0;
+}
//=============================================================================
/*!
*/
//=============================================================================
-void SMESH_Mesh_i::CreateGroupServants()
+void SMESH_Mesh_i::CreateGroupServants()
{
SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
//=============================================================================
void SMESH_Mesh_i::SetParameters(const char* theParameters)
{
- SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Mesh::_narrow(_this()),
- CORBA::string_dup(theParameters));
+ // SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Mesh::_narrow(_this()),
+ // CORBA::string_dup(theParameters));
+ SMESH_Gen_i::GetSMESHGen()->UpdateParameters(theParameters);
}
//=============================================================================
SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType;
- types->length( 4 );
+ types->length( 5 );
int nbTypes = 0;
- if (_impl->NbEdges())
- types[nbTypes++] = SMESH::EDGE;
- if (_impl->NbFaces())
- types[nbTypes++] = SMESH::FACE;
- if (_impl->NbVolumes())
- types[nbTypes++] = SMESH::VOLUME;
- if (_impl->Nb0DElements())
- types[nbTypes++] = SMESH::ELEM0D;
+ if (_impl->NbEdges()) types[nbTypes++] = SMESH::EDGE;
+ if (_impl->NbFaces()) types[nbTypes++] = SMESH::FACE;
+ if (_impl->NbVolumes()) types[nbTypes++] = SMESH::VOLUME;
+ if (_impl->Nb0DElements()) types[nbTypes++] = SMESH::ELEM0D;
+ if (_impl->NbBalls()) types[nbTypes++] = SMESH::BALL;
types->length( nbTypes );
return types._retn();
}
//=============================================================================
+namespace // Finding concurrent hypotheses
+//=============================================================================
+{
+
/*!
* \brief mapping of mesh dimension into shape type
*/
-//=============================================================================
-
-static TopAbs_ShapeEnum shapeTypeByDim(const int theDim)
+TopAbs_ShapeEnum shapeTypeByDim(const int theDim)
{
TopAbs_ShapeEnum aType = TopAbs_SOLID;
switch ( theDim ) {
return aType;
}
-//=============================================================================
+//-----------------------------------------------------------------------------
/*!
* \brief Internal structure used to find concurent submeshes
*
* with another submesh. In other words, it is dimension of a hypothesis assigned
* to submesh.
*/
-//=============================================================================
-
class SMESH_DimHyp
{
public:
int _ownDim; //!< dimension of shape of _subMesh (>=_dim)
TopTools_MapOfShape _shapeMap;
SMESH_subMesh* _subMesh;
- list<const SMESHDS_Hypothesis*> _hypothesises; //!< algo is first, then its parameters
+ list<const SMESHDS_Hypothesis*> _hypotheses; //!< algo is first, then its parameters
+
+ //-----------------------------------------------------------------------------
+ // Return the algorithm
+ const SMESH_Algo* GetAlgo() const
+ { return _hypotheses.empty() ? 0 : dynamic_cast<const SMESH_Algo*>( _hypotheses.front() ); }
+ //-----------------------------------------------------------------------------
//! Constructors
SMESH_DimHyp(const SMESH_subMesh* theSubMesh,
const int theDim,
SetShape( theDim, theShape );
}
+ //-----------------------------------------------------------------------------
//! set shape
void SetShape(const int theDim,
const TopoDS_Shape& theShape)
}
}
+ //-----------------------------------------------------------------------------
//! Check sharing of sub-shapes
static bool isShareSubShapes(const TopTools_MapOfShape& theToCheck,
const TopTools_MapOfShape& theToFind,
return isShared;
}
+ //-----------------------------------------------------------------------------
//! check algorithms
static bool checkAlgo(const SMESHDS_Hypothesis* theA1,
const SMESHDS_Hypothesis* theA2)
{
- if ( theA1->GetType() == SMESHDS_Hypothesis::PARAM_ALGO ||
+ if ( !theA1 || !theA2 ||
+ theA1->GetType() == SMESHDS_Hypothesis::PARAM_ALGO ||
theA2->GetType() == SMESHDS_Hypothesis::PARAM_ALGO )
return false; // one of the hypothesis is not algorithm
// check algorithm names (should be equal)
}
+ //-----------------------------------------------------------------------------
//! Check if sub-shape hypotheses are concurrent
bool IsConcurrent(const SMESH_DimHyp* theOther) const
{
// if ( <own dim of either of submeshes> == <concurrent dim> &&
// any of the two submeshes is not on COMPOUND shape )
// -> no concurrency
- bool meIsCompound = (_subMesh->GetSubMeshDS() && _subMesh->GetSubMeshDS()->IsComplexSubmesh());
- bool otherIsCompound = (theOther->_subMesh->GetSubMeshDS() && theOther->_subMesh->GetSubMeshDS()->IsComplexSubmesh());
+ bool meIsCompound = (_subMesh->GetSubMeshDS() &&
+ _subMesh->GetSubMeshDS()->IsComplexSubmesh());
+ bool otherIsCompound = (theOther->_subMesh->GetSubMeshDS() &&
+ theOther->_subMesh->GetSubMeshDS()->IsComplexSubmesh());
if ( (_ownDim == _dim || theOther->_ownDim == _dim ) && (!meIsCompound || !otherIsCompound))
return false;
return false;
// check algorithms to be same
- if (!checkAlgo( _hypothesises.front(), theOther->_hypothesises.front() ))
- return true; // different algorithms
-
+ if ( !checkAlgo( this->GetAlgo(), theOther->GetAlgo() ))
+ return true; // different algorithms -> concurrency !
+
// check hypothesises for concurrence (skip first as algorithm)
int nbSame = 0;
- // pointers should be same, becase it is referenes from mesh hypothesis partition
- list <const SMESHDS_Hypothesis*>::const_iterator hypIt = _hypothesises.begin();
- list <const SMESHDS_Hypothesis*>::const_iterator otheEndIt = theOther->_hypothesises.end();
- for ( hypIt++ /*skip first as algo*/; hypIt != _hypothesises.end(); hypIt++ )
- if ( find( theOther->_hypothesises.begin(), otheEndIt, *hypIt ) != otheEndIt )
+ // pointers should be same, because it is referened from mesh hypothesis partition
+ list <const SMESHDS_Hypothesis*>::const_iterator hypIt = _hypotheses.begin();
+ list <const SMESHDS_Hypothesis*>::const_iterator otheEndIt = theOther->_hypotheses.end();
+ for ( hypIt++ /*skip first as algo*/; hypIt != _hypotheses.end(); hypIt++ )
+ if ( find( theOther->_hypotheses.begin(), otheEndIt, *hypIt ) != otheEndIt )
nbSame++;
// the submeshes are concurrent if their algorithms has different parameters
- return nbSame != theOther->_hypothesises.size() - 1;
+ return nbSame != theOther->_hypotheses.size() - 1;
+ }
+
+ // Return true if algorithm of this SMESH_DimHyp is used if no
+ // sub-mesh order is imposed by the user
+ bool IsHigherPriorityThan( const SMESH_DimHyp* theOther ) const
+ {
+ // NeedDiscreteBoundary() algo has a higher priority
+ if ( this ->GetAlgo()->NeedDiscreteBoundary() !=
+ theOther->GetAlgo()->NeedDiscreteBoundary() )
+ return !this->GetAlgo()->NeedDiscreteBoundary();
+
+ return ( this->_subMesh->GetId() < theOther->_subMesh->GetId() );
}
}; // end of SMESH_DimHyp
+//-----------------------------------------------------------------------------
+
+typedef list<const SMESH_DimHyp*> TDimHypList;
-typedef list<SMESH_DimHyp*> TDimHypList;
+//-----------------------------------------------------------------------------
-static void addDimHypInstance(const int theDim,
- const TopoDS_Shape& theShape,
- const SMESH_Algo* theAlgo,
- const SMESH_subMesh* theSubMesh,
- const list <const SMESHDS_Hypothesis*>& theHypList,
- TDimHypList* theDimHypListArr )
+void addDimHypInstance(const int theDim,
+ const TopoDS_Shape& theShape,
+ const SMESH_Algo* theAlgo,
+ const SMESH_subMesh* theSubMesh,
+ const list <const SMESHDS_Hypothesis*>& theHypList,
+ TDimHypList* theDimHypListArr )
{
TDimHypList& listOfdimHyp = theDimHypListArr[theDim];
if ( listOfdimHyp.empty() || listOfdimHyp.back()->_subMesh != theSubMesh ) {
SMESH_DimHyp* dimHyp = new SMESH_DimHyp( theSubMesh, theDim, theShape );
+ dimHyp->_hypotheses.push_front(theAlgo);
listOfdimHyp.push_back( dimHyp );
}
- SMESH_DimHyp* dimHyp = listOfdimHyp.back();
- dimHyp->_hypothesises.push_front(theAlgo);
- list <const SMESHDS_Hypothesis*>::const_iterator hypIt = theHypList.begin();
- for( ; hypIt != theHypList.end(); hypIt++ )
- dimHyp->_hypothesises.push_back( *hypIt );
+ SMESH_DimHyp* dimHyp = const_cast<SMESH_DimHyp*>( listOfdimHyp.back() );
+ dimHyp->_hypotheses.insert( dimHyp->_hypotheses.end(),
+ theHypList.begin(), theHypList.end() );
}
-static void findConcurrents(const SMESH_DimHyp* theDimHyp,
- const TDimHypList& theListOfDimHyp,
- TListOfInt& theListOfConcurr )
+//-----------------------------------------------------------------------------
+void addInOrderOfPriority( const SMESH_DimHyp* theDimHyp,
+ TDimHypList& theListOfConcurr)
+{
+ if ( theListOfConcurr.empty() )
+ {
+ theListOfConcurr.push_back( theDimHyp );
+ }
+ else
+ {
+ TDimHypList::iterator hypIt = theListOfConcurr.begin();
+ while ( hypIt != theListOfConcurr.end() &&
+ !theDimHyp->IsHigherPriorityThan( *hypIt ))
+ ++hypIt;
+ theListOfConcurr.insert( hypIt, theDimHyp );
+ }
+}
+
+//-----------------------------------------------------------------------------
+void findConcurrents(const SMESH_DimHyp* theDimHyp,
+ const TDimHypList& theListOfDimHyp,
+ TDimHypList& theListOfConcurrHyp,
+ set<int>& theSetOfConcurrId )
{
TDimHypList::const_reverse_iterator rIt = theListOfDimHyp.rbegin();
- for ( ; rIt != theListOfDimHyp.rend(); rIt++ ) {
+ for ( ; rIt != theListOfDimHyp.rend(); rIt++ )
+ {
const SMESH_DimHyp* curDimHyp = *rIt;
if ( curDimHyp == theDimHyp )
break; // meet own dimHyp pointer in same dimension
- else if ( theDimHyp->IsConcurrent( curDimHyp ) )
- if ( find( theListOfConcurr.begin(),
- theListOfConcurr.end(),
- curDimHyp->_subMesh->GetId() ) == theListOfConcurr.end() )
- theListOfConcurr.push_back( curDimHyp->_subMesh->GetId() );
+
+ if ( theDimHyp->IsConcurrent( curDimHyp ) &&
+ theSetOfConcurrId.insert( curDimHyp->_subMesh->GetId() ).second )
+ {
+ addInOrderOfPriority( curDimHyp, theListOfConcurrHyp );
+ }
}
}
-static void unionLists(TListOfInt& theListOfId,
- TListOfListOfInt& theListOfListOfId,
- const int theIndx )
+//-----------------------------------------------------------------------------
+void unionLists(TListOfInt& theListOfId,
+ TListOfListOfInt& theListOfListOfId,
+ const int theIndx )
{
TListOfListOfInt::iterator it = theListOfListOfId.begin();
for ( int i = 0; it != theListOfListOfId.end(); it++, i++ ) {
otherListOfId.clear();
}
}
+//-----------------------------------------------------------------------------
//! free memory allocated for dimension-hypothesis objects
-static void removeDimHyps( TDimHypList* theArrOfList )
+void removeDimHyps( TDimHypList* theArrOfList )
{
for (int i = 0; i < 4; i++ ) {
TDimHypList& listOfdimHyp = theArrOfList[i];
}
}
+//-----------------------------------------------------------------------------
+/*!
+ * \brief find common submeshes with given submesh
+ * \param theSubMeshList list of already collected submesh to check
+ * \param theSubMesh given submesh to intersect with other
+ * \param theCommonSubMeshes collected common submeshes
+ */
+void findCommonSubMesh (list<const SMESH_subMesh*>& theSubMeshList,
+ const SMESH_subMesh* theSubMesh,
+ set<const SMESH_subMesh*>& theCommon )
+{
+ if ( !theSubMesh )
+ return;
+ list<const SMESH_subMesh*>::const_iterator it = theSubMeshList.begin();
+ for ( ; it != theSubMeshList.end(); it++ )
+ theSubMesh->FindIntersection( *it, theCommon );
+ theSubMeshList.push_back( theSubMesh );
+ //theCommon.insert( theSubMesh );
+}
+
+} // namespace
+
//=============================================================================
/*!
* \brief Return submesh objects list in meshing order
TListOfListOfInt anOrder = mesh.GetMeshOrder(); // is there already defined order?
if ( !anOrder.size() ) {
- // collect submeshes detecting concurrent algorithms and hypothesises
+ // collect submeshes and detect concurrent algorithms and hypothesises
TDimHypList dimHypListArr[4]; // dimHyp list for each shape dimension
map<int, ::SMESH_subMesh*>::iterator i_sm = _mapSubMesh.begin();
::SMESH_subMesh* sm = (*i_sm).second;
// shape of submesh
const TopoDS_Shape& aSubMeshShape = sm->GetSubShape();
-
+
// list of assigned hypothesises
const list <const SMESHDS_Hypothesis*>& hypList = mesh.GetHypothesisList(aSubMeshShape);
// Find out dimensions where the submesh can be concurrent.
anAlgo = mesh.GetGen()->GetAlgo( mesh, anExp.Current() );
}
if (!anAlgo)
- continue; // no assigned algorithm to current submesh
+ continue; // no algorithm assigned to a current submesh
int dim = anAlgo->GetDim(); // top concurrent dimension (see comment to SMESH_DimHyp)
// the submesh can concurrent at <dim> (or lower dims if !anAlgo->NeedDiscreteBoundary())
// iterate on created dimension-hypotheses and check for concurrents
for ( int i = 0; i < 4; i++ ) {
- const list<SMESH_DimHyp*>& listOfDimHyp = dimHypListArr[i];
+ const TDimHypList& listOfDimHyp = dimHypListArr[i];
// check for concurrents in own and other dimensions (step-by-step)
TDimHypList::const_iterator dhIt = listOfDimHyp.begin();
for ( ; dhIt != listOfDimHyp.end(); dhIt++ ) {
const SMESH_DimHyp* dimHyp = *dhIt;
- TListOfInt listOfConcurr;
+ TDimHypList listOfConcurr;
+ set<int> setOfConcurrIds;
// looking for concurrents and collect into own list
for ( int j = i; j < 4; j++ )
- findConcurrents( dimHyp, dimHypListArr[j], listOfConcurr );
+ findConcurrents( dimHyp, dimHypListArr[j], listOfConcurr, setOfConcurrIds );
// check if any concurrents found
if ( listOfConcurr.size() > 0 ) {
// add own submesh to list of concurrent
- listOfConcurr.push_front( dimHyp->_subMesh->GetId() );
- anOrder.push_back( listOfConcurr );
+ addInOrderOfPriority( dimHyp, listOfConcurr );
+ list<int> listOfConcurrIds;
+ TDimHypList::iterator hypIt = listOfConcurr.begin();
+ for ( ; hypIt != listOfConcurr.end(); ++hypIt )
+ listOfConcurrIds.push_back( (*hypIt)->_subMesh->GetId() );
+ anOrder.push_back( listOfConcurrIds );
}
}
}
return aResult._retn();
}
-//=============================================================================
-/*!
- * \brief find common submeshes with given submesh
- * \param theSubMeshList list of already collected submesh to check
- * \param theSubMesh given submesh to intersect with other
- * \param theCommonSubMeshes collected common submeshes
- */
-//=============================================================================
-
-static void findCommonSubMesh (list<const SMESH_subMesh*>& theSubMeshList,
- const SMESH_subMesh* theSubMesh,
- set<const SMESH_subMesh*>& theCommon )
-{
- if ( !theSubMesh )
- return;
- list<const SMESH_subMesh*>::const_iterator it = theSubMeshList.begin();
- for ( ; it != theSubMeshList.end(); it++ )
- theSubMesh->FindIntersection( *it, theCommon );
- theSubMeshList.push_back( theSubMesh );
- //theCommon.insert( theSubMesh );
-}
-
//=============================================================================
/*!
* \brief Set submesh object order
// clear collected submeshes
set<const SMESH_subMesh*>::iterator clrIt = subMeshToClear.begin();
- for ( ; clrIt != subMeshToClear.end(); clrIt++ ) {
- SMESH_subMesh* sm = (SMESH_subMesh*)*clrIt;
- if ( sm )
- sm->ComputeStateEngine( SMESH_subMesh::CLEAN );
- // ClearSubMesh( *clrIt );
- }
+ for ( ; clrIt != subMeshToClear.end(); clrIt++ )
+ if ( SMESH_subMesh* sm = (SMESH_subMesh*)*clrIt )
+ sm->ComputeStateEngine( SMESH_subMesh::CLEAN );
}
aPythonDump << " ])";
}
}
// -------------------------------------------------------------------------------------
+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 );
+
+ typedef SMDS_SetIterator
+ <const SMDS_MeshElement*,
+ TIDSortedElemSet::const_iterator,
+ SMDS::SimpleAccessor<const SMDS_MeshElement*, TIDSortedElemSet::const_iterator>,
+ SMDS_MeshElement::GeomFilter
+ > TIter;
+
+ SMDSAbs_ElementType type = SMDS_MeshCell::toSmdsType( geomType );
+
+ return SMDS_ElemIteratorPtr( new TIter( _elements[type].begin(),
+ _elements[type].end(),
+ SMDS_MeshElement::GeomFilter( geomType )));
+}
+// -------------------------------------------------------------------------------------
+SMDS_ElemIteratorPtr SMESH_MeshPartDS::elementEntityIterator(SMDSAbs_EntityType entity) const
+{
+ if ( _meshDS ) return _meshDS->elementEntityIterator( entity );
+
+ typedef SMDS_SetIterator
+ <const SMDS_MeshElement*,
+ TIDSortedElemSet::const_iterator,
+ SMDS::SimpleAccessor<const SMDS_MeshElement*, TIDSortedElemSet::const_iterator>,
+ SMDS_MeshElement::EntityFilter
+ > TIter;
+
+ SMDSAbs_ElementType type = SMDS_MeshCell::toSmdsType( entity );
+
+ return SMDS_ElemIteratorPtr( new TIter( _elements[type].begin(),
+ _elements[type].end(),
+ SMDS_MeshElement::EntityFilter( entity )));
+}
+// -------------------------------------------------------------------------------------
SMDS_ElemIteratorPtr SMESH_MeshPartDS::elementsIterator(SMDSAbs_ElementType type) const
{
typedef SMDS_SetIterator<const SMDS_MeshElement*, TIDSortedElemSet::const_iterator > TIter;
}
// -------------------------------------------------------------------------------------
_GET_ITER_DEFINE( SMDS_NodeIteratorPtr, nodesIterator, SMDS_MeshNode, SMDSAbs_Node )
-_GET_ITER_DEFINE( SMDS_0DElementIteratorPtr, elements0dIterator, SMDS_Mesh0DElement, SMDSAbs_0DElement)
_GET_ITER_DEFINE( SMDS_EdgeIteratorPtr, edgesIterator, SMDS_MeshEdge, SMDSAbs_Edge )
_GET_ITER_DEFINE( SMDS_FaceIteratorPtr, facesIterator, SMDS_MeshFace, SMDSAbs_Face )
_GET_ITER_DEFINE( SMDS_VolumeIteratorPtr, volumesIterator, SMDS_MeshVolume, SMDSAbs_Volume)
// END Implementation of SMESH_MeshPartDS
//
//================================================================================
+
+