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;
82 //=============================================================================
84 * \brief Mesh to apply modifications for preview purposes
86 //=============================================================================
88 struct TPreviewMesh: public SMESH_Mesh
90 SMDSAbs_ElementType myPreviewType; // type to show
92 TPreviewMesh(SMDSAbs_ElementType previewElements = SMDSAbs_All) {
93 _isShapeToMesh = (_id =_studyId =_idDoc = 0);
94 _myMeshDS = new SMESHDS_Mesh( _id, true );
95 myPreviewType = previewElements;
98 virtual ~TPreviewMesh() { delete _myMeshDS; _myMeshDS = 0; }
99 //!< Copy a set of elements
100 void Copy(const TIDSortedElemSet & theElements,
101 TIDSortedElemSet& theCopyElements,
102 SMDSAbs_ElementType theSelectType = SMDSAbs_All,
103 SMDSAbs_ElementType theAvoidType = SMDSAbs_All)
105 // loop on theIDsOfElements
106 TIDSortedElemSet::const_iterator eIt = theElements.begin();
107 for ( ; eIt != theElements.end(); ++eIt )
109 const SMDS_MeshElement* anElem = *eIt;
110 if ( !anElem ) continue;
111 SMDSAbs_ElementType type = anElem->GetType();
112 if ( type == theAvoidType ||
113 ( theSelectType != SMDSAbs_All && type != theSelectType ))
115 const SMDS_MeshElement* anElemCopy;
116 if ( type == SMDSAbs_Node)
117 anElemCopy = Copy( cast2Node(anElem) );
119 anElemCopy = Copy( anElem );
121 theCopyElements.insert( theCopyElements.end(), anElemCopy );
125 SMDS_MeshElement* Copy( const SMDS_MeshElement* anElem )
127 // copy element nodes
128 int anElemNbNodes = anElem->NbNodes();
129 vector< int > anElemNodesID( anElemNbNodes ) ;
130 SMDS_ElemIteratorPtr itElemNodes = anElem->nodesIterator();
131 for ( int i = 0; itElemNodes->more(); i++)
133 const SMDS_MeshNode* anElemNode = cast2Node( itElemNodes->next() );
135 anElemNodesID[i] = anElemNode->GetID();
138 // creates a corresponding element on copied nodes
139 SMDS_MeshElement* anElemCopy = 0;
140 if ( anElem->IsPoly() && anElem->GetType() == SMDSAbs_Volume )
142 const SMDS_VtkVolume* ph =
143 dynamic_cast<const SMDS_VtkVolume*> (anElem);
145 anElemCopy = _myMeshDS->AddPolyhedralVolumeWithID
146 (anElemNodesID, ph->GetQuantities(),anElem->GetID());
149 anElemCopy = ::SMESH_MeshEditor(this).AddElement( anElemNodesID,
156 SMDS_MeshNode* Copy( const SMDS_MeshNode* anElemNode )
158 return _myMeshDS->AddNodeWithID(anElemNode->X(), anElemNode->Y(), anElemNode->Z(),
159 anElemNode->GetID());
161 };// struct TPreviewMesh
163 static SMESH_NodeSearcher * theNodeSearcher = 0;
164 static SMESH_ElementSearcher * theElementSearcher = 0;
166 //=============================================================================
168 * \brief Deleter of theNodeSearcher at any compute event occured
170 //=============================================================================
172 struct TSearchersDeleter : public SMESH_subMeshEventListener
175 string myMeshPartIOR;
177 TSearchersDeleter(): SMESH_subMeshEventListener( false, // won't be deleted by submesh
178 "SMESH_MeshEditor_i::TSearchersDeleter"),
180 //!< Delete theNodeSearcher
183 if ( theNodeSearcher ) delete theNodeSearcher; theNodeSearcher = 0;
184 if ( theElementSearcher ) delete theElementSearcher; theElementSearcher = 0;
186 typedef map < int, SMESH_subMesh * > TDependsOnMap;
187 //!< The meshod called by submesh: do my main job
188 void ProcessEvent(const int, const int eventType, SMESH_subMesh* sm,
189 SMESH_subMeshEventListenerData*,const SMESH_Hypothesis*)
191 if ( eventType == SMESH_subMesh::COMPUTE_EVENT ) {
193 Unset( sm->GetFather() );
196 //!< set self on all submeshes and delete theNodeSearcher if other mesh is set
197 void Set(SMESH_Mesh* mesh, const string& meshPartIOR = string())
199 if ( myMesh != mesh || myMeshPartIOR != meshPartIOR)
206 myMeshPartIOR = meshPartIOR;
207 if ( SMESH_subMesh* myMainSubMesh = mesh->GetSubMeshContaining(1) ) {
208 const TDependsOnMap & subMeshes = myMainSubMesh->DependsOn();
209 TDependsOnMap::const_iterator sm;
210 for (sm = subMeshes.begin(); sm != subMeshes.end(); sm++)
211 sm->second->SetEventListener( this, 0, sm->second );
215 //!< delete self from all submeshes
216 void Unset(SMESH_Mesh* mesh)
218 if ( SMESH_subMesh* myMainSubMesh = mesh->GetSubMeshContaining(1) ) {
219 const TDependsOnMap & subMeshes = myMainSubMesh->DependsOn();
220 TDependsOnMap::const_iterator sm;
221 for (sm = subMeshes.begin(); sm != subMeshes.end(); sm++)
222 sm->second->DeleteEventListener( this );
227 } theSearchersDeleter;
229 TCollection_AsciiString mirrorTypeName( SMESH::SMESH_MeshEditor::MirrorType theMirrorType )
231 TCollection_AsciiString typeStr;
232 switch ( theMirrorType ) {
233 case SMESH::SMESH_MeshEditor::POINT:
234 typeStr = "SMESH.SMESH_MeshEditor.POINT";
236 case SMESH::SMESH_MeshEditor::AXIS:
237 typeStr = "SMESH.SMESH_MeshEditor.AXIS";
240 typeStr = "SMESH.SMESH_MeshEditor.PLANE";
244 //================================================================================
246 * \brief function for conversion of long_array to TIDSortedElemSet
247 * \param IDs - array of IDs
248 * \param aMesh - mesh
249 * \param aMap - collection to fill
250 * \param aType - element type
252 //================================================================================
254 void arrayToSet(const SMESH::long_array & IDs,
255 const SMESHDS_Mesh* aMesh,
256 TIDSortedElemSet& aMap,
257 const SMDSAbs_ElementType aType = SMDSAbs_All )
259 for (int i=0; i<IDs.length(); i++) {
260 CORBA::Long ind = IDs[i];
261 const SMDS_MeshElement * elem =
262 (aType == SMDSAbs_Node ? aMesh->FindNode(ind) : aMesh->FindElement(ind));
263 if ( elem && ( aType == SMDSAbs_All || elem->GetType() == aType ))
267 //================================================================================
269 * \brief Retrieve elements of given type from SMESH_IDSource
271 //================================================================================
273 bool idSourceToSet(SMESH::SMESH_IDSource_ptr theIDSource,
274 const SMESHDS_Mesh* theMeshDS,
275 TIDSortedElemSet& theElemSet,
276 const SMDSAbs_ElementType theType,
277 const bool emptyIfIsMesh=false)
280 if ( CORBA::is_nil( theIDSource ) )
282 if ( emptyIfIsMesh && SMESH::DownCast<SMESH_Mesh_i*>( theIDSource ))
285 SMESH::long_array_var anIDs = theIDSource->GetIDs();
286 if ( anIDs->length() == 0 )
288 SMESH::array_of_ElementType_var types = theIDSource->GetTypes();
289 if ( types->length() == 1 && types[0] == SMESH::NODE ) // group of nodes
291 if ( theType == SMDSAbs_All || theType == SMDSAbs_Node )
292 arrayToSet( anIDs, theMeshDS, theElemSet, SMDSAbs_Node );
298 arrayToSet( anIDs, theMeshDS, theElemSet, theType);
302 //================================================================================
304 * \brief Retrieve nodes from SMESH_IDSource
306 //================================================================================
308 void idSourceToNodeSet(SMESH::SMESH_IDSource_ptr theObject,
309 const SMESHDS_Mesh* theMeshDS,
310 TIDSortedNodeSet& theNodeSet)
313 if ( CORBA::is_nil( theObject ) )
315 SMESH::array_of_ElementType_var types = theObject->GetTypes();
316 SMESH::long_array_var aElementsId = theObject->GetIDs();
317 if ( types->length() == 1 && types[0] == SMESH::NODE)
319 for(int i = 0; i < aElementsId->length(); i++)
320 if ( const SMDS_MeshNode * n = theMeshDS->FindNode( aElementsId[i] ))
321 theNodeSet.insert( theNodeSet.end(), n);
323 else if ( SMESH::DownCast<SMESH_Mesh_i*>( theObject ))
325 SMDS_NodeIteratorPtr nIt = theMeshDS->nodesIterator();
326 while ( nIt->more( ))
327 if( const SMDS_MeshElement * elem = nIt->next() )
328 theNodeSet.insert( elem->begin_nodes(), elem->end_nodes());
332 for(int i = 0; i < aElementsId->length(); i++)
333 if( const SMDS_MeshElement * elem = theMeshDS->FindElement( aElementsId[i] ))
334 theNodeSet.insert( elem->begin_nodes(), elem->end_nodes());
338 //================================================================================
340 * \brief Returns elements connected to the given elements
342 //================================================================================
344 void getElementsAround(const TIDSortedElemSet& theElements,
345 const SMESHDS_Mesh* theMeshDS,
346 TIDSortedElemSet& theElementsAround)
348 if ( theElements.empty() ) return;
350 SMDSAbs_ElementType elemType = (*theElements.begin())->GetType();
351 bool sameElemType = ( elemType == (*theElements.rbegin())->GetType() );
353 theMeshDS->GetMeshInfo().NbElements( elemType ) == theElements.size() )
354 return; // all the elements are in theElements
357 elemType = SMDSAbs_All;
359 TIDSortedElemSet visitedNodes;
360 TIDSortedElemSet::const_iterator elemIt = theElements.begin();
361 for ( ; elemIt != theElements.end(); ++elemIt )
363 const SMDS_MeshElement* e = *elemIt;
364 int i = e->NbCornerNodes();
367 const SMDS_MeshNode* n = e->GetNode( i );
368 if ( visitedNodes.insert( n ).second )
370 SMDS_ElemIteratorPtr invIt = n->GetInverseElementIterator(elemType);
371 while ( invIt->more() )
373 const SMDS_MeshElement* elemAround = invIt->next();
374 if ( !theElements.count( elemAround ))
375 theElementsAround.insert( elemAround );
383 //=============================================================================
387 //=============================================================================
389 SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESH_Mesh_i* theMesh, bool isPreview)
392 myMesh = & theMesh->GetImpl();
393 myPreviewMode = isPreview;
396 //================================================================================
400 //================================================================================
402 SMESH_MeshEditor_i::~SMESH_MeshEditor_i()
406 //================================================================================
408 * \brief Clear members
410 //================================================================================
412 void SMESH_MeshEditor_i::initData(bool deleteSearchers)
414 if ( myPreviewMode ) {
415 myPreviewData = new SMESH::MeshPreviewStruct();
418 myLastCreatedElems = new SMESH::long_array();
419 myLastCreatedNodes = new SMESH::long_array();
420 if ( deleteSearchers )
421 TSearchersDeleter::Delete();
425 //=======================================================================
426 //function : MakeIDSource
427 //purpose : Wrap a sequence of ids in a SMESH_IDSource
428 //=======================================================================
430 struct _IDSource : public POA_SMESH::SMESH_IDSource
432 SMESH::long_array _ids;
433 SMESH::ElementType _type;
434 SMESH::SMESH_Mesh_ptr _mesh;
435 SMESH::long_array* GetIDs() { return new SMESH::long_array( _ids ); }
436 SMESH::long_array* GetMeshInfo() { return 0; }
437 SMESH::SMESH_Mesh_ptr GetMesh() { return SMESH::SMESH_Mesh::_duplicate( _mesh ); }
438 bool IsMeshInfoCorrect() { return true; }
439 SMESH::array_of_ElementType* GetTypes()
441 SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType;
442 if ( _ids.length() > 0 ) {
446 return types._retn();
450 SMESH::SMESH_IDSource_ptr SMESH_MeshEditor_i::MakeIDSource(const SMESH::long_array& ids,
451 SMESH::ElementType type)
453 _IDSource* anIDSource = new _IDSource;
454 anIDSource->_ids = ids;
455 anIDSource->_type = type;
456 anIDSource->_mesh = myMesh_i->_this();
457 SMESH::SMESH_IDSource_var anIDSourceVar = anIDSource->_this();
459 return anIDSourceVar._retn();
462 //=============================================================================
466 //=============================================================================
469 SMESH_MeshEditor_i::RemoveElements(const SMESH::long_array & IDsOfElements)
473 ::SMESH_MeshEditor anEditor( myMesh );
476 for (int i = 0; i < IDsOfElements.length(); i++)
477 IdList.push_back( IDsOfElements[i] );
479 // Update Python script
480 TPythonDump() << "isDone = " << this << ".RemoveElements( " << IDsOfElements << " )";
483 bool ret = anEditor.Remove( IdList, false );
484 myMesh->GetMeshDS()->Modified();
485 if ( IDsOfElements.length() )
486 myMesh->SetIsModified( true ); // issue 0020693
490 //=============================================================================
494 //=============================================================================
496 CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::long_array & IDsOfNodes)
500 ::SMESH_MeshEditor anEditor( myMesh );
502 for (int i = 0; i < IDsOfNodes.length(); i++)
503 IdList.push_back( IDsOfNodes[i] );
505 // Update Python script
506 TPythonDump() << "isDone = " << this << ".RemoveNodes( " << IDsOfNodes << " )";
508 bool ret = anEditor.Remove( IdList, true );
509 myMesh->GetMeshDS()->Modified();
510 if ( IDsOfNodes.length() )
511 myMesh->SetIsModified( true ); // issue 0020693
515 //=============================================================================
519 //=============================================================================
521 CORBA::Long SMESH_MeshEditor_i::RemoveOrphanNodes()
525 ::SMESH_MeshEditor anEditor( myMesh );
527 // Update Python script
528 TPythonDump() << "nbRemoved = " << this << ".RemoveOrphanNodes()";
530 // Create filter to find all orphan nodes
531 SMESH::Controls::Filter::TIdSequence seq;
532 SMESH::Controls::PredicatePtr predicate( new SMESH::Controls::FreeNodes() );
533 SMESH::Controls::Filter::GetElementsId( GetMeshDS(), predicate, seq );
535 // remove orphan nodes (if there are any)
537 for ( int i = 0; i < seq.size(); i++ )
538 IdList.push_back( seq[i] );
540 int nbNodesBefore = myMesh->NbNodes();
541 anEditor.Remove( IdList, true );
542 myMesh->GetMeshDS()->Modified();
544 myMesh->SetIsModified( true );
545 int nbNodesAfter = myMesh->NbNodes();
547 return nbNodesBefore - nbNodesAfter;
550 //=============================================================================
554 //=============================================================================
556 CORBA::Long SMESH_MeshEditor_i::AddNode(CORBA::Double x,
557 CORBA::Double y, CORBA::Double z)
561 const SMDS_MeshNode* N = GetMeshDS()->AddNode(x, y, z);
563 // Update Python script
564 TPythonDump() << "nodeID = " << this << ".AddNode( "
565 << TVar( x ) << ", " << TVar( y ) << ", " << TVar( z )<< " )";
567 myMesh->GetMeshDS()->Modified();
568 myMesh->SetIsModified( true ); // issue 0020693
572 //=============================================================================
576 //=============================================================================
577 CORBA::Long SMESH_MeshEditor_i::Add0DElement(CORBA::Long IDOfNode)
581 const SMDS_MeshNode* aNode = GetMeshDS()->FindNode(IDOfNode);
582 SMDS_MeshElement* elem = GetMeshDS()->Add0DElement(aNode);
584 // Update Python script
585 TPythonDump() << "elem0d = " << this << ".Add0DElement( " << IDOfNode <<" )";
587 myMesh->GetMeshDS()->Modified();
588 myMesh->SetIsModified( true ); // issue 0020693
591 return elem->GetID();
596 //=============================================================================
600 //=============================================================================
602 CORBA::Long SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes)
606 int NbNodes = IDsOfNodes.length();
607 SMDS_MeshElement* elem = 0;
610 CORBA::Long index1 = IDsOfNodes[0];
611 CORBA::Long index2 = IDsOfNodes[1];
612 elem = GetMeshDS()->AddEdge(GetMeshDS()->FindNode(index1), GetMeshDS()->FindNode(index2));
614 // Update Python script
615 TPythonDump() << "edge = " << this << ".AddEdge([ "
616 << index1 << ", " << index2 <<" ])";
619 CORBA::Long n1 = IDsOfNodes[0];
620 CORBA::Long n2 = IDsOfNodes[1];
621 CORBA::Long n12 = IDsOfNodes[2];
622 elem = GetMeshDS()->AddEdge(GetMeshDS()->FindNode(n1),
623 GetMeshDS()->FindNode(n2),
624 GetMeshDS()->FindNode(n12));
625 // Update Python script
626 TPythonDump() << "edgeID = " << this << ".AddEdge([ "
627 <<n1<<", "<<n2<<", "<<n12<<" ])";
630 myMesh->GetMeshDS()->Modified();
632 return myMesh->SetIsModified( true ), elem->GetID();
637 //=============================================================================
641 //=============================================================================
643 CORBA::Long SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
647 int NbNodes = IDsOfNodes.length();
653 std::vector<const SMDS_MeshNode*> nodes (NbNodes);
654 for (int i = 0; i < NbNodes; i++)
655 nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
657 SMDS_MeshElement* elem = 0;
659 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]);
661 else if (NbNodes == 4) {
662 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
664 else if (NbNodes == 6) {
665 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
668 else if (NbNodes == 8) {
669 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
670 nodes[4], nodes[5], nodes[6], nodes[7]);
672 else if (NbNodes == 9) {
673 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
674 nodes[4], nodes[5], nodes[6], nodes[7], nodes[8] );
676 else if (NbNodes > 2) {
677 elem = GetMeshDS()->AddPolygonalFace(nodes);
680 // Update Python script
681 TPythonDump() << "faceID = " << this << ".AddFace( " << IDsOfNodes << " )";
683 myMesh->GetMeshDS()->Modified();
685 return myMesh->SetIsModified( true ), elem->GetID();
690 //=============================================================================
694 //=============================================================================
695 CORBA::Long SMESH_MeshEditor_i::AddPolygonalFace (const SMESH::long_array & IDsOfNodes)
699 int NbNodes = IDsOfNodes.length();
700 std::vector<const SMDS_MeshNode*> nodes (NbNodes);
701 for (int i = 0; i < NbNodes; i++)
702 nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
704 const SMDS_MeshElement* elem = GetMeshDS()->AddPolygonalFace(nodes);
706 // Update Python script
707 TPythonDump() <<"faceID = "<<this<<".AddPolygonalFace( "<<IDsOfNodes<<" )";
709 myMesh->GetMeshDS()->Modified();
710 return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0;
713 //=============================================================================
717 //=============================================================================
719 CORBA::Long SMESH_MeshEditor_i::AddVolume(const SMESH::long_array & IDsOfNodes)
723 int NbNodes = IDsOfNodes.length();
724 vector< const SMDS_MeshNode*> n(NbNodes);
725 for(int i=0;i<NbNodes;i++)
726 n[i]=GetMeshDS()->FindNode(IDsOfNodes[i]);
728 SMDS_MeshElement* elem = 0;
731 case 4 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3]); break;
732 case 5 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4]); break;
733 case 6 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5]); break;
734 case 8 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break;
735 case 10:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],
736 n[6],n[7],n[8],n[9]);
738 case 12:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],
739 n[6],n[7],n[8],n[9],n[10],n[11]);
741 case 13:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],
742 n[7],n[8],n[9],n[10],n[11],n[12]);
744 case 15:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],
745 n[9],n[10],n[11],n[12],n[13],n[14]);
747 case 20:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],
748 n[8],n[9],n[10],n[11],n[12],n[13],n[14],
749 n[15],n[16],n[17],n[18],n[19]);
751 case 27:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],
752 n[8],n[9],n[10],n[11],n[12],n[13],n[14],
753 n[15],n[16],n[17],n[18],n[19],
754 n[20],n[21],n[22],n[23],n[24],n[25],n[26]);
758 // Update Python script
759 TPythonDump() << "volID = " << this << ".AddVolume( " << IDsOfNodes << " )";
761 myMesh->GetMeshDS()->Modified();
763 return myMesh->SetIsModified( true ), elem->GetID();
768 //=============================================================================
770 * AddPolyhedralVolume
772 //=============================================================================
773 CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolume (const SMESH::long_array & IDsOfNodes,
774 const SMESH::long_array & Quantities)
778 int NbNodes = IDsOfNodes.length();
779 std::vector<const SMDS_MeshNode*> n (NbNodes);
780 for (int i = 0; i < NbNodes; i++)
782 const SMDS_MeshNode* aNode = GetMeshDS()->FindNode(IDsOfNodes[i]);
783 if (!aNode) return 0;
787 int NbFaces = Quantities.length();
788 std::vector<int> q (NbFaces);
789 for (int j = 0; j < NbFaces; j++)
790 q[j] = Quantities[j];
792 const SMDS_MeshElement* elem = GetMeshDS()->AddPolyhedralVolume(n, q);
794 // Update Python script
795 TPythonDump() << "volID = " << this << ".AddPolyhedralVolume( "
796 << IDsOfNodes << ", " << Quantities << " )";
797 myMesh->GetMeshDS()->Modified();
799 return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0;
802 //=============================================================================
804 * AddPolyhedralVolumeByFaces
806 //=============================================================================
807 CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces (const SMESH::long_array & IdsOfFaces)
811 int NbFaces = IdsOfFaces.length();
812 std::vector<const SMDS_MeshNode*> poly_nodes;
813 std::vector<int> quantities (NbFaces);
815 for (int i = 0; i < NbFaces; i++) {
816 const SMDS_MeshElement* aFace = GetMeshDS()->FindElement(IdsOfFaces[i]);
817 quantities[i] = aFace->NbNodes();
819 SMDS_ElemIteratorPtr It = aFace->nodesIterator();
821 poly_nodes.push_back(static_cast<const SMDS_MeshNode *>(It->next()));
825 const SMDS_MeshElement* elem = GetMeshDS()->AddPolyhedralVolume(poly_nodes, quantities);
827 // Update Python script
828 TPythonDump() << "volID = " << this << ".AddPolyhedralVolumeByFaces( "
829 << IdsOfFaces << " )";
830 myMesh->GetMeshDS()->Modified();
832 return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0;
835 //=============================================================================
837 * \brief Bind a node to a vertex
838 * \param NodeID - node ID
839 * \param VertexID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
840 * \retval boolean - false if NodeID or VertexID is invalid
842 //=============================================================================
844 void SMESH_MeshEditor_i::SetNodeOnVertex(CORBA::Long NodeID, CORBA::Long VertexID)
845 throw (SALOME::SALOME_Exception)
847 Unexpect aCatch(SALOME_SalomeException);
849 SMESHDS_Mesh * mesh = GetMeshDS();
850 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
852 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
854 if ( mesh->MaxShapeIndex() < VertexID )
855 THROW_SALOME_CORBA_EXCEPTION("Invalid VertexID", SALOME::BAD_PARAM);
857 TopoDS_Shape shape = mesh->IndexToShape( VertexID );
858 if ( shape.ShapeType() != TopAbs_VERTEX )
859 THROW_SALOME_CORBA_EXCEPTION("Invalid VertexID", SALOME::BAD_PARAM);
861 mesh->SetNodeOnVertex( node, VertexID );
863 myMesh->SetIsModified( true );
866 //=============================================================================
868 * \brief Store node position on an edge
869 * \param NodeID - node ID
870 * \param EdgeID - edge ID available through GEOM_Object.GetSubShapeIndices()[0]
871 * \param paramOnEdge - parameter on edge where the node is located
872 * \retval boolean - false if any parameter is invalid
874 //=============================================================================
876 void SMESH_MeshEditor_i::SetNodeOnEdge(CORBA::Long NodeID, CORBA::Long EdgeID,
877 CORBA::Double paramOnEdge)
878 throw (SALOME::SALOME_Exception)
880 Unexpect aCatch(SALOME_SalomeException);
882 SMESHDS_Mesh * mesh = GetMeshDS();
883 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
885 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
887 if ( mesh->MaxShapeIndex() < EdgeID )
888 THROW_SALOME_CORBA_EXCEPTION("Invalid EdgeID", SALOME::BAD_PARAM);
890 TopoDS_Shape shape = mesh->IndexToShape( EdgeID );
891 if ( shape.ShapeType() != TopAbs_EDGE )
892 THROW_SALOME_CORBA_EXCEPTION("Invalid EdgeID", SALOME::BAD_PARAM);
895 BRep_Tool::Range( TopoDS::Edge( shape ), f,l);
896 if ( paramOnEdge < f || paramOnEdge > l )
897 THROW_SALOME_CORBA_EXCEPTION("Invalid paramOnEdge", SALOME::BAD_PARAM);
899 mesh->SetNodeOnEdge( node, EdgeID, paramOnEdge );
901 myMesh->SetIsModified( true );
904 //=============================================================================
906 * \brief Store node position on a face
907 * \param NodeID - node ID
908 * \param FaceID - face ID available through GEOM_Object.GetSubShapeIndices()[0]
909 * \param u - U parameter on face where the node is located
910 * \param v - V parameter on face where the node is located
911 * \retval boolean - false if any parameter is invalid
913 //=============================================================================
915 void SMESH_MeshEditor_i::SetNodeOnFace(CORBA::Long NodeID, CORBA::Long FaceID,
916 CORBA::Double u, CORBA::Double v)
917 throw (SALOME::SALOME_Exception)
919 Unexpect aCatch(SALOME_SalomeException);
921 SMESHDS_Mesh * mesh = GetMeshDS();
922 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
924 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
926 if ( mesh->MaxShapeIndex() < FaceID )
927 THROW_SALOME_CORBA_EXCEPTION("Invalid FaceID", SALOME::BAD_PARAM);
929 TopoDS_Shape shape = mesh->IndexToShape( FaceID );
930 if ( shape.ShapeType() != TopAbs_FACE )
931 THROW_SALOME_CORBA_EXCEPTION("Invalid FaceID", SALOME::BAD_PARAM);
933 BRepAdaptor_Surface surf( TopoDS::Face( shape ));
934 bool isOut = ( u < surf.FirstUParameter() ||
935 u > surf.LastUParameter() ||
936 v < surf.FirstVParameter() ||
937 v > surf.LastVParameter() );
941 MESSAGE ( "FACE " << FaceID << " (" << u << "," << v << ") out of "
942 << " u( " << surf.FirstUParameter()
943 << "," << surf.LastUParameter()
944 << ") v( " << surf.FirstVParameter()
945 << "," << surf.LastVParameter() << ")" );
947 THROW_SALOME_CORBA_EXCEPTION("Invalid UV", SALOME::BAD_PARAM);
950 mesh->SetNodeOnFace( node, FaceID, u, v );
951 myMesh->SetIsModified( true );
954 //=============================================================================
956 * \brief Bind a node to a solid
957 * \param NodeID - node ID
958 * \param SolidID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
959 * \retval boolean - false if NodeID or SolidID is invalid
961 //=============================================================================
963 void SMESH_MeshEditor_i::SetNodeInVolume(CORBA::Long NodeID, CORBA::Long SolidID)
964 throw (SALOME::SALOME_Exception)
966 Unexpect aCatch(SALOME_SalomeException);
968 SMESHDS_Mesh * mesh = GetMeshDS();
969 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
971 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
973 if ( mesh->MaxShapeIndex() < SolidID )
974 THROW_SALOME_CORBA_EXCEPTION("Invalid SolidID", SALOME::BAD_PARAM);
976 TopoDS_Shape shape = mesh->IndexToShape( SolidID );
977 if ( shape.ShapeType() != TopAbs_SOLID &&
978 shape.ShapeType() != TopAbs_SHELL)
979 THROW_SALOME_CORBA_EXCEPTION("Invalid SolidID", SALOME::BAD_PARAM);
981 mesh->SetNodeInVolume( node, SolidID );
983 // myMesh->SetIsModified( true ); - SetNodeInVolume() can't prevent re-compute, I believe
986 //=============================================================================
988 * \brief Bind an element to a shape
989 * \param ElementID - element ID
990 * \param ShapeID - shape ID available through GEOM_Object.GetSubShapeIndices()[0]
991 * \retval boolean - false if ElementID or ShapeID is invalid
993 //=============================================================================
995 void SMESH_MeshEditor_i::SetMeshElementOnShape(CORBA::Long ElementID,
997 throw (SALOME::SALOME_Exception)
999 Unexpect aCatch(SALOME_SalomeException);
1001 SMESHDS_Mesh * mesh = GetMeshDS();
1002 SMDS_MeshElement* elem = const_cast<SMDS_MeshElement*>(mesh->FindElement(ElementID));
1004 THROW_SALOME_CORBA_EXCEPTION("Invalid ElementID", SALOME::BAD_PARAM);
1006 if ( mesh->MaxShapeIndex() < ShapeID )
1007 THROW_SALOME_CORBA_EXCEPTION("Invalid ShapeID", SALOME::BAD_PARAM);
1009 TopoDS_Shape shape = mesh->IndexToShape( ShapeID );
1010 if ( shape.ShapeType() != TopAbs_EDGE &&
1011 shape.ShapeType() != TopAbs_FACE &&
1012 shape.ShapeType() != TopAbs_SOLID &&
1013 shape.ShapeType() != TopAbs_SHELL )
1014 THROW_SALOME_CORBA_EXCEPTION("Invalid shape type", SALOME::BAD_PARAM);
1016 mesh->SetMeshElementOnShape( elem, ShapeID );
1018 myMesh->SetIsModified( true );
1021 //=============================================================================
1025 //=============================================================================
1027 CORBA::Boolean SMESH_MeshEditor_i::InverseDiag(CORBA::Long NodeID1,
1028 CORBA::Long NodeID2)
1032 const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
1033 const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
1037 // Update Python script
1038 TPythonDump() << "isDone = " << this << ".InverseDiag( "
1039 << NodeID1 << ", " << NodeID2 << " )";
1042 ::SMESH_MeshEditor aMeshEditor( myMesh );
1043 int ret = aMeshEditor.InverseDiag ( n1, n2 );
1044 myMesh->GetMeshDS()->Modified();
1045 myMesh->SetIsModified( true );
1049 //=============================================================================
1053 //=============================================================================
1055 CORBA::Boolean SMESH_MeshEditor_i::DeleteDiag(CORBA::Long NodeID1,
1056 CORBA::Long NodeID2)
1060 const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
1061 const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
1065 // Update Python script
1066 TPythonDump() << "isDone = " << this << ".DeleteDiag( "
1067 << NodeID1 << ", " << NodeID2 << " )";
1069 ::SMESH_MeshEditor aMeshEditor( myMesh );
1071 bool stat = aMeshEditor.DeleteDiag ( n1, n2 );
1073 myMesh->GetMeshDS()->Modified();
1075 myMesh->SetIsModified( true ); // issue 0020693
1077 storeResult(aMeshEditor);
1082 //=============================================================================
1086 //=============================================================================
1088 CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::long_array & IDsOfElements)
1092 ::SMESH_MeshEditor anEditor( myMesh );
1093 for (int i = 0; i < IDsOfElements.length(); i++)
1095 CORBA::Long index = IDsOfElements[i];
1096 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
1098 anEditor.Reorient( elem );
1100 // Update Python script
1101 TPythonDump() << "isDone = " << this << ".Reorient( " << IDsOfElements << " )";
1103 myMesh->GetMeshDS()->Modified();
1104 if ( IDsOfElements.length() )
1105 myMesh->SetIsModified( true ); // issue 0020693
1111 //=============================================================================
1115 //=============================================================================
1117 CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theObject)
1121 TPythonDump aTPythonDump; // suppress dump in Reorient()
1123 SMESH::long_array_var anElementsId = theObject->GetIDs();
1124 CORBA::Boolean isDone = Reorient(anElementsId);
1126 // Update Python script
1127 aTPythonDump << "isDone = " << this << ".ReorientObject( " << theObject << " )";
1132 //=============================================================================
1136 //=============================================================================
1137 CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfElements,
1138 SMESH::NumericalFunctor_ptr Criterion,
1139 CORBA::Double MaxAngle)
1143 SMESHDS_Mesh* aMesh = GetMeshDS();
1144 TIDSortedElemSet faces;
1145 arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
1147 SMESH::NumericalFunctor_i* aNumericalFunctor =
1148 dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
1149 SMESH::Controls::NumericalFunctorPtr aCrit;
1150 if ( !aNumericalFunctor )
1151 aCrit.reset( new SMESH::Controls::AspectRatio() );
1153 aCrit = aNumericalFunctor->GetNumericalFunctor();
1155 // Update Python script
1156 TPythonDump() << "isDone = " << this << ".TriToQuad( "
1157 << IDsOfElements << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
1159 ::SMESH_MeshEditor anEditor( myMesh );
1161 bool stat = anEditor.TriToQuad( faces, aCrit, MaxAngle );
1162 myMesh->GetMeshDS()->Modified();
1164 myMesh->SetIsModified( true ); // issue 0020693
1166 storeResult(anEditor);
1172 //=============================================================================
1176 //=============================================================================
1177 CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr theObject,
1178 SMESH::NumericalFunctor_ptr Criterion,
1179 CORBA::Double MaxAngle)
1183 TPythonDump aTPythonDump; // suppress dump in TriToQuad()
1184 SMESH::long_array_var anElementsId = theObject->GetIDs();
1185 CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
1187 SMESH::NumericalFunctor_i* aNumericalFunctor =
1188 SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
1190 // Update Python script
1191 aTPythonDump << "isDone = " << this << ".TriToQuadObject("
1192 << theObject << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
1198 //=============================================================================
1202 //=============================================================================
1203 CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array & IDsOfElements,
1204 SMESH::NumericalFunctor_ptr Criterion)
1208 SMESHDS_Mesh* aMesh = GetMeshDS();
1209 TIDSortedElemSet faces;
1210 arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
1212 SMESH::NumericalFunctor_i* aNumericalFunctor =
1213 dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
1214 SMESH::Controls::NumericalFunctorPtr aCrit;
1215 if ( !aNumericalFunctor )
1216 aCrit.reset( new SMESH::Controls::AspectRatio() );
1218 aCrit = aNumericalFunctor->GetNumericalFunctor();
1221 // Update Python script
1222 TPythonDump() << "isDone = " << this << ".QuadToTri( " << IDsOfElements << ", " << aNumericalFunctor << " )";
1224 ::SMESH_MeshEditor anEditor( myMesh );
1225 CORBA::Boolean stat = anEditor.QuadToTri( faces, aCrit );
1226 myMesh->GetMeshDS()->Modified();
1228 myMesh->SetIsModified( true ); // issue 0020693
1230 storeResult(anEditor);
1236 //=============================================================================
1240 //=============================================================================
1241 CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr theObject,
1242 SMESH::NumericalFunctor_ptr Criterion)
1246 TPythonDump aTPythonDump; // suppress dump in QuadToTri()
1248 SMESH::long_array_var anElementsId = theObject->GetIDs();
1249 CORBA::Boolean isDone = QuadToTri(anElementsId, Criterion);
1251 SMESH::NumericalFunctor_i* aNumericalFunctor =
1252 SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
1254 // Update Python script
1255 aTPythonDump << "isDone = " << this << ".QuadToTriObject( " << theObject << ", " << aNumericalFunctor << " )";
1261 //=============================================================================
1265 //=============================================================================
1266 CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfElements,
1267 CORBA::Boolean Diag13)
1271 SMESHDS_Mesh* aMesh = GetMeshDS();
1272 TIDSortedElemSet faces;
1273 arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
1275 // Update Python script
1276 TPythonDump() << "isDone = " << this << ".SplitQuad( "
1277 << IDsOfElements << ", " << Diag13 << " )";
1279 ::SMESH_MeshEditor anEditor( myMesh );
1280 CORBA::Boolean stat = anEditor.QuadToTri( faces, Diag13 );
1281 myMesh->GetMeshDS()->Modified();
1283 myMesh->SetIsModified( true ); // issue 0020693
1286 storeResult(anEditor);
1292 //=============================================================================
1296 //=============================================================================
1297 CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr theObject,
1298 CORBA::Boolean Diag13)
1302 TPythonDump aTPythonDump; // suppress dump in SplitQuad()
1304 SMESH::long_array_var anElementsId = theObject->GetIDs();
1305 CORBA::Boolean isDone = SplitQuad(anElementsId, Diag13);
1307 // Update Python script
1308 aTPythonDump << "isDone = " << this << ".SplitQuadObject( "
1309 << theObject << ", " << Diag13 << " )";
1315 //=============================================================================
1319 //=============================================================================
1320 CORBA::Long SMESH_MeshEditor_i::BestSplit (CORBA::Long IDOfQuad,
1321 SMESH::NumericalFunctor_ptr Criterion)
1325 const SMDS_MeshElement* quad = GetMeshDS()->FindElement(IDOfQuad);
1326 if (quad && quad->GetType() == SMDSAbs_Face && quad->NbNodes() == 4)
1328 SMESH::NumericalFunctor_i* aNumericalFunctor =
1329 dynamic_cast<SMESH::NumericalFunctor_i*>(SMESH_Gen_i::GetServant(Criterion).in());
1330 SMESH::Controls::NumericalFunctorPtr aCrit;
1331 if (aNumericalFunctor)
1332 aCrit = aNumericalFunctor->GetNumericalFunctor();
1334 aCrit.reset(new SMESH::Controls::AspectRatio());
1336 ::SMESH_MeshEditor anEditor (myMesh);
1337 return anEditor.BestSplit(quad, aCrit);
1342 //================================================================================
1344 * \brief Split volumic elements into tetrahedrons
1346 //================================================================================
1348 void SMESH_MeshEditor_i::SplitVolumesIntoTetra (SMESH::SMESH_IDSource_ptr elems,
1349 CORBA::Short methodFlags)
1350 throw (SALOME::SALOME_Exception)
1352 Unexpect aCatch(SALOME_SalomeException);
1356 SMESH::long_array_var anElementsId = elems->GetIDs();
1357 TIDSortedElemSet elemSet;
1358 arrayToSet( anElementsId, GetMeshDS(), elemSet, SMDSAbs_Volume );
1360 ::SMESH_MeshEditor anEditor (myMesh);
1361 anEditor.SplitVolumesIntoTetra( elemSet, int( methodFlags ));
1362 myMesh->GetMeshDS()->Modified();
1364 storeResult(anEditor);
1366 // if ( myLastCreatedElems.length() ) - it does not influence Compute()
1367 // myMesh->SetIsModified( true ); // issue 0020693
1369 TPythonDump() << this << ".SplitVolumesIntoTetra( "
1370 << elems << ", " << methodFlags << " )";
1373 //=======================================================================
1376 //=======================================================================
1379 SMESH_MeshEditor_i::Smooth(const SMESH::long_array & IDsOfElements,
1380 const SMESH::long_array & IDsOfFixedNodes,
1381 CORBA::Long MaxNbOfIterations,
1382 CORBA::Double MaxAspectRatio,
1383 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1385 return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations,
1386 MaxAspectRatio, Method, false );
1390 //=======================================================================
1391 //function : SmoothParametric
1393 //=======================================================================
1396 SMESH_MeshEditor_i::SmoothParametric(const SMESH::long_array & IDsOfElements,
1397 const SMESH::long_array & IDsOfFixedNodes,
1398 CORBA::Long MaxNbOfIterations,
1399 CORBA::Double MaxAspectRatio,
1400 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1402 return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations,
1403 MaxAspectRatio, Method, true );
1407 //=======================================================================
1408 //function : SmoothObject
1410 //=======================================================================
1413 SMESH_MeshEditor_i::SmoothObject(SMESH::SMESH_IDSource_ptr theObject,
1414 const SMESH::long_array & IDsOfFixedNodes,
1415 CORBA::Long MaxNbOfIterations,
1416 CORBA::Double MaxAspectRatio,
1417 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1419 return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations,
1420 MaxAspectRatio, Method, false);
1424 //=======================================================================
1425 //function : SmoothParametricObject
1427 //=======================================================================
1430 SMESH_MeshEditor_i::SmoothParametricObject(SMESH::SMESH_IDSource_ptr theObject,
1431 const SMESH::long_array & IDsOfFixedNodes,
1432 CORBA::Long MaxNbOfIterations,
1433 CORBA::Double MaxAspectRatio,
1434 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1436 return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations,
1437 MaxAspectRatio, Method, true);
1441 //=============================================================================
1445 //=============================================================================
1448 SMESH_MeshEditor_i::smooth(const SMESH::long_array & IDsOfElements,
1449 const SMESH::long_array & IDsOfFixedNodes,
1450 CORBA::Long MaxNbOfIterations,
1451 CORBA::Double MaxAspectRatio,
1452 SMESH::SMESH_MeshEditor::Smooth_Method Method,
1457 SMESHDS_Mesh* aMesh = GetMeshDS();
1459 TIDSortedElemSet elements;
1460 arrayToSet(IDsOfElements, aMesh, elements, SMDSAbs_Face);
1462 set<const SMDS_MeshNode*> fixedNodes;
1463 for (int i = 0; i < IDsOfFixedNodes.length(); i++) {
1464 CORBA::Long index = IDsOfFixedNodes[i];
1465 const SMDS_MeshNode * node = aMesh->FindNode(index);
1467 fixedNodes.insert( node );
1469 ::SMESH_MeshEditor::SmoothMethod method = ::SMESH_MeshEditor::LAPLACIAN;
1470 if ( Method != SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH )
1471 method = ::SMESH_MeshEditor::CENTROIDAL;
1473 ::SMESH_MeshEditor anEditor( myMesh );
1474 anEditor.Smooth(elements, fixedNodes, method,
1475 MaxNbOfIterations, MaxAspectRatio, IsParametric );
1477 myMesh->GetMeshDS()->Modified();
1478 myMesh->SetIsModified( true ); // issue 0020693
1480 storeResult(anEditor);
1482 // Update Python script
1483 TPythonDump() << "isDone = " << this << "."
1484 << (IsParametric ? "SmoothParametric( " : "Smooth( ")
1485 << IDsOfElements << ", " << IDsOfFixedNodes << ", "
1486 << TVar( MaxNbOfIterations ) << ", " << TVar( MaxAspectRatio ) << ", "
1487 << "SMESH.SMESH_MeshEditor."
1488 << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
1489 "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
1495 //=============================================================================
1499 //=============================================================================
1502 SMESH_MeshEditor_i::smoothObject(SMESH::SMESH_IDSource_ptr theObject,
1503 const SMESH::long_array & IDsOfFixedNodes,
1504 CORBA::Long MaxNbOfIterations,
1505 CORBA::Double MaxAspectRatio,
1506 SMESH::SMESH_MeshEditor::Smooth_Method Method,
1511 TPythonDump aTPythonDump; // suppress dump in smooth()
1513 SMESH::long_array_var anElementsId = theObject->GetIDs();
1514 CORBA::Boolean isDone = smooth (anElementsId, IDsOfFixedNodes, MaxNbOfIterations,
1515 MaxAspectRatio, Method, IsParametric);
1517 // Update Python script
1518 aTPythonDump << "isDone = " << this << "."
1519 << (IsParametric ? "SmoothParametricObject( " : "SmoothObject( ")
1520 << theObject << ", " << IDsOfFixedNodes << ", "
1521 << TVar( MaxNbOfIterations ) << ", " << TVar( MaxAspectRatio ) << ", "
1522 << "SMESH.SMESH_MeshEditor."
1523 << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
1524 "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
1530 //=============================================================================
1534 //=============================================================================
1536 void SMESH_MeshEditor_i::RenumberNodes()
1538 // Update Python script
1539 TPythonDump() << this << ".RenumberNodes()";
1541 GetMeshDS()->Renumber( true );
1545 //=============================================================================
1549 //=============================================================================
1551 void SMESH_MeshEditor_i::RenumberElements()
1553 // Update Python script
1554 TPythonDump() << this << ".RenumberElements()";
1556 GetMeshDS()->Renumber( false );
1559 //=======================================================================
1561 * \brief Return groups by their IDs
1563 //=======================================================================
1565 SMESH::ListOfGroups* SMESH_MeshEditor_i::getGroups(const std::list<int>* groupIDs)
1569 myMesh_i->CreateGroupServants();
1570 return myMesh_i->GetGroups( *groupIDs );
1573 //=======================================================================
1574 //function : rotationSweep
1576 //=======================================================================
1578 SMESH::ListOfGroups*
1579 SMESH_MeshEditor_i::rotationSweep(const SMESH::long_array & theIDsOfElements,
1580 const SMESH::AxisStruct & theAxis,
1581 CORBA::Double theAngleInRadians,
1582 CORBA::Long theNbOfSteps,
1583 CORBA::Double theTolerance,
1584 const bool theMakeGroups,
1585 const SMDSAbs_ElementType theElementType)
1589 TIDSortedElemSet inElements, copyElements;
1590 arrayToSet(theIDsOfElements, GetMeshDS(), inElements, theElementType);
1592 TIDSortedElemSet* workElements = & inElements;
1593 TPreviewMesh tmpMesh( SMDSAbs_Face );
1594 SMESH_Mesh* mesh = 0;
1595 bool makeWalls=true;
1596 if ( myPreviewMode )
1598 SMDSAbs_ElementType select = SMDSAbs_All, avoid = SMDSAbs_Volume;
1599 tmpMesh.Copy( inElements, copyElements, select, avoid );
1601 workElements = & copyElements;
1602 //makeWalls = false;
1609 gp_Ax1 Ax1 (gp_Pnt( theAxis.x, theAxis.y, theAxis.z ),
1610 gp_Vec( theAxis.vx, theAxis.vy, theAxis.vz ));
1612 ::SMESH_MeshEditor anEditor( mesh );
1613 ::SMESH_MeshEditor::PGroupIDs groupIds =
1614 anEditor.RotationSweep (*workElements, Ax1, theAngleInRadians,
1615 theNbOfSteps, theTolerance, theMakeGroups, makeWalls);
1616 storeResult(anEditor);
1617 myMesh->GetMeshDS()->Modified();
1619 // myMesh->SetIsModified( true ); -- it does not influence Compute()
1621 return theMakeGroups ? getGroups(groupIds.get()) : 0;
1624 //=======================================================================
1625 //function : RotationSweep
1627 //=======================================================================
1629 void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElements,
1630 const SMESH::AxisStruct & theAxis,
1631 CORBA::Double theAngleInRadians,
1632 CORBA::Long theNbOfSteps,
1633 CORBA::Double theTolerance)
1635 if ( !myPreviewMode ) {
1636 TPythonDump() << this << ".RotationSweep( "
1637 << theIDsOfElements << ", "
1639 << TVar( theAngleInRadians ) << ", "
1640 << TVar( theNbOfSteps ) << ", "
1641 << TVar( theTolerance ) << " )";
1643 rotationSweep(theIDsOfElements,
1651 //=======================================================================
1652 //function : RotationSweepMakeGroups
1654 //=======================================================================
1656 SMESH::ListOfGroups*
1657 SMESH_MeshEditor_i::RotationSweepMakeGroups(const SMESH::long_array& theIDsOfElements,
1658 const SMESH::AxisStruct& theAxis,
1659 CORBA::Double theAngleInRadians,
1660 CORBA::Long theNbOfSteps,
1661 CORBA::Double theTolerance)
1663 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
1665 SMESH::ListOfGroups *aGroups = rotationSweep(theIDsOfElements,
1671 if (!myPreviewMode) {
1672 DumpGroupsList(aPythonDump, aGroups);
1673 aPythonDump << this << ".RotationSweepMakeGroups( "
1674 << theIDsOfElements << ", "
1676 << TVar( theAngleInRadians ) << ", "
1677 << TVar( theNbOfSteps ) << ", "
1678 << TVar( theTolerance ) << " )";
1683 //=======================================================================
1684 //function : RotationSweepObject
1686 //=======================================================================
1688 void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject,
1689 const SMESH::AxisStruct & theAxis,
1690 CORBA::Double theAngleInRadians,
1691 CORBA::Long theNbOfSteps,
1692 CORBA::Double theTolerance)
1694 if ( !myPreviewMode ) {
1695 TPythonDump() << this << ".RotationSweepObject( "
1696 << theObject << ", "
1698 << theAngleInRadians << ", "
1699 << theNbOfSteps << ", "
1700 << theTolerance << " )";
1702 SMESH::long_array_var anElementsId = theObject->GetIDs();
1703 rotationSweep(anElementsId,
1711 //=======================================================================
1712 //function : RotationSweepObject1D
1714 //=======================================================================
1716 void SMESH_MeshEditor_i::RotationSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
1717 const SMESH::AxisStruct & theAxis,
1718 CORBA::Double theAngleInRadians,
1719 CORBA::Long theNbOfSteps,
1720 CORBA::Double theTolerance)
1722 if ( !myPreviewMode ) {
1723 TPythonDump() << this << ".RotationSweepObject1D( "
1724 << theObject << ", "
1726 << TVar( theAngleInRadians ) << ", "
1727 << TVar( theNbOfSteps ) << ", "
1728 << TVar( theTolerance ) << " )";
1730 SMESH::long_array_var anElementsId = theObject->GetIDs();
1731 rotationSweep(anElementsId,
1740 //=======================================================================
1741 //function : RotationSweepObject2D
1743 //=======================================================================
1745 void SMESH_MeshEditor_i::RotationSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
1746 const SMESH::AxisStruct & theAxis,
1747 CORBA::Double theAngleInRadians,
1748 CORBA::Long theNbOfSteps,
1749 CORBA::Double theTolerance)
1751 if ( !myPreviewMode ) {
1752 TPythonDump() << this << ".RotationSweepObject2D( "
1753 << theObject << ", "
1755 << TVar( theAngleInRadians ) << ", "
1756 << TVar( theNbOfSteps ) << ", "
1757 << TVar( theTolerance ) << " )";
1759 SMESH::long_array_var anElementsId = theObject->GetIDs();
1760 rotationSweep(anElementsId,
1769 //=======================================================================
1770 //function : RotationSweepObjectMakeGroups
1772 //=======================================================================
1774 SMESH::ListOfGroups*
1775 SMESH_MeshEditor_i::RotationSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1776 const SMESH::AxisStruct& theAxis,
1777 CORBA::Double theAngleInRadians,
1778 CORBA::Long theNbOfSteps,
1779 CORBA::Double theTolerance)
1781 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
1783 SMESH::long_array_var anElementsId = theObject->GetIDs();
1784 SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
1790 if (!myPreviewMode) {
1791 DumpGroupsList(aPythonDump, aGroups);
1792 aPythonDump << this << ".RotationSweepObjectMakeGroups( "
1793 << theObject << ", "
1795 << theAngleInRadians << ", "
1796 << theNbOfSteps << ", "
1797 << theTolerance << " )";
1802 //=======================================================================
1803 //function : RotationSweepObject1DMakeGroups
1805 //=======================================================================
1807 SMESH::ListOfGroups*
1808 SMESH_MeshEditor_i::RotationSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1809 const SMESH::AxisStruct& theAxis,
1810 CORBA::Double theAngleInRadians,
1811 CORBA::Long theNbOfSteps,
1812 CORBA::Double theTolerance)
1814 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
1816 SMESH::long_array_var anElementsId = theObject->GetIDs();
1817 SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
1824 if (!myPreviewMode) {
1825 DumpGroupsList(aPythonDump, aGroups);
1826 aPythonDump << this << ".RotationSweepObject1DMakeGroups( "
1827 << theObject << ", "
1829 << TVar( theAngleInRadians ) << ", "
1830 << TVar( theNbOfSteps ) << ", "
1831 << TVar( theTolerance ) << " )";
1836 //=======================================================================
1837 //function : RotationSweepObject2DMakeGroups
1839 //=======================================================================
1841 SMESH::ListOfGroups*
1842 SMESH_MeshEditor_i::RotationSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1843 const SMESH::AxisStruct& theAxis,
1844 CORBA::Double theAngleInRadians,
1845 CORBA::Long theNbOfSteps,
1846 CORBA::Double theTolerance)
1848 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
1850 SMESH::long_array_var anElementsId = theObject->GetIDs();
1851 SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
1858 if (!myPreviewMode) {
1859 DumpGroupsList(aPythonDump, aGroups);
1860 aPythonDump << this << ".RotationSweepObject2DMakeGroups( "
1861 << theObject << ", "
1863 << TVar( theAngleInRadians ) << ", "
1864 << TVar( theNbOfSteps ) << ", "
1865 << TVar( theTolerance ) << " )";
1871 //=======================================================================
1872 //function : extrusionSweep
1874 //=======================================================================
1876 SMESH::ListOfGroups*
1877 SMESH_MeshEditor_i::extrusionSweep(const SMESH::long_array & theIDsOfElements,
1878 const SMESH::DirStruct & theStepVector,
1879 CORBA::Long theNbOfSteps,
1881 const SMDSAbs_ElementType theElementType)
1889 TIDSortedElemSet elements, copyElements;
1890 arrayToSet(theIDsOfElements, GetMeshDS(), elements, theElementType);
1892 const SMESH::PointStruct * P = &theStepVector.PS;
1893 gp_Vec stepVec( P->x, P->y, P->z );
1895 TIDSortedElemSet* workElements = & elements;
1897 SMDSAbs_ElementType aType = SMDSAbs_Face;
1898 //::SMESH_MeshEditor::ExtrusionFlags aFlag = ::SMESH_MeshEditor::ExtrusionFlags::EXTRUSION_FLAG_BOUNDARY;
1899 if (theElementType == SMDSAbs_Node)
1901 aType = SMDSAbs_Edge;
1902 //aFlag = ::SMESH_MeshEditor::ExtrusionFlags::EXTRUSION_FLAG_SEW;
1904 TPreviewMesh tmpMesh( aType );
1905 SMESH_Mesh* mesh = myMesh;
1907 if ( myPreviewMode ) {
1908 SMDSAbs_ElementType select = SMDSAbs_All, avoid = SMDSAbs_Volume;
1909 tmpMesh.Copy( elements, copyElements, select, avoid );
1911 workElements = & copyElements;
1912 theMakeGroups = false;
1915 TElemOfElemListMap aHystory;
1916 ::SMESH_MeshEditor anEditor( mesh );
1917 ::SMESH_MeshEditor::PGroupIDs groupIds =
1918 anEditor.ExtrusionSweep (*workElements, stepVec, theNbOfSteps, aHystory, theMakeGroups);
1920 myMesh->GetMeshDS()->Modified();
1921 storeResult(anEditor);
1923 return theMakeGroups ? getGroups(groupIds.get()) : 0;
1925 } catch(Standard_Failure) {
1926 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1927 INFOS( "SMESH_MeshEditor_i::ExtrusionSweep fails - "<< aFail->GetMessageString() );
1932 //=======================================================================
1933 //function : ExtrusionSweep
1935 //=======================================================================
1937 void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElements,
1938 const SMESH::DirStruct & theStepVector,
1939 CORBA::Long theNbOfSteps)
1941 extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false );
1942 if (!myPreviewMode) {
1943 TPythonDump() << this << ".ExtrusionSweep( "
1944 << theIDsOfElements << ", " << theStepVector <<", " << TVar(theNbOfSteps) << " )";
1948 //=======================================================================
1949 //function : ExtrusionSweep0D
1951 //=======================================================================
1953 void SMESH_MeshEditor_i::ExtrusionSweep0D(const SMESH::long_array & theIDsOfElements,
1954 const SMESH::DirStruct & theStepVector,
1955 CORBA::Long theNbOfSteps)
1957 extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false, SMDSAbs_Node );
1958 if (!myPreviewMode) {
1959 TPythonDump() << this << ".ExtrusionSweep0D( "
1960 << theIDsOfElements << ", " << theStepVector <<", " << TVar(theNbOfSteps)<< " )";
1964 //=======================================================================
1965 //function : ExtrusionSweepObject
1967 //=======================================================================
1969 void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObject,
1970 const SMESH::DirStruct & theStepVector,
1971 CORBA::Long theNbOfSteps)
1973 SMESH::long_array_var anElementsId = theObject->GetIDs();
1974 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false );
1975 if (!myPreviewMode) {
1976 TPythonDump() << this << ".ExtrusionSweepObject( "
1977 << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
1981 //=======================================================================
1982 //function : ExtrusionSweepObject0D
1984 //=======================================================================
1986 void SMESH_MeshEditor_i::ExtrusionSweepObject0D(SMESH::SMESH_IDSource_ptr theObject,
1987 const SMESH::DirStruct & theStepVector,
1988 CORBA::Long theNbOfSteps)
1990 SMESH::long_array_var anElementsId = theObject->GetIDs();
1991 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Node );
1992 if ( !myPreviewMode ) {
1993 TPythonDump() << this << ".ExtrusionSweepObject0D( "
1994 << theObject << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )";
1998 //=======================================================================
1999 //function : ExtrusionSweepObject1D
2001 //=======================================================================
2003 void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
2004 const SMESH::DirStruct & theStepVector,
2005 CORBA::Long theNbOfSteps)
2007 SMESH::long_array_var anElementsId = theObject->GetIDs();
2008 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Edge );
2009 if ( !myPreviewMode ) {
2010 TPythonDump() << this << ".ExtrusionSweepObject1D( "
2011 << theObject << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )";
2015 //=======================================================================
2016 //function : ExtrusionSweepObject2D
2018 //=======================================================================
2020 void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
2021 const SMESH::DirStruct & theStepVector,
2022 CORBA::Long theNbOfSteps)
2024 SMESH::long_array_var anElementsId = theObject->GetIDs();
2025 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Face );
2026 if ( !myPreviewMode ) {
2027 TPythonDump() << this << ".ExtrusionSweepObject2D( "
2028 << theObject << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )";
2032 //=======================================================================
2033 //function : ExtrusionSweepMakeGroups
2035 //=======================================================================
2037 SMESH::ListOfGroups*
2038 SMESH_MeshEditor_i::ExtrusionSweepMakeGroups(const SMESH::long_array& theIDsOfElements,
2039 const SMESH::DirStruct& theStepVector,
2040 CORBA::Long theNbOfSteps)
2042 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2044 SMESH::ListOfGroups* aGroups = extrusionSweep(theIDsOfElements, theStepVector, theNbOfSteps, true);
2046 if (!myPreviewMode) {
2047 DumpGroupsList(aPythonDump, aGroups);
2048 aPythonDump << this << ".ExtrusionSweepMakeGroups( " << theIDsOfElements
2049 << ", " << theStepVector <<", " << TVar( theNbOfSteps ) << " )";
2054 //=======================================================================
2055 //function : ExtrusionSweepMakeGroups0D
2057 //=======================================================================
2059 SMESH::ListOfGroups*
2060 SMESH_MeshEditor_i::ExtrusionSweepMakeGroups0D(const SMESH::long_array& theIDsOfElements,
2061 const SMESH::DirStruct& theStepVector,
2062 CORBA::Long theNbOfSteps)
2064 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2066 SMESH::ListOfGroups* aGroups = extrusionSweep(theIDsOfElements, theStepVector, theNbOfSteps, true,SMDSAbs_Node);
2068 if (!myPreviewMode) {
2069 DumpGroupsList(aPythonDump, aGroups);
2070 aPythonDump << this << ".ExtrusionSweepMakeGroups0D( " << theIDsOfElements
2071 << ", " << theStepVector <<", " << TVar( theNbOfSteps ) << " )";
2076 //=======================================================================
2077 //function : ExtrusionSweepObjectMakeGroups
2079 //=======================================================================
2081 SMESH::ListOfGroups*
2082 SMESH_MeshEditor_i::ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2083 const SMESH::DirStruct& theStepVector,
2084 CORBA::Long theNbOfSteps)
2086 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2088 SMESH::long_array_var anElementsId = theObject->GetIDs();
2089 SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector, theNbOfSteps, true);
2091 if (!myPreviewMode) {
2092 DumpGroupsList(aPythonDump, aGroups);
2093 aPythonDump << this << ".ExtrusionSweepObjectMakeGroups( " << theObject
2094 << ", " << theStepVector << ", " << theNbOfSteps << " )";
2099 //=======================================================================
2100 //function : ExtrusionSweepObject0DMakeGroups
2102 //=======================================================================
2104 SMESH::ListOfGroups*
2105 SMESH_MeshEditor_i::ExtrusionSweepObject0DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2106 const SMESH::DirStruct& theStepVector,
2107 CORBA::Long theNbOfSteps)
2109 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2111 SMESH::long_array_var anElementsId = theObject->GetIDs();
2112 SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector,
2113 theNbOfSteps, true, SMDSAbs_Node);
2114 if (!myPreviewMode) {
2115 DumpGroupsList(aPythonDump, aGroups);
2116 aPythonDump << this << ".ExtrusionSweepObject0DMakeGroups( " << theObject
2117 << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )";
2122 //=======================================================================
2123 //function : ExtrusionSweepObject1DMakeGroups
2125 //=======================================================================
2127 SMESH::ListOfGroups*
2128 SMESH_MeshEditor_i::ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2129 const SMESH::DirStruct& theStepVector,
2130 CORBA::Long theNbOfSteps)
2132 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2134 SMESH::long_array_var anElementsId = theObject->GetIDs();
2135 SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector,
2136 theNbOfSteps, true, SMDSAbs_Edge);
2137 if (!myPreviewMode) {
2138 DumpGroupsList(aPythonDump, aGroups);
2139 aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( " << theObject
2140 << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )";
2145 //=======================================================================
2146 //function : ExtrusionSweepObject2DMakeGroups
2148 //=======================================================================
2150 SMESH::ListOfGroups*
2151 SMESH_MeshEditor_i::ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2152 const SMESH::DirStruct& theStepVector,
2153 CORBA::Long theNbOfSteps)
2155 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2157 SMESH::long_array_var anElementsId = theObject->GetIDs();
2158 SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector,
2159 theNbOfSteps, true, SMDSAbs_Face);
2160 if (!myPreviewMode) {
2161 DumpGroupsList(aPythonDump, aGroups);
2162 aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( " << theObject
2163 << ", " << theStepVector << ", " << TVar( theNbOfSteps ) << " )";
2169 //=======================================================================
2170 //function : advancedExtrusion
2172 //=======================================================================
2174 SMESH::ListOfGroups*
2175 SMESH_MeshEditor_i::advancedExtrusion(const SMESH::long_array & theIDsOfElements,
2176 const SMESH::DirStruct & theStepVector,
2177 CORBA::Long theNbOfSteps,
2178 CORBA::Long theExtrFlags,
2179 CORBA::Double theSewTolerance,
2180 const bool theMakeGroups)
2184 TIDSortedElemSet elements;
2185 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
2187 const SMESH::PointStruct * P = &theStepVector.PS;
2188 gp_Vec stepVec( P->x, P->y, P->z );
2190 ::SMESH_MeshEditor anEditor( myMesh );
2191 TElemOfElemListMap aHystory;
2192 ::SMESH_MeshEditor::PGroupIDs groupIds =
2193 anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory,
2194 theMakeGroups, theExtrFlags, theSewTolerance);
2195 storeResult(anEditor);
2197 return theMakeGroups ? getGroups(groupIds.get()) : 0;
2200 //=======================================================================
2201 //function : AdvancedExtrusion
2203 //=======================================================================
2205 void SMESH_MeshEditor_i::AdvancedExtrusion(const SMESH::long_array & theIDsOfElements,
2206 const SMESH::DirStruct & theStepVector,
2207 CORBA::Long theNbOfSteps,
2208 CORBA::Long theExtrFlags,
2209 CORBA::Double theSewTolerance)
2211 if ( !myPreviewMode ) {
2212 TPythonDump() << "stepVector = " << theStepVector;
2213 TPythonDump() << this << ".AdvancedExtrusion("
2216 << theNbOfSteps << ","
2217 << theExtrFlags << ", "
2218 << theSewTolerance << " )";
2220 advancedExtrusion( theIDsOfElements,
2228 //=======================================================================
2229 //function : AdvancedExtrusionMakeGroups
2231 //=======================================================================
2232 SMESH::ListOfGroups*
2233 SMESH_MeshEditor_i::AdvancedExtrusionMakeGroups(const SMESH::long_array& theIDsOfElements,
2234 const SMESH::DirStruct& theStepVector,
2235 CORBA::Long theNbOfSteps,
2236 CORBA::Long theExtrFlags,
2237 CORBA::Double theSewTolerance)
2239 if (!myPreviewMode) {
2240 TPythonDump() << "stepVector = " << theStepVector;
2242 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2244 SMESH::ListOfGroups * aGroups = advancedExtrusion( theIDsOfElements,
2251 if (!myPreviewMode) {
2252 DumpGroupsList(aPythonDump, aGroups);
2253 aPythonDump << this << ".AdvancedExtrusionMakeGroups("
2256 << theNbOfSteps << ","
2257 << theExtrFlags << ", "
2258 << theSewTolerance << " )";
2264 //================================================================================
2266 * \brief Convert extrusion error to IDL enum
2268 //================================================================================
2270 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
2272 static SMESH::SMESH_MeshEditor::Extrusion_Error convExtrError( const::SMESH_MeshEditor::Extrusion_Error e )
2276 RETCASE( EXTR_NO_ELEMENTS );
2277 RETCASE( EXTR_PATH_NOT_EDGE );
2278 RETCASE( EXTR_BAD_PATH_SHAPE );
2279 RETCASE( EXTR_BAD_STARTING_NODE );
2280 RETCASE( EXTR_BAD_ANGLES_NUMBER );
2281 RETCASE( EXTR_CANT_GET_TANGENT );
2283 return SMESH::SMESH_MeshEditor::EXTR_OK;
2287 //=======================================================================
2288 //function : extrusionAlongPath
2290 //=======================================================================
2291 SMESH::ListOfGroups*
2292 SMESH_MeshEditor_i::extrusionAlongPath(const SMESH::long_array & theIDsOfElements,
2293 SMESH::SMESH_Mesh_ptr thePathMesh,
2294 GEOM::GEOM_Object_ptr thePathShape,
2295 CORBA::Long theNodeStart,
2296 CORBA::Boolean theHasAngles,
2297 const SMESH::double_array & theAngles,
2298 CORBA::Boolean theHasRefPoint,
2299 const SMESH::PointStruct & theRefPoint,
2300 const bool theMakeGroups,
2301 SMESH::SMESH_MeshEditor::Extrusion_Error & theError,
2302 const SMDSAbs_ElementType theElementType)
2304 MESSAGE("extrusionAlongPath");
2307 if ( thePathMesh->_is_nil() || thePathShape->_is_nil() ) {
2308 theError = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
2311 SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( thePathMesh );
2313 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
2314 SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
2316 if ( !aSubMesh || !aSubMesh->GetSubMeshDS()) {
2317 theError = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
2321 SMDS_MeshNode* nodeStart = (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(theNodeStart);
2323 theError = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
2327 TIDSortedElemSet elements;
2328 arrayToSet(theIDsOfElements, GetMeshDS(), elements, theElementType);
2330 list<double> angles;
2331 for (int i = 0; i < theAngles.length(); i++) {
2332 angles.push_back( theAngles[i] );
2335 gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z );
2337 int nbOldGroups = myMesh->NbGroup();
2339 ::SMESH_MeshEditor anEditor( myMesh );
2340 ::SMESH_MeshEditor::Extrusion_Error error =
2341 anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart,
2342 theHasAngles, angles, false,
2343 theHasRefPoint, refPnt, theMakeGroups );
2344 myMesh->GetMeshDS()->Modified();
2345 storeResult(anEditor);
2346 theError = convExtrError( error );
2348 if ( theMakeGroups ) {
2349 list<int> groupIDs = myMesh->GetGroupIds();
2350 list<int>::iterator newBegin = groupIDs.begin();
2351 std::advance( newBegin, nbOldGroups ); // skip old groups
2352 groupIDs.erase( groupIDs.begin(), newBegin );
2353 return getGroups( & groupIDs );
2359 //=======================================================================
2360 //function : extrusionAlongPathX
2362 //=======================================================================
2363 SMESH::ListOfGroups*
2364 SMESH_MeshEditor_i::extrusionAlongPathX(const SMESH::long_array & IDsOfElements,
2365 SMESH::SMESH_IDSource_ptr Path,
2366 CORBA::Long NodeStart,
2367 CORBA::Boolean HasAngles,
2368 const SMESH::double_array& Angles,
2369 CORBA::Boolean LinearVariation,
2370 CORBA::Boolean HasRefPoint,
2371 const SMESH::PointStruct& RefPoint,
2373 const SMDSAbs_ElementType ElementType,
2374 SMESH::SMESH_MeshEditor::Extrusion_Error & Error)
2376 SMESH::ListOfGroups* EmptyGr = new SMESH::ListOfGroups;
2380 list<double> angles;
2381 for (int i = 0; i < Angles.length(); i++) {
2382 angles.push_back( Angles[i] );
2384 gp_Pnt refPnt( RefPoint.x, RefPoint.y, RefPoint.z );
2385 int nbOldGroups = myMesh->NbGroup();
2387 if ( Path->_is_nil() ) {
2388 Error = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
2392 TIDSortedElemSet elements, copyElements;
2393 arrayToSet(IDsOfElements, GetMeshDS(), elements, ElementType);
2395 TIDSortedElemSet* workElements = &elements;
2396 TPreviewMesh tmpMesh( SMDSAbs_Face );
2397 SMESH_Mesh* mesh = myMesh;
2399 if ( myPreviewMode )
2401 SMDSAbs_ElementType select = SMDSAbs_All, avoid = SMDSAbs_Volume;
2402 tmpMesh.Copy( elements, copyElements, select, avoid );
2404 workElements = & copyElements;
2408 ::SMESH_MeshEditor anEditor( mesh );
2409 ::SMESH_MeshEditor::Extrusion_Error error;
2411 if ( SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( Path ))
2414 SMDS_MeshNode* aNodeStart =
2415 (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(NodeStart);
2416 if ( !aNodeStart ) {
2417 Error = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
2420 error = anEditor.ExtrusionAlongTrack( *workElements, &(aMeshImp->GetImpl()), aNodeStart,
2421 HasAngles, angles, LinearVariation,
2422 HasRefPoint, refPnt, MakeGroups );
2423 myMesh->GetMeshDS()->Modified();
2425 else if ( SMESH_subMesh_i* aSubMeshImp = SMESH::DownCast<SMESH_subMesh_i*>( Path ))
2428 SMESH::SMESH_Mesh_ptr aPathMesh = aSubMeshImp->GetFather();
2429 aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( aPathMesh );
2430 SMDS_MeshNode* aNodeStart =
2431 (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(NodeStart);
2432 if ( !aNodeStart ) {
2433 Error = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
2436 SMESH_subMesh* aSubMesh =
2437 aMeshImp->GetImpl().GetSubMeshContaining(aSubMeshImp->GetId());
2438 error = anEditor.ExtrusionAlongTrack( *workElements, aSubMesh, aNodeStart,
2439 HasAngles, angles, LinearVariation,
2440 HasRefPoint, refPnt, MakeGroups );
2441 myMesh->GetMeshDS()->Modified();
2443 else if ( SMESH::DownCast<SMESH_Group_i*>( Path ))
2445 // path as group of 1D elements
2451 Error = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
2455 storeResult(anEditor);
2456 Error = convExtrError( error );
2459 list<int> groupIDs = myMesh->GetGroupIds();
2460 list<int>::iterator newBegin = groupIDs.begin();
2461 std::advance( newBegin, nbOldGroups ); // skip old groups
2462 groupIDs.erase( groupIDs.begin(), newBegin );
2463 return getGroups( & groupIDs );
2469 //=======================================================================
2470 //function : ExtrusionAlongPath
2472 //=======================================================================
2473 SMESH::SMESH_MeshEditor::Extrusion_Error
2474 SMESH_MeshEditor_i::ExtrusionAlongPath(const SMESH::long_array & theIDsOfElements,
2475 SMESH::SMESH_Mesh_ptr thePathMesh,
2476 GEOM::GEOM_Object_ptr thePathShape,
2477 CORBA::Long theNodeStart,
2478 CORBA::Boolean theHasAngles,
2479 const SMESH::double_array & theAngles,
2480 CORBA::Boolean theHasRefPoint,
2481 const SMESH::PointStruct & theRefPoint)
2483 MESSAGE("ExtrusionAlongPath");
2484 if ( !myPreviewMode ) {
2485 TPythonDump() << "error = " << this << ".ExtrusionAlongPath( "
2486 << theIDsOfElements << ", "
2487 << thePathMesh << ", "
2488 << thePathShape << ", "
2489 << theNodeStart << ", "
2490 << theHasAngles << ", "
2491 << theAngles << ", "
2492 << theHasRefPoint << ", "
2493 << "SMESH.PointStruct( "
2494 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2495 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2496 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2498 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
2499 extrusionAlongPath( theIDsOfElements,
2512 //=======================================================================
2513 //function : ExtrusionAlongPathObject
2515 //=======================================================================
2516 SMESH::SMESH_MeshEditor::Extrusion_Error
2517 SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject,
2518 SMESH::SMESH_Mesh_ptr thePathMesh,
2519 GEOM::GEOM_Object_ptr thePathShape,
2520 CORBA::Long theNodeStart,
2521 CORBA::Boolean theHasAngles,
2522 const SMESH::double_array & theAngles,
2523 CORBA::Boolean theHasRefPoint,
2524 const SMESH::PointStruct & theRefPoint)
2526 if ( !myPreviewMode ) {
2527 TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject( "
2528 << theObject << ", "
2529 << thePathMesh << ", "
2530 << thePathShape << ", "
2531 << theNodeStart << ", "
2532 << theHasAngles << ", "
2533 << theAngles << ", "
2534 << theHasRefPoint << ", "
2535 << "SMESH.PointStruct( "
2536 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2537 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2538 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2540 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
2541 SMESH::long_array_var anElementsId = theObject->GetIDs();
2542 extrusionAlongPath( anElementsId,
2555 //=======================================================================
2556 //function : ExtrusionAlongPathObject1D
2558 //=======================================================================
2559 SMESH::SMESH_MeshEditor::Extrusion_Error
2560 SMESH_MeshEditor_i::ExtrusionAlongPathObject1D(SMESH::SMESH_IDSource_ptr theObject,
2561 SMESH::SMESH_Mesh_ptr thePathMesh,
2562 GEOM::GEOM_Object_ptr thePathShape,
2563 CORBA::Long theNodeStart,
2564 CORBA::Boolean theHasAngles,
2565 const SMESH::double_array & theAngles,
2566 CORBA::Boolean theHasRefPoint,
2567 const SMESH::PointStruct & theRefPoint)
2569 if ( !myPreviewMode ) {
2570 TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject1D( "
2571 << theObject << ", "
2572 << thePathMesh << ", "
2573 << thePathShape << ", "
2574 << theNodeStart << ", "
2575 << theHasAngles << ", "
2576 << theAngles << ", "
2577 << theHasRefPoint << ", "
2578 << "SMESH.PointStruct( "
2579 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2580 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2581 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2583 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
2584 SMESH::long_array_var anElementsId = theObject->GetIDs();
2585 extrusionAlongPath( anElementsId,
2599 //=======================================================================
2600 //function : ExtrusionAlongPathObject2D
2602 //=======================================================================
2603 SMESH::SMESH_MeshEditor::Extrusion_Error
2604 SMESH_MeshEditor_i::ExtrusionAlongPathObject2D(SMESH::SMESH_IDSource_ptr theObject,
2605 SMESH::SMESH_Mesh_ptr thePathMesh,
2606 GEOM::GEOM_Object_ptr thePathShape,
2607 CORBA::Long theNodeStart,
2608 CORBA::Boolean theHasAngles,
2609 const SMESH::double_array & theAngles,
2610 CORBA::Boolean theHasRefPoint,
2611 const SMESH::PointStruct & theRefPoint)
2613 if ( !myPreviewMode ) {
2614 TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject2D( "
2615 << theObject << ", "
2616 << thePathMesh << ", "
2617 << thePathShape << ", "
2618 << theNodeStart << ", "
2619 << theHasAngles << ", "
2620 << theAngles << ", "
2621 << theHasRefPoint << ", "
2622 << "SMESH.PointStruct( "
2623 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2624 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2625 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2627 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
2628 SMESH::long_array_var anElementsId = theObject->GetIDs();
2629 extrusionAlongPath( anElementsId,
2644 //=======================================================================
2645 //function : ExtrusionAlongPathMakeGroups
2647 //=======================================================================
2648 SMESH::ListOfGroups*
2649 SMESH_MeshEditor_i::ExtrusionAlongPathMakeGroups(const SMESH::long_array& theIDsOfElements,
2650 SMESH::SMESH_Mesh_ptr thePathMesh,
2651 GEOM::GEOM_Object_ptr thePathShape,
2652 CORBA::Long theNodeStart,
2653 CORBA::Boolean theHasAngles,
2654 const SMESH::double_array& theAngles,
2655 CORBA::Boolean theHasRefPoint,
2656 const SMESH::PointStruct& theRefPoint,
2657 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2659 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2661 SMESH::ListOfGroups * aGroups = extrusionAlongPath( theIDsOfElements,
2671 if (!myPreviewMode) {
2672 bool isDumpGroups = aGroups && aGroups->length() > 0;
2674 aPythonDump << "(" << aGroups << ", error)";
2676 aPythonDump <<"error";
2678 aPythonDump<<" = "<< this << ".ExtrusionAlongPathMakeGroups( "
2679 << theIDsOfElements << ", "
2680 << thePathMesh << ", "
2681 << thePathShape << ", "
2682 << theNodeStart << ", "
2683 << theHasAngles << ", "
2684 << theAngles << ", "
2685 << theHasRefPoint << ", "
2686 << "SMESH.PointStruct( "
2687 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2688 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2689 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2694 //=======================================================================
2695 //function : ExtrusionAlongPathObjectMakeGroups
2697 //=======================================================================
2698 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2699 ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2700 SMESH::SMESH_Mesh_ptr thePathMesh,
2701 GEOM::GEOM_Object_ptr thePathShape,
2702 CORBA::Long theNodeStart,
2703 CORBA::Boolean theHasAngles,
2704 const SMESH::double_array& theAngles,
2705 CORBA::Boolean theHasRefPoint,
2706 const SMESH::PointStruct& theRefPoint,
2707 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2709 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2711 SMESH::long_array_var anElementsId = theObject->GetIDs();
2712 SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
2723 if (!myPreviewMode) {
2724 bool isDumpGroups = aGroups && aGroups->length() > 0;
2726 aPythonDump << "(" << aGroups << ", error)";
2728 aPythonDump <<"error";
2730 aPythonDump << " = " << this << ".ExtrusionAlongPathObjectMakeGroups( "
2731 << theObject << ", "
2732 << thePathMesh << ", "
2733 << thePathShape << ", "
2734 << theNodeStart << ", "
2735 << theHasAngles << ", "
2736 << theAngles << ", "
2737 << theHasRefPoint << ", "
2738 << "SMESH.PointStruct( "
2739 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2740 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2741 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2746 //=======================================================================
2747 //function : ExtrusionAlongPathObject1DMakeGroups
2749 //=======================================================================
2750 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2751 ExtrusionAlongPathObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2752 SMESH::SMESH_Mesh_ptr thePathMesh,
2753 GEOM::GEOM_Object_ptr thePathShape,
2754 CORBA::Long theNodeStart,
2755 CORBA::Boolean theHasAngles,
2756 const SMESH::double_array& theAngles,
2757 CORBA::Boolean theHasRefPoint,
2758 const SMESH::PointStruct& theRefPoint,
2759 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2761 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2763 SMESH::long_array_var anElementsId = theObject->GetIDs();
2764 SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
2776 if (!myPreviewMode) {
2777 bool isDumpGroups = aGroups && aGroups->length() > 0;
2779 aPythonDump << "(" << aGroups << ", error)";
2781 aPythonDump << "error";
2783 aPythonDump << " = " << this << ".ExtrusionAlongPathObject1DMakeGroups( "
2784 << theObject << ", "
2785 << thePathMesh << ", "
2786 << thePathShape << ", "
2787 << theNodeStart << ", "
2788 << theHasAngles << ", "
2789 << theAngles << ", "
2790 << theHasRefPoint << ", "
2791 << "SMESH.PointStruct( "
2792 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2793 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2794 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2799 //=======================================================================
2800 //function : ExtrusionAlongPathObject2DMakeGroups
2802 //=======================================================================
2803 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2804 ExtrusionAlongPathObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2805 SMESH::SMESH_Mesh_ptr thePathMesh,
2806 GEOM::GEOM_Object_ptr thePathShape,
2807 CORBA::Long theNodeStart,
2808 CORBA::Boolean theHasAngles,
2809 const SMESH::double_array& theAngles,
2810 CORBA::Boolean theHasRefPoint,
2811 const SMESH::PointStruct& theRefPoint,
2812 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2814 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2816 SMESH::long_array_var anElementsId = theObject->GetIDs();
2817 SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
2829 if (!myPreviewMode) {
2830 bool isDumpGroups = aGroups && aGroups->length() > 0;
2832 aPythonDump << "(" << aGroups << ", error)";
2834 aPythonDump << "error";
2836 aPythonDump << " = " << this << ".ExtrusionAlongPathObject2DMakeGroups( "
2837 << theObject << ", "
2838 << thePathMesh << ", "
2839 << thePathShape << ", "
2840 << theNodeStart << ", "
2841 << theHasAngles << ", "
2842 << theAngles << ", "
2843 << theHasRefPoint << ", "
2844 << "SMESH.PointStruct( "
2845 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2846 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2847 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2853 //=======================================================================
2854 //function : ExtrusionAlongPathObjX
2856 //=======================================================================
2857 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2858 ExtrusionAlongPathObjX(SMESH::SMESH_IDSource_ptr Object,
2859 SMESH::SMESH_IDSource_ptr Path,
2860 CORBA::Long NodeStart,
2861 CORBA::Boolean HasAngles,
2862 const SMESH::double_array& Angles,
2863 CORBA::Boolean LinearVariation,
2864 CORBA::Boolean HasRefPoint,
2865 const SMESH::PointStruct& RefPoint,
2866 CORBA::Boolean MakeGroups,
2867 SMESH::ElementType ElemType,
2868 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2870 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2872 SMESH::long_array_var anElementsId = Object->GetIDs();
2873 SMESH::ListOfGroups * aGroups = extrusionAlongPathX(anElementsId,
2882 (SMDSAbs_ElementType)ElemType,
2885 if (!myPreviewMode) {
2886 bool isDumpGroups = aGroups && aGroups->length() > 0;
2888 aPythonDump << "(" << *aGroups << ", error)";
2890 aPythonDump << "error";
2892 aPythonDump << " = " << this << ".ExtrusionAlongPathObjX( "
2895 << NodeStart << ", "
2896 << HasAngles << ", "
2897 << TVar( Angles ) << ", "
2898 << LinearVariation << ", "
2899 << HasRefPoint << ", "
2900 << "SMESH.PointStruct( "
2901 << TVar( HasRefPoint ? RefPoint.x : 0 ) << ", "
2902 << TVar( HasRefPoint ? RefPoint.y : 0 ) << ", "
2903 << TVar( HasRefPoint ? RefPoint.z : 0 ) << " ), "
2904 << MakeGroups << ", "
2905 << ElemType << " )";
2911 //=======================================================================
2912 //function : ExtrusionAlongPathX
2914 //=======================================================================
2915 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2916 ExtrusionAlongPathX(const SMESH::long_array& IDsOfElements,
2917 SMESH::SMESH_IDSource_ptr Path,
2918 CORBA::Long NodeStart,
2919 CORBA::Boolean HasAngles,
2920 const SMESH::double_array& Angles,
2921 CORBA::Boolean LinearVariation,
2922 CORBA::Boolean HasRefPoint,
2923 const SMESH::PointStruct& RefPoint,
2924 CORBA::Boolean MakeGroups,
2925 SMESH::ElementType ElemType,
2926 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2928 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2930 SMESH::ListOfGroups * aGroups = extrusionAlongPathX(IDsOfElements,
2939 (SMDSAbs_ElementType)ElemType,
2942 if (!myPreviewMode) {
2943 bool isDumpGroups = aGroups && aGroups->length() > 0;
2945 aPythonDump << "(" << *aGroups << ", error)";
2947 aPythonDump <<"error";
2949 aPythonDump << " = " << this << ".ExtrusionAlongPathX( "
2950 << IDsOfElements << ", "
2952 << NodeStart << ", "
2953 << HasAngles << ", "
2954 << TVar( Angles ) << ", "
2955 << LinearVariation << ", "
2956 << HasRefPoint << ", "
2957 << "SMESH.PointStruct( "
2958 << TVar( HasRefPoint ? RefPoint.x : 0 ) << ", "
2959 << TVar( HasRefPoint ? RefPoint.y : 0 ) << ", "
2960 << TVar( HasRefPoint ? RefPoint.z : 0 ) << " ), "
2961 << MakeGroups << ", "
2962 << ElemType << " )";
2968 //================================================================================
2970 * \brief Compute rotation angles for ExtrusionAlongPath as linear variation
2971 * of given angles along path steps
2972 * \param PathMesh mesh containing a 1D sub-mesh on the edge, along
2973 * which proceeds the extrusion
2974 * \param PathShape is shape(edge); as the mesh can be complex, the edge
2975 * is used to define the sub-mesh for the path
2977 //================================================================================
2979 SMESH::double_array*
2980 SMESH_MeshEditor_i::LinearAnglesVariation(SMESH::SMESH_Mesh_ptr thePathMesh,
2981 GEOM::GEOM_Object_ptr thePathShape,
2982 const SMESH::double_array & theAngles)
2984 SMESH::double_array_var aResult = new SMESH::double_array();
2985 int nbAngles = theAngles.length();
2986 if ( nbAngles > 0 && !thePathMesh->_is_nil() && !thePathShape->_is_nil() )
2988 SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( thePathMesh );
2989 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
2990 SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
2991 if ( !aSubMesh || !aSubMesh->GetSubMeshDS())
2992 return aResult._retn();
2993 int nbSteps = aSubMesh->GetSubMeshDS()->NbElements();
2994 if ( nbSteps == nbAngles )
2996 aResult.inout() = theAngles;
3000 aResult->length( nbSteps );
3001 double rAn2St = double( nbAngles ) / double( nbSteps );
3002 double angPrev = 0, angle;
3003 for ( int iSt = 0; iSt < nbSteps; ++iSt )
3005 double angCur = rAn2St * ( iSt+1 );
3006 double angCurFloor = floor( angCur );
3007 double angPrevFloor = floor( angPrev );
3008 if ( angPrevFloor == angCurFloor )
3009 angle = rAn2St * theAngles[ int( angCurFloor ) ];
3012 int iP = int( angPrevFloor );
3013 double angPrevCeil = ceil(angPrev);
3014 angle = ( angPrevCeil - angPrev ) * theAngles[ iP ];
3016 int iC = int( angCurFloor );
3017 if ( iC < nbAngles )
3018 angle += ( angCur - angCurFloor ) * theAngles[ iC ];
3020 iP = int( angPrevCeil );
3022 angle += theAngles[ iC ];
3024 aResult[ iSt ] = angle;
3029 // Update Python script
3030 TPythonDump() << "rotAngles = " << theAngles;
3031 TPythonDump() << "rotAngles = " << this << ".LinearAnglesVariation( "
3032 << thePathMesh << ", "
3033 << thePathShape << ", "
3036 return aResult._retn();
3040 //=======================================================================
3043 //=======================================================================
3045 SMESH::ListOfGroups*
3046 SMESH_MeshEditor_i::mirror(TIDSortedElemSet & theElements,
3047 const SMESH::AxisStruct & theAxis,
3048 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
3049 CORBA::Boolean theCopy,
3051 ::SMESH_Mesh* theTargetMesh)
3055 gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
3056 gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
3058 if ( theTargetMesh )
3062 switch ( theMirrorType ) {
3063 case SMESH::SMESH_MeshEditor::POINT:
3064 aTrsf.SetMirror( P );
3066 case SMESH::SMESH_MeshEditor::AXIS:
3067 aTrsf.SetMirror( gp_Ax1( P, V ));
3070 aTrsf.SetMirror( gp_Ax2( P, V ));
3073 TIDSortedElemSet copyElements;
3074 TPreviewMesh tmpMesh;
3075 TIDSortedElemSet* workElements = & theElements;
3076 SMESH_Mesh* mesh = myMesh;
3078 if ( myPreviewMode )
3080 tmpMesh.Copy( theElements, copyElements);
3081 if ( !theCopy && !theTargetMesh )
3083 TIDSortedElemSet elemsAround, elemsAroundCopy;
3084 getElementsAround( theElements, GetMeshDS(), elemsAround );
3085 tmpMesh.Copy( elemsAround, elemsAroundCopy);
3088 workElements = & copyElements;
3089 theMakeGroups = false;
3092 ::SMESH_MeshEditor anEditor( mesh );
3093 ::SMESH_MeshEditor::PGroupIDs groupIds =
3094 anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
3096 if(theCopy || myPreviewMode)
3097 storeResult(anEditor); // store preview data or new elements
3099 if ( !myPreviewMode )
3101 if ( theTargetMesh )
3103 theTargetMesh->GetMeshDS()->Modified();
3107 myMesh->GetMeshDS()->Modified();
3108 myMesh->SetIsModified( true );
3111 return theMakeGroups ? getGroups(groupIds.get()) : 0;
3114 //=======================================================================
3117 //=======================================================================
3119 void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElements,
3120 const SMESH::AxisStruct & theAxis,
3121 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
3122 CORBA::Boolean theCopy)
3124 if ( !myPreviewMode ) {
3125 TPythonDump() << this << ".Mirror( "
3126 << theIDsOfElements << ", "
3128 << mirrorTypeName(theMirrorType) << ", "
3131 if ( theIDsOfElements.length() > 0 )
3133 TIDSortedElemSet elements;
3134 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3135 mirror(elements, theAxis, theMirrorType, theCopy, false);
3140 //=======================================================================
3141 //function : MirrorObject
3143 //=======================================================================
3145 void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObject,
3146 const SMESH::AxisStruct & theAxis,
3147 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
3148 CORBA::Boolean theCopy)
3150 if ( !myPreviewMode ) {
3151 TPythonDump() << this << ".MirrorObject( "
3152 << theObject << ", "
3154 << mirrorTypeName(theMirrorType) << ", "
3157 TIDSortedElemSet elements;
3159 bool emptyIfIsMesh = myPreviewMode ? false : true;
3161 if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
3162 mirror(elements, theAxis, theMirrorType, theCopy, false);
3165 //=======================================================================
3166 //function : MirrorMakeGroups
3168 //=======================================================================
3170 SMESH::ListOfGroups*
3171 SMESH_MeshEditor_i::MirrorMakeGroups(const SMESH::long_array& theIDsOfElements,
3172 const SMESH::AxisStruct& theMirror,
3173 SMESH::SMESH_MeshEditor::MirrorType theMirrorType)
3175 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3177 SMESH::ListOfGroups * aGroups = 0;
3178 if ( theIDsOfElements.length() > 0 )
3180 TIDSortedElemSet elements;
3181 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3182 aGroups = mirror(elements, theMirror, theMirrorType, true, true);
3184 if (!myPreviewMode) {
3185 DumpGroupsList(aPythonDump, aGroups);
3186 aPythonDump << this << ".MirrorMakeGroups( "
3187 << theIDsOfElements << ", "
3188 << theMirror << ", "
3189 << mirrorTypeName(theMirrorType) << " )";
3194 //=======================================================================
3195 //function : MirrorObjectMakeGroups
3197 //=======================================================================
3199 SMESH::ListOfGroups*
3200 SMESH_MeshEditor_i::MirrorObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
3201 const SMESH::AxisStruct& theMirror,
3202 SMESH::SMESH_MeshEditor::MirrorType theMirrorType)
3204 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3206 SMESH::ListOfGroups * aGroups = 0;
3207 TIDSortedElemSet elements;
3208 if ( idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3209 aGroups = mirror(elements, theMirror, theMirrorType, true, true);
3213 DumpGroupsList(aPythonDump,aGroups);
3214 aPythonDump << this << ".MirrorObjectMakeGroups( "
3215 << theObject << ", "
3216 << theMirror << ", "
3217 << mirrorTypeName(theMirrorType) << " )";
3222 //=======================================================================
3223 //function : MirrorMakeMesh
3225 //=======================================================================
3227 SMESH::SMESH_Mesh_ptr
3228 SMESH_MeshEditor_i::MirrorMakeMesh(const SMESH::long_array& theIDsOfElements,
3229 const SMESH::AxisStruct& theMirror,
3230 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
3231 CORBA::Boolean theCopyGroups,
3232 const char* theMeshName)
3234 SMESH_Mesh_i* mesh_i;
3235 SMESH::SMESH_Mesh_var mesh;
3236 { // open new scope to dump "MakeMesh" command
3237 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3239 TPythonDump pydump; // to prevent dump at mesh creation
3241 mesh = makeMesh( theMeshName );
3242 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3243 if (mesh_i && theIDsOfElements.length() > 0 )
3245 TIDSortedElemSet elements;
3246 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3247 mirror(elements, theMirror, theMirrorType,
3248 false, theCopyGroups, & mesh_i->GetImpl());
3249 mesh_i->CreateGroupServants();
3252 if (!myPreviewMode) {
3253 pydump << mesh << " = " << this << ".MirrorMakeMesh( "
3254 << theIDsOfElements << ", "
3255 << theMirror << ", "
3256 << mirrorTypeName(theMirrorType) << ", "
3257 << theCopyGroups << ", '"
3258 << theMeshName << "' )";
3263 if (!myPreviewMode && mesh_i)
3264 mesh_i->GetGroups();
3266 return mesh._retn();
3269 //=======================================================================
3270 //function : MirrorObjectMakeMesh
3272 //=======================================================================
3274 SMESH::SMESH_Mesh_ptr
3275 SMESH_MeshEditor_i::MirrorObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
3276 const SMESH::AxisStruct& theMirror,
3277 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
3278 CORBA::Boolean theCopyGroups,
3279 const char* theMeshName)
3281 SMESH_Mesh_i* mesh_i;
3282 SMESH::SMESH_Mesh_var mesh;
3283 { // open new scope to dump "MakeMesh" command
3284 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3286 TPythonDump pydump; // to prevent dump at mesh creation
3288 mesh = makeMesh( theMeshName );
3289 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3290 TIDSortedElemSet elements;
3292 idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3294 mirror(elements, theMirror, theMirrorType,
3295 false, theCopyGroups, & mesh_i->GetImpl());
3296 mesh_i->CreateGroupServants();
3298 if (!myPreviewMode) {
3299 pydump << mesh << " = " << this << ".MirrorObjectMakeMesh( "
3300 << theObject << ", "
3301 << theMirror << ", "
3302 << mirrorTypeName(theMirrorType) << ", "
3303 << theCopyGroups << ", '"
3304 << theMeshName << "' )";
3309 if (!myPreviewMode && mesh_i)
3310 mesh_i->GetGroups();
3312 return mesh._retn();
3315 //=======================================================================
3316 //function : translate
3318 //=======================================================================
3320 SMESH::ListOfGroups*
3321 SMESH_MeshEditor_i::translate(TIDSortedElemSet & theElements,
3322 const SMESH::DirStruct & theVector,
3323 CORBA::Boolean theCopy,
3325 ::SMESH_Mesh* theTargetMesh)
3329 if ( theTargetMesh )
3333 const SMESH::PointStruct * P = &theVector.PS;
3334 aTrsf.SetTranslation( gp_Vec( P->x, P->y, P->z ));
3336 TIDSortedElemSet copyElements;
3337 TIDSortedElemSet* workElements = &theElements;
3338 TPreviewMesh tmpMesh;
3339 SMESH_Mesh* mesh = myMesh;
3341 if ( myPreviewMode )
3343 tmpMesh.Copy( theElements, copyElements);
3344 if ( !theCopy && !theTargetMesh )
3346 TIDSortedElemSet elemsAround, elemsAroundCopy;
3347 getElementsAround( theElements, GetMeshDS(), elemsAround );
3348 tmpMesh.Copy( elemsAround, elemsAroundCopy);
3351 workElements = & copyElements;
3352 theMakeGroups = false;
3355 ::SMESH_MeshEditor anEditor( mesh );
3356 ::SMESH_MeshEditor::PGroupIDs groupIds =
3357 anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
3359 if(theCopy || myPreviewMode)
3360 storeResult(anEditor);
3362 if ( !myPreviewMode )
3364 if ( theTargetMesh )
3366 theTargetMesh->GetMeshDS()->Modified();
3370 myMesh->GetMeshDS()->Modified();
3371 myMesh->SetIsModified( true );
3375 return theMakeGroups ? getGroups(groupIds.get()) : 0;
3378 //=======================================================================
3379 //function : Translate
3381 //=======================================================================
3383 void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements,
3384 const SMESH::DirStruct & theVector,
3385 CORBA::Boolean theCopy)
3387 if (!myPreviewMode) {
3388 TPythonDump() << this << ".Translate( "
3389 << theIDsOfElements << ", "
3390 << theVector << ", "
3393 if (theIDsOfElements.length()) {
3394 TIDSortedElemSet elements;
3395 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3396 translate(elements, theVector, theCopy, false);
3400 //=======================================================================
3401 //function : TranslateObject
3403 //=======================================================================
3405 void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject,
3406 const SMESH::DirStruct & theVector,
3407 CORBA::Boolean theCopy)
3409 if (!myPreviewMode) {
3410 TPythonDump() << this << ".TranslateObject( "
3411 << theObject << ", "
3412 << theVector << ", "
3415 TIDSortedElemSet elements;
3417 bool emptyIfIsMesh = myPreviewMode ? false : true;
3419 if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
3420 translate(elements, theVector, theCopy, false);
3423 //=======================================================================
3424 //function : TranslateMakeGroups
3426 //=======================================================================
3428 SMESH::ListOfGroups*
3429 SMESH_MeshEditor_i::TranslateMakeGroups(const SMESH::long_array& theIDsOfElements,
3430 const SMESH::DirStruct& theVector)
3432 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3434 SMESH::ListOfGroups * aGroups = 0;
3435 if (theIDsOfElements.length()) {
3436 TIDSortedElemSet elements;
3437 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3438 aGroups = translate(elements,theVector,true,true);
3440 if (!myPreviewMode) {
3441 DumpGroupsList(aPythonDump, aGroups);
3442 aPythonDump << this << ".TranslateMakeGroups( "
3443 << theIDsOfElements << ", "
3444 << theVector << " )";
3449 //=======================================================================
3450 //function : TranslateObjectMakeGroups
3452 //=======================================================================
3454 SMESH::ListOfGroups*
3455 SMESH_MeshEditor_i::TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
3456 const SMESH::DirStruct& theVector)
3458 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3460 SMESH::ListOfGroups * aGroups = 0;
3461 TIDSortedElemSet elements;
3462 if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3463 aGroups = translate(elements, theVector, true, true);
3465 if (!myPreviewMode) {
3466 DumpGroupsList(aPythonDump, aGroups);
3467 aPythonDump << this << ".TranslateObjectMakeGroups( "
3468 << theObject << ", "
3469 << theVector << " )";
3474 //=======================================================================
3475 //function : TranslateMakeMesh
3477 //=======================================================================
3479 SMESH::SMESH_Mesh_ptr
3480 SMESH_MeshEditor_i::TranslateMakeMesh(const SMESH::long_array& theIDsOfElements,
3481 const SMESH::DirStruct& theVector,
3482 CORBA::Boolean theCopyGroups,
3483 const char* theMeshName)
3485 SMESH_Mesh_i* mesh_i;
3486 SMESH::SMESH_Mesh_var mesh;
3488 { // open new scope to dump "MakeMesh" command
3489 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3491 TPythonDump pydump; // to prevent dump at mesh creation
3493 mesh = makeMesh( theMeshName );
3494 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3496 if ( mesh_i && theIDsOfElements.length() )
3498 TIDSortedElemSet elements;
3499 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3500 translate(elements, theVector, false, theCopyGroups, & mesh_i->GetImpl());
3501 mesh_i->CreateGroupServants();
3504 if ( !myPreviewMode ) {
3505 pydump << mesh << " = " << this << ".TranslateMakeMesh( "
3506 << theIDsOfElements << ", "
3507 << theVector << ", "
3508 << theCopyGroups << ", '"
3509 << theMeshName << "' )";
3514 if (!myPreviewMode && mesh_i)
3515 mesh_i->GetGroups();
3517 return mesh._retn();
3520 //=======================================================================
3521 //function : TranslateObjectMakeMesh
3523 //=======================================================================
3525 SMESH::SMESH_Mesh_ptr
3526 SMESH_MeshEditor_i::TranslateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
3527 const SMESH::DirStruct& theVector,
3528 CORBA::Boolean theCopyGroups,
3529 const char* theMeshName)
3531 SMESH_Mesh_i* mesh_i;
3532 SMESH::SMESH_Mesh_var mesh;
3533 { // open new scope to dump "MakeMesh" command
3534 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3536 TPythonDump pydump; // to prevent dump at mesh creation
3537 mesh = makeMesh( theMeshName );
3538 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3540 TIDSortedElemSet elements;
3542 idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3544 translate(elements, theVector,false, theCopyGroups, & mesh_i->GetImpl());
3545 mesh_i->CreateGroupServants();
3547 if ( !myPreviewMode ) {
3548 pydump << mesh << " = " << this << ".TranslateObjectMakeMesh( "
3549 << theObject << ", "
3550 << theVector << ", "
3551 << theCopyGroups << ", '"
3552 << theMeshName << "' )";
3557 if (!myPreviewMode && mesh_i)
3558 mesh_i->GetGroups();
3560 return mesh._retn();
3563 //=======================================================================
3566 //=======================================================================
3568 SMESH::ListOfGroups*
3569 SMESH_MeshEditor_i::rotate(TIDSortedElemSet & theElements,
3570 const SMESH::AxisStruct & theAxis,
3571 CORBA::Double theAngle,
3572 CORBA::Boolean theCopy,
3574 ::SMESH_Mesh* theTargetMesh)
3578 if ( theTargetMesh )
3581 gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
3582 gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
3585 aTrsf.SetRotation( gp_Ax1( P, V ), theAngle);
3587 TIDSortedElemSet copyElements;
3588 TIDSortedElemSet* workElements = &theElements;
3589 TPreviewMesh tmpMesh;
3590 SMESH_Mesh* mesh = myMesh;
3592 if ( myPreviewMode ) {
3593 tmpMesh.Copy( theElements, copyElements );
3594 if ( !theCopy && !theTargetMesh )
3596 TIDSortedElemSet elemsAround, elemsAroundCopy;
3597 getElementsAround( theElements, GetMeshDS(), elemsAround );
3598 tmpMesh.Copy( elemsAround, elemsAroundCopy);
3601 workElements = ©Elements;
3602 theMakeGroups = false;
3605 ::SMESH_MeshEditor anEditor( mesh );
3606 ::SMESH_MeshEditor::PGroupIDs groupIds =
3607 anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
3609 if(theCopy || myPreviewMode)
3610 storeResult(anEditor);
3612 if ( !myPreviewMode )
3614 if ( theTargetMesh )
3616 theTargetMesh->GetMeshDS()->Modified();
3620 myMesh->GetMeshDS()->Modified();
3621 myMesh->SetIsModified( true );
3625 return theMakeGroups ? getGroups(groupIds.get()) : 0;
3628 //=======================================================================
3631 //=======================================================================
3633 void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements,
3634 const SMESH::AxisStruct & theAxis,
3635 CORBA::Double theAngle,
3636 CORBA::Boolean theCopy)
3638 if (!myPreviewMode) {
3639 TPythonDump() << this << ".Rotate( "
3640 << theIDsOfElements << ", "
3642 << TVar( theAngle ) << ", "
3645 if (theIDsOfElements.length() > 0)
3647 TIDSortedElemSet elements;
3648 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3649 rotate(elements,theAxis,theAngle,theCopy,false);
3653 //=======================================================================
3654 //function : RotateObject
3656 //=======================================================================
3658 void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject,
3659 const SMESH::AxisStruct & theAxis,
3660 CORBA::Double theAngle,
3661 CORBA::Boolean theCopy)
3663 if ( !myPreviewMode ) {
3664 TPythonDump() << this << ".RotateObject( "
3665 << theObject << ", "
3667 << TVar( theAngle ) << ", "
3670 TIDSortedElemSet elements;
3671 bool emptyIfIsMesh = myPreviewMode ? false : true;
3672 if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
3673 rotate(elements,theAxis,theAngle,theCopy,false);
3676 //=======================================================================
3677 //function : RotateMakeGroups
3679 //=======================================================================
3681 SMESH::ListOfGroups*
3682 SMESH_MeshEditor_i::RotateMakeGroups(const SMESH::long_array& theIDsOfElements,
3683 const SMESH::AxisStruct& theAxis,
3684 CORBA::Double theAngle)
3686 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3688 SMESH::ListOfGroups * aGroups = 0;
3689 if (theIDsOfElements.length() > 0)
3691 TIDSortedElemSet elements;
3692 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3693 aGroups = rotate(elements,theAxis,theAngle,true,true);
3695 if (!myPreviewMode) {
3696 DumpGroupsList(aPythonDump, aGroups);
3697 aPythonDump << this << ".RotateMakeGroups( "
3698 << theIDsOfElements << ", "
3700 << TVar( theAngle ) << " )";
3705 //=======================================================================
3706 //function : RotateObjectMakeGroups
3708 //=======================================================================
3710 SMESH::ListOfGroups*
3711 SMESH_MeshEditor_i::RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
3712 const SMESH::AxisStruct& theAxis,
3713 CORBA::Double theAngle)
3715 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3717 SMESH::ListOfGroups * aGroups = 0;
3718 TIDSortedElemSet elements;
3719 if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3720 aGroups = rotate(elements, theAxis, theAngle, true, true);
3722 if (!myPreviewMode) {
3723 DumpGroupsList(aPythonDump, aGroups);
3724 aPythonDump << this << ".RotateObjectMakeGroups( "
3725 << theObject << ", "
3727 << TVar( theAngle ) << " )";
3732 //=======================================================================
3733 //function : RotateMakeMesh
3735 //=======================================================================
3737 SMESH::SMESH_Mesh_ptr
3738 SMESH_MeshEditor_i::RotateMakeMesh(const SMESH::long_array& theIDsOfElements,
3739 const SMESH::AxisStruct& theAxis,
3740 CORBA::Double theAngleInRadians,
3741 CORBA::Boolean theCopyGroups,
3742 const char* theMeshName)
3744 SMESH::SMESH_Mesh_var mesh;
3745 SMESH_Mesh_i* mesh_i;
3747 { // open new scope to dump "MakeMesh" command
3748 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3750 TPythonDump pydump; // to prevent dump at mesh creation
3752 mesh = makeMesh( theMeshName );
3753 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3755 if ( mesh_i && theIDsOfElements.length() > 0 )
3757 TIDSortedElemSet elements;
3758 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3759 rotate(elements, theAxis, theAngleInRadians,
3760 false, theCopyGroups, & mesh_i->GetImpl());
3761 mesh_i->CreateGroupServants();
3763 if ( !myPreviewMode ) {
3764 pydump << mesh << " = " << this << ".RotateMakeMesh( "
3765 << theIDsOfElements << ", "
3767 << TVar( theAngleInRadians ) << ", "
3768 << theCopyGroups << ", '"
3769 << theMeshName << "' )";
3774 if (!myPreviewMode && mesh_i && theIDsOfElements.length() > 0 )
3775 mesh_i->GetGroups();
3777 return mesh._retn();
3780 //=======================================================================
3781 //function : RotateObjectMakeMesh
3783 //=======================================================================
3785 SMESH::SMESH_Mesh_ptr
3786 SMESH_MeshEditor_i::RotateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
3787 const SMESH::AxisStruct& theAxis,
3788 CORBA::Double theAngleInRadians,
3789 CORBA::Boolean theCopyGroups,
3790 const char* theMeshName)
3792 SMESH::SMESH_Mesh_var mesh;
3793 SMESH_Mesh_i* mesh_i;
3795 {// open new scope to dump "MakeMesh" command
3796 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3798 TPythonDump pydump; // to prevent dump at mesh creation
3799 mesh = makeMesh( theMeshName );
3800 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3802 TIDSortedElemSet elements;
3804 idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3806 rotate(elements, theAxis, theAngleInRadians,
3807 false, theCopyGroups, & mesh_i->GetImpl());
3808 mesh_i->CreateGroupServants();
3810 if ( !myPreviewMode ) {
3811 pydump << mesh << " = " << this << ".RotateObjectMakeMesh( "
3812 << theObject << ", "
3814 << TVar( theAngleInRadians ) << ", "
3815 << theCopyGroups << ", '"
3816 << theMeshName << "' )";
3821 if (!myPreviewMode && mesh_i)
3822 mesh_i->GetGroups();
3824 return mesh._retn();
3827 //=======================================================================
3830 //=======================================================================
3832 SMESH::ListOfGroups*
3833 SMESH_MeshEditor_i::scale(SMESH::SMESH_IDSource_ptr theObject,
3834 const SMESH::PointStruct& thePoint,
3835 const SMESH::double_array& theScaleFact,
3836 CORBA::Boolean theCopy,
3838 ::SMESH_Mesh* theTargetMesh)
3841 if ( theScaleFact.length() < 1 )
3842 THROW_SALOME_CORBA_EXCEPTION("Scale factor not given", SALOME::BAD_PARAM);
3843 if ( theScaleFact.length() == 2 )
3844 THROW_SALOME_CORBA_EXCEPTION("Invalid nb of scale factors : 2", SALOME::BAD_PARAM);
3846 if ( theTargetMesh )
3849 TIDSortedElemSet elements;
3850 bool emptyIfIsMesh = myPreviewMode ? false : true;
3851 if ( !idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
3856 (theScaleFact.length() == 1) ? theScaleFact[0] : theScaleFact[1],
3857 (theScaleFact.length() == 1) ? theScaleFact[0] : theScaleFact[2],
3859 double tol = std::numeric_limits<double>::max();
3861 aTrsf.SetValues( S[0], 0, 0, thePoint.x * (1-S[0]),
3862 0, S[1], 0, thePoint.y * (1-S[1]),
3863 0, 0, S[2], thePoint.z * (1-S[2]), tol, tol);
3865 TIDSortedElemSet copyElements;
3866 TPreviewMesh tmpMesh;
3867 TIDSortedElemSet* workElements = &elements;
3868 SMESH_Mesh* mesh = myMesh;
3870 if ( myPreviewMode )
3872 tmpMesh.Copy( elements, copyElements);
3873 if ( !theCopy && !theTargetMesh )
3875 TIDSortedElemSet elemsAround, elemsAroundCopy;
3876 getElementsAround( elements, GetMeshDS(), elemsAround );
3877 tmpMesh.Copy( elemsAround, elemsAroundCopy);
3880 workElements = & copyElements;
3881 theMakeGroups = false;
3884 ::SMESH_MeshEditor anEditor( mesh );
3885 ::SMESH_MeshEditor::PGroupIDs groupIds =
3886 anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
3888 if(theCopy || myPreviewMode )
3889 storeResult(anEditor);
3891 if ( !myPreviewMode )
3893 if ( theTargetMesh )
3895 theTargetMesh->GetMeshDS()->Modified();
3899 myMesh->GetMeshDS()->Modified();
3900 myMesh->SetIsModified( true );
3904 return theMakeGroups ? getGroups(groupIds.get()) : 0;
3907 //=======================================================================
3910 //=======================================================================
3912 void SMESH_MeshEditor_i::Scale(SMESH::SMESH_IDSource_ptr theObject,
3913 const SMESH::PointStruct& thePoint,
3914 const SMESH::double_array& theScaleFact,
3915 CORBA::Boolean theCopy)
3917 if ( !myPreviewMode ) {
3918 TPythonDump() << this << ".Scale( "
3919 << theObject << ", "
3921 << TVar( theScaleFact ) << ", "
3924 scale(theObject, thePoint, theScaleFact, theCopy, false);
3928 //=======================================================================
3929 //function : ScaleMakeGroups
3931 //=======================================================================
3933 SMESH::ListOfGroups*
3934 SMESH_MeshEditor_i::ScaleMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
3935 const SMESH::PointStruct& thePoint,
3936 const SMESH::double_array& theScaleFact)
3938 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3940 SMESH::ListOfGroups * aGroups = scale(theObject, thePoint, theScaleFact, true, true);
3941 if (!myPreviewMode) {
3942 DumpGroupsList(aPythonDump, aGroups);
3943 aPythonDump << this << ".Scale("
3946 << TVar( 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 << ", "
3982 << TVar( theScaleFact ) << ", "
3983 << theCopyGroups << ", '"
3984 << theMeshName << "' )";
3988 if (!myPreviewMode && mesh_i)
3989 mesh_i->GetGroups();
3991 return mesh._retn();
3995 //=======================================================================
3996 //function : FindCoincidentNodes
3998 //=======================================================================
4000 void SMESH_MeshEditor_i::FindCoincidentNodes (CORBA::Double Tolerance,
4001 SMESH::array_of_long_array_out GroupsOfNodes)
4005 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
4006 ::SMESH_MeshEditor anEditor( myMesh );
4007 TIDSortedNodeSet nodes; // no input nodes
4008 anEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
4010 GroupsOfNodes = new SMESH::array_of_long_array;
4011 GroupsOfNodes->length( aListOfListOfNodes.size() );
4012 ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
4013 for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ ) {
4014 list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
4015 list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
4016 SMESH::long_array& aGroup = (*GroupsOfNodes)[ i ];
4017 aGroup.length( aListOfNodes.size() );
4018 for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
4019 aGroup[ j ] = (*lIt)->GetID();
4021 TPythonDump() << "coincident_nodes = " << this << ".FindCoincidentNodes( "
4022 << Tolerance << " )";
4025 //=======================================================================
4026 //function : FindCoincidentNodesOnPart
4028 //=======================================================================
4029 void SMESH_MeshEditor_i::FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr theObject,
4030 CORBA::Double Tolerance,
4031 SMESH::array_of_long_array_out GroupsOfNodes)
4035 TIDSortedNodeSet nodes;
4036 idSourceToNodeSet( theObject, GetMeshDS(), nodes );
4038 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
4039 ::SMESH_MeshEditor anEditor( myMesh );
4041 anEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
4043 GroupsOfNodes = new SMESH::array_of_long_array;
4044 GroupsOfNodes->length( aListOfListOfNodes.size() );
4045 ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
4046 for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ )
4048 list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
4049 list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
4050 SMESH::long_array& aGroup = (*GroupsOfNodes)[ i ];
4051 aGroup.length( aListOfNodes.size() );
4052 for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
4053 aGroup[ j ] = (*lIt)->GetID();
4055 TPythonDump() << "coincident_nodes_on_part = " << this << ".FindCoincidentNodesOnPart( "
4057 << Tolerance << " )";
4060 //================================================================================
4062 * \brief Finds nodes coinsident with Tolerance within Object excluding nodes within
4063 * ExceptSubMeshOrGroups
4065 //================================================================================
4067 void SMESH_MeshEditor_i::
4068 FindCoincidentNodesOnPartBut(SMESH::SMESH_IDSource_ptr theObject,
4069 CORBA::Double theTolerance,
4070 SMESH::array_of_long_array_out theGroupsOfNodes,
4071 const SMESH::ListOfIDSources& theExceptSubMeshOrGroups)
4075 TIDSortedNodeSet nodes;
4076 idSourceToNodeSet( theObject, GetMeshDS(), nodes );
4078 for ( int i = 0; i < theExceptSubMeshOrGroups.length(); ++i )
4080 TIDSortedNodeSet exceptNodes;
4081 idSourceToNodeSet( theExceptSubMeshOrGroups[i], GetMeshDS(), exceptNodes );
4082 TIDSortedNodeSet::iterator avoidNode = exceptNodes.begin();
4083 for ( ; avoidNode != exceptNodes.end(); ++avoidNode)
4084 nodes.erase( *avoidNode );
4086 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
4087 ::SMESH_MeshEditor anEditor( myMesh );
4089 anEditor.FindCoincidentNodes( nodes, theTolerance, aListOfListOfNodes );
4091 theGroupsOfNodes = new SMESH::array_of_long_array;
4092 theGroupsOfNodes->length( aListOfListOfNodes.size() );
4093 ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
4094 for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ )
4096 list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
4097 list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
4098 SMESH::long_array& aGroup = (*theGroupsOfNodes)[ i ];
4099 aGroup.length( aListOfNodes.size() );
4100 for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
4101 aGroup[ j ] = (*lIt)->GetID();
4103 TPythonDump() << "coincident_nodes_on_part = " << this << ".FindCoincidentNodesOnPartBut( "
4105 << theTolerance << ", "
4106 << theExceptSubMeshOrGroups << " )";
4109 //=======================================================================
4110 //function : MergeNodes
4112 //=======================================================================
4114 void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes)
4118 SMESHDS_Mesh* aMesh = GetMeshDS();
4120 TPythonDump aTPythonDump;
4121 aTPythonDump << this << ".MergeNodes([";
4122 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
4123 for (int i = 0; i < GroupsOfNodes.length(); i++)
4125 const SMESH::long_array& aNodeGroup = GroupsOfNodes[ i ];
4126 aListOfListOfNodes.push_back( list< const SMDS_MeshNode* >() );
4127 list< const SMDS_MeshNode* >& aListOfNodes = aListOfListOfNodes.back();
4128 for ( int j = 0; j < aNodeGroup.length(); j++ )
4130 CORBA::Long index = aNodeGroup[ j ];
4131 const SMDS_MeshNode * node = aMesh->FindNode(index);
4133 aListOfNodes.push_back( node );
4135 if ( aListOfNodes.size() < 2 )
4136 aListOfListOfNodes.pop_back();
4138 if ( i > 0 ) aTPythonDump << ", ";
4139 aTPythonDump << aNodeGroup;
4141 ::SMESH_MeshEditor anEditor( myMesh );
4142 anEditor.MergeNodes( aListOfListOfNodes );
4144 aTPythonDump << "])";
4145 myMesh->GetMeshDS()->Modified();
4146 myMesh->SetIsModified( true );
4149 //=======================================================================
4150 //function : FindEqualElements
4152 //=======================================================================
4153 void SMESH_MeshEditor_i::FindEqualElements(SMESH::SMESH_IDSource_ptr theObject,
4154 SMESH::array_of_long_array_out GroupsOfElementsID)
4158 SMESH::SMESH_GroupBase_var group = SMESH::SMESH_GroupBase::_narrow(theObject);
4159 if ( !(!group->_is_nil() && group->GetType() == SMESH::NODE) )
4161 typedef list<int> TListOfIDs;
4162 set<const SMDS_MeshElement*> elems;
4163 SMESH::long_array_var aElementsId = theObject->GetIDs();
4164 SMESHDS_Mesh* aMesh = GetMeshDS();
4166 for(int i = 0; i < aElementsId->length(); i++) {
4167 CORBA::Long anID = aElementsId[i];
4168 const SMDS_MeshElement * elem = aMesh->FindElement(anID);
4174 ::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
4175 ::SMESH_MeshEditor anEditor( myMesh );
4176 anEditor.FindEqualElements( elems, aListOfListOfElementsID );
4178 GroupsOfElementsID = new SMESH::array_of_long_array;
4179 GroupsOfElementsID->length( aListOfListOfElementsID.size() );
4181 ::SMESH_MeshEditor::TListOfListOfElementsID::iterator arraysIt = aListOfListOfElementsID.begin();
4182 for (CORBA::Long j = 0; arraysIt != aListOfListOfElementsID.end(); ++arraysIt, ++j) {
4183 SMESH::long_array& aGroup = (*GroupsOfElementsID)[ j ];
4184 TListOfIDs& listOfIDs = *arraysIt;
4185 aGroup.length( listOfIDs.size() );
4186 TListOfIDs::iterator idIt = listOfIDs.begin();
4187 for (int k = 0; idIt != listOfIDs.end(); ++idIt, ++k ) {
4188 aGroup[ k ] = *idIt;
4192 TPythonDump() << "equal_elements = " << this << ".FindEqualElements( "
4197 //=======================================================================
4198 //function : MergeElements
4200 //=======================================================================
4202 void SMESH_MeshEditor_i::MergeElements(const SMESH::array_of_long_array& GroupsOfElementsID)
4206 TPythonDump aTPythonDump;
4207 aTPythonDump << this << ".MergeElements( [";
4209 ::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
4211 for (int i = 0; i < GroupsOfElementsID.length(); i++) {
4212 const SMESH::long_array& anElemsIDGroup = GroupsOfElementsID[ i ];
4213 aListOfListOfElementsID.push_back( list< int >() );
4214 list< int >& aListOfElemsID = aListOfListOfElementsID.back();
4215 for ( int j = 0; j < anElemsIDGroup.length(); j++ ) {
4216 CORBA::Long id = anElemsIDGroup[ j ];
4217 aListOfElemsID.push_back( id );
4219 if ( aListOfElemsID.size() < 2 )
4220 aListOfListOfElementsID.pop_back();
4221 if ( i > 0 ) aTPythonDump << ", ";
4222 aTPythonDump << anElemsIDGroup;
4225 ::SMESH_MeshEditor anEditor( myMesh );
4226 anEditor.MergeElements(aListOfListOfElementsID);
4227 myMesh->GetMeshDS()->Modified();
4228 myMesh->SetIsModified( true );
4230 aTPythonDump << "] )";
4233 //=======================================================================
4234 //function : MergeEqualElements
4236 //=======================================================================
4238 void SMESH_MeshEditor_i::MergeEqualElements()
4242 ::SMESH_MeshEditor anEditor( myMesh );
4243 anEditor.MergeEqualElements();
4245 myMesh->GetMeshDS()->Modified();
4247 TPythonDump() << this << ".MergeEqualElements()";
4250 //=============================================================================
4252 * Move the node to a given point
4254 //=============================================================================
4256 CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long NodeID,
4261 initData(/*deleteSearchers=*/false);
4263 const SMDS_MeshNode * node = GetMeshDS()->FindNode( NodeID );
4267 if ( theNodeSearcher )
4268 theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
4270 if ( myPreviewMode ) // make preview data
4272 // in a preview mesh, make edges linked to a node
4273 TPreviewMesh tmpMesh;
4274 TIDSortedElemSet linkedNodes;
4275 ::SMESH_MeshEditor::GetLinkedNodes( node, linkedNodes );
4276 TIDSortedElemSet::iterator nIt = linkedNodes.begin();
4277 SMDS_MeshNode *nodeCpy1 = tmpMesh.Copy(node);
4278 for ( ; nIt != linkedNodes.end(); ++nIt )
4280 SMDS_MeshNode *nodeCpy2 = tmpMesh.Copy ( cast2Node( *nIt ));
4281 tmpMesh.GetMeshDS()->AddEdge(nodeCpy1, nodeCpy2);
4285 tmpMesh.GetMeshDS()->MoveNode(nodeCpy1, x, y, z);
4286 // fill preview data
4287 ::SMESH_MeshEditor anEditor( & tmpMesh );
4288 storeResult( anEditor );
4290 else if ( theNodeSearcher ) // move node and update theNodeSearcher data accordingly
4291 theNodeSearcher->MoveNode(node, gp_Pnt( x,y,z ));
4293 GetMeshDS()->MoveNode(node, x, y, z);
4295 if ( !myPreviewMode )
4297 // Update Python script
4298 TPythonDump() << "isDone = " << this << ".MoveNode( "
4299 << NodeID << ", " << TVar(x) << ", " << TVar(y) << ", " << TVar(z) << " )";
4300 myMesh->GetMeshDS()->Modified();
4301 myMesh->SetIsModified( true );
4307 //================================================================================
4309 * \brief Return ID of node closest to a given point
4311 //================================================================================
4313 CORBA::Long SMESH_MeshEditor_i::FindNodeClosestTo(CORBA::Double x,
4317 theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
4319 if ( !theNodeSearcher ) {
4320 ::SMESH_MeshEditor anEditor( myMesh );
4321 theNodeSearcher = anEditor.GetNodeSearcher();
4324 if ( const SMDS_MeshNode* node = theNodeSearcher->FindClosestTo( p ))
4325 return node->GetID();
4330 //================================================================================
4332 * \brief If the given ID is a valid node ID (nodeID > 0), just move this node, else
4333 * move the node closest to the point to point's location and return ID of the node
4335 //================================================================================
4337 CORBA::Long SMESH_MeshEditor_i::MoveClosestNodeToPoint(CORBA::Double x,
4340 CORBA::Long theNodeID)
4342 // We keep theNodeSearcher until any mesh modification:
4343 // 1) initData() deletes theNodeSearcher at any edition,
4344 // 2) TSearchersDeleter - at any mesh compute event and mesh change
4346 initData(/*deleteSearchers=*/false);
4348 theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
4350 int nodeID = theNodeID;
4351 const SMDS_MeshNode* node = GetMeshDS()->FindNode( nodeID );
4352 if ( !node ) // preview moving node
4354 if ( !theNodeSearcher ) {
4355 ::SMESH_MeshEditor anEditor( myMesh );
4356 theNodeSearcher = anEditor.GetNodeSearcher();
4359 node = theNodeSearcher->FindClosestTo( p );
4362 nodeID = node->GetID();
4363 if ( myPreviewMode ) // make preview data
4365 // in a preview mesh, make edges linked to a node
4366 TPreviewMesh tmpMesh;
4367 TIDSortedElemSet linkedNodes;
4368 ::SMESH_MeshEditor::GetLinkedNodes( node, linkedNodes );
4369 TIDSortedElemSet::iterator nIt = linkedNodes.begin();
4370 for ( ; nIt != linkedNodes.end(); ++nIt )
4372 SMDS_LinearEdge edge( node, cast2Node( *nIt ));
4373 tmpMesh.Copy( &edge );
4376 node = tmpMesh.GetMeshDS()->FindNode( nodeID );
4378 tmpMesh.GetMeshDS()->MoveNode(node, x, y, z);
4379 // fill preview data
4380 ::SMESH_MeshEditor anEditor( & tmpMesh );
4381 storeResult( anEditor );
4383 else if ( theNodeSearcher ) // move node and update theNodeSearcher data accordingly
4385 theNodeSearcher->MoveNode(node, gp_Pnt( x,y,z ));
4389 GetMeshDS()->MoveNode(node, x, y, z);
4393 if ( !myPreviewMode )
4395 TPythonDump() << "nodeID = " << this
4396 << ".MoveClosestNodeToPoint( "<< x << ", " << y << ", " << z
4397 << ", " << nodeID << " )";
4399 myMesh->GetMeshDS()->Modified();
4400 myMesh->SetIsModified( true );
4406 //=======================================================================
4408 * Return elements of given type where the given point is IN or ON.
4410 * 'ALL' type means elements of any type excluding nodes
4412 //=======================================================================
4414 SMESH::long_array* SMESH_MeshEditor_i::FindElementsByPoint(CORBA::Double x,
4417 SMESH::ElementType type)
4419 SMESH::long_array_var res = new SMESH::long_array;
4420 vector< const SMDS_MeshElement* > foundElems;
4422 theSearchersDeleter.Set( myMesh );
4423 if ( !theElementSearcher ) {
4424 ::SMESH_MeshEditor anEditor( myMesh );
4425 theElementSearcher = anEditor.GetElementSearcher();
4427 theElementSearcher->FindElementsByPoint( gp_Pnt( x,y,z ),
4428 SMDSAbs_ElementType( type ),
4430 res->length( foundElems.size() );
4431 for ( int i = 0; i < foundElems.size(); ++i )
4432 res[i] = foundElems[i]->GetID();
4434 if ( !myPreviewMode ) // call from tui
4435 TPythonDump() << "res = " << this << ".FindElementsByPoint( "
4444 //=======================================================================
4445 //function : FindAmongElementsByPoint
4446 //purpose : Searching among the given elements, return elements of given type
4447 // where the given point is IN or ON.
4448 // 'ALL' type means elements of any type excluding nodes
4449 //=======================================================================
4452 SMESH_MeshEditor_i::FindAmongElementsByPoint(SMESH::SMESH_IDSource_ptr elementIDs,
4456 SMESH::ElementType type)
4458 SMESH::long_array_var res = new SMESH::long_array;
4460 SMESH::array_of_ElementType_var types = elementIDs->GetTypes();
4461 if ( types->length() == 1 && // a part contains only nodes or 0D elements
4462 ( types[0] == SMESH::NODE || types[0] == SMESH::ELEM0D ) &&
4463 type != types[0] ) // but search of elements of dim > 0
4466 if ( SMESH::DownCast<SMESH_Mesh_i*>( elementIDs )) // elementIDs is the whole mesh
4467 return FindElementsByPoint( x,y,z, type );
4469 string partIOR = SMESH_Gen_i::GetORB()->object_to_string( elementIDs );
4470 if ( SMESH_Group_i* group_i = SMESH::DownCast<SMESH_Group_i*>( elementIDs ))
4471 // take into account passible group modification
4472 partIOR += SMESH_Comment( ((SMESHDS_Group*)group_i->GetGroupDS())->SMDSGroup().Tic() );
4473 partIOR += SMESH_Comment( type );
4475 TIDSortedElemSet elements; // elems should live until FindElementsByPoint() finishes
4477 theSearchersDeleter.Set( myMesh, partIOR );
4478 if ( !theElementSearcher )
4480 // create a searcher from elementIDs
4481 SMESH::SMESH_Mesh_var mesh = elementIDs->GetMesh();
4482 SMESHDS_Mesh* meshDS = SMESH::DownCast<SMESH_Mesh_i*>( mesh )->GetImpl().GetMeshDS();
4484 if ( !idSourceToSet( elementIDs, meshDS, elements,
4485 SMDSAbs_ElementType(type), /*emptyIfIsMesh=*/true))
4488 typedef SMDS_SetIterator<const SMDS_MeshElement*, TIDSortedElemSet::const_iterator > TIter;
4489 SMDS_ElemIteratorPtr elemsIt( new TIter( elements.begin(), elements.end() ));
4491 ::SMESH_MeshEditor anEditor( myMesh );
4492 theElementSearcher = anEditor.GetElementSearcher(elemsIt);
4495 vector< const SMDS_MeshElement* > foundElems;
4497 theElementSearcher->FindElementsByPoint( gp_Pnt( x,y,z ),
4498 SMDSAbs_ElementType( type ),
4500 res->length( foundElems.size() );
4501 for ( int i = 0; i < foundElems.size(); ++i )
4502 res[i] = foundElems[i]->GetID();
4504 if ( !myPreviewMode ) // call from tui
4505 TPythonDump() << "res = " << this << ".FindAmongElementsByPoint( "
4506 << elementIDs << ", "
4515 //=======================================================================
4516 //function : GetPointState
4517 //purpose : Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
4518 // TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
4519 //=======================================================================
4521 CORBA::Short SMESH_MeshEditor_i::GetPointState(CORBA::Double x,
4525 theSearchersDeleter.Set( myMesh );
4526 if ( !theElementSearcher ) {
4527 ::SMESH_MeshEditor anEditor( myMesh );
4528 theElementSearcher = anEditor.GetElementSearcher();
4530 return CORBA::Short( theElementSearcher->GetPointState( gp_Pnt( x,y,z )));
4533 //=======================================================================
4534 //function : convError
4536 //=======================================================================
4538 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
4540 static SMESH::SMESH_MeshEditor::Sew_Error convError( const::SMESH_MeshEditor::Sew_Error e )
4544 RETCASE( SEW_BORDER1_NOT_FOUND );
4545 RETCASE( SEW_BORDER2_NOT_FOUND );
4546 RETCASE( SEW_BOTH_BORDERS_NOT_FOUND );
4547 RETCASE( SEW_BAD_SIDE_NODES );
4548 RETCASE( SEW_VOLUMES_TO_SPLIT );
4549 RETCASE( SEW_DIFF_NB_OF_ELEMENTS );
4550 RETCASE( SEW_TOPO_DIFF_SETS_OF_ELEMENTS );
4551 RETCASE( SEW_BAD_SIDE1_NODES );
4552 RETCASE( SEW_BAD_SIDE2_NODES );
4554 return SMESH::SMESH_MeshEditor::SEW_OK;
4557 //=======================================================================
4558 //function : SewFreeBorders
4560 //=======================================================================
4562 SMESH::SMESH_MeshEditor::Sew_Error
4563 SMESH_MeshEditor_i::SewFreeBorders(CORBA::Long FirstNodeID1,
4564 CORBA::Long SecondNodeID1,
4565 CORBA::Long LastNodeID1,
4566 CORBA::Long FirstNodeID2,
4567 CORBA::Long SecondNodeID2,
4568 CORBA::Long LastNodeID2,
4569 CORBA::Boolean CreatePolygons,
4570 CORBA::Boolean CreatePolyedrs)
4574 SMESHDS_Mesh* aMesh = GetMeshDS();
4576 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
4577 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
4578 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
4579 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
4580 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
4581 const SMDS_MeshNode* aSide2ThirdNode = aMesh->FindNode( LastNodeID2 );
4583 if (!aBorderFirstNode ||
4584 !aBorderSecondNode||
4586 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
4587 if (!aSide2FirstNode ||
4588 !aSide2SecondNode ||
4590 return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
4592 TPythonDump() << "error = " << this << ".SewFreeBorders( "
4593 << FirstNodeID1 << ", "
4594 << SecondNodeID1 << ", "
4595 << LastNodeID1 << ", "
4596 << FirstNodeID2 << ", "
4597 << SecondNodeID2 << ", "
4598 << LastNodeID2 << ", "
4599 << CreatePolygons<< ", "
4600 << CreatePolyedrs<< " )";
4602 ::SMESH_MeshEditor anEditor( myMesh );
4603 SMESH::SMESH_MeshEditor::Sew_Error error =
4604 convError( anEditor.SewFreeBorder (aBorderFirstNode,
4614 storeResult(anEditor);
4616 myMesh->GetMeshDS()->Modified();
4617 myMesh->SetIsModified( true );
4623 //=======================================================================
4624 //function : SewConformFreeBorders
4626 //=======================================================================
4628 SMESH::SMESH_MeshEditor::Sew_Error
4629 SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1,
4630 CORBA::Long SecondNodeID1,
4631 CORBA::Long LastNodeID1,
4632 CORBA::Long FirstNodeID2,
4633 CORBA::Long SecondNodeID2)
4637 SMESHDS_Mesh* aMesh = GetMeshDS();
4639 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
4640 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
4641 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
4642 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
4643 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
4644 const SMDS_MeshNode* aSide2ThirdNode = 0;
4646 if (!aBorderFirstNode ||
4647 !aBorderSecondNode||
4649 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
4650 if (!aSide2FirstNode ||
4652 return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
4654 TPythonDump() << "error = " << this << ".SewConformFreeBorders( "
4655 << FirstNodeID1 << ", "
4656 << SecondNodeID1 << ", "
4657 << LastNodeID1 << ", "
4658 << FirstNodeID2 << ", "
4659 << SecondNodeID2 << " )";
4661 ::SMESH_MeshEditor anEditor( myMesh );
4662 SMESH::SMESH_MeshEditor::Sew_Error error =
4663 convError( anEditor.SewFreeBorder (aBorderFirstNode,
4672 storeResult(anEditor);
4674 myMesh->GetMeshDS()->Modified();
4675 myMesh->SetIsModified( true );
4681 //=======================================================================
4682 //function : SewBorderToSide
4684 //=======================================================================
4686 SMESH::SMESH_MeshEditor::Sew_Error
4687 SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder,
4688 CORBA::Long SecondNodeIDOnFreeBorder,
4689 CORBA::Long LastNodeIDOnFreeBorder,
4690 CORBA::Long FirstNodeIDOnSide,
4691 CORBA::Long LastNodeIDOnSide,
4692 CORBA::Boolean CreatePolygons,
4693 CORBA::Boolean CreatePolyedrs)
4697 SMESHDS_Mesh* aMesh = GetMeshDS();
4699 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeIDOnFreeBorder );
4700 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeIDOnFreeBorder );
4701 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeIDOnFreeBorder );
4702 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeIDOnSide );
4703 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( LastNodeIDOnSide );
4704 const SMDS_MeshNode* aSide2ThirdNode = 0;
4706 if (!aBorderFirstNode ||
4707 !aBorderSecondNode||
4709 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
4710 if (!aSide2FirstNode ||
4712 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE_NODES;
4714 TPythonDump() << "error = " << this << ".SewBorderToSide( "
4715 << FirstNodeIDOnFreeBorder << ", "
4716 << SecondNodeIDOnFreeBorder << ", "
4717 << LastNodeIDOnFreeBorder << ", "
4718 << FirstNodeIDOnSide << ", "
4719 << LastNodeIDOnSide << ", "
4720 << CreatePolygons << ", "
4721 << CreatePolyedrs << ") ";
4723 ::SMESH_MeshEditor anEditor( myMesh );
4724 SMESH::SMESH_MeshEditor::Sew_Error error =
4725 convError( anEditor.SewFreeBorder (aBorderFirstNode,
4735 storeResult(anEditor);
4737 myMesh->GetMeshDS()->Modified();
4738 myMesh->SetIsModified( true );
4744 //=======================================================================
4745 //function : SewSideElements
4747 //=======================================================================
4749 SMESH::SMESH_MeshEditor::Sew_Error
4750 SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements,
4751 const SMESH::long_array& IDsOfSide2Elements,
4752 CORBA::Long NodeID1OfSide1ToMerge,
4753 CORBA::Long NodeID1OfSide2ToMerge,
4754 CORBA::Long NodeID2OfSide1ToMerge,
4755 CORBA::Long NodeID2OfSide2ToMerge)
4759 SMESHDS_Mesh* aMesh = GetMeshDS();
4761 const SMDS_MeshNode* aFirstNode1ToMerge = aMesh->FindNode( NodeID1OfSide1ToMerge );
4762 const SMDS_MeshNode* aFirstNode2ToMerge = aMesh->FindNode( NodeID1OfSide2ToMerge );
4763 const SMDS_MeshNode* aSecondNode1ToMerge = aMesh->FindNode( NodeID2OfSide1ToMerge );
4764 const SMDS_MeshNode* aSecondNode2ToMerge = aMesh->FindNode( NodeID2OfSide2ToMerge );
4766 if (!aFirstNode1ToMerge ||
4767 !aFirstNode2ToMerge )
4768 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE1_NODES;
4769 if (!aSecondNode1ToMerge||
4770 !aSecondNode2ToMerge)
4771 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE2_NODES;
4773 TIDSortedElemSet aSide1Elems, aSide2Elems;
4774 arrayToSet(IDsOfSide1Elements, aMesh, aSide1Elems);
4775 arrayToSet(IDsOfSide2Elements, aMesh, aSide2Elems);
4777 TPythonDump() << "error = " << this << ".SewSideElements( "
4778 << IDsOfSide1Elements << ", "
4779 << IDsOfSide2Elements << ", "
4780 << NodeID1OfSide1ToMerge << ", "
4781 << NodeID1OfSide2ToMerge << ", "
4782 << NodeID2OfSide1ToMerge << ", "
4783 << NodeID2OfSide2ToMerge << ")";
4785 ::SMESH_MeshEditor anEditor( myMesh );
4786 SMESH::SMESH_MeshEditor::Sew_Error error =
4787 convError( anEditor.SewSideElements (aSide1Elems, aSide2Elems,
4790 aSecondNode1ToMerge,
4791 aSecondNode2ToMerge));
4793 storeResult(anEditor);
4795 myMesh->GetMeshDS()->Modified();
4796 myMesh->SetIsModified( true );
4801 //================================================================================
4803 * \brief Set new nodes for given element
4804 * \param ide - element id
4805 * \param newIDs - new node ids
4806 * \retval CORBA::Boolean - true if result is OK
4808 //================================================================================
4810 CORBA::Boolean SMESH_MeshEditor_i::ChangeElemNodes(CORBA::Long ide,
4811 const SMESH::long_array& newIDs)
4815 const SMDS_MeshElement* elem = GetMeshDS()->FindElement(ide);
4816 if(!elem) return false;
4818 int nbn = newIDs.length();
4820 vector<const SMDS_MeshNode*> aNodes(nbn);
4823 const SMDS_MeshNode* aNode = GetMeshDS()->FindNode(newIDs[i]);
4826 aNodes[nbn1] = aNode;
4829 TPythonDump() << "isDone = " << this << ".ChangeElemNodes( "
4830 << ide << ", " << newIDs << " )";
4832 MESSAGE("ChangeElementNodes");
4833 bool res = GetMeshDS()->ChangeElementNodes( elem, & aNodes[0], nbn1+1 );
4835 myMesh->GetMeshDS()->Modified();
4837 myMesh->SetIsModified( true );
4842 //================================================================================
4844 * \brief Update myLastCreated* or myPreviewData
4845 * \param anEditor - it contains last modification results
4847 //================================================================================
4849 void SMESH_MeshEditor_i::storeResult(::SMESH_MeshEditor& anEditor)
4851 if ( myPreviewMode ) { // --- MeshPreviewStruct filling ---
4853 list<int> aNodesConnectivity;
4854 typedef map<int, int> TNodesMap;
4857 TPreviewMesh * aPreviewMesh = dynamic_cast< TPreviewMesh* >( anEditor.GetMesh() );
4858 SMDSAbs_ElementType previewType = aPreviewMesh->myPreviewType;
4860 SMESHDS_Mesh* aMeshDS = anEditor.GetMeshDS();
4861 int nbEdges = aMeshDS->NbEdges();
4862 int nbFaces = aMeshDS->NbFaces();
4863 int nbVolum = aMeshDS->NbVolumes();
4864 switch ( previewType ) {
4865 case SMDSAbs_Edge : nbFaces = nbVolum = 0; break;
4866 case SMDSAbs_Face : nbEdges = nbVolum = 0; break;
4867 case SMDSAbs_Volume: nbEdges = nbFaces = 0; break;
4870 myPreviewData->nodesXYZ.length(aMeshDS->NbNodes());
4871 myPreviewData->elementTypes.length(nbEdges + nbFaces + nbVolum);
4873 SMDS_ElemIteratorPtr itMeshElems = aMeshDS->elementsIterator();
4875 while ( itMeshElems->more() ) {
4876 const SMDS_MeshElement* aMeshElem = itMeshElems->next();
4877 if ( previewType != SMDSAbs_All && aMeshElem->GetType() != previewType )
4880 SMDS_ElemIteratorPtr itElemNodes = aMeshElem->nodesIterator();
4881 while ( itElemNodes->more() ) {
4882 const SMDS_MeshNode* aMeshNode =
4883 static_cast<const SMDS_MeshNode*>( itElemNodes->next() );
4884 int aNodeID = aMeshNode->GetID();
4885 TNodesMap::iterator anIter = nodesMap.find(aNodeID);
4886 if ( anIter == nodesMap.end() ) {
4887 // filling the nodes coordinates
4888 myPreviewData->nodesXYZ[j].x = aMeshNode->X();
4889 myPreviewData->nodesXYZ[j].y = aMeshNode->Y();
4890 myPreviewData->nodesXYZ[j].z = aMeshNode->Z();
4891 anIter = nodesMap.insert( make_pair(aNodeID, j) ).first;
4894 aNodesConnectivity.push_back(anIter->second);
4897 // filling the elements types
4898 SMDSAbs_ElementType aType;
4900 /*if (aMeshElem->GetType() == SMDSAbs_Volume) {
4901 aType = SMDSAbs_Node;
4905 aType = aMeshElem->GetType();
4906 isPoly = aMeshElem->IsPoly();
4909 myPreviewData->elementTypes[i].SMDS_ElementType = (SMESH::ElementType) aType;
4910 myPreviewData->elementTypes[i].isPoly = isPoly;
4911 myPreviewData->elementTypes[i].nbNodesInElement = aMeshElem->NbNodes();
4915 myPreviewData->nodesXYZ.length( j );
4917 // filling the elements connectivities
4918 list<int>::iterator aConnIter = aNodesConnectivity.begin();
4919 myPreviewData->elementConnectivities.length(aNodesConnectivity.size());
4920 for( int i = 0; aConnIter != aNodesConnectivity.end(); aConnIter++, i++ )
4921 myPreviewData->elementConnectivities[i] = *aConnIter;
4927 // append new nodes into myLastCreatedNodes
4928 const SMESH_SequenceOfElemPtr& aSeq = anEditor.GetLastCreatedNodes();
4929 int j = myLastCreatedNodes->length();
4930 int newLen = j + aSeq.Length();
4931 myLastCreatedNodes->length( newLen );
4932 for(int i=0; j<newLen; i++,j++)
4933 myLastCreatedNodes[j] = aSeq.Value(i+1)->GetID();
4936 // append new elements into myLastCreatedElems
4937 const SMESH_SequenceOfElemPtr& aSeq = anEditor.GetLastCreatedElems();
4938 int j = myLastCreatedElems->length();
4939 int newLen = j + aSeq.Length();
4940 myLastCreatedElems->length( newLen );
4941 for(int i=0; j<newLen; i++,j++)
4942 myLastCreatedElems[j] = aSeq.Value(i+1)->GetID();
4946 //================================================================================
4948 * Return data of mesh edition preview
4950 //================================================================================
4952 SMESH::MeshPreviewStruct* SMESH_MeshEditor_i::GetPreviewData()
4954 return myPreviewData._retn();
4957 //================================================================================
4959 * \brief Returns list of it's IDs of created nodes
4960 * \retval SMESH::long_array* - list of node ID
4962 //================================================================================
4964 SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedNodes()
4966 return myLastCreatedNodes._retn();
4969 //================================================================================
4971 * \brief Returns list of it's IDs of created elements
4972 * \retval SMESH::long_array* - list of elements' ID
4974 //================================================================================
4976 SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedElems()
4978 return myLastCreatedElems._retn();
4981 //=======================================================================
4982 //function : ConvertToQuadratic
4984 //=======================================================================
4986 void SMESH_MeshEditor_i::ConvertToQuadratic(CORBA::Boolean theForce3d)
4988 ::SMESH_MeshEditor anEditor( myMesh );
4989 anEditor.ConvertToQuadratic(theForce3d);
4990 TPythonDump() << this << ".ConvertToQuadratic( " << theForce3d << " )";
4991 myMesh->GetMeshDS()->Modified();
4992 myMesh->SetIsModified( true );
4995 //=======================================================================
4996 //function : ConvertFromQuadratic
4998 //=======================================================================
5000 CORBA::Boolean SMESH_MeshEditor_i::ConvertFromQuadratic()
5002 ::SMESH_MeshEditor anEditor( myMesh );
5003 CORBA::Boolean isDone = anEditor.ConvertFromQuadratic();
5004 TPythonDump() << this << ".ConvertFromQuadratic()";
5005 myMesh->GetMeshDS()->Modified();
5007 myMesh->SetIsModified( true );
5010 //================================================================================
5012 * \brief Makes a part of the mesh quadratic
5014 //================================================================================
5016 void SMESH_MeshEditor_i::ConvertToQuadraticObject(CORBA::Boolean theForce3d,
5017 SMESH::SMESH_IDSource_ptr theObject)
5018 throw (SALOME::SALOME_Exception)
5020 Unexpect aCatch(SALOME_SalomeException);
5022 TIDSortedElemSet elems;
5023 if ( idSourceToSet( theObject, GetMeshDS(), elems, SMDSAbs_All, /*emptyIfIsMesh=*/true ))
5025 if ( elems.empty() )
5027 ConvertToQuadratic( theForce3d );
5029 else if ( (*elems.begin())->GetType() == SMDSAbs_Node )
5031 THROW_SALOME_CORBA_EXCEPTION("Group of nodes is not allowed", SALOME::BAD_PARAM);
5035 ::SMESH_MeshEditor anEditor( myMesh );
5036 anEditor.ConvertToQuadratic(theForce3d, elems);
5039 myMesh->GetMeshDS()->Modified();
5040 myMesh->SetIsModified( true );
5042 pyDump << this << ".ConvertToQuadraticObject( "<<theForce3d<<", "<<theObject<<" )";
5045 //================================================================================
5047 * \brief Makes a part of the mesh linear
5049 //================================================================================
5051 void SMESH_MeshEditor_i::ConvertFromQuadraticObject(SMESH::SMESH_IDSource_ptr theObject)
5052 throw (SALOME::SALOME_Exception)
5054 Unexpect aCatch(SALOME_SalomeException);
5056 TIDSortedElemSet elems;
5057 if ( idSourceToSet( theObject, GetMeshDS(), elems, SMDSAbs_All, /*emptyIfIsMesh=*/true ))
5059 if ( elems.empty() )
5061 ConvertFromQuadratic();
5063 else if ( (*elems.begin())->GetType() == SMDSAbs_Node )
5065 THROW_SALOME_CORBA_EXCEPTION("Group of nodes is not allowed", SALOME::BAD_PARAM);
5069 ::SMESH_MeshEditor anEditor( myMesh );
5070 anEditor.ConvertFromQuadratic(elems);
5073 myMesh->GetMeshDS()->Modified();
5074 myMesh->SetIsModified( true );
5076 pyDump << this << ".ConvertFromQuadraticObject( "<<theObject<<" )";
5079 //=======================================================================
5080 //function : makeMesh
5081 //purpose : create a named imported mesh
5082 //=======================================================================
5084 SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::makeMesh(const char* theMeshName)
5086 SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen();
5087 SMESH::SMESH_Mesh_var mesh = gen->CreateEmptyMesh();
5088 SALOMEDS::Study_var study = gen->GetCurrentStudy();
5089 SALOMEDS::SObject_var meshSO = gen->ObjectToSObject( study, mesh );
5090 gen->SetName( meshSO, theMeshName, "Mesh" );
5091 gen->SetPixMap( meshSO, "ICON_SMESH_TREE_MESH_IMPORTED");
5093 return mesh._retn();
5096 //=======================================================================
5097 //function : DumpGroupsList
5099 //=======================================================================
5100 void SMESH_MeshEditor_i::DumpGroupsList(TPythonDump & theDumpPython,
5101 const SMESH::ListOfGroups * theGroupList)
5103 bool isDumpGroupList = theGroupList && theGroupList->length() > 0;
5104 if(isDumpGroupList) {
5105 theDumpPython << theGroupList << " = ";
5109 //================================================================================
5111 \brief Generates the unique group name.
5112 \param thePrefix name prefix
5115 //================================================================================
5116 string SMESH_MeshEditor_i::generateGroupName(const string& thePrefix)
5118 SMESH::ListOfGroups_var groups = myMesh_i->GetGroups();
5119 set<string> groupNames;
5121 // Get existing group names
5122 for (int i = 0, nbGroups = groups->length(); i < nbGroups; i++ ) {
5123 SMESH::SMESH_GroupBase_var aGroup = groups[i];
5124 if (CORBA::is_nil(aGroup))
5127 groupNames.insert(aGroup->GetName());
5131 string name = thePrefix;
5134 while (!groupNames.insert(name).second) {
5139 TCollection_AsciiString nbStr(index+1);
5140 name.resize( name.rfind('_')+1 );
5141 name += nbStr.ToCString();
5149 //================================================================================
5151 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5152 \param theNodes - identifiers of nodes to be doubled
5153 \param theModifiedElems - identifiers of elements to be updated by the new (doubled)
5154 nodes. If list of element identifiers is empty then nodes are doubled but
5155 they not assigned to elements
5156 \return TRUE if operation has been completed successfully, FALSE otherwise
5157 \sa DoubleNode(), DoubleNodeGroup(), DoubleNodeGroups()
5159 //================================================================================
5161 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodes( const SMESH::long_array& theNodes,
5162 const SMESH::long_array& theModifiedElems )
5166 ::SMESH_MeshEditor aMeshEditor( myMesh );
5167 list< int > aListOfNodes;
5169 for ( i = 0, n = theNodes.length(); i < n; i++ )
5170 aListOfNodes.push_back( theNodes[ i ] );
5172 list< int > aListOfElems;
5173 for ( i = 0, n = theModifiedElems.length(); i < n; i++ )
5174 aListOfElems.push_back( theModifiedElems[ i ] );
5176 bool aResult = aMeshEditor.DoubleNodes( aListOfNodes, aListOfElems );
5178 myMesh->GetMeshDS()->Modified();
5179 storeResult( aMeshEditor) ;
5181 myMesh->SetIsModified( true );
5183 // Update Python script
5184 TPythonDump() << this << ".DoubleNodes( " << theNodes << ", "<< theModifiedElems << " )";
5189 //================================================================================
5191 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5192 This method provided for convenience works as DoubleNodes() described above.
5193 \param theNodeId - identifier of node to be doubled.
5194 \param theModifiedElems - identifiers of elements to be updated.
5195 \return TRUE if operation has been completed successfully, FALSE otherwise
5196 \sa DoubleNodes(), DoubleNodeGroup(), DoubleNodeGroups()
5198 //================================================================================
5200 CORBA::Boolean SMESH_MeshEditor_i::DoubleNode( CORBA::Long theNodeId,
5201 const SMESH::long_array& theModifiedElems )
5203 SMESH::long_array_var aNodes = new SMESH::long_array;
5204 aNodes->length( 1 );
5205 aNodes[ 0 ] = theNodeId;
5207 TPythonDump pyDump; // suppress dump by the next line
5209 CORBA::Boolean done = DoubleNodes( aNodes, theModifiedElems );
5211 pyDump << this << ".DoubleNode( " << theNodeId << ", " << theModifiedElems << " )";
5216 //================================================================================
5218 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5219 This method provided for convenience works as DoubleNodes() described above.
5220 \param theNodes - group of nodes to be doubled.
5221 \param theModifiedElems - group of elements to be updated.
5222 \return TRUE if operation has been completed successfully, FALSE otherwise
5223 \sa DoubleNode(), DoubleNodes(), DoubleNodeGroups()
5225 //================================================================================
5227 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroup(SMESH::SMESH_GroupBase_ptr theNodes,
5228 SMESH::SMESH_GroupBase_ptr theModifiedElems )
5230 if ( CORBA::is_nil( theNodes ) && theNodes->GetType() != SMESH::NODE )
5233 SMESH::long_array_var aNodes = theNodes->GetListOfID();
5234 SMESH::long_array_var aModifiedElems;
5235 if ( !CORBA::is_nil( theModifiedElems ) )
5236 aModifiedElems = theModifiedElems->GetListOfID();
5239 aModifiedElems = new SMESH::long_array;
5240 aModifiedElems->length( 0 );
5243 TPythonDump pyDump; // suppress dump by the next line
5245 bool done = DoubleNodes( aNodes, aModifiedElems );
5247 pyDump << this << ".DoubleNodeGroup( " << theNodes << ", " << theModifiedElems << " )";
5253 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements.
5254 * Works as DoubleNodeGroup(), but returns a new group with newly created nodes.
5255 * \param theNodes - group of nodes to be doubled.
5256 * \param theModifiedElems - group of elements to be updated.
5257 * \return a new group with newly created nodes
5258 * \sa DoubleNodeGroup()
5260 SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeGroupNew( SMESH::SMESH_GroupBase_ptr theNodes,
5261 SMESH::SMESH_GroupBase_ptr theModifiedElems )
5263 if ( CORBA::is_nil( theNodes ) && theNodes->GetType() != SMESH::NODE )
5266 SMESH::SMESH_Group_var aNewGroup;
5269 SMESH::long_array_var aNodes = theNodes->GetListOfID();
5270 SMESH::long_array_var aModifiedElems;
5271 if ( !CORBA::is_nil( theModifiedElems ) )
5272 aModifiedElems = theModifiedElems->GetListOfID();
5274 aModifiedElems = new SMESH::long_array;
5275 aModifiedElems->length( 0 );
5278 TPythonDump pyDump; // suppress dump by the next line
5280 bool aResult = DoubleNodes( aNodes, aModifiedElems );
5284 // Create group with newly created nodes
5285 SMESH::long_array_var anIds = GetLastCreatedNodes();
5286 if (anIds->length() > 0) {
5287 string anUnindexedName (theNodes->GetName());
5288 string aNewName = generateGroupName(anUnindexedName + "_double");
5289 aNewGroup = myMesh_i->CreateGroup(SMESH::NODE, aNewName.c_str());
5290 aNewGroup->Add(anIds);
5294 pyDump << "createdNodes = " << this << ".DoubleNodeGroupNew( " << theNodes << ", "
5295 << theModifiedElems << " )";
5297 return aNewGroup._retn();
5300 //================================================================================
5302 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5303 This method provided for convenience works as DoubleNodes() described above.
5304 \param theNodes - list of groups of nodes to be doubled
5305 \param theModifiedElems - list of groups of elements to be updated.
5306 \return TRUE if operation has been completed successfully, FALSE otherwise
5307 \sa DoubleNode(), DoubleNodeGroup(), DoubleNodes()
5309 //================================================================================
5311 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroups(const SMESH::ListOfGroups& theNodes,
5312 const SMESH::ListOfGroups& theModifiedElems )
5316 ::SMESH_MeshEditor aMeshEditor( myMesh );
5318 std::list< int > aNodes;
5320 for ( i = 0, n = theNodes.length(); i < n; i++ )
5322 SMESH::SMESH_GroupBase_var aGrp = theNodes[ i ];
5323 if ( !CORBA::is_nil( aGrp ) && aGrp->GetType() == SMESH::NODE )
5325 SMESH::long_array_var aCurr = aGrp->GetListOfID();
5326 for ( j = 0, m = aCurr->length(); j < m; j++ )
5327 aNodes.push_back( aCurr[ j ] );
5331 std::list< int > anElems;
5332 for ( i = 0, n = theModifiedElems.length(); i < n; i++ )
5334 SMESH::SMESH_GroupBase_var aGrp = theModifiedElems[ i ];
5335 if ( !CORBA::is_nil( aGrp ) && aGrp->GetType() != SMESH::NODE )
5337 SMESH::long_array_var aCurr = aGrp->GetListOfID();
5338 for ( j = 0, m = aCurr->length(); j < m; j++ )
5339 anElems.push_back( aCurr[ j ] );
5343 bool aResult = aMeshEditor.DoubleNodes( aNodes, anElems );
5345 storeResult( aMeshEditor) ;
5347 myMesh->GetMeshDS()->Modified();
5349 myMesh->SetIsModified( true );
5352 TPythonDump() << this << ".DoubleNodeGroups( " << theNodes << ", " << theModifiedElems << " )";
5357 //================================================================================
5359 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements.
5360 * Works as DoubleNodeGroups(), but returns a new group with newly created nodes.
5361 * \param theNodes - group of nodes to be doubled.
5362 * \param theModifiedElems - group of elements to be updated.
5363 * \return a new group with newly created nodes
5364 * \sa DoubleNodeGroups()
5366 //================================================================================
5368 SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeGroupsNew( const SMESH::ListOfGroups& theNodes,
5369 const SMESH::ListOfGroups& theModifiedElems )
5371 SMESH::SMESH_Group_var aNewGroup;
5373 TPythonDump pyDump; // suppress dump by the next line
5375 bool aResult = DoubleNodeGroups( theNodes, theModifiedElems );
5379 // Create group with newly created nodes
5380 SMESH::long_array_var anIds = GetLastCreatedNodes();
5381 if (anIds->length() > 0) {
5382 string anUnindexedName (theNodes[0]->GetName());
5383 string aNewName = generateGroupName(anUnindexedName + "_double");
5384 aNewGroup = myMesh_i->CreateGroup(SMESH::NODE, aNewName.c_str());
5385 aNewGroup->Add(anIds);
5389 pyDump << "createdNodes = " << this << ".DoubleNodeGroupsNew( " << theNodes << ", "
5390 << theModifiedElems << " )";
5392 return aNewGroup._retn();
5396 //================================================================================
5398 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5399 \param theElems - the list of elements (edges or faces) to be replicated
5400 The nodes for duplication could be found from these elements
5401 \param theNodesNot - list of nodes to NOT replicate
5402 \param theAffectedElems - the list of elements (cells and edges) to which the
5403 replicated nodes should be associated to.
5404 \return TRUE if operation has been completed successfully, FALSE otherwise
5405 \sa DoubleNodeGroup(), DoubleNodeGroups()
5407 //================================================================================
5409 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElem( const SMESH::long_array& theElems,
5410 const SMESH::long_array& theNodesNot,
5411 const SMESH::long_array& theAffectedElems )
5416 ::SMESH_MeshEditor aMeshEditor( myMesh );
5418 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5419 TIDSortedElemSet anElems, aNodes, anAffected;
5420 arrayToSet(theElems, aMeshDS, anElems, SMDSAbs_All);
5421 arrayToSet(theNodesNot, aMeshDS, aNodes, SMDSAbs_Node);
5422 arrayToSet(theAffectedElems, aMeshDS, anAffected, SMDSAbs_All);
5424 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
5426 storeResult( aMeshEditor) ;
5428 myMesh->GetMeshDS()->Modified();
5430 myMesh->SetIsModified( true );
5432 // Update Python script
5433 TPythonDump() << this << ".DoubleNodeElem( " << theElems << ", "
5434 << theNodesNot << ", " << theAffectedElems << " )";
5438 //================================================================================
5440 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5441 \param theElems - the list of elements (edges or faces) to be replicated
5442 The nodes for duplication could be found from these elements
5443 \param theNodesNot - list of nodes to NOT replicate
5444 \param theShape - shape to detect affected elements (element which geometric center
5445 located on or inside shape).
5446 The replicated nodes should be associated to affected elements.
5447 \return TRUE if operation has been completed successfully, FALSE otherwise
5448 \sa DoubleNodeGroupInRegion(), DoubleNodeGroupsInRegion()
5450 //================================================================================
5452 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemInRegion ( const SMESH::long_array& theElems,
5453 const SMESH::long_array& theNodesNot,
5454 GEOM::GEOM_Object_ptr theShape )
5459 ::SMESH_MeshEditor aMeshEditor( myMesh );
5461 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5462 TIDSortedElemSet anElems, aNodes;
5463 arrayToSet(theElems, aMeshDS, anElems, SMDSAbs_All);
5464 arrayToSet(theNodesNot, aMeshDS, aNodes, SMDSAbs_Node);
5466 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape );
5467 bool aResult = aMeshEditor.DoubleNodesInRegion( anElems, aNodes, aShape );
5469 storeResult( aMeshEditor) ;
5471 myMesh->GetMeshDS()->Modified();
5473 myMesh->SetIsModified( true );
5475 // Update Python script
5476 TPythonDump() << "isDone = " << this << ".DoubleNodeElemInRegion( " << theElems << ", "
5477 << theNodesNot << ", " << theShape << " )";
5481 //================================================================================
5483 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5484 \param theElems - group of of elements (edges or faces) to be replicated
5485 \param theNodesNot - group of nodes not to replicated
5486 \param theAffectedElems - group of elements to which the replicated nodes
5487 should be associated to.
5488 \return TRUE if operation has been completed successfully, FALSE otherwise
5489 \sa DoubleNodes(), DoubleNodeGroups()
5491 //================================================================================
5493 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroup(SMESH::SMESH_GroupBase_ptr theElems,
5494 SMESH::SMESH_GroupBase_ptr theNodesNot,
5495 SMESH::SMESH_GroupBase_ptr theAffectedElems)
5497 if ( CORBA::is_nil( theElems ) && theElems->GetType() == SMESH::NODE )
5502 ::SMESH_MeshEditor aMeshEditor( myMesh );
5504 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5505 TIDSortedElemSet anElems, aNodes, anAffected;
5506 idSourceToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
5507 idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
5508 idSourceToSet( theAffectedElems, aMeshDS, anAffected, SMDSAbs_All );
5510 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
5512 storeResult( aMeshEditor) ;
5514 myMesh->GetMeshDS()->Modified();
5516 myMesh->SetIsModified( true );
5518 // Update Python script
5519 TPythonDump() << "isDone = " << this << ".DoubleNodeElemGroup( " << theElems << ", "
5520 << theNodesNot << ", " << theAffectedElems << " )";
5525 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5526 * Works as DoubleNodeElemGroup(), but returns a new group with newly created elements.
5527 * \param theElems - group of of elements (edges or faces) to be replicated
5528 * \param theNodesNot - group of nodes not to replicated
5529 * \param theAffectedElems - group of elements to which the replicated nodes
5530 * should be associated to.
5531 * \return a new group with newly created elements
5532 * \sa DoubleNodeElemGroup()
5534 SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeElemGroupNew(SMESH::SMESH_GroupBase_ptr theElems,
5535 SMESH::SMESH_GroupBase_ptr theNodesNot,
5536 SMESH::SMESH_GroupBase_ptr theAffectedElems)
5538 if ( CORBA::is_nil( theElems ) && theElems->GetType() == SMESH::NODE )
5541 SMESH::SMESH_Group_var aNewGroup;
5545 ::SMESH_MeshEditor aMeshEditor( myMesh );
5547 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5548 TIDSortedElemSet anElems, aNodes, anAffected;
5549 idSourceToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
5550 idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
5551 idSourceToSet( theAffectedElems, aMeshDS, anAffected, SMDSAbs_All );
5554 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
5556 storeResult( aMeshEditor) ;
5559 myMesh->SetIsModified( true );
5561 // Create group with newly created elements
5562 SMESH::long_array_var anIds = GetLastCreatedElems();
5563 if (anIds->length() > 0) {
5564 SMESH::ElementType aGroupType = myMesh_i->GetElementType(anIds[0], true);
5565 string anUnindexedName (theElems->GetName());
5566 string aNewName = generateGroupName(anUnindexedName + "_double");
5567 aNewGroup = myMesh_i->CreateGroup(aGroupType, aNewName.c_str());
5568 aNewGroup->Add(anIds);
5572 // Update Python script
5573 TPythonDump() << "createdElems = " << this << ".DoubleNodeElemGroupNew( " << theElems << ", "
5574 << theNodesNot << ", " << theAffectedElems << " )";
5575 return aNewGroup._retn();
5578 //================================================================================
5580 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5581 \param theElems - group of of elements (edges or faces) to be replicated
5582 \param theNodesNot - group of nodes not to replicated
5583 \param theShape - shape to detect affected elements (element which geometric center
5584 located on or inside shape).
5585 The replicated nodes should be associated to affected elements.
5586 \return TRUE if operation has been completed successfully, FALSE otherwise
5587 \sa DoubleNodesInRegion(), DoubleNodeGroupsInRegion()
5589 //================================================================================
5591 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroupInRegion(SMESH::SMESH_GroupBase_ptr theElems,
5592 SMESH::SMESH_GroupBase_ptr theNodesNot,
5593 GEOM::GEOM_Object_ptr theShape )
5596 if ( CORBA::is_nil( theElems ) && theElems->GetType() == SMESH::NODE )
5601 ::SMESH_MeshEditor aMeshEditor( myMesh );
5603 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5604 TIDSortedElemSet anElems, aNodes, anAffected;
5605 idSourceToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
5606 idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
5608 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape );
5609 bool aResult = aMeshEditor.DoubleNodesInRegion( anElems, aNodes, aShape );
5611 storeResult( aMeshEditor) ;
5613 myMesh->GetMeshDS()->Modified();
5615 myMesh->SetIsModified( true );
5617 // Update Python script
5618 TPythonDump() << "isDone = " << this << ".DoubleNodeElemGroupInRegion( " << theElems << ", "
5619 << theNodesNot << ", " << theShape << " )";
5623 //================================================================================
5625 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5626 This method provided for convenience works as DoubleNodes() described above.
5627 \param theElems - list of groups of elements (edges or faces) to be replicated
5628 \param theNodesNot - list of groups of nodes not to replicated
5629 \param theAffectedElems - group of elements to which the replicated nodes
5630 should be associated to.
5631 \return TRUE if operation has been completed successfully, FALSE otherwise
5632 \sa DoubleNodeGroup(), DoubleNodes(), DoubleNodeElemGroupsNew()
5634 //================================================================================
5636 static void listOfGroupToSet(const SMESH::ListOfGroups& theGrpList,
5637 SMESHDS_Mesh* theMeshDS,
5638 TIDSortedElemSet& theElemSet,
5639 const bool theIsNodeGrp)
5641 for ( int i = 0, n = theGrpList.length(); i < n; i++ )
5643 SMESH::SMESH_GroupBase_var aGrp = theGrpList[ i ];
5644 if ( !CORBA::is_nil( aGrp ) && (theIsNodeGrp ? aGrp->GetType() == SMESH::NODE
5645 : aGrp->GetType() != SMESH::NODE ) )
5647 SMESH::long_array_var anIDs = aGrp->GetIDs();
5648 arrayToSet( anIDs, theMeshDS, theElemSet, theIsNodeGrp ? SMDSAbs_Node : SMDSAbs_All );
5653 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroups(const SMESH::ListOfGroups& theElems,
5654 const SMESH::ListOfGroups& theNodesNot,
5655 const SMESH::ListOfGroups& theAffectedElems)
5659 ::SMESH_MeshEditor aMeshEditor( myMesh );
5661 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5662 TIDSortedElemSet anElems, aNodes, anAffected;
5663 listOfGroupToSet(theElems, aMeshDS, anElems, false );
5664 listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true );
5665 listOfGroupToSet(theAffectedElems, aMeshDS, anAffected, false );
5667 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
5669 storeResult( aMeshEditor) ;
5671 myMesh->GetMeshDS()->Modified();
5673 myMesh->SetIsModified( true );
5675 // Update Python script
5676 TPythonDump() << "isDone = " << this << ".DoubleNodeElemGroups( " << &theElems << ", "
5677 << &theNodesNot << ", " << &theAffectedElems << " )";
5681 //================================================================================
5683 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5684 * Works as DoubleNodeElemGroups(), but returns a new group with newly created elements.
5685 \param theElems - list of groups of elements (edges or faces) to be replicated
5686 \param theNodesNot - list of groups of nodes not to replicated
5687 \param theAffectedElems - group of elements to which the replicated nodes
5688 should be associated to.
5689 * \return a new group with newly created elements
5690 * \sa DoubleNodeElemGroups()
5692 //================================================================================
5694 SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeElemGroupsNew(const SMESH::ListOfGroups& theElems,
5695 const SMESH::ListOfGroups& theNodesNot,
5696 const SMESH::ListOfGroups& theAffectedElems)
5698 SMESH::SMESH_Group_var aNewGroup;
5702 ::SMESH_MeshEditor aMeshEditor( myMesh );
5704 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5705 TIDSortedElemSet anElems, aNodes, anAffected;
5706 listOfGroupToSet(theElems, aMeshDS, anElems, false );
5707 listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true );
5708 listOfGroupToSet(theAffectedElems, aMeshDS, anAffected, false );
5710 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
5712 storeResult( aMeshEditor) ;
5714 myMesh->GetMeshDS()->Modified();
5716 myMesh->SetIsModified( true );
5718 // Create group with newly created elements
5719 SMESH::long_array_var anIds = GetLastCreatedElems();
5720 if (anIds->length() > 0) {
5721 SMESH::ElementType aGroupType = myMesh_i->GetElementType(anIds[0], true);
5722 string anUnindexedName (theElems[0]->GetName());
5723 string aNewName = generateGroupName(anUnindexedName + "_double");
5724 aNewGroup = myMesh_i->CreateGroup(aGroupType, aNewName.c_str());
5725 aNewGroup->Add(anIds);
5729 // Update Python script
5730 TPythonDump() << "createdElems = " << this << ".DoubleNodeElemGroupsNew( " << &theElems << ", "
5731 << &theNodesNot << ", " << &theAffectedElems << " )";
5732 return aNewGroup._retn();
5735 //================================================================================
5737 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5738 This method provided for convenience works as DoubleNodes() described above.
5739 \param theElems - list of groups of elements (edges or faces) to be replicated
5740 \param theNodesNot - list of groups of nodes not to replicated
5741 \param theShape - shape to detect affected elements (element which geometric center
5742 located on or inside shape).
5743 The replicated nodes should be associated to affected elements.
5744 \return TRUE if operation has been completed successfully, FALSE otherwise
5745 \sa DoubleNodeGroupInRegion(), DoubleNodesInRegion()
5747 //================================================================================
5750 SMESH_MeshEditor_i::DoubleNodeElemGroupsInRegion(const SMESH::ListOfGroups& theElems,
5751 const SMESH::ListOfGroups& theNodesNot,
5752 GEOM::GEOM_Object_ptr theShape )
5756 ::SMESH_MeshEditor aMeshEditor( myMesh );
5758 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5759 TIDSortedElemSet anElems, aNodes;
5760 listOfGroupToSet(theElems, aMeshDS, anElems,false );
5761 listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true );
5763 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape );
5764 bool aResult = aMeshEditor.DoubleNodesInRegion( anElems, aNodes, aShape );
5766 storeResult( aMeshEditor) ;
5768 myMesh->GetMeshDS()->Modified();
5770 myMesh->SetIsModified( true );
5772 // Update Python script
5773 TPythonDump() << "isDone = " << this << ".DoubleNodeElemGroupsInRegion( " << &theElems << ", "
5774 << &theNodesNot << ", " << theShape << " )";
5778 //================================================================================
5780 \brief Generated skin mesh (containing 2D cells) from 3D mesh
5781 The created 2D mesh elements based on nodes of free faces of boundary volumes
5782 \return TRUE if operation has been completed successfully, FALSE otherwise
5784 //================================================================================
5786 CORBA::Boolean SMESH_MeshEditor_i::Make2DMeshFrom3D()
5790 ::SMESH_MeshEditor aMeshEditor( myMesh );
5791 bool aResult = aMeshEditor.Make2DMeshFrom3D();
5792 storeResult( aMeshEditor) ;
5793 myMesh->GetMeshDS()->Modified();
5794 TPythonDump() << "isDone = " << this << ".Make2DMeshFrom3D()";
5798 //================================================================================
5800 * \brief Double nodes on shared faces between groups of volumes and create flat elements on demand.
5801 * The list of groups must describe a partition of the mesh volumes.
5802 * The nodes of the internal faces at the boundaries of the groups are doubled.
5803 * In option, the internal faces are replaced by flat elements.
5804 * Triangles are transformed in prisms, and quadrangles in hexahedrons.
5805 * The flat elements are stored in groups of volumes.
5806 * @param theDomains - list of groups of volumes
5807 * @param createJointElems - if TRUE, create the elements
5808 * @return TRUE if operation has been completed successfully, FALSE otherwise
5810 //================================================================================
5812 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodesOnGroupBoundaries( const SMESH::ListOfGroups& theDomains,
5813 CORBA::Boolean createJointElems )
5814 throw (SALOME::SALOME_Exception)
5818 ::SMESH_MeshEditor aMeshEditor( myMesh );
5820 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5822 vector<TIDSortedElemSet> domains;
5825 for ( int i = 0, n = theDomains.length(); i < n; i++ )
5827 SMESH::SMESH_GroupBase_var aGrp = theDomains[ i ];
5828 if ( !CORBA::is_nil( aGrp ) /*&& ( aGrp->GetType() != SMESH::NODE )*/ )
5830 // if ( aGrp->GetType() != SMESH::VOLUME )
5831 // THROW_SALOME_CORBA_EXCEPTION("Not a volume group", SALOME::BAD_PARAM);
5832 TIDSortedElemSet domain;
5834 domains.push_back(domain);
5835 SMESH::long_array_var anIDs = aGrp->GetIDs();
5836 arrayToSet( anIDs, aMeshDS, domains[ i ], SMDSAbs_All );
5840 bool aResult = aMeshEditor.DoubleNodesOnGroupBoundaries( domains, createJointElems );
5841 // TODO publish the groups of flat elements in study
5843 storeResult( aMeshEditor) ;
5844 myMesh->GetMeshDS()->Modified();
5846 // Update Python script
5847 TPythonDump() << "isDone = " << this << ".DoubleNodesOnGroupBoundaries( " << &theDomains
5848 << ", " << createJointElems << " )";
5852 //================================================================================
5854 * \brief Double nodes on some external faces and create flat elements.
5855 * Flat elements are mainly used by some types of mechanic calculations.
5857 * Each group of the list must be constituted of faces.
5858 * Triangles are transformed in prisms, and quadrangles in hexahedrons.
5859 * @param theGroupsOfFaces - list of groups of faces
5860 * @return TRUE if operation has been completed successfully, FALSE otherwise
5862 //================================================================================
5864 CORBA::Boolean SMESH_MeshEditor_i::CreateFlatElementsOnFacesGroups( const SMESH::ListOfGroups& theGroupsOfFaces )
5868 ::SMESH_MeshEditor aMeshEditor( myMesh );
5870 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5872 vector<TIDSortedElemSet> faceGroups;
5875 for ( int i = 0, n = theGroupsOfFaces.length(); i < n; i++ )
5877 SMESH::SMESH_GroupBase_var aGrp = theGroupsOfFaces[ i ];
5878 if ( !CORBA::is_nil( aGrp ) && ( aGrp->GetType() != SMESH::NODE ) )
5880 TIDSortedElemSet faceGroup;
5882 faceGroups.push_back(faceGroup);
5883 SMESH::long_array_var anIDs = aGrp->GetIDs();
5884 arrayToSet( anIDs, aMeshDS, faceGroups[ i ], SMDSAbs_All );
5888 bool aResult = aMeshEditor.CreateFlatElementsOnFacesGroups( faceGroups );
5889 // TODO publish the groups of flat elements in study
5891 storeResult( aMeshEditor) ;
5892 myMesh->GetMeshDS()->Modified();
5894 // Update Python script
5895 TPythonDump() << "isDone = " << this << ".CreateFlatElementsOnFacesGroups( " << &theGroupsOfFaces << " )";
5899 // issue 20749 ===================================================================
5901 * \brief Creates missing boundary elements
5902 * \param elements - elements whose boundary is to be checked
5903 * \param dimension - defines type of boundary elements to create
5904 * \param groupName - a name of group to store created boundary elements in,
5905 * "" means not to create the group
5906 * \param meshName - a name of new mesh to store created boundary elements in,
5907 * "" means not to create the new mesh
5908 * \param toCopyElements - if true, the checked elements will be copied into the new mesh
5909 * \param toCopyExistingBondary - if true, not only new but also pre-existing
5910 * boundary elements will be copied into the new mesh
5911 * \param group - returns the create group, if any
5912 * \retval SMESH::SMESH_Mesh - the mesh where elements were added to
5914 // ================================================================================
5916 SMESH::SMESH_Mesh_ptr
5917 SMESH_MeshEditor_i::MakeBoundaryMesh(SMESH::SMESH_IDSource_ptr idSource,
5918 SMESH::Bnd_Dimension dim,
5919 const char* groupName,
5920 const char* meshName,
5921 CORBA::Boolean toCopyElements,
5922 CORBA::Boolean toCopyExistingBondary,
5923 SMESH::SMESH_Group_out group)
5927 if ( dim > SMESH::BND_1DFROM2D )
5928 THROW_SALOME_CORBA_EXCEPTION("Invalid boundary dimension", SALOME::BAD_PARAM);
5930 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5932 SMESH::SMESH_Mesh_var mesh_var;
5933 SMESH::SMESH_Group_var group_var;
5937 TIDSortedElemSet elements;
5938 SMDSAbs_ElementType elemType = (dim == SMESH::BND_1DFROM2D) ? SMDSAbs_Face : SMDSAbs_Volume;
5939 if ( idSourceToSet( idSource, aMeshDS, elements, elemType,/*emptyIfIsMesh=*/true ))
5943 strlen(meshName) ? makeMesh(meshName) : SMESH::SMESH_Mesh::_duplicate(myMesh_i->_this());
5944 SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh_var );
5946 SMESH_Mesh* smesh_mesh = (mesh_i==myMesh_i) ? (SMESH_Mesh*)0 : &mesh_i->GetImpl();
5948 // group of new boundary elements
5949 SMESH_Group* smesh_group = 0;
5950 if ( strlen(groupName) )
5952 group_var = mesh_i->CreateGroup( SMESH::ElementType(int(elemType)-1),groupName);
5953 if ( SMESH_GroupBase_i* group_i = SMESH::DownCast<SMESH_GroupBase_i*>( group_var ))
5954 smesh_group = group_i->GetSmeshGroup();
5958 ::SMESH_MeshEditor aMeshEditor( myMesh );
5959 aMeshEditor.MakeBoundaryMesh( elements,
5960 ::SMESH_MeshEditor::Bnd_Dimension(dim),
5964 toCopyExistingBondary);
5965 storeResult( aMeshEditor );
5968 smesh_mesh->GetMeshDS()->Modified();
5971 const char* dimName[] = { "BND_2DFROM3D", "BND_1DFROM3D", "BND_1DFROM2D" };
5973 // result of MakeBoundaryMesh() is a tuple (mesh, group)
5974 if ( mesh_var->_is_nil() )
5975 pyDump << myMesh_i->_this() << ", ";
5977 pyDump << mesh_var << ", ";
5978 if ( group_var->_is_nil() )
5979 pyDump << "_NoneGroup = "; // assignment to None is forbiden
5981 pyDump << group_var << " = ";
5982 pyDump << this << ".MakeBoundaryMesh( "
5984 << "SMESH." << dimName[int(dim)] << ", "
5985 << "'" << groupName << "', "
5986 << "'" << meshName<< "', "
5987 << toCopyElements << ", "
5988 << toCopyExistingBondary << ")";
5990 group = group_var._retn();
5991 return mesh_var._retn();
5994 //================================================================================
5996 * \brief Creates missing boundary elements
5997 * \param dimension - defines type of boundary elements to create
5998 * \param groupName - a name of group to store all boundary elements in,
5999 * "" means not to create the group
6000 * \param meshName - a name of a new mesh, which is a copy of the initial
6001 * mesh + created boundary elements; "" means not to create the new mesh
6002 * \param toCopyAll - if true, the whole initial mesh will be copied into
6003 * the new mesh else only boundary elements will be copied into the new mesh
6004 * \param groups - optional groups of elements to make boundary around
6005 * \param mesh - returns the mesh where elements were added to
6006 * \param group - returns the created group, if any
6007 * \retval long - number of added boundary elements
6009 //================================================================================
6011 CORBA::Long SMESH_MeshEditor_i::MakeBoundaryElements(SMESH::Bnd_Dimension dim,
6012 const char* groupName,
6013 const char* meshName,
6014 CORBA::Boolean toCopyAll,
6015 const SMESH::ListOfIDSources& groups,
6016 SMESH::SMESH_Mesh_out mesh,
6017 SMESH::SMESH_Group_out group)
6018 throw (SALOME::SALOME_Exception)
6020 Unexpect aCatch(SALOME_SalomeException);
6024 if ( dim > SMESH::BND_1DFROM2D )
6025 THROW_SALOME_CORBA_EXCEPTION("Invalid boundary dimension", SALOME::BAD_PARAM);
6027 // separate groups belonging to this and other mesh
6028 SMESH::ListOfIDSources_var groupsOfThisMesh = new SMESH::ListOfIDSources;
6029 SMESH::ListOfIDSources_var groupsOfOtherMesh = new SMESH::ListOfIDSources;
6030 groupsOfThisMesh->length( groups.length() );
6031 groupsOfOtherMesh->length( groups.length() );
6032 int nbGroups = 0, nbGroupsOfOtherMesh = 0;
6033 for ( int i = 0; i < groups.length(); ++i )
6035 SMESH::SMESH_Mesh_var m = groups[i]->GetMesh();
6036 if ( myMesh_i != SMESH::DownCast<SMESH_Mesh_i*>( m ))
6037 groupsOfOtherMesh[ nbGroupsOfOtherMesh++ ] = groups[i];
6039 groupsOfThisMesh[ nbGroups++ ] = groups[i];
6040 if ( SMESH::DownCast<SMESH_Mesh_i*>( groups[i] ))
6041 THROW_SALOME_CORBA_EXCEPTION("expect a group but recieve a mesh", SALOME::BAD_PARAM);
6043 groupsOfThisMesh->length( nbGroups );
6044 groupsOfOtherMesh->length( nbGroupsOfOtherMesh );
6049 if ( nbGroupsOfOtherMesh > 0 )
6051 // process groups belonging to another mesh
6052 SMESH::SMESH_Mesh_var otherMesh = groupsOfOtherMesh[0]->GetMesh();
6053 SMESH::SMESH_MeshEditor_var editor = otherMesh->GetMeshEditor();
6054 nbAdded += editor->MakeBoundaryElements( dim, groupName, meshName, toCopyAll,
6055 groupsOfOtherMesh, mesh, group );
6058 SMESH::SMESH_Mesh_var mesh_var;
6059 SMESH::SMESH_Group_var group_var;
6062 mesh_var = SMESH::SMESH_Mesh::_duplicate( myMesh_i->_this() );
6063 const bool toCopyMesh = ( strlen( meshName ) > 0 );
6067 mesh_var = SMESH_Gen_i::GetSMESHGen()->CopyMesh(mesh_var,
6069 /*toCopyGroups=*/false,
6070 /*toKeepIDs=*/true);
6072 mesh_var = makeMesh(meshName);
6074 SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh_var );
6075 SMESH_Mesh* tgtMesh = &mesh_i->GetImpl();
6078 SMESH_Mesh* srcMesh = ( toCopyMesh && !toCopyAll ) ? myMesh : tgtMesh;
6079 SMESHDS_Mesh* srcMeshDS = srcMesh->GetMeshDS();
6081 // group of boundary elements
6082 SMESH_Group* smesh_group = 0;
6083 SMDSAbs_ElementType elemType = (dim == SMESH::BND_2DFROM3D) ? SMDSAbs_Volume : SMDSAbs_Face;
6084 if ( strlen(groupName) )
6086 SMESH::ElementType groupType = SMESH::ElementType( int(elemType)-1 );
6087 group_var = mesh_i->CreateGroup( groupType, groupName );
6088 if ( SMESH_GroupBase_i* group_i = SMESH::DownCast<SMESH_GroupBase_i*>( group_var ))
6089 smesh_group = group_i->GetSmeshGroup();
6092 TIDSortedElemSet elements;
6094 if ( groups.length() > 0 )
6096 for ( int i = 0; i < nbGroups; ++i )
6099 if ( idSourceToSet( groupsOfThisMesh[i], srcMeshDS, elements, elemType,/*emptyIfIsMesh=*/0 ))
6101 SMESH::Bnd_Dimension bdim =
6102 ( elemType == SMDSAbs_Volume ) ? SMESH::BND_2DFROM3D : SMESH::BND_1DFROM2D;
6103 ::SMESH_MeshEditor aMeshEditor( srcMesh );
6104 nbAdded += aMeshEditor.MakeBoundaryMesh( elements,
6105 ::SMESH_MeshEditor::Bnd_Dimension(bdim),
6108 /*toCopyElements=*/false,
6109 /*toCopyExistingBondary=*/srcMesh != tgtMesh,
6110 /*toAddExistingBondary=*/true,
6111 /*aroundElements=*/true);
6112 storeResult( aMeshEditor );
6118 ::SMESH_MeshEditor aMeshEditor( srcMesh );
6119 nbAdded += aMeshEditor.MakeBoundaryMesh( elements,
6120 ::SMESH_MeshEditor::Bnd_Dimension(dim),
6123 /*toCopyElements=*/false,
6124 /*toCopyExistingBondary=*/srcMesh != tgtMesh,
6125 /*toAddExistingBondary=*/true);
6126 storeResult( aMeshEditor );
6128 tgtMesh->GetMeshDS()->Modified();
6130 const char* dimName[] = { "BND_2DFROM3D", "BND_1DFROM3D", "BND_1DFROM2D" };
6132 // result of MakeBoundaryElements() is a tuple (nb, mesh, group)
6133 pyDump << "nbAdded, ";
6134 if ( mesh_var->_is_nil() )
6135 pyDump << myMesh_i->_this() << ", ";
6137 pyDump << mesh_var << ", ";
6138 if ( group_var->_is_nil() )
6139 pyDump << "_NoneGroup = "; // assignment to None is forbiden
6141 pyDump << group_var << " = ";
6142 pyDump << this << ".MakeBoundaryElements( "
6143 << "SMESH." << dimName[int(dim)] << ", "
6144 << "'" << groupName << "', "
6145 << "'" << meshName<< "', "
6146 << toCopyAll << ", "
6149 mesh = mesh_var._retn();
6150 group = group_var._retn();