+//=======================================================================
+//function : MirrorMakeMesh
+//purpose :
+//=======================================================================
+
+SMESH::SMESH_Mesh_ptr
+SMESH_MeshEditor_i::MirrorMakeMesh(const SMESH::long_array& theIDsOfElements,
+ const SMESH::AxisStruct& theMirror,
+ SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
+ CORBA::Boolean theCopyGroups,
+ const char* theMeshName)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_Mesh_i* mesh_i;
+ SMESH::SMESH_Mesh_var mesh;
+ { // open new scope to dump "MakeMesh" command
+ // and then "GetGroups" using SMESH_Mesh::GetGroups()
+
+ TPythonDump pydump; // to prevent dump at mesh creation
+
+ mesh = makeMesh( theMeshName );
+ mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
+ if (mesh_i && theIDsOfElements.length() > 0 )
+ {
+ TIDSortedElemSet elements;
+ arrayToSet(theIDsOfElements, getMeshDS(), elements);
+ mirror(elements, theMirror, theMirrorType,
+ false, theCopyGroups, & mesh_i->GetImpl());
+ mesh_i->CreateGroupServants();
+ }
+
+ if (!myIsPreviewMode) {
+ pydump << mesh << " = " << this << ".MirrorMakeMesh( "
+ << theIDsOfElements << ", "
+ << theMirror << ", "
+ << mirrorTypeName(theMirrorType) << ", "
+ << theCopyGroups << ", '"
+ << theMeshName << "' )";
+ }
+ }
+
+ //dump "GetGroups"
+ if (!myIsPreviewMode && mesh_i)
+ mesh_i->GetGroups();
+
+ return mesh._retn();
+}
+
+//=======================================================================
+//function : MirrorObjectMakeMesh
+//purpose :
+//=======================================================================
+
+SMESH::SMESH_Mesh_ptr
+SMESH_MeshEditor_i::MirrorObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::AxisStruct& theMirror,
+ SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
+ CORBA::Boolean theCopyGroups,
+ const char* theMeshName)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_Mesh_i* mesh_i;
+ SMESH::SMESH_Mesh_var mesh;
+ { // open new scope to dump "MakeMesh" command
+ // and then "GetGroups" using SMESH_Mesh::GetGroups()
+
+ TPythonDump pydump; // to prevent dump at mesh creation
+
+ mesh = makeMesh( theMeshName );
+ mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
+ TIDSortedElemSet elements;
+ prepareIdSource( theObject );
+ if ( mesh_i &&
+ idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
+ {
+ mirror(elements, theMirror, theMirrorType,
+ false, theCopyGroups, & mesh_i->GetImpl());
+ mesh_i->CreateGroupServants();
+ }
+ if (!myIsPreviewMode) {
+ pydump << mesh << " = " << this << ".MirrorObjectMakeMesh( "
+ << theObject << ", "
+ << theMirror << ", "
+ << mirrorTypeName(theMirrorType) << ", "
+ << theCopyGroups << ", '"
+ << theMeshName << "' )";
+ }
+ }
+
+ //dump "GetGroups"
+ if (!myIsPreviewMode && mesh_i)
+ mesh_i->GetGroups();
+
+ return mesh._retn();
+}
+
+//=======================================================================
+//function : translate
+//purpose :
+//=======================================================================
+
+SMESH::ListOfGroups*
+SMESH_MeshEditor_i::translate(TIDSortedElemSet & theElements,
+ const SMESH::DirStruct & theVector,
+ CORBA::Boolean theCopy,
+ bool theMakeGroups,
+ ::SMESH_Mesh* theTargetMesh)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ initData();
+
+ if ( theTargetMesh )
+ theCopy = false;
+
+ gp_Trsf aTrsf;
+ const SMESH::PointStruct * P = &theVector.PS;
+ aTrsf.SetTranslation( gp_Vec( P->x, P->y, P->z ));
+
+ TIDSortedElemSet copyElements;
+ TIDSortedElemSet* workElements = &theElements;
+
+ if ( myIsPreviewMode )
+ {
+ TPreviewMesh * tmpMesh = getPreviewMesh();
+ tmpMesh->Copy( theElements, copyElements);
+ if ( !theCopy && !theTargetMesh )
+ {
+ TIDSortedElemSet elemsAround, elemsAroundCopy;
+ getElementsAround( theElements, getMeshDS(), elemsAround );
+ tmpMesh->Copy( elemsAround, elemsAroundCopy);
+ }
+ workElements = & copyElements;
+ theMakeGroups = false;
+ }
+
+ ::SMESH_MeshEditor::PGroupIDs groupIds =
+ getEditor().Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
+
+ if ( theCopy && !myIsPreviewMode )
+ {
+ if ( theTargetMesh )
+ {
+ theTargetMesh->GetMeshDS()->Modified();
+ }
+ else
+ {
+ declareMeshModified( /*isReComputeSafe=*/false );
+ }
+ }
+
+ return theMakeGroups ? getGroups(groupIds.get()) : 0;
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+ return 0;
+}
+
+//=======================================================================
+//function : Translate
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements,
+ const SMESH::DirStruct & theVector,
+ CORBA::Boolean theCopy)
+ throw (SALOME::SALOME_Exception)
+{
+ if (!myIsPreviewMode) {
+ TPythonDump() << this << ".Translate( "
+ << theIDsOfElements << ", "
+ << theVector << ", "
+ << theCopy << " )";
+ }
+ if (theIDsOfElements.length()) {
+ TIDSortedElemSet elements;
+ arrayToSet(theIDsOfElements, getMeshDS(), elements);
+ translate(elements, theVector, theCopy, false);
+ }
+}
+
+//=======================================================================
+//function : TranslateObject
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::DirStruct & theVector,
+ CORBA::Boolean theCopy)
+ throw (SALOME::SALOME_Exception)
+{
+ if (!myIsPreviewMode) {
+ TPythonDump() << this << ".TranslateObject( "
+ << theObject << ", "
+ << theVector << ", "
+ << theCopy << " )";
+ }
+ TIDSortedElemSet elements;
+
+ bool emptyIfIsMesh = myIsPreviewMode ? false : true;
+
+ prepareIdSource( theObject );
+ if (idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
+ translate(elements, theVector, theCopy, false);
+}
+
+//=======================================================================
+//function : TranslateMakeGroups
+//purpose :
+//=======================================================================
+
+SMESH::ListOfGroups*
+SMESH_MeshEditor_i::TranslateMakeGroups(const SMESH::long_array& theIDsOfElements,
+ const SMESH::DirStruct& theVector)
+ throw (SALOME::SALOME_Exception)
+{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
+ SMESH::ListOfGroups * aGroups = 0;
+ if (theIDsOfElements.length()) {
+ TIDSortedElemSet elements;
+ arrayToSet(theIDsOfElements, getMeshDS(), elements);
+ aGroups = translate(elements,theVector,true,true);
+ }
+ if (!myIsPreviewMode) {
+ dumpGroupsList(aPythonDump, aGroups);
+ aPythonDump << this << ".TranslateMakeGroups( "
+ << theIDsOfElements << ", "
+ << theVector << " )";
+ }
+ return aGroups;
+}
+
+//=======================================================================
+//function : TranslateObjectMakeGroups
+//purpose :
+//=======================================================================
+
+SMESH::ListOfGroups*
+SMESH_MeshEditor_i::TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::DirStruct& theVector)
+ throw (SALOME::SALOME_Exception)
+{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
+ SMESH::ListOfGroups * aGroups = 0;
+ TIDSortedElemSet elements;
+ prepareIdSource( theObject );
+ if (idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
+ aGroups = translate(elements, theVector, true, true);
+
+ if (!myIsPreviewMode) {
+ dumpGroupsList(aPythonDump, aGroups);
+ aPythonDump << this << ".TranslateObjectMakeGroups( "
+ << theObject << ", "
+ << theVector << " )";
+ }
+ return aGroups;
+}
+
+//=======================================================================
+//function : TranslateMakeMesh
+//purpose :
+//=======================================================================
+
+SMESH::SMESH_Mesh_ptr
+SMESH_MeshEditor_i::TranslateMakeMesh(const SMESH::long_array& theIDsOfElements,
+ const SMESH::DirStruct& theVector,
+ CORBA::Boolean theCopyGroups,
+ const char* theMeshName)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_Mesh_i* mesh_i;
+ SMESH::SMESH_Mesh_var mesh;
+
+ { // open new scope to dump "MakeMesh" command
+ // and then "GetGroups" using SMESH_Mesh::GetGroups()
+
+ TPythonDump pydump; // to prevent dump at mesh creation
+
+ mesh = makeMesh( theMeshName );
+ mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
+
+ if ( mesh_i && theIDsOfElements.length() )
+ {
+ TIDSortedElemSet elements;
+ arrayToSet(theIDsOfElements, getMeshDS(), elements);
+ translate(elements, theVector, false, theCopyGroups, & mesh_i->GetImpl());
+ mesh_i->CreateGroupServants();
+ }
+
+ if ( !myIsPreviewMode ) {
+ pydump << mesh << " = " << this << ".TranslateMakeMesh( "
+ << theIDsOfElements << ", "
+ << theVector << ", "
+ << theCopyGroups << ", '"
+ << theMeshName << "' )";
+ }
+ }
+
+ //dump "GetGroups"
+ if (!myIsPreviewMode && mesh_i)
+ mesh_i->GetGroups();
+
+ return mesh._retn();
+}
+
+//=======================================================================
+//function : TranslateObjectMakeMesh
+//purpose :
+//=======================================================================
+
+SMESH::SMESH_Mesh_ptr
+SMESH_MeshEditor_i::TranslateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::DirStruct& theVector,
+ CORBA::Boolean theCopyGroups,
+ const char* theMeshName)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ SMESH_Mesh_i* mesh_i;
+ SMESH::SMESH_Mesh_var mesh;
+ { // open new scope to dump "MakeMesh" command
+ // and then "GetGroups" using SMESH_Mesh::GetGroups()
+
+ TPythonDump pydump; // to prevent dump at mesh creation
+ mesh = makeMesh( theMeshName );
+ mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
+
+ TIDSortedElemSet elements;
+ prepareIdSource( theObject );
+ if ( mesh_i &&
+ idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
+ {
+ translate(elements, theVector,false, theCopyGroups, & mesh_i->GetImpl());
+ mesh_i->CreateGroupServants();
+ }
+ if ( !myIsPreviewMode ) {
+ pydump << mesh << " = " << this << ".TranslateObjectMakeMesh( "
+ << theObject << ", "
+ << theVector << ", "
+ << theCopyGroups << ", '"
+ << theMeshName << "' )";
+ }
+ }
+
+ // dump "GetGroups"
+ if (!myIsPreviewMode && mesh_i)
+ mesh_i->GetGroups();
+
+ return mesh._retn();
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+ return 0;
+}
+
+//=======================================================================
+//function : rotate
+//purpose :
+//=======================================================================
+
+SMESH::ListOfGroups*
+SMESH_MeshEditor_i::rotate(TIDSortedElemSet & theElements,
+ const SMESH::AxisStruct & theAxis,
+ CORBA::Double theAngle,
+ CORBA::Boolean theCopy,
+ bool theMakeGroups,
+ ::SMESH_Mesh* theTargetMesh)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ initData();
+
+ if ( theTargetMesh )
+ theCopy = false;
+
+ gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
+ gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
+
+ gp_Trsf aTrsf;
+ aTrsf.SetRotation( gp_Ax1( P, V ), theAngle);
+
+ TIDSortedElemSet copyElements;
+ TIDSortedElemSet* workElements = &theElements;
+ if ( myIsPreviewMode ) {
+ TPreviewMesh * tmpMesh = getPreviewMesh();
+ tmpMesh->Copy( theElements, copyElements );
+ if ( !theCopy && !theTargetMesh )
+ {
+ TIDSortedElemSet elemsAround, elemsAroundCopy;
+ getElementsAround( theElements, getMeshDS(), elemsAround );
+ tmpMesh->Copy( elemsAround, elemsAroundCopy);
+ }
+ workElements = ©Elements;
+ theMakeGroups = false;
+ }
+
+ ::SMESH_MeshEditor::PGroupIDs groupIds =
+ getEditor().Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
+
+ if ( theCopy && !myIsPreviewMode)
+ {
+ if ( theTargetMesh ) theTargetMesh->GetMeshDS()->Modified();
+ else declareMeshModified( /*isReComputeSafe=*/false );
+ }
+
+ return theMakeGroups ? getGroups(groupIds.get()) : 0;
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+ return 0;
+}
+
+//=======================================================================
+//function : Rotate
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements,
+ const SMESH::AxisStruct & theAxis,
+ CORBA::Double theAngle,
+ CORBA::Boolean theCopy)
+ throw (SALOME::SALOME_Exception)
+{
+ if (!myIsPreviewMode) {
+ TPythonDump() << this << ".Rotate( "
+ << theIDsOfElements << ", "
+ << theAxis << ", "
+ << TVar( theAngle ) << ", "
+ << theCopy << " )";
+ }
+ if (theIDsOfElements.length() > 0)
+ {
+ TIDSortedElemSet elements;
+ arrayToSet(theIDsOfElements, getMeshDS(), elements);
+ rotate(elements,theAxis,theAngle,theCopy,false);
+ }
+}
+
+//=======================================================================
+//function : RotateObject
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::AxisStruct & theAxis,
+ CORBA::Double theAngle,
+ CORBA::Boolean theCopy)
+ throw (SALOME::SALOME_Exception)
+{
+ if ( !myIsPreviewMode ) {
+ TPythonDump() << this << ".RotateObject( "
+ << theObject << ", "
+ << theAxis << ", "
+ << TVar( theAngle ) << ", "
+ << theCopy << " )";
+ }
+ TIDSortedElemSet elements;
+ bool emptyIfIsMesh = myIsPreviewMode ? false : true;
+ prepareIdSource( theObject );
+ if (idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
+ rotate(elements,theAxis,theAngle,theCopy,false);
+}
+
+//=======================================================================
+//function : RotateMakeGroups
+//purpose :
+//=======================================================================
+
+SMESH::ListOfGroups*
+SMESH_MeshEditor_i::RotateMakeGroups(const SMESH::long_array& theIDsOfElements,
+ const SMESH::AxisStruct& theAxis,
+ CORBA::Double theAngle)
+ throw (SALOME::SALOME_Exception)
+{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
+ SMESH::ListOfGroups * aGroups = 0;
+ if (theIDsOfElements.length() > 0)
+ {
+ TIDSortedElemSet elements;
+ arrayToSet(theIDsOfElements, getMeshDS(), elements);
+ aGroups = rotate(elements,theAxis,theAngle,true,true);
+ }
+ if (!myIsPreviewMode) {
+ dumpGroupsList(aPythonDump, aGroups);
+ aPythonDump << this << ".RotateMakeGroups( "
+ << theIDsOfElements << ", "
+ << theAxis << ", "
+ << TVar( theAngle ) << " )";
+ }
+ return aGroups;
+}
+
+//=======================================================================
+//function : RotateObjectMakeGroups
+//purpose :
+//=======================================================================
+
+SMESH::ListOfGroups*
+SMESH_MeshEditor_i::RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::AxisStruct& theAxis,
+ CORBA::Double theAngle)
+ throw (SALOME::SALOME_Exception)
+{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
+ SMESH::ListOfGroups * aGroups = 0;
+ TIDSortedElemSet elements;
+ prepareIdSource( theObject );
+ if (idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
+ aGroups = rotate(elements, theAxis, theAngle, true, true);
+
+ if (!myIsPreviewMode) {
+ dumpGroupsList(aPythonDump, aGroups);
+ aPythonDump << this << ".RotateObjectMakeGroups( "
+ << theObject << ", "
+ << theAxis << ", "
+ << TVar( theAngle ) << " )";
+ }
+ return aGroups;
+}
+
+//=======================================================================
+//function : RotateMakeMesh
+//purpose :
+//=======================================================================
+
+SMESH::SMESH_Mesh_ptr
+SMESH_MeshEditor_i::RotateMakeMesh(const SMESH::long_array& theIDsOfElements,
+ const SMESH::AxisStruct& theAxis,
+ CORBA::Double theAngleInRadians,
+ CORBA::Boolean theCopyGroups,
+ const char* theMeshName)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ SMESH::SMESH_Mesh_var mesh;
+ SMESH_Mesh_i* mesh_i;
+
+ { // open new scope to dump "MakeMesh" command
+ // and then "GetGroups" using SMESH_Mesh::GetGroups()
+
+ TPythonDump pydump; // to prevent dump at mesh creation
+
+ mesh = makeMesh( theMeshName );
+ mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
+
+ if ( mesh_i && theIDsOfElements.length() > 0 )
+ {
+ TIDSortedElemSet elements;
+ arrayToSet(theIDsOfElements, getMeshDS(), elements);
+ rotate(elements, theAxis, theAngleInRadians,
+ false, theCopyGroups, & mesh_i->GetImpl());
+ mesh_i->CreateGroupServants();
+ }
+ if ( !myIsPreviewMode ) {
+ pydump << mesh << " = " << this << ".RotateMakeMesh( "
+ << theIDsOfElements << ", "
+ << theAxis << ", "
+ << TVar( theAngleInRadians ) << ", "
+ << theCopyGroups << ", '"
+ << theMeshName << "' )";
+ }
+ }
+
+ // dump "GetGroups"
+ if (!myIsPreviewMode && mesh_i && theIDsOfElements.length() > 0 )
+ mesh_i->GetGroups();
+
+ return mesh._retn();
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+ return 0;
+}
+
+//=======================================================================
+//function : RotateObjectMakeMesh
+//purpose :
+//=======================================================================
+
+SMESH::SMESH_Mesh_ptr
+SMESH_MeshEditor_i::RotateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::AxisStruct& theAxis,
+ CORBA::Double theAngleInRadians,
+ CORBA::Boolean theCopyGroups,
+ const char* theMeshName)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ SMESH::SMESH_Mesh_var mesh;
+ SMESH_Mesh_i* mesh_i;
+
+ {// open new scope to dump "MakeMesh" command
+ // and then "GetGroups" using SMESH_Mesh::GetGroups()
+
+ TPythonDump pydump; // to prevent dump at mesh creation
+ mesh = makeMesh( theMeshName );
+ mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
+
+ TIDSortedElemSet elements;
+ prepareIdSource( theObject );
+ if (mesh_i &&
+ idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
+ {
+ rotate(elements, theAxis, theAngleInRadians,
+ false, theCopyGroups, & mesh_i->GetImpl());
+ mesh_i->CreateGroupServants();
+ }
+ if ( !myIsPreviewMode ) {
+ pydump << mesh << " = " << this << ".RotateObjectMakeMesh( "
+ << theObject << ", "
+ << theAxis << ", "
+ << TVar( theAngleInRadians ) << ", "
+ << theCopyGroups << ", '"
+ << theMeshName << "' )";
+ }
+ }
+
+ // dump "GetGroups"
+ if (!myIsPreviewMode && mesh_i)
+ mesh_i->GetGroups();
+
+ return mesh._retn();
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+ return 0;
+}
+
+//=======================================================================
+//function : scale
+//purpose :
+//=======================================================================
+
+SMESH::ListOfGroups*
+SMESH_MeshEditor_i::scale(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::PointStruct& thePoint,
+ const SMESH::double_array& theScaleFact,
+ CORBA::Boolean theCopy,
+ bool theMakeGroups,
+ ::SMESH_Mesh* theTargetMesh)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ initData();
+ if ( theScaleFact.length() < 1 )
+ THROW_SALOME_CORBA_EXCEPTION("Scale factor not given", SALOME::BAD_PARAM);
+ if ( theScaleFact.length() == 2 )
+ THROW_SALOME_CORBA_EXCEPTION("Invalid nb of scale factors : 2", SALOME::BAD_PARAM);
+
+ if ( theTargetMesh )
+ theCopy = false;
+
+ TIDSortedElemSet elements;
+ prepareIdSource( theObject );
+ bool emptyIfIsMesh = myIsPreviewMode ? false : true;
+ if ( !idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
+ return 0;
+
+ double S[3] = {
+ theScaleFact[0],
+ (theScaleFact.length() == 1) ? theScaleFact[0] : theScaleFact[1],
+ (theScaleFact.length() == 1) ? theScaleFact[0] : theScaleFact[2],
+ };
+ double tol = std::numeric_limits<double>::max();
+ gp_Trsf aTrsf;
+ aTrsf.SetValues( S[0], 0, 0, thePoint.x * (1-S[0]),
+ 0, S[1], 0, thePoint.y * (1-S[1]),
+ 0, 0, S[2], thePoint.z * (1-S[2]), tol, tol);
+
+ TIDSortedElemSet copyElements;
+ TIDSortedElemSet* workElements = &elements;
+ if ( myIsPreviewMode )
+ {
+ TPreviewMesh * tmpMesh = getPreviewMesh();
+ tmpMesh->Copy( elements, copyElements);
+ if ( !theCopy && !theTargetMesh )
+ {
+ TIDSortedElemSet elemsAround, elemsAroundCopy;
+ getElementsAround( elements, getMeshDS(), elemsAround );
+ tmpMesh->Copy( elemsAround, elemsAroundCopy);
+ }
+ workElements = & copyElements;
+ theMakeGroups = false;
+ }
+
+ ::SMESH_MeshEditor::PGroupIDs groupIds =
+ getEditor().Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
+
+ if ( theCopy && !myIsPreviewMode )
+ {
+ if ( theTargetMesh ) theTargetMesh->GetMeshDS()->Modified();
+ else declareMeshModified( /*isReComputeSafe=*/false );
+ }
+ return theMakeGroups ? getGroups(groupIds.get()) : 0;
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+ return 0;
+}
+
+//=======================================================================
+//function : Scale
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::Scale(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::PointStruct& thePoint,
+ const SMESH::double_array& theScaleFact,
+ CORBA::Boolean theCopy)
+ throw (SALOME::SALOME_Exception)
+{
+ if ( !myIsPreviewMode ) {
+ TPythonDump() << this << ".Scale( "
+ << theObject << ", "
+ << thePoint << ", "
+ << TVar( theScaleFact ) << ", "
+ << theCopy << " )";
+ }
+ scale(theObject, thePoint, theScaleFact, theCopy, false);
+}
+
+
+//=======================================================================
+//function : ScaleMakeGroups
+//purpose :
+//=======================================================================
+
+SMESH::ListOfGroups*
+SMESH_MeshEditor_i::ScaleMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::PointStruct& thePoint,
+ const SMESH::double_array& theScaleFact)
+ throw (SALOME::SALOME_Exception)
+{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
+ SMESH::ListOfGroups * aGroups = scale(theObject, thePoint, theScaleFact, true, true);
+ if (!myIsPreviewMode) {
+ dumpGroupsList(aPythonDump, aGroups);
+ aPythonDump << this << ".Scale("
+ << theObject << ","
+ << thePoint << ","
+ << TVar( theScaleFact ) << ",True,True)";
+ }
+ return aGroups;
+}
+
+
+//=======================================================================
+//function : ScaleMakeMesh
+//purpose :
+//=======================================================================
+
+SMESH::SMESH_Mesh_ptr
+SMESH_MeshEditor_i::ScaleMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::PointStruct& thePoint,
+ const SMESH::double_array& theScaleFact,
+ CORBA::Boolean theCopyGroups,
+ const char* theMeshName)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_Mesh_i* mesh_i;
+ SMESH::SMESH_Mesh_var mesh;
+ { // open new scope to dump "MakeMesh" command
+ // and then "GetGroups" using SMESH_Mesh::GetGroups()
+
+ TPythonDump pydump; // to prevent dump at mesh creation
+ mesh = makeMesh( theMeshName );
+ mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
+
+ if ( mesh_i )
+ {
+ scale(theObject, thePoint, theScaleFact,false, theCopyGroups, & mesh_i->GetImpl());
+ mesh_i->CreateGroupServants();
+ }
+ if ( !myIsPreviewMode )
+ pydump << mesh << " = " << this << ".ScaleMakeMesh( "
+ << theObject << ", "
+ << thePoint << ", "
+ << TVar( theScaleFact ) << ", "
+ << theCopyGroups << ", '"
+ << theMeshName << "' )";
+ }
+
+ // dump "GetGroups"
+ if (!myIsPreviewMode && mesh_i)
+ mesh_i->GetGroups();
+
+ return mesh._retn();
+}
+
+
+//=======================================================================
+//function : FindCoincidentNodes
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::FindCoincidentNodes (CORBA::Double Tolerance,
+ SMESH::array_of_long_array_out GroupsOfNodes)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ initData();
+
+ ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
+ TIDSortedNodeSet nodes; // no input nodes
+ getEditor().FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
+
+ GroupsOfNodes = new SMESH::array_of_long_array;
+ GroupsOfNodes->length( aListOfListOfNodes.size() );
+ ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
+ for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ ) {
+ list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
+ list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
+ SMESH::long_array& aGroup = (*GroupsOfNodes)[ i ];
+ aGroup.length( aListOfNodes.size() );
+ for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
+ aGroup[ j ] = (*lIt)->GetID();
+ }
+ TPythonDump() << "coincident_nodes = " << this << ".FindCoincidentNodes( "
+ << Tolerance << " )";
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+}
+
+//=======================================================================
+//function : FindCoincidentNodesOnPart
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr theObject,
+ CORBA::Double Tolerance,
+ SMESH::array_of_long_array_out GroupsOfNodes)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ initData();
+
+ TIDSortedNodeSet nodes;
+ prepareIdSource( theObject );
+ idSourceToNodeSet( theObject, getMeshDS(), nodes );
+
+ ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
+ if(!nodes.empty())
+ getEditor().FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
+
+ GroupsOfNodes = new SMESH::array_of_long_array;
+ GroupsOfNodes->length( aListOfListOfNodes.size() );
+ ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
+ for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ )
+ {
+ list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
+ list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
+ SMESH::long_array& aGroup = (*GroupsOfNodes)[ i ];
+ aGroup.length( aListOfNodes.size() );
+ for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
+ aGroup[ j ] = (*lIt)->GetID();
+ }
+ TPythonDump() << "coincident_nodes_on_part = " << this << ".FindCoincidentNodesOnPart( "
+ <<theObject<<", "
+ << Tolerance << " )";
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+}
+
+//================================================================================
+/*!
+ * \brief Finds nodes coinsident with Tolerance within Object excluding nodes within
+ * ExceptSubMeshOrGroups
+ */
+//================================================================================
+
+void SMESH_MeshEditor_i::
+FindCoincidentNodesOnPartBut(SMESH::SMESH_IDSource_ptr theObject,
+ CORBA::Double theTolerance,
+ SMESH::array_of_long_array_out theGroupsOfNodes,
+ const SMESH::ListOfIDSources& theExceptSubMeshOrGroups)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ initData();
+
+ TIDSortedNodeSet nodes;
+ prepareIdSource( theObject );
+ idSourceToNodeSet( theObject, getMeshDS(), nodes );
+
+ for ( int i = 0; i < theExceptSubMeshOrGroups.length(); ++i )
+ {
+ TIDSortedNodeSet exceptNodes;
+ idSourceToNodeSet( theExceptSubMeshOrGroups[i], getMeshDS(), exceptNodes );
+ TIDSortedNodeSet::iterator avoidNode = exceptNodes.begin();
+ for ( ; avoidNode != exceptNodes.end(); ++avoidNode)
+ nodes.erase( *avoidNode );
+ }
+ ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
+ if(!nodes.empty())
+ getEditor().FindCoincidentNodes( nodes, theTolerance, aListOfListOfNodes );
+
+ theGroupsOfNodes = new SMESH::array_of_long_array;
+ theGroupsOfNodes->length( aListOfListOfNodes.size() );
+ ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
+ for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ )
+ {
+ list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
+ list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
+ SMESH::long_array& aGroup = (*theGroupsOfNodes)[ i ];
+ aGroup.length( aListOfNodes.size() );
+ for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
+ aGroup[ j ] = (*lIt)->GetID();
+ }
+ TPythonDump() << "coincident_nodes_on_part = " << this << ".FindCoincidentNodesOnPartBut( "
+ << theObject<<", "
+ << theTolerance << ", "
+ << theExceptSubMeshOrGroups << " )";
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+}
+
+//=======================================================================
+//function : MergeNodes
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ initData();
+
+ SMESHDS_Mesh* aMesh = getMeshDS();
+
+ TPythonDump aTPythonDump;
+ aTPythonDump << this << ".MergeNodes([";
+ ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
+ for (int i = 0; i < GroupsOfNodes.length(); i++)
+ {
+ const SMESH::long_array& aNodeGroup = GroupsOfNodes[ i ];
+ aListOfListOfNodes.push_back( list< const SMDS_MeshNode* >() );
+ list< const SMDS_MeshNode* >& aListOfNodes = aListOfListOfNodes.back();
+ for ( int j = 0; j < aNodeGroup.length(); j++ )
+ {
+ CORBA::Long index = aNodeGroup[ j ];
+ const SMDS_MeshNode * node = aMesh->FindNode(index);
+ if ( node )
+ aListOfNodes.push_back( node );
+ }
+ if ( aListOfNodes.size() < 2 )
+ aListOfListOfNodes.pop_back();
+
+ if ( i > 0 ) aTPythonDump << ", ";
+ aTPythonDump << aNodeGroup;
+ }
+ getEditor().MergeNodes( aListOfListOfNodes );
+
+ aTPythonDump << "])";
+
+ declareMeshModified( /*isReComputeSafe=*/false );
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+}
+
+//=======================================================================
+//function : FindEqualElements
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::FindEqualElements(SMESH::SMESH_IDSource_ptr theObject,
+ SMESH::array_of_long_array_out GroupsOfElementsID)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ initData();
+
+ SMESH::SMESH_GroupBase_var group = SMESH::SMESH_GroupBase::_narrow(theObject);
+ if ( !(!group->_is_nil() && group->GetType() == SMESH::NODE) )
+ {
+ TIDSortedElemSet elems;
+ prepareIdSource( theObject );
+ idSourceToSet( theObject, getMeshDS(), elems, SMDSAbs_All, /*emptyIfIsMesh=*/true);
+
+ ::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
+ getEditor().FindEqualElements( elems, aListOfListOfElementsID );
+
+ GroupsOfElementsID = new SMESH::array_of_long_array;
+ GroupsOfElementsID->length( aListOfListOfElementsID.size() );
+
+ ::SMESH_MeshEditor::TListOfListOfElementsID::iterator arraysIt =
+ aListOfListOfElementsID.begin();
+ for (CORBA::Long j = 0; arraysIt != aListOfListOfElementsID.end(); ++arraysIt, ++j)
+ {
+ SMESH::long_array& aGroup = (*GroupsOfElementsID)[ j ];
+ list<int>& listOfIDs = *arraysIt;
+ aGroup.length( listOfIDs.size() );
+ list<int>::iterator idIt = listOfIDs.begin();
+ for (int k = 0; idIt != listOfIDs.end(); ++idIt, ++k )
+ aGroup[ k ] = *idIt;
+ }
+
+ TPythonDump() << "equal_elements = " << this << ".FindEqualElements( "
+ <<theObject<<" )";
+ }
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+}
+
+//=======================================================================
+//function : MergeElements
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::MergeElements(const SMESH::array_of_long_array& GroupsOfElementsID)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ initData();
+
+ TPythonDump aTPythonDump;
+ aTPythonDump << this << ".MergeElements( [";
+
+ ::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
+
+ for (int i = 0; i < GroupsOfElementsID.length(); i++) {
+ const SMESH::long_array& anElemsIDGroup = GroupsOfElementsID[ i ];
+ aListOfListOfElementsID.push_back( list< int >() );
+ list< int >& aListOfElemsID = aListOfListOfElementsID.back();
+ for ( int j = 0; j < anElemsIDGroup.length(); j++ ) {
+ CORBA::Long id = anElemsIDGroup[ j ];
+ aListOfElemsID.push_back( id );
+ }
+ if ( aListOfElemsID.size() < 2 )
+ aListOfListOfElementsID.pop_back();
+ if ( i > 0 ) aTPythonDump << ", ";
+ aTPythonDump << anElemsIDGroup;
+ }
+
+ getEditor().MergeElements(aListOfListOfElementsID);
+
+ declareMeshModified( /*isReComputeSafe=*/true );
+
+ aTPythonDump << "] )";
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+}
+
+//=======================================================================
+//function : MergeEqualElements
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::MergeEqualElements()
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ initData();
+
+ getEditor().MergeEqualElements();
+
+ declareMeshModified( /*isReComputeSafe=*/true );
+
+ TPythonDump() << this << ".MergeEqualElements()";
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+}
+
+//=============================================================================
+/*!
+ * Move the node to a given point
+ */
+//=============================================================================
+
+CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long NodeID,
+ CORBA::Double x,
+ CORBA::Double y,
+ CORBA::Double z)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ initData(/*deleteSearchers=*/false);
+
+ const SMDS_MeshNode * node = getMeshDS()->FindNode( NodeID );
+ if ( !node )
+ return false;
+
+ if ( theNodeSearcher )
+ theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
+
+ if ( myIsPreviewMode ) // make preview data
+ {
+ // in a preview mesh, make edges linked to a node
+ TPreviewMesh& tmpMesh = *getPreviewMesh();
+ TIDSortedElemSet linkedNodes;
+ ::SMESH_MeshEditor::GetLinkedNodes( node, linkedNodes );
+ TIDSortedElemSet::iterator nIt = linkedNodes.begin();
+ SMDS_MeshNode *nodeCpy1 = tmpMesh.Copy(node);
+ for ( ; nIt != linkedNodes.end(); ++nIt )
+ {
+ SMDS_MeshNode *nodeCpy2 = tmpMesh.Copy ( cast2Node( *nIt ));
+ tmpMesh.GetMeshDS()->AddEdge(nodeCpy1, nodeCpy2);
+ }
+ // move copied node
+ if ( nodeCpy1 )
+ tmpMesh.GetMeshDS()->MoveNode(nodeCpy1, x, y, z);
+ // fill preview data
+ }
+ else if ( theNodeSearcher ) // move node and update theNodeSearcher data accordingly
+ theNodeSearcher->MoveNode(node, gp_Pnt( x,y,z ));
+ else
+ getMeshDS()->MoveNode(node, x, y, z);
+
+ if ( !myIsPreviewMode )
+ {
+ // Update Python script
+ TPythonDump() << "isDone = " << this << ".MoveNode( "
+ << NodeID << ", " << TVar(x) << ", " << TVar(y) << ", " << TVar(z) << " )";
+ declareMeshModified( /*isReComputeSafe=*/false );
+ }
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+
+ return true;
+}
+
+//================================================================================
+/*!
+ * \brief Return ID of node closest to a given point
+ */
+//================================================================================
+
+CORBA::Long SMESH_MeshEditor_i::FindNodeClosestTo(CORBA::Double x,
+ CORBA::Double y,
+ CORBA::Double z)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
+
+ if ( !theNodeSearcher ) {
+ theNodeSearcher = SMESH_MeshAlgos::GetNodeSearcher( *getMeshDS() );
+ }
+ gp_Pnt p( x,y,z );
+ if ( const SMDS_MeshNode* node = theNodeSearcher->FindClosestTo( p ))
+ return node->GetID();
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+ return 0;
+}
+
+//================================================================================
+/*!
+ * \brief If the given ID is a valid node ID (nodeID > 0), just move this node, else
+ * move the node closest to the point to point's location and return ID of the node
+ */
+//================================================================================
+
+CORBA::Long SMESH_MeshEditor_i::MoveClosestNodeToPoint(CORBA::Double x,
+ CORBA::Double y,
+ CORBA::Double z,
+ CORBA::Long theNodeID)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ // We keep theNodeSearcher until any mesh modification:
+ // 1) initData() deletes theNodeSearcher at any edition,
+ // 2) TSearchersDeleter - at any mesh compute event and mesh change
+
+ initData(/*deleteSearchers=*/false);
+
+ theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
+
+ int nodeID = theNodeID;
+ const SMDS_MeshNode* node = getMeshDS()->FindNode( nodeID );
+ if ( !node ) // preview moving node
+ {
+ if ( !theNodeSearcher ) {
+ theNodeSearcher = SMESH_MeshAlgos::GetNodeSearcher( *getMeshDS() );
+ }
+ gp_Pnt p( x,y,z );
+ node = theNodeSearcher->FindClosestTo( p );
+ }
+ if ( node ) {
+ nodeID = node->GetID();
+ if ( myIsPreviewMode ) // make preview data
+ {
+ // in a preview mesh, make edges linked to a node
+ TPreviewMesh tmpMesh = *getPreviewMesh();
+ TIDSortedElemSet linkedNodes;
+ ::SMESH_MeshEditor::GetLinkedNodes( node, linkedNodes );
+ TIDSortedElemSet::iterator nIt = linkedNodes.begin();
+ for ( ; nIt != linkedNodes.end(); ++nIt )
+ {
+ SMDS_LinearEdge edge( node, cast2Node( *nIt ));
+ tmpMesh.Copy( &edge );
+ }
+ // move copied node
+ node = tmpMesh.GetMeshDS()->FindNode( nodeID );
+ if ( node )
+ tmpMesh.GetMeshDS()->MoveNode(node, x, y, z);
+ // fill preview data
+ }
+ else if ( theNodeSearcher ) // move node and update theNodeSearcher data accordingly
+ {
+ theNodeSearcher->MoveNode(node, gp_Pnt( x,y,z ));
+ }
+ else
+ {
+ getMeshDS()->MoveNode(node, x, y, z);
+ }
+ }
+
+ if ( !myIsPreviewMode )
+ {
+ TPythonDump() << "nodeID = " << this
+ << ".MoveClosestNodeToPoint( "<< x << ", " << y << ", " << z
+ << ", " << nodeID << " )";
+
+ declareMeshModified( /*isReComputeSafe=*/false );
+ }
+
+ return nodeID;
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+ return 0;
+}
+
+//=======================================================================
+/*!
+ * Return elements of given type where the given point is IN or ON.
+ *
+ * 'ALL' type means elements of any type excluding nodes
+ */
+//=======================================================================
+
+SMESH::long_array* SMESH_MeshEditor_i::FindElementsByPoint(CORBA::Double x,
+ CORBA::Double y,
+ CORBA::Double z,
+ SMESH::ElementType type)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ SMESH::long_array_var res = new SMESH::long_array;
+ vector< const SMDS_MeshElement* > foundElems;
+
+ theSearchersDeleter.Set( myMesh );
+ if ( !theElementSearcher ) {
+ theElementSearcher = SMESH_MeshAlgos::GetElementSearcher( *getMeshDS() );
+ }
+ theElementSearcher->FindElementsByPoint( gp_Pnt( x,y,z ),
+ SMDSAbs_ElementType( type ),
+ foundElems);
+ res->length( foundElems.size() );
+ for ( int i = 0; i < foundElems.size(); ++i )
+ res[i] = foundElems[i]->GetID();
+
+ if ( !myIsPreviewMode ) // call from tui
+ TPythonDump() << "res = " << this << ".FindElementsByPoint( "
+ << x << ", "
+ << y << ", "
+ << z << ", "
+ << type << " )";
+
+ return res._retn();
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+ return 0;
+}
+
+//=======================================================================
+//function : FindAmongElementsByPoint
+//purpose : Searching among the given elements, return elements of given type
+// where the given point is IN or ON.
+// 'ALL' type means elements of any type excluding nodes
+//=======================================================================
+
+SMESH::long_array*
+SMESH_MeshEditor_i::FindAmongElementsByPoint(SMESH::SMESH_IDSource_ptr elementIDs,
+ CORBA::Double x,
+ CORBA::Double y,
+ CORBA::Double z,
+ SMESH::ElementType type)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ SMESH::long_array_var res = new SMESH::long_array;
+
+ SMESH::array_of_ElementType_var types = elementIDs->GetTypes();
+ if ( types->length() == 1 && // a part contains only nodes or 0D elements
+ ( types[0] == SMESH::NODE || types[0] == SMESH::ELEM0D || types[0] == SMESH::BALL) &&
+ type != types[0] ) // but search of elements of dim > 0
+ return res._retn();
+
+ if ( SMESH::DownCast<SMESH_Mesh_i*>( elementIDs )) // elementIDs is the whole mesh
+ return FindElementsByPoint( x,y,z, type );
+
+ TIDSortedElemSet elements; // elems should live until FindElementsByPoint() finishes
+
+ theSearchersDeleter.Set( myMesh, getPartIOR( elementIDs, type ));
+ if ( !theElementSearcher )
+ {
+ // create a searcher from elementIDs
+ SMESH::SMESH_Mesh_var mesh = elementIDs->GetMesh();
+ SMESHDS_Mesh* meshDS = SMESH::DownCast<SMESH_Mesh_i*>( mesh )->GetImpl().GetMeshDS();
+
+ if ( !idSourceToSet( elementIDs, meshDS, elements,
+ SMDSAbs_ElementType(type), /*emptyIfIsMesh=*/true))
+ return res._retn();
+
+ typedef SMDS_SetIterator<const SMDS_MeshElement*, TIDSortedElemSet::const_iterator > TIter;
+ SMDS_ElemIteratorPtr elemsIt( new TIter( elements.begin(), elements.end() ));
+
+ theElementSearcher = SMESH_MeshAlgos::GetElementSearcher( *getMeshDS(), elemsIt );
+ }
+
+ vector< const SMDS_MeshElement* > foundElems;
+
+ theElementSearcher->FindElementsByPoint( gp_Pnt( x,y,z ),
+ SMDSAbs_ElementType( type ),
+ foundElems);
+ res->length( foundElems.size() );
+ for ( int i = 0; i < foundElems.size(); ++i )
+ res[i] = foundElems[i]->GetID();
+
+ if ( !myIsPreviewMode ) // call from tui
+ TPythonDump() << "res = " << this << ".FindAmongElementsByPoint( "
+ << elementIDs << ", "
+ << x << ", "
+ << y << ", "
+ << z << ", "
+ << type << " )";
+
+ return res._retn();
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+ return 0;
+}
+
+//=======================================================================
+//function : GetPointState
+//purpose : Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
+// TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
+//=======================================================================
+
+CORBA::Short SMESH_MeshEditor_i::GetPointState(CORBA::Double x,
+ CORBA::Double y,
+ CORBA::Double z)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ theSearchersDeleter.Set( myMesh );
+ if ( !theElementSearcher ) {
+ theElementSearcher = SMESH_MeshAlgos::GetElementSearcher( *getMeshDS() );
+ }
+ return CORBA::Short( theElementSearcher->GetPointState( gp_Pnt( x,y,z )));
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+ return 0;
+}
+
+//=======================================================================
+//function : convError
+//purpose :
+//=======================================================================
+
+#define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
+
+static SMESH::SMESH_MeshEditor::Sew_Error convError( const::SMESH_MeshEditor::Sew_Error e )
+{
+ switch ( e ) {
+ RETCASE( SEW_OK );
+ RETCASE( SEW_BORDER1_NOT_FOUND );
+ RETCASE( SEW_BORDER2_NOT_FOUND );
+ RETCASE( SEW_BOTH_BORDERS_NOT_FOUND );
+ RETCASE( SEW_BAD_SIDE_NODES );
+ RETCASE( SEW_VOLUMES_TO_SPLIT );
+ RETCASE( SEW_DIFF_NB_OF_ELEMENTS );
+ RETCASE( SEW_TOPO_DIFF_SETS_OF_ELEMENTS );
+ RETCASE( SEW_BAD_SIDE1_NODES );
+ RETCASE( SEW_BAD_SIDE2_NODES );
+ }
+ return SMESH::SMESH_MeshEditor::SEW_OK;
+}
+
+//=======================================================================
+//function : SewFreeBorders
+//purpose :
+//=======================================================================
+
+SMESH::SMESH_MeshEditor::Sew_Error
+SMESH_MeshEditor_i::SewFreeBorders(CORBA::Long FirstNodeID1,
+ CORBA::Long SecondNodeID1,
+ CORBA::Long LastNodeID1,
+ CORBA::Long FirstNodeID2,
+ CORBA::Long SecondNodeID2,
+ CORBA::Long LastNodeID2,
+ CORBA::Boolean CreatePolygons,
+ CORBA::Boolean CreatePolyedrs)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ initData();
+
+ SMESHDS_Mesh* aMesh = getMeshDS();
+
+ const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
+ const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
+ const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
+ const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
+ const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
+ const SMDS_MeshNode* aSide2ThirdNode = aMesh->FindNode( LastNodeID2 );
+
+ if (!aBorderFirstNode ||
+ !aBorderSecondNode||
+ !aBorderLastNode)
+ return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
+ if (!aSide2FirstNode ||
+ !aSide2SecondNode ||
+ !aSide2ThirdNode)
+ return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
+
+ TPythonDump() << "error = " << this << ".SewFreeBorders( "
+ << FirstNodeID1 << ", "
+ << SecondNodeID1 << ", "
+ << LastNodeID1 << ", "
+ << FirstNodeID2 << ", "
+ << SecondNodeID2 << ", "
+ << LastNodeID2 << ", "
+ << CreatePolygons<< ", "
+ << CreatePolyedrs<< " )";
+
+ SMESH::SMESH_MeshEditor::Sew_Error error =
+ convError( getEditor().SewFreeBorder (aBorderFirstNode,
+ aBorderSecondNode,
+ aBorderLastNode,
+ aSide2FirstNode,
+ aSide2SecondNode,
+ aSide2ThirdNode,
+ true,
+ CreatePolygons,
+ CreatePolyedrs) );
+
+
+ declareMeshModified( /*isReComputeSafe=*/false );
+ return error;
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+ return SMESH::SMESH_MeshEditor::Sew_Error(0);
+}
+
+
+//=======================================================================
+//function : SewConformFreeBorders
+//purpose :
+//=======================================================================
+
+SMESH::SMESH_MeshEditor::Sew_Error
+SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1,
+ CORBA::Long SecondNodeID1,
+ CORBA::Long LastNodeID1,
+ CORBA::Long FirstNodeID2,
+ CORBA::Long SecondNodeID2)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ initData();
+
+ SMESHDS_Mesh* aMesh = getMeshDS();
+
+ const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
+ const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
+ const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
+ const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
+ const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
+ const SMDS_MeshNode* aSide2ThirdNode = 0;
+
+ if (!aBorderFirstNode ||
+ !aBorderSecondNode||
+ !aBorderLastNode )
+ return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
+ if (!aSide2FirstNode ||
+ !aSide2SecondNode)