1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESH_MeshEditor_i.cxx
23 // Author : Nicolas REJNERI
30 #include "SMESH_MeshEditor_i.hxx"
32 #include "SMDS_LinearEdge.hxx"
33 #include "SMDS_Mesh0DElement.hxx"
34 #include "SMDS_MeshFace.hxx"
35 #include "SMDS_MeshVolume.hxx"
36 #include "SMDS_PolyhedralVolumeOfNodes.hxx"
37 #include "SMDS_SetIterator.hxx"
38 #include "SMESHDS_Group.hxx"
39 #include "SMESH_ControlsDef.hxx"
40 #include "SMESH_Filter_i.hxx"
41 #include "SMESH_Gen_i.hxx"
42 #include "SMESH_Group_i.hxx"
43 #include "SMESH_PythonDump.hxx"
44 #include "SMESH_subMeshEventListener.hxx"
45 #include "SMESH_subMesh_i.hxx"
47 #include "utilities.h"
48 #include "Utils_ExceptHandlers.hxx"
49 #include "Utils_CorbaException.hxx"
51 #include <BRepAdaptor_Surface.hxx>
52 #include <BRep_Tool.hxx>
53 #include <TopExp_Explorer.hxx>
55 #include <TopoDS_Edge.hxx>
56 #include <TopoDS_Face.hxx>
61 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
65 #include <Standard_Failure.hxx>
68 #include <Standard_ErrorHandler.hxx>
74 #define cast2Node(elem) static_cast<const SMDS_MeshNode*>( elem )
77 using SMESH::TPythonDump;
81 //=============================================================================
83 * \brief Mesh to apply modifications for preview purposes
85 //=============================================================================
87 struct TPreviewMesh: public SMESH_Mesh
89 SMDSAbs_ElementType myPreviewType; // type to show
91 TPreviewMesh(SMDSAbs_ElementType previewElements = SMDSAbs_All) {
92 _isShapeToMesh = (_id =_studyId =_idDoc = 0);
93 _myMeshDS = new SMESHDS_Mesh( _id, true );
94 myPreviewType = previewElements;
97 virtual ~TPreviewMesh() { delete _myMeshDS; _myMeshDS = 0; }
98 //!< Copy a set of elements
99 void Copy(const TIDSortedElemSet & theElements,
100 TIDSortedElemSet& theCopyElements,
101 SMDSAbs_ElementType theSelectType = SMDSAbs_All,
102 SMDSAbs_ElementType theAvoidType = SMDSAbs_All)
104 // loop on theIDsOfElements
105 TIDSortedElemSet::const_iterator eIt = theElements.begin();
106 for ( ; eIt != theElements.end(); ++eIt )
108 const SMDS_MeshElement* anElem = *eIt;
109 if ( !anElem ) continue;
110 SMDSAbs_ElementType type = anElem->GetType();
111 if ( type == theAvoidType ||
112 ( theSelectType != SMDSAbs_All && type != theSelectType ))
114 const SMDS_MeshElement* anElemCopy;
115 if ( type == SMDSAbs_Node)
116 anElemCopy = Copy( cast2Node(anElem) );
118 anElemCopy = Copy( anElem );
120 theCopyElements.insert( theCopyElements.end(), anElemCopy );
124 SMDS_MeshElement* Copy( const SMDS_MeshElement* anElem )
126 // copy element nodes
127 int anElemNbNodes = anElem->NbNodes();
128 vector< int > anElemNodesID( anElemNbNodes ) ;
129 SMDS_ElemIteratorPtr itElemNodes = anElem->nodesIterator();
130 for ( int i = 0; itElemNodes->more(); i++)
132 const SMDS_MeshNode* anElemNode = cast2Node( itElemNodes->next() );
134 anElemNodesID[i] = anElemNode->GetID();
137 // creates a corresponding element on copied nodes
138 SMDS_MeshElement* anElemCopy = 0;
139 if ( anElem->IsPoly() && anElem->GetType() == SMDSAbs_Volume )
141 const SMDS_VtkVolume* ph =
142 dynamic_cast<const SMDS_VtkVolume*> (anElem);
144 anElemCopy = _myMeshDS->AddPolyhedralVolumeWithID
145 (anElemNodesID, ph->GetQuantities(),anElem->GetID());
148 anElemCopy = ::SMESH_MeshEditor(this).AddElement( anElemNodesID,
155 SMDS_MeshNode* Copy( const SMDS_MeshNode* anElemNode )
157 return _myMeshDS->AddNodeWithID(anElemNode->X(), anElemNode->Y(), anElemNode->Z(),
158 anElemNode->GetID());
160 };// struct TPreviewMesh
162 static SMESH_NodeSearcher * theNodeSearcher = 0;
163 static SMESH_ElementSearcher * theElementSearcher = 0;
165 //=============================================================================
167 * \brief Deleter of theNodeSearcher at any compute event occured
169 //=============================================================================
171 struct TSearchersDeleter : public SMESH_subMeshEventListener
174 string myMeshPartIOR;
176 TSearchersDeleter(): SMESH_subMeshEventListener( false, // won't be deleted by submesh
177 "SMESH_MeshEditor_i::TSearchersDeleter"),
179 //!< Delete theNodeSearcher
182 if ( theNodeSearcher ) delete theNodeSearcher; theNodeSearcher = 0;
183 if ( theElementSearcher ) delete theElementSearcher; theElementSearcher = 0;
185 typedef map < int, SMESH_subMesh * > TDependsOnMap;
186 //!< The meshod called by submesh: do my main job
187 void ProcessEvent(const int, const int eventType, SMESH_subMesh* sm,
188 SMESH_subMeshEventListenerData*,const SMESH_Hypothesis*)
190 if ( eventType == SMESH_subMesh::COMPUTE_EVENT ) {
192 Unset( sm->GetFather() );
195 //!< set self on all submeshes and delete theNodeSearcher if other mesh is set
196 void Set(SMESH_Mesh* mesh, const string& meshPartIOR = string())
198 if ( myMesh != mesh || myMeshPartIOR != meshPartIOR)
205 myMeshPartIOR = meshPartIOR;
206 if ( SMESH_subMesh* myMainSubMesh = mesh->GetSubMeshContaining(1) ) {
207 const TDependsOnMap & subMeshes = myMainSubMesh->DependsOn();
208 TDependsOnMap::const_iterator sm;
209 for (sm = subMeshes.begin(); sm != subMeshes.end(); sm++)
210 sm->second->SetEventListener( this, 0, sm->second );
214 //!< delete self from all submeshes
215 void Unset(SMESH_Mesh* mesh)
217 if ( SMESH_subMesh* myMainSubMesh = mesh->GetSubMeshContaining(1) ) {
218 const TDependsOnMap & subMeshes = myMainSubMesh->DependsOn();
219 TDependsOnMap::const_iterator sm;
220 for (sm = subMeshes.begin(); sm != subMeshes.end(); sm++)
221 sm->second->DeleteEventListener( this );
226 } theSearchersDeleter;
228 TCollection_AsciiString mirrorTypeName( SMESH::SMESH_MeshEditor::MirrorType theMirrorType )
230 TCollection_AsciiString typeStr;
231 switch ( theMirrorType ) {
232 case SMESH::SMESH_MeshEditor::POINT:
233 typeStr = "SMESH.SMESH_MeshEditor.POINT";
235 case SMESH::SMESH_MeshEditor::AXIS:
236 typeStr = "SMESH.SMESH_MeshEditor.AXIS";
239 typeStr = "SMESH.SMESH_MeshEditor.PLANE";
243 //================================================================================
245 * \brief function for conversion of long_array to TIDSortedElemSet
246 * \param IDs - array of IDs
247 * \param aMesh - mesh
248 * \param aMap - collection to fill
249 * \param aType - element type
251 //================================================================================
253 void arrayToSet(const SMESH::long_array & IDs,
254 const SMESHDS_Mesh* aMesh,
255 TIDSortedElemSet& aMap,
256 const SMDSAbs_ElementType aType = SMDSAbs_All )
258 for (int i=0; i<IDs.length(); i++) {
259 CORBA::Long ind = IDs[i];
260 const SMDS_MeshElement * elem =
261 (aType == SMDSAbs_Node ? aMesh->FindNode(ind) : aMesh->FindElement(ind));
262 if ( elem && ( aType == SMDSAbs_All || elem->GetType() == aType ))
266 //================================================================================
268 * \brief Retrieve elements of given type from SMESH_IDSource
270 //================================================================================
272 bool idSourceToSet(SMESH::SMESH_IDSource_ptr theIDSource,
273 const SMESHDS_Mesh* theMeshDS,
274 TIDSortedElemSet& theElemSet,
275 const SMDSAbs_ElementType theType,
276 const bool emptyIfIsMesh=false)
279 if ( CORBA::is_nil( theIDSource ) )
281 if ( emptyIfIsMesh && SMESH::DownCast<SMESH_Mesh_i*>( theIDSource ))
284 SMESH::long_array_var anIDs = theIDSource->GetIDs();
285 if ( anIDs->length() == 0 )
287 SMESH::array_of_ElementType_var types = theIDSource->GetTypes();
288 if ( types->length() == 1 && types[0] == SMESH::NODE ) // group of nodes
290 if ( theType == SMDSAbs_All || theType == SMDSAbs_Node )
291 arrayToSet( anIDs, theMeshDS, theElemSet, SMDSAbs_Node );
297 arrayToSet( anIDs, theMeshDS, theElemSet, theType);
301 //================================================================================
303 * \brief Retrieve nodes from SMESH_IDSource
305 //================================================================================
307 void idSourceToNodeSet(SMESH::SMESH_IDSource_ptr theObject,
308 const SMESHDS_Mesh* theMeshDS,
309 TIDSortedNodeSet& theNodeSet)
312 if ( CORBA::is_nil( theObject ) )
314 SMESH::array_of_ElementType_var types = theObject->GetTypes();
315 SMESH::long_array_var aElementsId = theObject->GetIDs();
316 if ( types->length() == 1 && types[0] == SMESH::NODE)
318 for(int i = 0; i < aElementsId->length(); i++)
319 if ( const SMDS_MeshNode * n = theMeshDS->FindNode( aElementsId[i] ))
320 theNodeSet.insert( theNodeSet.end(), n);
322 else if ( SMESH::DownCast<SMESH_Mesh_i*>( theObject ))
324 SMDS_NodeIteratorPtr nIt = theMeshDS->nodesIterator();
325 while ( nIt->more( ))
326 if( const SMDS_MeshElement * elem = nIt->next() )
327 theNodeSet.insert( elem->begin_nodes(), elem->end_nodes());
331 for(int i = 0; i < aElementsId->length(); i++)
332 if( const SMDS_MeshElement * elem = theMeshDS->FindElement( aElementsId[i] ))
333 theNodeSet.insert( elem->begin_nodes(), elem->end_nodes());
337 //================================================================================
339 * \brief Returns elements connected to the given elements
341 //================================================================================
343 void getElementsAround(const TIDSortedElemSet& theElements,
344 const SMESHDS_Mesh* theMeshDS,
345 TIDSortedElemSet& theElementsAround)
347 if ( theElements.empty() ) return;
349 SMDSAbs_ElementType elemType = (*theElements.begin())->GetType();
350 bool sameElemType = ( elemType == (*theElements.rbegin())->GetType() );
352 theMeshDS->GetMeshInfo().NbElements( elemType ) == theElements.size() )
353 return; // all the elements are in theElements
356 elemType = SMDSAbs_All;
358 TIDSortedElemSet visitedNodes;
359 TIDSortedElemSet::const_iterator elemIt = theElements.begin();
360 for ( ; elemIt != theElements.end(); ++elemIt )
362 const SMDS_MeshElement* e = *elemIt;
363 int i = e->NbCornerNodes();
366 const SMDS_MeshNode* n = e->GetNode( i );
367 if ( visitedNodes.insert( n ).second )
369 SMDS_ElemIteratorPtr invIt = n->GetInverseElementIterator(elemType);
370 while ( invIt->more() )
372 const SMDS_MeshElement* elemAround = invIt->next();
373 if ( !theElements.count( elemAround ))
374 theElementsAround.insert( elemAround );
382 //=============================================================================
386 //=============================================================================
388 SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESH_Mesh_i* theMesh, bool isPreview)
391 myMesh = & theMesh->GetImpl();
392 myPreviewMode = isPreview;
395 //================================================================================
399 //================================================================================
401 SMESH_MeshEditor_i::~SMESH_MeshEditor_i()
405 //================================================================================
407 * \brief Clear members
409 //================================================================================
411 void SMESH_MeshEditor_i::initData(bool deleteSearchers)
413 if ( myPreviewMode ) {
414 myPreviewData = new SMESH::MeshPreviewStruct();
417 myLastCreatedElems = new SMESH::long_array();
418 myLastCreatedNodes = new SMESH::long_array();
419 if ( deleteSearchers )
420 TSearchersDeleter::Delete();
424 //=======================================================================
425 //function : MakeIDSource
426 //purpose : Wrap a sequence of ids in a SMESH_IDSource
427 //=======================================================================
429 struct _IDSource : public POA_SMESH::SMESH_IDSource
431 SMESH::long_array _ids;
432 SMESH::ElementType _type;
433 SMESH::SMESH_Mesh_ptr _mesh;
434 SMESH::long_array* GetIDs() { return new SMESH::long_array( _ids ); }
435 SMESH::long_array* GetMeshInfo() { return 0; }
436 SMESH::SMESH_Mesh_ptr GetMesh() { return SMESH::SMESH_Mesh::_duplicate( _mesh ); }
437 SMESH::array_of_ElementType* GetTypes()
439 SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType;
440 if ( _ids.length() > 0 ) {
444 return types._retn();
448 SMESH::SMESH_IDSource_ptr SMESH_MeshEditor_i::MakeIDSource(const SMESH::long_array& ids,
449 SMESH::ElementType type)
451 _IDSource* anIDSource = new _IDSource;
452 anIDSource->_ids = ids;
453 anIDSource->_type = type;
454 anIDSource->_mesh = myMesh_i->_this();
455 SMESH::SMESH_IDSource_var anIDSourceVar = anIDSource->_this();
457 return anIDSourceVar._retn();
460 //=============================================================================
464 //=============================================================================
467 SMESH_MeshEditor_i::RemoveElements(const SMESH::long_array & IDsOfElements)
471 ::SMESH_MeshEditor anEditor( myMesh );
474 for (int i = 0; i < IDsOfElements.length(); i++)
475 IdList.push_back( IDsOfElements[i] );
477 // Update Python script
478 TPythonDump() << "isDone = " << this << ".RemoveElements( " << IDsOfElements << " )";
481 bool ret = anEditor.Remove( IdList, false );
482 myMesh->GetMeshDS()->Modified();
483 if ( IDsOfElements.length() )
484 myMesh->SetIsModified( true ); // issue 0020693
488 //=============================================================================
492 //=============================================================================
494 CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::long_array & IDsOfNodes)
498 ::SMESH_MeshEditor anEditor( myMesh );
500 for (int i = 0; i < IDsOfNodes.length(); i++)
501 IdList.push_back( IDsOfNodes[i] );
503 // Update Python script
504 TPythonDump() << "isDone = " << this << ".RemoveNodes( " << IDsOfNodes << " )";
506 bool ret = anEditor.Remove( IdList, true );
507 myMesh->GetMeshDS()->Modified();
508 if ( IDsOfNodes.length() )
509 myMesh->SetIsModified( true ); // issue 0020693
513 //=============================================================================
517 //=============================================================================
519 CORBA::Long SMESH_MeshEditor_i::RemoveOrphanNodes()
523 ::SMESH_MeshEditor anEditor( myMesh );
525 // Update Python script
526 TPythonDump() << "nbRemoved = " << this << ".RemoveOrphanNodes()";
528 // Create filter to find all orphan nodes
529 SMESH::Controls::Filter::TIdSequence seq;
530 SMESH::Controls::PredicatePtr predicate( new SMESH::Controls::FreeNodes() );
531 SMESH::Controls::Filter::GetElementsId( GetMeshDS(), predicate, seq );
533 // remove orphan nodes (if there are any)
535 for ( int i = 0; i < seq.size(); i++ )
536 IdList.push_back( seq[i] );
538 int nbNodesBefore = myMesh->NbNodes();
539 anEditor.Remove( IdList, true );
540 myMesh->GetMeshDS()->Modified();
542 myMesh->SetIsModified( true );
543 int nbNodesAfter = myMesh->NbNodes();
545 return nbNodesBefore - nbNodesAfter;
548 //=============================================================================
552 //=============================================================================
554 CORBA::Long SMESH_MeshEditor_i::AddNode(CORBA::Double x,
555 CORBA::Double y, CORBA::Double z)
559 const SMDS_MeshNode* N = GetMeshDS()->AddNode(x, y, z);
561 // Update Python script
562 TPythonDump() << "nodeID = " << this << ".AddNode( "
563 << x << ", " << y << ", " << z << " )";
565 myMesh->GetMeshDS()->Modified();
566 myMesh->SetIsModified( true ); // issue 0020693
570 //=============================================================================
574 //=============================================================================
575 CORBA::Long SMESH_MeshEditor_i::Add0DElement(CORBA::Long IDOfNode)
579 const SMDS_MeshNode* aNode = GetMeshDS()->FindNode(IDOfNode);
580 SMDS_MeshElement* elem = GetMeshDS()->Add0DElement(aNode);
582 // Update Python script
583 TPythonDump() << "elem0d = " << this << ".Add0DElement( " << IDOfNode <<" )";
585 myMesh->GetMeshDS()->Modified();
586 myMesh->SetIsModified( true ); // issue 0020693
589 return elem->GetID();
594 //=============================================================================
598 //=============================================================================
600 CORBA::Long SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes)
604 int NbNodes = IDsOfNodes.length();
605 SMDS_MeshElement* elem = 0;
608 CORBA::Long index1 = IDsOfNodes[0];
609 CORBA::Long index2 = IDsOfNodes[1];
610 elem = GetMeshDS()->AddEdge(GetMeshDS()->FindNode(index1), GetMeshDS()->FindNode(index2));
612 // Update Python script
613 TPythonDump() << "edge = " << this << ".AddEdge([ "
614 << index1 << ", " << index2 <<" ])";
617 CORBA::Long n1 = IDsOfNodes[0];
618 CORBA::Long n2 = IDsOfNodes[1];
619 CORBA::Long n12 = IDsOfNodes[2];
620 elem = GetMeshDS()->AddEdge(GetMeshDS()->FindNode(n1),
621 GetMeshDS()->FindNode(n2),
622 GetMeshDS()->FindNode(n12));
623 // Update Python script
624 TPythonDump() << "edgeID = " << this << ".AddEdge([ "
625 <<n1<<", "<<n2<<", "<<n12<<" ])";
628 myMesh->GetMeshDS()->Modified();
630 return myMesh->SetIsModified( true ), elem->GetID();
635 //=============================================================================
639 //=============================================================================
641 CORBA::Long SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
645 int NbNodes = IDsOfNodes.length();
651 std::vector<const SMDS_MeshNode*> nodes (NbNodes);
652 for (int i = 0; i < NbNodes; i++)
653 nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
655 SMDS_MeshElement* elem = 0;
657 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]);
659 else if (NbNodes == 4) {
660 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
662 else if (NbNodes == 6) {
663 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
666 else if (NbNodes == 8) {
667 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
668 nodes[4], nodes[5], nodes[6], nodes[7]);
670 else if (NbNodes == 9) {
671 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
672 nodes[4], nodes[5], nodes[6], nodes[7], nodes[8] );
674 else if (NbNodes > 2) {
675 elem = GetMeshDS()->AddPolygonalFace(nodes);
678 // Update Python script
679 TPythonDump() << "faceID = " << this << ".AddFace( " << IDsOfNodes << " )";
681 myMesh->GetMeshDS()->Modified();
683 return myMesh->SetIsModified( true ), elem->GetID();
688 //=============================================================================
692 //=============================================================================
693 CORBA::Long SMESH_MeshEditor_i::AddPolygonalFace (const SMESH::long_array & IDsOfNodes)
697 int NbNodes = IDsOfNodes.length();
698 std::vector<const SMDS_MeshNode*> nodes (NbNodes);
699 for (int i = 0; i < NbNodes; i++)
700 nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
702 const SMDS_MeshElement* elem = GetMeshDS()->AddPolygonalFace(nodes);
704 // Update Python script
705 TPythonDump() <<"faceID = "<<this<<".AddPolygonalFace( "<<IDsOfNodes<<" )";
707 myMesh->GetMeshDS()->Modified();
708 return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0;
711 //=============================================================================
715 //=============================================================================
717 CORBA::Long SMESH_MeshEditor_i::AddVolume(const SMESH::long_array & IDsOfNodes)
721 int NbNodes = IDsOfNodes.length();
722 vector< const SMDS_MeshNode*> n(NbNodes);
723 for(int i=0;i<NbNodes;i++)
724 n[i]=GetMeshDS()->FindNode(IDsOfNodes[i]);
726 SMDS_MeshElement* elem = 0;
729 case 4 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3]); break;
730 case 5 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4]); break;
731 case 6 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5]); break;
732 case 8 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break;
733 case 10:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],
734 n[6],n[7],n[8],n[9]);
736 case 12:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],
737 n[6],n[7],n[8],n[9],n[10],n[11]);
739 case 13:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],
740 n[7],n[8],n[9],n[10],n[11],n[12]);
742 case 15:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],
743 n[9],n[10],n[11],n[12],n[13],n[14]);
745 case 20:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],
746 n[8],n[9],n[10],n[11],n[12],n[13],n[14],
747 n[15],n[16],n[17],n[18],n[19]);
749 case 27:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],
750 n[8],n[9],n[10],n[11],n[12],n[13],n[14],
751 n[15],n[16],n[17],n[18],n[19],
752 n[20],n[21],n[22],n[23],n[24],n[25],n[26]);
756 // Update Python script
757 TPythonDump() << "volID = " << this << ".AddVolume( " << IDsOfNodes << " )";
759 myMesh->GetMeshDS()->Modified();
761 return myMesh->SetIsModified( true ), elem->GetID();
766 //=============================================================================
768 * AddPolyhedralVolume
770 //=============================================================================
771 CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolume (const SMESH::long_array & IDsOfNodes,
772 const SMESH::long_array & Quantities)
776 int NbNodes = IDsOfNodes.length();
777 std::vector<const SMDS_MeshNode*> n (NbNodes);
778 for (int i = 0; i < NbNodes; i++)
780 const SMDS_MeshNode* aNode = GetMeshDS()->FindNode(IDsOfNodes[i]);
781 if (!aNode) return 0;
785 int NbFaces = Quantities.length();
786 std::vector<int> q (NbFaces);
787 for (int j = 0; j < NbFaces; j++)
788 q[j] = Quantities[j];
790 const SMDS_MeshElement* elem = GetMeshDS()->AddPolyhedralVolume(n, q);
792 // Update Python script
793 TPythonDump() << "volID = " << this << ".AddPolyhedralVolume( "
794 << IDsOfNodes << ", " << Quantities << " )";
795 myMesh->GetMeshDS()->Modified();
797 return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0;
800 //=============================================================================
802 * AddPolyhedralVolumeByFaces
804 //=============================================================================
805 CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces (const SMESH::long_array & IdsOfFaces)
809 int NbFaces = IdsOfFaces.length();
810 std::vector<const SMDS_MeshNode*> poly_nodes;
811 std::vector<int> quantities (NbFaces);
813 for (int i = 0; i < NbFaces; i++) {
814 const SMDS_MeshElement* aFace = GetMeshDS()->FindElement(IdsOfFaces[i]);
815 quantities[i] = aFace->NbNodes();
817 SMDS_ElemIteratorPtr It = aFace->nodesIterator();
819 poly_nodes.push_back(static_cast<const SMDS_MeshNode *>(It->next()));
823 const SMDS_MeshElement* elem = GetMeshDS()->AddPolyhedralVolume(poly_nodes, quantities);
825 // Update Python script
826 TPythonDump() << "volID = " << this << ".AddPolyhedralVolumeByFaces( "
827 << IdsOfFaces << " )";
828 myMesh->GetMeshDS()->Modified();
830 return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0;
833 //=============================================================================
835 * \brief Bind a node to a vertex
836 * \param NodeID - node ID
837 * \param VertexID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
838 * \retval boolean - false if NodeID or VertexID is invalid
840 //=============================================================================
842 void SMESH_MeshEditor_i::SetNodeOnVertex(CORBA::Long NodeID, CORBA::Long VertexID)
843 throw (SALOME::SALOME_Exception)
845 Unexpect aCatch(SALOME_SalomeException);
847 SMESHDS_Mesh * mesh = GetMeshDS();
848 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
850 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
852 if ( mesh->MaxShapeIndex() < VertexID )
853 THROW_SALOME_CORBA_EXCEPTION("Invalid VertexID", SALOME::BAD_PARAM);
855 TopoDS_Shape shape = mesh->IndexToShape( VertexID );
856 if ( shape.ShapeType() != TopAbs_VERTEX )
857 THROW_SALOME_CORBA_EXCEPTION("Invalid VertexID", SALOME::BAD_PARAM);
859 mesh->SetNodeOnVertex( node, VertexID );
861 myMesh->SetIsModified( true );
864 //=============================================================================
866 * \brief Store node position on an edge
867 * \param NodeID - node ID
868 * \param EdgeID - edge ID available through GEOM_Object.GetSubShapeIndices()[0]
869 * \param paramOnEdge - parameter on edge where the node is located
870 * \retval boolean - false if any parameter is invalid
872 //=============================================================================
874 void SMESH_MeshEditor_i::SetNodeOnEdge(CORBA::Long NodeID, CORBA::Long EdgeID,
875 CORBA::Double paramOnEdge)
876 throw (SALOME::SALOME_Exception)
878 Unexpect aCatch(SALOME_SalomeException);
880 SMESHDS_Mesh * mesh = GetMeshDS();
881 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
883 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
885 if ( mesh->MaxShapeIndex() < EdgeID )
886 THROW_SALOME_CORBA_EXCEPTION("Invalid EdgeID", SALOME::BAD_PARAM);
888 TopoDS_Shape shape = mesh->IndexToShape( EdgeID );
889 if ( shape.ShapeType() != TopAbs_EDGE )
890 THROW_SALOME_CORBA_EXCEPTION("Invalid EdgeID", SALOME::BAD_PARAM);
893 BRep_Tool::Range( TopoDS::Edge( shape ), f,l);
894 if ( paramOnEdge < f || paramOnEdge > l )
895 THROW_SALOME_CORBA_EXCEPTION("Invalid paramOnEdge", SALOME::BAD_PARAM);
897 mesh->SetNodeOnEdge( node, EdgeID, paramOnEdge );
899 myMesh->SetIsModified( true );
902 //=============================================================================
904 * \brief Store node position on a face
905 * \param NodeID - node ID
906 * \param FaceID - face ID available through GEOM_Object.GetSubShapeIndices()[0]
907 * \param u - U parameter on face where the node is located
908 * \param v - V parameter on face where the node is located
909 * \retval boolean - false if any parameter is invalid
911 //=============================================================================
913 void SMESH_MeshEditor_i::SetNodeOnFace(CORBA::Long NodeID, CORBA::Long FaceID,
914 CORBA::Double u, CORBA::Double v)
915 throw (SALOME::SALOME_Exception)
917 Unexpect aCatch(SALOME_SalomeException);
919 SMESHDS_Mesh * mesh = GetMeshDS();
920 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
922 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
924 if ( mesh->MaxShapeIndex() < FaceID )
925 THROW_SALOME_CORBA_EXCEPTION("Invalid FaceID", SALOME::BAD_PARAM);
927 TopoDS_Shape shape = mesh->IndexToShape( FaceID );
928 if ( shape.ShapeType() != TopAbs_FACE )
929 THROW_SALOME_CORBA_EXCEPTION("Invalid FaceID", SALOME::BAD_PARAM);
931 BRepAdaptor_Surface surf( TopoDS::Face( shape ));
932 bool isOut = ( u < surf.FirstUParameter() ||
933 u > surf.LastUParameter() ||
934 v < surf.FirstVParameter() ||
935 v > surf.LastVParameter() );
939 MESSAGE ( "FACE " << FaceID << " (" << u << "," << v << ") out of "
940 << " u( " << surf.FirstUParameter()
941 << "," << surf.LastUParameter()
942 << ") v( " << surf.FirstVParameter()
943 << "," << surf.LastVParameter() << ")" );
945 THROW_SALOME_CORBA_EXCEPTION("Invalid UV", SALOME::BAD_PARAM);
948 mesh->SetNodeOnFace( node, FaceID, u, v );
949 myMesh->SetIsModified( true );
952 //=============================================================================
954 * \brief Bind a node to a solid
955 * \param NodeID - node ID
956 * \param SolidID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
957 * \retval boolean - false if NodeID or SolidID is invalid
959 //=============================================================================
961 void SMESH_MeshEditor_i::SetNodeInVolume(CORBA::Long NodeID, CORBA::Long SolidID)
962 throw (SALOME::SALOME_Exception)
964 Unexpect aCatch(SALOME_SalomeException);
966 SMESHDS_Mesh * mesh = GetMeshDS();
967 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
969 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
971 if ( mesh->MaxShapeIndex() < SolidID )
972 THROW_SALOME_CORBA_EXCEPTION("Invalid SolidID", SALOME::BAD_PARAM);
974 TopoDS_Shape shape = mesh->IndexToShape( SolidID );
975 if ( shape.ShapeType() != TopAbs_SOLID &&
976 shape.ShapeType() != TopAbs_SHELL)
977 THROW_SALOME_CORBA_EXCEPTION("Invalid SolidID", SALOME::BAD_PARAM);
979 mesh->SetNodeInVolume( node, SolidID );
981 // myMesh->SetIsModified( true ); - SetNodeInVolume() can't prevent re-compute, I believe
984 //=============================================================================
986 * \brief Bind an element to a shape
987 * \param ElementID - element ID
988 * \param ShapeID - shape ID available through GEOM_Object.GetSubShapeIndices()[0]
989 * \retval boolean - false if ElementID or ShapeID is invalid
991 //=============================================================================
993 void SMESH_MeshEditor_i::SetMeshElementOnShape(CORBA::Long ElementID,
995 throw (SALOME::SALOME_Exception)
997 Unexpect aCatch(SALOME_SalomeException);
999 SMESHDS_Mesh * mesh = GetMeshDS();
1000 SMDS_MeshElement* elem = const_cast<SMDS_MeshElement*>(mesh->FindElement(ElementID));
1002 THROW_SALOME_CORBA_EXCEPTION("Invalid ElementID", SALOME::BAD_PARAM);
1004 if ( mesh->MaxShapeIndex() < ShapeID )
1005 THROW_SALOME_CORBA_EXCEPTION("Invalid ShapeID", SALOME::BAD_PARAM);
1007 TopoDS_Shape shape = mesh->IndexToShape( ShapeID );
1008 if ( shape.ShapeType() != TopAbs_EDGE &&
1009 shape.ShapeType() != TopAbs_FACE &&
1010 shape.ShapeType() != TopAbs_SOLID &&
1011 shape.ShapeType() != TopAbs_SHELL )
1012 THROW_SALOME_CORBA_EXCEPTION("Invalid shape type", SALOME::BAD_PARAM);
1014 mesh->SetMeshElementOnShape( elem, ShapeID );
1016 myMesh->SetIsModified( true );
1019 //=============================================================================
1023 //=============================================================================
1025 CORBA::Boolean SMESH_MeshEditor_i::InverseDiag(CORBA::Long NodeID1,
1026 CORBA::Long NodeID2)
1030 const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
1031 const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
1035 // Update Python script
1036 TPythonDump() << "isDone = " << this << ".InverseDiag( "
1037 << NodeID1 << ", " << NodeID2 << " )";
1040 ::SMESH_MeshEditor aMeshEditor( myMesh );
1041 int ret = aMeshEditor.InverseDiag ( n1, n2 );
1042 myMesh->GetMeshDS()->Modified();
1043 myMesh->SetIsModified( true );
1047 //=============================================================================
1051 //=============================================================================
1053 CORBA::Boolean SMESH_MeshEditor_i::DeleteDiag(CORBA::Long NodeID1,
1054 CORBA::Long NodeID2)
1058 const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
1059 const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
1063 // Update Python script
1064 TPythonDump() << "isDone = " << this << ".DeleteDiag( "
1065 << NodeID1 << ", " << NodeID2 << " )";
1067 ::SMESH_MeshEditor aMeshEditor( myMesh );
1069 bool stat = aMeshEditor.DeleteDiag ( n1, n2 );
1071 myMesh->GetMeshDS()->Modified();
1073 myMesh->SetIsModified( true ); // issue 0020693
1075 storeResult(aMeshEditor);
1080 //=============================================================================
1084 //=============================================================================
1086 CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::long_array & IDsOfElements)
1090 ::SMESH_MeshEditor anEditor( myMesh );
1091 for (int i = 0; i < IDsOfElements.length(); i++)
1093 CORBA::Long index = IDsOfElements[i];
1094 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
1096 anEditor.Reorient( elem );
1098 // Update Python script
1099 TPythonDump() << "isDone = " << this << ".Reorient( " << IDsOfElements << " )";
1101 myMesh->GetMeshDS()->Modified();
1102 if ( IDsOfElements.length() )
1103 myMesh->SetIsModified( true ); // issue 0020693
1109 //=============================================================================
1113 //=============================================================================
1115 CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theObject)
1119 TPythonDump aTPythonDump; // suppress dump in Reorient()
1121 SMESH::long_array_var anElementsId = theObject->GetIDs();
1122 CORBA::Boolean isDone = Reorient(anElementsId);
1124 // Update Python script
1125 aTPythonDump << "isDone = " << this << ".ReorientObject( " << theObject << " )";
1130 //=============================================================================
1134 //=============================================================================
1135 CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfElements,
1136 SMESH::NumericalFunctor_ptr Criterion,
1137 CORBA::Double MaxAngle)
1141 SMESHDS_Mesh* aMesh = GetMeshDS();
1142 TIDSortedElemSet faces;
1143 arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
1145 SMESH::NumericalFunctor_i* aNumericalFunctor =
1146 dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
1147 SMESH::Controls::NumericalFunctorPtr aCrit;
1148 if ( !aNumericalFunctor )
1149 aCrit.reset( new SMESH::Controls::AspectRatio() );
1151 aCrit = aNumericalFunctor->GetNumericalFunctor();
1153 // Update Python script
1154 TPythonDump() << "isDone = " << this << ".TriToQuad( "
1155 << IDsOfElements << ", " << aNumericalFunctor << ", " << MaxAngle << " )";
1157 ::SMESH_MeshEditor anEditor( myMesh );
1159 bool stat = anEditor.TriToQuad( faces, aCrit, MaxAngle );
1160 myMesh->GetMeshDS()->Modified();
1162 myMesh->SetIsModified( true ); // issue 0020693
1164 storeResult(anEditor);
1170 //=============================================================================
1174 //=============================================================================
1175 CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr theObject,
1176 SMESH::NumericalFunctor_ptr Criterion,
1177 CORBA::Double MaxAngle)
1181 TPythonDump aTPythonDump; // suppress dump in TriToQuad()
1182 SMESH::long_array_var anElementsId = theObject->GetIDs();
1183 CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
1185 SMESH::NumericalFunctor_i* aNumericalFunctor =
1186 SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
1188 // Update Python script
1189 aTPythonDump << "isDone = " << this << ".TriToQuadObject("
1190 << theObject << ", " << aNumericalFunctor << ", " << MaxAngle << " )";
1196 //=============================================================================
1200 //=============================================================================
1201 CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array & IDsOfElements,
1202 SMESH::NumericalFunctor_ptr Criterion)
1206 SMESHDS_Mesh* aMesh = GetMeshDS();
1207 TIDSortedElemSet faces;
1208 arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
1210 SMESH::NumericalFunctor_i* aNumericalFunctor =
1211 dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
1212 SMESH::Controls::NumericalFunctorPtr aCrit;
1213 if ( !aNumericalFunctor )
1214 aCrit.reset( new SMESH::Controls::AspectRatio() );
1216 aCrit = aNumericalFunctor->GetNumericalFunctor();
1219 // Update Python script
1220 TPythonDump() << "isDone = " << this << ".QuadToTri( " << IDsOfElements << ", " << aNumericalFunctor << " )";
1222 ::SMESH_MeshEditor anEditor( myMesh );
1223 CORBA::Boolean stat = anEditor.QuadToTri( faces, aCrit );
1224 myMesh->GetMeshDS()->Modified();
1226 myMesh->SetIsModified( true ); // issue 0020693
1228 storeResult(anEditor);
1234 //=============================================================================
1238 //=============================================================================
1239 CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr theObject,
1240 SMESH::NumericalFunctor_ptr Criterion)
1244 TPythonDump aTPythonDump; // suppress dump in QuadToTri()
1246 SMESH::long_array_var anElementsId = theObject->GetIDs();
1247 CORBA::Boolean isDone = QuadToTri(anElementsId, Criterion);
1249 SMESH::NumericalFunctor_i* aNumericalFunctor =
1250 SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
1252 // Update Python script
1253 aTPythonDump << "isDone = " << this << ".QuadToTriObject( " << theObject << ", " << aNumericalFunctor << " )";
1259 //=============================================================================
1263 //=============================================================================
1264 CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfElements,
1265 CORBA::Boolean Diag13)
1269 SMESHDS_Mesh* aMesh = GetMeshDS();
1270 TIDSortedElemSet faces;
1271 arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
1273 // Update Python script
1274 TPythonDump() << "isDone = " << this << ".SplitQuad( "
1275 << IDsOfElements << ", " << Diag13 << " )";
1277 ::SMESH_MeshEditor anEditor( myMesh );
1278 CORBA::Boolean stat = anEditor.QuadToTri( faces, Diag13 );
1279 myMesh->GetMeshDS()->Modified();
1281 myMesh->SetIsModified( true ); // issue 0020693
1284 storeResult(anEditor);
1290 //=============================================================================
1294 //=============================================================================
1295 CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr theObject,
1296 CORBA::Boolean Diag13)
1300 TPythonDump aTPythonDump; // suppress dump in SplitQuad()
1302 SMESH::long_array_var anElementsId = theObject->GetIDs();
1303 CORBA::Boolean isDone = SplitQuad(anElementsId, Diag13);
1305 // Update Python script
1306 aTPythonDump << "isDone = " << this << ".SplitQuadObject( "
1307 << theObject << ", " << Diag13 << " )";
1313 //=============================================================================
1317 //=============================================================================
1318 CORBA::Long SMESH_MeshEditor_i::BestSplit (CORBA::Long IDOfQuad,
1319 SMESH::NumericalFunctor_ptr Criterion)
1323 const SMDS_MeshElement* quad = GetMeshDS()->FindElement(IDOfQuad);
1324 if (quad && quad->GetType() == SMDSAbs_Face && quad->NbNodes() == 4)
1326 SMESH::NumericalFunctor_i* aNumericalFunctor =
1327 dynamic_cast<SMESH::NumericalFunctor_i*>(SMESH_Gen_i::GetServant(Criterion).in());
1328 SMESH::Controls::NumericalFunctorPtr aCrit;
1329 if (aNumericalFunctor)
1330 aCrit = aNumericalFunctor->GetNumericalFunctor();
1332 aCrit.reset(new SMESH::Controls::AspectRatio());
1334 ::SMESH_MeshEditor anEditor (myMesh);
1335 return anEditor.BestSplit(quad, aCrit);
1340 //================================================================================
1342 * \brief Split volumic elements into tetrahedrons
1344 //================================================================================
1346 void SMESH_MeshEditor_i::SplitVolumesIntoTetra (SMESH::SMESH_IDSource_ptr elems,
1347 CORBA::Short methodFlags)
1348 throw (SALOME::SALOME_Exception)
1350 Unexpect aCatch(SALOME_SalomeException);
1354 SMESH::long_array_var anElementsId = elems->GetIDs();
1355 TIDSortedElemSet elemSet;
1356 arrayToSet( anElementsId, GetMeshDS(), elemSet, SMDSAbs_Volume );
1358 ::SMESH_MeshEditor anEditor (myMesh);
1359 anEditor.SplitVolumesIntoTetra( elemSet, int( methodFlags ));
1360 myMesh->GetMeshDS()->Modified();
1362 storeResult(anEditor);
1364 // if ( myLastCreatedElems.length() ) - it does not influence Compute()
1365 // myMesh->SetIsModified( true ); // issue 0020693
1367 TPythonDump() << this << ".SplitVolumesIntoTetra( "
1368 << elems << ", " << methodFlags << " )";
1371 //=======================================================================
1374 //=======================================================================
1377 SMESH_MeshEditor_i::Smooth(const SMESH::long_array & IDsOfElements,
1378 const SMESH::long_array & IDsOfFixedNodes,
1379 CORBA::Long MaxNbOfIterations,
1380 CORBA::Double MaxAspectRatio,
1381 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1383 return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations,
1384 MaxAspectRatio, Method, false );
1388 //=======================================================================
1389 //function : SmoothParametric
1391 //=======================================================================
1394 SMESH_MeshEditor_i::SmoothParametric(const SMESH::long_array & IDsOfElements,
1395 const SMESH::long_array & IDsOfFixedNodes,
1396 CORBA::Long MaxNbOfIterations,
1397 CORBA::Double MaxAspectRatio,
1398 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1400 return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations,
1401 MaxAspectRatio, Method, true );
1405 //=======================================================================
1406 //function : SmoothObject
1408 //=======================================================================
1411 SMESH_MeshEditor_i::SmoothObject(SMESH::SMESH_IDSource_ptr theObject,
1412 const SMESH::long_array & IDsOfFixedNodes,
1413 CORBA::Long MaxNbOfIterations,
1414 CORBA::Double MaxAspectRatio,
1415 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1417 return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations,
1418 MaxAspectRatio, Method, false);
1422 //=======================================================================
1423 //function : SmoothParametricObject
1425 //=======================================================================
1428 SMESH_MeshEditor_i::SmoothParametricObject(SMESH::SMESH_IDSource_ptr theObject,
1429 const SMESH::long_array & IDsOfFixedNodes,
1430 CORBA::Long MaxNbOfIterations,
1431 CORBA::Double MaxAspectRatio,
1432 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1434 return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations,
1435 MaxAspectRatio, Method, true);
1439 //=============================================================================
1443 //=============================================================================
1446 SMESH_MeshEditor_i::smooth(const SMESH::long_array & IDsOfElements,
1447 const SMESH::long_array & IDsOfFixedNodes,
1448 CORBA::Long MaxNbOfIterations,
1449 CORBA::Double MaxAspectRatio,
1450 SMESH::SMESH_MeshEditor::Smooth_Method Method,
1455 SMESHDS_Mesh* aMesh = GetMeshDS();
1457 TIDSortedElemSet elements;
1458 arrayToSet(IDsOfElements, aMesh, elements, SMDSAbs_Face);
1460 set<const SMDS_MeshNode*> fixedNodes;
1461 for (int i = 0; i < IDsOfFixedNodes.length(); i++) {
1462 CORBA::Long index = IDsOfFixedNodes[i];
1463 const SMDS_MeshNode * node = aMesh->FindNode(index);
1465 fixedNodes.insert( node );
1467 ::SMESH_MeshEditor::SmoothMethod method = ::SMESH_MeshEditor::LAPLACIAN;
1468 if ( Method != SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH )
1469 method = ::SMESH_MeshEditor::CENTROIDAL;
1471 ::SMESH_MeshEditor anEditor( myMesh );
1472 anEditor.Smooth(elements, fixedNodes, method,
1473 MaxNbOfIterations, MaxAspectRatio, IsParametric );
1475 myMesh->GetMeshDS()->Modified();
1476 myMesh->SetIsModified( true ); // issue 0020693
1478 storeResult(anEditor);
1480 // Update Python script
1481 TPythonDump() << "isDone = " << this << "."
1482 << (IsParametric ? "SmoothParametric( " : "Smooth( ")
1483 << IDsOfElements << ", " << IDsOfFixedNodes << ", "
1484 << MaxNbOfIterations << ", " << MaxAspectRatio << ", "
1485 << "SMESH.SMESH_MeshEditor."
1486 << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
1487 "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
1493 //=============================================================================
1497 //=============================================================================
1500 SMESH_MeshEditor_i::smoothObject(SMESH::SMESH_IDSource_ptr theObject,
1501 const SMESH::long_array & IDsOfFixedNodes,
1502 CORBA::Long MaxNbOfIterations,
1503 CORBA::Double MaxAspectRatio,
1504 SMESH::SMESH_MeshEditor::Smooth_Method Method,
1509 TPythonDump aTPythonDump; // suppress dump in smooth()
1511 SMESH::long_array_var anElementsId = theObject->GetIDs();
1512 CORBA::Boolean isDone = smooth (anElementsId, IDsOfFixedNodes, MaxNbOfIterations,
1513 MaxAspectRatio, Method, IsParametric);
1515 // Update Python script
1516 aTPythonDump << "isDone = " << this << "."
1517 << (IsParametric ? "SmoothParametricObject( " : "SmoothObject( ")
1518 << theObject << ", " << IDsOfFixedNodes << ", "
1519 << MaxNbOfIterations << ", " << MaxAspectRatio << ", "
1520 << "SMESH.SMESH_MeshEditor."
1521 << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
1522 "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
1528 //=============================================================================
1532 //=============================================================================
1534 void SMESH_MeshEditor_i::RenumberNodes()
1536 // Update Python script
1537 TPythonDump() << this << ".RenumberNodes()";
1539 GetMeshDS()->Renumber( true );
1543 //=============================================================================
1547 //=============================================================================
1549 void SMESH_MeshEditor_i::RenumberElements()
1551 // Update Python script
1552 TPythonDump() << this << ".RenumberElements()";
1554 GetMeshDS()->Renumber( false );
1557 //=======================================================================
1559 * \brief Return groups by their IDs
1561 //=======================================================================
1563 SMESH::ListOfGroups* SMESH_MeshEditor_i::getGroups(const std::list<int>* groupIDs)
1567 myMesh_i->CreateGroupServants();
1568 return myMesh_i->GetGroups( *groupIDs );
1571 //=======================================================================
1572 //function : rotationSweep
1574 //=======================================================================
1576 SMESH::ListOfGroups*
1577 SMESH_MeshEditor_i::rotationSweep(const SMESH::long_array & theIDsOfElements,
1578 const SMESH::AxisStruct & theAxis,
1579 CORBA::Double theAngleInRadians,
1580 CORBA::Long theNbOfSteps,
1581 CORBA::Double theTolerance,
1582 const bool theMakeGroups,
1583 const SMDSAbs_ElementType theElementType)
1587 TIDSortedElemSet inElements, copyElements;
1588 arrayToSet(theIDsOfElements, GetMeshDS(), inElements, theElementType);
1590 TIDSortedElemSet* workElements = & inElements;
1591 TPreviewMesh tmpMesh( SMDSAbs_Face );
1592 SMESH_Mesh* mesh = 0;
1593 bool makeWalls=true;
1594 if ( myPreviewMode )
1596 SMDSAbs_ElementType select = SMDSAbs_All, avoid = SMDSAbs_Volume;
1597 tmpMesh.Copy( inElements, copyElements, select, avoid );
1599 workElements = & copyElements;
1600 //makeWalls = false;
1607 gp_Ax1 Ax1 (gp_Pnt( theAxis.x, theAxis.y, theAxis.z ),
1608 gp_Vec( theAxis.vx, theAxis.vy, theAxis.vz ));
1610 ::SMESH_MeshEditor anEditor( mesh );
1611 ::SMESH_MeshEditor::PGroupIDs groupIds =
1612 anEditor.RotationSweep (*workElements, Ax1, theAngleInRadians,
1613 theNbOfSteps, theTolerance, theMakeGroups, makeWalls);
1614 storeResult(anEditor);
1615 myMesh->GetMeshDS()->Modified();
1617 // myMesh->SetIsModified( true ); -- it does not influence Compute()
1619 return theMakeGroups ? getGroups(groupIds.get()) : 0;
1622 //=======================================================================
1623 //function : RotationSweep
1625 //=======================================================================
1627 void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElements,
1628 const SMESH::AxisStruct & theAxis,
1629 CORBA::Double theAngleInRadians,
1630 CORBA::Long theNbOfSteps,
1631 CORBA::Double theTolerance)
1633 if ( !myPreviewMode ) {
1634 TPythonDump() << this << ".RotationSweep( "
1635 << theIDsOfElements << ", "
1637 << theAngleInRadians << ", "
1638 << theNbOfSteps << ", "
1639 << theTolerance << " )";
1641 rotationSweep(theIDsOfElements,
1649 //=======================================================================
1650 //function : RotationSweepMakeGroups
1652 //=======================================================================
1654 SMESH::ListOfGroups*
1655 SMESH_MeshEditor_i::RotationSweepMakeGroups(const SMESH::long_array& theIDsOfElements,
1656 const SMESH::AxisStruct& theAxis,
1657 CORBA::Double theAngleInRadians,
1658 CORBA::Long theNbOfSteps,
1659 CORBA::Double theTolerance)
1661 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
1663 SMESH::ListOfGroups *aGroups = rotationSweep(theIDsOfElements,
1669 if (!myPreviewMode) {
1670 DumpGroupsList(aPythonDump, aGroups);
1671 aPythonDump << this << ".RotationSweepMakeGroups( "
1672 << theIDsOfElements << ", "
1674 << theAngleInRadians << ", "
1675 << theNbOfSteps << ", "
1676 << theTolerance << " )";
1681 //=======================================================================
1682 //function : RotationSweepObject
1684 //=======================================================================
1686 void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject,
1687 const SMESH::AxisStruct & theAxis,
1688 CORBA::Double theAngleInRadians,
1689 CORBA::Long theNbOfSteps,
1690 CORBA::Double theTolerance)
1692 if ( !myPreviewMode ) {
1693 TPythonDump() << this << ".RotationSweepObject( "
1694 << theObject << ", "
1696 << theAngleInRadians << ", "
1697 << theNbOfSteps << ", "
1698 << theTolerance << " )";
1700 SMESH::long_array_var anElementsId = theObject->GetIDs();
1701 rotationSweep(anElementsId,
1709 //=======================================================================
1710 //function : RotationSweepObject1D
1712 //=======================================================================
1714 void SMESH_MeshEditor_i::RotationSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
1715 const SMESH::AxisStruct & theAxis,
1716 CORBA::Double theAngleInRadians,
1717 CORBA::Long theNbOfSteps,
1718 CORBA::Double theTolerance)
1720 if ( !myPreviewMode ) {
1721 TPythonDump() << this << ".RotationSweepObject1D( "
1722 << theObject << ", "
1724 << theAngleInRadians << ", "
1725 << theNbOfSteps << ", "
1726 << theTolerance << " )";
1728 SMESH::long_array_var anElementsId = theObject->GetIDs();
1729 rotationSweep(anElementsId,
1738 //=======================================================================
1739 //function : RotationSweepObject2D
1741 //=======================================================================
1743 void SMESH_MeshEditor_i::RotationSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
1744 const SMESH::AxisStruct & theAxis,
1745 CORBA::Double theAngleInRadians,
1746 CORBA::Long theNbOfSteps,
1747 CORBA::Double theTolerance)
1749 if ( !myPreviewMode ) {
1750 TPythonDump() << this << ".RotationSweepObject2D( "
1751 << theObject << ", "
1753 << theAngleInRadians << ", "
1754 << theNbOfSteps << ", "
1755 << theTolerance << " )";
1757 SMESH::long_array_var anElementsId = theObject->GetIDs();
1758 rotationSweep(anElementsId,
1767 //=======================================================================
1768 //function : RotationSweepObjectMakeGroups
1770 //=======================================================================
1772 SMESH::ListOfGroups*
1773 SMESH_MeshEditor_i::RotationSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1774 const SMESH::AxisStruct& theAxis,
1775 CORBA::Double theAngleInRadians,
1776 CORBA::Long theNbOfSteps,
1777 CORBA::Double theTolerance)
1779 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
1781 SMESH::long_array_var anElementsId = theObject->GetIDs();
1782 SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
1788 if (!myPreviewMode) {
1789 DumpGroupsList(aPythonDump, aGroups);
1790 aPythonDump << this << ".RotationSweepObjectMakeGroups( "
1791 << theObject << ", "
1793 << theAngleInRadians << ", "
1794 << theNbOfSteps << ", "
1795 << theTolerance << " )";
1800 //=======================================================================
1801 //function : RotationSweepObject1DMakeGroups
1803 //=======================================================================
1805 SMESH::ListOfGroups*
1806 SMESH_MeshEditor_i::RotationSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1807 const SMESH::AxisStruct& theAxis,
1808 CORBA::Double theAngleInRadians,
1809 CORBA::Long theNbOfSteps,
1810 CORBA::Double theTolerance)
1812 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
1814 SMESH::long_array_var anElementsId = theObject->GetIDs();
1815 SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
1822 if (!myPreviewMode) {
1823 DumpGroupsList(aPythonDump, aGroups);
1824 aPythonDump << this << ".RotationSweepObject1DMakeGroups( "
1825 << theObject << ", "
1827 << theAngleInRadians << ", "
1828 << theNbOfSteps << ", "
1829 << theTolerance << " )";
1834 //=======================================================================
1835 //function : RotationSweepObject2DMakeGroups
1837 //=======================================================================
1839 SMESH::ListOfGroups*
1840 SMESH_MeshEditor_i::RotationSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1841 const SMESH::AxisStruct& theAxis,
1842 CORBA::Double theAngleInRadians,
1843 CORBA::Long theNbOfSteps,
1844 CORBA::Double theTolerance)
1846 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
1848 SMESH::long_array_var anElementsId = theObject->GetIDs();
1849 SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
1856 if (!myPreviewMode) {
1857 DumpGroupsList(aPythonDump, aGroups);
1858 aPythonDump << this << ".RotationSweepObject2DMakeGroups( "
1859 << theObject << ", "
1861 << theAngleInRadians << ", "
1862 << theNbOfSteps << ", "
1863 << theTolerance << " )";
1869 //=======================================================================
1870 //function : extrusionSweep
1872 //=======================================================================
1874 SMESH::ListOfGroups*
1875 SMESH_MeshEditor_i::extrusionSweep(const SMESH::long_array & theIDsOfElements,
1876 const SMESH::DirStruct & theStepVector,
1877 CORBA::Long theNbOfSteps,
1879 const SMDSAbs_ElementType theElementType)
1887 TIDSortedElemSet elements, copyElements;
1888 arrayToSet(theIDsOfElements, GetMeshDS(), elements, theElementType);
1890 const SMESH::PointStruct * P = &theStepVector.PS;
1891 gp_Vec stepVec( P->x, P->y, P->z );
1893 TIDSortedElemSet* workElements = & elements;
1895 SMDSAbs_ElementType aType = SMDSAbs_Face;
1896 ::SMESH_MeshEditor::ExtrusionFlags aFlag = ::SMESH_MeshEditor::ExtrusionFlags::EXTRUSION_FLAG_BOUNDARY;
1897 if (theElementType == SMDSAbs_Node)
1899 aType = SMDSAbs_Edge;
1900 aFlag = ::SMESH_MeshEditor::ExtrusionFlags::EXTRUSION_FLAG_SEW;
1902 TPreviewMesh tmpMesh( aType );
1903 SMESH_Mesh* mesh = myMesh;
1905 if ( myPreviewMode ) {
1906 SMDSAbs_ElementType select = SMDSAbs_All, avoid = SMDSAbs_Volume;
1907 tmpMesh.Copy( elements, copyElements, select, avoid );
1909 workElements = & copyElements;
1910 theMakeGroups = false;
1913 TElemOfElemListMap aHystory;
1914 ::SMESH_MeshEditor anEditor( mesh );
1915 ::SMESH_MeshEditor::PGroupIDs groupIds =
1916 anEditor.ExtrusionSweep (*workElements, stepVec, theNbOfSteps, aHystory, theMakeGroups, aFlag);
1918 myMesh->GetMeshDS()->Modified();
1919 storeResult(anEditor);
1921 return theMakeGroups ? getGroups(groupIds.get()) : 0;
1923 } catch(Standard_Failure) {
1924 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1925 INFOS( "SMESH_MeshEditor_i::ExtrusionSweep fails - "<< aFail->GetMessageString() );
1930 //=======================================================================
1931 //function : ExtrusionSweep
1933 //=======================================================================
1935 void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElements,
1936 const SMESH::DirStruct & theStepVector,
1937 CORBA::Long theNbOfSteps)
1939 extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false );
1940 if (!myPreviewMode) {
1941 TPythonDump() << this << ".ExtrusionSweep( "
1942 << theIDsOfElements << ", " << theStepVector <<", " << theNbOfSteps << " )";
1946 //=======================================================================
1947 //function : ExtrusionSweep0D
1949 //=======================================================================
1951 void SMESH_MeshEditor_i::ExtrusionSweep0D(const SMESH::long_array & theIDsOfElements,
1952 const SMESH::DirStruct & theStepVector,
1953 CORBA::Long theNbOfSteps)
1955 extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false, SMDSAbs_Node );
1956 if (!myPreviewMode) {
1957 TPythonDump() << this << ".ExtrusionSweep0D( "
1958 << theIDsOfElements << ", " << theStepVector <<", " << theNbOfSteps << " )";
1962 //=======================================================================
1963 //function : ExtrusionSweepObject
1965 //=======================================================================
1967 void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObject,
1968 const SMESH::DirStruct & theStepVector,
1969 CORBA::Long theNbOfSteps)
1971 SMESH::long_array_var anElementsId = theObject->GetIDs();
1972 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false );
1973 if (!myPreviewMode) {
1974 TPythonDump() << this << ".ExtrusionSweepObject( "
1975 << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
1979 //=======================================================================
1980 //function : ExtrusionSweepObject0D
1982 //=======================================================================
1984 void SMESH_MeshEditor_i::ExtrusionSweepObject0D(SMESH::SMESH_IDSource_ptr theObject,
1985 const SMESH::DirStruct & theStepVector,
1986 CORBA::Long theNbOfSteps)
1988 SMESH::long_array_var anElementsId = theObject->GetIDs();
1989 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Node );
1990 if ( !myPreviewMode ) {
1991 TPythonDump() << this << ".ExtrusionSweepObject0D( "
1992 << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
1996 //=======================================================================
1997 //function : ExtrusionSweepObject1D
1999 //=======================================================================
2001 void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
2002 const SMESH::DirStruct & theStepVector,
2003 CORBA::Long theNbOfSteps)
2005 SMESH::long_array_var anElementsId = theObject->GetIDs();
2006 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Edge );
2007 if ( !myPreviewMode ) {
2008 TPythonDump() << this << ".ExtrusionSweepObject1D( "
2009 << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
2013 //=======================================================================
2014 //function : ExtrusionSweepObject2D
2016 //=======================================================================
2018 void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
2019 const SMESH::DirStruct & theStepVector,
2020 CORBA::Long theNbOfSteps)
2022 SMESH::long_array_var anElementsId = theObject->GetIDs();
2023 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Face );
2024 if ( !myPreviewMode ) {
2025 TPythonDump() << this << ".ExtrusionSweepObject2D( "
2026 << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
2030 //=======================================================================
2031 //function : ExtrusionSweepMakeGroups
2033 //=======================================================================
2035 SMESH::ListOfGroups*
2036 SMESH_MeshEditor_i::ExtrusionSweepMakeGroups(const SMESH::long_array& theIDsOfElements,
2037 const SMESH::DirStruct& theStepVector,
2038 CORBA::Long theNbOfSteps)
2040 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2042 SMESH::ListOfGroups* aGroups = extrusionSweep(theIDsOfElements, theStepVector, theNbOfSteps, true);
2044 if (!myPreviewMode) {
2045 DumpGroupsList(aPythonDump, aGroups);
2046 aPythonDump << this << ".ExtrusionSweepMakeGroups( " << theIDsOfElements
2047 << ", " << theStepVector <<", " << theNbOfSteps << " )";
2052 //=======================================================================
2053 //function : ExtrusionSweepMakeGroups0D
2055 //=======================================================================
2057 SMESH::ListOfGroups*
2058 SMESH_MeshEditor_i::ExtrusionSweepMakeGroups0D(const SMESH::long_array& theIDsOfElements,
2059 const SMESH::DirStruct& theStepVector,
2060 CORBA::Long theNbOfSteps)
2062 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2064 SMESH::ListOfGroups* aGroups = extrusionSweep(theIDsOfElements, theStepVector, theNbOfSteps, true,SMDSAbs_Node);
2066 if (!myPreviewMode) {
2067 DumpGroupsList(aPythonDump, aGroups);
2068 aPythonDump << this << ".ExtrusionSweepMakeGroups0D( " << theIDsOfElements
2069 << ", " << theStepVector <<", " << theNbOfSteps << " )";
2074 //=======================================================================
2075 //function : ExtrusionSweepObjectMakeGroups
2077 //=======================================================================
2079 SMESH::ListOfGroups*
2080 SMESH_MeshEditor_i::ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2081 const SMESH::DirStruct& theStepVector,
2082 CORBA::Long theNbOfSteps)
2084 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2086 SMESH::long_array_var anElementsId = theObject->GetIDs();
2087 SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector, theNbOfSteps, true);
2089 if (!myPreviewMode) {
2090 DumpGroupsList(aPythonDump, aGroups);
2091 aPythonDump << this << ".ExtrusionSweepObjectMakeGroups( " << theObject
2092 << ", " << theStepVector << ", " << theNbOfSteps << " )";
2097 //=======================================================================
2098 //function : ExtrusionSweepObject0DMakeGroups
2100 //=======================================================================
2102 SMESH::ListOfGroups*
2103 SMESH_MeshEditor_i::ExtrusionSweepObject0DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2104 const SMESH::DirStruct& theStepVector,
2105 CORBA::Long theNbOfSteps)
2107 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2109 SMESH::long_array_var anElementsId = theObject->GetIDs();
2110 SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector,
2111 theNbOfSteps, true, SMDSAbs_Node);
2112 if (!myPreviewMode) {
2113 DumpGroupsList(aPythonDump, aGroups);
2114 aPythonDump << this << ".ExtrusionSweepObject0DMakeGroups( " << theObject
2115 << ", " << theStepVector << ", " << theNbOfSteps << " )";
2120 //=======================================================================
2121 //function : ExtrusionSweepObject1DMakeGroups
2123 //=======================================================================
2125 SMESH::ListOfGroups*
2126 SMESH_MeshEditor_i::ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2127 const SMESH::DirStruct& theStepVector,
2128 CORBA::Long theNbOfSteps)
2130 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2132 SMESH::long_array_var anElementsId = theObject->GetIDs();
2133 SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector,
2134 theNbOfSteps, true, SMDSAbs_Edge);
2135 if (!myPreviewMode) {
2136 DumpGroupsList(aPythonDump, aGroups);
2137 aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( " << theObject
2138 << ", " << theStepVector << ", " << theNbOfSteps << " )";
2143 //=======================================================================
2144 //function : ExtrusionSweepObject2DMakeGroups
2146 //=======================================================================
2148 SMESH::ListOfGroups*
2149 SMESH_MeshEditor_i::ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2150 const SMESH::DirStruct& theStepVector,
2151 CORBA::Long theNbOfSteps)
2153 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2155 SMESH::long_array_var anElementsId = theObject->GetIDs();
2156 SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector,
2157 theNbOfSteps, true, SMDSAbs_Face);
2158 if (!myPreviewMode) {
2159 DumpGroupsList(aPythonDump, aGroups);
2160 aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( " << theObject
2161 << ", " << theStepVector << ", " << theNbOfSteps << " )";
2167 //=======================================================================
2168 //function : advancedExtrusion
2170 //=======================================================================
2172 SMESH::ListOfGroups*
2173 SMESH_MeshEditor_i::advancedExtrusion(const SMESH::long_array & theIDsOfElements,
2174 const SMESH::DirStruct & theStepVector,
2175 CORBA::Long theNbOfSteps,
2176 CORBA::Long theExtrFlags,
2177 CORBA::Double theSewTolerance,
2178 const bool theMakeGroups)
2182 TIDSortedElemSet elements;
2183 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
2185 const SMESH::PointStruct * P = &theStepVector.PS;
2186 gp_Vec stepVec( P->x, P->y, P->z );
2188 ::SMESH_MeshEditor anEditor( myMesh );
2189 TElemOfElemListMap aHystory;
2190 ::SMESH_MeshEditor::PGroupIDs groupIds =
2191 anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory,
2192 theMakeGroups, theExtrFlags, theSewTolerance);
2193 storeResult(anEditor);
2195 return theMakeGroups ? getGroups(groupIds.get()) : 0;
2198 //=======================================================================
2199 //function : AdvancedExtrusion
2201 //=======================================================================
2203 void SMESH_MeshEditor_i::AdvancedExtrusion(const SMESH::long_array & theIDsOfElements,
2204 const SMESH::DirStruct & theStepVector,
2205 CORBA::Long theNbOfSteps,
2206 CORBA::Long theExtrFlags,
2207 CORBA::Double theSewTolerance)
2209 if ( !myPreviewMode ) {
2210 TPythonDump() << "stepVector = " << theStepVector;
2211 TPythonDump() << this << ".AdvancedExtrusion("
2214 << theNbOfSteps << ","
2215 << theExtrFlags << ", "
2216 << theSewTolerance << " )";
2218 advancedExtrusion( theIDsOfElements,
2226 //=======================================================================
2227 //function : AdvancedExtrusionMakeGroups
2229 //=======================================================================
2230 SMESH::ListOfGroups*
2231 SMESH_MeshEditor_i::AdvancedExtrusionMakeGroups(const SMESH::long_array& theIDsOfElements,
2232 const SMESH::DirStruct& theStepVector,
2233 CORBA::Long theNbOfSteps,
2234 CORBA::Long theExtrFlags,
2235 CORBA::Double theSewTolerance)
2237 if (!myPreviewMode) {
2238 TPythonDump() << "stepVector = " << theStepVector;
2240 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2242 SMESH::ListOfGroups * aGroups = advancedExtrusion( theIDsOfElements,
2249 if (!myPreviewMode) {
2250 DumpGroupsList(aPythonDump, aGroups);
2251 aPythonDump << this << ".AdvancedExtrusionMakeGroups("
2254 << theNbOfSteps << ","
2255 << theExtrFlags << ", "
2256 << theSewTolerance << " )";
2262 //================================================================================
2264 * \brief Convert extrusion error to IDL enum
2266 //================================================================================
2268 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
2270 static SMESH::SMESH_MeshEditor::Extrusion_Error convExtrError( const::SMESH_MeshEditor::Extrusion_Error e )
2274 RETCASE( EXTR_NO_ELEMENTS );
2275 RETCASE( EXTR_PATH_NOT_EDGE );
2276 RETCASE( EXTR_BAD_PATH_SHAPE );
2277 RETCASE( EXTR_BAD_STARTING_NODE );
2278 RETCASE( EXTR_BAD_ANGLES_NUMBER );
2279 RETCASE( EXTR_CANT_GET_TANGENT );
2281 return SMESH::SMESH_MeshEditor::EXTR_OK;
2285 //=======================================================================
2286 //function : extrusionAlongPath
2288 //=======================================================================
2289 SMESH::ListOfGroups*
2290 SMESH_MeshEditor_i::extrusionAlongPath(const SMESH::long_array & theIDsOfElements,
2291 SMESH::SMESH_Mesh_ptr thePathMesh,
2292 GEOM::GEOM_Object_ptr thePathShape,
2293 CORBA::Long theNodeStart,
2294 CORBA::Boolean theHasAngles,
2295 const SMESH::double_array & theAngles,
2296 CORBA::Boolean theHasRefPoint,
2297 const SMESH::PointStruct & theRefPoint,
2298 const bool theMakeGroups,
2299 SMESH::SMESH_MeshEditor::Extrusion_Error & theError,
2300 const SMDSAbs_ElementType theElementType)
2302 MESSAGE("extrusionAlongPath");
2305 if ( thePathMesh->_is_nil() || thePathShape->_is_nil() ) {
2306 theError = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
2309 SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( thePathMesh );
2311 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
2312 SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
2314 if ( !aSubMesh || !aSubMesh->GetSubMeshDS()) {
2315 theError = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
2319 SMDS_MeshNode* nodeStart = (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(theNodeStart);
2321 theError = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
2325 TIDSortedElemSet elements;
2326 arrayToSet(theIDsOfElements, GetMeshDS(), elements, theElementType);
2328 list<double> angles;
2329 for (int i = 0; i < theAngles.length(); i++) {
2330 angles.push_back( theAngles[i] );
2333 gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z );
2335 int nbOldGroups = myMesh->NbGroup();
2337 ::SMESH_MeshEditor anEditor( myMesh );
2338 ::SMESH_MeshEditor::Extrusion_Error error =
2339 anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart,
2340 theHasAngles, angles, false,
2341 theHasRefPoint, refPnt, theMakeGroups );
2342 myMesh->GetMeshDS()->Modified();
2343 storeResult(anEditor);
2344 theError = convExtrError( error );
2346 if ( theMakeGroups ) {
2347 list<int> groupIDs = myMesh->GetGroupIds();
2348 list<int>::iterator newBegin = groupIDs.begin();
2349 std::advance( newBegin, nbOldGroups ); // skip old groups
2350 groupIDs.erase( groupIDs.begin(), newBegin );
2351 return getGroups( & groupIDs );
2357 //=======================================================================
2358 //function : extrusionAlongPathX
2360 //=======================================================================
2361 SMESH::ListOfGroups*
2362 SMESH_MeshEditor_i::extrusionAlongPathX(const SMESH::long_array & IDsOfElements,
2363 SMESH::SMESH_IDSource_ptr Path,
2364 CORBA::Long NodeStart,
2365 CORBA::Boolean HasAngles,
2366 const SMESH::double_array& Angles,
2367 CORBA::Boolean LinearVariation,
2368 CORBA::Boolean HasRefPoint,
2369 const SMESH::PointStruct& RefPoint,
2371 const SMDSAbs_ElementType ElementType,
2372 SMESH::SMESH_MeshEditor::Extrusion_Error & Error)
2374 SMESH::ListOfGroups* EmptyGr = new SMESH::ListOfGroups;
2378 list<double> angles;
2379 for (int i = 0; i < Angles.length(); i++) {
2380 angles.push_back( Angles[i] );
2382 gp_Pnt refPnt( RefPoint.x, RefPoint.y, RefPoint.z );
2383 int nbOldGroups = myMesh->NbGroup();
2385 if ( Path->_is_nil() ) {
2386 Error = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
2390 TIDSortedElemSet elements, copyElements;
2391 arrayToSet(IDsOfElements, GetMeshDS(), elements, ElementType);
2393 TIDSortedElemSet* workElements = &elements;
2394 TPreviewMesh tmpMesh( SMDSAbs_Face );
2395 SMESH_Mesh* mesh = myMesh;
2397 if ( myPreviewMode )
2399 SMDSAbs_ElementType select = SMDSAbs_All, avoid = SMDSAbs_Volume;
2400 tmpMesh.Copy( elements, copyElements, select, avoid );
2402 workElements = & copyElements;
2406 ::SMESH_MeshEditor anEditor( mesh );
2407 ::SMESH_MeshEditor::Extrusion_Error error;
2409 if ( SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( Path ))
2412 SMDS_MeshNode* aNodeStart =
2413 (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(NodeStart);
2414 if ( !aNodeStart ) {
2415 Error = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
2418 error = anEditor.ExtrusionAlongTrack( *workElements, &(aMeshImp->GetImpl()), aNodeStart,
2419 HasAngles, angles, LinearVariation,
2420 HasRefPoint, refPnt, MakeGroups );
2421 myMesh->GetMeshDS()->Modified();
2423 else if ( SMESH_subMesh_i* aSubMeshImp = SMESH::DownCast<SMESH_subMesh_i*>( Path ))
2426 SMESH::SMESH_Mesh_ptr aPathMesh = aSubMeshImp->GetFather();
2427 aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( aPathMesh );
2428 SMDS_MeshNode* aNodeStart =
2429 (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(NodeStart);
2430 if ( !aNodeStart ) {
2431 Error = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
2434 SMESH_subMesh* aSubMesh =
2435 aMeshImp->GetImpl().GetSubMeshContaining(aSubMeshImp->GetId());
2436 error = anEditor.ExtrusionAlongTrack( *workElements, aSubMesh, aNodeStart,
2437 HasAngles, angles, LinearVariation,
2438 HasRefPoint, refPnt, MakeGroups );
2439 myMesh->GetMeshDS()->Modified();
2441 else if ( SMESH::DownCast<SMESH_Group_i*>( Path ))
2443 // path as group of 1D elements
2449 Error = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
2453 storeResult(anEditor);
2454 Error = convExtrError( error );
2457 list<int> groupIDs = myMesh->GetGroupIds();
2458 list<int>::iterator newBegin = groupIDs.begin();
2459 std::advance( newBegin, nbOldGroups ); // skip old groups
2460 groupIDs.erase( groupIDs.begin(), newBegin );
2461 return getGroups( & groupIDs );
2467 //=======================================================================
2468 //function : ExtrusionAlongPath
2470 //=======================================================================
2471 SMESH::SMESH_MeshEditor::Extrusion_Error
2472 SMESH_MeshEditor_i::ExtrusionAlongPath(const SMESH::long_array & theIDsOfElements,
2473 SMESH::SMESH_Mesh_ptr thePathMesh,
2474 GEOM::GEOM_Object_ptr thePathShape,
2475 CORBA::Long theNodeStart,
2476 CORBA::Boolean theHasAngles,
2477 const SMESH::double_array & theAngles,
2478 CORBA::Boolean theHasRefPoint,
2479 const SMESH::PointStruct & theRefPoint)
2481 MESSAGE("ExtrusionAlongPath");
2482 if ( !myPreviewMode ) {
2483 TPythonDump() << "error = " << this << ".ExtrusionAlongPath( "
2484 << theIDsOfElements << ", "
2485 << thePathMesh << ", "
2486 << thePathShape << ", "
2487 << theNodeStart << ", "
2488 << theHasAngles << ", "
2489 << theAngles << ", "
2490 << theHasRefPoint << ", "
2491 << "SMESH.PointStruct( "
2492 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2493 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2494 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2496 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
2497 extrusionAlongPath( theIDsOfElements,
2510 //=======================================================================
2511 //function : ExtrusionAlongPathObject
2513 //=======================================================================
2514 SMESH::SMESH_MeshEditor::Extrusion_Error
2515 SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject,
2516 SMESH::SMESH_Mesh_ptr thePathMesh,
2517 GEOM::GEOM_Object_ptr thePathShape,
2518 CORBA::Long theNodeStart,
2519 CORBA::Boolean theHasAngles,
2520 const SMESH::double_array & theAngles,
2521 CORBA::Boolean theHasRefPoint,
2522 const SMESH::PointStruct & theRefPoint)
2524 if ( !myPreviewMode ) {
2525 TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject( "
2526 << theObject << ", "
2527 << thePathMesh << ", "
2528 << thePathShape << ", "
2529 << theNodeStart << ", "
2530 << theHasAngles << ", "
2531 << theAngles << ", "
2532 << theHasRefPoint << ", "
2533 << "SMESH.PointStruct( "
2534 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2535 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2536 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2538 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
2539 SMESH::long_array_var anElementsId = theObject->GetIDs();
2540 extrusionAlongPath( anElementsId,
2553 //=======================================================================
2554 //function : ExtrusionAlongPathObject1D
2556 //=======================================================================
2557 SMESH::SMESH_MeshEditor::Extrusion_Error
2558 SMESH_MeshEditor_i::ExtrusionAlongPathObject1D(SMESH::SMESH_IDSource_ptr theObject,
2559 SMESH::SMESH_Mesh_ptr thePathMesh,
2560 GEOM::GEOM_Object_ptr thePathShape,
2561 CORBA::Long theNodeStart,
2562 CORBA::Boolean theHasAngles,
2563 const SMESH::double_array & theAngles,
2564 CORBA::Boolean theHasRefPoint,
2565 const SMESH::PointStruct & theRefPoint)
2567 if ( !myPreviewMode ) {
2568 TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject1D( "
2569 << theObject << ", "
2570 << thePathMesh << ", "
2571 << thePathShape << ", "
2572 << theNodeStart << ", "
2573 << theHasAngles << ", "
2574 << theAngles << ", "
2575 << theHasRefPoint << ", "
2576 << "SMESH.PointStruct( "
2577 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2578 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2579 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2581 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
2582 SMESH::long_array_var anElementsId = theObject->GetIDs();
2583 extrusionAlongPath( anElementsId,
2597 //=======================================================================
2598 //function : ExtrusionAlongPathObject2D
2600 //=======================================================================
2601 SMESH::SMESH_MeshEditor::Extrusion_Error
2602 SMESH_MeshEditor_i::ExtrusionAlongPathObject2D(SMESH::SMESH_IDSource_ptr theObject,
2603 SMESH::SMESH_Mesh_ptr thePathMesh,
2604 GEOM::GEOM_Object_ptr thePathShape,
2605 CORBA::Long theNodeStart,
2606 CORBA::Boolean theHasAngles,
2607 const SMESH::double_array & theAngles,
2608 CORBA::Boolean theHasRefPoint,
2609 const SMESH::PointStruct & theRefPoint)
2611 if ( !myPreviewMode ) {
2612 TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject2D( "
2613 << theObject << ", "
2614 << thePathMesh << ", "
2615 << thePathShape << ", "
2616 << theNodeStart << ", "
2617 << theHasAngles << ", "
2618 << theAngles << ", "
2619 << theHasRefPoint << ", "
2620 << "SMESH.PointStruct( "
2621 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2622 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2623 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2625 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
2626 SMESH::long_array_var anElementsId = theObject->GetIDs();
2627 extrusionAlongPath( anElementsId,
2642 //=======================================================================
2643 //function : ExtrusionAlongPathMakeGroups
2645 //=======================================================================
2646 SMESH::ListOfGroups*
2647 SMESH_MeshEditor_i::ExtrusionAlongPathMakeGroups(const SMESH::long_array& theIDsOfElements,
2648 SMESH::SMESH_Mesh_ptr thePathMesh,
2649 GEOM::GEOM_Object_ptr thePathShape,
2650 CORBA::Long theNodeStart,
2651 CORBA::Boolean theHasAngles,
2652 const SMESH::double_array& theAngles,
2653 CORBA::Boolean theHasRefPoint,
2654 const SMESH::PointStruct& theRefPoint,
2655 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2657 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2659 SMESH::ListOfGroups * aGroups = extrusionAlongPath( theIDsOfElements,
2669 if (!myPreviewMode) {
2670 bool isDumpGroups = aGroups && aGroups->length() > 0;
2672 aPythonDump << "(" << aGroups << ", error)";
2674 aPythonDump <<"error";
2676 aPythonDump<<" = "<< this << ".ExtrusionAlongPathMakeGroups( "
2677 << theIDsOfElements << ", "
2678 << thePathMesh << ", "
2679 << thePathShape << ", "
2680 << theNodeStart << ", "
2681 << theHasAngles << ", "
2682 << theAngles << ", "
2683 << theHasRefPoint << ", "
2684 << "SMESH.PointStruct( "
2685 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2686 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2687 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2692 //=======================================================================
2693 //function : ExtrusionAlongPathObjectMakeGroups
2695 //=======================================================================
2696 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2697 ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2698 SMESH::SMESH_Mesh_ptr thePathMesh,
2699 GEOM::GEOM_Object_ptr thePathShape,
2700 CORBA::Long theNodeStart,
2701 CORBA::Boolean theHasAngles,
2702 const SMESH::double_array& theAngles,
2703 CORBA::Boolean theHasRefPoint,
2704 const SMESH::PointStruct& theRefPoint,
2705 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2707 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2709 SMESH::long_array_var anElementsId = theObject->GetIDs();
2710 SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
2721 if (!myPreviewMode) {
2722 bool isDumpGroups = aGroups && aGroups->length() > 0;
2724 aPythonDump << "(" << aGroups << ", error)";
2726 aPythonDump <<"error";
2728 aPythonDump << " = " << this << ".ExtrusionAlongPathObjectMakeGroups( "
2729 << theObject << ", "
2730 << thePathMesh << ", "
2731 << thePathShape << ", "
2732 << theNodeStart << ", "
2733 << theHasAngles << ", "
2734 << theAngles << ", "
2735 << theHasRefPoint << ", "
2736 << "SMESH.PointStruct( "
2737 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2738 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2739 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2744 //=======================================================================
2745 //function : ExtrusionAlongPathObject1DMakeGroups
2747 //=======================================================================
2748 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2749 ExtrusionAlongPathObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2750 SMESH::SMESH_Mesh_ptr thePathMesh,
2751 GEOM::GEOM_Object_ptr thePathShape,
2752 CORBA::Long theNodeStart,
2753 CORBA::Boolean theHasAngles,
2754 const SMESH::double_array& theAngles,
2755 CORBA::Boolean theHasRefPoint,
2756 const SMESH::PointStruct& theRefPoint,
2757 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2759 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2761 SMESH::long_array_var anElementsId = theObject->GetIDs();
2762 SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
2774 if (!myPreviewMode) {
2775 bool isDumpGroups = aGroups && aGroups->length() > 0;
2777 aPythonDump << "(" << aGroups << ", error)";
2779 aPythonDump << "error";
2781 aPythonDump << " = " << this << ".ExtrusionAlongPathObject1DMakeGroups( "
2782 << theObject << ", "
2783 << thePathMesh << ", "
2784 << thePathShape << ", "
2785 << theNodeStart << ", "
2786 << theHasAngles << ", "
2787 << theAngles << ", "
2788 << theHasRefPoint << ", "
2789 << "SMESH.PointStruct( "
2790 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2791 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2792 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2797 //=======================================================================
2798 //function : ExtrusionAlongPathObject2DMakeGroups
2800 //=======================================================================
2801 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2802 ExtrusionAlongPathObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2803 SMESH::SMESH_Mesh_ptr thePathMesh,
2804 GEOM::GEOM_Object_ptr thePathShape,
2805 CORBA::Long theNodeStart,
2806 CORBA::Boolean theHasAngles,
2807 const SMESH::double_array& theAngles,
2808 CORBA::Boolean theHasRefPoint,
2809 const SMESH::PointStruct& theRefPoint,
2810 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2812 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2814 SMESH::long_array_var anElementsId = theObject->GetIDs();
2815 SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
2827 if (!myPreviewMode) {
2828 bool isDumpGroups = aGroups && aGroups->length() > 0;
2830 aPythonDump << "(" << aGroups << ", error)";
2832 aPythonDump << "error";
2834 aPythonDump << " = " << this << ".ExtrusionAlongPathObject2DMakeGroups( "
2835 << theObject << ", "
2836 << thePathMesh << ", "
2837 << thePathShape << ", "
2838 << theNodeStart << ", "
2839 << theHasAngles << ", "
2840 << theAngles << ", "
2841 << theHasRefPoint << ", "
2842 << "SMESH.PointStruct( "
2843 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2844 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2845 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2851 //=======================================================================
2852 //function : ExtrusionAlongPathObjX
2854 //=======================================================================
2855 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2856 ExtrusionAlongPathObjX(SMESH::SMESH_IDSource_ptr Object,
2857 SMESH::SMESH_IDSource_ptr Path,
2858 CORBA::Long NodeStart,
2859 CORBA::Boolean HasAngles,
2860 const SMESH::double_array& Angles,
2861 CORBA::Boolean LinearVariation,
2862 CORBA::Boolean HasRefPoint,
2863 const SMESH::PointStruct& RefPoint,
2864 CORBA::Boolean MakeGroups,
2865 SMESH::ElementType ElemType,
2866 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2868 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2870 SMESH::long_array_var anElementsId = Object->GetIDs();
2871 SMESH::ListOfGroups * aGroups = extrusionAlongPathX(anElementsId,
2880 (SMDSAbs_ElementType)ElemType,
2883 if (!myPreviewMode) {
2884 bool isDumpGroups = aGroups && aGroups->length() > 0;
2886 aPythonDump << "(" << *aGroups << ", error)";
2888 aPythonDump << "error";
2890 aPythonDump << " = " << this << ".ExtrusionAlongPathObjX( "
2893 << NodeStart << ", "
2894 << HasAngles << ", "
2896 << LinearVariation << ", "
2897 << HasRefPoint << ", "
2898 << "SMESH.PointStruct( "
2899 << ( HasRefPoint ? RefPoint.x : 0 ) << ", "
2900 << ( HasRefPoint ? RefPoint.y : 0 ) << ", "
2901 << ( HasRefPoint ? RefPoint.z : 0 ) << " ), "
2902 << MakeGroups << ", "
2903 << ElemType << " )";
2909 //=======================================================================
2910 //function : ExtrusionAlongPathX
2912 //=======================================================================
2913 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2914 ExtrusionAlongPathX(const SMESH::long_array& IDsOfElements,
2915 SMESH::SMESH_IDSource_ptr Path,
2916 CORBA::Long NodeStart,
2917 CORBA::Boolean HasAngles,
2918 const SMESH::double_array& Angles,
2919 CORBA::Boolean LinearVariation,
2920 CORBA::Boolean HasRefPoint,
2921 const SMESH::PointStruct& RefPoint,
2922 CORBA::Boolean MakeGroups,
2923 SMESH::ElementType ElemType,
2924 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2926 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2928 SMESH::ListOfGroups * aGroups = extrusionAlongPathX(IDsOfElements,
2937 (SMDSAbs_ElementType)ElemType,
2940 if (!myPreviewMode) {
2941 bool isDumpGroups = aGroups && aGroups->length() > 0;
2943 aPythonDump << "(" << *aGroups << ", error)";
2945 aPythonDump <<"error";
2947 aPythonDump << " = " << this << ".ExtrusionAlongPathX( "
2948 << IDsOfElements << ", "
2950 << NodeStart << ", "
2951 << HasAngles << ", "
2953 << LinearVariation << ", "
2954 << HasRefPoint << ", "
2955 << "SMESH.PointStruct( "
2956 << ( HasRefPoint ? RefPoint.x : 0 ) << ", "
2957 << ( HasRefPoint ? RefPoint.y : 0 ) << ", "
2958 << ( HasRefPoint ? RefPoint.z : 0 ) << " ), "
2959 << MakeGroups << ", "
2960 << ElemType << " )";
2966 //================================================================================
2968 * \brief Compute rotation angles for ExtrusionAlongPath as linear variation
2969 * of given angles along path steps
2970 * \param PathMesh mesh containing a 1D sub-mesh on the edge, along
2971 * which proceeds the extrusion
2972 * \param PathShape is shape(edge); as the mesh can be complex, the edge
2973 * is used to define the sub-mesh for the path
2975 //================================================================================
2977 SMESH::double_array*
2978 SMESH_MeshEditor_i::LinearAnglesVariation(SMESH::SMESH_Mesh_ptr thePathMesh,
2979 GEOM::GEOM_Object_ptr thePathShape,
2980 const SMESH::double_array & theAngles)
2982 SMESH::double_array_var aResult = new SMESH::double_array();
2983 int nbAngles = theAngles.length();
2984 if ( nbAngles > 0 && !thePathMesh->_is_nil() && !thePathShape->_is_nil() )
2986 SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( thePathMesh );
2987 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
2988 SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
2989 if ( !aSubMesh || !aSubMesh->GetSubMeshDS())
2990 return aResult._retn();
2991 int nbSteps = aSubMesh->GetSubMeshDS()->NbElements();
2992 if ( nbSteps == nbAngles )
2994 aResult.inout() = theAngles;
2998 aResult->length( nbSteps );
2999 double rAn2St = double( nbAngles ) / double( nbSteps );
3000 double angPrev = 0, angle;
3001 for ( int iSt = 0; iSt < nbSteps; ++iSt )
3003 double angCur = rAn2St * ( iSt+1 );
3004 double angCurFloor = floor( angCur );
3005 double angPrevFloor = floor( angPrev );
3006 if ( angPrevFloor == angCurFloor )
3007 angle = rAn2St * theAngles[ int( angCurFloor ) ];
3010 int iP = int( angPrevFloor );
3011 double angPrevCeil = ceil(angPrev);
3012 angle = ( angPrevCeil - angPrev ) * theAngles[ iP ];
3014 int iC = int( angCurFloor );
3015 if ( iC < nbAngles )
3016 angle += ( angCur - angCurFloor ) * theAngles[ iC ];
3018 iP = int( angPrevCeil );
3020 angle += theAngles[ iC ];
3022 aResult[ iSt ] = angle;
3027 // Update Python script
3028 TPythonDump() << "rotAngles = " << theAngles;
3029 TPythonDump() << "rotAngles = " << this << ".LinearAnglesVariation( "
3030 << thePathMesh << ", "
3031 << thePathShape << ", "
3034 return aResult._retn();
3038 //=======================================================================
3041 //=======================================================================
3043 SMESH::ListOfGroups*
3044 SMESH_MeshEditor_i::mirror(TIDSortedElemSet & theElements,
3045 const SMESH::AxisStruct & theAxis,
3046 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
3047 CORBA::Boolean theCopy,
3049 ::SMESH_Mesh* theTargetMesh)
3053 gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
3054 gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
3056 if ( theTargetMesh )
3060 switch ( theMirrorType ) {
3061 case SMESH::SMESH_MeshEditor::POINT:
3062 aTrsf.SetMirror( P );
3064 case SMESH::SMESH_MeshEditor::AXIS:
3065 aTrsf.SetMirror( gp_Ax1( P, V ));
3068 aTrsf.SetMirror( gp_Ax2( P, V ));
3071 TIDSortedElemSet copyElements;
3072 TPreviewMesh tmpMesh;
3073 TIDSortedElemSet* workElements = & theElements;
3074 SMESH_Mesh* mesh = myMesh;
3076 if ( myPreviewMode )
3078 tmpMesh.Copy( theElements, copyElements);
3079 if ( !theCopy && !theTargetMesh )
3081 TIDSortedElemSet elemsAround, elemsAroundCopy;
3082 getElementsAround( theElements, GetMeshDS(), elemsAround );
3083 tmpMesh.Copy( elemsAround, elemsAroundCopy);
3086 workElements = & copyElements;
3087 theMakeGroups = false;
3090 ::SMESH_MeshEditor anEditor( mesh );
3091 ::SMESH_MeshEditor::PGroupIDs groupIds =
3092 anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
3094 if(theCopy || myPreviewMode)
3095 storeResult(anEditor); // store preview data or new elements
3097 if ( !myPreviewMode )
3099 if ( theTargetMesh )
3101 theTargetMesh->GetMeshDS()->Modified();
3105 myMesh->GetMeshDS()->Modified();
3106 myMesh->SetIsModified( true );
3109 return theMakeGroups ? getGroups(groupIds.get()) : 0;
3112 //=======================================================================
3115 //=======================================================================
3117 void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElements,
3118 const SMESH::AxisStruct & theAxis,
3119 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
3120 CORBA::Boolean theCopy)
3122 if ( !myPreviewMode ) {
3123 TPythonDump() << this << ".Mirror( "
3124 << theIDsOfElements << ", "
3126 << mirrorTypeName(theMirrorType) << ", "
3129 if ( theIDsOfElements.length() > 0 )
3131 TIDSortedElemSet elements;
3132 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3133 mirror(elements, theAxis, theMirrorType, theCopy, false);
3138 //=======================================================================
3139 //function : MirrorObject
3141 //=======================================================================
3143 void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObject,
3144 const SMESH::AxisStruct & theAxis,
3145 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
3146 CORBA::Boolean theCopy)
3148 if ( !myPreviewMode ) {
3149 TPythonDump() << this << ".MirrorObject( "
3150 << theObject << ", "
3152 << mirrorTypeName(theMirrorType) << ", "
3155 TIDSortedElemSet elements;
3157 bool emptyIfIsMesh = myPreviewMode ? false : true;
3159 if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
3160 mirror(elements, theAxis, theMirrorType, theCopy, false);
3163 //=======================================================================
3164 //function : MirrorMakeGroups
3166 //=======================================================================
3168 SMESH::ListOfGroups*
3169 SMESH_MeshEditor_i::MirrorMakeGroups(const SMESH::long_array& theIDsOfElements,
3170 const SMESH::AxisStruct& theMirror,
3171 SMESH::SMESH_MeshEditor::MirrorType theMirrorType)
3173 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3175 SMESH::ListOfGroups * aGroups = 0;
3176 if ( theIDsOfElements.length() > 0 )
3178 TIDSortedElemSet elements;
3179 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3180 aGroups = mirror(elements, theMirror, theMirrorType, true, true);
3182 if (!myPreviewMode) {
3183 DumpGroupsList(aPythonDump, aGroups);
3184 aPythonDump << this << ".MirrorMakeGroups( "
3185 << theIDsOfElements << ", "
3186 << theMirror << ", "
3187 << mirrorTypeName(theMirrorType) << " )";
3192 //=======================================================================
3193 //function : MirrorObjectMakeGroups
3195 //=======================================================================
3197 SMESH::ListOfGroups*
3198 SMESH_MeshEditor_i::MirrorObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
3199 const SMESH::AxisStruct& theMirror,
3200 SMESH::SMESH_MeshEditor::MirrorType theMirrorType)
3202 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3204 SMESH::ListOfGroups * aGroups = 0;
3205 TIDSortedElemSet elements;
3206 if ( idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3207 aGroups = mirror(elements, theMirror, theMirrorType, true, true);
3211 DumpGroupsList(aPythonDump,aGroups);
3212 aPythonDump << this << ".MirrorObjectMakeGroups( "
3213 << theObject << ", "
3214 << theMirror << ", "
3215 << mirrorTypeName(theMirrorType) << " )";
3220 //=======================================================================
3221 //function : MirrorMakeMesh
3223 //=======================================================================
3225 SMESH::SMESH_Mesh_ptr
3226 SMESH_MeshEditor_i::MirrorMakeMesh(const SMESH::long_array& theIDsOfElements,
3227 const SMESH::AxisStruct& theMirror,
3228 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
3229 CORBA::Boolean theCopyGroups,
3230 const char* theMeshName)
3232 SMESH_Mesh_i* mesh_i;
3233 SMESH::SMESH_Mesh_var mesh;
3234 { // open new scope to dump "MakeMesh" command
3235 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3237 TPythonDump pydump; // to prevent dump at mesh creation
3239 mesh = makeMesh( theMeshName );
3240 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3241 if (mesh_i && theIDsOfElements.length() > 0 )
3243 TIDSortedElemSet elements;
3244 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3245 mirror(elements, theMirror, theMirrorType,
3246 false, theCopyGroups, & mesh_i->GetImpl());
3247 mesh_i->CreateGroupServants();
3250 if (!myPreviewMode) {
3251 pydump << mesh << " = " << this << ".MirrorMakeMesh( "
3252 << theIDsOfElements << ", "
3253 << theMirror << ", "
3254 << mirrorTypeName(theMirrorType) << ", "
3255 << theCopyGroups << ", '"
3256 << theMeshName << "' )";
3261 if (!myPreviewMode && mesh_i)
3262 mesh_i->GetGroups();
3264 return mesh._retn();
3267 //=======================================================================
3268 //function : MirrorObjectMakeMesh
3270 //=======================================================================
3272 SMESH::SMESH_Mesh_ptr
3273 SMESH_MeshEditor_i::MirrorObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
3274 const SMESH::AxisStruct& theMirror,
3275 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
3276 CORBA::Boolean theCopyGroups,
3277 const char* theMeshName)
3279 SMESH_Mesh_i* mesh_i;
3280 SMESH::SMESH_Mesh_var mesh;
3281 { // open new scope to dump "MakeMesh" command
3282 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3284 TPythonDump pydump; // to prevent dump at mesh creation
3286 mesh = makeMesh( theMeshName );
3287 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3288 TIDSortedElemSet elements;
3290 idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3292 mirror(elements, theMirror, theMirrorType,
3293 false, theCopyGroups, & mesh_i->GetImpl());
3294 mesh_i->CreateGroupServants();
3296 if (!myPreviewMode) {
3297 pydump << mesh << " = " << this << ".MirrorObjectMakeMesh( "
3298 << theObject << ", "
3299 << theMirror << ", "
3300 << mirrorTypeName(theMirrorType) << ", "
3301 << theCopyGroups << ", '"
3302 << theMeshName << "' )";
3307 if (!myPreviewMode && mesh_i)
3308 mesh_i->GetGroups();
3310 return mesh._retn();
3313 //=======================================================================
3314 //function : translate
3316 //=======================================================================
3318 SMESH::ListOfGroups*
3319 SMESH_MeshEditor_i::translate(TIDSortedElemSet & theElements,
3320 const SMESH::DirStruct & theVector,
3321 CORBA::Boolean theCopy,
3323 ::SMESH_Mesh* theTargetMesh)
3327 if ( theTargetMesh )
3331 const SMESH::PointStruct * P = &theVector.PS;
3332 aTrsf.SetTranslation( gp_Vec( P->x, P->y, P->z ));
3334 TIDSortedElemSet copyElements;
3335 TIDSortedElemSet* workElements = &theElements;
3336 TPreviewMesh tmpMesh;
3337 SMESH_Mesh* mesh = myMesh;
3339 if ( myPreviewMode )
3341 tmpMesh.Copy( theElements, copyElements);
3342 if ( !theCopy && !theTargetMesh )
3344 TIDSortedElemSet elemsAround, elemsAroundCopy;
3345 getElementsAround( theElements, GetMeshDS(), elemsAround );
3346 tmpMesh.Copy( elemsAround, elemsAroundCopy);
3349 workElements = & copyElements;
3350 theMakeGroups = false;
3353 ::SMESH_MeshEditor anEditor( mesh );
3354 ::SMESH_MeshEditor::PGroupIDs groupIds =
3355 anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
3357 if(theCopy || myPreviewMode)
3358 storeResult(anEditor);
3360 if ( !myPreviewMode )
3362 if ( theTargetMesh )
3364 theTargetMesh->GetMeshDS()->Modified();
3368 myMesh->GetMeshDS()->Modified();
3369 myMesh->SetIsModified( true );
3373 return theMakeGroups ? getGroups(groupIds.get()) : 0;
3376 //=======================================================================
3377 //function : Translate
3379 //=======================================================================
3381 void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements,
3382 const SMESH::DirStruct & theVector,
3383 CORBA::Boolean theCopy)
3385 if (!myPreviewMode) {
3386 TPythonDump() << this << ".Translate( "
3387 << theIDsOfElements << ", "
3388 << theVector << ", "
3391 if (theIDsOfElements.length()) {
3392 TIDSortedElemSet elements;
3393 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3394 translate(elements, theVector, theCopy, false);
3398 //=======================================================================
3399 //function : TranslateObject
3401 //=======================================================================
3403 void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject,
3404 const SMESH::DirStruct & theVector,
3405 CORBA::Boolean theCopy)
3407 if (!myPreviewMode) {
3408 TPythonDump() << this << ".TranslateObject( "
3409 << theObject << ", "
3410 << theVector << ", "
3413 TIDSortedElemSet elements;
3415 bool emptyIfIsMesh = myPreviewMode ? false : true;
3417 if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
3418 translate(elements, theVector, theCopy, false);
3421 //=======================================================================
3422 //function : TranslateMakeGroups
3424 //=======================================================================
3426 SMESH::ListOfGroups*
3427 SMESH_MeshEditor_i::TranslateMakeGroups(const SMESH::long_array& theIDsOfElements,
3428 const SMESH::DirStruct& theVector)
3430 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3432 SMESH::ListOfGroups * aGroups = 0;
3433 if (theIDsOfElements.length()) {
3434 TIDSortedElemSet elements;
3435 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3436 aGroups = translate(elements,theVector,true,true);
3438 if (!myPreviewMode) {
3439 DumpGroupsList(aPythonDump, aGroups);
3440 aPythonDump << this << ".TranslateMakeGroups( "
3441 << theIDsOfElements << ", "
3442 << theVector << " )";
3447 //=======================================================================
3448 //function : TranslateObjectMakeGroups
3450 //=======================================================================
3452 SMESH::ListOfGroups*
3453 SMESH_MeshEditor_i::TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
3454 const SMESH::DirStruct& theVector)
3456 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3458 SMESH::ListOfGroups * aGroups = 0;
3459 TIDSortedElemSet elements;
3460 if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3461 aGroups = translate(elements, theVector, true, true);
3463 if (!myPreviewMode) {
3464 DumpGroupsList(aPythonDump, aGroups);
3465 aPythonDump << this << ".TranslateObjectMakeGroups( "
3466 << theObject << ", "
3467 << theVector << " )";
3472 //=======================================================================
3473 //function : TranslateMakeMesh
3475 //=======================================================================
3477 SMESH::SMESH_Mesh_ptr
3478 SMESH_MeshEditor_i::TranslateMakeMesh(const SMESH::long_array& theIDsOfElements,
3479 const SMESH::DirStruct& theVector,
3480 CORBA::Boolean theCopyGroups,
3481 const char* theMeshName)
3483 SMESH_Mesh_i* mesh_i;
3484 SMESH::SMESH_Mesh_var mesh;
3486 { // open new scope to dump "MakeMesh" command
3487 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3489 TPythonDump pydump; // to prevent dump at mesh creation
3491 mesh = makeMesh( theMeshName );
3492 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3494 if ( mesh_i && theIDsOfElements.length() )
3496 TIDSortedElemSet elements;
3497 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3498 translate(elements, theVector, false, theCopyGroups, & mesh_i->GetImpl());
3499 mesh_i->CreateGroupServants();
3502 if ( !myPreviewMode ) {
3503 pydump << mesh << " = " << this << ".TranslateMakeMesh( "
3504 << theIDsOfElements << ", "
3505 << theVector << ", "
3506 << theCopyGroups << ", '"
3507 << theMeshName << "' )";
3512 if (!myPreviewMode && mesh_i)
3513 mesh_i->GetGroups();
3515 return mesh._retn();
3518 //=======================================================================
3519 //function : TranslateObjectMakeMesh
3521 //=======================================================================
3523 SMESH::SMESH_Mesh_ptr
3524 SMESH_MeshEditor_i::TranslateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
3525 const SMESH::DirStruct& theVector,
3526 CORBA::Boolean theCopyGroups,
3527 const char* theMeshName)
3529 SMESH_Mesh_i* mesh_i;
3530 SMESH::SMESH_Mesh_var mesh;
3531 { // open new scope to dump "MakeMesh" command
3532 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3534 TPythonDump pydump; // to prevent dump at mesh creation
3535 mesh = makeMesh( theMeshName );
3536 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3538 TIDSortedElemSet elements;
3540 idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3542 translate(elements, theVector,false, theCopyGroups, & mesh_i->GetImpl());
3543 mesh_i->CreateGroupServants();
3545 if ( !myPreviewMode ) {
3546 pydump << mesh << " = " << this << ".TranslateObjectMakeMesh( "
3547 << theObject << ", "
3548 << theVector << ", "
3549 << theCopyGroups << ", '"
3550 << theMeshName << "' )";
3555 if (!myPreviewMode && mesh_i)
3556 mesh_i->GetGroups();
3558 return mesh._retn();
3561 //=======================================================================
3564 //=======================================================================
3566 SMESH::ListOfGroups*
3567 SMESH_MeshEditor_i::rotate(TIDSortedElemSet & theElements,
3568 const SMESH::AxisStruct & theAxis,
3569 CORBA::Double theAngle,
3570 CORBA::Boolean theCopy,
3572 ::SMESH_Mesh* theTargetMesh)
3576 if ( theTargetMesh )
3579 gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
3580 gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
3583 aTrsf.SetRotation( gp_Ax1( P, V ), theAngle);
3585 TIDSortedElemSet copyElements;
3586 TIDSortedElemSet* workElements = &theElements;
3587 TPreviewMesh tmpMesh;
3588 SMESH_Mesh* mesh = myMesh;
3590 if ( myPreviewMode ) {
3591 tmpMesh.Copy( theElements, copyElements );
3592 if ( !theCopy && !theTargetMesh )
3594 TIDSortedElemSet elemsAround, elemsAroundCopy;
3595 getElementsAround( theElements, GetMeshDS(), elemsAround );
3596 tmpMesh.Copy( elemsAround, elemsAroundCopy);
3599 workElements = ©Elements;
3600 theMakeGroups = false;
3603 ::SMESH_MeshEditor anEditor( mesh );
3604 ::SMESH_MeshEditor::PGroupIDs groupIds =
3605 anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
3607 if(theCopy || myPreviewMode)
3608 storeResult(anEditor);
3610 if ( !myPreviewMode )
3612 if ( theTargetMesh )
3614 theTargetMesh->GetMeshDS()->Modified();
3618 myMesh->GetMeshDS()->Modified();
3619 myMesh->SetIsModified( true );
3623 return theMakeGroups ? getGroups(groupIds.get()) : 0;
3626 //=======================================================================
3629 //=======================================================================
3631 void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements,
3632 const SMESH::AxisStruct & theAxis,
3633 CORBA::Double theAngle,
3634 CORBA::Boolean theCopy)
3636 if (!myPreviewMode) {
3637 TPythonDump() << this << ".Rotate( "
3638 << theIDsOfElements << ", "
3643 if (theIDsOfElements.length() > 0)
3645 TIDSortedElemSet elements;
3646 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3647 rotate(elements,theAxis,theAngle,theCopy,false);
3651 //=======================================================================
3652 //function : RotateObject
3654 //=======================================================================
3656 void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject,
3657 const SMESH::AxisStruct & theAxis,
3658 CORBA::Double theAngle,
3659 CORBA::Boolean theCopy)
3661 if ( !myPreviewMode ) {
3662 TPythonDump() << this << ".RotateObject( "
3663 << theObject << ", "
3668 TIDSortedElemSet elements;
3669 bool emptyIfIsMesh = myPreviewMode ? false : true;
3670 if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
3671 rotate(elements,theAxis,theAngle,theCopy,false);
3674 //=======================================================================
3675 //function : RotateMakeGroups
3677 //=======================================================================
3679 SMESH::ListOfGroups*
3680 SMESH_MeshEditor_i::RotateMakeGroups(const SMESH::long_array& theIDsOfElements,
3681 const SMESH::AxisStruct& theAxis,
3682 CORBA::Double theAngle)
3684 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3686 SMESH::ListOfGroups * aGroups = 0;
3687 if (theIDsOfElements.length() > 0)
3689 TIDSortedElemSet elements;
3690 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3691 aGroups = rotate(elements,theAxis,theAngle,true,true);
3693 if (!myPreviewMode) {
3694 DumpGroupsList(aPythonDump, aGroups);
3695 aPythonDump << this << ".RotateMakeGroups( "
3696 << theIDsOfElements << ", "
3698 << theAngle << " )";
3703 //=======================================================================
3704 //function : RotateObjectMakeGroups
3706 //=======================================================================
3708 SMESH::ListOfGroups*
3709 SMESH_MeshEditor_i::RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
3710 const SMESH::AxisStruct& theAxis,
3711 CORBA::Double theAngle)
3713 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3715 SMESH::ListOfGroups * aGroups = 0;
3716 TIDSortedElemSet elements;
3717 if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3718 aGroups = rotate(elements, theAxis, theAngle, true, true);
3720 if (!myPreviewMode) {
3721 DumpGroupsList(aPythonDump, aGroups);
3722 aPythonDump << this << ".RotateObjectMakeGroups( "
3723 << theObject << ", "
3725 << theAngle << " )";
3730 //=======================================================================
3731 //function : RotateMakeMesh
3733 //=======================================================================
3735 SMESH::SMESH_Mesh_ptr
3736 SMESH_MeshEditor_i::RotateMakeMesh(const SMESH::long_array& theIDsOfElements,
3737 const SMESH::AxisStruct& theAxis,
3738 CORBA::Double theAngleInRadians,
3739 CORBA::Boolean theCopyGroups,
3740 const char* theMeshName)
3742 SMESH::SMESH_Mesh_var mesh;
3743 SMESH_Mesh_i* mesh_i;
3745 { // open new scope to dump "MakeMesh" command
3746 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3748 TPythonDump pydump; // to prevent dump at mesh creation
3750 mesh = makeMesh( theMeshName );
3751 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3753 if ( mesh_i && theIDsOfElements.length() > 0 )
3755 TIDSortedElemSet elements;
3756 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3757 rotate(elements, theAxis, theAngleInRadians,
3758 false, theCopyGroups, & mesh_i->GetImpl());
3759 mesh_i->CreateGroupServants();
3761 if ( !myPreviewMode ) {
3762 pydump << mesh << " = " << this << ".RotateMakeMesh( "
3763 << theIDsOfElements << ", "
3765 << theAngleInRadians << ", "
3766 << theCopyGroups << ", '"
3767 << theMeshName << "' )";
3772 if (!myPreviewMode && mesh_i && theIDsOfElements.length() > 0 )
3773 mesh_i->GetGroups();
3775 return mesh._retn();
3778 //=======================================================================
3779 //function : RotateObjectMakeMesh
3781 //=======================================================================
3783 SMESH::SMESH_Mesh_ptr
3784 SMESH_MeshEditor_i::RotateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
3785 const SMESH::AxisStruct& theAxis,
3786 CORBA::Double theAngleInRadians,
3787 CORBA::Boolean theCopyGroups,
3788 const char* theMeshName)
3790 SMESH::SMESH_Mesh_var mesh;
3791 SMESH_Mesh_i* mesh_i;
3793 {// open new scope to dump "MakeMesh" command
3794 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3796 TPythonDump pydump; // to prevent dump at mesh creation
3797 mesh = makeMesh( theMeshName );
3798 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3800 TIDSortedElemSet elements;
3802 idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3804 rotate(elements, theAxis, theAngleInRadians,
3805 false, theCopyGroups, & mesh_i->GetImpl());
3806 mesh_i->CreateGroupServants();
3808 if ( !myPreviewMode ) {
3809 pydump << mesh << " = " << this << ".RotateObjectMakeMesh( "
3810 << theObject << ", "
3812 << theAngleInRadians << ", "
3813 << theCopyGroups << ", '"
3814 << theMeshName << "' )";
3819 if (!myPreviewMode && mesh_i)
3820 mesh_i->GetGroups();
3822 return mesh._retn();
3825 //=======================================================================
3828 //=======================================================================
3830 SMESH::ListOfGroups*
3831 SMESH_MeshEditor_i::scale(SMESH::SMESH_IDSource_ptr theObject,
3832 const SMESH::PointStruct& thePoint,
3833 const SMESH::double_array& theScaleFact,
3834 CORBA::Boolean theCopy,
3836 ::SMESH_Mesh* theTargetMesh)
3839 if ( theScaleFact.length() < 1 )
3840 THROW_SALOME_CORBA_EXCEPTION("Scale factor not given", SALOME::BAD_PARAM);
3841 if ( theScaleFact.length() == 2 )
3842 THROW_SALOME_CORBA_EXCEPTION("Invalid nb of scale factors : 2", SALOME::BAD_PARAM);
3844 if ( theTargetMesh )
3847 TIDSortedElemSet elements;
3848 bool emptyIfIsMesh = myPreviewMode ? false : true;
3849 if ( !idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
3854 (theScaleFact.length() == 1) ? theScaleFact[0] : theScaleFact[1],
3855 (theScaleFact.length() == 1) ? theScaleFact[0] : theScaleFact[2],
3857 double tol = std::numeric_limits<double>::max();
3859 aTrsf.SetValues( S[0], 0, 0, thePoint.x * (1-S[0]),
3860 0, S[1], 0, thePoint.y * (1-S[1]),
3861 0, 0, S[2], thePoint.z * (1-S[2]), tol, tol);
3863 TIDSortedElemSet copyElements;
3864 TPreviewMesh tmpMesh;
3865 TIDSortedElemSet* workElements = &elements;
3866 SMESH_Mesh* mesh = myMesh;
3868 if ( myPreviewMode )
3870 tmpMesh.Copy( elements, copyElements);
3871 if ( !theCopy && !theTargetMesh )
3873 TIDSortedElemSet elemsAround, elemsAroundCopy;
3874 getElementsAround( elements, GetMeshDS(), elemsAround );
3875 tmpMesh.Copy( elemsAround, elemsAroundCopy);
3878 workElements = & copyElements;
3879 theMakeGroups = false;
3882 ::SMESH_MeshEditor anEditor( mesh );
3883 ::SMESH_MeshEditor::PGroupIDs groupIds =
3884 anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
3886 if(theCopy || myPreviewMode )
3887 storeResult(anEditor);
3889 if ( !myPreviewMode )
3891 if ( theTargetMesh )
3893 theTargetMesh->GetMeshDS()->Modified();
3897 myMesh->GetMeshDS()->Modified();
3898 myMesh->SetIsModified( true );
3902 return theMakeGroups ? getGroups(groupIds.get()) : 0;
3905 //=======================================================================
3908 //=======================================================================
3910 void SMESH_MeshEditor_i::Scale(SMESH::SMESH_IDSource_ptr theObject,
3911 const SMESH::PointStruct& thePoint,
3912 const SMESH::double_array& theScaleFact,
3913 CORBA::Boolean theCopy)
3915 if ( !myPreviewMode ) {
3916 TPythonDump() << this << ".Scale( "
3917 << theObject << ", "
3918 << "SMESH.PointStruct( " << thePoint.x << ", "
3919 << thePoint.y << ", " << thePoint.z << " ) ,"
3920 << theScaleFact << ", "
3923 scale(theObject, thePoint, theScaleFact, theCopy, false);
3927 //=======================================================================
3928 //function : ScaleMakeGroups
3930 //=======================================================================
3932 SMESH::ListOfGroups*
3933 SMESH_MeshEditor_i::ScaleMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
3934 const SMESH::PointStruct& thePoint,
3935 const SMESH::double_array& theScaleFact)
3937 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3939 SMESH::ListOfGroups * aGroups = scale(theObject, thePoint, theScaleFact, true, true);
3940 if (!myPreviewMode) {
3941 DumpGroupsList(aPythonDump, aGroups);
3942 aPythonDump << this << ".Scale("
3944 << "SMESH.PointStruct(" <<thePoint.x << ","
3945 << thePoint.y << "," << thePoint.z << "),"
3946 << theScaleFact << ",True,True)";
3952 //=======================================================================
3953 //function : ScaleMakeMesh
3955 //=======================================================================
3957 SMESH::SMESH_Mesh_ptr
3958 SMESH_MeshEditor_i::ScaleMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
3959 const SMESH::PointStruct& thePoint,
3960 const SMESH::double_array& theScaleFact,
3961 CORBA::Boolean theCopyGroups,
3962 const char* theMeshName)
3964 SMESH_Mesh_i* mesh_i;
3965 SMESH::SMESH_Mesh_var mesh;
3966 { // open new scope to dump "MakeMesh" command
3967 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3969 TPythonDump pydump; // to prevent dump at mesh creation
3970 mesh = makeMesh( theMeshName );
3971 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3975 scale(theObject, thePoint, theScaleFact,false, theCopyGroups, & mesh_i->GetImpl());
3976 mesh_i->CreateGroupServants();
3978 if ( !myPreviewMode )
3979 pydump << mesh << " = " << this << ".ScaleMakeMesh( "
3980 << theObject << ", "
3981 << "SMESH.PointStruct( " << thePoint.x << ", "
3982 << thePoint.y << ", " << thePoint.z << " ) ,"
3983 << theScaleFact << ", "
3984 << theCopyGroups << ", '"
3985 << theMeshName << "' )";
3989 if (!myPreviewMode && mesh_i)
3990 mesh_i->GetGroups();
3992 return mesh._retn();
3996 //=======================================================================
3997 //function : FindCoincidentNodes
3999 //=======================================================================
4001 void SMESH_MeshEditor_i::FindCoincidentNodes (CORBA::Double Tolerance,
4002 SMESH::array_of_long_array_out GroupsOfNodes)
4006 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
4007 ::SMESH_MeshEditor anEditor( myMesh );
4008 TIDSortedNodeSet nodes; // no input nodes
4009 anEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
4011 GroupsOfNodes = new SMESH::array_of_long_array;
4012 GroupsOfNodes->length( aListOfListOfNodes.size() );
4013 ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
4014 for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ ) {
4015 list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
4016 list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
4017 SMESH::long_array& aGroup = (*GroupsOfNodes)[ i ];
4018 aGroup.length( aListOfNodes.size() );
4019 for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
4020 aGroup[ j ] = (*lIt)->GetID();
4022 TPythonDump() << "coincident_nodes = " << this << ".FindCoincidentNodes( "
4023 << Tolerance << " )";
4026 //=======================================================================
4027 //function : FindCoincidentNodesOnPart
4029 //=======================================================================
4030 void SMESH_MeshEditor_i::FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr theObject,
4031 CORBA::Double Tolerance,
4032 SMESH::array_of_long_array_out GroupsOfNodes)
4036 TIDSortedNodeSet nodes;
4037 idSourceToNodeSet( theObject, GetMeshDS(), nodes );
4039 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
4040 ::SMESH_MeshEditor anEditor( myMesh );
4042 anEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
4044 GroupsOfNodes = new SMESH::array_of_long_array;
4045 GroupsOfNodes->length( aListOfListOfNodes.size() );
4046 ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
4047 for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ )
4049 list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
4050 list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
4051 SMESH::long_array& aGroup = (*GroupsOfNodes)[ i ];
4052 aGroup.length( aListOfNodes.size() );
4053 for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
4054 aGroup[ j ] = (*lIt)->GetID();
4056 TPythonDump() << "coincident_nodes_on_part = " << this << ".FindCoincidentNodesOnPart( "
4058 << Tolerance << " )";
4061 //================================================================================
4063 * \brief Finds nodes coinsident with Tolerance within Object excluding nodes within
4064 * ExceptSubMeshOrGroups
4066 //================================================================================
4068 void SMESH_MeshEditor_i::
4069 FindCoincidentNodesOnPartBut(SMESH::SMESH_IDSource_ptr theObject,
4070 CORBA::Double theTolerance,
4071 SMESH::array_of_long_array_out theGroupsOfNodes,
4072 const SMESH::ListOfIDSources& theExceptSubMeshOrGroups)
4076 TIDSortedNodeSet nodes;
4077 idSourceToNodeSet( theObject, GetMeshDS(), nodes );
4079 for ( int i = 0; i < theExceptSubMeshOrGroups.length(); ++i )
4081 TIDSortedNodeSet exceptNodes;
4082 idSourceToNodeSet( theExceptSubMeshOrGroups[i], GetMeshDS(), exceptNodes );
4083 TIDSortedNodeSet::iterator avoidNode = exceptNodes.begin();
4084 for ( ; avoidNode != exceptNodes.end(); ++avoidNode)
4085 nodes.erase( *avoidNode );
4087 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
4088 ::SMESH_MeshEditor anEditor( myMesh );
4090 anEditor.FindCoincidentNodes( nodes, theTolerance, aListOfListOfNodes );
4092 theGroupsOfNodes = new SMESH::array_of_long_array;
4093 theGroupsOfNodes->length( aListOfListOfNodes.size() );
4094 ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
4095 for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ )
4097 list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
4098 list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
4099 SMESH::long_array& aGroup = (*theGroupsOfNodes)[ i ];
4100 aGroup.length( aListOfNodes.size() );
4101 for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
4102 aGroup[ j ] = (*lIt)->GetID();
4104 TPythonDump() << "coincident_nodes_on_part = " << this << ".FindCoincidentNodesOnPartBut( "
4106 << theTolerance << ", "
4107 << theExceptSubMeshOrGroups << " )";
4110 //=======================================================================
4111 //function : MergeNodes
4113 //=======================================================================
4115 void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes)
4119 SMESHDS_Mesh* aMesh = GetMeshDS();
4121 TPythonDump aTPythonDump;
4122 aTPythonDump << this << ".MergeNodes([";
4123 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
4124 for (int i = 0; i < GroupsOfNodes.length(); i++)
4126 const SMESH::long_array& aNodeGroup = GroupsOfNodes[ i ];
4127 aListOfListOfNodes.push_back( list< const SMDS_MeshNode* >() );
4128 list< const SMDS_MeshNode* >& aListOfNodes = aListOfListOfNodes.back();
4129 for ( int j = 0; j < aNodeGroup.length(); j++ )
4131 CORBA::Long index = aNodeGroup[ j ];
4132 const SMDS_MeshNode * node = aMesh->FindNode(index);
4134 aListOfNodes.push_back( node );
4136 if ( aListOfNodes.size() < 2 )
4137 aListOfListOfNodes.pop_back();
4139 if ( i > 0 ) aTPythonDump << ", ";
4140 aTPythonDump << aNodeGroup;
4142 ::SMESH_MeshEditor anEditor( myMesh );
4143 anEditor.MergeNodes( aListOfListOfNodes );
4145 aTPythonDump << "])";
4146 myMesh->GetMeshDS()->Modified();
4147 myMesh->SetIsModified( true );
4150 //=======================================================================
4151 //function : FindEqualElements
4153 //=======================================================================
4154 void SMESH_MeshEditor_i::FindEqualElements(SMESH::SMESH_IDSource_ptr theObject,
4155 SMESH::array_of_long_array_out GroupsOfElementsID)
4159 SMESH::SMESH_GroupBase_var group = SMESH::SMESH_GroupBase::_narrow(theObject);
4160 if ( !(!group->_is_nil() && group->GetType() == SMESH::NODE) )
4162 typedef list<int> TListOfIDs;
4163 set<const SMDS_MeshElement*> elems;
4164 SMESH::long_array_var aElementsId = theObject->GetIDs();
4165 SMESHDS_Mesh* aMesh = GetMeshDS();
4167 for(int i = 0; i < aElementsId->length(); i++) {
4168 CORBA::Long anID = aElementsId[i];
4169 const SMDS_MeshElement * elem = aMesh->FindElement(anID);
4175 ::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
4176 ::SMESH_MeshEditor anEditor( myMesh );
4177 anEditor.FindEqualElements( elems, aListOfListOfElementsID );
4179 GroupsOfElementsID = new SMESH::array_of_long_array;
4180 GroupsOfElementsID->length( aListOfListOfElementsID.size() );
4182 ::SMESH_MeshEditor::TListOfListOfElementsID::iterator arraysIt = aListOfListOfElementsID.begin();
4183 for (CORBA::Long j = 0; arraysIt != aListOfListOfElementsID.end(); ++arraysIt, ++j) {
4184 SMESH::long_array& aGroup = (*GroupsOfElementsID)[ j ];
4185 TListOfIDs& listOfIDs = *arraysIt;
4186 aGroup.length( listOfIDs.size() );
4187 TListOfIDs::iterator idIt = listOfIDs.begin();
4188 for (int k = 0; idIt != listOfIDs.end(); ++idIt, ++k ) {
4189 aGroup[ k ] = *idIt;
4193 TPythonDump() << "equal_elements = " << this << ".FindEqualElements( "
4198 //=======================================================================
4199 //function : MergeElements
4201 //=======================================================================
4203 void SMESH_MeshEditor_i::MergeElements(const SMESH::array_of_long_array& GroupsOfElementsID)
4207 TPythonDump aTPythonDump;
4208 aTPythonDump << this << ".MergeElements( [";
4210 ::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
4212 for (int i = 0; i < GroupsOfElementsID.length(); i++) {
4213 const SMESH::long_array& anElemsIDGroup = GroupsOfElementsID[ i ];
4214 aListOfListOfElementsID.push_back( list< int >() );
4215 list< int >& aListOfElemsID = aListOfListOfElementsID.back();
4216 for ( int j = 0; j < anElemsIDGroup.length(); j++ ) {
4217 CORBA::Long id = anElemsIDGroup[ j ];
4218 aListOfElemsID.push_back( id );
4220 if ( aListOfElemsID.size() < 2 )
4221 aListOfListOfElementsID.pop_back();
4222 if ( i > 0 ) aTPythonDump << ", ";
4223 aTPythonDump << anElemsIDGroup;
4226 ::SMESH_MeshEditor anEditor( myMesh );
4227 anEditor.MergeElements(aListOfListOfElementsID);
4228 myMesh->GetMeshDS()->Modified();
4229 myMesh->SetIsModified( true );
4231 aTPythonDump << "] )";
4234 //=======================================================================
4235 //function : MergeEqualElements
4237 //=======================================================================
4239 void SMESH_MeshEditor_i::MergeEqualElements()
4243 ::SMESH_MeshEditor anEditor( myMesh );
4244 anEditor.MergeEqualElements();
4246 myMesh->GetMeshDS()->Modified();
4248 TPythonDump() << this << ".MergeEqualElements()";
4251 //=============================================================================
4253 * Move the node to a given point
4255 //=============================================================================
4257 CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long NodeID,
4262 initData(/*deleteSearchers=*/false);
4264 const SMDS_MeshNode * node = GetMeshDS()->FindNode( NodeID );
4268 if ( theNodeSearcher )
4269 theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
4271 if ( myPreviewMode ) // make preview data
4273 // in a preview mesh, make edges linked to a node
4274 TPreviewMesh tmpMesh;
4275 TIDSortedElemSet linkedNodes;
4276 ::SMESH_MeshEditor::GetLinkedNodes( node, linkedNodes );
4277 TIDSortedElemSet::iterator nIt = linkedNodes.begin();
4278 SMDS_MeshNode *nodeCpy1 = tmpMesh.Copy(node);
4279 for ( ; nIt != linkedNodes.end(); ++nIt )
4281 SMDS_MeshNode *nodeCpy2 = tmpMesh.Copy ( cast2Node( *nIt ));
4282 tmpMesh.GetMeshDS()->AddEdge(nodeCpy1, nodeCpy2);
4286 tmpMesh.GetMeshDS()->MoveNode(nodeCpy1, x, y, z);
4287 // fill preview data
4288 ::SMESH_MeshEditor anEditor( & tmpMesh );
4289 storeResult( anEditor );
4291 else if ( theNodeSearcher ) // move node and update theNodeSearcher data accordingly
4292 theNodeSearcher->MoveNode(node, gp_Pnt( x,y,z ));
4294 GetMeshDS()->MoveNode(node, x, y, z);
4296 if ( !myPreviewMode )
4298 // Update Python script
4299 TPythonDump() << "isDone = " << this << ".MoveNode( "
4300 << NodeID << ", " << x << ", " << y << ", " << z << " )";
4301 myMesh->GetMeshDS()->Modified();
4302 myMesh->SetIsModified( true );
4308 //================================================================================
4310 * \brief Return ID of node closest to a given point
4312 //================================================================================
4314 CORBA::Long SMESH_MeshEditor_i::FindNodeClosestTo(CORBA::Double x,
4318 theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
4320 if ( !theNodeSearcher ) {
4321 ::SMESH_MeshEditor anEditor( myMesh );
4322 theNodeSearcher = anEditor.GetNodeSearcher();
4325 if ( const SMDS_MeshNode* node = theNodeSearcher->FindClosestTo( p ))
4326 return node->GetID();
4331 //================================================================================
4333 * \brief If the given ID is a valid node ID (nodeID > 0), just move this node, else
4334 * move the node closest to the point to point's location and return ID of the node
4336 //================================================================================
4338 CORBA::Long SMESH_MeshEditor_i::MoveClosestNodeToPoint(CORBA::Double x,
4341 CORBA::Long theNodeID)
4343 // We keep theNodeSearcher until any mesh modification:
4344 // 1) initData() deletes theNodeSearcher at any edition,
4345 // 2) TSearchersDeleter - at any mesh compute event and mesh change
4347 initData(/*deleteSearchers=*/false);
4349 theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
4351 int nodeID = theNodeID;
4352 const SMDS_MeshNode* node = GetMeshDS()->FindNode( nodeID );
4353 if ( !node ) // preview moving node
4355 if ( !theNodeSearcher ) {
4356 ::SMESH_MeshEditor anEditor( myMesh );
4357 theNodeSearcher = anEditor.GetNodeSearcher();
4360 node = theNodeSearcher->FindClosestTo( p );
4363 nodeID = node->GetID();
4364 if ( myPreviewMode ) // make preview data
4366 // in a preview mesh, make edges linked to a node
4367 TPreviewMesh tmpMesh;
4368 TIDSortedElemSet linkedNodes;
4369 ::SMESH_MeshEditor::GetLinkedNodes( node, linkedNodes );
4370 TIDSortedElemSet::iterator nIt = linkedNodes.begin();
4371 for ( ; nIt != linkedNodes.end(); ++nIt )
4373 SMDS_LinearEdge edge( node, cast2Node( *nIt ));
4374 tmpMesh.Copy( &edge );
4377 node = tmpMesh.GetMeshDS()->FindNode( nodeID );
4379 tmpMesh.GetMeshDS()->MoveNode(node, x, y, z);
4380 // fill preview data
4381 ::SMESH_MeshEditor anEditor( & tmpMesh );
4382 storeResult( anEditor );
4384 else if ( theNodeSearcher ) // move node and update theNodeSearcher data accordingly
4386 theNodeSearcher->MoveNode(node, gp_Pnt( x,y,z ));
4390 GetMeshDS()->MoveNode(node, x, y, z);
4394 if ( !myPreviewMode )
4396 TPythonDump() << "nodeID = " << this
4397 << ".MoveClosestNodeToPoint( "<< x << ", " << y << ", " << z
4398 << ", " << nodeID << " )";
4400 myMesh->GetMeshDS()->Modified();
4401 myMesh->SetIsModified( true );
4407 //=======================================================================
4409 * Return elements of given type where the given point is IN or ON.
4411 * 'ALL' type means elements of any type excluding nodes
4413 //=======================================================================
4415 SMESH::long_array* SMESH_MeshEditor_i::FindElementsByPoint(CORBA::Double x,
4418 SMESH::ElementType type)
4420 SMESH::long_array_var res = new SMESH::long_array;
4421 vector< const SMDS_MeshElement* > foundElems;
4423 theSearchersDeleter.Set( myMesh );
4424 if ( !theElementSearcher ) {
4425 ::SMESH_MeshEditor anEditor( myMesh );
4426 theElementSearcher = anEditor.GetElementSearcher();
4428 theElementSearcher->FindElementsByPoint( gp_Pnt( x,y,z ),
4429 SMDSAbs_ElementType( type ),
4431 res->length( foundElems.size() );
4432 for ( int i = 0; i < foundElems.size(); ++i )
4433 res[i] = foundElems[i]->GetID();
4435 if ( !myPreviewMode ) // call from tui
4436 TPythonDump() << "res = " << this << ".FindElementsByPoint( "
4445 //=======================================================================
4446 //function : FindAmongElementsByPoint
4447 //purpose : Searching among the given elements, return elements of given type
4448 // where the given point is IN or ON.
4449 // 'ALL' type means elements of any type excluding nodes
4450 //=======================================================================
4453 SMESH_MeshEditor_i::FindAmongElementsByPoint(SMESH::SMESH_IDSource_ptr elementIDs,
4457 SMESH::ElementType type)
4459 SMESH::long_array_var res = new SMESH::long_array;
4461 SMESH::array_of_ElementType_var types = elementIDs->GetTypes();
4462 if ( types->length() == 1 && // a part contains only nodes or 0D elements
4463 ( types[0] == SMESH::NODE || types[0] == SMESH::ELEM0D ) &&
4464 type != types[0] ) // but search of elements of dim > 0
4467 if ( SMESH::DownCast<SMESH_Mesh_i*>( elementIDs )) // elementIDs is the whole mesh
4468 return FindElementsByPoint( x,y,z, type );
4470 string partIOR = SMESH_Gen_i::GetORB()->object_to_string( elementIDs );
4471 if ( SMESH_Group_i* group_i = SMESH::DownCast<SMESH_Group_i*>( elementIDs ))
4472 // take into account passible group modification
4473 partIOR += SMESH_Comment( ((SMESHDS_Group*)group_i->GetGroupDS())->SMDSGroup().Tic() );
4474 partIOR += SMESH_Comment( type );
4476 TIDSortedElemSet elements; // elems should live until FindElementsByPoint() finishes
4478 theSearchersDeleter.Set( myMesh, partIOR );
4479 if ( !theElementSearcher )
4481 // create a searcher from elementIDs
4482 SMESH::SMESH_Mesh_var mesh = elementIDs->GetMesh();
4483 SMESHDS_Mesh* meshDS = SMESH::DownCast<SMESH_Mesh_i*>( mesh )->GetImpl().GetMeshDS();
4485 if ( !idSourceToSet( elementIDs, meshDS, elements,
4486 SMDSAbs_ElementType(type), /*emptyIfIsMesh=*/true))
4489 typedef SMDS_SetIterator<const SMDS_MeshElement*, TIDSortedElemSet::const_iterator > TIter;
4490 SMDS_ElemIteratorPtr elemsIt( new TIter( elements.begin(), elements.end() ));
4492 ::SMESH_MeshEditor anEditor( myMesh );
4493 theElementSearcher = anEditor.GetElementSearcher(elemsIt);
4496 vector< const SMDS_MeshElement* > foundElems;
4498 theElementSearcher->FindElementsByPoint( gp_Pnt( x,y,z ),
4499 SMDSAbs_ElementType( type ),
4501 res->length( foundElems.size() );
4502 for ( int i = 0; i < foundElems.size(); ++i )
4503 res[i] = foundElems[i]->GetID();
4505 if ( !myPreviewMode ) // call from tui
4506 TPythonDump() << "res = " << this << ".FindAmongElementsByPoint( "
4507 << elementIDs << ", "
4516 //=======================================================================
4517 //function : GetPointState
4518 //purpose : Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
4519 // TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
4520 //=======================================================================
4522 CORBA::Short SMESH_MeshEditor_i::GetPointState(CORBA::Double x,
4526 theSearchersDeleter.Set( myMesh );
4527 if ( !theElementSearcher ) {
4528 ::SMESH_MeshEditor anEditor( myMesh );
4529 theElementSearcher = anEditor.GetElementSearcher();
4531 return CORBA::Short( theElementSearcher->GetPointState( gp_Pnt( x,y,z )));
4534 //=======================================================================
4535 //function : convError
4537 //=======================================================================
4539 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
4541 static SMESH::SMESH_MeshEditor::Sew_Error convError( const::SMESH_MeshEditor::Sew_Error e )
4545 RETCASE( SEW_BORDER1_NOT_FOUND );
4546 RETCASE( SEW_BORDER2_NOT_FOUND );
4547 RETCASE( SEW_BOTH_BORDERS_NOT_FOUND );
4548 RETCASE( SEW_BAD_SIDE_NODES );
4549 RETCASE( SEW_VOLUMES_TO_SPLIT );
4550 RETCASE( SEW_DIFF_NB_OF_ELEMENTS );
4551 RETCASE( SEW_TOPO_DIFF_SETS_OF_ELEMENTS );
4552 RETCASE( SEW_BAD_SIDE1_NODES );
4553 RETCASE( SEW_BAD_SIDE2_NODES );
4555 return SMESH::SMESH_MeshEditor::SEW_OK;
4558 //=======================================================================
4559 //function : SewFreeBorders
4561 //=======================================================================
4563 SMESH::SMESH_MeshEditor::Sew_Error
4564 SMESH_MeshEditor_i::SewFreeBorders(CORBA::Long FirstNodeID1,
4565 CORBA::Long SecondNodeID1,
4566 CORBA::Long LastNodeID1,
4567 CORBA::Long FirstNodeID2,
4568 CORBA::Long SecondNodeID2,
4569 CORBA::Long LastNodeID2,
4570 CORBA::Boolean CreatePolygons,
4571 CORBA::Boolean CreatePolyedrs)
4575 SMESHDS_Mesh* aMesh = GetMeshDS();
4577 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
4578 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
4579 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
4580 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
4581 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
4582 const SMDS_MeshNode* aSide2ThirdNode = aMesh->FindNode( LastNodeID2 );
4584 if (!aBorderFirstNode ||
4585 !aBorderSecondNode||
4587 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
4588 if (!aSide2FirstNode ||
4589 !aSide2SecondNode ||
4591 return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
4593 TPythonDump() << "error = " << this << ".SewFreeBorders( "
4594 << FirstNodeID1 << ", "
4595 << SecondNodeID1 << ", "
4596 << LastNodeID1 << ", "
4597 << FirstNodeID2 << ", "
4598 << SecondNodeID2 << ", "
4599 << LastNodeID2 << ", "
4600 << CreatePolygons<< ", "
4601 << CreatePolyedrs<< " )";
4603 ::SMESH_MeshEditor anEditor( myMesh );
4604 SMESH::SMESH_MeshEditor::Sew_Error error =
4605 convError( anEditor.SewFreeBorder (aBorderFirstNode,
4615 storeResult(anEditor);
4617 myMesh->GetMeshDS()->Modified();
4618 myMesh->SetIsModified( true );
4624 //=======================================================================
4625 //function : SewConformFreeBorders
4627 //=======================================================================
4629 SMESH::SMESH_MeshEditor::Sew_Error
4630 SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1,
4631 CORBA::Long SecondNodeID1,
4632 CORBA::Long LastNodeID1,
4633 CORBA::Long FirstNodeID2,
4634 CORBA::Long SecondNodeID2)
4638 SMESHDS_Mesh* aMesh = GetMeshDS();
4640 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
4641 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
4642 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
4643 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
4644 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
4645 const SMDS_MeshNode* aSide2ThirdNode = 0;
4647 if (!aBorderFirstNode ||
4648 !aBorderSecondNode||
4650 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
4651 if (!aSide2FirstNode ||
4653 return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
4655 TPythonDump() << "error = " << this << ".SewConformFreeBorders( "
4656 << FirstNodeID1 << ", "
4657 << SecondNodeID1 << ", "
4658 << LastNodeID1 << ", "
4659 << FirstNodeID2 << ", "
4660 << SecondNodeID2 << " )";
4662 ::SMESH_MeshEditor anEditor( myMesh );
4663 SMESH::SMESH_MeshEditor::Sew_Error error =
4664 convError( anEditor.SewFreeBorder (aBorderFirstNode,
4673 storeResult(anEditor);
4675 myMesh->GetMeshDS()->Modified();
4676 myMesh->SetIsModified( true );
4682 //=======================================================================
4683 //function : SewBorderToSide
4685 //=======================================================================
4687 SMESH::SMESH_MeshEditor::Sew_Error
4688 SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder,
4689 CORBA::Long SecondNodeIDOnFreeBorder,
4690 CORBA::Long LastNodeIDOnFreeBorder,
4691 CORBA::Long FirstNodeIDOnSide,
4692 CORBA::Long LastNodeIDOnSide,
4693 CORBA::Boolean CreatePolygons,
4694 CORBA::Boolean CreatePolyedrs)
4698 SMESHDS_Mesh* aMesh = GetMeshDS();
4700 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeIDOnFreeBorder );
4701 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeIDOnFreeBorder );
4702 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeIDOnFreeBorder );
4703 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeIDOnSide );
4704 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( LastNodeIDOnSide );
4705 const SMDS_MeshNode* aSide2ThirdNode = 0;
4707 if (!aBorderFirstNode ||
4708 !aBorderSecondNode||
4710 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
4711 if (!aSide2FirstNode ||
4713 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE_NODES;
4715 TPythonDump() << "error = " << this << ".SewBorderToSide( "
4716 << FirstNodeIDOnFreeBorder << ", "
4717 << SecondNodeIDOnFreeBorder << ", "
4718 << LastNodeIDOnFreeBorder << ", "
4719 << FirstNodeIDOnSide << ", "
4720 << LastNodeIDOnSide << ", "
4721 << CreatePolygons << ", "
4722 << CreatePolyedrs << ") ";
4724 ::SMESH_MeshEditor anEditor( myMesh );
4725 SMESH::SMESH_MeshEditor::Sew_Error error =
4726 convError( anEditor.SewFreeBorder (aBorderFirstNode,
4736 storeResult(anEditor);
4738 myMesh->GetMeshDS()->Modified();
4739 myMesh->SetIsModified( true );
4745 //=======================================================================
4746 //function : SewSideElements
4748 //=======================================================================
4750 SMESH::SMESH_MeshEditor::Sew_Error
4751 SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements,
4752 const SMESH::long_array& IDsOfSide2Elements,
4753 CORBA::Long NodeID1OfSide1ToMerge,
4754 CORBA::Long NodeID1OfSide2ToMerge,
4755 CORBA::Long NodeID2OfSide1ToMerge,
4756 CORBA::Long NodeID2OfSide2ToMerge)
4760 SMESHDS_Mesh* aMesh = GetMeshDS();
4762 const SMDS_MeshNode* aFirstNode1ToMerge = aMesh->FindNode( NodeID1OfSide1ToMerge );
4763 const SMDS_MeshNode* aFirstNode2ToMerge = aMesh->FindNode( NodeID1OfSide2ToMerge );
4764 const SMDS_MeshNode* aSecondNode1ToMerge = aMesh->FindNode( NodeID2OfSide1ToMerge );
4765 const SMDS_MeshNode* aSecondNode2ToMerge = aMesh->FindNode( NodeID2OfSide2ToMerge );
4767 if (!aFirstNode1ToMerge ||
4768 !aFirstNode2ToMerge )
4769 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE1_NODES;
4770 if (!aSecondNode1ToMerge||
4771 !aSecondNode2ToMerge)
4772 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE2_NODES;
4774 TIDSortedElemSet aSide1Elems, aSide2Elems;
4775 arrayToSet(IDsOfSide1Elements, aMesh, aSide1Elems);
4776 arrayToSet(IDsOfSide2Elements, aMesh, aSide2Elems);
4778 TPythonDump() << "error = " << this << ".SewSideElements( "
4779 << IDsOfSide1Elements << ", "
4780 << IDsOfSide2Elements << ", "
4781 << NodeID1OfSide1ToMerge << ", "
4782 << NodeID1OfSide2ToMerge << ", "
4783 << NodeID2OfSide1ToMerge << ", "
4784 << NodeID2OfSide2ToMerge << ")";
4786 ::SMESH_MeshEditor anEditor( myMesh );
4787 SMESH::SMESH_MeshEditor::Sew_Error error =
4788 convError( anEditor.SewSideElements (aSide1Elems, aSide2Elems,
4791 aSecondNode1ToMerge,
4792 aSecondNode2ToMerge));
4794 storeResult(anEditor);
4796 myMesh->GetMeshDS()->Modified();
4797 myMesh->SetIsModified( true );
4802 //================================================================================
4804 * \brief Set new nodes for given element
4805 * \param ide - element id
4806 * \param newIDs - new node ids
4807 * \retval CORBA::Boolean - true if result is OK
4809 //================================================================================
4811 CORBA::Boolean SMESH_MeshEditor_i::ChangeElemNodes(CORBA::Long ide,
4812 const SMESH::long_array& newIDs)
4816 const SMDS_MeshElement* elem = GetMeshDS()->FindElement(ide);
4817 if(!elem) return false;
4819 int nbn = newIDs.length();
4821 vector<const SMDS_MeshNode*> aNodes(nbn);
4824 const SMDS_MeshNode* aNode = GetMeshDS()->FindNode(newIDs[i]);
4827 aNodes[nbn1] = aNode;
4830 TPythonDump() << "isDone = " << this << ".ChangeElemNodes( "
4831 << ide << ", " << newIDs << " )";
4833 MESSAGE("ChangeElementNodes");
4834 bool res = GetMeshDS()->ChangeElementNodes( elem, & aNodes[0], nbn1+1 );
4836 myMesh->GetMeshDS()->Modified();
4838 myMesh->SetIsModified( true );
4843 //================================================================================
4845 * \brief Update myLastCreated* or myPreviewData
4846 * \param anEditor - it contains last modification results
4848 //================================================================================
4850 void SMESH_MeshEditor_i::storeResult(::SMESH_MeshEditor& anEditor)
4852 if ( myPreviewMode ) { // --- MeshPreviewStruct filling ---
4854 list<int> aNodesConnectivity;
4855 typedef map<int, int> TNodesMap;
4858 TPreviewMesh * aPreviewMesh = dynamic_cast< TPreviewMesh* >( anEditor.GetMesh() );
4859 SMDSAbs_ElementType previewType = aPreviewMesh->myPreviewType;
4861 SMESHDS_Mesh* aMeshDS = anEditor.GetMeshDS();
4862 int nbEdges = aMeshDS->NbEdges();
4863 int nbFaces = aMeshDS->NbFaces();
4864 int nbVolum = aMeshDS->NbVolumes();
4865 switch ( previewType ) {
4866 case SMDSAbs_Edge : nbFaces = nbVolum = 0; break;
4867 case SMDSAbs_Face : nbEdges = nbVolum = 0; break;
4868 case SMDSAbs_Volume: nbEdges = nbFaces = 0; break;
4871 myPreviewData->nodesXYZ.length(aMeshDS->NbNodes());
4872 myPreviewData->elementTypes.length(nbEdges + nbFaces + nbVolum);
4874 SMDS_ElemIteratorPtr itMeshElems = aMeshDS->elementsIterator();
4876 while ( itMeshElems->more() ) {
4877 const SMDS_MeshElement* aMeshElem = itMeshElems->next();
4878 if ( previewType != SMDSAbs_All && aMeshElem->GetType() != previewType )
4881 SMDS_ElemIteratorPtr itElemNodes = aMeshElem->nodesIterator();
4882 while ( itElemNodes->more() ) {
4883 const SMDS_MeshNode* aMeshNode =
4884 static_cast<const SMDS_MeshNode*>( itElemNodes->next() );
4885 int aNodeID = aMeshNode->GetID();
4886 TNodesMap::iterator anIter = nodesMap.find(aNodeID);
4887 if ( anIter == nodesMap.end() ) {
4888 // filling the nodes coordinates
4889 myPreviewData->nodesXYZ[j].x = aMeshNode->X();
4890 myPreviewData->nodesXYZ[j].y = aMeshNode->Y();
4891 myPreviewData->nodesXYZ[j].z = aMeshNode->Z();
4892 anIter = nodesMap.insert( make_pair(aNodeID, j) ).first;
4895 aNodesConnectivity.push_back(anIter->second);
4898 // filling the elements types
4899 SMDSAbs_ElementType aType;
4901 /*if (aMeshElem->GetType() == SMDSAbs_Volume) {
4902 aType = SMDSAbs_Node;
4906 aType = aMeshElem->GetType();
4907 isPoly = aMeshElem->IsPoly();
4910 myPreviewData->elementTypes[i].SMDS_ElementType = (SMESH::ElementType) aType;
4911 myPreviewData->elementTypes[i].isPoly = isPoly;
4912 myPreviewData->elementTypes[i].nbNodesInElement = aMeshElem->NbNodes();
4916 myPreviewData->nodesXYZ.length( j );
4918 // filling the elements connectivities
4919 list<int>::iterator aConnIter = aNodesConnectivity.begin();
4920 myPreviewData->elementConnectivities.length(aNodesConnectivity.size());
4921 for( int i = 0; aConnIter != aNodesConnectivity.end(); aConnIter++, i++ )
4922 myPreviewData->elementConnectivities[i] = *aConnIter;
4928 // append new nodes into myLastCreatedNodes
4929 const SMESH_SequenceOfElemPtr& aSeq = anEditor.GetLastCreatedNodes();
4930 int j = myLastCreatedNodes->length();
4931 int newLen = j + aSeq.Length();
4932 myLastCreatedNodes->length( newLen );
4933 for(int i=0; j<newLen; i++,j++)
4934 myLastCreatedNodes[j] = aSeq.Value(i+1)->GetID();
4937 // append new elements into myLastCreatedElems
4938 const SMESH_SequenceOfElemPtr& aSeq = anEditor.GetLastCreatedElems();
4939 int j = myLastCreatedElems->length();
4940 int newLen = j + aSeq.Length();
4941 myLastCreatedElems->length( newLen );
4942 for(int i=0; j<newLen; i++,j++)
4943 myLastCreatedElems[j] = aSeq.Value(i+1)->GetID();
4947 //================================================================================
4949 * Return data of mesh edition preview
4951 //================================================================================
4953 SMESH::MeshPreviewStruct* SMESH_MeshEditor_i::GetPreviewData()
4955 return myPreviewData._retn();
4958 //================================================================================
4960 * \brief Returns list of it's IDs of created nodes
4961 * \retval SMESH::long_array* - list of node ID
4963 //================================================================================
4965 SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedNodes()
4967 return myLastCreatedNodes._retn();
4970 //================================================================================
4972 * \brief Returns list of it's IDs of created elements
4973 * \retval SMESH::long_array* - list of elements' ID
4975 //================================================================================
4977 SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedElems()
4979 return myLastCreatedElems._retn();
4982 //=======================================================================
4983 //function : ConvertToQuadratic
4985 //=======================================================================
4987 void SMESH_MeshEditor_i::ConvertToQuadratic(CORBA::Boolean theForce3d)
4989 ::SMESH_MeshEditor anEditor( myMesh );
4990 anEditor.ConvertToQuadratic(theForce3d);
4991 TPythonDump() << this << ".ConvertToQuadratic( " << theForce3d << " )";
4992 myMesh->GetMeshDS()->Modified();
4993 myMesh->SetIsModified( true );
4996 //=======================================================================
4997 //function : ConvertFromQuadratic
4999 //=======================================================================
5001 CORBA::Boolean SMESH_MeshEditor_i::ConvertFromQuadratic()
5003 ::SMESH_MeshEditor anEditor( myMesh );
5004 CORBA::Boolean isDone = anEditor.ConvertFromQuadratic();
5005 TPythonDump() << this << ".ConvertFromQuadratic()";
5006 myMesh->GetMeshDS()->Modified();
5008 myMesh->SetIsModified( true );
5011 //================================================================================
5013 * \brief Makes a part of the mesh quadratic
5015 //================================================================================
5017 void SMESH_MeshEditor_i::ConvertToQuadraticObject(CORBA::Boolean theForce3d,
5018 SMESH::SMESH_IDSource_ptr theObject)
5019 throw (SALOME::SALOME_Exception)
5021 Unexpect aCatch(SALOME_SalomeException);
5023 TIDSortedElemSet elems;
5024 if ( idSourceToSet( theObject, GetMeshDS(), elems, SMDSAbs_All, /*emptyIfIsMesh=*/true ))
5026 if ( elems.empty() )
5028 ConvertToQuadratic( theForce3d );
5030 else if ( (*elems.begin())->GetType() == SMDSAbs_Node )
5032 THROW_SALOME_CORBA_EXCEPTION("Group of nodes is not allowed", SALOME::BAD_PARAM);
5036 ::SMESH_MeshEditor anEditor( myMesh );
5037 anEditor.ConvertToQuadratic(theForce3d, elems);
5040 myMesh->GetMeshDS()->Modified();
5041 myMesh->SetIsModified( true );
5043 pyDump << this << ".ConvertToQuadraticObject( "<<theForce3d<<", "<<theObject<<" )";
5046 //================================================================================
5048 * \brief Makes a part of the mesh linear
5050 //================================================================================
5052 void SMESH_MeshEditor_i::ConvertFromQuadraticObject(SMESH::SMESH_IDSource_ptr theObject)
5053 throw (SALOME::SALOME_Exception)
5055 Unexpect aCatch(SALOME_SalomeException);
5057 TIDSortedElemSet elems;
5058 if ( idSourceToSet( theObject, GetMeshDS(), elems, SMDSAbs_All, /*emptyIfIsMesh=*/true ))
5060 if ( elems.empty() )
5062 ConvertFromQuadratic();
5064 else if ( (*elems.begin())->GetType() == SMDSAbs_Node )
5066 THROW_SALOME_CORBA_EXCEPTION("Group of nodes is not allowed", SALOME::BAD_PARAM);
5070 ::SMESH_MeshEditor anEditor( myMesh );
5071 anEditor.ConvertFromQuadratic(elems);
5074 myMesh->GetMeshDS()->Modified();
5075 myMesh->SetIsModified( true );
5077 pyDump << this << ".ConvertFromQuadraticObject( "<<theObject<<" )";
5080 //=======================================================================
5081 //function : makeMesh
5082 //purpose : create a named imported mesh
5083 //=======================================================================
5085 SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::makeMesh(const char* theMeshName)
5087 SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen();
5088 SMESH::SMESH_Mesh_var mesh = gen->CreateEmptyMesh();
5089 SALOMEDS::Study_var study = gen->GetCurrentStudy();
5090 SALOMEDS::SObject_var meshSO = gen->ObjectToSObject( study, mesh );
5091 gen->SetName( meshSO, theMeshName, "Mesh" );
5092 gen->SetPixMap( meshSO, "ICON_SMESH_TREE_MESH_IMPORTED");
5094 return mesh._retn();
5097 //=======================================================================
5098 //function : DumpGroupsList
5100 //=======================================================================
5101 void SMESH_MeshEditor_i::DumpGroupsList(TPythonDump & theDumpPython,
5102 const SMESH::ListOfGroups * theGroupList)
5104 bool isDumpGroupList = theGroupList && theGroupList->length() > 0;
5105 if(isDumpGroupList) {
5106 theDumpPython << theGroupList << " = ";
5110 //================================================================================
5112 \brief Generates the unique group name.
5113 \param thePrefix name prefix
5116 //================================================================================
5117 string SMESH_MeshEditor_i::generateGroupName(const string& thePrefix)
5119 SMESH::ListOfGroups_var groups = myMesh_i->GetGroups();
5120 set<string> groupNames;
5122 // Get existing group names
5123 for (int i = 0, nbGroups = groups->length(); i < nbGroups; i++ ) {
5124 SMESH::SMESH_GroupBase_var aGroup = groups[i];
5125 if (CORBA::is_nil(aGroup))
5128 groupNames.insert(aGroup->GetName());
5132 string name = thePrefix;
5135 while (!groupNames.insert(name).second) {
5140 TCollection_AsciiString nbStr(index+1);
5141 name.resize( name.rfind('_')+1 );
5142 name += nbStr.ToCString();
5150 //================================================================================
5152 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5153 \param theNodes - identifiers of nodes to be doubled
5154 \param theModifiedElems - identifiers of elements to be updated by the new (doubled)
5155 nodes. If list of element identifiers is empty then nodes are doubled but
5156 they not assigned to elements
5157 \return TRUE if operation has been completed successfully, FALSE otherwise
5158 \sa DoubleNode(), DoubleNodeGroup(), DoubleNodeGroups()
5160 //================================================================================
5162 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodes( const SMESH::long_array& theNodes,
5163 const SMESH::long_array& theModifiedElems )
5167 ::SMESH_MeshEditor aMeshEditor( myMesh );
5168 list< int > aListOfNodes;
5170 for ( i = 0, n = theNodes.length(); i < n; i++ )
5171 aListOfNodes.push_back( theNodes[ i ] );
5173 list< int > aListOfElems;
5174 for ( i = 0, n = theModifiedElems.length(); i < n; i++ )
5175 aListOfElems.push_back( theModifiedElems[ i ] );
5177 bool aResult = aMeshEditor.DoubleNodes( aListOfNodes, aListOfElems );
5179 myMesh->GetMeshDS()->Modified();
5180 storeResult( aMeshEditor) ;
5182 myMesh->SetIsModified( true );
5184 // Update Python script
5185 TPythonDump() << this << ".DoubleNodes( " << theNodes << ", "<< theModifiedElems << " )";
5190 //================================================================================
5192 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5193 This method provided for convenience works as DoubleNodes() described above.
5194 \param theNodeId - identifier of node to be doubled.
5195 \param theModifiedElems - identifiers of elements to be updated.
5196 \return TRUE if operation has been completed successfully, FALSE otherwise
5197 \sa DoubleNodes(), DoubleNodeGroup(), DoubleNodeGroups()
5199 //================================================================================
5201 CORBA::Boolean SMESH_MeshEditor_i::DoubleNode( CORBA::Long theNodeId,
5202 const SMESH::long_array& theModifiedElems )
5204 SMESH::long_array_var aNodes = new SMESH::long_array;
5205 aNodes->length( 1 );
5206 aNodes[ 0 ] = theNodeId;
5208 TPythonDump pyDump; // suppress dump by the next line
5210 CORBA::Boolean done = DoubleNodes( aNodes, theModifiedElems );
5212 pyDump << this << ".DoubleNode( " << theNodeId << ", " << theModifiedElems << " )";
5217 //================================================================================
5219 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5220 This method provided for convenience works as DoubleNodes() described above.
5221 \param theNodes - group of nodes to be doubled.
5222 \param theModifiedElems - group of elements to be updated.
5223 \return TRUE if operation has been completed successfully, FALSE otherwise
5224 \sa DoubleNode(), DoubleNodes(), DoubleNodeGroups()
5226 //================================================================================
5228 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroup(SMESH::SMESH_GroupBase_ptr theNodes,
5229 SMESH::SMESH_GroupBase_ptr theModifiedElems )
5231 if ( CORBA::is_nil( theNodes ) && theNodes->GetType() != SMESH::NODE )
5234 SMESH::long_array_var aNodes = theNodes->GetListOfID();
5235 SMESH::long_array_var aModifiedElems;
5236 if ( !CORBA::is_nil( theModifiedElems ) )
5237 aModifiedElems = theModifiedElems->GetListOfID();
5240 aModifiedElems = new SMESH::long_array;
5241 aModifiedElems->length( 0 );
5244 TPythonDump pyDump; // suppress dump by the next line
5246 bool done = DoubleNodes( aNodes, aModifiedElems );
5248 pyDump << this << ".DoubleNodeGroup( " << theNodes << ", " << theModifiedElems << " )";
5254 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements.
5255 * Works as DoubleNodeGroup(), but returns a new group with newly created nodes.
5256 * \param theNodes - group of nodes to be doubled.
5257 * \param theModifiedElems - group of elements to be updated.
5258 * \return a new group with newly created nodes
5259 * \sa DoubleNodeGroup()
5261 SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeGroupNew( SMESH::SMESH_GroupBase_ptr theNodes,
5262 SMESH::SMESH_GroupBase_ptr theModifiedElems )
5264 if ( CORBA::is_nil( theNodes ) && theNodes->GetType() != SMESH::NODE )
5267 SMESH::SMESH_Group_var aNewGroup;
5270 SMESH::long_array_var aNodes = theNodes->GetListOfID();
5271 SMESH::long_array_var aModifiedElems;
5272 if ( !CORBA::is_nil( theModifiedElems ) )
5273 aModifiedElems = theModifiedElems->GetListOfID();
5275 aModifiedElems = new SMESH::long_array;
5276 aModifiedElems->length( 0 );
5279 TPythonDump pyDump; // suppress dump by the next line
5281 bool aResult = DoubleNodes( aNodes, aModifiedElems );
5285 // Create group with newly created nodes
5286 SMESH::long_array_var anIds = GetLastCreatedNodes();
5287 if (anIds->length() > 0) {
5288 string anUnindexedName (theNodes->GetName());
5289 string aNewName = generateGroupName(anUnindexedName + "_double");
5290 aNewGroup = myMesh_i->CreateGroup(SMESH::NODE, aNewName.c_str());
5291 aNewGroup->Add(anIds);
5295 pyDump << "createdNodes = " << this << ".DoubleNodeGroupNew( " << theNodes << ", "
5296 << theModifiedElems << " )";
5298 return aNewGroup._retn();
5301 //================================================================================
5303 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5304 This method provided for convenience works as DoubleNodes() described above.
5305 \param theNodes - list of groups of nodes to be doubled
5306 \param theModifiedElems - list of groups of elements to be updated.
5307 \return TRUE if operation has been completed successfully, FALSE otherwise
5308 \sa DoubleNode(), DoubleNodeGroup(), DoubleNodes()
5310 //================================================================================
5312 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroups(const SMESH::ListOfGroups& theNodes,
5313 const SMESH::ListOfGroups& theModifiedElems )
5317 ::SMESH_MeshEditor aMeshEditor( myMesh );
5319 std::list< int > aNodes;
5321 for ( i = 0, n = theNodes.length(); i < n; i++ )
5323 SMESH::SMESH_GroupBase_var aGrp = theNodes[ i ];
5324 if ( !CORBA::is_nil( aGrp ) && aGrp->GetType() == SMESH::NODE )
5326 SMESH::long_array_var aCurr = aGrp->GetListOfID();
5327 for ( j = 0, m = aCurr->length(); j < m; j++ )
5328 aNodes.push_back( aCurr[ j ] );
5332 std::list< int > anElems;
5333 for ( i = 0, n = theModifiedElems.length(); i < n; i++ )
5335 SMESH::SMESH_GroupBase_var aGrp = theModifiedElems[ i ];
5336 if ( !CORBA::is_nil( aGrp ) && aGrp->GetType() != SMESH::NODE )
5338 SMESH::long_array_var aCurr = aGrp->GetListOfID();
5339 for ( j = 0, m = aCurr->length(); j < m; j++ )
5340 anElems.push_back( aCurr[ j ] );
5344 bool aResult = aMeshEditor.DoubleNodes( aNodes, anElems );
5346 storeResult( aMeshEditor) ;
5348 myMesh->GetMeshDS()->Modified();
5350 myMesh->SetIsModified( true );
5353 TPythonDump() << this << ".DoubleNodeGroups( " << theNodes << ", " << theModifiedElems << " )";
5358 //================================================================================
5360 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements.
5361 * Works as DoubleNodeGroups(), but returns a new group with newly created nodes.
5362 * \param theNodes - group of nodes to be doubled.
5363 * \param theModifiedElems - group of elements to be updated.
5364 * \return a new group with newly created nodes
5365 * \sa DoubleNodeGroups()
5367 //================================================================================
5369 SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeGroupsNew( const SMESH::ListOfGroups& theNodes,
5370 const SMESH::ListOfGroups& theModifiedElems )
5372 SMESH::SMESH_Group_var aNewGroup;
5374 TPythonDump pyDump; // suppress dump by the next line
5376 bool aResult = DoubleNodeGroups( theNodes, theModifiedElems );
5380 // Create group with newly created nodes
5381 SMESH::long_array_var anIds = GetLastCreatedNodes();
5382 if (anIds->length() > 0) {
5383 string anUnindexedName (theNodes[0]->GetName());
5384 string aNewName = generateGroupName(anUnindexedName + "_double");
5385 aNewGroup = myMesh_i->CreateGroup(SMESH::NODE, aNewName.c_str());
5386 aNewGroup->Add(anIds);
5390 pyDump << "createdNodes = " << this << ".DoubleNodeGroupsNew( " << theNodes << ", "
5391 << theModifiedElems << " )";
5393 return aNewGroup._retn();
5397 //================================================================================
5399 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5400 \param theElems - the list of elements (edges or faces) to be replicated
5401 The nodes for duplication could be found from these elements
5402 \param theNodesNot - list of nodes to NOT replicate
5403 \param theAffectedElems - the list of elements (cells and edges) to which the
5404 replicated nodes should be associated to.
5405 \return TRUE if operation has been completed successfully, FALSE otherwise
5406 \sa DoubleNodeGroup(), DoubleNodeGroups()
5408 //================================================================================
5410 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElem( const SMESH::long_array& theElems,
5411 const SMESH::long_array& theNodesNot,
5412 const SMESH::long_array& theAffectedElems )
5417 ::SMESH_MeshEditor aMeshEditor( myMesh );
5419 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5420 TIDSortedElemSet anElems, aNodes, anAffected;
5421 arrayToSet(theElems, aMeshDS, anElems, SMDSAbs_All);
5422 arrayToSet(theNodesNot, aMeshDS, aNodes, SMDSAbs_Node);
5423 arrayToSet(theAffectedElems, aMeshDS, anAffected, SMDSAbs_All);
5425 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
5427 storeResult( aMeshEditor) ;
5429 myMesh->GetMeshDS()->Modified();
5431 myMesh->SetIsModified( true );
5433 // Update Python script
5434 TPythonDump() << this << ".DoubleNodeElem( " << theElems << ", "
5435 << theNodesNot << ", " << theAffectedElems << " )";
5439 //================================================================================
5441 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5442 \param theElems - the list of elements (edges or faces) to be replicated
5443 The nodes for duplication could be found from these elements
5444 \param theNodesNot - list of nodes to NOT replicate
5445 \param theShape - shape to detect affected elements (element which geometric center
5446 located on or inside shape).
5447 The replicated nodes should be associated to affected elements.
5448 \return TRUE if operation has been completed successfully, FALSE otherwise
5449 \sa DoubleNodeGroupInRegion(), DoubleNodeGroupsInRegion()
5451 //================================================================================
5453 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemInRegion ( const SMESH::long_array& theElems,
5454 const SMESH::long_array& theNodesNot,
5455 GEOM::GEOM_Object_ptr theShape )
5460 ::SMESH_MeshEditor aMeshEditor( myMesh );
5462 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5463 TIDSortedElemSet anElems, aNodes;
5464 arrayToSet(theElems, aMeshDS, anElems, SMDSAbs_All);
5465 arrayToSet(theNodesNot, aMeshDS, aNodes, SMDSAbs_Node);
5467 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape );
5468 bool aResult = aMeshEditor.DoubleNodesInRegion( anElems, aNodes, aShape );
5470 storeResult( aMeshEditor) ;
5472 myMesh->GetMeshDS()->Modified();
5474 myMesh->SetIsModified( true );
5476 // Update Python script
5477 TPythonDump() << "isDone = " << this << ".DoubleNodeElemInRegion( " << theElems << ", "
5478 << theNodesNot << ", " << theShape << " )";
5482 //================================================================================
5484 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5485 \param theElems - group of of elements (edges or faces) to be replicated
5486 \param theNodesNot - group of nodes not to replicated
5487 \param theAffectedElems - group of elements to which the replicated nodes
5488 should be associated to.
5489 \return TRUE if operation has been completed successfully, FALSE otherwise
5490 \sa DoubleNodes(), DoubleNodeGroups()
5492 //================================================================================
5494 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroup(SMESH::SMESH_GroupBase_ptr theElems,
5495 SMESH::SMESH_GroupBase_ptr theNodesNot,
5496 SMESH::SMESH_GroupBase_ptr theAffectedElems)
5498 if ( CORBA::is_nil( theElems ) && theElems->GetType() == SMESH::NODE )
5503 ::SMESH_MeshEditor aMeshEditor( myMesh );
5505 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5506 TIDSortedElemSet anElems, aNodes, anAffected;
5507 idSourceToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
5508 idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
5509 idSourceToSet( theAffectedElems, aMeshDS, anAffected, SMDSAbs_All );
5511 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
5513 storeResult( aMeshEditor) ;
5515 myMesh->GetMeshDS()->Modified();
5517 myMesh->SetIsModified( true );
5519 // Update Python script
5520 TPythonDump() << "isDone = " << this << ".DoubleNodeElemGroup( " << theElems << ", "
5521 << theNodesNot << ", " << theAffectedElems << " )";
5526 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5527 * Works as DoubleNodeElemGroup(), but returns a new group with newly created elements.
5528 * \param theElems - group of of elements (edges or faces) to be replicated
5529 * \param theNodesNot - group of nodes not to replicated
5530 * \param theAffectedElems - group of elements to which the replicated nodes
5531 * should be associated to.
5532 * \return a new group with newly created elements
5533 * \sa DoubleNodeElemGroup()
5535 SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeElemGroupNew(SMESH::SMESH_GroupBase_ptr theElems,
5536 SMESH::SMESH_GroupBase_ptr theNodesNot,
5537 SMESH::SMESH_GroupBase_ptr theAffectedElems)
5539 if ( CORBA::is_nil( theElems ) && theElems->GetType() == SMESH::NODE )
5542 SMESH::SMESH_Group_var aNewGroup;
5546 ::SMESH_MeshEditor aMeshEditor( myMesh );
5548 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5549 TIDSortedElemSet anElems, aNodes, anAffected;
5550 idSourceToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
5551 idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
5552 idSourceToSet( theAffectedElems, aMeshDS, anAffected, SMDSAbs_All );
5555 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
5557 storeResult( aMeshEditor) ;
5560 myMesh->SetIsModified( true );
5562 // Create group with newly created elements
5563 SMESH::long_array_var anIds = GetLastCreatedElems();
5564 if (anIds->length() > 0) {
5565 SMESH::ElementType aGroupType = myMesh_i->GetElementType(anIds[0], true);
5566 string anUnindexedName (theElems->GetName());
5567 string aNewName = generateGroupName(anUnindexedName + "_double");
5568 aNewGroup = myMesh_i->CreateGroup(aGroupType, aNewName.c_str());
5569 aNewGroup->Add(anIds);
5573 // Update Python script
5574 TPythonDump() << "createdElems = " << this << ".DoubleNodeElemGroupNew( " << theElems << ", "
5575 << theNodesNot << ", " << theAffectedElems << " )";
5576 return aNewGroup._retn();
5579 //================================================================================
5581 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5582 \param theElems - group of of elements (edges or faces) to be replicated
5583 \param theNodesNot - group of nodes not to replicated
5584 \param theShape - shape to detect affected elements (element which geometric center
5585 located on or inside shape).
5586 The replicated nodes should be associated to affected elements.
5587 \return TRUE if operation has been completed successfully, FALSE otherwise
5588 \sa DoubleNodesInRegion(), DoubleNodeGroupsInRegion()
5590 //================================================================================
5592 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroupInRegion(SMESH::SMESH_GroupBase_ptr theElems,
5593 SMESH::SMESH_GroupBase_ptr theNodesNot,
5594 GEOM::GEOM_Object_ptr theShape )
5597 if ( CORBA::is_nil( theElems ) && theElems->GetType() == SMESH::NODE )
5602 ::SMESH_MeshEditor aMeshEditor( myMesh );
5604 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5605 TIDSortedElemSet anElems, aNodes, anAffected;
5606 idSourceToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
5607 idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
5609 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape );
5610 bool aResult = aMeshEditor.DoubleNodesInRegion( anElems, aNodes, aShape );
5612 storeResult( aMeshEditor) ;
5614 myMesh->GetMeshDS()->Modified();
5616 myMesh->SetIsModified( true );
5618 // Update Python script
5619 TPythonDump() << "isDone = " << this << ".DoubleNodeElemGroupInRegion( " << theElems << ", "
5620 << theNodesNot << ", " << theShape << " )";
5624 //================================================================================
5626 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5627 This method provided for convenience works as DoubleNodes() described above.
5628 \param theElems - list of groups of elements (edges or faces) to be replicated
5629 \param theNodesNot - list of groups of nodes not to replicated
5630 \param theAffectedElems - group of elements to which the replicated nodes
5631 should be associated to.
5632 \return TRUE if operation has been completed successfully, FALSE otherwise
5633 \sa DoubleNodeGroup(), DoubleNodes(), DoubleNodeElemGroupsNew()
5635 //================================================================================
5637 static void listOfGroupToSet(const SMESH::ListOfGroups& theGrpList,
5638 SMESHDS_Mesh* theMeshDS,
5639 TIDSortedElemSet& theElemSet,
5640 const bool theIsNodeGrp)
5642 for ( int i = 0, n = theGrpList.length(); i < n; i++ )
5644 SMESH::SMESH_GroupBase_var aGrp = theGrpList[ i ];
5645 if ( !CORBA::is_nil( aGrp ) && (theIsNodeGrp ? aGrp->GetType() == SMESH::NODE
5646 : aGrp->GetType() != SMESH::NODE ) )
5648 SMESH::long_array_var anIDs = aGrp->GetIDs();
5649 arrayToSet( anIDs, theMeshDS, theElemSet, theIsNodeGrp ? SMDSAbs_Node : SMDSAbs_All );
5654 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroups(const SMESH::ListOfGroups& theElems,
5655 const SMESH::ListOfGroups& theNodesNot,
5656 const SMESH::ListOfGroups& theAffectedElems)
5660 ::SMESH_MeshEditor aMeshEditor( myMesh );
5662 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5663 TIDSortedElemSet anElems, aNodes, anAffected;
5664 listOfGroupToSet(theElems, aMeshDS, anElems, false );
5665 listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true );
5666 listOfGroupToSet(theAffectedElems, aMeshDS, anAffected, false );
5668 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
5670 storeResult( aMeshEditor) ;
5672 myMesh->GetMeshDS()->Modified();
5674 myMesh->SetIsModified( true );
5676 // Update Python script
5677 TPythonDump() << "isDone = " << this << ".DoubleNodeElemGroups( " << &theElems << ", "
5678 << &theNodesNot << ", " << &theAffectedElems << " )";
5682 //================================================================================
5684 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5685 * Works as DoubleNodeElemGroups(), but returns a new group with newly created elements.
5686 \param theElems - list of groups of elements (edges or faces) to be replicated
5687 \param theNodesNot - list of groups of nodes not to replicated
5688 \param theAffectedElems - group of elements to which the replicated nodes
5689 should be associated to.
5690 * \return a new group with newly created elements
5691 * \sa DoubleNodeElemGroups()
5693 //================================================================================
5695 SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeElemGroupsNew(const SMESH::ListOfGroups& theElems,
5696 const SMESH::ListOfGroups& theNodesNot,
5697 const SMESH::ListOfGroups& theAffectedElems)
5699 SMESH::SMESH_Group_var aNewGroup;
5703 ::SMESH_MeshEditor aMeshEditor( myMesh );
5705 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5706 TIDSortedElemSet anElems, aNodes, anAffected;
5707 listOfGroupToSet(theElems, aMeshDS, anElems, false );
5708 listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true );
5709 listOfGroupToSet(theAffectedElems, aMeshDS, anAffected, false );
5711 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
5713 storeResult( aMeshEditor) ;
5715 myMesh->GetMeshDS()->Modified();
5717 myMesh->SetIsModified( true );
5719 // Create group with newly created elements
5720 SMESH::long_array_var anIds = GetLastCreatedElems();
5721 if (anIds->length() > 0) {
5722 SMESH::ElementType aGroupType = myMesh_i->GetElementType(anIds[0], true);
5723 string anUnindexedName (theElems[0]->GetName());
5724 string aNewName = generateGroupName(anUnindexedName + "_double");
5725 aNewGroup = myMesh_i->CreateGroup(aGroupType, aNewName.c_str());
5726 aNewGroup->Add(anIds);
5730 // Update Python script
5731 TPythonDump() << "createdElems = " << this << ".DoubleNodeElemGroupsNew( " << &theElems << ", "
5732 << &theNodesNot << ", " << &theAffectedElems << " )";
5733 return aNewGroup._retn();
5736 //================================================================================
5738 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5739 This method provided for convenience works as DoubleNodes() described above.
5740 \param theElems - list of groups of elements (edges or faces) to be replicated
5741 \param theNodesNot - list of groups of nodes not to replicated
5742 \param theShape - shape to detect affected elements (element which geometric center
5743 located on or inside shape).
5744 The replicated nodes should be associated to affected elements.
5745 \return TRUE if operation has been completed successfully, FALSE otherwise
5746 \sa DoubleNodeGroupInRegion(), DoubleNodesInRegion()
5748 //================================================================================
5751 SMESH_MeshEditor_i::DoubleNodeElemGroupsInRegion(const SMESH::ListOfGroups& theElems,
5752 const SMESH::ListOfGroups& theNodesNot,
5753 GEOM::GEOM_Object_ptr theShape )
5757 ::SMESH_MeshEditor aMeshEditor( myMesh );
5759 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5760 TIDSortedElemSet anElems, aNodes;
5761 listOfGroupToSet(theElems, aMeshDS, anElems,false );
5762 listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true );
5764 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape );
5765 bool aResult = aMeshEditor.DoubleNodesInRegion( anElems, aNodes, aShape );
5767 storeResult( aMeshEditor) ;
5769 myMesh->GetMeshDS()->Modified();
5771 myMesh->SetIsModified( true );
5773 // Update Python script
5774 TPythonDump() << "isDone = " << this << ".DoubleNodeElemGroupsInRegion( " << &theElems << ", "
5775 << &theNodesNot << ", " << theShape << " )";
5779 //================================================================================
5781 \brief Generated skin mesh (containing 2D cells) from 3D mesh
5782 The created 2D mesh elements based on nodes of free faces of boundary volumes
5783 \return TRUE if operation has been completed successfully, FALSE otherwise
5785 //================================================================================
5787 CORBA::Boolean SMESH_MeshEditor_i::Make2DMeshFrom3D()
5791 ::SMESH_MeshEditor aMeshEditor( myMesh );
5792 bool aResult = aMeshEditor.Make2DMeshFrom3D();
5793 storeResult( aMeshEditor) ;
5794 myMesh->GetMeshDS()->Modified();
5795 TPythonDump() << "isDone = " << this << ".Make2DMeshFrom3D()";
5799 //================================================================================
5801 * \brief Double nodes on shared faces between groups of volumes and create flat elements on demand.
5802 * The list of groups must describe a partition of the mesh volumes.
5803 * The nodes of the internal faces at the boundaries of the groups are doubled.
5804 * In option, the internal faces are replaced by flat elements.
5805 * Triangles are transformed in prisms, and quadrangles in hexahedrons.
5806 * The flat elements are stored in groups of volumes.
5807 * @param theDomains - list of groups of volumes
5808 * @param createJointElems - if TRUE, create the elements
5809 * @return TRUE if operation has been completed successfully, FALSE otherwise
5811 //================================================================================
5813 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodesOnGroupBoundaries( const SMESH::ListOfGroups& theDomains,
5814 CORBA::Boolean createJointElems )
5815 throw (SALOME::SALOME_Exception)
5819 ::SMESH_MeshEditor aMeshEditor( myMesh );
5821 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5823 vector<TIDSortedElemSet> domains;
5826 for ( int i = 0, n = theDomains.length(); i < n; i++ )
5828 SMESH::SMESH_GroupBase_var aGrp = theDomains[ i ];
5829 if ( !CORBA::is_nil( aGrp ) /*&& ( aGrp->GetType() != SMESH::NODE )*/ )
5831 // if ( aGrp->GetType() != SMESH::VOLUME )
5832 // THROW_SALOME_CORBA_EXCEPTION("Not a volume group", SALOME::BAD_PARAM);
5833 TIDSortedElemSet domain;
5835 domains.push_back(domain);
5836 SMESH::long_array_var anIDs = aGrp->GetIDs();
5837 arrayToSet( anIDs, aMeshDS, domains[ i ], SMDSAbs_All );
5841 bool aResult = aMeshEditor.DoubleNodesOnGroupBoundaries( domains, createJointElems );
5842 // TODO publish the groups of flat elements in study
5844 storeResult( aMeshEditor) ;
5845 myMesh->GetMeshDS()->Modified();
5847 // Update Python script
5848 TPythonDump() << "isDone = " << this << ".DoubleNodesOnGroupBoundaries( " << &theDomains
5849 << ", " << createJointElems << " )";
5853 //================================================================================
5855 * \brief Double nodes on some external faces and create flat elements.
5856 * Flat elements are mainly used by some types of mechanic calculations.
5858 * Each group of the list must be constituted of faces.
5859 * Triangles are transformed in prisms, and quadrangles in hexahedrons.
5860 * @param theGroupsOfFaces - list of groups of faces
5861 * @return TRUE if operation has been completed successfully, FALSE otherwise
5863 //================================================================================
5865 CORBA::Boolean SMESH_MeshEditor_i::CreateFlatElementsOnFacesGroups( const SMESH::ListOfGroups& theGroupsOfFaces )
5869 ::SMESH_MeshEditor aMeshEditor( myMesh );
5871 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5873 vector<TIDSortedElemSet> faceGroups;
5876 for ( int i = 0, n = theGroupsOfFaces.length(); i < n; i++ )
5878 SMESH::SMESH_GroupBase_var aGrp = theGroupsOfFaces[ i ];
5879 if ( !CORBA::is_nil( aGrp ) && ( aGrp->GetType() != SMESH::NODE ) )
5881 TIDSortedElemSet faceGroup;
5883 faceGroups.push_back(faceGroup);
5884 SMESH::long_array_var anIDs = aGrp->GetIDs();
5885 arrayToSet( anIDs, aMeshDS, faceGroups[ i ], SMDSAbs_All );
5889 bool aResult = aMeshEditor.CreateFlatElementsOnFacesGroups( faceGroups );
5890 // TODO publish the groups of flat elements in study
5892 storeResult( aMeshEditor) ;
5893 myMesh->GetMeshDS()->Modified();
5895 // Update Python script
5896 TPythonDump() << "isDone = " << this << ".CreateFlatElementsOnFacesGroups( " << &theGroupsOfFaces << " )";
5900 // issue 20749 ===================================================================
5902 * \brief Creates missing boundary elements
5903 * \param elements - elements whose boundary is to be checked
5904 * \param dimension - defines type of boundary elements to create
5905 * \param groupName - a name of group to store created boundary elements in,
5906 * "" means not to create the group
5907 * \param meshName - a name of new mesh to store created boundary elements in,
5908 * "" means not to create the new mesh
5909 * \param toCopyElements - if true, the checked elements will be copied into the new mesh
5910 * \param toCopyExistingBondary - if true, not only new but also pre-existing
5911 * boundary elements will be copied into the new mesh
5912 * \param group - returns the create group, if any
5913 * \retval SMESH::SMESH_Mesh - the mesh where elements were added to
5915 // ================================================================================
5917 SMESH::SMESH_Mesh_ptr
5918 SMESH_MeshEditor_i::MakeBoundaryMesh(SMESH::SMESH_IDSource_ptr idSource,
5919 SMESH::Bnd_Dimension dim,
5920 const char* groupName,
5921 const char* meshName,
5922 CORBA::Boolean toCopyElements,
5923 CORBA::Boolean toCopyExistingBondary,
5924 SMESH::SMESH_Group_out group)
5928 if ( dim > SMESH::BND_1DFROM2D )
5929 THROW_SALOME_CORBA_EXCEPTION("Invalid boundary dimension", SALOME::BAD_PARAM);
5931 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5933 SMESH::SMESH_Mesh_var mesh_var;
5934 SMESH::SMESH_Group_var group_var;
5938 TIDSortedElemSet elements;
5939 SMDSAbs_ElementType elemType = (dim == SMESH::BND_1DFROM2D) ? SMDSAbs_Face : SMDSAbs_Volume;
5940 if ( idSourceToSet( idSource, aMeshDS, elements, elemType,/*emptyIfIsMesh=*/true ))
5944 strlen(meshName) ? makeMesh(meshName) : SMESH::SMESH_Mesh::_duplicate(myMesh_i->_this());
5945 SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh_var );
5947 SMESH_Mesh* smesh_mesh = (mesh_i==myMesh_i) ? (SMESH_Mesh*)0 : &mesh_i->GetImpl();
5949 // group of new boundary elements
5950 SMESH_Group* smesh_group = 0;
5951 if ( strlen(groupName) )
5953 group_var = mesh_i->CreateGroup( SMESH::ElementType(int(elemType)-1),groupName);
5954 if ( SMESH_GroupBase_i* group_i = SMESH::DownCast<SMESH_GroupBase_i*>( group_var ))
5955 smesh_group = group_i->GetSmeshGroup();
5959 ::SMESH_MeshEditor aMeshEditor( myMesh );
5960 aMeshEditor.MakeBoundaryMesh( elements,
5961 ::SMESH_MeshEditor::Bnd_Dimension(dim),
5965 toCopyExistingBondary);
5966 storeResult( aMeshEditor );
5969 smesh_mesh->GetMeshDS()->Modified();
5972 const char* dimName[] = { "BND_2DFROM3D", "BND_1DFROM3D", "BND_1DFROM2D" };
5974 // result of MakeBoundaryMesh() is a tuple (mesh, group)
5975 if ( mesh_var->_is_nil() )
5976 pyDump << myMesh_i->_this() << ", ";
5978 pyDump << mesh_var << ", ";
5979 if ( group_var->_is_nil() )
5980 pyDump << "_NoneGroup = "; // assignment to None is forbiden
5982 pyDump << group_var << " = ";
5983 pyDump << this << ".MakeBoundaryMesh( "
5985 << "SMESH." << dimName[int(dim)] << ", "
5986 << "'" << groupName << "', "
5987 << "'" << meshName<< "', "
5988 << toCopyElements << ", "
5989 << toCopyExistingBondary << ")";
5991 group = group_var._retn();
5992 return mesh_var._retn();
5995 //================================================================================
5997 * \brief Creates missing boundary elements
5998 * \param dimension - defines type of boundary elements to create
5999 * \param groupName - a name of group to store all boundary elements in,
6000 * "" means not to create the group
6001 * \param meshName - a name of a new mesh, which is a copy of the initial
6002 * mesh + created boundary elements; "" means not to create the new mesh
6003 * \param toCopyAll - if true, the whole initial mesh will be copied into
6004 * the new mesh else only boundary elements will be copied into the new mesh
6005 * \param groups - optional groups of elements to make boundary around
6006 * \param mesh - returns the mesh where elements were added to
6007 * \param group - returns the created group, if any
6008 * \retval long - number of added boundary elements
6010 //================================================================================
6012 CORBA::Long SMESH_MeshEditor_i::MakeBoundaryElements(SMESH::Bnd_Dimension dim,
6013 const char* groupName,
6014 const char* meshName,
6015 CORBA::Boolean toCopyAll,
6016 const SMESH::ListOfIDSources& groups,
6017 SMESH::SMESH_Mesh_out mesh,
6018 SMESH::SMESH_Group_out group)
6019 throw (SALOME::SALOME_Exception)
6021 Unexpect aCatch(SALOME_SalomeException);
6025 if ( dim > SMESH::BND_1DFROM2D )
6026 THROW_SALOME_CORBA_EXCEPTION("Invalid boundary dimension", SALOME::BAD_PARAM);
6028 // separate groups belonging to this and other mesh
6029 SMESH::ListOfIDSources_var groupsOfThisMesh = new SMESH::ListOfIDSources;
6030 SMESH::ListOfIDSources_var groupsOfOtherMesh = new SMESH::ListOfIDSources;
6031 groupsOfThisMesh->length( groups.length() );
6032 groupsOfOtherMesh->length( groups.length() );
6033 int nbGroups = 0, nbGroupsOfOtherMesh = 0;
6034 for ( int i = 0; i < groups.length(); ++i )
6036 SMESH::SMESH_Mesh_var m = groups[i]->GetMesh();
6037 if ( myMesh_i != SMESH::DownCast<SMESH_Mesh_i*>( m ))
6038 groupsOfOtherMesh[ nbGroupsOfOtherMesh++ ] = groups[i];
6040 groupsOfThisMesh[ nbGroups++ ] = groups[i];
6041 if ( SMESH::DownCast<SMESH_Mesh_i*>( groups[i] ))
6042 THROW_SALOME_CORBA_EXCEPTION("expect a group but recieve a mesh", SALOME::BAD_PARAM);
6044 groupsOfThisMesh->length( nbGroups );
6045 groupsOfOtherMesh->length( nbGroupsOfOtherMesh );
6050 if ( nbGroupsOfOtherMesh > 0 )
6052 // process groups belonging to another mesh
6053 SMESH::SMESH_Mesh_var otherMesh = groupsOfOtherMesh[0]->GetMesh();
6054 SMESH::SMESH_MeshEditor_var editor = otherMesh->GetMeshEditor();
6055 nbAdded += editor->MakeBoundaryElements( dim, groupName, meshName, toCopyAll,
6056 groupsOfOtherMesh, mesh, group );
6059 SMESH::SMESH_Mesh_var mesh_var;
6060 SMESH::SMESH_Group_var group_var;
6063 mesh_var = SMESH::SMESH_Mesh::_duplicate( myMesh_i->_this() );
6064 const bool toCopyMesh = ( strlen( meshName ) > 0 );
6068 mesh_var = SMESH_Gen_i::GetSMESHGen()->CopyMesh(mesh_var,
6070 /*toCopyGroups=*/false,
6071 /*toKeepIDs=*/true);
6073 mesh_var = makeMesh(meshName);
6075 SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh_var );
6076 SMESH_Mesh* tgtMesh = &mesh_i->GetImpl();
6079 SMESH_Mesh* srcMesh = ( toCopyMesh && !toCopyAll ) ? myMesh : tgtMesh;
6080 SMESHDS_Mesh* srcMeshDS = srcMesh->GetMeshDS();
6082 // group of boundary elements
6083 SMESH_Group* smesh_group = 0;
6084 SMDSAbs_ElementType elemType = (dim == SMESH::BND_2DFROM3D) ? SMDSAbs_Volume : SMDSAbs_Face;
6085 if ( strlen(groupName) )
6087 SMESH::ElementType groupType = SMESH::ElementType( int(elemType)-1 );
6088 group_var = mesh_i->CreateGroup( groupType, groupName );
6089 if ( SMESH_GroupBase_i* group_i = SMESH::DownCast<SMESH_GroupBase_i*>( group_var ))
6090 smesh_group = group_i->GetSmeshGroup();
6093 TIDSortedElemSet elements;
6095 if ( groups.length() > 0 )
6097 for ( int i = 0; i < nbGroups; ++i )
6100 if ( idSourceToSet( groupsOfThisMesh[i], srcMeshDS, elements, elemType,/*emptyIfIsMesh=*/0 ))
6102 SMESH::Bnd_Dimension bdim =
6103 ( elemType == SMDSAbs_Volume ) ? SMESH::BND_2DFROM3D : SMESH::BND_1DFROM2D;
6104 ::SMESH_MeshEditor aMeshEditor( srcMesh );
6105 nbAdded += aMeshEditor.MakeBoundaryMesh( elements,
6106 ::SMESH_MeshEditor::Bnd_Dimension(bdim),
6109 /*toCopyElements=*/false,
6110 /*toCopyExistingBondary=*/srcMesh != tgtMesh,
6111 /*toAddExistingBondary=*/true,
6112 /*aroundElements=*/true);
6113 storeResult( aMeshEditor );
6119 ::SMESH_MeshEditor aMeshEditor( srcMesh );
6120 nbAdded += aMeshEditor.MakeBoundaryMesh( elements,
6121 ::SMESH_MeshEditor::Bnd_Dimension(dim),
6124 /*toCopyElements=*/false,
6125 /*toCopyExistingBondary=*/srcMesh != tgtMesh,
6126 /*toAddExistingBondary=*/true);
6127 storeResult( aMeshEditor );
6129 tgtMesh->GetMeshDS()->Modified();
6131 const char* dimName[] = { "BND_2DFROM3D", "BND_1DFROM3D", "BND_1DFROM2D" };
6133 // result of MakeBoundaryElements() is a tuple (nb, mesh, group)
6134 pyDump << "nbAdded, ";
6135 if ( mesh_var->_is_nil() )
6136 pyDump << myMesh_i->_this() << ", ";
6138 pyDump << mesh_var << ", ";
6139 if ( group_var->_is_nil() )
6140 pyDump << "_NoneGroup = "; // assignment to None is forbiden
6142 pyDump << group_var << " = ";
6143 pyDump << this << ".MakeBoundaryElements( "
6144 << "SMESH." << dimName[int(dim)] << ", "
6145 << "'" << groupName << "', "
6146 << "'" << meshName<< "', "
6147 << toCopyAll << ", "
6150 mesh = mesh_var._retn();
6151 group = group_var._retn();