X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_MeshEditor_i.cxx;h=42d0b3c2fae1d8f2ff8d9c8be9d383be25cdaac0;hb=7446d65dcb323bdf4ccd6b19522276925dcd2807;hp=824a1314160da6c790599fc71a4b55b930a85ceb;hpb=a2db5e7c304efdf1b3c82bcfcad8ce98b385be9e;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index 824a13141..42d0b3c2f 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -1,25 +1,24 @@ -// Copyright (C) 2007-2010 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 +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses // File : SMESH_MeshEditor_i.cxx // Author : Nicolas REJNERI // Module : SMESH @@ -30,18 +29,20 @@ #include "SMESH_MeshEditor_i.hxx" -#include "SMDS_Mesh0DElement.hxx" #include "SMDS_LinearEdge.hxx" +#include "SMDS_Mesh0DElement.hxx" #include "SMDS_MeshFace.hxx" #include "SMDS_MeshVolume.hxx" #include "SMDS_PolyhedralVolumeOfNodes.hxx" -#include "SMESH_subMeshEventListener.hxx" -#include "SMESH_Gen_i.hxx" +#include "SMDS_SetIterator.hxx" +#include "SMESHDS_Group.hxx" +#include "SMESH_ControlsDef.hxx" #include "SMESH_Filter_i.hxx" -#include "SMESH_subMesh_i.hxx" +#include "SMESH_Gen_i.hxx" #include "SMESH_Group_i.hxx" #include "SMESH_PythonDump.hxx" -#include "SMESH_ControlsDef.hxx" +#include "SMESH_subMeshEventListener.hxx" +#include "SMESH_subMesh_i.hxx" #include "utilities.h" #include "Utils_ExceptHandlers.hxx" @@ -74,6 +75,7 @@ using namespace std; using SMESH::TPythonDump; +using SMESH::TVar; namespace { @@ -93,7 +95,7 @@ namespace { myPreviewType = previewElements; } //!< Destructor - virtual ~TPreviewMesh() { delete _myMeshDS; } + virtual ~TPreviewMesh() { delete _myMeshDS; _myMeshDS = 0; } //!< Copy a set of elements void Copy(const TIDSortedElemSet & theElements, TIDSortedElemSet& theCopyElements, @@ -110,8 +112,12 @@ namespace { if ( type == theAvoidType || ( theSelectType != SMDSAbs_All && type != theSelectType )) continue; - - if ( const SMDS_MeshElement* anElemCopy = Copy( anElem )) + const SMDS_MeshElement* anElemCopy; + if ( type == SMDSAbs_Node) + anElemCopy = Copy( cast2Node(anElem) ); + else + anElemCopy = Copy( anElem ); + if ( anElemCopy ) theCopyElements.insert( theCopyElements.end(), anElemCopy ); } } @@ -166,8 +172,10 @@ namespace { struct TSearchersDeleter : public SMESH_subMeshEventListener { SMESH_Mesh* myMesh; + string myMeshPartIOR; //!< Constructor - TSearchersDeleter(): SMESH_subMeshEventListener( false ), // won't be deleted by submesh + TSearchersDeleter(): SMESH_subMeshEventListener( false, // won't be deleted by submesh + "SMESH_MeshEditor_i::TSearchersDeleter"), myMesh(0) {} //!< Delete theNodeSearcher static void Delete() @@ -186,15 +194,16 @@ namespace { } } //!< set self on all submeshes and delete theNodeSearcher if other mesh is set - void Set(SMESH_Mesh* mesh) + void Set(SMESH_Mesh* mesh, const string& meshPartIOR = string()) { - if ( myMesh != mesh ) + if ( myMesh != mesh || myMeshPartIOR != meshPartIOR) { if ( myMesh ) { Delete(); Unset( myMesh ); } myMesh = mesh; + myMeshPartIOR = meshPartIOR; if ( SMESH_subMesh* myMainSubMesh = mesh->GetSubMeshContaining(1) ) { const TDependsOnMap & subMeshes = myMainSubMesh->DependsOn(); TDependsOnMap::const_iterator sm; @@ -287,6 +296,7 @@ namespace { else { arrayToSet( anIDs, theMeshDS, theElemSet, theType); + return bool(anIDs->length()) == bool(theElemSet.size()); } return true; } @@ -311,7 +321,15 @@ namespace { if ( const SMDS_MeshNode * n = theMeshDS->FindNode( aElementsId[i] )) theNodeSet.insert( theNodeSet.end(), n); } - else { + else if ( SMESH::DownCast( theObject )) + { + SMDS_NodeIteratorPtr nIt = theMeshDS->nodesIterator(); + while ( nIt->more( )) + if( const SMDS_MeshElement * elem = nIt->next() ) + theNodeSet.insert( elem->begin_nodes(), elem->end_nodes()); + } + else + { for(int i = 0; i < aElementsId->length(); i++) if( const SMDS_MeshElement * elem = theMeshDS->FindElement( aElementsId[i] )) theNodeSet.insert( elem->begin_nodes(), elem->end_nodes()); @@ -361,6 +379,24 @@ namespace { } } } + + //================================================================================ + /*! + * \brief Return a string used to detect change of mesh part on which theElementSearcher + * is going to be used + */ + //================================================================================ + + string getPartIOR( SMESH::SMESH_IDSource_ptr theMeshPart, SMESH::ElementType type) + { + string partIOR = SMESH_Gen_i::GetORB()->object_to_string( theMeshPart ); + if ( SMESH_Group_i* group_i = SMESH::DownCast( theMeshPart )) + // take into account passible group modification + partIOR += SMESH_Comment( ((SMESHDS_Group*)group_i->GetGroupDS())->SMDSGroup().Tic() ); + partIOR += SMESH_Comment( type ); + return partIOR; + } + } //============================================================================= @@ -369,11 +405,12 @@ namespace { */ //============================================================================= -SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESH_Mesh_i* theMesh, bool isPreview) +SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESH_Mesh_i* theMesh, bool isPreview): + myMesh_i( theMesh ), + myMesh( &theMesh->GetImpl() ), + myEditor( myMesh ), + myPreviewMode ( isPreview ) { - myMesh_i = theMesh; - myMesh = & theMesh->GetImpl(); - myPreviewMode = isPreview; } //================================================================================ @@ -395,16 +432,139 @@ SMESH_MeshEditor_i::~SMESH_MeshEditor_i() void SMESH_MeshEditor_i::initData(bool deleteSearchers) { if ( myPreviewMode ) { - myPreviewData = new SMESH::MeshPreviewStruct(); + //myPreviewData = new SMESH::MeshPreviewStruct(); } else { - myLastCreatedElems = new SMESH::long_array(); - myLastCreatedNodes = new SMESH::long_array(); if ( deleteSearchers ) TSearchersDeleter::Delete(); } } +//================================================================================ +/*! + * \brief Now does nothing + */ +//================================================================================ + +void SMESH_MeshEditor_i::storeResult(::SMESH_MeshEditor& ) +{ +} + +//================================================================================ +/*! + * Return data of mesh edition preview + */ +//================================================================================ + +SMESH::MeshPreviewStruct* SMESH_MeshEditor_i::GetPreviewData() +{ + if ( myPreviewMode ) { // --- MeshPreviewStruct filling --- + + list aNodesConnectivity; + typedef map TNodesMap; + TNodesMap nodesMap; + + SMESHDS_Mesh* aMeshDS = myEditor.GetMeshDS(); + int nbEdges = aMeshDS->NbEdges(); + int nbFaces = aMeshDS->NbFaces(); + int nbVolum = aMeshDS->NbVolumes(); + myPreviewData = new SMESH::MeshPreviewStruct(); + myPreviewData->nodesXYZ.length(aMeshDS->NbNodes()); + + TPreviewMesh * aPreviewMesh = dynamic_cast< TPreviewMesh* >( myEditor.GetMesh() ); + SMDSAbs_ElementType previewType = SMDSAbs_All; + if (aPreviewMesh) { + previewType = aPreviewMesh->myPreviewType; + switch ( previewType ) { + case SMDSAbs_Edge : nbFaces = nbVolum = 0; break; + case SMDSAbs_Face : nbEdges = nbVolum = 0; break; + case SMDSAbs_Volume: nbEdges = nbFaces = 0; break; + default:; + } + } + + myPreviewData->elementTypes.length(nbEdges + nbFaces + nbVolum); + int i = 0, j = 0; + SMDS_ElemIteratorPtr itMeshElems = aMeshDS->elementsIterator(); + + while ( itMeshElems->more() ) { + const SMDS_MeshElement* aMeshElem = itMeshElems->next(); + if ( previewType != SMDSAbs_All && aMeshElem->GetType() != previewType ) + continue; + + SMDS_ElemIteratorPtr itElemNodes = aMeshElem->nodesIterator(); + while ( itElemNodes->more() ) { + const SMDS_MeshNode* aMeshNode = + static_cast( itElemNodes->next() ); + int aNodeID = aMeshNode->GetID(); + TNodesMap::iterator anIter = nodesMap.find(aNodeID); + if ( anIter == nodesMap.end() ) { + // filling the nodes coordinates + myPreviewData->nodesXYZ[j].x = aMeshNode->X(); + myPreviewData->nodesXYZ[j].y = aMeshNode->Y(); + myPreviewData->nodesXYZ[j].z = aMeshNode->Z(); + anIter = nodesMap.insert( make_pair(aNodeID, j) ).first; + j++; + } + aNodesConnectivity.push_back(anIter->second); + } + + // filling the elements types + SMDSAbs_ElementType aType = aMeshElem->GetType(); + bool isPoly = aMeshElem->IsPoly(); + + myPreviewData->elementTypes[i].SMDS_ElementType = (SMESH::ElementType) aType; + myPreviewData->elementTypes[i].isPoly = isPoly; + myPreviewData->elementTypes[i].nbNodesInElement = aMeshElem->NbNodes(); + i++; + + } + myPreviewData->nodesXYZ.length( j ); + + // filling the elements connectivities + list::iterator aConnIter = aNodesConnectivity.begin(); + myPreviewData->elementConnectivities.length(aNodesConnectivity.size()); + for( int i = 0; aConnIter != aNodesConnectivity.end(); aConnIter++, i++ ) + myPreviewData->elementConnectivities[i] = *aConnIter; + } + + return myPreviewData._retn(); +} + +//================================================================================ +/*! + * \brief Returns list of it's IDs of created nodes + * \retval SMESH::long_array* - list of node ID + */ +//================================================================================ + +SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedNodes() +{ + SMESH::long_array_var myLastCreatedNodes = new SMESH::long_array(); + const SMESH_SequenceOfElemPtr& aSeq = myEditor.GetLastCreatedNodes(); + myLastCreatedNodes->length( aSeq.Length() ); + for (int i = 1; i <= aSeq.Length(); i++) + myLastCreatedNodes[i-1] = aSeq.Value(i)->GetID(); + return myLastCreatedNodes._retn(); +} + +//================================================================================ +/*! + * \brief Returns list of it's IDs of created elements + * \retval SMESH::long_array* - list of elements' ID + */ +//================================================================================ + +SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedElems() +{ + SMESH::long_array_var myLastCreatedElems = new SMESH::long_array(); + const SMESH_SequenceOfElemPtr& aSeq = myEditor.GetLastCreatedElems(); + myLastCreatedElems->length( aSeq.Length() ); + for ( int i = 1; i <= aSeq.Length(); i++ ) + myLastCreatedElems[i-1] = aSeq.Value(i)->GetID(); + return myLastCreatedElems._retn(); +} + //======================================================================= //function : MakeIDSource //purpose : Wrap a sequence of ids in a SMESH_IDSource @@ -418,11 +578,14 @@ struct _IDSource : public POA_SMESH::SMESH_IDSource SMESH::long_array* GetIDs() { return new SMESH::long_array( _ids ); } SMESH::long_array* GetMeshInfo() { return 0; } SMESH::SMESH_Mesh_ptr GetMesh() { return SMESH::SMESH_Mesh::_duplicate( _mesh ); } + bool IsMeshInfoCorrect() { return true; } SMESH::array_of_ElementType* GetTypes() { SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType; - types->length( 1 ); - types[0] = _type; + if ( _ids.length() > 0 ) { + types->length( 1 ); + types[0] = _type; + } return types._retn(); } }; @@ -450,7 +613,6 @@ SMESH_MeshEditor_i::RemoveElements(const SMESH::long_array & IDsOfElements) { initData(); - ::SMESH_MeshEditor anEditor( myMesh ); list< int > IdList; for (int i = 0; i < IDsOfElements.length(); i++) @@ -460,7 +622,7 @@ SMESH_MeshEditor_i::RemoveElements(const SMESH::long_array & IDsOfElements) TPythonDump() << "isDone = " << this << ".RemoveElements( " << IDsOfElements << " )"; // Remove Elements - bool ret = anEditor.Remove( IdList, false ); + bool ret = myEditor.Remove( IdList, false ); myMesh->GetMeshDS()->Modified(); if ( IDsOfElements.length() ) myMesh->SetIsModified( true ); // issue 0020693 @@ -477,7 +639,6 @@ CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::long_array & IDsOfNo { initData(); - ::SMESH_MeshEditor anEditor( myMesh ); list< int > IdList; for (int i = 0; i < IDsOfNodes.length(); i++) IdList.push_back( IDsOfNodes[i] ); @@ -485,7 +646,7 @@ CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::long_array & IDsOfNo // Update Python script TPythonDump() << "isDone = " << this << ".RemoveNodes( " << IDsOfNodes << " )"; - bool ret = anEditor.Remove( IdList, true ); + bool ret = myEditor.Remove( IdList, true ); myMesh->GetMeshDS()->Modified(); if ( IDsOfNodes.length() ) myMesh->SetIsModified( true ); // issue 0020693 @@ -502,7 +663,6 @@ CORBA::Long SMESH_MeshEditor_i::RemoveOrphanNodes() { initData(); - ::SMESH_MeshEditor anEditor( myMesh ); // Update Python script TPythonDump() << "nbRemoved = " << this << ".RemoveOrphanNodes()"; @@ -517,17 +677,19 @@ CORBA::Long SMESH_MeshEditor_i::RemoveOrphanNodes() for ( int i = 0; i < seq.size(); i++ ) IdList.push_back( seq[i] ); - bool ret = anEditor.Remove( IdList, true ); + int nbNodesBefore = myMesh->NbNodes(); + myEditor.Remove( IdList, true ); myMesh->GetMeshDS()->Modified(); if ( IdList.size() ) myMesh->SetIsModified( true ); + int nbNodesAfter = myMesh->NbNodes(); - return ret; + return nbNodesBefore - nbNodesAfter; } //============================================================================= /*! - * + * Add a new node. */ //============================================================================= @@ -540,7 +702,7 @@ CORBA::Long SMESH_MeshEditor_i::AddNode(CORBA::Double x, // Update Python script TPythonDump() << "nodeID = " << this << ".AddNode( " - << x << ", " << y << ", " << z << " )"; + << TVar( x ) << ", " << TVar( y ) << ", " << TVar( z )<< " )"; myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); // issue 0020693 @@ -549,9 +711,10 @@ CORBA::Long SMESH_MeshEditor_i::AddNode(CORBA::Double x, //============================================================================= /*! - * + * Create 0D element on the given node. */ //============================================================================= + CORBA::Long SMESH_MeshEditor_i::Add0DElement(CORBA::Long IDOfNode) { initData(); @@ -573,7 +736,38 @@ CORBA::Long SMESH_MeshEditor_i::Add0DElement(CORBA::Long IDOfNode) //============================================================================= /*! - * + * Create a ball element on the given node. + */ +//============================================================================= + +CORBA::Long SMESH_MeshEditor_i::AddBall(CORBA::Long IDOfNode, CORBA::Double diameter) + throw (SALOME::SALOME_Exception) +{ + initData(); + + if ( diameter < std::numeric_limits::min() ) + THROW_SALOME_CORBA_EXCEPTION("Invalid diameter", SALOME::BAD_PARAM); + + const SMDS_MeshNode* aNode = GetMeshDS()->FindNode(IDOfNode); + SMDS_MeshElement* elem = GetMeshDS()->AddBall(aNode, diameter); + + // Update Python script + TPythonDump() << "ballElem = " + << this << ".AddBall( " << IDOfNode << ", " << diameter <<" )"; + + myMesh->GetMeshDS()->Modified(); + myMesh->SetIsModified( true ); // issue 0020693 + + if (elem) + return elem->GetID(); + + return 0; +} + +//============================================================================= +/*! + * Create an edge, either linear and quadratic (this is determed + * by number of given nodes, two or three) */ //============================================================================= @@ -647,6 +841,10 @@ CORBA::Long SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes) 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); } @@ -686,7 +884,8 @@ CORBA::Long SMESH_MeshEditor_i::AddPolygonalFace (const SMESH::long_array & IDsO //============================================================================= /*! - * + * Create volume, either linear and quadratic (this is determed + * by number of given nodes) */ //============================================================================= @@ -709,6 +908,9 @@ CORBA::Long SMESH_MeshEditor_i::AddVolume(const SMESH::long_array & IDsOfNodes) case 10:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5], n[6],n[7],n[8],n[9]); break; + case 12:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5], + n[6],n[7],n[8],n[9],n[10],n[11]); + break; case 13:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6], n[7],n[8],n[9],n[10],n[11],n[12]); break; @@ -719,6 +921,11 @@ CORBA::Long SMESH_MeshEditor_i::AddVolume(const SMESH::long_array & IDsOfNodes) n[8],n[9],n[10],n[11],n[12],n[13],n[14], n[15],n[16],n[17],n[18],n[19]); break; + case 27:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7], + n[8],n[9],n[10],n[11],n[12],n[13],n[14], + n[15],n[16],n[17],n[18],n[19], + n[20],n[21],n[22],n[23],n[24],n[25],n[26]); + break; } // Update Python script @@ -1005,8 +1212,7 @@ CORBA::Boolean SMESH_MeshEditor_i::InverseDiag(CORBA::Long NodeID1, << NodeID1 << ", " << NodeID2 << " )"; - ::SMESH_MeshEditor aMeshEditor( myMesh ); - int ret = aMeshEditor.InverseDiag ( n1, n2 ); + int ret = myEditor.InverseDiag ( n1, n2 ); myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); return ret; @@ -1032,15 +1238,14 @@ CORBA::Boolean SMESH_MeshEditor_i::DeleteDiag(CORBA::Long NodeID1, TPythonDump() << "isDone = " << this << ".DeleteDiag( " << NodeID1 << ", " << NodeID2 << " )"; - ::SMESH_MeshEditor aMeshEditor( myMesh ); - bool stat = aMeshEditor.DeleteDiag ( n1, n2 ); + bool stat = myEditor.DeleteDiag ( n1, n2 ); myMesh->GetMeshDS()->Modified(); if ( stat ) myMesh->SetIsModified( true ); // issue 0020693 - storeResult(aMeshEditor); + storeResult(myEditor); return stat; } @@ -1055,13 +1260,12 @@ CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::long_array & IDsOfEleme { initData(); - ::SMESH_MeshEditor anEditor( myMesh ); for (int i = 0; i < IDsOfElements.length(); i++) { CORBA::Long index = IDsOfElements[i]; const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index); if ( elem ) - anEditor.Reorient( elem ); + myEditor.Reorient( elem ); } // Update Python script TPythonDump() << "isDone = " << this << ".Reorient( " << IDsOfElements << " )"; @@ -1095,6 +1299,93 @@ CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theO return isDone; } +//======================================================================= +//function : Reorient2D +//purpose : Reorient faces contained in \a the2Dgroup. +// the2Dgroup - the mesh or its part to reorient +// theDirection - desired direction of normal of \a theFace +// theFace - ID of face whose orientation is checked. +// It can be < 1 then \a thePoint is used to find a face. +// thePoint - is used to find a face if \a theFace < 1. +// return number of reoriented elements. +//======================================================================= + +CORBA::Long SMESH_MeshEditor_i::Reorient2D(SMESH::SMESH_IDSource_ptr the2Dgroup, + const SMESH::DirStruct& theDirection, + CORBA::Long theFace, + const SMESH::PointStruct& thePoint) + throw (SALOME::SALOME_Exception) +{ + Unexpect aCatch(SALOME_SalomeException); + + initData(/*deleteSearchers=*/false); + + TIDSortedElemSet elements; + if ( !idSourceToSet( the2Dgroup, GetMeshDS(), elements, SMDSAbs_Face, /*emptyIfIsMesh=*/1)) + THROW_SALOME_CORBA_EXCEPTION("No faces in given group", SALOME::BAD_PARAM); + + + const SMDS_MeshElement* face = 0; + if ( theFace > 0 ) + { + face = GetMeshDS()->FindElement( theFace ); + if ( !face ) + THROW_SALOME_CORBA_EXCEPTION("Inexistent face given", SALOME::BAD_PARAM); + if ( face->GetType() != SMDSAbs_Face ) + THROW_SALOME_CORBA_EXCEPTION("Wrong element type", SALOME::BAD_PARAM); + } + else + { + // create theElementSearcher if needed + theSearchersDeleter.Set( myMesh, getPartIOR( the2Dgroup, SMESH::FACE )); + if ( !theElementSearcher ) + { + if ( elements.empty() ) // search in the whole mesh + { + if ( myMesh->NbFaces() == 0 ) + THROW_SALOME_CORBA_EXCEPTION("No faces in the mesh", SALOME::BAD_PARAM); + + theElementSearcher = myEditor.GetElementSearcher(); + } + else + { + typedef SMDS_SetIterator TIter; + SMDS_ElemIteratorPtr elemsIt( new TIter( elements.begin(), elements.end() )); + + theElementSearcher = myEditor.GetElementSearcher(elemsIt); + } + } + // find a face + gp_Pnt p( thePoint.x, thePoint.y, thePoint.z ); + face = theElementSearcher->FindClosestTo( p, SMDSAbs_Face ); + + if ( !face ) + THROW_SALOME_CORBA_EXCEPTION("No face found by point", SALOME::INTERNAL_ERROR ); + if ( !elements.empty() && !elements.count( face )) + THROW_SALOME_CORBA_EXCEPTION("Found face is not in the group", SALOME::BAD_PARAM ); + } + + const SMESH::PointStruct * P = &theDirection.PS; + gp_Vec dirVec( P->x, P->y, P->z ); + if ( dirVec.Magnitude() < std::numeric_limits< double >::min() ) + THROW_SALOME_CORBA_EXCEPTION("Zero size vector", SALOME::BAD_PARAM); + + int nbReori = myEditor.Reorient2D( elements, dirVec, face ); + storeResult(myEditor); + + if ( nbReori ) { + myMesh->SetIsModified( true ); + myMesh->GetMeshDS()->Modified(); + } + TPythonDump() << this << ".Reorient2D( " + << the2Dgroup << ", " + << theDirection << ", " + << theFace << ", " + << thePoint << " )"; + + return nbReori; +} + //============================================================================= /*! * @@ -1120,16 +1411,15 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfE // Update Python script TPythonDump() << "isDone = " << this << ".TriToQuad( " - << IDsOfElements << ", " << aNumericalFunctor << ", " << MaxAngle << " )"; + << IDsOfElements << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )"; - ::SMESH_MeshEditor anEditor( myMesh ); - bool stat = anEditor.TriToQuad( faces, aCrit, MaxAngle ); + bool stat = myEditor.TriToQuad( faces, aCrit, MaxAngle ); myMesh->GetMeshDS()->Modified(); if ( stat ) myMesh->SetIsModified( true ); // issue 0020693 - storeResult(anEditor); + storeResult(myEditor); return stat; } @@ -1155,7 +1445,7 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr // Update Python script aTPythonDump << "isDone = " << this << ".TriToQuadObject(" - << theObject << ", " << aNumericalFunctor << ", " << MaxAngle << " )"; + << theObject << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )"; return isDone; } @@ -1187,13 +1477,12 @@ CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array & IDsOfE // Update Python script TPythonDump() << "isDone = " << this << ".QuadToTri( " << IDsOfElements << ", " << aNumericalFunctor << " )"; - ::SMESH_MeshEditor anEditor( myMesh ); - CORBA::Boolean stat = anEditor.QuadToTri( faces, aCrit ); + CORBA::Boolean stat = myEditor.QuadToTri( faces, aCrit ); myMesh->GetMeshDS()->Modified(); if ( stat ) myMesh->SetIsModified( true ); // issue 0020693 - storeResult(anEditor); + storeResult(myEditor); return stat; } @@ -1242,14 +1531,13 @@ CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfEle TPythonDump() << "isDone = " << this << ".SplitQuad( " << IDsOfElements << ", " << Diag13 << " )"; - ::SMESH_MeshEditor anEditor( myMesh ); - CORBA::Boolean stat = anEditor.QuadToTri( faces, Diag13 ); + CORBA::Boolean stat = myEditor.QuadToTri( faces, Diag13 ); myMesh->GetMeshDS()->Modified(); if ( stat ) myMesh->SetIsModified( true ); // issue 0020693 - storeResult(anEditor); + storeResult(myEditor); return stat; } @@ -1299,8 +1587,7 @@ CORBA::Long SMESH_MeshEditor_i::BestSplit (CORBA::Long IDOfQuad, else aCrit.reset(new SMESH::Controls::AspectRatio()); - ::SMESH_MeshEditor anEditor (myMesh); - return anEditor.BestSplit(quad, aCrit); + return myEditor.BestSplit(quad, aCrit); } return -1; } @@ -1323,11 +1610,10 @@ void SMESH_MeshEditor_i::SplitVolumesIntoTetra (SMESH::SMESH_IDSource_ptr elems, TIDSortedElemSet elemSet; arrayToSet( anElementsId, GetMeshDS(), elemSet, SMDSAbs_Volume ); - ::SMESH_MeshEditor anEditor (myMesh); - anEditor.SplitVolumesIntoTetra( elemSet, int( methodFlags )); + myEditor.SplitVolumesIntoTetra( elemSet, int( methodFlags )); myMesh->GetMeshDS()->Modified(); - storeResult(anEditor); + storeResult(myEditor); // if ( myLastCreatedElems.length() ) - it does not influence Compute() // myMesh->SetIsModified( true ); // issue 0020693 @@ -1436,20 +1722,19 @@ SMESH_MeshEditor_i::smooth(const SMESH::long_array & IDsOfElements, if ( Method != SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH ) method = ::SMESH_MeshEditor::CENTROIDAL; - ::SMESH_MeshEditor anEditor( myMesh ); - anEditor.Smooth(elements, fixedNodes, method, + myEditor.Smooth(elements, fixedNodes, method, MaxNbOfIterations, MaxAspectRatio, IsParametric ); myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); // issue 0020693 - storeResult(anEditor); + storeResult(myEditor); // Update Python script TPythonDump() << "isDone = " << this << "." << (IsParametric ? "SmoothParametric( " : "Smooth( ") << IDsOfElements << ", " << IDsOfFixedNodes << ", " - << MaxNbOfIterations << ", " << MaxAspectRatio << ", " + << TVar( MaxNbOfIterations ) << ", " << TVar( MaxAspectRatio ) << ", " << "SMESH.SMESH_MeshEditor." << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ? "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )"); @@ -1484,7 +1769,7 @@ SMESH_MeshEditor_i::smoothObject(SMESH::SMESH_IDSource_ptr theObjec aTPythonDump << "isDone = " << this << "." << (IsParametric ? "SmoothParametricObject( " : "SmoothObject( ") << theObject << ", " << IDsOfFixedNodes << ", " - << MaxNbOfIterations << ", " << MaxAspectRatio << ", " + << TVar( MaxNbOfIterations ) << ", " << TVar( MaxAspectRatio ) << ", " << "SMESH.SMESH_MeshEditor." << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ? "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )"); @@ -1575,11 +1860,10 @@ SMESH_MeshEditor_i::rotationSweep(const SMESH::long_array & theIDsOfElements, gp_Ax1 Ax1 (gp_Pnt( theAxis.x, theAxis.y, theAxis.z ), gp_Vec( theAxis.vx, theAxis.vy, theAxis.vz )); - ::SMESH_MeshEditor anEditor( mesh ); ::SMESH_MeshEditor::PGroupIDs groupIds = - anEditor.RotationSweep (*workElements, Ax1, theAngleInRadians, + myEditor.RotationSweep (*workElements, Ax1, theAngleInRadians, theNbOfSteps, theTolerance, theMakeGroups, makeWalls); - storeResult(anEditor); + storeResult(myEditor); myMesh->GetMeshDS()->Modified(); // myMesh->SetIsModified( true ); -- it does not influence Compute() @@ -1600,11 +1884,11 @@ void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElement { if ( !myPreviewMode ) { TPythonDump() << this << ".RotationSweep( " - << theIDsOfElements << ", " - << theAxis << ", " - << theAngleInRadians << ", " - << theNbOfSteps << ", " - << theTolerance << " )"; + << theIDsOfElements << ", " + << theAxis << ", " + << TVar( theAngleInRadians ) << ", " + << TVar( theNbOfSteps ) << ", " + << TVar( theTolerance ) << " )"; } rotationSweep(theIDsOfElements, theAxis, @@ -1637,11 +1921,11 @@ SMESH_MeshEditor_i::RotationSweepMakeGroups(const SMESH::long_array& theIDsOfEle if (!myPreviewMode) { DumpGroupsList(aPythonDump, aGroups); aPythonDump << this << ".RotationSweepMakeGroups( " - << theIDsOfElements << ", " - << theAxis << ", " - << theAngleInRadians << ", " - << theNbOfSteps << ", " - << theTolerance << " )"; + << theIDsOfElements << ", " + << theAxis << ", " + << TVar( theAngleInRadians ) << ", " + << TVar( theNbOfSteps ) << ", " + << TVar( theTolerance ) << " )"; } return aGroups; } @@ -1687,11 +1971,11 @@ void SMESH_MeshEditor_i::RotationSweepObject1D(SMESH::SMESH_IDSource_ptr theObje { if ( !myPreviewMode ) { TPythonDump() << this << ".RotationSweepObject1D( " - << theObject << ", " - << theAxis << ", " - << theAngleInRadians << ", " - << theNbOfSteps << ", " - << theTolerance << " )"; + << theObject << ", " + << theAxis << ", " + << TVar( theAngleInRadians ) << ", " + << TVar( theNbOfSteps ) << ", " + << TVar( theTolerance ) << " )"; } SMESH::long_array_var anElementsId = theObject->GetIDs(); rotationSweep(anElementsId, @@ -1716,11 +2000,11 @@ void SMESH_MeshEditor_i::RotationSweepObject2D(SMESH::SMESH_IDSource_ptr theObje { if ( !myPreviewMode ) { TPythonDump() << this << ".RotationSweepObject2D( " - << theObject << ", " - << theAxis << ", " - << theAngleInRadians << ", " - << theNbOfSteps << ", " - << theTolerance << " )"; + << theObject << ", " + << theAxis << ", " + << TVar( theAngleInRadians ) << ", " + << TVar( theNbOfSteps ) << ", " + << TVar( theTolerance ) << " )"; } SMESH::long_array_var anElementsId = theObject->GetIDs(); rotationSweep(anElementsId, @@ -1790,11 +2074,11 @@ SMESH_MeshEditor_i::RotationSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr th if (!myPreviewMode) { DumpGroupsList(aPythonDump, aGroups); aPythonDump << this << ".RotationSweepObject1DMakeGroups( " - << theObject << ", " - << theAxis << ", " - << theAngleInRadians << ", " - << theNbOfSteps << ", " - << theTolerance << " )"; + << theObject << ", " + << theAxis << ", " + << TVar( theAngleInRadians ) << ", " + << TVar( theNbOfSteps ) << ", " + << TVar( theTolerance ) << " )"; } return aGroups; } @@ -1824,11 +2108,11 @@ SMESH_MeshEditor_i::RotationSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr th if (!myPreviewMode) { DumpGroupsList(aPythonDump, aGroups); aPythonDump << this << ".RotationSweepObject2DMakeGroups( " - << theObject << ", " - << theAxis << ", " - << theAngleInRadians << ", " - << theNbOfSteps << ", " - << theTolerance << " )"; + << theObject << ", " + << theAxis << ", " + << TVar( theAngleInRadians ) << ", " + << TVar( theNbOfSteps ) << ", " + << TVar( theTolerance ) << " )"; } return aGroups; } @@ -1859,9 +2143,17 @@ SMESH_MeshEditor_i::extrusionSweep(const SMESH::long_array & theIDsOfElements, gp_Vec stepVec( P->x, P->y, P->z ); TIDSortedElemSet* workElements = & elements; - TPreviewMesh tmpMesh( SMDSAbs_Face ); - SMESH_Mesh* mesh = myMesh; - + + SMDSAbs_ElementType aType = SMDSAbs_Face; + //::SMESH_MeshEditor::ExtrusionFlags aFlag = ::SMESH_MeshEditor::ExtrusionFlags::EXTRUSION_FLAG_BOUNDARY; + if (theElementType == SMDSAbs_Node) + { + aType = SMDSAbs_Edge; + //aFlag = ::SMESH_MeshEditor::ExtrusionFlags::EXTRUSION_FLAG_SEW; + } + TPreviewMesh tmpMesh( aType ); + SMESH_Mesh* mesh = myMesh; + if ( myPreviewMode ) { SMDSAbs_ElementType select = SMDSAbs_All, avoid = SMDSAbs_Volume; tmpMesh.Copy( elements, copyElements, select, avoid ); @@ -1871,12 +2163,11 @@ SMESH_MeshEditor_i::extrusionSweep(const SMESH::long_array & theIDsOfElements, } TElemOfElemListMap aHystory; - ::SMESH_MeshEditor anEditor( mesh ); - ::SMESH_MeshEditor::PGroupIDs groupIds = - anEditor.ExtrusionSweep (*workElements, stepVec, theNbOfSteps, aHystory, theMakeGroups); + ::SMESH_MeshEditor::PGroupIDs groupIds = + myEditor.ExtrusionSweep (*workElements, stepVec, theNbOfSteps, aHystory, theMakeGroups); myMesh->GetMeshDS()->Modified(); - storeResult(anEditor); + storeResult(myEditor); return theMakeGroups ? getGroups(groupIds.get()) : 0; @@ -1899,10 +2190,25 @@ void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElemen extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false ); if (!myPreviewMode) { TPythonDump() << this << ".ExtrusionSweep( " - << theIDsOfElements << ", " << theStepVector <<", " << theNbOfSteps << " )"; + << theIDsOfElements << ", " << theStepVector <<", " << TVar(theNbOfSteps) << " )"; } } +//======================================================================= +//function : ExtrusionSweep0D +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::ExtrusionSweep0D(const SMESH::long_array & theIDsOfElements, + const SMESH::DirStruct & theStepVector, + CORBA::Long theNbOfSteps) +{ + extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false, SMDSAbs_Node ); + if (!myPreviewMode) { + TPythonDump() << this << ".ExtrusionSweep0D( " + << theIDsOfElements << ", " << theStepVector <<", " << TVar(theNbOfSteps)<< " )"; + } +} //======================================================================= //function : ExtrusionSweepObject @@ -1922,36 +2228,53 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObjec } //======================================================================= -//function : ExtrusionSweepObject1D +//function : ExtrusionSweepObject0D //purpose : //======================================================================= -void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObject, +void SMESH_MeshEditor_i::ExtrusionSweepObject0D(SMESH::SMESH_IDSource_ptr theObject, const SMESH::DirStruct & theStepVector, CORBA::Long theNbOfSteps) { SMESH::long_array_var anElementsId = theObject->GetIDs(); - extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Edge ); + extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Node ); if ( !myPreviewMode ) { - TPythonDump() << this << ".ExtrusionSweepObject1D( " - << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )"; + TPythonDump() << this << ".ExtrusionSweepObject0D( " + << theObject << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )"; } } //======================================================================= -//function : ExtrusionSweepObject2D +//function : ExtrusionSweepObject1D //purpose : //======================================================================= -void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject, +void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObject, const SMESH::DirStruct & theStepVector, CORBA::Long theNbOfSteps) { SMESH::long_array_var anElementsId = theObject->GetIDs(); - extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Face ); + extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Edge ); + if ( !myPreviewMode ) { + TPythonDump() << this << ".ExtrusionSweepObject1D( " + << theObject << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )"; + } +} + +//======================================================================= +//function : ExtrusionSweepObject2D +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::DirStruct & theStepVector, + CORBA::Long theNbOfSteps) +{ + SMESH::long_array_var anElementsId = theObject->GetIDs(); + extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Face ); if ( !myPreviewMode ) { TPythonDump() << this << ".ExtrusionSweepObject2D( " - << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )"; + << theObject << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )"; } } @@ -1972,7 +2295,29 @@ SMESH_MeshEditor_i::ExtrusionSweepMakeGroups(const SMESH::long_array& theIDsOfEl if (!myPreviewMode) { DumpGroupsList(aPythonDump, aGroups); aPythonDump << this << ".ExtrusionSweepMakeGroups( " << theIDsOfElements - << ", " << theStepVector <<", " << theNbOfSteps << " )"; + << ", " << theStepVector <<", " << TVar( theNbOfSteps ) << " )"; + } + return aGroups; +} + +//======================================================================= +//function : ExtrusionSweepMakeGroups0D +//purpose : +//======================================================================= + +SMESH::ListOfGroups* +SMESH_MeshEditor_i::ExtrusionSweepMakeGroups0D(const SMESH::long_array& theIDsOfElements, + const SMESH::DirStruct& theStepVector, + CORBA::Long theNbOfSteps) +{ + TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() + + SMESH::ListOfGroups* aGroups = extrusionSweep(theIDsOfElements, theStepVector, theNbOfSteps, true,SMDSAbs_Node); + + if (!myPreviewMode) { + DumpGroupsList(aPythonDump, aGroups); + aPythonDump << this << ".ExtrusionSweepMakeGroups0D( " << theIDsOfElements + << ", " << theStepVector <<", " << TVar( theNbOfSteps ) << " )"; } return aGroups; } @@ -2000,6 +2345,29 @@ SMESH_MeshEditor_i::ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr the return aGroups; } +//======================================================================= +//function : ExtrusionSweepObject0DMakeGroups +//purpose : +//======================================================================= + +SMESH::ListOfGroups* +SMESH_MeshEditor_i::ExtrusionSweepObject0DMakeGroups(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::DirStruct& theStepVector, + CORBA::Long theNbOfSteps) +{ + TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() + + SMESH::long_array_var anElementsId = theObject->GetIDs(); + SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector, + theNbOfSteps, true, SMDSAbs_Node); + if (!myPreviewMode) { + DumpGroupsList(aPythonDump, aGroups); + aPythonDump << this << ".ExtrusionSweepObject0DMakeGroups( " << theObject + << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )"; + } + return aGroups; +} + //======================================================================= //function : ExtrusionSweepObject1DMakeGroups //purpose : @@ -2018,7 +2386,7 @@ SMESH_MeshEditor_i::ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr t if (!myPreviewMode) { DumpGroupsList(aPythonDump, aGroups); aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( " << theObject - << ", " << theStepVector << ", " << theNbOfSteps << " )"; + << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )"; } return aGroups; } @@ -2041,7 +2409,7 @@ SMESH_MeshEditor_i::ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr t if (!myPreviewMode) { DumpGroupsList(aPythonDump, aGroups); aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( " << theObject - << ", " << theStepVector << ", " << theNbOfSteps << " )"; + << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )"; } return aGroups; } @@ -2068,12 +2436,11 @@ SMESH_MeshEditor_i::advancedExtrusion(const SMESH::long_array & theIDsOfElements const SMESH::PointStruct * P = &theStepVector.PS; gp_Vec stepVec( P->x, P->y, P->z ); - ::SMESH_MeshEditor anEditor( myMesh ); TElemOfElemListMap aHystory; ::SMESH_MeshEditor::PGroupIDs groupIds = - anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory, + myEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory, theMakeGroups, theExtrFlags, theSewTolerance); - storeResult(anEditor); + storeResult(myEditor); return theMakeGroups ? getGroups(groupIds.get()) : 0; } @@ -2217,13 +2584,12 @@ SMESH_MeshEditor_i::extrusionAlongPath(const SMESH::long_array & theIDsOfEleme int nbOldGroups = myMesh->NbGroup(); - ::SMESH_MeshEditor anEditor( myMesh ); ::SMESH_MeshEditor::Extrusion_Error error = - anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart, + myEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart, theHasAngles, angles, false, theHasRefPoint, refPnt, theMakeGroups ); myMesh->GetMeshDS()->Modified(); - storeResult(anEditor); + storeResult(myEditor); theError = convExtrError( error ); if ( theMakeGroups ) { @@ -2286,7 +2652,6 @@ SMESH_MeshEditor_i::extrusionAlongPathX(const SMESH::long_array & IDsOfElements MakeGroups = false; } - ::SMESH_MeshEditor anEditor( mesh ); ::SMESH_MeshEditor::Extrusion_Error error; if ( SMESH_Mesh_i* aMeshImp = SMESH::DownCast( Path )) @@ -2298,7 +2663,7 @@ SMESH_MeshEditor_i::extrusionAlongPathX(const SMESH::long_array & IDsOfElements Error = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE; return EmptyGr; } - error = anEditor.ExtrusionAlongTrack( *workElements, &(aMeshImp->GetImpl()), aNodeStart, + error = myEditor.ExtrusionAlongTrack( *workElements, &(aMeshImp->GetImpl()), aNodeStart, HasAngles, angles, LinearVariation, HasRefPoint, refPnt, MakeGroups ); myMesh->GetMeshDS()->Modified(); @@ -2316,7 +2681,7 @@ SMESH_MeshEditor_i::extrusionAlongPathX(const SMESH::long_array & IDsOfElements } SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMeshContaining(aSubMeshImp->GetId()); - error = anEditor.ExtrusionAlongTrack( *workElements, aSubMesh, aNodeStart, + error = myEditor.ExtrusionAlongTrack( *workElements, aSubMesh, aNodeStart, HasAngles, angles, LinearVariation, HasRefPoint, refPnt, MakeGroups ); myMesh->GetMeshDS()->Modified(); @@ -2333,7 +2698,7 @@ SMESH_MeshEditor_i::extrusionAlongPathX(const SMESH::long_array & IDsOfElements return EmptyGr; } - storeResult(anEditor); + storeResult(myEditor); Error = convExtrError( error ); if ( MakeGroups ) { @@ -2771,17 +3136,17 @@ ExtrusionAlongPathObjX(SMESH::SMESH_IDSource_ptr Object, aPythonDump << "error"; aPythonDump << " = " << this << ".ExtrusionAlongPathObjX( " - << Object << ", " - << Path << ", " - << NodeStart << ", " - << HasAngles << ", " - << Angles << ", " + << Object << ", " + << Path << ", " + << NodeStart << ", " + << HasAngles << ", " + << TVar( Angles ) << ", " << LinearVariation << ", " - << HasRefPoint << ", " + << HasRefPoint << ", " << "SMESH.PointStruct( " - << ( HasRefPoint ? RefPoint.x : 0 ) << ", " - << ( HasRefPoint ? RefPoint.y : 0 ) << ", " - << ( HasRefPoint ? RefPoint.z : 0 ) << " ), " + << TVar( HasRefPoint ? RefPoint.x : 0 ) << ", " + << TVar( HasRefPoint ? RefPoint.y : 0 ) << ", " + << TVar( HasRefPoint ? RefPoint.z : 0 ) << " ), " << MakeGroups << ", " << ElemType << " )"; } @@ -2828,17 +3193,17 @@ ExtrusionAlongPathX(const SMESH::long_array& IDsOfElements, aPythonDump <<"error"; aPythonDump << " = " << this << ".ExtrusionAlongPathX( " - << IDsOfElements << ", " - << Path << ", " - << NodeStart << ", " - << HasAngles << ", " - << Angles << ", " + << IDsOfElements << ", " + << Path << ", " + << NodeStart << ", " + << HasAngles << ", " + << TVar( Angles ) << ", " << LinearVariation << ", " - << HasRefPoint << ", " + << HasRefPoint << ", " << "SMESH.PointStruct( " - << ( HasRefPoint ? RefPoint.x : 0 ) << ", " - << ( HasRefPoint ? RefPoint.y : 0 ) << ", " - << ( HasRefPoint ? RefPoint.z : 0 ) << " ), " + << TVar( HasRefPoint ? RefPoint.x : 0 ) << ", " + << TVar( HasRefPoint ? RefPoint.y : 0 ) << ", " + << TVar( HasRefPoint ? RefPoint.z : 0 ) << " ), " << MakeGroups << ", " << ElemType << " )"; } @@ -2970,16 +3335,23 @@ SMESH_MeshEditor_i::mirror(TIDSortedElemSet & theElements, theMakeGroups = false; } - ::SMESH_MeshEditor anEditor( mesh ); ::SMESH_MeshEditor::PGroupIDs groupIds = - anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh); + myEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh); if(theCopy || myPreviewMode) - storeResult(anEditor); - else + storeResult(myEditor); // store preview data or new elements + + if ( !myPreviewMode ) { - myMesh->SetIsModified( true ); - myMesh->GetMeshDS()->Modified(); + if ( theTargetMesh ) + { + theTargetMesh->GetMeshDS()->Modified(); + } + else + { + myMesh->GetMeshDS()->Modified(); + myMesh->SetIsModified( true ); + } } return theMakeGroups ? getGroups(groupIds.get()) : 0; } @@ -2996,10 +3368,10 @@ void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElem { if ( !myPreviewMode ) { TPythonDump() << this << ".Mirror( " - << theIDsOfElements << ", " - << theAxis << ", " + << theIDsOfElements << ", " + << theAxis << ", " << mirrorTypeName(theMirrorType) << ", " - << theCopy << " )"; + << theCopy << " )"; } if ( theIDsOfElements.length() > 0 ) { @@ -3022,10 +3394,10 @@ void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObj { if ( !myPreviewMode ) { TPythonDump() << this << ".MirrorObject( " - << theObject << ", " - << theAxis << ", " + << theObject << ", " + << theAxis << ", " << mirrorTypeName(theMirrorType) << ", " - << theCopy << " )"; + << theCopy << " )"; } TIDSortedElemSet elements; @@ -3057,8 +3429,8 @@ SMESH_MeshEditor_i::MirrorMakeGroups(const SMESH::long_array& theIDsO if (!myPreviewMode) { DumpGroupsList(aPythonDump, aGroups); aPythonDump << this << ".MirrorMakeGroups( " - << theIDsOfElements << ", " - << theMirror << ", " + << theIDsOfElements << ", " + << theMirror << ", " << mirrorTypeName(theMirrorType) << " )"; } return aGroups; @@ -3085,8 +3457,8 @@ SMESH_MeshEditor_i::MirrorObjectMakeGroups(SMESH::SMESH_IDSource_ptr t { DumpGroupsList(aPythonDump,aGroups); aPythonDump << this << ".MirrorObjectMakeGroups( " - << theObject << ", " - << theMirror << ", " + << theObject << ", " + << theMirror << ", " << mirrorTypeName(theMirrorType) << " )"; } return aGroups; @@ -3124,11 +3496,11 @@ SMESH_MeshEditor_i::MirrorMakeMesh(const SMESH::long_array& theIDsOfE if (!myPreviewMode) { pydump << mesh << " = " << this << ".MirrorMakeMesh( " - << theIDsOfElements << ", " - << theMirror << ", " + << theIDsOfElements << ", " + << theMirror << ", " << mirrorTypeName(theMirrorType) << ", " - << theCopyGroups << ", '" - << theMeshName << "' )"; + << theCopyGroups << ", '" + << theMeshName << "' )"; } } @@ -3170,11 +3542,11 @@ SMESH_MeshEditor_i::MirrorObjectMakeMesh(SMESH::SMESH_IDSource_ptr the } if (!myPreviewMode) { pydump << mesh << " = " << this << ".MirrorObjectMakeMesh( " - << theObject << ", " - << theMirror << ", " + << theObject << ", " + << theMirror << ", " << mirrorTypeName(theMirrorType) << ", " - << theCopyGroups << ", '" - << theMeshName << "' )"; + << theCopyGroups << ", '" + << theMeshName << "' )"; } } @@ -3225,16 +3597,23 @@ SMESH_MeshEditor_i::translate(TIDSortedElemSet & theElements, theMakeGroups = false; } - ::SMESH_MeshEditor anEditor( mesh ); ::SMESH_MeshEditor::PGroupIDs groupIds = - anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh); + myEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh); if(theCopy || myPreviewMode) - storeResult(anEditor); - else + storeResult(myEditor); + + if ( !myPreviewMode ) { - myMesh->GetMeshDS()->Modified(); - myMesh->SetIsModified( true ); + if ( theTargetMesh ) + { + theTargetMesh->GetMeshDS()->Modified(); + } + else + { + myMesh->GetMeshDS()->Modified(); + myMesh->SetIsModified( true ); + } } return theMakeGroups ? getGroups(groupIds.get()) : 0; @@ -3252,8 +3631,8 @@ void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements, if (!myPreviewMode) { TPythonDump() << this << ".Translate( " << theIDsOfElements << ", " - << theVector << ", " - << theCopy << " )"; + << theVector << ", " + << theCopy << " )"; } if (theIDsOfElements.length()) { TIDSortedElemSet elements; @@ -3275,7 +3654,7 @@ void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject, TPythonDump() << this << ".TranslateObject( " << theObject << ", " << theVector << ", " - << theCopy << " )"; + << theCopy << " )"; } TIDSortedElemSet elements; @@ -3306,7 +3685,7 @@ SMESH_MeshEditor_i::TranslateMakeGroups(const SMESH::long_array& theIDsOfElement DumpGroupsList(aPythonDump, aGroups); aPythonDump << this << ".TranslateMakeGroups( " << theIDsOfElements << ", " - << theVector << " )"; + << theVector << " )"; } return aGroups; } @@ -3369,9 +3748,9 @@ SMESH_MeshEditor_i::TranslateMakeMesh(const SMESH::long_array& theIDsOfElements, if ( !myPreviewMode ) { pydump << mesh << " = " << this << ".TranslateMakeMesh( " << theIDsOfElements << ", " - << theVector << ", " - << theCopyGroups << ", '" - << theMeshName << "' )"; + << theVector << ", " + << theCopyGroups << ", '" + << theMeshName << "' )"; } } @@ -3411,10 +3790,10 @@ SMESH_MeshEditor_i::TranslateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject, } if ( !myPreviewMode ) { pydump << mesh << " = " << this << ".TranslateObjectMakeMesh( " - << theObject << ", " - << theVector << ", " + << theObject << ", " + << theVector << ", " << theCopyGroups << ", '" - << theMeshName << "' )"; + << theMeshName << "' )"; } } @@ -3467,16 +3846,23 @@ SMESH_MeshEditor_i::rotate(TIDSortedElemSet & theElements, theMakeGroups = false; } - ::SMESH_MeshEditor anEditor( mesh ); ::SMESH_MeshEditor::PGroupIDs groupIds = - anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh); + myEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh); if(theCopy || myPreviewMode) - storeResult(anEditor); - else + storeResult(myEditor); + + if ( !myPreviewMode ) { - myMesh->GetMeshDS()->Modified(); - myMesh->SetIsModified( true ); + if ( theTargetMesh ) + { + theTargetMesh->GetMeshDS()->Modified(); + } + else + { + myMesh->GetMeshDS()->Modified(); + myMesh->SetIsModified( true ); + } } return theMakeGroups ? getGroups(groupIds.get()) : 0; @@ -3495,9 +3881,9 @@ void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements, if (!myPreviewMode) { TPythonDump() << this << ".Rotate( " << theIDsOfElements << ", " - << theAxis << ", " - << theAngle << ", " - << theCopy << " )"; + << theAxis << ", " + << TVar( theAngle ) << ", " + << theCopy << " )"; } if (theIDsOfElements.length() > 0) { @@ -3519,10 +3905,10 @@ void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject, { if ( !myPreviewMode ) { TPythonDump() << this << ".RotateObject( " - << theObject << ", " - << theAxis << ", " - << theAngle << ", " - << theCopy << " )"; + << theObject << ", " + << theAxis << ", " + << TVar( theAngle ) << ", " + << theCopy << " )"; } TIDSortedElemSet elements; bool emptyIfIsMesh = myPreviewMode ? false : true; @@ -3553,8 +3939,8 @@ SMESH_MeshEditor_i::RotateMakeGroups(const SMESH::long_array& theIDsOfElements, DumpGroupsList(aPythonDump, aGroups); aPythonDump << this << ".RotateMakeGroups( " << theIDsOfElements << ", " - << theAxis << ", " - << theAngle << " )"; + << theAxis << ", " + << TVar( theAngle ) << " )"; } return aGroups; } @@ -3579,9 +3965,9 @@ SMESH_MeshEditor_i::RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject, if (!myPreviewMode) { DumpGroupsList(aPythonDump, aGroups); aPythonDump << this << ".RotateObjectMakeGroups( " - << theObject << ", " - << theAxis << ", " - << theAngle << " )"; + << theObject << ", " + << theAxis << ", " + << TVar( theAngle ) << " )"; } return aGroups; } @@ -3619,11 +4005,11 @@ SMESH_MeshEditor_i::RotateMakeMesh(const SMESH::long_array& theIDsOfElements, } if ( !myPreviewMode ) { pydump << mesh << " = " << this << ".RotateMakeMesh( " - << theIDsOfElements << ", " - << theAxis << ", " - << theAngleInRadians << ", " - << theCopyGroups << ", '" - << theMeshName << "' )"; + << theIDsOfElements << ", " + << theAxis << ", " + << TVar( theAngleInRadians ) << ", " + << theCopyGroups << ", '" + << theMeshName << "' )"; } } @@ -3666,11 +4052,11 @@ SMESH_MeshEditor_i::RotateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject, } if ( !myPreviewMode ) { pydump << mesh << " = " << this << ".RotateObjectMakeMesh( " - << theObject << ", " - << theAxis << ", " - << theAngleInRadians << ", " - << theCopyGroups << ", '" - << theMeshName << "' )"; + << theObject << ", " + << theAxis << ", " + << TVar( theAngleInRadians ) << ", " + << theCopyGroups << ", '" + << theMeshName << "' )"; } } @@ -3738,17 +4124,25 @@ SMESH_MeshEditor_i::scale(SMESH::SMESH_IDSource_ptr theObject, theMakeGroups = false; } - ::SMESH_MeshEditor anEditor( mesh ); ::SMESH_MeshEditor::PGroupIDs groupIds = - anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh); + myEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh); if(theCopy || myPreviewMode ) - storeResult(anEditor); - else + storeResult(myEditor); + + if ( !myPreviewMode ) { - myMesh->GetMeshDS()->Modified(); - myMesh->SetIsModified( true ); + if ( theTargetMesh ) + { + theTargetMesh->GetMeshDS()->Modified(); + } + else + { + myMesh->GetMeshDS()->Modified(); + myMesh->SetIsModified( true ); + } } + return theMakeGroups ? getGroups(groupIds.get()) : 0; } @@ -3764,11 +4158,10 @@ void SMESH_MeshEditor_i::Scale(SMESH::SMESH_IDSource_ptr theObject, { if ( !myPreviewMode ) { TPythonDump() << this << ".Scale( " - << theObject << ", " - << "SMESH.PointStruct( " << thePoint.x << ", " - << thePoint.y << ", " << thePoint.z << " ) ," - << theScaleFact << ", " - << theCopy << " )"; + << theObject << ", " + << thePoint << ", " + << TVar( theScaleFact ) << ", " + << theCopy << " )"; } scale(theObject, thePoint, theScaleFact, theCopy, false); } @@ -3790,10 +4183,9 @@ SMESH_MeshEditor_i::ScaleMakeGroups(SMESH::SMESH_IDSource_ptr theObject, if (!myPreviewMode) { DumpGroupsList(aPythonDump, aGroups); aPythonDump << this << ".Scale(" - << theObject << "," - << "SMESH.PointStruct(" <length( aListOfListOfNodes.size() ); @@ -3887,9 +4277,8 @@ void SMESH_MeshEditor_i::FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr idSourceToNodeSet( theObject, GetMeshDS(), nodes ); ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes; - ::SMESH_MeshEditor anEditor( myMesh ); if(!nodes.empty()) - anEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes ); + myEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes ); GroupsOfNodes = new SMESH::array_of_long_array; GroupsOfNodes->length( aListOfListOfNodes.size() ); @@ -3935,9 +4324,8 @@ FindCoincidentNodesOnPartBut(SMESH::SMESH_IDSource_ptr theObject, nodes.erase( *avoidNode ); } ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes; - ::SMESH_MeshEditor anEditor( myMesh ); if(!nodes.empty()) - anEditor.FindCoincidentNodes( nodes, theTolerance, aListOfListOfNodes ); + myEditor.FindCoincidentNodes( nodes, theTolerance, aListOfListOfNodes ); theGroupsOfNodes = new SMESH::array_of_long_array; theGroupsOfNodes->length( aListOfListOfNodes.size() ); @@ -3989,8 +4377,7 @@ void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfN if ( i > 0 ) aTPythonDump << ", "; aTPythonDump << aNodeGroup; } - ::SMESH_MeshEditor anEditor( myMesh ); - anEditor.MergeNodes( aListOfListOfNodes ); + myEditor.MergeNodes( aListOfListOfNodes ); aTPythonDump << "])"; myMesh->GetMeshDS()->Modified(); @@ -4023,8 +4410,7 @@ void SMESH_MeshEditor_i::FindEqualElements(SMESH::SMESH_IDSource_ptr theObj } ::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID; - ::SMESH_MeshEditor anEditor( myMesh ); - anEditor.FindEqualElements( elems, aListOfListOfElementsID ); + myEditor.FindEqualElements( elems, aListOfListOfElementsID ); GroupsOfElementsID = new SMESH::array_of_long_array; GroupsOfElementsID->length( aListOfListOfElementsID.size() ); @@ -4073,8 +4459,7 @@ void SMESH_MeshEditor_i::MergeElements(const SMESH::array_of_long_array& GroupsO aTPythonDump << anElemsIDGroup; } - ::SMESH_MeshEditor anEditor( myMesh ); - anEditor.MergeElements(aListOfListOfElementsID); + myEditor.MergeElements(aListOfListOfElementsID); myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); @@ -4090,8 +4475,9 @@ void SMESH_MeshEditor_i::MergeEqualElements() { initData(); - ::SMESH_MeshEditor anEditor( myMesh ); - anEditor.MergeEqualElements(); + myEditor.MergeEqualElements(); + + myMesh->GetMeshDS()->Modified(); TPythonDump() << this << ".MergeEqualElements()"; } @@ -4133,8 +4519,7 @@ CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long NodeID, if ( nodeCpy1 ) tmpMesh.GetMeshDS()->MoveNode(nodeCpy1, x, y, z); // fill preview data - ::SMESH_MeshEditor anEditor( & tmpMesh ); - storeResult( anEditor ); + storeResult( myEditor ); } else if ( theNodeSearcher ) // move node and update theNodeSearcher data accordingly theNodeSearcher->MoveNode(node, gp_Pnt( x,y,z )); @@ -4145,7 +4530,7 @@ CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long NodeID, { // Update Python script TPythonDump() << "isDone = " << this << ".MoveNode( " - << NodeID << ", " << x << ", " << y << ", " << z << " )"; + << NodeID << ", " << TVar(x) << ", " << TVar(y) << ", " << TVar(z) << " )"; myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); } @@ -4166,8 +4551,7 @@ CORBA::Long SMESH_MeshEditor_i::FindNodeClosestTo(CORBA::Double x, theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other if ( !theNodeSearcher ) { - ::SMESH_MeshEditor anEditor( myMesh ); - theNodeSearcher = anEditor.GetNodeSearcher(); + theNodeSearcher = myEditor.GetNodeSearcher(); } gp_Pnt p( x,y,z ); if ( const SMDS_MeshNode* node = theNodeSearcher->FindClosestTo( p )) @@ -4201,8 +4585,7 @@ CORBA::Long SMESH_MeshEditor_i::MoveClosestNodeToPoint(CORBA::Double x, if ( !node ) // preview moving node { if ( !theNodeSearcher ) { - ::SMESH_MeshEditor anEditor( myMesh ); - theNodeSearcher = anEditor.GetNodeSearcher(); + theNodeSearcher = myEditor.GetNodeSearcher(); } gp_Pnt p( x,y,z ); node = theNodeSearcher->FindClosestTo( p ); @@ -4226,8 +4609,7 @@ CORBA::Long SMESH_MeshEditor_i::MoveClosestNodeToPoint(CORBA::Double x, if ( node ) tmpMesh.GetMeshDS()->MoveNode(node, x, y, z); // fill preview data - ::SMESH_MeshEditor anEditor( & tmpMesh ); - storeResult( anEditor ); + storeResult( myEditor ); } else if ( theNodeSearcher ) // move node and update theNodeSearcher data accordingly { @@ -4270,8 +4652,7 @@ SMESH::long_array* SMESH_MeshEditor_i::FindElementsByPoint(CORBA::Double x, theSearchersDeleter.Set( myMesh ); if ( !theElementSearcher ) { - ::SMESH_MeshEditor anEditor( myMesh ); - theElementSearcher = anEditor.GetElementSearcher(); + theElementSearcher = myEditor.GetElementSearcher(); } theElementSearcher->FindElementsByPoint( gp_Pnt( x,y,z ), SMDSAbs_ElementType( type ), @@ -4281,7 +4662,7 @@ SMESH::long_array* SMESH_MeshEditor_i::FindElementsByPoint(CORBA::Double x, res[i] = foundElems[i]->GetID(); if ( !myPreviewMode ) // call from tui - TPythonDump() << res << " = " << this << ".FindElementsByPoint( " + TPythonDump() << "res = " << this << ".FindElementsByPoint( " << x << ", " << y << ", " << z << ", " @@ -4290,6 +4671,70 @@ SMESH::long_array* SMESH_MeshEditor_i::FindElementsByPoint(CORBA::Double x, return res._retn(); } +//======================================================================= +//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) +{ + 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( 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( mesh )->GetImpl().GetMeshDS(); + + if ( !idSourceToSet( elementIDs, meshDS, elements, + SMDSAbs_ElementType(type), /*emptyIfIsMesh=*/true)) + return res._retn(); + + typedef SMDS_SetIterator TIter; + SMDS_ElemIteratorPtr elemsIt( new TIter( elements.begin(), elements.end() )); + + theElementSearcher = myEditor.GetElementSearcher(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 ( !myPreviewMode ) // call from tui + TPythonDump() << "res = " << this << ".FindAmongElementsByPoint( " + << elementIDs << ", " + << x << ", " + << y << ", " + << z << ", " + << type << " )"; + + return res._retn(); + +} //======================================================================= //function : GetPointState //purpose : Return point state in a closed 2D mesh in terms of TopAbs_State enumeration. @@ -4302,8 +4747,7 @@ CORBA::Short SMESH_MeshEditor_i::GetPointState(CORBA::Double x, { theSearchersDeleter.Set( myMesh ); if ( !theElementSearcher ) { - ::SMESH_MeshEditor anEditor( myMesh ); - theElementSearcher = anEditor.GetElementSearcher(); + theElementSearcher = myEditor.GetElementSearcher(); } return CORBA::Short( theElementSearcher->GetPointState( gp_Pnt( x,y,z ))); } @@ -4377,9 +4821,8 @@ SMESH_MeshEditor_i::SewFreeBorders(CORBA::Long FirstNodeID1, << CreatePolygons<< ", " << CreatePolyedrs<< " )"; - ::SMESH_MeshEditor anEditor( myMesh ); SMESH::SMESH_MeshEditor::Sew_Error error = - convError( anEditor.SewFreeBorder (aBorderFirstNode, + convError( myEditor.SewFreeBorder (aBorderFirstNode, aBorderSecondNode, aBorderLastNode, aSide2FirstNode, @@ -4389,7 +4832,7 @@ SMESH_MeshEditor_i::SewFreeBorders(CORBA::Long FirstNodeID1, CreatePolygons, CreatePolyedrs) ); - storeResult(anEditor); + storeResult(myEditor); myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); @@ -4436,9 +4879,8 @@ SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1, << FirstNodeID2 << ", " << SecondNodeID2 << " )"; - ::SMESH_MeshEditor anEditor( myMesh ); SMESH::SMESH_MeshEditor::Sew_Error error = - convError( anEditor.SewFreeBorder (aBorderFirstNode, + convError( myEditor.SewFreeBorder (aBorderFirstNode, aBorderSecondNode, aBorderLastNode, aSide2FirstNode, @@ -4447,7 +4889,7 @@ SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1, true, false, false) ); - storeResult(anEditor); + storeResult(myEditor); myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); @@ -4498,9 +4940,8 @@ SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder, << CreatePolygons << ", " << CreatePolyedrs << ") "; - ::SMESH_MeshEditor anEditor( myMesh ); SMESH::SMESH_MeshEditor::Sew_Error error = - convError( anEditor.SewFreeBorder (aBorderFirstNode, + convError( myEditor.SewFreeBorder (aBorderFirstNode, aBorderSecondNode, aBorderLastNode, aSide2FirstNode, @@ -4510,7 +4951,7 @@ SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder, CreatePolygons, CreatePolyedrs) ); - storeResult(anEditor); + storeResult(myEditor); myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); @@ -4560,15 +5001,14 @@ SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements, << NodeID2OfSide1ToMerge << ", " << NodeID2OfSide2ToMerge << ")"; - ::SMESH_MeshEditor anEditor( myMesh ); SMESH::SMESH_MeshEditor::Sew_Error error = - convError( anEditor.SewSideElements (aSide1Elems, aSide2Elems, + convError( myEditor.SewSideElements (aSide1Elems, aSide2Elems, aFirstNode1ToMerge, aFirstNode2ToMerge, aSecondNode1ToMerge, aSecondNode2ToMerge)); - storeResult(anEditor); + storeResult(myEditor); myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); @@ -4617,145 +5057,6 @@ CORBA::Boolean SMESH_MeshEditor_i::ChangeElemNodes(CORBA::Long ide, return res; } -//================================================================================ -/*! - * \brief Update myLastCreated* or myPreviewData - * \param anEditor - it contains last modification results - */ -//================================================================================ - -void SMESH_MeshEditor_i::storeResult(::SMESH_MeshEditor& anEditor) -{ - if ( myPreviewMode ) { // --- MeshPreviewStruct filling --- - - list aNodesConnectivity; - typedef map TNodesMap; - TNodesMap nodesMap; - - TPreviewMesh * aPreviewMesh = dynamic_cast< TPreviewMesh* >( anEditor.GetMesh() ); - SMDSAbs_ElementType previewType = aPreviewMesh->myPreviewType; - - SMESHDS_Mesh* aMeshDS = anEditor.GetMeshDS(); - int nbEdges = aMeshDS->NbEdges(); - int nbFaces = aMeshDS->NbFaces(); - int nbVolum = aMeshDS->NbVolumes(); - switch ( previewType ) { - case SMDSAbs_Edge : nbFaces = nbVolum = 0; break; - case SMDSAbs_Face : nbEdges = nbVolum = 0; break; - case SMDSAbs_Volume: nbEdges = nbFaces = 0; break; - default:; - } - myPreviewData->nodesXYZ.length(aMeshDS->NbNodes()); - myPreviewData->elementTypes.length(nbEdges + nbFaces + nbVolum); - int i = 0, j = 0; - SMDS_ElemIteratorPtr itMeshElems = aMeshDS->elementsIterator(); - - while ( itMeshElems->more() ) { - const SMDS_MeshElement* aMeshElem = itMeshElems->next(); - if ( previewType != SMDSAbs_All && aMeshElem->GetType() != previewType ) - continue; - - SMDS_ElemIteratorPtr itElemNodes = aMeshElem->nodesIterator(); - while ( itElemNodes->more() ) { - const SMDS_MeshNode* aMeshNode = - static_cast( itElemNodes->next() ); - int aNodeID = aMeshNode->GetID(); - TNodesMap::iterator anIter = nodesMap.find(aNodeID); - if ( anIter == nodesMap.end() ) { - // filling the nodes coordinates - myPreviewData->nodesXYZ[j].x = aMeshNode->X(); - myPreviewData->nodesXYZ[j].y = aMeshNode->Y(); - myPreviewData->nodesXYZ[j].z = aMeshNode->Z(); - anIter = nodesMap.insert( make_pair(aNodeID, j) ).first; - j++; - } - aNodesConnectivity.push_back(anIter->second); - } - - // filling the elements types - SMDSAbs_ElementType aType; - bool isPoly; - /*if (aMeshElem->GetType() == SMDSAbs_Volume) { - aType = SMDSAbs_Node; - isPoly = false; - } - else*/ { - aType = aMeshElem->GetType(); - isPoly = aMeshElem->IsPoly(); - } - - myPreviewData->elementTypes[i].SMDS_ElementType = (SMESH::ElementType) aType; - myPreviewData->elementTypes[i].isPoly = isPoly; - myPreviewData->elementTypes[i].nbNodesInElement = aMeshElem->NbNodes(); - i++; - - } - myPreviewData->nodesXYZ.length( j ); - - // filling the elements connectivities - list::iterator aConnIter = aNodesConnectivity.begin(); - myPreviewData->elementConnectivities.length(aNodesConnectivity.size()); - for( int i = 0; aConnIter != aNodesConnectivity.end(); aConnIter++, i++ ) - myPreviewData->elementConnectivities[i] = *aConnIter; - - return; - } - - { - // append new nodes into myLastCreatedNodes - const SMESH_SequenceOfElemPtr& aSeq = anEditor.GetLastCreatedNodes(); - int j = myLastCreatedNodes->length(); - int newLen = j + aSeq.Length(); - myLastCreatedNodes->length( newLen ); - for(int i=0; jGetID(); - } - { - // append new elements into myLastCreatedElems - const SMESH_SequenceOfElemPtr& aSeq = anEditor.GetLastCreatedElems(); - int j = myLastCreatedElems->length(); - int newLen = j + aSeq.Length(); - myLastCreatedElems->length( newLen ); - for(int i=0; jGetID(); - } -} - -//================================================================================ -/*! - * Return data of mesh edition preview - */ -//================================================================================ - -SMESH::MeshPreviewStruct* SMESH_MeshEditor_i::GetPreviewData() -{ - return myPreviewData._retn(); -} - -//================================================================================ -/*! - * \brief Returns list of it's IDs of created nodes - * \retval SMESH::long_array* - list of node ID - */ -//================================================================================ - -SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedNodes() -{ - return myLastCreatedNodes._retn(); -} - -//================================================================================ -/*! - * \brief Returns list of it's IDs of created elements - * \retval SMESH::long_array* - list of elements' ID - */ -//================================================================================ - -SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedElems() -{ - return myLastCreatedElems._retn(); -} - //======================================================================= //function : ConvertToQuadratic //purpose : @@ -4763,8 +5064,7 @@ SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedElems() void SMESH_MeshEditor_i::ConvertToQuadratic(CORBA::Boolean theForce3d) { - ::SMESH_MeshEditor anEditor( myMesh ); - anEditor.ConvertToQuadratic(theForce3d); + myEditor.ConvertToQuadratic(theForce3d); TPythonDump() << this << ".ConvertToQuadratic( " << theForce3d << " )"; myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); @@ -4777,14 +5077,79 @@ void SMESH_MeshEditor_i::ConvertToQuadratic(CORBA::Boolean theForce3d) CORBA::Boolean SMESH_MeshEditor_i::ConvertFromQuadratic() { - ::SMESH_MeshEditor anEditor( myMesh ); - CORBA::Boolean isDone = anEditor.ConvertFromQuadratic(); + CORBA::Boolean isDone = myEditor.ConvertFromQuadratic(); TPythonDump() << this << ".ConvertFromQuadratic()"; myMesh->GetMeshDS()->Modified(); if ( isDone ) myMesh->SetIsModified( true ); return isDone; } +//================================================================================ +/*! + * \brief Makes a part of the mesh quadratic + */ +//================================================================================ + +void SMESH_MeshEditor_i::ConvertToQuadraticObject(CORBA::Boolean theForce3d, + SMESH::SMESH_IDSource_ptr theObject) + throw (SALOME::SALOME_Exception) +{ + Unexpect aCatch(SALOME_SalomeException); + TPythonDump pyDump; + TIDSortedElemSet elems; + if ( idSourceToSet( theObject, GetMeshDS(), elems, SMDSAbs_All, /*emptyIfIsMesh=*/true )) + { + if ( elems.empty() ) + { + ConvertToQuadratic( theForce3d ); + } + else if ( (*elems.begin())->GetType() == SMDSAbs_Node ) + { + THROW_SALOME_CORBA_EXCEPTION("Group of nodes is not allowed", SALOME::BAD_PARAM); + } + else + { + myEditor.ConvertToQuadratic(theForce3d, elems); + } + } + myMesh->GetMeshDS()->Modified(); + myMesh->SetIsModified( true ); + + pyDump << this << ".ConvertToQuadraticObject( "<GetType() == SMDSAbs_Node ) + { + THROW_SALOME_CORBA_EXCEPTION("Group of nodes is not allowed", SALOME::BAD_PARAM); + } + else + { + myEditor.ConvertFromQuadratic(elems); + } + } + myMesh->GetMeshDS()->Modified(); + myMesh->SetIsModified( true ); + + pyDump << this << ".ConvertFromQuadraticObject( "< aListOfNodes; int i, n; for ( i = 0, n = theNodes.length(); i < n; i++ ) @@ -4883,10 +5247,10 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodes( const SMESH::long_array& theNode for ( i = 0, n = theModifiedElems.length(); i < n; i++ ) aListOfElems.push_back( theModifiedElems[ i ] ); - bool aResult = aMeshEditor.DoubleNodes( aListOfNodes, aListOfElems ); + bool aResult = myEditor.DoubleNodes( aListOfNodes, aListOfElems ); myMesh->GetMeshDS()->Modified(); - storeResult( aMeshEditor) ; + storeResult( myEditor) ; if ( aResult ) myMesh->SetIsModified( true ); @@ -4967,14 +5331,15 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroup(SMESH::SMESH_GroupBase_ptr th * \return a new group with newly created nodes * \sa DoubleNodeGroup() */ -SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeGroupNew( SMESH::SMESH_GroupBase_ptr theNodes, - SMESH::SMESH_GroupBase_ptr theModifiedElems ) +SMESH::SMESH_Group_ptr +SMESH_MeshEditor_i::DoubleNodeGroupNew( SMESH::SMESH_GroupBase_ptr theNodes, + SMESH::SMESH_GroupBase_ptr theModifiedElems ) { - if ( CORBA::is_nil( theNodes ) && theNodes->GetType() != SMESH::NODE ) - return false; - SMESH::SMESH_Group_var aNewGroup; + if ( CORBA::is_nil( theNodes ) && theNodes->GetType() != SMESH::NODE ) + return aNewGroup._retn(); + // Duplicate nodes SMESH::long_array_var aNodes = theNodes->GetListOfID(); SMESH::long_array_var aModifiedElems; @@ -4988,7 +5353,6 @@ SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeGroupNew( SMESH::SMESH_Grou TPythonDump pyDump; // suppress dump by the next line bool aResult = DoubleNodes( aNodes, aModifiedElems ); - if ( aResult ) { // Create group with newly created nodes @@ -4998,11 +5362,12 @@ SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeGroupNew( SMESH::SMESH_Grou string aNewName = generateGroupName(anUnindexedName + "_double"); aNewGroup = myMesh_i->CreateGroup(SMESH::NODE, aNewName.c_str()); aNewGroup->Add(anIds); + pyDump << aNewGroup << " = "; } } - pyDump << "createdNodes = " << this << ".DoubleNodeGroupNew( " << theNodes << ", " - << theModifiedElems << " )"; + pyDump << this << ".DoubleNodeGroupNew( " << theNodes << ", " + << theModifiedElems << " )"; return aNewGroup._retn(); } @@ -5023,7 +5388,6 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroups(const SMESH::ListOfGroups& t { initData(); - ::SMESH_MeshEditor aMeshEditor( myMesh ); std::list< int > aNodes; int i, n, j, m; @@ -5050,9 +5414,9 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroups(const SMESH::ListOfGroups& t } } - bool aResult = aMeshEditor.DoubleNodes( aNodes, anElems ); + bool aResult = myEditor.DoubleNodes( aNodes, anElems ); - storeResult( aMeshEditor) ; + storeResult( myEditor) ; myMesh->GetMeshDS()->Modified(); if ( aResult ) @@ -5075,8 +5439,9 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroups(const SMESH::ListOfGroups& t */ //================================================================================ -SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeGroupsNew( const SMESH::ListOfGroups& theNodes, - const SMESH::ListOfGroups& theModifiedElems ) +SMESH::SMESH_Group_ptr +SMESH_MeshEditor_i::DoubleNodeGroupsNew( const SMESH::ListOfGroups& theNodes, + const SMESH::ListOfGroups& theModifiedElems ) { SMESH::SMESH_Group_var aNewGroup; @@ -5093,11 +5458,12 @@ SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeGroupsNew( const SMESH::Lis string aNewName = generateGroupName(anUnindexedName + "_double"); aNewGroup = myMesh_i->CreateGroup(SMESH::NODE, aNewName.c_str()); aNewGroup->Add(anIds); + pyDump << aNewGroup << " = "; } } - pyDump << "createdNodes = " << this << ".DoubleNodeGroupsNew( " << theNodes << ", " - << theModifiedElems << " )"; + pyDump << this << ".DoubleNodeGroupsNew( " << theNodes << ", " + << theModifiedElems << " )"; return aNewGroup._retn(); } @@ -5123,7 +5489,6 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElem( const SMESH::long_array& theE { initData(); - ::SMESH_MeshEditor aMeshEditor( myMesh ); SMESHDS_Mesh* aMeshDS = GetMeshDS(); TIDSortedElemSet anElems, aNodes, anAffected; @@ -5131,9 +5496,9 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElem( const SMESH::long_array& theE arrayToSet(theNodesNot, aMeshDS, aNodes, SMDSAbs_Node); arrayToSet(theAffectedElems, aMeshDS, anAffected, SMDSAbs_All); - bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected ); + bool aResult = myEditor.DoubleNodes( anElems, aNodes, anAffected ); - storeResult( aMeshEditor) ; + storeResult( myEditor) ; myMesh->GetMeshDS()->Modified(); if ( aResult ) @@ -5166,7 +5531,6 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemInRegion ( const SMESH::long_ar { initData(); - ::SMESH_MeshEditor aMeshEditor( myMesh ); SMESHDS_Mesh* aMeshDS = GetMeshDS(); TIDSortedElemSet anElems, aNodes; @@ -5174,9 +5538,9 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemInRegion ( const SMESH::long_ar arrayToSet(theNodesNot, aMeshDS, aNodes, SMDSAbs_Node); TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape ); - bool aResult = aMeshEditor.DoubleNodesInRegion( anElems, aNodes, aShape ); + bool aResult = myEditor.DoubleNodesInRegion( anElems, aNodes, aShape ); - storeResult( aMeshEditor) ; + storeResult( myEditor) ; myMesh->GetMeshDS()->Modified(); if ( aResult ) @@ -5209,7 +5573,6 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroup(SMESH::SMESH_GroupBase_pt initData(); - ::SMESH_MeshEditor aMeshEditor( myMesh ); SMESHDS_Mesh* aMeshDS = GetMeshDS(); TIDSortedElemSet anElems, aNodes, anAffected; @@ -5217,9 +5580,9 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroup(SMESH::SMESH_GroupBase_pt idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node ); idSourceToSet( theAffectedElems, aMeshDS, anAffected, SMDSAbs_All ); - bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected ); + bool aResult = myEditor.DoubleNodes( anElems, aNodes, anAffected ); - storeResult( aMeshEditor) ; + storeResult( myEditor) ; myMesh->GetMeshDS()->Modified(); if ( aResult ) @@ -5241,18 +5604,43 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroup(SMESH::SMESH_GroupBase_pt * \return a new group with newly created elements * \sa DoubleNodeElemGroup() */ -SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeElemGroupNew(SMESH::SMESH_GroupBase_ptr theElems, - SMESH::SMESH_GroupBase_ptr theNodesNot, - SMESH::SMESH_GroupBase_ptr theAffectedElems) +SMESH::SMESH_Group_ptr +SMESH_MeshEditor_i::DoubleNodeElemGroupNew(SMESH::SMESH_GroupBase_ptr theElems, + SMESH::SMESH_GroupBase_ptr theNodesNot, + SMESH::SMESH_GroupBase_ptr theAffectedElems) { - if ( CORBA::is_nil( theElems ) && theElems->GetType() == SMESH::NODE ) - return false; + TPythonDump pyDump; + SMESH::ListOfGroups_var twoGroups = DoubleNodeElemGroup2New( theElems, + theNodesNot, + theAffectedElems, + true, false ); + SMESH::SMESH_GroupBase_var baseGroup = twoGroups[0].in(); + SMESH::SMESH_Group_var elemGroup = SMESH::SMESH_Group::_narrow( baseGroup ); - SMESH::SMESH_Group_var aNewGroup; + pyDump << elemGroup << " = " << this << ".DoubleNodeElemGroupNew( " + << theElems << ", " + << theNodesNot << ", " + << theAffectedElems << " )"; + + return elemGroup._retn(); +} + +SMESH::ListOfGroups* +SMESH_MeshEditor_i::DoubleNodeElemGroup2New(SMESH::SMESH_GroupBase_ptr theElems, + SMESH::SMESH_GroupBase_ptr theNodesNot, + SMESH::SMESH_GroupBase_ptr theAffectedElems, + CORBA::Boolean theElemGroupNeeded, + CORBA::Boolean theNodeGroupNeeded) +{ + SMESH::SMESH_Group_var aNewElemGroup, aNewNodeGroup; + SMESH::ListOfGroups_var aTwoGroups = new SMESH::ListOfGroups(); + aTwoGroups->length( 2 ); + + if ( CORBA::is_nil( theElems ) && theElems->GetType() == SMESH::NODE ) + return aTwoGroups._retn(); initData(); - ::SMESH_MeshEditor aMeshEditor( myMesh ); SMESHDS_Mesh* aMeshDS = GetMeshDS(); TIDSortedElemSet anElems, aNodes, anAffected; @@ -5261,28 +5649,52 @@ SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeElemGroupNew(SMESH::SMESH_G idSourceToSet( theAffectedElems, aMeshDS, anAffected, SMDSAbs_All ); - bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected ); + bool aResult = myEditor.DoubleNodes( anElems, aNodes, anAffected ); - storeResult( aMeshEditor) ; + storeResult( myEditor) ; + myMesh->GetMeshDS()->Modified(); - if ( aResult ) { + TPythonDump pyDump; + + if ( aResult ) + { myMesh->SetIsModified( true ); // Create group with newly created elements - SMESH::long_array_var anIds = GetLastCreatedElems(); - if (anIds->length() > 0) { + CORBA::String_var elemGroupName = theElems->GetName(); + string aNewName = generateGroupName( string(elemGroupName.in()) + "_double"); + if ( !myEditor.GetLastCreatedElems().IsEmpty() && theElemGroupNeeded ) + { + SMESH::long_array_var anIds = GetLastCreatedElems(); SMESH::ElementType aGroupType = myMesh_i->GetElementType(anIds[0], true); - string anUnindexedName (theElems->GetName()); - string aNewName = generateGroupName(anUnindexedName + "_double"); - aNewGroup = myMesh_i->CreateGroup(aGroupType, aNewName.c_str()); - aNewGroup->Add(anIds); + aNewElemGroup = myMesh_i->CreateGroup(aGroupType, aNewName.c_str()); + aNewElemGroup->Add(anIds); + } + if ( !myEditor.GetLastCreatedNodes().IsEmpty() && theNodeGroupNeeded ) + { + SMESH::long_array_var anIds = GetLastCreatedNodes(); + aNewNodeGroup = myMesh_i->CreateGroup(SMESH::NODE, aNewName.c_str()); + aNewNodeGroup->Add(anIds); } } // Update Python script - TPythonDump() << "createdElems = " << this << ".DoubleNodeElemGroupNew( " << theElems << ", " - << theNodesNot << ", " << theAffectedElems << " )"; - return aNewGroup._retn(); + + pyDump << "[ "; + if ( aNewElemGroup->_is_nil() ) pyDump << "nothing, "; + else pyDump << aNewElemGroup << ", "; + if ( aNewNodeGroup->_is_nil() ) pyDump << "nothing ] = "; + else pyDump << aNewNodeGroup << " ] = "; + + pyDump << this << ".DoubleNodeElemGroup2New( " << theElems << ", " + << theNodesNot << ", " + << theAffectedElems << ", " + << theElemGroupNeeded << ", " + << theNodeGroupNeeded <<" )"; + + aTwoGroups[0] = aNewElemGroup._retn(); + aTwoGroups[1] = aNewNodeGroup._retn(); + return aTwoGroups._retn(); } //================================================================================ @@ -5308,7 +5720,6 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroupInRegion(SMESH::SMESH_Grou initData(); - ::SMESH_MeshEditor aMeshEditor( myMesh ); SMESHDS_Mesh* aMeshDS = GetMeshDS(); TIDSortedElemSet anElems, aNodes, anAffected; @@ -5316,9 +5727,9 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroupInRegion(SMESH::SMESH_Grou idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node ); TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape ); - bool aResult = aMeshEditor.DoubleNodesInRegion( anElems, aNodes, aShape ); + bool aResult = myEditor.DoubleNodesInRegion( anElems, aNodes, aShape ); - storeResult( aMeshEditor) ; + storeResult( myEditor) ; myMesh->GetMeshDS()->Modified(); if ( aResult ) @@ -5366,7 +5777,6 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroups(const SMESH::ListOfGroup { initData(); - ::SMESH_MeshEditor aMeshEditor( myMesh ); SMESHDS_Mesh* aMeshDS = GetMeshDS(); TIDSortedElemSet anElems, aNodes, anAffected; @@ -5374,9 +5784,9 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroups(const SMESH::ListOfGroup listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true ); listOfGroupToSet(theAffectedElems, aMeshDS, anAffected, false ); - bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected ); + bool aResult = myEditor.DoubleNodes( anElems, aNodes, anAffected ); - storeResult( aMeshEditor) ; + storeResult( myEditor) ; myMesh->GetMeshDS()->Modified(); if ( aResult ) @@ -5401,15 +5811,40 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroups(const SMESH::ListOfGroup */ //================================================================================ -SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeElemGroupsNew(const SMESH::ListOfGroups& theElems, - const SMESH::ListOfGroups& theNodesNot, - const SMESH::ListOfGroups& theAffectedElems) +SMESH::SMESH_Group_ptr +SMESH_MeshEditor_i::DoubleNodeElemGroupsNew(const SMESH::ListOfGroups& theElems, + const SMESH::ListOfGroups& theNodesNot, + const SMESH::ListOfGroups& theAffectedElems) { - SMESH::SMESH_Group_var aNewGroup; + TPythonDump pyDump; + SMESH::ListOfGroups_var twoGroups = DoubleNodeElemGroups2New( theElems, + theNodesNot, + theAffectedElems, + true, false ); + SMESH::SMESH_GroupBase_var baseGroup = twoGroups[0].in(); + SMESH::SMESH_Group_var elemGroup = SMESH::SMESH_Group::_narrow( baseGroup ); + + pyDump << elemGroup << " = " << this << ".DoubleNodeElemGroupsNew( " + << theElems << ", " + << theNodesNot << ", " + << theAffectedElems << " )"; + + return elemGroup._retn(); +} + +SMESH::ListOfGroups* +SMESH_MeshEditor_i::DoubleNodeElemGroups2New(const SMESH::ListOfGroups& theElems, + const SMESH::ListOfGroups& theNodesNot, + const SMESH::ListOfGroups& theAffectedElems, + CORBA::Boolean theElemGroupNeeded, + CORBA::Boolean theNodeGroupNeeded) +{ + SMESH::SMESH_Group_var aNewElemGroup, aNewNodeGroup; + SMESH::ListOfGroups_var aTwoGroups = new SMESH::ListOfGroups(); + aTwoGroups->length( 2 ); initData(); - ::SMESH_MeshEditor aMeshEditor( myMesh ); SMESHDS_Mesh* aMeshDS = GetMeshDS(); TIDSortedElemSet anElems, aNodes, anAffected; @@ -5417,29 +5852,51 @@ SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeElemGroupsNew(const SMESH:: listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true ); listOfGroupToSet(theAffectedElems, aMeshDS, anAffected, false ); - bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected ); + bool aResult = myEditor.DoubleNodes( anElems, aNodes, anAffected ); - storeResult( aMeshEditor) ; + storeResult( myEditor) ; myMesh->GetMeshDS()->Modified(); - if ( aResult ) { + TPythonDump pyDump; + if ( aResult ) + { myMesh->SetIsModified( true ); // Create group with newly created elements - SMESH::long_array_var anIds = GetLastCreatedElems(); - if (anIds->length() > 0) { + CORBA::String_var elemGroupName = theElems[0]->GetName(); + string aNewName = generateGroupName( string(elemGroupName.in()) + "_double"); + if ( !myEditor.GetLastCreatedElems().IsEmpty() && theElemGroupNeeded ) + { + SMESH::long_array_var anIds = GetLastCreatedElems(); SMESH::ElementType aGroupType = myMesh_i->GetElementType(anIds[0], true); - string anUnindexedName (theElems[0]->GetName()); - string aNewName = generateGroupName(anUnindexedName + "_double"); - aNewGroup = myMesh_i->CreateGroup(aGroupType, aNewName.c_str()); - aNewGroup->Add(anIds); + aNewElemGroup = myMesh_i->CreateGroup(aGroupType, aNewName.c_str()); + aNewElemGroup->Add(anIds); + } + if ( !myEditor.GetLastCreatedNodes().IsEmpty() && theNodeGroupNeeded ) + { + SMESH::long_array_var anIds = GetLastCreatedNodes(); + aNewNodeGroup = myMesh_i->CreateGroup(SMESH::NODE, aNewName.c_str()); + aNewNodeGroup->Add(anIds); } } // Update Python script - TPythonDump() << "createdElems = " << this << ".DoubleNodeElemGroupsNew( " << &theElems << ", " - << &theNodesNot << ", " << &theAffectedElems << " )"; - return aNewGroup._retn(); + + pyDump << "[ "; + if ( aNewElemGroup->_is_nil() ) pyDump << "nothing, "; + else pyDump << aNewElemGroup << ", "; + if ( aNewNodeGroup->_is_nil() ) pyDump << "nothing ] = "; + else pyDump << aNewNodeGroup << " ] = "; + + pyDump << this << ".DoubleNodeElemGroups2New( " << &theElems << ", " + << &theNodesNot << ", " + << &theAffectedElems << ", " + << theElemGroupNeeded << ", " + << theNodeGroupNeeded << " )"; + + aTwoGroups[0] = aNewElemGroup._retn(); + aTwoGroups[1] = aNewNodeGroup._retn(); + return aTwoGroups._retn(); } //================================================================================ @@ -5463,7 +5920,6 @@ SMESH_MeshEditor_i::DoubleNodeElemGroupsInRegion(const SMESH::ListOfGroups& theE { initData(); - ::SMESH_MeshEditor aMeshEditor( myMesh ); SMESHDS_Mesh* aMeshDS = GetMeshDS(); TIDSortedElemSet anElems, aNodes; @@ -5471,9 +5927,9 @@ SMESH_MeshEditor_i::DoubleNodeElemGroupsInRegion(const SMESH::ListOfGroups& theE listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true ); TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape ); - bool aResult = aMeshEditor.DoubleNodesInRegion( anElems, aNodes, aShape ); + bool aResult = myEditor.DoubleNodesInRegion( anElems, aNodes, aShape ); - storeResult( aMeshEditor) ; + storeResult( myEditor) ; myMesh->GetMeshDS()->Modified(); if ( aResult ) @@ -5485,6 +5941,124 @@ SMESH_MeshEditor_i::DoubleNodeElemGroupsInRegion(const SMESH::ListOfGroups& theE return aResult; } +//================================================================================ +/*! + \brief Identify the elements that will be affected by node duplication (actual duplication is not performed. + This method is the first step of DoubleNodeElemGroupsInRegion. + \param theElems - list of groups of elements (edges or faces) to be replicated + \param theNodesNot - list of groups of nodes not to replicated + \param theShape - shape to detect affected elements (element which geometric center + located on or inside shape). + The replicated nodes should be associated to affected elements. + \return groups of affected elements + \sa DoubleNodeElemGroupsInRegion() + */ +//================================================================================ +SMESH::ListOfGroups* +SMESH_MeshEditor_i::AffectedElemGroupsInRegion( const SMESH::ListOfGroups& theElems, + const SMESH::ListOfGroups& theNodesNot, + GEOM::GEOM_Object_ptr theShape ) +{ + MESSAGE("AffectedElemGroupsInRegion"); + SMESH::ListOfGroups_var aListOfGroups = new SMESH::ListOfGroups(); + bool isEdgeGroup = false; + bool isFaceGroup = false; + bool isVolumeGroup = false; + SMESH::SMESH_Group_var aNewEdgeGroup = myMesh_i->CreateGroup(SMESH::EDGE, "affectedEdges"); + SMESH::SMESH_Group_var aNewFaceGroup = myMesh_i->CreateGroup(SMESH::FACE, "affectedFaces"); + SMESH::SMESH_Group_var aNewVolumeGroup = myMesh_i->CreateGroup(SMESH::VOLUME, "affectedVolumes"); + + initData(); + + ::SMESH_MeshEditor aMeshEditor(myMesh); + + SMESHDS_Mesh* aMeshDS = GetMeshDS(); + TIDSortedElemSet anElems, aNodes; + listOfGroupToSet(theElems, aMeshDS, anElems, false); + listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true); + + TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape(theShape); + TIDSortedElemSet anAffected; + bool aResult = aMeshEditor.AffectedElemGroupsInRegion(anElems, aNodes, aShape, anAffected); + + storeResult(aMeshEditor); + + myMesh->GetMeshDS()->Modified(); + TPythonDump pyDump; + if (aResult) + { + myMesh->SetIsModified(true); + + int lg = anAffected.size(); + MESSAGE("lg="<< lg); + SMESH::long_array_var volumeIds = new SMESH::long_array; + volumeIds->length(lg); + SMESH::long_array_var faceIds = new SMESH::long_array; + faceIds->length(lg); + SMESH::long_array_var edgeIds = new SMESH::long_array; + edgeIds->length(lg); + int ivol = 0; + int iface = 0; + int iedge = 0; + + TIDSortedElemSet::const_iterator eIt = anAffected.begin(); + for (; eIt != anAffected.end(); ++eIt) + { + const SMDS_MeshElement* anElem = *eIt; + if (!anElem) + continue; + int elemId = anElem->GetID(); + if (myMesh->GetElementType(elemId, true) == SMDSAbs_Volume) + volumeIds[ivol++] = elemId; + else if (myMesh->GetElementType(elemId, true) == SMDSAbs_Face) + faceIds[iface++] = elemId; + else if (myMesh->GetElementType(elemId, true) == SMDSAbs_Edge) + edgeIds[iedge++] = elemId; + } + volumeIds->length(ivol); + faceIds->length(iface); + edgeIds->length(iedge); + + aNewVolumeGroup->Add(volumeIds); + aNewFaceGroup->Add(faceIds); + aNewEdgeGroup->Add(edgeIds); + isVolumeGroup = (aNewVolumeGroup->Size() > 0); + isFaceGroup = (aNewFaceGroup->Size() > 0); + isEdgeGroup = (aNewEdgeGroup->Size() > 0); + } + + int nbGroups = 0; + if (isEdgeGroup) + nbGroups++; + if (isFaceGroup) + nbGroups++; + if (isVolumeGroup) + nbGroups++; + aListOfGroups->length(nbGroups); + + int i = 0; + if (isEdgeGroup) + aListOfGroups[i++] = aNewEdgeGroup._retn(); + if (isFaceGroup) + aListOfGroups[i++] = aNewFaceGroup._retn(); + if (isVolumeGroup) + aListOfGroups[i++] = aNewVolumeGroup._retn(); + + // Update Python script + + pyDump << "[ "; + if (isEdgeGroup) + pyDump << aNewEdgeGroup << ", "; + if (isFaceGroup) + pyDump << aNewFaceGroup << ", "; + if (isVolumeGroup) + pyDump << aNewVolumeGroup << ", "; + pyDump << "] = "; + pyDump << this << ".AffectedElemGroupsInRegion( " << &theElems << ", " << &theNodesNot << ", " << theShape << " )"; + + return aListOfGroups._retn(); +} + //================================================================================ /*! \brief Generated skin mesh (containing 2D cells) from 3D mesh @@ -5497,9 +6071,8 @@ CORBA::Boolean SMESH_MeshEditor_i::Make2DMeshFrom3D() { initData(); - ::SMESH_MeshEditor aMeshEditor( myMesh ); - bool aResult = aMeshEditor.Make2DMeshFrom3D(); - storeResult( aMeshEditor) ; + bool aResult = myEditor.Make2DMeshFrom3D(); + storeResult( myEditor) ; myMesh->GetMeshDS()->Modified(); TPythonDump() << "isDone = " << this << ".Make2DMeshFrom3D()"; return aResult; @@ -5512,6 +6085,7 @@ CORBA::Boolean SMESH_MeshEditor_i::Make2DMeshFrom3D() * The nodes of the internal faces at the boundaries of the groups are doubled. * In option, the internal faces are replaced by flat elements. * Triangles are transformed in prisms, and quadrangles in hexahedrons. + * The flat elements are stored in groups of volumes. * @param theDomains - list of groups of volumes * @param createJointElems - if TRUE, create the elements * @return TRUE if operation has been completed successfully, FALSE otherwise @@ -5520,10 +6094,10 @@ CORBA::Boolean SMESH_MeshEditor_i::Make2DMeshFrom3D() CORBA::Boolean SMESH_MeshEditor_i::DoubleNodesOnGroupBoundaries( const SMESH::ListOfGroups& theDomains, CORBA::Boolean createJointElems ) + throw (SALOME::SALOME_Exception) { initData(); - ::SMESH_MeshEditor aMeshEditor( myMesh ); SMESHDS_Mesh* aMeshDS = GetMeshDS(); @@ -5533,8 +6107,10 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodesOnGroupBoundaries( const SMESH::Li for ( int i = 0, n = theDomains.length(); i < n; i++ ) { SMESH::SMESH_GroupBase_var aGrp = theDomains[ i ]; - if ( !CORBA::is_nil( aGrp ) && ( aGrp->GetType() != SMESH::NODE ) ) + if ( !CORBA::is_nil( aGrp ) /*&& ( aGrp->GetType() != SMESH::NODE )*/ ) { +// if ( aGrp->GetType() != SMESH::VOLUME ) +// THROW_SALOME_CORBA_EXCEPTION("Not a volume group", SALOME::BAD_PARAM); TIDSortedElemSet domain; domain.clear(); domains.push_back(domain); @@ -5543,9 +6119,10 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodesOnGroupBoundaries( const SMESH::Li } } - bool aResult = aMeshEditor.DoubleNodesOnGroupBoundaries( domains, createJointElems ); + bool aResult = myEditor.DoubleNodesOnGroupBoundaries( domains, createJointElems ); + // TODO publish the groups of flat elements in study - storeResult( aMeshEditor) ; + storeResult( myEditor) ; myMesh->GetMeshDS()->Modified(); // Update Python script @@ -5554,6 +6131,99 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodesOnGroupBoundaries( const SMESH::Li return aResult; } +//================================================================================ +/*! + * \brief Double nodes on some external faces and create flat elements. + * Flat elements are mainly used by some types of mechanic calculations. + * + * Each group of the list must be constituted of faces. + * Triangles are transformed in prisms, and quadrangles in hexahedrons. + * @param theGroupsOfFaces - list of groups of faces + * @return TRUE if operation has been completed successfully, FALSE otherwise + */ +//================================================================================ + +CORBA::Boolean SMESH_MeshEditor_i::CreateFlatElementsOnFacesGroups( const SMESH::ListOfGroups& theGroupsOfFaces ) +{ + initData(); + + + SMESHDS_Mesh* aMeshDS = GetMeshDS(); + + vector faceGroups; + faceGroups.clear(); + + for ( int i = 0, n = theGroupsOfFaces.length(); i < n; i++ ) + { + SMESH::SMESH_GroupBase_var aGrp = theGroupsOfFaces[ i ]; + if ( !CORBA::is_nil( aGrp ) && ( aGrp->GetType() != SMESH::NODE ) ) + { + TIDSortedElemSet faceGroup; + faceGroup.clear(); + faceGroups.push_back(faceGroup); + SMESH::long_array_var anIDs = aGrp->GetIDs(); + arrayToSet( anIDs, aMeshDS, faceGroups[ i ], SMDSAbs_All ); + } + } + + bool aResult = myEditor.CreateFlatElementsOnFacesGroups( faceGroups ); + // TODO publish the groups of flat elements in study + + storeResult( myEditor) ; + myMesh->GetMeshDS()->Modified(); + + // Update Python script + TPythonDump() << "isDone = " << this << ".CreateFlatElementsOnFacesGroups( " << &theGroupsOfFaces << " )"; + return aResult; +} + +/*! + * \brief identify all the elements around a geom shape, get the faces delimiting the hole + * Build groups of volume to remove, groups of faces to replace on the skin of the object, + * groups of faces to remove inside the object, (idem edges). + * Build ordered list of nodes at the border of each group of faces to replace (to be used to build a geom subshape) + */ +void SMESH_MeshEditor_i::CreateHoleSkin(CORBA::Double radius, + GEOM::GEOM_Object_ptr theShape, + const char* groupName, + const SMESH::double_array& theNodesCoords, + SMESH::array_of_long_array_out GroupsOfNodes) +throw (SALOME::SALOME_Exception) +{ + initData(); + std::vector > aListOfListOfNodes; + ::SMESH_MeshEditor aMeshEditor( myMesh ); + + theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other + if ( !theNodeSearcher ) + theNodeSearcher = aMeshEditor.GetNodeSearcher(); + + vector nodesCoords; + for (int i = 0; i < theNodesCoords.length(); i++) + { + nodesCoords.push_back( theNodesCoords[i] ); + } + + TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape ); + aMeshEditor.CreateHoleSkin(radius, aShape, theNodeSearcher, groupName, nodesCoords, aListOfListOfNodes); + + GroupsOfNodes = new SMESH::array_of_long_array; + GroupsOfNodes->length( aListOfListOfNodes.size() ); + std::vector >::iterator llIt = aListOfListOfNodes.begin(); + for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ ) + { + vector& aListOfNodes = *llIt; + vector::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); + } + TPythonDump() << "lists_nodes = " << this << ".CreateHoleSkin( " + << radius << ", " << theShape << ", " << ", " << groupName << ", " << theNodesCoords << " )"; +} + + // issue 20749 =================================================================== /*! * \brief Creates missing boundary elements @@ -5613,14 +6283,13 @@ SMESH_MeshEditor_i::MakeBoundaryMesh(SMESH::SMESH_IDSource_ptr idSource, } // do it - ::SMESH_MeshEditor aMeshEditor( myMesh ); - aMeshEditor.MakeBoundaryMesh( elements, + myEditor.MakeBoundaryMesh( elements, ::SMESH_MeshEditor::Bnd_Dimension(dim), smesh_group, smesh_mesh, toCopyElements, toCopyExistingBondary); - storeResult( aMeshEditor ); + storeResult( myEditor ); if ( smesh_mesh ) smesh_mesh->GetMeshDS()->Modified(); @@ -5682,20 +6351,37 @@ CORBA::Long SMESH_MeshEditor_i::MakeBoundaryElements(SMESH::Bnd_Dimension dim, if ( dim > SMESH::BND_1DFROM2D ) THROW_SALOME_CORBA_EXCEPTION("Invalid boundary dimension", SALOME::BAD_PARAM); - // check that groups belongs to to this mesh and is not this mesh - const int nbGroups = groups.length(); - for ( int i = 0; i < nbGroups; ++i ) + // separate groups belonging to this and other mesh + SMESH::ListOfIDSources_var groupsOfThisMesh = new SMESH::ListOfIDSources; + SMESH::ListOfIDSources_var groupsOfOtherMesh = new SMESH::ListOfIDSources; + groupsOfThisMesh->length( groups.length() ); + groupsOfOtherMesh->length( groups.length() ); + int nbGroups = 0, nbGroupsOfOtherMesh = 0; + for ( int i = 0; i < groups.length(); ++i ) { SMESH::SMESH_Mesh_var m = groups[i]->GetMesh(); if ( myMesh_i != SMESH::DownCast( m )) - THROW_SALOME_CORBA_EXCEPTION("group does not belong to this mesh", SALOME::BAD_PARAM); + groupsOfOtherMesh[ nbGroupsOfOtherMesh++ ] = groups[i]; + else + groupsOfThisMesh[ nbGroups++ ] = groups[i]; if ( SMESH::DownCast( groups[i] )) THROW_SALOME_CORBA_EXCEPTION("expect a group but recieve a mesh", SALOME::BAD_PARAM); } + groupsOfThisMesh->length( nbGroups ); + groupsOfOtherMesh->length( nbGroupsOfOtherMesh ); + int nbAdded = 0; TPythonDump pyDump; - int nbAdded = 0; + if ( nbGroupsOfOtherMesh > 0 ) + { + // process groups belonging to another mesh + SMESH::SMESH_Mesh_var otherMesh = groupsOfOtherMesh[0]->GetMesh(); + SMESH::SMESH_MeshEditor_var editor = otherMesh->GetMeshEditor(); + nbAdded += editor->MakeBoundaryElements( dim, groupName, meshName, toCopyAll, + groupsOfOtherMesh, mesh, group ); + } + SMESH::SMESH_Mesh_var mesh_var; SMESH::SMESH_Group_var group_var; @@ -5732,17 +6418,16 @@ CORBA::Long SMESH_MeshEditor_i::MakeBoundaryElements(SMESH::Bnd_Dimension dim, TIDSortedElemSet elements; - if ( nbGroups > 0 ) + if ( groups.length() > 0 ) { for ( int i = 0; i < nbGroups; ++i ) { elements.clear(); - if ( idSourceToSet( groups[i], srcMeshDS, elements, elemType,/*emptyIfIsMesh=*/false )) + if ( idSourceToSet( groupsOfThisMesh[i], srcMeshDS, elements, elemType,/*emptyIfIsMesh=*/0 )) { SMESH::Bnd_Dimension bdim = ( elemType == SMDSAbs_Volume ) ? SMESH::BND_2DFROM3D : SMESH::BND_1DFROM2D; - ::SMESH_MeshEditor aMeshEditor( srcMesh ); - nbAdded += aMeshEditor.MakeBoundaryMesh( elements, + nbAdded += myEditor.MakeBoundaryMesh( elements, ::SMESH_MeshEditor::Bnd_Dimension(bdim), smesh_group, tgtMesh, @@ -5750,21 +6435,20 @@ CORBA::Long SMESH_MeshEditor_i::MakeBoundaryElements(SMESH::Bnd_Dimension dim, /*toCopyExistingBondary=*/srcMesh != tgtMesh, /*toAddExistingBondary=*/true, /*aroundElements=*/true); - storeResult( aMeshEditor ); + storeResult( myEditor ); } } } else { - ::SMESH_MeshEditor aMeshEditor( srcMesh ); - nbAdded += aMeshEditor.MakeBoundaryMesh( elements, + nbAdded += myEditor.MakeBoundaryMesh( elements, ::SMESH_MeshEditor::Bnd_Dimension(dim), smesh_group, tgtMesh, /*toCopyElements=*/false, /*toCopyExistingBondary=*/srcMesh != tgtMesh, /*toAddExistingBondary=*/true); - storeResult( aMeshEditor ); + storeResult( myEditor ); } tgtMesh->GetMeshDS()->Modified();