#define NOMINMAX
#endif
+// A macro used in SMESH_TryCatch.hxx,
+// it re-raises a CORBA SALOME exception thrown by SMESH_MeshEditor_i and caught by SMESH_CATCH
+#define SMY_OWN_CATCH \
+ catch ( SALOME::SALOME_Exception & e ) { throw e; }
+
#include "SMESH_MeshEditor_i.hxx"
#include "SMDS_EdgePosition.hxx"
#include "SMESH_Gen_i.hxx"
#include "SMESH_Group.hxx"
#include "SMESH_Group_i.hxx"
+#include "SMESH_MeshAlgos.hxx"
#include "SMESH_MeshPartDS.hxx"
#include "SMESH_MesherHelper.hxx"
#include "SMESH_PythonDump.hxx"
return 0;
}
+//=======================================================================
+//function : ClearLastCreated
+//purpose : Clears sequences of last created elements and nodes
+//=======================================================================
+
+void SMESH_MeshEditor_i::ClearLastCreated() throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ getEditor().CrearLastCreated();
+ SMESH_CATCH( SMESH::throwCorbaException );
+}
+
//=======================================================================
/*
* Returns description of an error/warning occured during the last operation
nodes[i] = getMeshDS()->FindNode(IDsOfNodes[i]);
SMDS_MeshElement* elem = 0;
- if (NbNodes == 3) {
- elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]);
- }
- else if (NbNodes == 4) {
- elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
- }
- else if (NbNodes == 6) {
- elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
- nodes[4], nodes[5]);
- }
- else if (NbNodes == 8) {
- elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
- nodes[4], nodes[5], nodes[6], nodes[7]);
- }
- else if (NbNodes == 9) {
- elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
- nodes[4], nodes[5], nodes[6], nodes[7], nodes[8] );
- }
- else if (NbNodes > 2) {
- elem = getMeshDS()->AddPolygonalFace(nodes);
+ switch (NbNodes) {
+ case 3: elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]); break;
+ case 4: elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]); break;
+ case 6: elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
+ nodes[4], nodes[5]); break;
+ case 7: elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
+ nodes[4], nodes[5], nodes[6]); break;
+ case 8: elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
+ nodes[4], nodes[5], nodes[6], nodes[7]); break;
+ case 9: elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
+ nodes[4], nodes[5], nodes[6], nodes[7],
+ nodes[8] ); break;
+ default: elem = getMeshDS()->AddPolygonalFace(nodes);
}
// Update Python script
* \brief Bind an element to a shape
* \param ElementID - element ID
* \param ShapeID - shape ID available through GEOM_Object.GetSubShapeIndices()[0]
- * \retval boolean - false if ElementID or ShapeID is invalid
*/
//=============================================================================
if ( !elem )
THROW_SALOME_CORBA_EXCEPTION("Invalid ElementID", SALOME::BAD_PARAM);
- if ( mesh->MaxShapeIndex() < ShapeID )
+ if ( mesh->MaxShapeIndex() < ShapeID || ShapeID < 1 )
THROW_SALOME_CORBA_EXCEPTION("Invalid ShapeID", SALOME::BAD_PARAM);
TopoDS_Shape shape = mesh->IndexToShape( ShapeID );
if ( myMesh->NbFaces() == 0 )
THROW_SALOME_CORBA_EXCEPTION("No faces in the mesh", SALOME::BAD_PARAM);
- theElementSearcher = myEditor.GetElementSearcher();
+ theElementSearcher = SMESH_MeshAlgos::GetElementSearcher( *getMeshDS() );
}
else
{
typedef SMDS_SetIterator<const SMDS_MeshElement*, TIDSortedElemSet::const_iterator > TIter;
SMDS_ElemIteratorPtr elemsIt( new TIter( elements.begin(), elements.end() ));
- theElementSearcher = myEditor.GetElementSearcher(elemsIt);
+ theElementSearcher = SMESH_MeshAlgos::GetElementSearcher( *getMeshDS(), elemsIt);
}
}
// find a face
theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
if ( !theNodeSearcher ) {
- theNodeSearcher = myEditor.GetNodeSearcher();
+ theNodeSearcher = SMESH_MeshAlgos::GetNodeSearcher( *getMeshDS() );
}
gp_Pnt p( x,y,z );
if ( const SMDS_MeshNode* node = theNodeSearcher->FindClosestTo( p ))
if ( !node ) // preview moving node
{
if ( !theNodeSearcher ) {
- theNodeSearcher = myEditor.GetNodeSearcher();
+ theNodeSearcher = SMESH_MeshAlgos::GetNodeSearcher( *getMeshDS() );
}
gp_Pnt p( x,y,z );
node = theNodeSearcher->FindClosestTo( p );
theSearchersDeleter.Set( myMesh );
if ( !theElementSearcher ) {
- theElementSearcher = myEditor.GetElementSearcher();
+ theElementSearcher = SMESH_MeshAlgos::GetElementSearcher( *getMeshDS() );
}
theElementSearcher->FindElementsByPoint( gp_Pnt( x,y,z ),
SMDSAbs_ElementType( type ),
typedef SMDS_SetIterator<const SMDS_MeshElement*, TIDSortedElemSet::const_iterator > TIter;
SMDS_ElemIteratorPtr elemsIt( new TIter( elements.begin(), elements.end() ));
- theElementSearcher = myEditor.GetElementSearcher(elemsIt);
+ theElementSearcher = SMESH_MeshAlgos::GetElementSearcher( *getMeshDS(), elemsIt );
}
vector< const SMDS_MeshElement* > foundElems;
SMESH_TRY;
theSearchersDeleter.Set( myMesh );
if ( !theElementSearcher ) {
- theElementSearcher = myEditor.GetElementSearcher();
+ theElementSearcher = SMESH_MeshAlgos::GetElementSearcher( *getMeshDS() );
}
return CORBA::Short( theElementSearcher->GetPointState( gp_Pnt( x,y,z )));
theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
if ( !theNodeSearcher )
- theNodeSearcher = aMeshEditor.GetNodeSearcher();
+ theNodeSearcher = SMESH_MeshAlgos::GetNodeSearcher( *getMeshDS() );
vector<double> nodesCoords;
for (int i = 0; i < theNodesCoords.length(); i++)