#include "DriverMED_W_Field.h"
#include "DriverMED_W_SMESHDS_Mesh.h"
#include "MED_Factory.hxx"
-#include "SMDS_LinearEdge.hxx"
#include "SMDS_EdgePosition.hxx"
#include "SMDS_ElemIterator.hxx"
#include "SMDS_FacePosition.hxx"
#include "SMDS_IteratorOnIterators.hxx"
#include "SMDS_MeshGroup.hxx"
#include "SMDS_SetIterator.hxx"
-#include "SMDS_StdIterator.hxx"
#include "SMDS_VolumeTool.hxx"
#include "SMESHDS_Command.hxx"
#include "SMESHDS_CommandType.hxx"
return;
vector<int> nodeIds; // to remove nodes becoming free
- bool isNodal = ( theGroup->GetType() == SMESH::NODE );
- if ( !isNodal && !theGroup->IsEmpty() )
+ if ( !theGroup->IsEmpty() )
{
CORBA::Long elemID = theGroup->GetID( 1 );
int nbElemNodes = GetElemNbNodes( elemID );
nodeIds.reserve( theGroup->Size() * nbElemNodes );
}
- // Retrieve contents
+ // Remove contents
SMESH::SMESH_IDSource_var idSrc = SMESH::SMESH_IDSource::_narrow( theGroup );
SMDS_ElemIteratorPtr elemIt = GetElements( idSrc, theGroup->GetType() );
- SMDS_StdIterator< const SMDS_MeshElement*, SMDS_ElemIteratorPtr > elemBeg( elemIt ), elemEnd;
- std::vector< const SMDS_MeshElement* > elems( theGroup->Size() );
- elems.assign( elemBeg, elemEnd );
-
- TPythonDump pyDump; // Suppress dump from RemoveGroup()
-
- // Remove group
- RemoveGroup( theGroup );
-
- // Remove contents
- for ( size_t i = 0; i < elems.size(); ++i )
+ while ( elemIt->more() )
{
- if ( !isNodal )
- {
- for ( SMDS_ElemIteratorPtr nIt = elems[i]->nodesIterator(); nIt->more(); )
- nodeIds.push_back( nIt->next()->GetID() );
+ const SMDS_MeshElement* e = elemIt->next();
- _impl->GetMeshDS()->RemoveFreeElement( elems[i], /*sm=*/0 );
- }
- else
- {
- _impl->GetMeshDS()->RemoveElement( elems[i] );
- }
+ SMDS_ElemIteratorPtr nIt = e->nodesIterator();
+ while ( nIt->more() )
+ nodeIds.push_back( nIt->next()->GetID() );
+
+ _impl->GetMeshDS()->RemoveElement( e );
}
// Remove free nodes
- for ( size_t i = 0 ; i < nodeIds.size(); ++i )
- if ( const SMDS_MeshNode* n = _impl->GetMeshDS()->FindNode( nodeIds[i] ))
- if ( n->NbInverseElements() == 0 )
- _impl->GetMeshDS()->RemoveFreeNode( n, /*sm=*/0 );
+ if ( theGroup->GetType() != SMESH::NODE )
+ for ( size_t i = 0 ; i < nodeIds.size(); ++i )
+ if ( const SMDS_MeshNode* n = _impl->GetMeshDS()->FindNode( nodeIds[i] ))
+ if ( n->NbInverseElements() == 0 )
+ _impl->GetMeshDS()->RemoveFreeNode( n, /*sm=*/0 );
+
+ TPythonDump pyDump; // Suppress dump from RemoveGroup()
// Update Python script (theGroup must be alive for this)
pyDump << SMESH::SMESH_Mesh_var(_this())
<< ".RemoveGroupWithContents( " << theGroup << " )";
+ // Remove group
+ RemoveGroup( theGroup );
+
SMESH_CATCH( SMESH::throwCorbaException );
}
const SMESH_PredicatePtr& thePredicate )
{
std::string newName;
- if ( !theName || !theName[0] )
+ if ( !theName || strlen( theName ) == 0 )
{
std::set< std::string > presentNames;
std::map<int, SMESH::SMESH_GroupBase_ptr>::const_iterator i_gr = _mapGroups.begin();
_preMeshInfo->FullLoadFromFile();
SMESH::long_array_var aResult = new SMESH::long_array();
- SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS();
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
- if ( aMeshDS == NULL )
+ if ( aSMESHDS_Mesh == NULL )
return aResult._retn();
long nbNodes = NbNodes();
aResult->length( nbNodes );
- SMDS_NodeIteratorPtr anIt = aMeshDS->nodesIterator();
+ SMDS_NodeIteratorPtr anIt = aSMESHDS_Mesh->nodesIterator(/*idInceasingOrder=*/true);
for ( int i = 0, n = nbNodes; i < n && anIt->more(); i++ )
aResult[i] = anIt->next()->GetID();
_preMeshInfo->FullLoadFromFile();
SMESH::double_array_var aResult = new SMESH::double_array();
- SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS();
- if ( aMeshDS == NULL )
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+ if ( aSMESHDS_Mesh == NULL )
return aResult._retn();
// find node
- const SMDS_MeshNode* aNode = aMeshDS->FindNode(id);
+ const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(id);
if(!aNode)
return aResult._retn();
_preMeshInfo->FullLoadFromFile();
SMESH::long_array_var aResult = new SMESH::long_array();
- SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS();
- if ( aMeshDS == NULL )
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+ if ( aSMESHDS_Mesh == NULL )
return aResult._retn();
// find node
- const SMDS_MeshNode* aNode = aMeshDS->FindNode(id);
+ const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(id);
if(!aNode)
return aResult._retn();
case SMDS_TOP_EDGE:
aNodePosition->shapeType = GEOM::EDGE;
aNodePosition->params.length(1);
- aNodePosition->params[0] = SMDS_EdgePositionPtr( pos )->GetUParameter();
+ aNodePosition->params[0] =
+ static_cast<SMDS_EdgePosition*>( pos )->GetUParameter();
break;
- case SMDS_TOP_FACE: {
- SMDS_FacePositionPtr fPos = pos;
+ case SMDS_TOP_FACE:
aNodePosition->shapeType = GEOM::FACE;
aNodePosition->params.length(2);
- aNodePosition->params[0] = fPos->GetUParameter();
- aNodePosition->params[1] = fPos->GetVParameter();
+ aNodePosition->params[0] =
+ static_cast<SMDS_FacePosition*>( pos )->GetUParameter();
+ aNodePosition->params[1] =
+ static_cast<SMDS_FacePosition*>( pos )->GetVParameter();
break;
- }
case SMDS_TOP_VERTEX:
aNodePosition->shapeType = GEOM::VERTEX;
break;
if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile();
- SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS();
- if ( aMeshDS == NULL )
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+ if ( aSMESHDS_Mesh == NULL )
return -1;
// try to find node
- const SMDS_MeshNode* aNode = aMeshDS->FindNode(id);
+ const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(id);
if(aNode) {
return aNode->getshapeId();
}
if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile();
- SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS();
- if ( aMeshDS == NULL )
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+ if ( aSMESHDS_Mesh == NULL )
return -1;
// try to find element
- const SMDS_MeshElement* elem = aMeshDS->FindElement(id);
+ const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
if(!elem)
return -1;
if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile();
- SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS();
- if ( aMeshDS == NULL ) return -1;
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+ if ( aSMESHDS_Mesh == NULL ) return -1;
// try to find element
- const SMDS_MeshElement* elem = aMeshDS->FindElement(id);
+ const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
if(!elem) return -1;
return elem->NbNodes();
}
if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile();
- SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS();
- if ( aMeshDS == NULL ) return -1;
- const SMDS_MeshElement* elem = aMeshDS->FindElement(id);
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+ if ( aSMESHDS_Mesh == NULL ) return -1;
+ const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
if(!elem) return -1;
if( index>=elem->NbNodes() || index<0 ) return -1;
return elem->GetNode(index)->GetID();
_preMeshInfo->FullLoadFromFile();
SMESH::long_array_var aResult = new SMESH::long_array();
- if ( SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS() )
+ if ( SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS() )
{
- if ( const SMDS_MeshElement* elem = aMeshDS->FindElement(id) )
+ if ( const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id) )
{
aResult->length( elem->NbNodes() );
for ( int i = 0; i < elem->NbNodes(); ++i )
if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile();
- SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS();
- if ( aMeshDS == NULL ) return false;
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+ if ( aSMESHDS_Mesh == NULL ) return false;
// try to find node
- const SMDS_MeshNode* aNode = aMeshDS->FindNode(idn);
+ const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(idn);
if(!aNode) return false;
// try to find element
- const SMDS_MeshElement* elem = aMeshDS->FindElement(ide);
+ const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(ide);
if(!elem) return false;
return elem->IsMediumNode(aNode);
if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile();
- SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS();
- if ( aMeshDS == NULL ) return false;
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+ if ( aSMESHDS_Mesh == NULL ) return false;
// try to find node
- const SMDS_MeshNode* aNode = aMeshDS->FindNode(idn);
+ const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(idn);
if(!aNode) return false;
SMESH_MesherHelper aHelper( *(_impl) );
if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile();
- SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS();
- if ( aMeshDS == NULL ) return -1;
- const SMDS_MeshElement* elem = aMeshDS->FindElement(id);
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+ if ( aSMESHDS_Mesh == NULL ) return -1;
+ const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
if(!elem) return -1;
return elem->NbEdges();
}
if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile();
- SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS();
- if ( aMeshDS == NULL ) return -1;
- const SMDS_MeshElement* elem = aMeshDS->FindElement(id);
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+ if ( aSMESHDS_Mesh == NULL ) return -1;
+ const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
if(!elem) return -1;
return elem->NbFaces();
}
_preMeshInfo->FullLoadFromFile();
SMESH::long_array_var aResult = new SMESH::long_array();
- if ( SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS() )
+ if ( SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS() )
{
- if ( const SMDS_MeshElement* elem = aMeshDS->FindElement(elemId) )
+ if ( const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(elemId) )
{
SMDS_VolumeTool vtool( elem );
if ( faceIndex < vtool.NbFaces() )
if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile();
- SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS();
- if ( aMeshDS == NULL ) return false;
- const SMDS_MeshElement* elem = aMeshDS->FindElement(id);
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+ if ( aSMESHDS_Mesh == NULL ) return false;
+ const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
if(!elem) return false;
return elem->IsPoly();
}
if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile();
- SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS();
- if ( aMeshDS == NULL ) return false;
- const SMDS_MeshElement* elem = aMeshDS->FindElement(id);
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+ if ( aSMESHDS_Mesh == NULL ) return false;
+ const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
if(!elem) return false;
return elem->IsQuadratic();
}
_preMeshInfo->FullLoadFromFile();
if ( const SMDS_BallElement* ball =
- SMDS_Mesh::DownCast<SMDS_BallElement>( _impl->GetMeshDS()->FindElement( id )))
+ dynamic_cast<const SMDS_BallElement*>( _impl->GetMeshDS()->FindElement( id )))
return ball->GetDiameter();
return 0;
_preMeshInfo->FullLoadFromFile();
SMESH::double_array_var aResult = new SMESH::double_array();
- SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS();
- if ( aMeshDS == NULL )
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+ if ( aSMESHDS_Mesh == NULL )
return aResult._retn();
- const SMDS_MeshElement* elem = aMeshDS->FindElement(id);
+ const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
if(!elem)
return aResult._retn();
{
// compute error
SMESH_ComputeErrorPtr error = sm->GetComputeError();
- if ( error && error->HasBadElems() )
+ if ( error && !error->myBadElements.empty())
{
// sort bad elements by type
vector< const SMDS_MeshElement* > elemsByType[ SMDSAbs_NbElementTypes ];
- const list<const SMDS_MeshElement*>& badElems =
- static_cast<SMESH_BadInputElements*>( error.get() )->myBadElements;
- list<const SMDS_MeshElement*>::const_iterator elemIt = badElems.begin();
- list<const SMDS_MeshElement*>::const_iterator elemEnd = badElems.end();
+ 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;
{
SALOMEDS::TMPFile_var SeqFile;
if ( SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS() ) {
- SMDS_UnstructuredGrid* aGrid = aMeshDS->GetGrid();
+ SMDS_UnstructuredGrid* aGrid = aMeshDS->getGrid();
if(aGrid) {
vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New();
aWriter->WriteToOutputStringOn();
}
}
-namespace // utils used by SMESH_MeshPartDS
-{
- /*!
- * \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 Element holing its ID only
- */
- struct TElemID : public SMDS_LinearEdge
- {
- TElemID(int ID) : SMDS_LinearEdge(0,0) { setID( ID ); }
- };
-}
-
//================================================================================
//
// Implementation of SMESH_MeshPartDS
SMDS_MeshElement::GeomFilter
> TIter;
- SMDSAbs_ElementType type = SMDS_MeshCell::ElemType( geomType );
+ SMDSAbs_ElementType type = SMDS_MeshCell::toSmdsType( geomType );
return SMDS_ElemIteratorPtr( new TIter( _elements[type].begin(),
_elements[type].end(),
SMDS_MeshElement::EntityFilter
> TIter;
- SMDSAbs_ElementType type = SMDS_MeshCell::ElemType( entity );
+ SMDSAbs_ElementType type = SMDS_MeshCell::toSmdsType( entity );
return SMDS_ElemIteratorPtr( new TIter( _elements[type].begin(),
_elements[type].end(),
}
// -------------------------------------------------------------------------------------
#define _GET_ITER_DEFINE( iterType, methName, elem, elemType) \
- iterType SMESH_MeshPartDS::methName() const \
+ iterType SMESH_MeshPartDS::methName( bool idInceasingOrder) const \
{ \
typedef SMDS_SetIterator<const elem*, TIDSortedElemSet::const_iterator > TIter; \
- return _meshDS ? _meshDS->methName() : iterType \
+ return _meshDS ? _meshDS->methName(idInceasingOrder) : iterType \
( new TIter( _elements[elemType].begin(), _elements[elemType].end() )); \
}
// -------------------------------------------------------------------------------------