1 // Copyright (C) 2007-2010 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 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
23 // File : SMESH_MeshEditor_i.cxx
24 // Author : Nicolas REJNERI
31 #include "SMESH_MeshEditor_i.hxx"
33 #include "SMDS_Mesh0DElement.hxx"
34 #include "SMDS_LinearEdge.hxx"
35 #include "SMDS_MeshFace.hxx"
36 #include "SMDS_MeshVolume.hxx"
37 #include "SMDS_PolyhedralVolumeOfNodes.hxx"
38 #include "SMESH_subMeshEventListener.hxx"
39 #include "SMESH_Gen_i.hxx"
40 #include "SMESH_Filter_i.hxx"
41 #include "SMESH_subMesh_i.hxx"
42 #include "SMESH_Group_i.hxx"
43 #include "SMESH_PythonDump.hxx"
44 #include "SMESH_ControlsDef.hxx"
46 #include "utilities.h"
47 #include "Utils_ExceptHandlers.hxx"
48 #include "Utils_CorbaException.hxx"
50 #include <BRepAdaptor_Surface.hxx>
51 #include <BRep_Tool.hxx>
52 #include <TopExp_Explorer.hxx>
54 #include <TopoDS_Edge.hxx>
55 #include <TopoDS_Face.hxx>
60 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
64 #include <Standard_Failure.hxx>
67 #include <Standard_ErrorHandler.hxx>
73 #define cast2Node(elem) static_cast<const SMDS_MeshNode*>( elem )
76 using SMESH::TPythonDump;
80 //=============================================================================
82 * \brief Mesh to apply modifications for preview purposes
84 //=============================================================================
86 struct TPreviewMesh: public SMESH_Mesh
88 SMDSAbs_ElementType myPreviewType; // type to show
90 TPreviewMesh(SMDSAbs_ElementType previewElements = SMDSAbs_All) {
91 _isShapeToMesh = (_id =_studyId =_idDoc = 0);
92 _myMeshDS = new SMESHDS_Mesh( _id, true );
93 myPreviewType = previewElements;
96 virtual ~TPreviewMesh() { delete _myMeshDS; }
97 //!< Copy a set of elements
98 void Copy(const TIDSortedElemSet & theElements,
99 TIDSortedElemSet& theCopyElements,
100 SMDSAbs_ElementType theSelectType = SMDSAbs_All,
101 SMDSAbs_ElementType theAvoidType = SMDSAbs_All)
103 // loop on theIDsOfElements
104 TIDSortedElemSet::const_iterator eIt = theElements.begin();
105 for ( ; eIt != theElements.end(); ++eIt )
107 const SMDS_MeshElement* anElem = *eIt;
108 if ( !anElem ) continue;
109 SMDSAbs_ElementType type = anElem->GetType();
110 if ( type == theAvoidType ||
111 ( theSelectType != SMDSAbs_All && type != theSelectType ))
114 if ( const SMDS_MeshElement* anElemCopy = Copy( anElem ))
115 theCopyElements.insert( theCopyElements.end(), anElemCopy );
119 SMDS_MeshElement* Copy( const SMDS_MeshElement* anElem )
121 // copy element nodes
122 int anElemNbNodes = anElem->NbNodes();
123 vector< int > anElemNodesID( anElemNbNodes ) ;
124 SMDS_ElemIteratorPtr itElemNodes = anElem->nodesIterator();
125 for ( int i = 0; itElemNodes->more(); i++)
127 const SMDS_MeshNode* anElemNode = cast2Node( itElemNodes->next() );
129 anElemNodesID[i] = anElemNode->GetID();
132 // creates a corresponding element on copied nodes
133 SMDS_MeshElement* anElemCopy = 0;
134 if ( anElem->IsPoly() && anElem->GetType() == SMDSAbs_Volume )
136 const SMDS_VtkVolume* ph =
137 dynamic_cast<const SMDS_VtkVolume*> (anElem);
139 anElemCopy = _myMeshDS->AddPolyhedralVolumeWithID
140 (anElemNodesID, ph->GetQuantities(),anElem->GetID());
143 anElemCopy = ::SMESH_MeshEditor(this).AddElement( anElemNodesID,
150 SMDS_MeshNode* Copy( const SMDS_MeshNode* anElemNode )
152 return _myMeshDS->AddNodeWithID(anElemNode->X(), anElemNode->Y(), anElemNode->Z(),
153 anElemNode->GetID());
155 };// struct TPreviewMesh
157 static SMESH_NodeSearcher * theNodeSearcher = 0;
158 static SMESH_ElementSearcher * theElementSearcher = 0;
160 //=============================================================================
162 * \brief Deleter of theNodeSearcher at any compute event occured
164 //=============================================================================
166 struct TSearchersDeleter : public SMESH_subMeshEventListener
170 TSearchersDeleter(): SMESH_subMeshEventListener( false ), // won't be deleted by submesh
172 //!< Delete theNodeSearcher
175 if ( theNodeSearcher ) delete theNodeSearcher; theNodeSearcher = 0;
176 if ( theElementSearcher ) delete theElementSearcher; theElementSearcher = 0;
178 typedef map < int, SMESH_subMesh * > TDependsOnMap;
179 //!< The meshod called by submesh: do my main job
180 void ProcessEvent(const int, const int eventType, SMESH_subMesh* sm,
181 SMESH_subMeshEventListenerData*,const SMESH_Hypothesis*)
183 if ( eventType == SMESH_subMesh::COMPUTE_EVENT ) {
185 Unset( sm->GetFather() );
188 //!< set self on all submeshes and delete theNodeSearcher if other mesh is set
189 void Set(SMESH_Mesh* mesh)
191 if ( myMesh != mesh )
198 if ( SMESH_subMesh* myMainSubMesh = mesh->GetSubMeshContaining(1) ) {
199 const TDependsOnMap & subMeshes = myMainSubMesh->DependsOn();
200 TDependsOnMap::const_iterator sm;
201 for (sm = subMeshes.begin(); sm != subMeshes.end(); sm++)
202 sm->second->SetEventListener( this, 0, sm->second );
206 //!< delete self from all submeshes
207 void Unset(SMESH_Mesh* mesh)
209 if ( SMESH_subMesh* myMainSubMesh = mesh->GetSubMeshContaining(1) ) {
210 const TDependsOnMap & subMeshes = myMainSubMesh->DependsOn();
211 TDependsOnMap::const_iterator sm;
212 for (sm = subMeshes.begin(); sm != subMeshes.end(); sm++)
213 sm->second->DeleteEventListener( this );
218 } theSearchersDeleter;
220 TCollection_AsciiString mirrorTypeName( SMESH::SMESH_MeshEditor::MirrorType theMirrorType )
222 TCollection_AsciiString typeStr;
223 switch ( theMirrorType ) {
224 case SMESH::SMESH_MeshEditor::POINT:
225 typeStr = "SMESH.SMESH_MeshEditor.POINT";
227 case SMESH::SMESH_MeshEditor::AXIS:
228 typeStr = "SMESH.SMESH_MeshEditor.AXIS";
231 typeStr = "SMESH.SMESH_MeshEditor.PLANE";
235 //================================================================================
237 * \brief function for conversion long_array to TIDSortedElemSet
238 * \param IDs - array of IDs
239 * \param aMesh - mesh
240 * \param aMap - collection to fill
241 * \param aType - element type
243 //================================================================================
245 void arrayToSet(const SMESH::long_array & IDs,
246 const SMESHDS_Mesh* aMesh,
247 TIDSortedElemSet& aMap,
248 const SMDSAbs_ElementType aType = SMDSAbs_All )
250 for (int i=0; i<IDs.length(); i++) {
251 CORBA::Long ind = IDs[i];
252 const SMDS_MeshElement * elem =
253 (aType == SMDSAbs_Node ? aMesh->FindNode(ind) : aMesh->FindElement(ind));
254 if ( elem && ( aType == SMDSAbs_All || elem->GetType() == aType ))
258 //================================================================================
260 * \brief Retrieve elements of given type from SMESH_IDSource
262 //================================================================================
264 bool idSourceToSet(SMESH::SMESH_IDSource_ptr theIDSource,
265 const SMESHDS_Mesh* theMeshDS,
266 TIDSortedElemSet& theElemSet,
267 const SMDSAbs_ElementType theType,
268 const bool emptyIfIsMesh=false)
271 if ( CORBA::is_nil( theIDSource ) )
273 if ( emptyIfIsMesh && SMESH::DownCast<SMESH_Mesh_i*>( theIDSource ))
276 SMESH::long_array_var anIDs = theIDSource->GetIDs();
277 if ( anIDs->length() == 0 )
279 SMESH::array_of_ElementType_var types = theIDSource->GetTypes();
280 if ( types->length() == 1 && types[0] == SMESH::NODE ) // group of nodes
282 if ( theType == SMDSAbs_All || theType == SMDSAbs_Node )
283 arrayToSet( anIDs, theMeshDS, theElemSet, SMDSAbs_Node );
289 arrayToSet( anIDs, theMeshDS, theElemSet, theType);
293 //================================================================================
295 * \brief Retrieve nodes from SMESH_IDSource
297 //================================================================================
299 void idSourceToNodeSet(SMESH::SMESH_IDSource_ptr theObject,
300 const SMESHDS_Mesh* theMeshDS,
301 TIDSortedNodeSet& theNodeSet)
304 if ( CORBA::is_nil( theObject ) )
306 SMESH::array_of_ElementType_var types = theObject->GetTypes();
307 SMESH::long_array_var aElementsId = theObject->GetIDs();
308 if ( types->length() == 1 && types[0] == SMESH::NODE)
310 for(int i = 0; i < aElementsId->length(); i++)
311 if ( const SMDS_MeshNode * n = theMeshDS->FindNode( aElementsId[i] ))
312 theNodeSet.insert( theNodeSet.end(), n);
315 for(int i = 0; i < aElementsId->length(); i++)
316 if( const SMDS_MeshElement * elem = theMeshDS->FindElement( aElementsId[i] ))
317 theNodeSet.insert( elem->begin_nodes(), elem->end_nodes());
322 //=============================================================================
326 //=============================================================================
328 SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESH_Mesh_i* theMesh, bool isPreview)
331 myMesh = & theMesh->GetImpl();
332 myPreviewMode = isPreview;
335 //================================================================================
339 //================================================================================
341 SMESH_MeshEditor_i::~SMESH_MeshEditor_i()
345 //================================================================================
347 * \brief Clear members
349 //================================================================================
351 void SMESH_MeshEditor_i::initData(bool deleteSearchers)
353 if ( myPreviewMode ) {
354 myPreviewData = new SMESH::MeshPreviewStruct();
357 myLastCreatedElems = new SMESH::long_array();
358 myLastCreatedNodes = new SMESH::long_array();
359 if ( deleteSearchers )
360 TSearchersDeleter::Delete();
364 //=======================================================================
365 //function : MakeIDSource
366 //purpose : Wrap a sequence of ids in a SMESH_IDSource
367 //=======================================================================
369 struct _IDSource : public POA_SMESH::SMESH_IDSource
371 SMESH::long_array _ids;
372 SMESH::ElementType _type;
373 SMESH::SMESH_Mesh_ptr _mesh;
374 SMESH::long_array* GetIDs() { return new SMESH::long_array( _ids ); }
375 SMESH::long_array* GetMeshInfo() { return 0; }
376 SMESH::SMESH_Mesh_ptr GetMesh() { return SMESH::SMESH_Mesh::_duplicate( _mesh ); }
377 SMESH::array_of_ElementType* GetTypes()
379 SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType;
382 return types._retn();
386 SMESH::SMESH_IDSource_ptr SMESH_MeshEditor_i::MakeIDSource(const SMESH::long_array& ids,
387 SMESH::ElementType type)
389 _IDSource* anIDSource = new _IDSource;
390 anIDSource->_ids = ids;
391 anIDSource->_type = type;
392 anIDSource->_mesh = myMesh_i->_this();
393 SMESH::SMESH_IDSource_var anIDSourceVar = anIDSource->_this();
395 return anIDSourceVar._retn();
398 //=============================================================================
402 //=============================================================================
405 SMESH_MeshEditor_i::RemoveElements(const SMESH::long_array & IDsOfElements)
409 ::SMESH_MeshEditor anEditor( myMesh );
412 for (int i = 0; i < IDsOfElements.length(); i++)
413 IdList.push_back( IDsOfElements[i] );
415 // Update Python script
416 TPythonDump() << "isDone = " << this << ".RemoveElements( " << IDsOfElements << " )";
419 bool ret = anEditor.Remove( IdList, false );
420 myMesh->GetMeshDS()->Modified();
421 if ( IDsOfElements.length() )
422 myMesh->SetIsModified( true ); // issue 0020693
426 //=============================================================================
430 //=============================================================================
432 CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::long_array & IDsOfNodes)
436 ::SMESH_MeshEditor anEditor( myMesh );
438 for (int i = 0; i < IDsOfNodes.length(); i++)
439 IdList.push_back( IDsOfNodes[i] );
441 // Update Python script
442 TPythonDump() << "isDone = " << this << ".RemoveNodes( " << IDsOfNodes << " )";
444 bool ret = anEditor.Remove( IdList, true );
445 myMesh->GetMeshDS()->Modified();
446 if ( IDsOfNodes.length() )
447 myMesh->SetIsModified( true ); // issue 0020693
451 //=============================================================================
455 //=============================================================================
457 CORBA::Long SMESH_MeshEditor_i::RemoveOrphanNodes()
461 ::SMESH_MeshEditor anEditor( myMesh );
463 // Update Python script
464 TPythonDump() << "nbRemoved = " << this << ".RemoveOrphanNodes()";
466 // Create filter to find all orphan nodes
467 SMESH::Controls::Filter::TIdSequence seq;
468 SMESH::Controls::PredicatePtr predicate( new SMESH::Controls::FreeNodes() );
469 SMESH::Controls::Filter::GetElementsId( GetMeshDS(), predicate, seq );
471 // remove orphan nodes (if there are any)
473 for ( int i = 0; i < seq.size(); i++ )
474 IdList.push_back( seq[i] );
476 bool ret = anEditor.Remove( IdList, true );
477 myMesh->GetMeshDS()->Modified();
479 myMesh->SetIsModified( true );
484 //=============================================================================
488 //=============================================================================
490 CORBA::Long SMESH_MeshEditor_i::AddNode(CORBA::Double x,
491 CORBA::Double y, CORBA::Double z)
495 const SMDS_MeshNode* N = GetMeshDS()->AddNode(x, y, z);
497 // Update Python script
498 TPythonDump() << "nodeID = " << this << ".AddNode( "
499 << x << ", " << y << ", " << z << " )";
501 myMesh->GetMeshDS()->Modified();
502 myMesh->SetIsModified( true ); // issue 0020693
506 //=============================================================================
510 //=============================================================================
511 CORBA::Long SMESH_MeshEditor_i::Add0DElement(CORBA::Long IDOfNode)
515 const SMDS_MeshNode* aNode = GetMeshDS()->FindNode(IDOfNode);
516 SMDS_MeshElement* elem = GetMeshDS()->Add0DElement(aNode);
518 // Update Python script
519 TPythonDump() << "elem0d = " << this << ".Add0DElement( " << IDOfNode <<" )";
521 myMesh->GetMeshDS()->Modified();
522 myMesh->SetIsModified( true ); // issue 0020693
525 return elem->GetID();
530 //=============================================================================
534 //=============================================================================
536 CORBA::Long SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes)
540 int NbNodes = IDsOfNodes.length();
541 SMDS_MeshElement* elem = 0;
544 CORBA::Long index1 = IDsOfNodes[0];
545 CORBA::Long index2 = IDsOfNodes[1];
546 elem = GetMeshDS()->AddEdge(GetMeshDS()->FindNode(index1), GetMeshDS()->FindNode(index2));
548 // Update Python script
549 TPythonDump() << "edge = " << this << ".AddEdge([ "
550 << index1 << ", " << index2 <<" ])";
553 CORBA::Long n1 = IDsOfNodes[0];
554 CORBA::Long n2 = IDsOfNodes[1];
555 CORBA::Long n12 = IDsOfNodes[2];
556 elem = GetMeshDS()->AddEdge(GetMeshDS()->FindNode(n1),
557 GetMeshDS()->FindNode(n2),
558 GetMeshDS()->FindNode(n12));
559 // Update Python script
560 TPythonDump() << "edgeID = " << this << ".AddEdge([ "
561 <<n1<<", "<<n2<<", "<<n12<<" ])";
564 myMesh->GetMeshDS()->Modified();
566 return myMesh->SetIsModified( true ), elem->GetID();
571 //=============================================================================
575 //=============================================================================
577 CORBA::Long SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
581 int NbNodes = IDsOfNodes.length();
587 std::vector<const SMDS_MeshNode*> nodes (NbNodes);
588 for (int i = 0; i < NbNodes; i++)
589 nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
591 SMDS_MeshElement* elem = 0;
593 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]);
595 else if (NbNodes == 4) {
596 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
598 else if (NbNodes == 6) {
599 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
602 else if (NbNodes == 8) {
603 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
604 nodes[4], nodes[5], nodes[6], nodes[7]);
606 else if (NbNodes > 2) {
607 elem = GetMeshDS()->AddPolygonalFace(nodes);
610 // Update Python script
611 TPythonDump() << "faceID = " << this << ".AddFace( " << IDsOfNodes << " )";
613 myMesh->GetMeshDS()->Modified();
615 return myMesh->SetIsModified( true ), elem->GetID();
620 //=============================================================================
624 //=============================================================================
625 CORBA::Long SMESH_MeshEditor_i::AddPolygonalFace (const SMESH::long_array & IDsOfNodes)
629 int NbNodes = IDsOfNodes.length();
630 std::vector<const SMDS_MeshNode*> nodes (NbNodes);
631 for (int i = 0; i < NbNodes; i++)
632 nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
634 const SMDS_MeshElement* elem = GetMeshDS()->AddPolygonalFace(nodes);
636 // Update Python script
637 TPythonDump() <<"faceID = "<<this<<".AddPolygonalFace( "<<IDsOfNodes<<" )";
639 myMesh->GetMeshDS()->Modified();
640 return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0;
643 //=============================================================================
647 //=============================================================================
649 CORBA::Long SMESH_MeshEditor_i::AddVolume(const SMESH::long_array & IDsOfNodes)
653 int NbNodes = IDsOfNodes.length();
654 vector< const SMDS_MeshNode*> n(NbNodes);
655 for(int i=0;i<NbNodes;i++)
656 n[i]=GetMeshDS()->FindNode(IDsOfNodes[i]);
658 SMDS_MeshElement* elem = 0;
661 case 4 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3]); break;
662 case 5 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4]); break;
663 case 6 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5]); break;
664 case 8 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break;
665 case 10:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],
666 n[6],n[7],n[8],n[9]);
668 case 13:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],
669 n[7],n[8],n[9],n[10],n[11],n[12]);
671 case 15:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],
672 n[9],n[10],n[11],n[12],n[13],n[14]);
674 case 20:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],
675 n[8],n[9],n[10],n[11],n[12],n[13],n[14],
676 n[15],n[16],n[17],n[18],n[19]);
680 // Update Python script
681 TPythonDump() << "volID = " << this << ".AddVolume( " << IDsOfNodes << " )";
683 myMesh->GetMeshDS()->Modified();
685 return myMesh->SetIsModified( true ), elem->GetID();
690 //=============================================================================
692 * AddPolyhedralVolume
694 //=============================================================================
695 CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolume (const SMESH::long_array & IDsOfNodes,
696 const SMESH::long_array & Quantities)
700 int NbNodes = IDsOfNodes.length();
701 std::vector<const SMDS_MeshNode*> n (NbNodes);
702 for (int i = 0; i < NbNodes; i++)
704 const SMDS_MeshNode* aNode = GetMeshDS()->FindNode(IDsOfNodes[i]);
705 if (!aNode) return 0;
709 int NbFaces = Quantities.length();
710 std::vector<int> q (NbFaces);
711 for (int j = 0; j < NbFaces; j++)
712 q[j] = Quantities[j];
714 const SMDS_MeshElement* elem = GetMeshDS()->AddPolyhedralVolume(n, q);
716 // Update Python script
717 TPythonDump() << "volID = " << this << ".AddPolyhedralVolume( "
718 << IDsOfNodes << ", " << Quantities << " )";
719 myMesh->GetMeshDS()->Modified();
721 return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0;
724 //=============================================================================
726 * AddPolyhedralVolumeByFaces
728 //=============================================================================
729 CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces (const SMESH::long_array & IdsOfFaces)
733 int NbFaces = IdsOfFaces.length();
734 std::vector<const SMDS_MeshNode*> poly_nodes;
735 std::vector<int> quantities (NbFaces);
737 for (int i = 0; i < NbFaces; i++) {
738 const SMDS_MeshElement* aFace = GetMeshDS()->FindElement(IdsOfFaces[i]);
739 quantities[i] = aFace->NbNodes();
741 SMDS_ElemIteratorPtr It = aFace->nodesIterator();
743 poly_nodes.push_back(static_cast<const SMDS_MeshNode *>(It->next()));
747 const SMDS_MeshElement* elem = GetMeshDS()->AddPolyhedralVolume(poly_nodes, quantities);
749 // Update Python script
750 TPythonDump() << "volID = " << this << ".AddPolyhedralVolumeByFaces( "
751 << IdsOfFaces << " )";
752 myMesh->GetMeshDS()->Modified();
754 return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0;
757 //=============================================================================
759 * \brief Bind a node to a vertex
760 * \param NodeID - node ID
761 * \param VertexID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
762 * \retval boolean - false if NodeID or VertexID is invalid
764 //=============================================================================
766 void SMESH_MeshEditor_i::SetNodeOnVertex(CORBA::Long NodeID, CORBA::Long VertexID)
767 throw (SALOME::SALOME_Exception)
769 Unexpect aCatch(SALOME_SalomeException);
771 SMESHDS_Mesh * mesh = GetMeshDS();
772 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
774 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
776 if ( mesh->MaxShapeIndex() < VertexID )
777 THROW_SALOME_CORBA_EXCEPTION("Invalid VertexID", SALOME::BAD_PARAM);
779 TopoDS_Shape shape = mesh->IndexToShape( VertexID );
780 if ( shape.ShapeType() != TopAbs_VERTEX )
781 THROW_SALOME_CORBA_EXCEPTION("Invalid VertexID", SALOME::BAD_PARAM);
783 mesh->SetNodeOnVertex( node, VertexID );
785 myMesh->SetIsModified( true );
788 //=============================================================================
790 * \brief Store node position on an edge
791 * \param NodeID - node ID
792 * \param EdgeID - edge ID available through GEOM_Object.GetSubShapeIndices()[0]
793 * \param paramOnEdge - parameter on edge where the node is located
794 * \retval boolean - false if any parameter is invalid
796 //=============================================================================
798 void SMESH_MeshEditor_i::SetNodeOnEdge(CORBA::Long NodeID, CORBA::Long EdgeID,
799 CORBA::Double paramOnEdge)
800 throw (SALOME::SALOME_Exception)
802 Unexpect aCatch(SALOME_SalomeException);
804 SMESHDS_Mesh * mesh = GetMeshDS();
805 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
807 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
809 if ( mesh->MaxShapeIndex() < EdgeID )
810 THROW_SALOME_CORBA_EXCEPTION("Invalid EdgeID", SALOME::BAD_PARAM);
812 TopoDS_Shape shape = mesh->IndexToShape( EdgeID );
813 if ( shape.ShapeType() != TopAbs_EDGE )
814 THROW_SALOME_CORBA_EXCEPTION("Invalid EdgeID", SALOME::BAD_PARAM);
817 BRep_Tool::Range( TopoDS::Edge( shape ), f,l);
818 if ( paramOnEdge < f || paramOnEdge > l )
819 THROW_SALOME_CORBA_EXCEPTION("Invalid paramOnEdge", SALOME::BAD_PARAM);
821 mesh->SetNodeOnEdge( node, EdgeID, paramOnEdge );
823 myMesh->SetIsModified( true );
826 //=============================================================================
828 * \brief Store node position on a face
829 * \param NodeID - node ID
830 * \param FaceID - face ID available through GEOM_Object.GetSubShapeIndices()[0]
831 * \param u - U parameter on face where the node is located
832 * \param v - V parameter on face where the node is located
833 * \retval boolean - false if any parameter is invalid
835 //=============================================================================
837 void SMESH_MeshEditor_i::SetNodeOnFace(CORBA::Long NodeID, CORBA::Long FaceID,
838 CORBA::Double u, CORBA::Double v)
839 throw (SALOME::SALOME_Exception)
841 Unexpect aCatch(SALOME_SalomeException);
843 SMESHDS_Mesh * mesh = GetMeshDS();
844 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
846 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
848 if ( mesh->MaxShapeIndex() < FaceID )
849 THROW_SALOME_CORBA_EXCEPTION("Invalid FaceID", SALOME::BAD_PARAM);
851 TopoDS_Shape shape = mesh->IndexToShape( FaceID );
852 if ( shape.ShapeType() != TopAbs_FACE )
853 THROW_SALOME_CORBA_EXCEPTION("Invalid FaceID", SALOME::BAD_PARAM);
855 BRepAdaptor_Surface surf( TopoDS::Face( shape ));
856 bool isOut = ( u < surf.FirstUParameter() ||
857 u > surf.LastUParameter() ||
858 v < surf.FirstVParameter() ||
859 v > surf.LastVParameter() );
863 MESSAGE ( "FACE " << FaceID << " (" << u << "," << v << ") out of "
864 << " u( " << surf.FirstUParameter()
865 << "," << surf.LastUParameter()
866 << ") v( " << surf.FirstVParameter()
867 << "," << surf.LastVParameter() << ")" );
869 THROW_SALOME_CORBA_EXCEPTION("Invalid UV", SALOME::BAD_PARAM);
872 mesh->SetNodeOnFace( node, FaceID, u, v );
873 myMesh->SetIsModified( true );
876 //=============================================================================
878 * \brief Bind a node to a solid
879 * \param NodeID - node ID
880 * \param SolidID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
881 * \retval boolean - false if NodeID or SolidID is invalid
883 //=============================================================================
885 void SMESH_MeshEditor_i::SetNodeInVolume(CORBA::Long NodeID, CORBA::Long SolidID)
886 throw (SALOME::SALOME_Exception)
888 Unexpect aCatch(SALOME_SalomeException);
890 SMESHDS_Mesh * mesh = GetMeshDS();
891 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
893 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
895 if ( mesh->MaxShapeIndex() < SolidID )
896 THROW_SALOME_CORBA_EXCEPTION("Invalid SolidID", SALOME::BAD_PARAM);
898 TopoDS_Shape shape = mesh->IndexToShape( SolidID );
899 if ( shape.ShapeType() != TopAbs_SOLID &&
900 shape.ShapeType() != TopAbs_SHELL)
901 THROW_SALOME_CORBA_EXCEPTION("Invalid SolidID", SALOME::BAD_PARAM);
903 mesh->SetNodeInVolume( node, SolidID );
905 // myMesh->SetIsModified( true ); - SetNodeInVolume() can't prevent re-compute, I believe
908 //=============================================================================
910 * \brief Bind an element to a shape
911 * \param ElementID - element ID
912 * \param ShapeID - shape ID available through GEOM_Object.GetSubShapeIndices()[0]
913 * \retval boolean - false if ElementID or ShapeID is invalid
915 //=============================================================================
917 void SMESH_MeshEditor_i::SetMeshElementOnShape(CORBA::Long ElementID,
919 throw (SALOME::SALOME_Exception)
921 Unexpect aCatch(SALOME_SalomeException);
923 SMESHDS_Mesh * mesh = GetMeshDS();
924 SMDS_MeshElement* elem = const_cast<SMDS_MeshElement*>(mesh->FindElement(ElementID));
926 THROW_SALOME_CORBA_EXCEPTION("Invalid ElementID", SALOME::BAD_PARAM);
928 if ( mesh->MaxShapeIndex() < ShapeID )
929 THROW_SALOME_CORBA_EXCEPTION("Invalid ShapeID", SALOME::BAD_PARAM);
931 TopoDS_Shape shape = mesh->IndexToShape( ShapeID );
932 if ( shape.ShapeType() != TopAbs_EDGE &&
933 shape.ShapeType() != TopAbs_FACE &&
934 shape.ShapeType() != TopAbs_SOLID &&
935 shape.ShapeType() != TopAbs_SHELL )
936 THROW_SALOME_CORBA_EXCEPTION("Invalid shape type", SALOME::BAD_PARAM);
938 mesh->SetMeshElementOnShape( elem, ShapeID );
940 myMesh->SetIsModified( true );
943 //=============================================================================
947 //=============================================================================
949 CORBA::Boolean SMESH_MeshEditor_i::InverseDiag(CORBA::Long NodeID1,
954 const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
955 const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
959 // Update Python script
960 TPythonDump() << "isDone = " << this << ".InverseDiag( "
961 << NodeID1 << ", " << NodeID2 << " )";
964 ::SMESH_MeshEditor aMeshEditor( myMesh );
965 int ret = aMeshEditor.InverseDiag ( n1, n2 );
966 myMesh->GetMeshDS()->Modified();
967 myMesh->SetIsModified( true );
971 //=============================================================================
975 //=============================================================================
977 CORBA::Boolean SMESH_MeshEditor_i::DeleteDiag(CORBA::Long NodeID1,
982 const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
983 const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
987 // Update Python script
988 TPythonDump() << "isDone = " << this << ".DeleteDiag( "
989 << NodeID1 << ", " << NodeID2 << " )";
991 ::SMESH_MeshEditor aMeshEditor( myMesh );
993 bool stat = aMeshEditor.DeleteDiag ( n1, n2 );
995 myMesh->GetMeshDS()->Modified();
997 myMesh->SetIsModified( true ); // issue 0020693
999 storeResult(aMeshEditor);
1004 //=============================================================================
1008 //=============================================================================
1010 CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::long_array & IDsOfElements)
1014 ::SMESH_MeshEditor anEditor( myMesh );
1015 for (int i = 0; i < IDsOfElements.length(); i++)
1017 CORBA::Long index = IDsOfElements[i];
1018 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
1020 anEditor.Reorient( elem );
1022 // Update Python script
1023 TPythonDump() << "isDone = " << this << ".Reorient( " << IDsOfElements << " )";
1025 myMesh->GetMeshDS()->Modified();
1026 if ( IDsOfElements.length() )
1027 myMesh->SetIsModified( true ); // issue 0020693
1033 //=============================================================================
1037 //=============================================================================
1039 CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theObject)
1043 TPythonDump aTPythonDump; // suppress dump in Reorient()
1045 SMESH::long_array_var anElementsId = theObject->GetIDs();
1046 CORBA::Boolean isDone = Reorient(anElementsId);
1048 // Update Python script
1049 aTPythonDump << "isDone = " << this << ".ReorientObject( " << theObject << " )";
1054 //=============================================================================
1058 //=============================================================================
1059 CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfElements,
1060 SMESH::NumericalFunctor_ptr Criterion,
1061 CORBA::Double MaxAngle)
1065 SMESHDS_Mesh* aMesh = GetMeshDS();
1066 TIDSortedElemSet faces;
1067 arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
1069 SMESH::NumericalFunctor_i* aNumericalFunctor =
1070 dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
1071 SMESH::Controls::NumericalFunctorPtr aCrit;
1072 if ( !aNumericalFunctor )
1073 aCrit.reset( new SMESH::Controls::AspectRatio() );
1075 aCrit = aNumericalFunctor->GetNumericalFunctor();
1077 // Update Python script
1078 TPythonDump() << "isDone = " << this << ".TriToQuad( "
1079 << IDsOfElements << ", " << aNumericalFunctor << ", " << MaxAngle << " )";
1081 ::SMESH_MeshEditor anEditor( myMesh );
1083 bool stat = anEditor.TriToQuad( faces, aCrit, MaxAngle );
1084 myMesh->GetMeshDS()->Modified();
1086 myMesh->SetIsModified( true ); // issue 0020693
1088 storeResult(anEditor);
1094 //=============================================================================
1098 //=============================================================================
1099 CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr theObject,
1100 SMESH::NumericalFunctor_ptr Criterion,
1101 CORBA::Double MaxAngle)
1105 TPythonDump aTPythonDump; // suppress dump in TriToQuad()
1106 SMESH::long_array_var anElementsId = theObject->GetIDs();
1107 CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
1109 SMESH::NumericalFunctor_i* aNumericalFunctor =
1110 SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
1112 // Update Python script
1113 aTPythonDump << "isDone = " << this << ".TriToQuadObject("
1114 << theObject << ", " << aNumericalFunctor << ", " << MaxAngle << " )";
1120 //=============================================================================
1124 //=============================================================================
1125 CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array & IDsOfElements,
1126 SMESH::NumericalFunctor_ptr Criterion)
1130 SMESHDS_Mesh* aMesh = GetMeshDS();
1131 TIDSortedElemSet faces;
1132 arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
1134 SMESH::NumericalFunctor_i* aNumericalFunctor =
1135 dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
1136 SMESH::Controls::NumericalFunctorPtr aCrit;
1137 if ( !aNumericalFunctor )
1138 aCrit.reset( new SMESH::Controls::AspectRatio() );
1140 aCrit = aNumericalFunctor->GetNumericalFunctor();
1143 // Update Python script
1144 TPythonDump() << "isDone = " << this << ".QuadToTri( " << IDsOfElements << ", " << aNumericalFunctor << " )";
1146 ::SMESH_MeshEditor anEditor( myMesh );
1147 CORBA::Boolean stat = anEditor.QuadToTri( faces, aCrit );
1148 myMesh->GetMeshDS()->Modified();
1150 myMesh->SetIsModified( true ); // issue 0020693
1152 storeResult(anEditor);
1158 //=============================================================================
1162 //=============================================================================
1163 CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr theObject,
1164 SMESH::NumericalFunctor_ptr Criterion)
1168 TPythonDump aTPythonDump; // suppress dump in QuadToTri()
1170 SMESH::long_array_var anElementsId = theObject->GetIDs();
1171 CORBA::Boolean isDone = QuadToTri(anElementsId, Criterion);
1173 SMESH::NumericalFunctor_i* aNumericalFunctor =
1174 SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
1176 // Update Python script
1177 aTPythonDump << "isDone = " << this << ".QuadToTriObject( " << theObject << ", " << aNumericalFunctor << " )";
1183 //=============================================================================
1187 //=============================================================================
1188 CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfElements,
1189 CORBA::Boolean Diag13)
1193 SMESHDS_Mesh* aMesh = GetMeshDS();
1194 TIDSortedElemSet faces;
1195 arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
1197 // Update Python script
1198 TPythonDump() << "isDone = " << this << ".SplitQuad( "
1199 << IDsOfElements << ", " << Diag13 << " )";
1201 ::SMESH_MeshEditor anEditor( myMesh );
1202 CORBA::Boolean stat = anEditor.QuadToTri( faces, Diag13 );
1203 myMesh->GetMeshDS()->Modified();
1205 myMesh->SetIsModified( true ); // issue 0020693
1208 storeResult(anEditor);
1214 //=============================================================================
1218 //=============================================================================
1219 CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr theObject,
1220 CORBA::Boolean Diag13)
1224 TPythonDump aTPythonDump; // suppress dump in SplitQuad()
1226 SMESH::long_array_var anElementsId = theObject->GetIDs();
1227 CORBA::Boolean isDone = SplitQuad(anElementsId, Diag13);
1229 // Update Python script
1230 aTPythonDump << "isDone = " << this << ".SplitQuadObject( "
1231 << theObject << ", " << Diag13 << " )";
1237 //=============================================================================
1241 //=============================================================================
1242 CORBA::Long SMESH_MeshEditor_i::BestSplit (CORBA::Long IDOfQuad,
1243 SMESH::NumericalFunctor_ptr Criterion)
1247 const SMDS_MeshElement* quad = GetMeshDS()->FindElement(IDOfQuad);
1248 if (quad && quad->GetType() == SMDSAbs_Face && quad->NbNodes() == 4)
1250 SMESH::NumericalFunctor_i* aNumericalFunctor =
1251 dynamic_cast<SMESH::NumericalFunctor_i*>(SMESH_Gen_i::GetServant(Criterion).in());
1252 SMESH::Controls::NumericalFunctorPtr aCrit;
1253 if (aNumericalFunctor)
1254 aCrit = aNumericalFunctor->GetNumericalFunctor();
1256 aCrit.reset(new SMESH::Controls::AspectRatio());
1258 ::SMESH_MeshEditor anEditor (myMesh);
1259 return anEditor.BestSplit(quad, aCrit);
1264 //================================================================================
1266 * \brief Split volumic elements into tetrahedrons
1268 //================================================================================
1270 void SMESH_MeshEditor_i::SplitVolumesIntoTetra (SMESH::SMESH_IDSource_ptr elems,
1271 CORBA::Short methodFlags)
1272 throw (SALOME::SALOME_Exception)
1274 Unexpect aCatch(SALOME_SalomeException);
1278 SMESH::long_array_var anElementsId = elems->GetIDs();
1279 TIDSortedElemSet elemSet;
1280 arrayToSet( anElementsId, GetMeshDS(), elemSet, SMDSAbs_Volume );
1282 ::SMESH_MeshEditor anEditor (myMesh);
1283 anEditor.SplitVolumesIntoTetra( elemSet, int( methodFlags ));
1284 myMesh->GetMeshDS()->Modified();
1286 storeResult(anEditor);
1288 // if ( myLastCreatedElems.length() ) - it does not influence Compute()
1289 // myMesh->SetIsModified( true ); // issue 0020693
1291 TPythonDump() << this << ".SplitVolumesIntoTetra( "
1292 << elems << ", " << methodFlags << " )";
1295 //=======================================================================
1298 //=======================================================================
1301 SMESH_MeshEditor_i::Smooth(const SMESH::long_array & IDsOfElements,
1302 const SMESH::long_array & IDsOfFixedNodes,
1303 CORBA::Long MaxNbOfIterations,
1304 CORBA::Double MaxAspectRatio,
1305 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1307 return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations,
1308 MaxAspectRatio, Method, false );
1312 //=======================================================================
1313 //function : SmoothParametric
1315 //=======================================================================
1318 SMESH_MeshEditor_i::SmoothParametric(const SMESH::long_array & IDsOfElements,
1319 const SMESH::long_array & IDsOfFixedNodes,
1320 CORBA::Long MaxNbOfIterations,
1321 CORBA::Double MaxAspectRatio,
1322 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1324 return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations,
1325 MaxAspectRatio, Method, true );
1329 //=======================================================================
1330 //function : SmoothObject
1332 //=======================================================================
1335 SMESH_MeshEditor_i::SmoothObject(SMESH::SMESH_IDSource_ptr theObject,
1336 const SMESH::long_array & IDsOfFixedNodes,
1337 CORBA::Long MaxNbOfIterations,
1338 CORBA::Double MaxAspectRatio,
1339 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1341 return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations,
1342 MaxAspectRatio, Method, false);
1346 //=======================================================================
1347 //function : SmoothParametricObject
1349 //=======================================================================
1352 SMESH_MeshEditor_i::SmoothParametricObject(SMESH::SMESH_IDSource_ptr theObject,
1353 const SMESH::long_array & IDsOfFixedNodes,
1354 CORBA::Long MaxNbOfIterations,
1355 CORBA::Double MaxAspectRatio,
1356 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1358 return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations,
1359 MaxAspectRatio, Method, true);
1363 //=============================================================================
1367 //=============================================================================
1370 SMESH_MeshEditor_i::smooth(const SMESH::long_array & IDsOfElements,
1371 const SMESH::long_array & IDsOfFixedNodes,
1372 CORBA::Long MaxNbOfIterations,
1373 CORBA::Double MaxAspectRatio,
1374 SMESH::SMESH_MeshEditor::Smooth_Method Method,
1379 SMESHDS_Mesh* aMesh = GetMeshDS();
1381 TIDSortedElemSet elements;
1382 arrayToSet(IDsOfElements, aMesh, elements, SMDSAbs_Face);
1384 set<const SMDS_MeshNode*> fixedNodes;
1385 for (int i = 0; i < IDsOfFixedNodes.length(); i++) {
1386 CORBA::Long index = IDsOfFixedNodes[i];
1387 const SMDS_MeshNode * node = aMesh->FindNode(index);
1389 fixedNodes.insert( node );
1391 ::SMESH_MeshEditor::SmoothMethod method = ::SMESH_MeshEditor::LAPLACIAN;
1392 if ( Method != SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH )
1393 method = ::SMESH_MeshEditor::CENTROIDAL;
1395 ::SMESH_MeshEditor anEditor( myMesh );
1396 anEditor.Smooth(elements, fixedNodes, method,
1397 MaxNbOfIterations, MaxAspectRatio, IsParametric );
1399 myMesh->GetMeshDS()->Modified();
1400 myMesh->SetIsModified( true ); // issue 0020693
1402 storeResult(anEditor);
1404 // Update Python script
1405 TPythonDump() << "isDone = " << this << "."
1406 << (IsParametric ? "SmoothParametric( " : "Smooth( ")
1407 << IDsOfElements << ", " << IDsOfFixedNodes << ", "
1408 << MaxNbOfIterations << ", " << MaxAspectRatio << ", "
1409 << "SMESH.SMESH_MeshEditor."
1410 << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
1411 "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
1417 //=============================================================================
1421 //=============================================================================
1424 SMESH_MeshEditor_i::smoothObject(SMESH::SMESH_IDSource_ptr theObject,
1425 const SMESH::long_array & IDsOfFixedNodes,
1426 CORBA::Long MaxNbOfIterations,
1427 CORBA::Double MaxAspectRatio,
1428 SMESH::SMESH_MeshEditor::Smooth_Method Method,
1433 TPythonDump aTPythonDump; // suppress dump in smooth()
1435 SMESH::long_array_var anElementsId = theObject->GetIDs();
1436 CORBA::Boolean isDone = smooth (anElementsId, IDsOfFixedNodes, MaxNbOfIterations,
1437 MaxAspectRatio, Method, IsParametric);
1439 // Update Python script
1440 aTPythonDump << "isDone = " << this << "."
1441 << (IsParametric ? "SmoothParametricObject( " : "SmoothObject( ")
1442 << theObject << ", " << IDsOfFixedNodes << ", "
1443 << MaxNbOfIterations << ", " << MaxAspectRatio << ", "
1444 << "SMESH.SMESH_MeshEditor."
1445 << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
1446 "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
1452 //=============================================================================
1456 //=============================================================================
1458 void SMESH_MeshEditor_i::RenumberNodes()
1460 // Update Python script
1461 TPythonDump() << this << ".RenumberNodes()";
1463 GetMeshDS()->Renumber( true );
1467 //=============================================================================
1471 //=============================================================================
1473 void SMESH_MeshEditor_i::RenumberElements()
1475 // Update Python script
1476 TPythonDump() << this << ".RenumberElements()";
1478 GetMeshDS()->Renumber( false );
1481 //=======================================================================
1483 * \brief Return groups by their IDs
1485 //=======================================================================
1487 SMESH::ListOfGroups* SMESH_MeshEditor_i::getGroups(const std::list<int>* groupIDs)
1491 myMesh_i->CreateGroupServants();
1492 return myMesh_i->GetGroups( *groupIDs );
1495 //=======================================================================
1496 //function : rotationSweep
1498 //=======================================================================
1500 SMESH::ListOfGroups*
1501 SMESH_MeshEditor_i::rotationSweep(const SMESH::long_array & theIDsOfElements,
1502 const SMESH::AxisStruct & theAxis,
1503 CORBA::Double theAngleInRadians,
1504 CORBA::Long theNbOfSteps,
1505 CORBA::Double theTolerance,
1506 const bool theMakeGroups,
1507 const SMDSAbs_ElementType theElementType)
1511 TIDSortedElemSet inElements, copyElements;
1512 arrayToSet(theIDsOfElements, GetMeshDS(), inElements, theElementType);
1514 TIDSortedElemSet* workElements = & inElements;
1515 TPreviewMesh tmpMesh( SMDSAbs_Face );
1516 SMESH_Mesh* mesh = 0;
1517 bool makeWalls=true;
1518 if ( myPreviewMode )
1520 SMDSAbs_ElementType select = SMDSAbs_All, avoid = SMDSAbs_Volume;
1521 tmpMesh.Copy( inElements, copyElements, select, avoid );
1523 workElements = & copyElements;
1524 //makeWalls = false;
1531 gp_Ax1 Ax1 (gp_Pnt( theAxis.x, theAxis.y, theAxis.z ),
1532 gp_Vec( theAxis.vx, theAxis.vy, theAxis.vz ));
1534 ::SMESH_MeshEditor anEditor( mesh );
1535 ::SMESH_MeshEditor::PGroupIDs groupIds =
1536 anEditor.RotationSweep (*workElements, Ax1, theAngleInRadians,
1537 theNbOfSteps, theTolerance, theMakeGroups, makeWalls);
1538 storeResult(anEditor);
1539 myMesh->GetMeshDS()->Modified();
1541 // myMesh->SetIsModified( true ); -- it does not influence Compute()
1543 return theMakeGroups ? getGroups(groupIds.get()) : 0;
1546 //=======================================================================
1547 //function : RotationSweep
1549 //=======================================================================
1551 void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElements,
1552 const SMESH::AxisStruct & theAxis,
1553 CORBA::Double theAngleInRadians,
1554 CORBA::Long theNbOfSteps,
1555 CORBA::Double theTolerance)
1557 if ( !myPreviewMode ) {
1558 TPythonDump() << this << ".RotationSweep( "
1559 << theIDsOfElements << ", "
1561 << theAngleInRadians << ", "
1562 << theNbOfSteps << ", "
1563 << theTolerance << " )";
1565 rotationSweep(theIDsOfElements,
1573 //=======================================================================
1574 //function : RotationSweepMakeGroups
1576 //=======================================================================
1578 SMESH::ListOfGroups*
1579 SMESH_MeshEditor_i::RotationSweepMakeGroups(const SMESH::long_array& theIDsOfElements,
1580 const SMESH::AxisStruct& theAxis,
1581 CORBA::Double theAngleInRadians,
1582 CORBA::Long theNbOfSteps,
1583 CORBA::Double theTolerance)
1585 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
1587 SMESH::ListOfGroups *aGroups = rotationSweep(theIDsOfElements,
1593 if (!myPreviewMode) {
1594 DumpGroupsList(aPythonDump, aGroups);
1595 aPythonDump << this << ".RotationSweepMakeGroups( "
1596 << theIDsOfElements << ", "
1598 << theAngleInRadians << ", "
1599 << theNbOfSteps << ", "
1600 << theTolerance << " )";
1605 //=======================================================================
1606 //function : RotationSweepObject
1608 //=======================================================================
1610 void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject,
1611 const SMESH::AxisStruct & theAxis,
1612 CORBA::Double theAngleInRadians,
1613 CORBA::Long theNbOfSteps,
1614 CORBA::Double theTolerance)
1616 if ( !myPreviewMode ) {
1617 TPythonDump() << this << ".RotationSweepObject( "
1618 << theObject << ", "
1620 << theAngleInRadians << ", "
1621 << theNbOfSteps << ", "
1622 << theTolerance << " )";
1624 SMESH::long_array_var anElementsId = theObject->GetIDs();
1625 rotationSweep(anElementsId,
1633 //=======================================================================
1634 //function : RotationSweepObject1D
1636 //=======================================================================
1638 void SMESH_MeshEditor_i::RotationSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
1639 const SMESH::AxisStruct & theAxis,
1640 CORBA::Double theAngleInRadians,
1641 CORBA::Long theNbOfSteps,
1642 CORBA::Double theTolerance)
1644 if ( !myPreviewMode ) {
1645 TPythonDump() << this << ".RotationSweepObject1D( "
1646 << theObject << ", "
1648 << theAngleInRadians << ", "
1649 << theNbOfSteps << ", "
1650 << theTolerance << " )";
1652 SMESH::long_array_var anElementsId = theObject->GetIDs();
1653 rotationSweep(anElementsId,
1662 //=======================================================================
1663 //function : RotationSweepObject2D
1665 //=======================================================================
1667 void SMESH_MeshEditor_i::RotationSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
1668 const SMESH::AxisStruct & theAxis,
1669 CORBA::Double theAngleInRadians,
1670 CORBA::Long theNbOfSteps,
1671 CORBA::Double theTolerance)
1673 if ( !myPreviewMode ) {
1674 TPythonDump() << this << ".RotationSweepObject2D( "
1675 << theObject << ", "
1677 << theAngleInRadians << ", "
1678 << theNbOfSteps << ", "
1679 << theTolerance << " )";
1681 SMESH::long_array_var anElementsId = theObject->GetIDs();
1682 rotationSweep(anElementsId,
1691 //=======================================================================
1692 //function : RotationSweepObjectMakeGroups
1694 //=======================================================================
1696 SMESH::ListOfGroups*
1697 SMESH_MeshEditor_i::RotationSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1698 const SMESH::AxisStruct& theAxis,
1699 CORBA::Double theAngleInRadians,
1700 CORBA::Long theNbOfSteps,
1701 CORBA::Double theTolerance)
1703 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
1705 SMESH::long_array_var anElementsId = theObject->GetIDs();
1706 SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
1712 if (!myPreviewMode) {
1713 DumpGroupsList(aPythonDump, aGroups);
1714 aPythonDump << this << ".RotationSweepObjectMakeGroups( "
1715 << theObject << ", "
1717 << theAngleInRadians << ", "
1718 << theNbOfSteps << ", "
1719 << theTolerance << " )";
1724 //=======================================================================
1725 //function : RotationSweepObject1DMakeGroups
1727 //=======================================================================
1729 SMESH::ListOfGroups*
1730 SMESH_MeshEditor_i::RotationSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1731 const SMESH::AxisStruct& theAxis,
1732 CORBA::Double theAngleInRadians,
1733 CORBA::Long theNbOfSteps,
1734 CORBA::Double theTolerance)
1736 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
1738 SMESH::long_array_var anElementsId = theObject->GetIDs();
1739 SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
1746 if (!myPreviewMode) {
1747 DumpGroupsList(aPythonDump, aGroups);
1748 aPythonDump << this << ".RotationSweepObject1DMakeGroups( "
1749 << theObject << ", "
1751 << theAngleInRadians << ", "
1752 << theNbOfSteps << ", "
1753 << theTolerance << " )";
1758 //=======================================================================
1759 //function : RotationSweepObject2DMakeGroups
1761 //=======================================================================
1763 SMESH::ListOfGroups*
1764 SMESH_MeshEditor_i::RotationSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1765 const SMESH::AxisStruct& theAxis,
1766 CORBA::Double theAngleInRadians,
1767 CORBA::Long theNbOfSteps,
1768 CORBA::Double theTolerance)
1770 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
1772 SMESH::long_array_var anElementsId = theObject->GetIDs();
1773 SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
1780 if (!myPreviewMode) {
1781 DumpGroupsList(aPythonDump, aGroups);
1782 aPythonDump << this << ".RotationSweepObject2DMakeGroups( "
1783 << theObject << ", "
1785 << theAngleInRadians << ", "
1786 << theNbOfSteps << ", "
1787 << theTolerance << " )";
1793 //=======================================================================
1794 //function : extrusionSweep
1796 //=======================================================================
1798 SMESH::ListOfGroups*
1799 SMESH_MeshEditor_i::extrusionSweep(const SMESH::long_array & theIDsOfElements,
1800 const SMESH::DirStruct & theStepVector,
1801 CORBA::Long theNbOfSteps,
1802 const bool theMakeGroups,
1803 const SMDSAbs_ElementType theElementType)
1811 TIDSortedElemSet elements, copyElements;
1812 arrayToSet(theIDsOfElements, GetMeshDS(), elements, theElementType);
1814 const SMESH::PointStruct * P = &theStepVector.PS;
1815 gp_Vec stepVec( P->x, P->y, P->z );
1817 TIDSortedElemSet* workElements = & elements;
1818 TPreviewMesh tmpMesh( SMDSAbs_Face );
1819 SMESH_Mesh* mesh = 0;
1821 if ( myPreviewMode ) {
1822 SMDSAbs_ElementType select = SMDSAbs_All, avoid = SMDSAbs_Volume;
1823 tmpMesh.Copy( elements, copyElements, select, avoid );
1825 workElements = & copyElements;
1831 TElemOfElemListMap aHystory;
1832 ::SMESH_MeshEditor anEditor( mesh );
1833 ::SMESH_MeshEditor::PGroupIDs groupIds =
1834 anEditor.ExtrusionSweep (*workElements, stepVec, theNbOfSteps, aHystory, theMakeGroups);
1836 myMesh->GetMeshDS()->Modified();
1837 storeResult(anEditor);
1839 return theMakeGroups ? getGroups(groupIds.get()) : 0;
1841 } catch(Standard_Failure) {
1842 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1843 INFOS( "SMESH_MeshEditor_i::ExtrusionSweep fails - "<< aFail->GetMessageString() );
1848 //=======================================================================
1849 //function : ExtrusionSweep
1851 //=======================================================================
1853 void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElements,
1854 const SMESH::DirStruct & theStepVector,
1855 CORBA::Long theNbOfSteps)
1857 extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false );
1858 if (!myPreviewMode) {
1859 TPythonDump() << this << ".ExtrusionSweep( "
1860 << theIDsOfElements << ", " << theStepVector <<", " << theNbOfSteps << " )";
1865 //=======================================================================
1866 //function : ExtrusionSweepObject
1868 //=======================================================================
1870 void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObject,
1871 const SMESH::DirStruct & theStepVector,
1872 CORBA::Long theNbOfSteps)
1874 SMESH::long_array_var anElementsId = theObject->GetIDs();
1875 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false );
1876 if (!myPreviewMode) {
1877 TPythonDump() << this << ".ExtrusionSweepObject( "
1878 << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
1882 //=======================================================================
1883 //function : ExtrusionSweepObject1D
1885 //=======================================================================
1887 void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
1888 const SMESH::DirStruct & theStepVector,
1889 CORBA::Long theNbOfSteps)
1891 SMESH::long_array_var anElementsId = theObject->GetIDs();
1892 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Edge );
1893 if ( !myPreviewMode ) {
1894 TPythonDump() << this << ".ExtrusionSweepObject1D( "
1895 << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
1899 //=======================================================================
1900 //function : ExtrusionSweepObject2D
1902 //=======================================================================
1904 void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
1905 const SMESH::DirStruct & theStepVector,
1906 CORBA::Long theNbOfSteps)
1908 SMESH::long_array_var anElementsId = theObject->GetIDs();
1909 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Face );
1910 if ( !myPreviewMode ) {
1911 TPythonDump() << this << ".ExtrusionSweepObject2D( "
1912 << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
1916 //=======================================================================
1917 //function : ExtrusionSweepMakeGroups
1919 //=======================================================================
1921 SMESH::ListOfGroups*
1922 SMESH_MeshEditor_i::ExtrusionSweepMakeGroups(const SMESH::long_array& theIDsOfElements,
1923 const SMESH::DirStruct& theStepVector,
1924 CORBA::Long theNbOfSteps)
1926 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
1928 SMESH::ListOfGroups* aGroups = extrusionSweep(theIDsOfElements, theStepVector, theNbOfSteps, true);
1930 if (!myPreviewMode) {
1931 DumpGroupsList(aPythonDump, aGroups);
1932 aPythonDump << this << ".ExtrusionSweepMakeGroups( " << theIDsOfElements
1933 << ", " << theStepVector <<", " << theNbOfSteps << " )";
1938 //=======================================================================
1939 //function : ExtrusionSweepObjectMakeGroups
1941 //=======================================================================
1943 SMESH::ListOfGroups*
1944 SMESH_MeshEditor_i::ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1945 const SMESH::DirStruct& theStepVector,
1946 CORBA::Long theNbOfSteps)
1948 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
1950 SMESH::long_array_var anElementsId = theObject->GetIDs();
1951 SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector, theNbOfSteps, true);
1953 if (!myPreviewMode) {
1954 DumpGroupsList(aPythonDump, aGroups);
1955 aPythonDump << this << ".ExtrusionSweepObjectMakeGroups( " << theObject
1956 << ", " << theStepVector << ", " << theNbOfSteps << " )";
1961 //=======================================================================
1962 //function : ExtrusionSweepObject1DMakeGroups
1964 //=======================================================================
1966 SMESH::ListOfGroups*
1967 SMESH_MeshEditor_i::ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1968 const SMESH::DirStruct& theStepVector,
1969 CORBA::Long theNbOfSteps)
1971 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
1973 SMESH::long_array_var anElementsId = theObject->GetIDs();
1974 SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector,
1975 theNbOfSteps, true, SMDSAbs_Edge);
1976 if (!myPreviewMode) {
1977 DumpGroupsList(aPythonDump, aGroups);
1978 aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( " << theObject
1979 << ", " << theStepVector << ", " << theNbOfSteps << " )";
1984 //=======================================================================
1985 //function : ExtrusionSweepObject2DMakeGroups
1987 //=======================================================================
1989 SMESH::ListOfGroups*
1990 SMESH_MeshEditor_i::ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1991 const SMESH::DirStruct& theStepVector,
1992 CORBA::Long theNbOfSteps)
1994 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
1996 SMESH::long_array_var anElementsId = theObject->GetIDs();
1997 SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector,
1998 theNbOfSteps, true, SMDSAbs_Face);
1999 if (!myPreviewMode) {
2000 DumpGroupsList(aPythonDump, aGroups);
2001 aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( " << theObject
2002 << ", " << theStepVector << ", " << theNbOfSteps << " )";
2008 //=======================================================================
2009 //function : advancedExtrusion
2011 //=======================================================================
2013 SMESH::ListOfGroups*
2014 SMESH_MeshEditor_i::advancedExtrusion(const SMESH::long_array & theIDsOfElements,
2015 const SMESH::DirStruct & theStepVector,
2016 CORBA::Long theNbOfSteps,
2017 CORBA::Long theExtrFlags,
2018 CORBA::Double theSewTolerance,
2019 const bool theMakeGroups)
2023 TIDSortedElemSet elements;
2024 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
2026 const SMESH::PointStruct * P = &theStepVector.PS;
2027 gp_Vec stepVec( P->x, P->y, P->z );
2029 ::SMESH_MeshEditor anEditor( myMesh );
2030 TElemOfElemListMap aHystory;
2031 ::SMESH_MeshEditor::PGroupIDs groupIds =
2032 anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory,
2033 theMakeGroups, theExtrFlags, theSewTolerance);
2034 storeResult(anEditor);
2036 return theMakeGroups ? getGroups(groupIds.get()) : 0;
2039 //=======================================================================
2040 //function : AdvancedExtrusion
2042 //=======================================================================
2044 void SMESH_MeshEditor_i::AdvancedExtrusion(const SMESH::long_array & theIDsOfElements,
2045 const SMESH::DirStruct & theStepVector,
2046 CORBA::Long theNbOfSteps,
2047 CORBA::Long theExtrFlags,
2048 CORBA::Double theSewTolerance)
2050 if ( !myPreviewMode ) {
2051 TPythonDump() << "stepVector = " << theStepVector;
2052 TPythonDump() << this << ".AdvancedExtrusion("
2055 << theNbOfSteps << ","
2056 << theExtrFlags << ", "
2057 << theSewTolerance << " )";
2059 advancedExtrusion( theIDsOfElements,
2067 //=======================================================================
2068 //function : AdvancedExtrusionMakeGroups
2070 //=======================================================================
2071 SMESH::ListOfGroups*
2072 SMESH_MeshEditor_i::AdvancedExtrusionMakeGroups(const SMESH::long_array& theIDsOfElements,
2073 const SMESH::DirStruct& theStepVector,
2074 CORBA::Long theNbOfSteps,
2075 CORBA::Long theExtrFlags,
2076 CORBA::Double theSewTolerance)
2078 if (!myPreviewMode) {
2079 TPythonDump() << "stepVector = " << theStepVector;
2081 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2083 SMESH::ListOfGroups * aGroups = advancedExtrusion( theIDsOfElements,
2090 if (!myPreviewMode) {
2091 DumpGroupsList(aPythonDump, aGroups);
2092 aPythonDump << this << ".AdvancedExtrusionMakeGroups("
2095 << theNbOfSteps << ","
2096 << theExtrFlags << ", "
2097 << theSewTolerance << " )";
2103 //================================================================================
2105 * \brief Convert extrusion error to IDL enum
2107 //================================================================================
2109 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
2111 static SMESH::SMESH_MeshEditor::Extrusion_Error convExtrError( const::SMESH_MeshEditor::Extrusion_Error e )
2115 RETCASE( EXTR_NO_ELEMENTS );
2116 RETCASE( EXTR_PATH_NOT_EDGE );
2117 RETCASE( EXTR_BAD_PATH_SHAPE );
2118 RETCASE( EXTR_BAD_STARTING_NODE );
2119 RETCASE( EXTR_BAD_ANGLES_NUMBER );
2120 RETCASE( EXTR_CANT_GET_TANGENT );
2122 return SMESH::SMESH_MeshEditor::EXTR_OK;
2126 //=======================================================================
2127 //function : extrusionAlongPath
2129 //=======================================================================
2130 SMESH::ListOfGroups*
2131 SMESH_MeshEditor_i::extrusionAlongPath(const SMESH::long_array & theIDsOfElements,
2132 SMESH::SMESH_Mesh_ptr thePathMesh,
2133 GEOM::GEOM_Object_ptr thePathShape,
2134 CORBA::Long theNodeStart,
2135 CORBA::Boolean theHasAngles,
2136 const SMESH::double_array & theAngles,
2137 CORBA::Boolean theHasRefPoint,
2138 const SMESH::PointStruct & theRefPoint,
2139 const bool theMakeGroups,
2140 SMESH::SMESH_MeshEditor::Extrusion_Error & theError,
2141 const SMDSAbs_ElementType theElementType)
2143 MESSAGE("extrusionAlongPath");
2146 if ( thePathMesh->_is_nil() || thePathShape->_is_nil() ) {
2147 theError = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
2150 SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( thePathMesh );
2152 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
2153 SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
2155 if ( !aSubMesh || !aSubMesh->GetSubMeshDS()) {
2156 theError = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
2160 SMDS_MeshNode* nodeStart = (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(theNodeStart);
2162 theError = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
2166 TIDSortedElemSet elements;
2167 arrayToSet(theIDsOfElements, GetMeshDS(), elements, theElementType);
2169 list<double> angles;
2170 for (int i = 0; i < theAngles.length(); i++) {
2171 angles.push_back( theAngles[i] );
2174 gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z );
2176 int nbOldGroups = myMesh->NbGroup();
2178 ::SMESH_MeshEditor anEditor( myMesh );
2179 ::SMESH_MeshEditor::Extrusion_Error error =
2180 anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart,
2181 theHasAngles, angles, false,
2182 theHasRefPoint, refPnt, theMakeGroups );
2183 myMesh->GetMeshDS()->Modified();
2184 storeResult(anEditor);
2185 theError = convExtrError( error );
2187 if ( theMakeGroups ) {
2188 list<int> groupIDs = myMesh->GetGroupIds();
2189 list<int>::iterator newBegin = groupIDs.begin();
2190 std::advance( newBegin, nbOldGroups ); // skip old groups
2191 groupIDs.erase( groupIDs.begin(), newBegin );
2192 return getGroups( & groupIDs );
2198 //=======================================================================
2199 //function : extrusionAlongPathX
2201 //=======================================================================
2202 SMESH::ListOfGroups*
2203 SMESH_MeshEditor_i::extrusionAlongPathX(const SMESH::long_array & IDsOfElements,
2204 SMESH::SMESH_IDSource_ptr Path,
2205 CORBA::Long NodeStart,
2206 CORBA::Boolean HasAngles,
2207 const SMESH::double_array& Angles,
2208 CORBA::Boolean LinearVariation,
2209 CORBA::Boolean HasRefPoint,
2210 const SMESH::PointStruct& RefPoint,
2211 const bool MakeGroups,
2212 const SMDSAbs_ElementType ElementType,
2213 SMESH::SMESH_MeshEditor::Extrusion_Error & Error)
2215 SMESH::ListOfGroups* EmptyGr = new SMESH::ListOfGroups;
2219 list<double> angles;
2220 for (int i = 0; i < Angles.length(); i++) {
2221 angles.push_back( Angles[i] );
2223 gp_Pnt refPnt( RefPoint.x, RefPoint.y, RefPoint.z );
2224 int nbOldGroups = myMesh->NbGroup();
2226 if ( Path->_is_nil() ) {
2227 Error = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
2231 TIDSortedElemSet elements, copyElements;
2232 arrayToSet(IDsOfElements, GetMeshDS(), elements, ElementType);
2234 TIDSortedElemSet* workElements = &elements;
2235 TPreviewMesh tmpMesh( SMDSAbs_Face );
2236 SMESH_Mesh* mesh = 0;
2238 if ( myPreviewMode )
2240 SMDSAbs_ElementType select = SMDSAbs_All, avoid = SMDSAbs_Volume;
2241 tmpMesh.Copy( elements, copyElements, select, avoid );
2243 workElements = & copyElements;
2250 ::SMESH_MeshEditor anEditor( mesh );
2251 ::SMESH_MeshEditor::Extrusion_Error error;
2253 SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( Path );
2256 SMDS_MeshNode* aNodeStart =
2257 (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(NodeStart);
2258 if ( !aNodeStart ) {
2259 Error = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
2262 error = anEditor.ExtrusionAlongTrack( *workElements, &(aMeshImp->GetImpl()), aNodeStart,
2263 HasAngles, angles, LinearVariation,
2264 HasRefPoint, refPnt, MakeGroups );
2265 myMesh->GetMeshDS()->Modified();
2268 SMESH_subMesh_i* aSubMeshImp = SMESH::DownCast<SMESH_subMesh_i*>( Path );
2271 SMESH::SMESH_Mesh_ptr aPathMesh = aSubMeshImp->GetFather();
2272 aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( aPathMesh );
2273 SMDS_MeshNode* aNodeStart =
2274 (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(NodeStart);
2275 if ( !aNodeStart ) {
2276 Error = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
2279 SMESH_subMesh* aSubMesh =
2280 aMeshImp->GetImpl().GetSubMeshContaining(aSubMeshImp->GetId());
2281 error = anEditor.ExtrusionAlongTrack( *workElements, aSubMesh, aNodeStart,
2282 HasAngles, angles, LinearVariation,
2283 HasRefPoint, refPnt, MakeGroups );
2284 myMesh->GetMeshDS()->Modified();
2287 SMESH_Group_i* aGroupImp = SMESH::DownCast<SMESH_Group_i*>( Path );
2289 // path as group of 1D elements
2293 Error = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
2299 storeResult(anEditor);
2300 Error = convExtrError( error );
2303 list<int> groupIDs = myMesh->GetGroupIds();
2304 list<int>::iterator newBegin = groupIDs.begin();
2305 std::advance( newBegin, nbOldGroups ); // skip old groups
2306 groupIDs.erase( groupIDs.begin(), newBegin );
2307 return getGroups( & groupIDs );
2313 //=======================================================================
2314 //function : ExtrusionAlongPath
2316 //=======================================================================
2317 SMESH::SMESH_MeshEditor::Extrusion_Error
2318 SMESH_MeshEditor_i::ExtrusionAlongPath(const SMESH::long_array & theIDsOfElements,
2319 SMESH::SMESH_Mesh_ptr thePathMesh,
2320 GEOM::GEOM_Object_ptr thePathShape,
2321 CORBA::Long theNodeStart,
2322 CORBA::Boolean theHasAngles,
2323 const SMESH::double_array & theAngles,
2324 CORBA::Boolean theHasRefPoint,
2325 const SMESH::PointStruct & theRefPoint)
2327 MESSAGE("ExtrusionAlongPath");
2328 if ( !myPreviewMode ) {
2329 TPythonDump() << "error = " << this << ".ExtrusionAlongPath( "
2330 << theIDsOfElements << ", "
2331 << thePathMesh << ", "
2332 << thePathShape << ", "
2333 << theNodeStart << ", "
2334 << theHasAngles << ", "
2335 << theAngles << ", "
2336 << theHasRefPoint << ", "
2337 << "SMESH.PointStruct( "
2338 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2339 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2340 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2342 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
2343 extrusionAlongPath( theIDsOfElements,
2356 //=======================================================================
2357 //function : ExtrusionAlongPathObject
2359 //=======================================================================
2360 SMESH::SMESH_MeshEditor::Extrusion_Error
2361 SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject,
2362 SMESH::SMESH_Mesh_ptr thePathMesh,
2363 GEOM::GEOM_Object_ptr thePathShape,
2364 CORBA::Long theNodeStart,
2365 CORBA::Boolean theHasAngles,
2366 const SMESH::double_array & theAngles,
2367 CORBA::Boolean theHasRefPoint,
2368 const SMESH::PointStruct & theRefPoint)
2370 if ( !myPreviewMode ) {
2371 TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject( "
2372 << theObject << ", "
2373 << thePathMesh << ", "
2374 << thePathShape << ", "
2375 << theNodeStart << ", "
2376 << theHasAngles << ", "
2377 << theAngles << ", "
2378 << theHasRefPoint << ", "
2379 << "SMESH.PointStruct( "
2380 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2381 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2382 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2384 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
2385 SMESH::long_array_var anElementsId = theObject->GetIDs();
2386 extrusionAlongPath( anElementsId,
2399 //=======================================================================
2400 //function : ExtrusionAlongPathObject1D
2402 //=======================================================================
2403 SMESH::SMESH_MeshEditor::Extrusion_Error
2404 SMESH_MeshEditor_i::ExtrusionAlongPathObject1D(SMESH::SMESH_IDSource_ptr theObject,
2405 SMESH::SMESH_Mesh_ptr thePathMesh,
2406 GEOM::GEOM_Object_ptr thePathShape,
2407 CORBA::Long theNodeStart,
2408 CORBA::Boolean theHasAngles,
2409 const SMESH::double_array & theAngles,
2410 CORBA::Boolean theHasRefPoint,
2411 const SMESH::PointStruct & theRefPoint)
2413 if ( !myPreviewMode ) {
2414 TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject1D( "
2415 << theObject << ", "
2416 << thePathMesh << ", "
2417 << thePathShape << ", "
2418 << theNodeStart << ", "
2419 << theHasAngles << ", "
2420 << theAngles << ", "
2421 << theHasRefPoint << ", "
2422 << "SMESH.PointStruct( "
2423 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2424 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2425 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2427 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
2428 SMESH::long_array_var anElementsId = theObject->GetIDs();
2429 extrusionAlongPath( anElementsId,
2443 //=======================================================================
2444 //function : ExtrusionAlongPathObject2D
2446 //=======================================================================
2447 SMESH::SMESH_MeshEditor::Extrusion_Error
2448 SMESH_MeshEditor_i::ExtrusionAlongPathObject2D(SMESH::SMESH_IDSource_ptr theObject,
2449 SMESH::SMESH_Mesh_ptr thePathMesh,
2450 GEOM::GEOM_Object_ptr thePathShape,
2451 CORBA::Long theNodeStart,
2452 CORBA::Boolean theHasAngles,
2453 const SMESH::double_array & theAngles,
2454 CORBA::Boolean theHasRefPoint,
2455 const SMESH::PointStruct & theRefPoint)
2457 if ( !myPreviewMode ) {
2458 TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject2D( "
2459 << theObject << ", "
2460 << thePathMesh << ", "
2461 << thePathShape << ", "
2462 << theNodeStart << ", "
2463 << theHasAngles << ", "
2464 << theAngles << ", "
2465 << theHasRefPoint << ", "
2466 << "SMESH.PointStruct( "
2467 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2468 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2469 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2471 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
2472 SMESH::long_array_var anElementsId = theObject->GetIDs();
2473 extrusionAlongPath( anElementsId,
2488 //=======================================================================
2489 //function : ExtrusionAlongPathMakeGroups
2491 //=======================================================================
2492 SMESH::ListOfGroups*
2493 SMESH_MeshEditor_i::ExtrusionAlongPathMakeGroups(const SMESH::long_array& theIDsOfElements,
2494 SMESH::SMESH_Mesh_ptr thePathMesh,
2495 GEOM::GEOM_Object_ptr thePathShape,
2496 CORBA::Long theNodeStart,
2497 CORBA::Boolean theHasAngles,
2498 const SMESH::double_array& theAngles,
2499 CORBA::Boolean theHasRefPoint,
2500 const SMESH::PointStruct& theRefPoint,
2501 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2503 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2505 SMESH::ListOfGroups * aGroups = extrusionAlongPath( theIDsOfElements,
2515 if (!myPreviewMode) {
2516 bool isDumpGroups = aGroups && aGroups->length() > 0;
2518 aPythonDump << "(" << aGroups << ", error)";
2520 aPythonDump <<"error";
2522 aPythonDump<<" = "<< this << ".ExtrusionAlongPathMakeGroups( "
2523 << theIDsOfElements << ", "
2524 << thePathMesh << ", "
2525 << thePathShape << ", "
2526 << theNodeStart << ", "
2527 << theHasAngles << ", "
2528 << theAngles << ", "
2529 << theHasRefPoint << ", "
2530 << "SMESH.PointStruct( "
2531 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2532 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2533 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2538 //=======================================================================
2539 //function : ExtrusionAlongPathObjectMakeGroups
2541 //=======================================================================
2542 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2543 ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2544 SMESH::SMESH_Mesh_ptr thePathMesh,
2545 GEOM::GEOM_Object_ptr thePathShape,
2546 CORBA::Long theNodeStart,
2547 CORBA::Boolean theHasAngles,
2548 const SMESH::double_array& theAngles,
2549 CORBA::Boolean theHasRefPoint,
2550 const SMESH::PointStruct& theRefPoint,
2551 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2553 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2555 SMESH::long_array_var anElementsId = theObject->GetIDs();
2556 SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
2567 if (!myPreviewMode) {
2568 bool isDumpGroups = aGroups && aGroups->length() > 0;
2570 aPythonDump << "(" << aGroups << ", error)";
2572 aPythonDump <<"error";
2574 aPythonDump << " = " << this << ".ExtrusionAlongPathObjectMakeGroups( "
2575 << theObject << ", "
2576 << thePathMesh << ", "
2577 << thePathShape << ", "
2578 << theNodeStart << ", "
2579 << theHasAngles << ", "
2580 << theAngles << ", "
2581 << theHasRefPoint << ", "
2582 << "SMESH.PointStruct( "
2583 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2584 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2585 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2590 //=======================================================================
2591 //function : ExtrusionAlongPathObject1DMakeGroups
2593 //=======================================================================
2594 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2595 ExtrusionAlongPathObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2596 SMESH::SMESH_Mesh_ptr thePathMesh,
2597 GEOM::GEOM_Object_ptr thePathShape,
2598 CORBA::Long theNodeStart,
2599 CORBA::Boolean theHasAngles,
2600 const SMESH::double_array& theAngles,
2601 CORBA::Boolean theHasRefPoint,
2602 const SMESH::PointStruct& theRefPoint,
2603 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2605 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2607 SMESH::long_array_var anElementsId = theObject->GetIDs();
2608 SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
2620 if (!myPreviewMode) {
2621 bool isDumpGroups = aGroups && aGroups->length() > 0;
2623 aPythonDump << "(" << aGroups << ", error)";
2625 aPythonDump << "error";
2627 aPythonDump << " = " << this << ".ExtrusionAlongPathObject1DMakeGroups( "
2628 << theObject << ", "
2629 << thePathMesh << ", "
2630 << thePathShape << ", "
2631 << theNodeStart << ", "
2632 << theHasAngles << ", "
2633 << theAngles << ", "
2634 << theHasRefPoint << ", "
2635 << "SMESH.PointStruct( "
2636 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2637 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2638 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2643 //=======================================================================
2644 //function : ExtrusionAlongPathObject2DMakeGroups
2646 //=======================================================================
2647 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2648 ExtrusionAlongPathObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2649 SMESH::SMESH_Mesh_ptr thePathMesh,
2650 GEOM::GEOM_Object_ptr thePathShape,
2651 CORBA::Long theNodeStart,
2652 CORBA::Boolean theHasAngles,
2653 const SMESH::double_array& theAngles,
2654 CORBA::Boolean theHasRefPoint,
2655 const SMESH::PointStruct& theRefPoint,
2656 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2658 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2660 SMESH::long_array_var anElementsId = theObject->GetIDs();
2661 SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
2673 if (!myPreviewMode) {
2674 bool isDumpGroups = aGroups && aGroups->length() > 0;
2676 aPythonDump << "(" << aGroups << ", error)";
2678 aPythonDump << "error";
2680 aPythonDump << " = " << this << ".ExtrusionAlongPathObject2DMakeGroups( "
2681 << theObject << ", "
2682 << thePathMesh << ", "
2683 << thePathShape << ", "
2684 << theNodeStart << ", "
2685 << theHasAngles << ", "
2686 << theAngles << ", "
2687 << theHasRefPoint << ", "
2688 << "SMESH.PointStruct( "
2689 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2690 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2691 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2697 //=======================================================================
2698 //function : ExtrusionAlongPathObjX
2700 //=======================================================================
2701 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2702 ExtrusionAlongPathObjX(SMESH::SMESH_IDSource_ptr Object,
2703 SMESH::SMESH_IDSource_ptr Path,
2704 CORBA::Long NodeStart,
2705 CORBA::Boolean HasAngles,
2706 const SMESH::double_array& Angles,
2707 CORBA::Boolean LinearVariation,
2708 CORBA::Boolean HasRefPoint,
2709 const SMESH::PointStruct& RefPoint,
2710 CORBA::Boolean MakeGroups,
2711 SMESH::ElementType ElemType,
2712 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2714 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2716 SMESH::long_array_var anElementsId = Object->GetIDs();
2717 SMESH::ListOfGroups * aGroups = extrusionAlongPathX(anElementsId,
2726 (SMDSAbs_ElementType)ElemType,
2729 if (!myPreviewMode) {
2730 bool isDumpGroups = aGroups && aGroups->length() > 0;
2732 aPythonDump << "(" << *aGroups << ", error)";
2734 aPythonDump << "error";
2736 aPythonDump << " = " << this << ".ExtrusionAlongPathObjX( "
2739 << NodeStart << ", "
2740 << HasAngles << ", "
2742 << LinearVariation << ", "
2743 << HasRefPoint << ", "
2744 << "SMESH.PointStruct( "
2745 << ( HasRefPoint ? RefPoint.x : 0 ) << ", "
2746 << ( HasRefPoint ? RefPoint.y : 0 ) << ", "
2747 << ( HasRefPoint ? RefPoint.z : 0 ) << " ), "
2748 << MakeGroups << ", "
2749 << ElemType << " )";
2755 //=======================================================================
2756 //function : ExtrusionAlongPathX
2758 //=======================================================================
2759 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2760 ExtrusionAlongPathX(const SMESH::long_array& IDsOfElements,
2761 SMESH::SMESH_IDSource_ptr Path,
2762 CORBA::Long NodeStart,
2763 CORBA::Boolean HasAngles,
2764 const SMESH::double_array& Angles,
2765 CORBA::Boolean LinearVariation,
2766 CORBA::Boolean HasRefPoint,
2767 const SMESH::PointStruct& RefPoint,
2768 CORBA::Boolean MakeGroups,
2769 SMESH::ElementType ElemType,
2770 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2772 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
2774 SMESH::ListOfGroups * aGroups = extrusionAlongPathX(IDsOfElements,
2783 (SMDSAbs_ElementType)ElemType,
2786 if (!myPreviewMode) {
2787 bool isDumpGroups = aGroups && aGroups->length() > 0;
2789 aPythonDump << "(" << *aGroups << ", error)";
2791 aPythonDump <<"error";
2793 aPythonDump << " = " << this << ".ExtrusionAlongPathX( "
2794 << IDsOfElements << ", "
2796 << NodeStart << ", "
2797 << HasAngles << ", "
2799 << LinearVariation << ", "
2800 << HasRefPoint << ", "
2801 << "SMESH.PointStruct( "
2802 << ( HasRefPoint ? RefPoint.x : 0 ) << ", "
2803 << ( HasRefPoint ? RefPoint.y : 0 ) << ", "
2804 << ( HasRefPoint ? RefPoint.z : 0 ) << " ), "
2805 << MakeGroups << ", "
2806 << ElemType << " )";
2812 //================================================================================
2814 * \brief Compute rotation angles for ExtrusionAlongPath as linear variation
2815 * of given angles along path steps
2816 * \param PathMesh mesh containing a 1D sub-mesh on the edge, along
2817 * which proceeds the extrusion
2818 * \param PathShape is shape(edge); as the mesh can be complex, the edge
2819 * is used to define the sub-mesh for the path
2821 //================================================================================
2823 SMESH::double_array*
2824 SMESH_MeshEditor_i::LinearAnglesVariation(SMESH::SMESH_Mesh_ptr thePathMesh,
2825 GEOM::GEOM_Object_ptr thePathShape,
2826 const SMESH::double_array & theAngles)
2828 SMESH::double_array_var aResult = new SMESH::double_array();
2829 int nbAngles = theAngles.length();
2830 if ( nbAngles > 0 && !thePathMesh->_is_nil() && !thePathShape->_is_nil() )
2832 SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( thePathMesh );
2833 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
2834 SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
2835 if ( !aSubMesh || !aSubMesh->GetSubMeshDS())
2836 return aResult._retn();
2837 int nbSteps = aSubMesh->GetSubMeshDS()->NbElements();
2838 if ( nbSteps == nbAngles )
2840 aResult.inout() = theAngles;
2844 aResult->length( nbSteps );
2845 double rAn2St = double( nbAngles ) / double( nbSteps );
2846 double angPrev = 0, angle;
2847 for ( int iSt = 0; iSt < nbSteps; ++iSt )
2849 double angCur = rAn2St * ( iSt+1 );
2850 double angCurFloor = floor( angCur );
2851 double angPrevFloor = floor( angPrev );
2852 if ( angPrevFloor == angCurFloor )
2853 angle = rAn2St * theAngles[ int( angCurFloor ) ];
2856 int iP = int( angPrevFloor );
2857 double angPrevCeil = ceil(angPrev);
2858 angle = ( angPrevCeil - angPrev ) * theAngles[ iP ];
2860 int iC = int( angCurFloor );
2861 if ( iC < nbAngles )
2862 angle += ( angCur - angCurFloor ) * theAngles[ iC ];
2864 iP = int( angPrevCeil );
2866 angle += theAngles[ iC ];
2868 aResult[ iSt ] = angle;
2873 // Update Python script
2874 TPythonDump() << "rotAngles = " << theAngles;
2875 TPythonDump() << "rotAngles = " << this << ".LinearAnglesVariation( "
2876 << thePathMesh << ", "
2877 << thePathShape << ", "
2880 return aResult._retn();
2884 //=======================================================================
2887 //=======================================================================
2889 SMESH::ListOfGroups*
2890 SMESH_MeshEditor_i::mirror(TIDSortedElemSet & theElements,
2891 const SMESH::AxisStruct & theAxis,
2892 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
2893 CORBA::Boolean theCopy,
2894 const bool theMakeGroups,
2895 ::SMESH_Mesh* theTargetMesh)
2899 gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
2900 gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
2903 switch ( theMirrorType ) {
2904 case SMESH::SMESH_MeshEditor::POINT:
2905 aTrsf.SetMirror( P );
2907 case SMESH::SMESH_MeshEditor::AXIS:
2908 aTrsf.SetMirror( gp_Ax1( P, V ));
2911 aTrsf.SetMirror( gp_Ax2( P, V ));
2914 TIDSortedElemSet copyElements;
2915 TPreviewMesh tmpMesh;
2916 TIDSortedElemSet* workElements = 0;
2917 SMESH_Mesh* mesh = 0;
2919 if ( myPreviewMode )
2921 tmpMesh.Copy( theElements, copyElements);
2923 workElements = & copyElements;
2928 workElements = & theElements;
2931 ::SMESH_MeshEditor anEditor( mesh );
2932 ::SMESH_MeshEditor::PGroupIDs groupIds =
2933 anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
2935 if(theCopy || myPreviewMode)
2936 storeResult(anEditor);
2939 myMesh->GetMeshDS()->Modified();
2940 myMesh->SetIsModified( true );
2943 return theMakeGroups ? getGroups(groupIds.get()) : 0;
2946 //=======================================================================
2949 //=======================================================================
2951 void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElements,
2952 const SMESH::AxisStruct & theAxis,
2953 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
2954 CORBA::Boolean theCopy)
2956 if ( !myPreviewMode ) {
2957 TPythonDump() << this << ".Mirror( "
2958 << theIDsOfElements << ", "
2960 << mirrorTypeName(theMirrorType) << ", "
2963 if ( theIDsOfElements.length() > 0 )
2965 TIDSortedElemSet elements;
2966 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
2967 mirror(elements, theAxis, theMirrorType, theCopy, false);
2972 //=======================================================================
2973 //function : MirrorObject
2975 //=======================================================================
2977 void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObject,
2978 const SMESH::AxisStruct & theAxis,
2979 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
2980 CORBA::Boolean theCopy)
2982 if ( !myPreviewMode ) {
2983 TPythonDump() << this << ".MirrorObject( "
2984 << theObject << ", "
2986 << mirrorTypeName(theMirrorType) << ", "
2989 TIDSortedElemSet elements;
2991 bool emptyIfIsMesh = myPreviewMode ? false : true;
2993 if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
2994 mirror(elements, theAxis, theMirrorType, theCopy, false);
2997 //=======================================================================
2998 //function : MirrorMakeGroups
3000 //=======================================================================
3002 SMESH::ListOfGroups*
3003 SMESH_MeshEditor_i::MirrorMakeGroups(const SMESH::long_array& theIDsOfElements,
3004 const SMESH::AxisStruct& theMirror,
3005 SMESH::SMESH_MeshEditor::MirrorType theMirrorType)
3007 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3009 SMESH::ListOfGroups * aGroups = 0;
3010 if ( theIDsOfElements.length() > 0 )
3012 TIDSortedElemSet elements;
3013 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3014 aGroups = mirror(elements, theMirror, theMirrorType, true, true);
3016 if (!myPreviewMode) {
3017 DumpGroupsList(aPythonDump, aGroups);
3018 aPythonDump << this << ".MirrorMakeGroups( "
3019 << theIDsOfElements << ", "
3020 << theMirror << ", "
3021 << mirrorTypeName(theMirrorType) << " )";
3026 //=======================================================================
3027 //function : MirrorObjectMakeGroups
3029 //=======================================================================
3031 SMESH::ListOfGroups*
3032 SMESH_MeshEditor_i::MirrorObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
3033 const SMESH::AxisStruct& theMirror,
3034 SMESH::SMESH_MeshEditor::MirrorType theMirrorType)
3036 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3038 SMESH::ListOfGroups * aGroups = 0;
3039 TIDSortedElemSet elements;
3040 if ( idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3041 aGroups = mirror(elements, theMirror, theMirrorType, true, true);
3045 DumpGroupsList(aPythonDump,aGroups);
3046 aPythonDump << this << ".MirrorObjectMakeGroups( "
3047 << theObject << ", "
3048 << theMirror << ", "
3049 << mirrorTypeName(theMirrorType) << " )";
3054 //=======================================================================
3055 //function : MirrorMakeMesh
3057 //=======================================================================
3059 SMESH::SMESH_Mesh_ptr
3060 SMESH_MeshEditor_i::MirrorMakeMesh(const SMESH::long_array& theIDsOfElements,
3061 const SMESH::AxisStruct& theMirror,
3062 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
3063 CORBA::Boolean theCopyGroups,
3064 const char* theMeshName)
3066 SMESH_Mesh_i* mesh_i;
3067 SMESH::SMESH_Mesh_var mesh;
3068 { // open new scope to dump "MakeMesh" command
3069 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3071 TPythonDump pydump; // to prevent dump at mesh creation
3073 mesh = makeMesh( theMeshName );
3074 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3075 if (mesh_i && theIDsOfElements.length() > 0 )
3077 TIDSortedElemSet elements;
3078 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3079 mirror(elements, theMirror, theMirrorType,
3080 false, theCopyGroups, & mesh_i->GetImpl());
3081 mesh_i->CreateGroupServants();
3084 if (!myPreviewMode) {
3085 pydump << mesh << " = " << this << ".MirrorMakeMesh( "
3086 << theIDsOfElements << ", "
3087 << theMirror << ", "
3088 << mirrorTypeName(theMirrorType) << ", "
3089 << theCopyGroups << ", '"
3090 << theMeshName << "' )";
3095 if (!myPreviewMode && mesh_i)
3096 mesh_i->GetGroups();
3098 return mesh._retn();
3101 //=======================================================================
3102 //function : MirrorObjectMakeMesh
3104 //=======================================================================
3106 SMESH::SMESH_Mesh_ptr
3107 SMESH_MeshEditor_i::MirrorObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
3108 const SMESH::AxisStruct& theMirror,
3109 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
3110 CORBA::Boolean theCopyGroups,
3111 const char* theMeshName)
3113 SMESH_Mesh_i* mesh_i;
3114 SMESH::SMESH_Mesh_var mesh;
3115 { // open new scope to dump "MakeMesh" command
3116 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3118 TPythonDump pydump; // to prevent dump at mesh creation
3120 mesh = makeMesh( theMeshName );
3121 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3122 TIDSortedElemSet elements;
3124 idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3126 mirror(elements, theMirror, theMirrorType,
3127 false, theCopyGroups, & mesh_i->GetImpl());
3128 mesh_i->CreateGroupServants();
3130 if (!myPreviewMode) {
3131 pydump << mesh << " = " << this << ".MirrorObjectMakeMesh( "
3132 << theObject << ", "
3133 << theMirror << ", "
3134 << mirrorTypeName(theMirrorType) << ", "
3135 << theCopyGroups << ", '"
3136 << theMeshName << "' )";
3141 if (!myPreviewMode && mesh_i)
3142 mesh_i->GetGroups();
3144 return mesh._retn();
3147 //=======================================================================
3148 //function : translate
3150 //=======================================================================
3152 SMESH::ListOfGroups*
3153 SMESH_MeshEditor_i::translate(TIDSortedElemSet & theElements,
3154 const SMESH::DirStruct & theVector,
3155 CORBA::Boolean theCopy,
3156 const bool theMakeGroups,
3157 ::SMESH_Mesh* theTargetMesh)
3162 const SMESH::PointStruct * P = &theVector.PS;
3163 aTrsf.SetTranslation( gp_Vec( P->x, P->y, P->z ));
3165 TIDSortedElemSet copyElements;
3166 TPreviewMesh tmpMesh;
3167 TIDSortedElemSet* workElements = 0;
3168 SMESH_Mesh* mesh = 0;
3170 if ( myPreviewMode )
3172 tmpMesh.Copy( theElements, copyElements);
3174 workElements = & copyElements;
3179 workElements = & theElements;
3182 ::SMESH_MeshEditor anEditor( mesh );
3183 ::SMESH_MeshEditor::PGroupIDs groupIds =
3184 anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
3186 if(theCopy || myPreviewMode)
3187 storeResult(anEditor);
3190 myMesh->GetMeshDS()->Modified();
3191 myMesh->SetIsModified( true );
3194 return theMakeGroups ? getGroups(groupIds.get()) : 0;
3197 //=======================================================================
3198 //function : Translate
3200 //=======================================================================
3202 void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements,
3203 const SMESH::DirStruct & theVector,
3204 CORBA::Boolean theCopy)
3206 if (!myPreviewMode) {
3207 TPythonDump() << this << ".Translate( "
3208 << theIDsOfElements << ", "
3209 << theVector << ", "
3212 if (theIDsOfElements.length()) {
3213 TIDSortedElemSet elements;
3214 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3215 translate(elements, theVector, theCopy, false);
3219 //=======================================================================
3220 //function : TranslateObject
3222 //=======================================================================
3224 void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject,
3225 const SMESH::DirStruct & theVector,
3226 CORBA::Boolean theCopy)
3228 if (!myPreviewMode) {
3229 TPythonDump() << this << ".TranslateObject( "
3230 << theObject << ", "
3231 << theVector << ", "
3234 TIDSortedElemSet elements;
3236 bool emptyIfIsMesh = myPreviewMode ? false : true;
3238 if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
3239 translate(elements, theVector, theCopy, false);
3242 //=======================================================================
3243 //function : TranslateMakeGroups
3245 //=======================================================================
3247 SMESH::ListOfGroups*
3248 SMESH_MeshEditor_i::TranslateMakeGroups(const SMESH::long_array& theIDsOfElements,
3249 const SMESH::DirStruct& theVector)
3251 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3253 SMESH::ListOfGroups * aGroups = 0;
3254 if (theIDsOfElements.length()) {
3255 TIDSortedElemSet elements;
3256 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3257 aGroups = translate(elements,theVector,true,true);
3259 if (!myPreviewMode) {
3260 DumpGroupsList(aPythonDump, aGroups);
3261 aPythonDump << this << ".TranslateMakeGroups( "
3262 << theIDsOfElements << ", "
3263 << theVector << " )";
3268 //=======================================================================
3269 //function : TranslateObjectMakeGroups
3271 //=======================================================================
3273 SMESH::ListOfGroups*
3274 SMESH_MeshEditor_i::TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
3275 const SMESH::DirStruct& theVector)
3277 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3279 SMESH::ListOfGroups * aGroups = 0;
3280 TIDSortedElemSet elements;
3281 if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3282 aGroups = translate(elements, theVector, true, true);
3284 if (!myPreviewMode) {
3285 DumpGroupsList(aPythonDump, aGroups);
3286 aPythonDump << this << ".TranslateObjectMakeGroups( "
3287 << theObject << ", "
3288 << theVector << " )";
3293 //=======================================================================
3294 //function : TranslateMakeMesh
3296 //=======================================================================
3298 SMESH::SMESH_Mesh_ptr
3299 SMESH_MeshEditor_i::TranslateMakeMesh(const SMESH::long_array& theIDsOfElements,
3300 const SMESH::DirStruct& theVector,
3301 CORBA::Boolean theCopyGroups,
3302 const char* theMeshName)
3304 SMESH_Mesh_i* mesh_i;
3305 SMESH::SMESH_Mesh_var mesh;
3307 { // open new scope to dump "MakeMesh" command
3308 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3310 TPythonDump pydump; // to prevent dump at mesh creation
3312 mesh = makeMesh( theMeshName );
3313 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3315 if ( mesh_i && theIDsOfElements.length() )
3317 TIDSortedElemSet elements;
3318 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3319 translate(elements, theVector, false, theCopyGroups, & mesh_i->GetImpl());
3320 mesh_i->CreateGroupServants();
3323 if ( !myPreviewMode ) {
3324 pydump << mesh << " = " << this << ".TranslateMakeMesh( "
3325 << theIDsOfElements << ", "
3326 << theVector << ", "
3327 << theCopyGroups << ", '"
3328 << theMeshName << "' )";
3333 if (!myPreviewMode && mesh_i)
3334 mesh_i->GetGroups();
3336 return mesh._retn();
3339 //=======================================================================
3340 //function : TranslateObjectMakeMesh
3342 //=======================================================================
3344 SMESH::SMESH_Mesh_ptr
3345 SMESH_MeshEditor_i::TranslateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
3346 const SMESH::DirStruct& theVector,
3347 CORBA::Boolean theCopyGroups,
3348 const char* theMeshName)
3350 SMESH_Mesh_i* mesh_i;
3351 SMESH::SMESH_Mesh_var mesh;
3352 { // open new scope to dump "MakeMesh" command
3353 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3355 TPythonDump pydump; // to prevent dump at mesh creation
3356 mesh = makeMesh( theMeshName );
3357 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3359 TIDSortedElemSet elements;
3361 idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3363 translate(elements, theVector,false, theCopyGroups, & mesh_i->GetImpl());
3364 mesh_i->CreateGroupServants();
3366 if ( !myPreviewMode ) {
3367 pydump << mesh << " = " << this << ".TranslateObjectMakeMesh( "
3368 << theObject << ", "
3369 << theVector << ", "
3370 << theCopyGroups << ", '"
3371 << theMeshName << "' )";
3376 if (!myPreviewMode && mesh_i)
3377 mesh_i->GetGroups();
3379 return mesh._retn();
3382 //=======================================================================
3385 //=======================================================================
3387 SMESH::ListOfGroups*
3388 SMESH_MeshEditor_i::rotate(TIDSortedElemSet & theElements,
3389 const SMESH::AxisStruct & theAxis,
3390 CORBA::Double theAngle,
3391 CORBA::Boolean theCopy,
3392 const bool theMakeGroups,
3393 ::SMESH_Mesh* theTargetMesh)
3397 gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
3398 gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
3401 aTrsf.SetRotation( gp_Ax1( P, V ), theAngle);
3403 TIDSortedElemSet copyElements;
3404 TPreviewMesh tmpMesh;
3405 TIDSortedElemSet* workElements = 0;
3406 SMESH_Mesh* mesh = 0;
3408 if ( myPreviewMode ) {
3409 tmpMesh.Copy( theElements, copyElements );
3411 workElements = ©Elements;
3416 workElements=&theElements;
3419 ::SMESH_MeshEditor anEditor( mesh );
3420 ::SMESH_MeshEditor::PGroupIDs groupIds =
3421 anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
3423 if(theCopy || myPreviewMode)
3424 storeResult(anEditor);
3427 myMesh->GetMeshDS()->Modified();
3428 myMesh->SetIsModified( true );
3431 return theMakeGroups ? getGroups(groupIds.get()) : 0;
3434 //=======================================================================
3437 //=======================================================================
3439 void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements,
3440 const SMESH::AxisStruct & theAxis,
3441 CORBA::Double theAngle,
3442 CORBA::Boolean theCopy)
3444 if (!myPreviewMode) {
3445 TPythonDump() << this << ".Rotate( "
3446 << theIDsOfElements << ", "
3451 if (theIDsOfElements.length() > 0)
3453 TIDSortedElemSet elements;
3454 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3455 rotate(elements,theAxis,theAngle,theCopy,false);
3459 //=======================================================================
3460 //function : RotateObject
3462 //=======================================================================
3464 void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject,
3465 const SMESH::AxisStruct & theAxis,
3466 CORBA::Double theAngle,
3467 CORBA::Boolean theCopy)
3469 if ( !myPreviewMode ) {
3470 TPythonDump() << this << ".RotateObject( "
3471 << theObject << ", "
3476 TIDSortedElemSet elements;
3477 bool emptyIfIsMesh = myPreviewMode ? false : true;
3478 if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
3479 rotate(elements,theAxis,theAngle,theCopy,false);
3482 //=======================================================================
3483 //function : RotateMakeGroups
3485 //=======================================================================
3487 SMESH::ListOfGroups*
3488 SMESH_MeshEditor_i::RotateMakeGroups(const SMESH::long_array& theIDsOfElements,
3489 const SMESH::AxisStruct& theAxis,
3490 CORBA::Double theAngle)
3492 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3494 SMESH::ListOfGroups * aGroups = 0;
3495 if (theIDsOfElements.length() > 0)
3497 TIDSortedElemSet elements;
3498 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3499 aGroups = rotate(elements,theAxis,theAngle,true,true);
3501 if (!myPreviewMode) {
3502 DumpGroupsList(aPythonDump, aGroups);
3503 aPythonDump << this << ".RotateMakeGroups( "
3504 << theIDsOfElements << ", "
3506 << theAngle << " )";
3511 //=======================================================================
3512 //function : RotateObjectMakeGroups
3514 //=======================================================================
3516 SMESH::ListOfGroups*
3517 SMESH_MeshEditor_i::RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
3518 const SMESH::AxisStruct& theAxis,
3519 CORBA::Double theAngle)
3521 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3523 SMESH::ListOfGroups * aGroups = 0;
3524 TIDSortedElemSet elements;
3525 if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3526 aGroups = rotate(elements, theAxis, theAngle, true, true);
3528 if (!myPreviewMode) {
3529 DumpGroupsList(aPythonDump, aGroups);
3530 aPythonDump << this << ".RotateObjectMakeGroups( "
3531 << theObject << ", "
3533 << theAngle << " )";
3538 //=======================================================================
3539 //function : RotateMakeMesh
3541 //=======================================================================
3543 SMESH::SMESH_Mesh_ptr
3544 SMESH_MeshEditor_i::RotateMakeMesh(const SMESH::long_array& theIDsOfElements,
3545 const SMESH::AxisStruct& theAxis,
3546 CORBA::Double theAngleInRadians,
3547 CORBA::Boolean theCopyGroups,
3548 const char* theMeshName)
3550 SMESH::SMESH_Mesh_var mesh;
3551 SMESH_Mesh_i* mesh_i;
3553 { // open new scope to dump "MakeMesh" command
3554 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3556 TPythonDump pydump; // to prevent dump at mesh creation
3558 mesh = makeMesh( theMeshName );
3559 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3561 if ( mesh_i && theIDsOfElements.length() > 0 )
3563 TIDSortedElemSet elements;
3564 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3565 rotate(elements, theAxis, theAngleInRadians,
3566 false, theCopyGroups, & mesh_i->GetImpl());
3567 mesh_i->CreateGroupServants();
3569 if ( !myPreviewMode ) {
3570 pydump << mesh << " = " << this << ".RotateMakeMesh( "
3571 << theIDsOfElements << ", "
3573 << theAngleInRadians << ", "
3574 << theCopyGroups << ", '"
3575 << theMeshName << "' )";
3580 if (!myPreviewMode && mesh_i && theIDsOfElements.length() > 0 )
3581 mesh_i->GetGroups();
3583 return mesh._retn();
3586 //=======================================================================
3587 //function : RotateObjectMakeMesh
3589 //=======================================================================
3591 SMESH::SMESH_Mesh_ptr
3592 SMESH_MeshEditor_i::RotateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
3593 const SMESH::AxisStruct& theAxis,
3594 CORBA::Double theAngleInRadians,
3595 CORBA::Boolean theCopyGroups,
3596 const char* theMeshName)
3598 SMESH::SMESH_Mesh_var mesh;
3599 SMESH_Mesh_i* mesh_i;
3601 {// open new scope to dump "MakeMesh" command
3602 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3604 TPythonDump pydump; // to prevent dump at mesh creation
3605 mesh = makeMesh( theMeshName );
3606 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3608 TIDSortedElemSet elements;
3610 idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
3612 rotate(elements, theAxis, theAngleInRadians,
3613 false, theCopyGroups, & mesh_i->GetImpl());
3614 mesh_i->CreateGroupServants();
3616 if ( !myPreviewMode ) {
3617 pydump << mesh << " = " << this << ".RotateObjectMakeMesh( "
3618 << theObject << ", "
3620 << theAngleInRadians << ", "
3621 << theCopyGroups << ", '"
3622 << theMeshName << "' )";
3627 if (!myPreviewMode && mesh_i)
3628 mesh_i->GetGroups();
3630 return mesh._retn();
3633 //=======================================================================
3636 //=======================================================================
3638 SMESH::ListOfGroups*
3639 SMESH_MeshEditor_i::scale(SMESH::SMESH_IDSource_ptr theObject,
3640 const SMESH::PointStruct& thePoint,
3641 const SMESH::double_array& theScaleFact,
3642 CORBA::Boolean theCopy,
3643 const bool theMakeGroups,
3644 ::SMESH_Mesh* theTargetMesh)
3647 if ( theScaleFact.length() < 1 )
3648 THROW_SALOME_CORBA_EXCEPTION("Scale factor not given", SALOME::BAD_PARAM);
3649 if ( theScaleFact.length() == 2 )
3650 THROW_SALOME_CORBA_EXCEPTION("Invalid nb of scale factors : 2", SALOME::BAD_PARAM);
3652 TIDSortedElemSet elements;
3653 bool emptyIfIsMesh = myPreviewMode ? false : true;
3654 if ( !idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
3657 vector<double> S(3);
3658 S[0] = theScaleFact[0];
3659 S[1] = (theScaleFact.length() == 1) ? theScaleFact[0] : theScaleFact[1];
3660 S[2] = (theScaleFact.length() == 1) ? theScaleFact[0] : theScaleFact[2];
3661 double tol = std::numeric_limits<double>::max();
3663 aTrsf.SetValues( S[0], 0, 0, thePoint.x * (1-S[0]),
3664 0, S[1], 0, thePoint.y * (1-S[1]),
3665 0, 0, S[2], thePoint.z * (1-S[2]), tol, tol);
3667 TIDSortedElemSet copyElements;
3668 TPreviewMesh tmpMesh;
3669 TIDSortedElemSet* workElements = 0;
3670 SMESH_Mesh* mesh = 0;
3672 if ( myPreviewMode )
3674 tmpMesh.Copy( elements, copyElements);
3676 workElements = & copyElements;
3681 workElements = & elements;
3684 ::SMESH_MeshEditor anEditor( mesh );
3685 ::SMESH_MeshEditor::PGroupIDs groupIds =
3686 anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
3688 if(theCopy || myPreviewMode )
3689 storeResult(anEditor);
3692 myMesh->GetMeshDS()->Modified();
3693 myMesh->SetIsModified( true );
3695 return theMakeGroups ? getGroups(groupIds.get()) : 0;
3698 //=======================================================================
3701 //=======================================================================
3703 void SMESH_MeshEditor_i::Scale(SMESH::SMESH_IDSource_ptr theObject,
3704 const SMESH::PointStruct& thePoint,
3705 const SMESH::double_array& theScaleFact,
3706 CORBA::Boolean theCopy)
3708 if ( !myPreviewMode ) {
3709 TPythonDump() << this << ".Scale( "
3710 << theObject << ", "
3711 << "SMESH.PointStruct( " << thePoint.x << ", "
3712 << thePoint.y << ", " << thePoint.z << " ) ,"
3713 << theScaleFact << ", "
3716 scale(theObject, thePoint, theScaleFact, theCopy, false);
3720 //=======================================================================
3721 //function : ScaleMakeGroups
3723 //=======================================================================
3725 SMESH::ListOfGroups*
3726 SMESH_MeshEditor_i::ScaleMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
3727 const SMESH::PointStruct& thePoint,
3728 const SMESH::double_array& theScaleFact)
3730 TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
3732 SMESH::ListOfGroups * aGroups = scale(theObject, thePoint, theScaleFact, true, true);
3733 if (!myPreviewMode) {
3734 DumpGroupsList(aPythonDump, aGroups);
3735 aPythonDump << this << ".Scale("
3737 << "SMESH.PointStruct(" <<thePoint.x << ","
3738 << thePoint.y << "," << thePoint.z << "),"
3739 << theScaleFact << ",True,True)";
3745 //=======================================================================
3746 //function : ScaleMakeMesh
3748 //=======================================================================
3750 SMESH::SMESH_Mesh_ptr
3751 SMESH_MeshEditor_i::ScaleMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
3752 const SMESH::PointStruct& thePoint,
3753 const SMESH::double_array& theScaleFact,
3754 CORBA::Boolean theCopyGroups,
3755 const char* theMeshName)
3757 SMESH_Mesh_i* mesh_i;
3758 SMESH::SMESH_Mesh_var mesh;
3759 { // open new scope to dump "MakeMesh" command
3760 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3762 TPythonDump pydump; // to prevent dump at mesh creation
3763 mesh = makeMesh( theMeshName );
3764 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3768 scale(theObject, thePoint, theScaleFact,false, theCopyGroups, & mesh_i->GetImpl());
3769 mesh_i->CreateGroupServants();
3771 if ( !myPreviewMode )
3772 pydump << mesh << " = " << this << ".ScaleMakeMesh( "
3773 << theObject << ", "
3774 << "SMESH.PointStruct( " << thePoint.x << ", "
3775 << thePoint.y << ", " << thePoint.z << " ) ,"
3776 << theScaleFact << ", "
3777 << theCopyGroups << ", '"
3778 << theMeshName << "' )";
3782 if (!myPreviewMode && mesh_i)
3783 mesh_i->GetGroups();
3785 return mesh._retn();
3789 //=======================================================================
3790 //function : FindCoincidentNodes
3792 //=======================================================================
3794 void SMESH_MeshEditor_i::FindCoincidentNodes (CORBA::Double Tolerance,
3795 SMESH::array_of_long_array_out GroupsOfNodes)
3799 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
3800 ::SMESH_MeshEditor anEditor( myMesh );
3801 TIDSortedNodeSet nodes; // no input nodes
3802 anEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
3804 GroupsOfNodes = new SMESH::array_of_long_array;
3805 GroupsOfNodes->length( aListOfListOfNodes.size() );
3806 ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
3807 for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ ) {
3808 list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
3809 list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
3810 SMESH::long_array& aGroup = (*GroupsOfNodes)[ i ];
3811 aGroup.length( aListOfNodes.size() );
3812 for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
3813 aGroup[ j ] = (*lIt)->GetID();
3815 TPythonDump() << "coincident_nodes = " << this << ".FindCoincidentNodes( "
3816 << Tolerance << " )";
3819 //=======================================================================
3820 //function : FindCoincidentNodesOnPart
3822 //=======================================================================
3823 void SMESH_MeshEditor_i::FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr theObject,
3824 CORBA::Double Tolerance,
3825 SMESH::array_of_long_array_out GroupsOfNodes)
3829 TIDSortedNodeSet nodes;
3830 idSourceToNodeSet( theObject, GetMeshDS(), nodes );
3832 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
3833 ::SMESH_MeshEditor anEditor( myMesh );
3835 anEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
3837 GroupsOfNodes = new SMESH::array_of_long_array;
3838 GroupsOfNodes->length( aListOfListOfNodes.size() );
3839 ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
3840 for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ )
3842 list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
3843 list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
3844 SMESH::long_array& aGroup = (*GroupsOfNodes)[ i ];
3845 aGroup.length( aListOfNodes.size() );
3846 for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
3847 aGroup[ j ] = (*lIt)->GetID();
3849 TPythonDump() << "coincident_nodes_on_part = " << this << ".FindCoincidentNodesOnPart( "
3851 << Tolerance << " )";
3854 //================================================================================
3856 * \brief Finds nodes coinsident with Tolerance within Object excluding nodes within
3857 * ExceptSubMeshOrGroups
3859 //================================================================================
3861 void SMESH_MeshEditor_i::
3862 FindCoincidentNodesOnPartBut(SMESH::SMESH_IDSource_ptr theObject,
3863 CORBA::Double theTolerance,
3864 SMESH::array_of_long_array_out theGroupsOfNodes,
3865 const SMESH::ListOfIDSources& theExceptSubMeshOrGroups)
3869 TIDSortedNodeSet nodes;
3870 idSourceToNodeSet( theObject, GetMeshDS(), nodes );
3872 for ( int i = 0; i < theExceptSubMeshOrGroups.length(); ++i )
3874 TIDSortedNodeSet exceptNodes;
3875 idSourceToNodeSet( theExceptSubMeshOrGroups[i], GetMeshDS(), exceptNodes );
3876 TIDSortedNodeSet::iterator avoidNode = exceptNodes.begin();
3877 for ( ; avoidNode != exceptNodes.end(); ++avoidNode)
3878 nodes.erase( *avoidNode );
3880 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
3881 ::SMESH_MeshEditor anEditor( myMesh );
3883 anEditor.FindCoincidentNodes( nodes, theTolerance, aListOfListOfNodes );
3885 theGroupsOfNodes = new SMESH::array_of_long_array;
3886 theGroupsOfNodes->length( aListOfListOfNodes.size() );
3887 ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
3888 for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ )
3890 list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
3891 list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
3892 SMESH::long_array& aGroup = (*theGroupsOfNodes)[ i ];
3893 aGroup.length( aListOfNodes.size() );
3894 for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
3895 aGroup[ j ] = (*lIt)->GetID();
3897 TPythonDump() << "coincident_nodes_on_part = " << this << ".FindCoincidentNodesOnPartBut( "
3899 << theTolerance << ", "
3900 << theExceptSubMeshOrGroups << " )";
3903 //=======================================================================
3904 //function : MergeNodes
3906 //=======================================================================
3908 void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes)
3912 SMESHDS_Mesh* aMesh = GetMeshDS();
3914 TPythonDump aTPythonDump;
3915 aTPythonDump << this << ".MergeNodes([";
3916 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
3917 for (int i = 0; i < GroupsOfNodes.length(); i++)
3919 const SMESH::long_array& aNodeGroup = GroupsOfNodes[ i ];
3920 aListOfListOfNodes.push_back( list< const SMDS_MeshNode* >() );
3921 list< const SMDS_MeshNode* >& aListOfNodes = aListOfListOfNodes.back();
3922 for ( int j = 0; j < aNodeGroup.length(); j++ )
3924 CORBA::Long index = aNodeGroup[ j ];
3925 const SMDS_MeshNode * node = aMesh->FindNode(index);
3927 aListOfNodes.push_back( node );
3929 if ( aListOfNodes.size() < 2 )
3930 aListOfListOfNodes.pop_back();
3932 if ( i > 0 ) aTPythonDump << ", ";
3933 aTPythonDump << aNodeGroup;
3935 ::SMESH_MeshEditor anEditor( myMesh );
3936 anEditor.MergeNodes( aListOfListOfNodes );
3938 aTPythonDump << "])";
3939 myMesh->GetMeshDS()->Modified();
3940 myMesh->SetIsModified( true );
3943 //=======================================================================
3944 //function : FindEqualElements
3946 //=======================================================================
3947 void SMESH_MeshEditor_i::FindEqualElements(SMESH::SMESH_IDSource_ptr theObject,
3948 SMESH::array_of_long_array_out GroupsOfElementsID)
3952 SMESH::SMESH_GroupBase_var group = SMESH::SMESH_GroupBase::_narrow(theObject);
3953 if ( !(!group->_is_nil() && group->GetType() == SMESH::NODE) )
3955 typedef list<int> TListOfIDs;
3956 set<const SMDS_MeshElement*> elems;
3957 SMESH::long_array_var aElementsId = theObject->GetIDs();
3958 SMESHDS_Mesh* aMesh = GetMeshDS();
3960 for(int i = 0; i < aElementsId->length(); i++) {
3961 CORBA::Long anID = aElementsId[i];
3962 const SMDS_MeshElement * elem = aMesh->FindElement(anID);
3968 ::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
3969 ::SMESH_MeshEditor anEditor( myMesh );
3970 anEditor.FindEqualElements( elems, aListOfListOfElementsID );
3972 GroupsOfElementsID = new SMESH::array_of_long_array;
3973 GroupsOfElementsID->length( aListOfListOfElementsID.size() );
3975 ::SMESH_MeshEditor::TListOfListOfElementsID::iterator arraysIt = aListOfListOfElementsID.begin();
3976 for (CORBA::Long j = 0; arraysIt != aListOfListOfElementsID.end(); ++arraysIt, ++j) {
3977 SMESH::long_array& aGroup = (*GroupsOfElementsID)[ j ];
3978 TListOfIDs& listOfIDs = *arraysIt;
3979 aGroup.length( listOfIDs.size() );
3980 TListOfIDs::iterator idIt = listOfIDs.begin();
3981 for (int k = 0; idIt != listOfIDs.end(); ++idIt, ++k ) {
3982 aGroup[ k ] = *idIt;
3986 TPythonDump() << "equal_elements = " << this << ".FindEqualElements( "
3991 //=======================================================================
3992 //function : MergeElements
3994 //=======================================================================
3996 void SMESH_MeshEditor_i::MergeElements(const SMESH::array_of_long_array& GroupsOfElementsID)
4000 TPythonDump aTPythonDump;
4001 aTPythonDump << this << ".MergeElements( [";
4003 ::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
4005 for (int i = 0; i < GroupsOfElementsID.length(); i++) {
4006 const SMESH::long_array& anElemsIDGroup = GroupsOfElementsID[ i ];
4007 aListOfListOfElementsID.push_back( list< int >() );
4008 list< int >& aListOfElemsID = aListOfListOfElementsID.back();
4009 for ( int j = 0; j < anElemsIDGroup.length(); j++ ) {
4010 CORBA::Long id = anElemsIDGroup[ j ];
4011 aListOfElemsID.push_back( id );
4013 if ( aListOfElemsID.size() < 2 )
4014 aListOfListOfElementsID.pop_back();
4015 if ( i > 0 ) aTPythonDump << ", ";
4016 aTPythonDump << anElemsIDGroup;
4019 ::SMESH_MeshEditor anEditor( myMesh );
4020 anEditor.MergeElements(aListOfListOfElementsID);
4021 myMesh->GetMeshDS()->Modified();
4022 myMesh->SetIsModified( true );
4024 aTPythonDump << "] )";
4027 //=======================================================================
4028 //function : MergeEqualElements
4030 //=======================================================================
4032 void SMESH_MeshEditor_i::MergeEqualElements()
4036 ::SMESH_MeshEditor anEditor( myMesh );
4037 anEditor.MergeEqualElements();
4039 TPythonDump() << this << ".MergeEqualElements()";
4042 //=============================================================================
4044 * Move the node to a given point
4046 //=============================================================================
4048 CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long NodeID,
4053 initData(/*deleteSearchers=*/false);
4055 const SMDS_MeshNode * node = GetMeshDS()->FindNode( NodeID );
4059 if ( theNodeSearcher )
4060 theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
4062 if ( myPreviewMode ) // make preview data
4064 // in a preview mesh, make edges linked to a node
4065 TPreviewMesh tmpMesh;
4066 TIDSortedElemSet linkedNodes;
4067 ::SMESH_MeshEditor::GetLinkedNodes( node, linkedNodes );
4068 TIDSortedElemSet::iterator nIt = linkedNodes.begin();
4069 SMDS_MeshNode *nodeCpy1 = tmpMesh.Copy(node);
4070 for ( ; nIt != linkedNodes.end(); ++nIt )
4072 SMDS_MeshNode *nodeCpy2 = tmpMesh.Copy ( cast2Node( *nIt ));
4073 tmpMesh.GetMeshDS()->AddEdge(nodeCpy1, nodeCpy2);
4077 tmpMesh.GetMeshDS()->MoveNode(nodeCpy1, x, y, z);
4078 // fill preview data
4079 ::SMESH_MeshEditor anEditor( & tmpMesh );
4080 storeResult( anEditor );
4082 else if ( theNodeSearcher ) // move node and update theNodeSearcher data accordingly
4083 theNodeSearcher->MoveNode(node, gp_Pnt( x,y,z ));
4085 GetMeshDS()->MoveNode(node, x, y, z);
4087 if ( !myPreviewMode )
4089 // Update Python script
4090 TPythonDump() << "isDone = " << this << ".MoveNode( "
4091 << NodeID << ", " << x << ", " << y << ", " << z << " )";
4092 myMesh->GetMeshDS()->Modified();
4093 myMesh->SetIsModified( true );
4099 //================================================================================
4101 * \brief Return ID of node closest to a given point
4103 //================================================================================
4105 CORBA::Long SMESH_MeshEditor_i::FindNodeClosestTo(CORBA::Double x,
4109 theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
4111 if ( !theNodeSearcher ) {
4112 ::SMESH_MeshEditor anEditor( myMesh );
4113 theNodeSearcher = anEditor.GetNodeSearcher();
4116 if ( const SMDS_MeshNode* node = theNodeSearcher->FindClosestTo( p ))
4117 return node->GetID();
4122 //================================================================================
4124 * \brief If the given ID is a valid node ID (nodeID > 0), just move this node, else
4125 * move the node closest to the point to point's location and return ID of the node
4127 //================================================================================
4129 CORBA::Long SMESH_MeshEditor_i::MoveClosestNodeToPoint(CORBA::Double x,
4132 CORBA::Long theNodeID)
4134 // We keep theNodeSearcher until any mesh modification:
4135 // 1) initData() deletes theNodeSearcher at any edition,
4136 // 2) TSearchersDeleter - at any mesh compute event and mesh change
4138 initData(/*deleteSearchers=*/false);
4140 theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
4142 int nodeID = theNodeID;
4143 const SMDS_MeshNode* node = GetMeshDS()->FindNode( nodeID );
4144 if ( !node ) // preview moving node
4146 if ( !theNodeSearcher ) {
4147 ::SMESH_MeshEditor anEditor( myMesh );
4148 theNodeSearcher = anEditor.GetNodeSearcher();
4151 node = theNodeSearcher->FindClosestTo( p );
4154 nodeID = node->GetID();
4155 if ( myPreviewMode ) // make preview data
4157 // in a preview mesh, make edges linked to a node
4158 TPreviewMesh tmpMesh;
4159 TIDSortedElemSet linkedNodes;
4160 ::SMESH_MeshEditor::GetLinkedNodes( node, linkedNodes );
4161 TIDSortedElemSet::iterator nIt = linkedNodes.begin();
4162 for ( ; nIt != linkedNodes.end(); ++nIt )
4164 SMDS_LinearEdge edge( node, cast2Node( *nIt ));
4165 tmpMesh.Copy( &edge );
4168 node = tmpMesh.GetMeshDS()->FindNode( nodeID );
4170 tmpMesh.GetMeshDS()->MoveNode(node, x, y, z);
4171 // fill preview data
4172 ::SMESH_MeshEditor anEditor( & tmpMesh );
4173 storeResult( anEditor );
4175 else if ( theNodeSearcher ) // move node and update theNodeSearcher data accordingly
4177 theNodeSearcher->MoveNode(node, gp_Pnt( x,y,z ));
4181 GetMeshDS()->MoveNode(node, x, y, z);
4185 if ( !myPreviewMode )
4187 TPythonDump() << "nodeID = " << this
4188 << ".MoveClosestNodeToPoint( "<< x << ", " << y << ", " << z
4189 << ", " << nodeID << " )";
4191 myMesh->GetMeshDS()->Modified();
4192 myMesh->SetIsModified( true );
4198 //=======================================================================
4200 * Return elements of given type where the given point is IN or ON.
4202 * 'ALL' type means elements of any type excluding nodes
4204 //=======================================================================
4206 SMESH::long_array* SMESH_MeshEditor_i::FindElementsByPoint(CORBA::Double x,
4209 SMESH::ElementType type)
4211 SMESH::long_array_var res = new SMESH::long_array;
4212 vector< const SMDS_MeshElement* > foundElems;
4214 theSearchersDeleter.Set( myMesh );
4215 if ( !theElementSearcher ) {
4216 ::SMESH_MeshEditor anEditor( myMesh );
4217 theElementSearcher = anEditor.GetElementSearcher();
4219 theElementSearcher->FindElementsByPoint( gp_Pnt( x,y,z ),
4220 SMDSAbs_ElementType( type ),
4222 res->length( foundElems.size() );
4223 for ( int i = 0; i < foundElems.size(); ++i )
4224 res[i] = foundElems[i]->GetID();
4226 if ( !myPreviewMode ) // call from tui
4227 TPythonDump() << res << " = " << this << ".FindElementsByPoint( "
4236 //=======================================================================
4237 //function : GetPointState
4238 //purpose : Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
4239 // TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
4240 //=======================================================================
4242 CORBA::Short SMESH_MeshEditor_i::GetPointState(CORBA::Double x,
4246 theSearchersDeleter.Set( myMesh );
4247 if ( !theElementSearcher ) {
4248 ::SMESH_MeshEditor anEditor( myMesh );
4249 theElementSearcher = anEditor.GetElementSearcher();
4251 return CORBA::Short( theElementSearcher->GetPointState( gp_Pnt( x,y,z )));
4254 //=======================================================================
4255 //function : convError
4257 //=======================================================================
4259 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
4261 static SMESH::SMESH_MeshEditor::Sew_Error convError( const::SMESH_MeshEditor::Sew_Error e )
4265 RETCASE( SEW_BORDER1_NOT_FOUND );
4266 RETCASE( SEW_BORDER2_NOT_FOUND );
4267 RETCASE( SEW_BOTH_BORDERS_NOT_FOUND );
4268 RETCASE( SEW_BAD_SIDE_NODES );
4269 RETCASE( SEW_VOLUMES_TO_SPLIT );
4270 RETCASE( SEW_DIFF_NB_OF_ELEMENTS );
4271 RETCASE( SEW_TOPO_DIFF_SETS_OF_ELEMENTS );
4272 RETCASE( SEW_BAD_SIDE1_NODES );
4273 RETCASE( SEW_BAD_SIDE2_NODES );
4275 return SMESH::SMESH_MeshEditor::SEW_OK;
4278 //=======================================================================
4279 //function : SewFreeBorders
4281 //=======================================================================
4283 SMESH::SMESH_MeshEditor::Sew_Error
4284 SMESH_MeshEditor_i::SewFreeBorders(CORBA::Long FirstNodeID1,
4285 CORBA::Long SecondNodeID1,
4286 CORBA::Long LastNodeID1,
4287 CORBA::Long FirstNodeID2,
4288 CORBA::Long SecondNodeID2,
4289 CORBA::Long LastNodeID2,
4290 CORBA::Boolean CreatePolygons,
4291 CORBA::Boolean CreatePolyedrs)
4295 SMESHDS_Mesh* aMesh = GetMeshDS();
4297 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
4298 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
4299 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
4300 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
4301 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
4302 const SMDS_MeshNode* aSide2ThirdNode = aMesh->FindNode( LastNodeID2 );
4304 if (!aBorderFirstNode ||
4305 !aBorderSecondNode||
4307 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
4308 if (!aSide2FirstNode ||
4309 !aSide2SecondNode ||
4311 return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
4313 TPythonDump() << "error = " << this << ".SewFreeBorders( "
4314 << FirstNodeID1 << ", "
4315 << SecondNodeID1 << ", "
4316 << LastNodeID1 << ", "
4317 << FirstNodeID2 << ", "
4318 << SecondNodeID2 << ", "
4319 << LastNodeID2 << ", "
4320 << CreatePolygons<< ", "
4321 << CreatePolyedrs<< " )";
4323 ::SMESH_MeshEditor anEditor( myMesh );
4324 SMESH::SMESH_MeshEditor::Sew_Error error =
4325 convError( anEditor.SewFreeBorder (aBorderFirstNode,
4335 storeResult(anEditor);
4337 myMesh->GetMeshDS()->Modified();
4338 myMesh->SetIsModified( true );
4344 //=======================================================================
4345 //function : SewConformFreeBorders
4347 //=======================================================================
4349 SMESH::SMESH_MeshEditor::Sew_Error
4350 SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1,
4351 CORBA::Long SecondNodeID1,
4352 CORBA::Long LastNodeID1,
4353 CORBA::Long FirstNodeID2,
4354 CORBA::Long SecondNodeID2)
4358 SMESHDS_Mesh* aMesh = GetMeshDS();
4360 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
4361 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
4362 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
4363 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
4364 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
4365 const SMDS_MeshNode* aSide2ThirdNode = 0;
4367 if (!aBorderFirstNode ||
4368 !aBorderSecondNode||
4370 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
4371 if (!aSide2FirstNode ||
4373 return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
4375 TPythonDump() << "error = " << this << ".SewConformFreeBorders( "
4376 << FirstNodeID1 << ", "
4377 << SecondNodeID1 << ", "
4378 << LastNodeID1 << ", "
4379 << FirstNodeID2 << ", "
4380 << SecondNodeID2 << " )";
4382 ::SMESH_MeshEditor anEditor( myMesh );
4383 SMESH::SMESH_MeshEditor::Sew_Error error =
4384 convError( anEditor.SewFreeBorder (aBorderFirstNode,
4393 storeResult(anEditor);
4395 myMesh->GetMeshDS()->Modified();
4396 myMesh->SetIsModified( true );
4402 //=======================================================================
4403 //function : SewBorderToSide
4405 //=======================================================================
4407 SMESH::SMESH_MeshEditor::Sew_Error
4408 SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder,
4409 CORBA::Long SecondNodeIDOnFreeBorder,
4410 CORBA::Long LastNodeIDOnFreeBorder,
4411 CORBA::Long FirstNodeIDOnSide,
4412 CORBA::Long LastNodeIDOnSide,
4413 CORBA::Boolean CreatePolygons,
4414 CORBA::Boolean CreatePolyedrs)
4418 SMESHDS_Mesh* aMesh = GetMeshDS();
4420 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeIDOnFreeBorder );
4421 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeIDOnFreeBorder );
4422 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeIDOnFreeBorder );
4423 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeIDOnSide );
4424 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( LastNodeIDOnSide );
4425 const SMDS_MeshNode* aSide2ThirdNode = 0;
4427 if (!aBorderFirstNode ||
4428 !aBorderSecondNode||
4430 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
4431 if (!aSide2FirstNode ||
4433 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE_NODES;
4435 TPythonDump() << "error = " << this << ".SewBorderToSide( "
4436 << FirstNodeIDOnFreeBorder << ", "
4437 << SecondNodeIDOnFreeBorder << ", "
4438 << LastNodeIDOnFreeBorder << ", "
4439 << FirstNodeIDOnSide << ", "
4440 << LastNodeIDOnSide << ", "
4441 << CreatePolygons << ", "
4442 << CreatePolyedrs << ") ";
4444 ::SMESH_MeshEditor anEditor( myMesh );
4445 SMESH::SMESH_MeshEditor::Sew_Error error =
4446 convError( anEditor.SewFreeBorder (aBorderFirstNode,
4456 storeResult(anEditor);
4458 myMesh->GetMeshDS()->Modified();
4459 myMesh->SetIsModified( true );
4465 //=======================================================================
4466 //function : SewSideElements
4468 //=======================================================================
4470 SMESH::SMESH_MeshEditor::Sew_Error
4471 SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements,
4472 const SMESH::long_array& IDsOfSide2Elements,
4473 CORBA::Long NodeID1OfSide1ToMerge,
4474 CORBA::Long NodeID1OfSide2ToMerge,
4475 CORBA::Long NodeID2OfSide1ToMerge,
4476 CORBA::Long NodeID2OfSide2ToMerge)
4480 SMESHDS_Mesh* aMesh = GetMeshDS();
4482 const SMDS_MeshNode* aFirstNode1ToMerge = aMesh->FindNode( NodeID1OfSide1ToMerge );
4483 const SMDS_MeshNode* aFirstNode2ToMerge = aMesh->FindNode( NodeID1OfSide2ToMerge );
4484 const SMDS_MeshNode* aSecondNode1ToMerge = aMesh->FindNode( NodeID2OfSide1ToMerge );
4485 const SMDS_MeshNode* aSecondNode2ToMerge = aMesh->FindNode( NodeID2OfSide2ToMerge );
4487 if (!aFirstNode1ToMerge ||
4488 !aFirstNode2ToMerge )
4489 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE1_NODES;
4490 if (!aSecondNode1ToMerge||
4491 !aSecondNode2ToMerge)
4492 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE2_NODES;
4494 TIDSortedElemSet aSide1Elems, aSide2Elems;
4495 arrayToSet(IDsOfSide1Elements, aMesh, aSide1Elems);
4496 arrayToSet(IDsOfSide2Elements, aMesh, aSide2Elems);
4498 TPythonDump() << "error = " << this << ".SewSideElements( "
4499 << IDsOfSide1Elements << ", "
4500 << IDsOfSide2Elements << ", "
4501 << NodeID1OfSide1ToMerge << ", "
4502 << NodeID1OfSide2ToMerge << ", "
4503 << NodeID2OfSide1ToMerge << ", "
4504 << NodeID2OfSide2ToMerge << ")";
4506 ::SMESH_MeshEditor anEditor( myMesh );
4507 SMESH::SMESH_MeshEditor::Sew_Error error =
4508 convError( anEditor.SewSideElements (aSide1Elems, aSide2Elems,
4511 aSecondNode1ToMerge,
4512 aSecondNode2ToMerge));
4514 storeResult(anEditor);
4516 myMesh->GetMeshDS()->Modified();
4517 myMesh->SetIsModified( true );
4522 //================================================================================
4524 * \brief Set new nodes for given element
4525 * \param ide - element id
4526 * \param newIDs - new node ids
4527 * \retval CORBA::Boolean - true if result is OK
4529 //================================================================================
4531 CORBA::Boolean SMESH_MeshEditor_i::ChangeElemNodes(CORBA::Long ide,
4532 const SMESH::long_array& newIDs)
4536 const SMDS_MeshElement* elem = GetMeshDS()->FindElement(ide);
4537 if(!elem) return false;
4539 int nbn = newIDs.length();
4541 vector<const SMDS_MeshNode*> aNodes(nbn);
4544 const SMDS_MeshNode* aNode = GetMeshDS()->FindNode(newIDs[i]);
4547 aNodes[nbn1] = aNode;
4550 TPythonDump() << "isDone = " << this << ".ChangeElemNodes( "
4551 << ide << ", " << newIDs << " )";
4553 MESSAGE("ChangeElementNodes");
4554 bool res = GetMeshDS()->ChangeElementNodes( elem, & aNodes[0], nbn1+1 );
4556 myMesh->GetMeshDS()->Modified();
4558 myMesh->SetIsModified( true );
4563 //================================================================================
4565 * \brief Update myLastCreated* or myPreviewData
4566 * \param anEditor - it contains last modification results
4568 //================================================================================
4570 void SMESH_MeshEditor_i::storeResult(::SMESH_MeshEditor& anEditor)
4572 if ( myPreviewMode ) { // --- MeshPreviewStruct filling ---
4574 list<int> aNodesConnectivity;
4575 typedef map<int, int> TNodesMap;
4578 TPreviewMesh * aPreviewMesh = dynamic_cast< TPreviewMesh* >( anEditor.GetMesh() );
4579 SMDSAbs_ElementType previewType = aPreviewMesh->myPreviewType;
4581 SMESHDS_Mesh* aMeshDS = anEditor.GetMeshDS();
4582 int nbEdges = aMeshDS->NbEdges();
4583 int nbFaces = aMeshDS->NbFaces();
4584 int nbVolum = aMeshDS->NbVolumes();
4585 switch ( previewType ) {
4586 case SMDSAbs_Edge : nbFaces = nbVolum = 0; break;
4587 case SMDSAbs_Face : nbEdges = nbVolum = 0; break;
4588 case SMDSAbs_Volume: nbEdges = nbFaces = 0; break;
4591 myPreviewData->nodesXYZ.length(aMeshDS->NbNodes());
4592 myPreviewData->elementTypes.length(nbEdges + nbFaces + nbVolum);
4594 SMDS_ElemIteratorPtr itMeshElems = aMeshDS->elementsIterator();
4596 while ( itMeshElems->more() ) {
4597 const SMDS_MeshElement* aMeshElem = itMeshElems->next();
4598 if ( previewType != SMDSAbs_All && aMeshElem->GetType() != previewType )
4601 SMDS_ElemIteratorPtr itElemNodes = aMeshElem->nodesIterator();
4602 while ( itElemNodes->more() ) {
4603 const SMDS_MeshNode* aMeshNode =
4604 static_cast<const SMDS_MeshNode*>( itElemNodes->next() );
4605 int aNodeID = aMeshNode->GetID();
4606 TNodesMap::iterator anIter = nodesMap.find(aNodeID);
4607 if ( anIter == nodesMap.end() ) {
4608 // filling the nodes coordinates
4609 myPreviewData->nodesXYZ[j].x = aMeshNode->X();
4610 myPreviewData->nodesXYZ[j].y = aMeshNode->Y();
4611 myPreviewData->nodesXYZ[j].z = aMeshNode->Z();
4612 anIter = nodesMap.insert( make_pair(aNodeID, j) ).first;
4615 aNodesConnectivity.push_back(anIter->second);
4618 // filling the elements types
4619 SMDSAbs_ElementType aType;
4621 /*if (aMeshElem->GetType() == SMDSAbs_Volume) {
4622 aType = SMDSAbs_Node;
4626 aType = aMeshElem->GetType();
4627 isPoly = aMeshElem->IsPoly();
4630 myPreviewData->elementTypes[i].SMDS_ElementType = (SMESH::ElementType) aType;
4631 myPreviewData->elementTypes[i].isPoly = isPoly;
4632 myPreviewData->elementTypes[i].nbNodesInElement = aMeshElem->NbNodes();
4636 myPreviewData->nodesXYZ.length( j );
4638 // filling the elements connectivities
4639 list<int>::iterator aConnIter = aNodesConnectivity.begin();
4640 myPreviewData->elementConnectivities.length(aNodesConnectivity.size());
4641 for( int i = 0; aConnIter != aNodesConnectivity.end(); aConnIter++, i++ )
4642 myPreviewData->elementConnectivities[i] = *aConnIter;
4648 // add new nodes into myLastCreatedNodes
4649 const SMESH_SequenceOfElemPtr& aSeq = anEditor.GetLastCreatedNodes();
4650 myLastCreatedNodes->length(aSeq.Length());
4651 for(int i=0; i<aSeq.Length(); i++)
4652 myLastCreatedNodes[i] = aSeq.Value(i+1)->GetID();
4655 // add new elements into myLastCreatedElems
4656 const SMESH_SequenceOfElemPtr& aSeq = anEditor.GetLastCreatedElems();
4657 myLastCreatedElems->length(aSeq.Length());
4658 for(int i=0; i<aSeq.Length(); i++)
4659 myLastCreatedElems[i] = aSeq.Value(i+1)->GetID();
4663 //================================================================================
4665 * Return data of mesh edition preview
4667 //================================================================================
4669 SMESH::MeshPreviewStruct* SMESH_MeshEditor_i::GetPreviewData()
4671 return myPreviewData._retn();
4674 //================================================================================
4676 * \brief Returns list of it's IDs of created nodes
4677 * \retval SMESH::long_array* - list of node ID
4679 //================================================================================
4681 SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedNodes()
4683 return myLastCreatedNodes._retn();
4686 //================================================================================
4688 * \brief Returns list of it's IDs of created elements
4689 * \retval SMESH::long_array* - list of elements' ID
4691 //================================================================================
4693 SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedElems()
4695 return myLastCreatedElems._retn();
4698 //=======================================================================
4699 //function : ConvertToQuadratic
4701 //=======================================================================
4703 void SMESH_MeshEditor_i::ConvertToQuadratic(CORBA::Boolean theForce3d)
4705 ::SMESH_MeshEditor anEditor( myMesh );
4706 anEditor.ConvertToQuadratic(theForce3d);
4707 TPythonDump() << this << ".ConvertToQuadratic( " << theForce3d << " )";
4708 myMesh->GetMeshDS()->Modified();
4709 myMesh->SetIsModified( true );
4712 //=======================================================================
4713 //function : ConvertFromQuadratic
4715 //=======================================================================
4717 CORBA::Boolean SMESH_MeshEditor_i::ConvertFromQuadratic()
4719 ::SMESH_MeshEditor anEditor( myMesh );
4720 CORBA::Boolean isDone = anEditor.ConvertFromQuadratic();
4721 TPythonDump() << this << ".ConvertFromQuadratic()";
4722 myMesh->GetMeshDS()->Modified();
4724 myMesh->SetIsModified( true );
4728 //=======================================================================
4729 //function : makeMesh
4730 //purpose : create a named imported mesh
4731 //=======================================================================
4733 SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::makeMesh(const char* theMeshName)
4735 SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen();
4736 SMESH::SMESH_Mesh_var mesh = gen->CreateEmptyMesh();
4737 SALOMEDS::Study_var study = gen->GetCurrentStudy();
4738 SALOMEDS::SObject_var meshSO = gen->ObjectToSObject( study, mesh );
4739 gen->SetName( meshSO, theMeshName, "Mesh" );
4740 gen->SetPixMap( meshSO, "ICON_SMESH_TREE_MESH_IMPORTED");
4742 return mesh._retn();
4745 //=======================================================================
4746 //function : DumpGroupsList
4748 //=======================================================================
4749 void SMESH_MeshEditor_i::DumpGroupsList(TPythonDump & theDumpPython,
4750 const SMESH::ListOfGroups * theGroupList)
4752 bool isDumpGroupList = theGroupList && theGroupList->length() > 0;
4753 if(isDumpGroupList) {
4754 theDumpPython << theGroupList << " = ";
4758 //================================================================================
4760 \brief Generates the unique group name.
4761 \param thePrefix name prefix
4764 //================================================================================
4765 string SMESH_MeshEditor_i::generateGroupName(const string& thePrefix)
4767 SMESH::ListOfGroups_var groups = myMesh_i->GetGroups();
4768 set<string> groupNames;
4770 // Get existing group names
4771 for (int i = 0, nbGroups = groups->length(); i < nbGroups; i++ ) {
4772 SMESH::SMESH_GroupBase_var aGroup = groups[i];
4773 if (CORBA::is_nil(aGroup))
4776 groupNames.insert(aGroup->GetName());
4780 string name = thePrefix;
4783 while (!groupNames.insert(name).second) {
4788 TCollection_AsciiString nbStr(index+1);
4789 name.resize( name.rfind('_')+1 );
4790 name += nbStr.ToCString();
4798 //================================================================================
4800 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
4801 \param theNodes - identifiers of nodes to be doubled
4802 \param theModifiedElems - identifiers of elements to be updated by the new (doubled)
4803 nodes. If list of element identifiers is empty then nodes are doubled but
4804 they not assigned to elements
4805 \return TRUE if operation has been completed successfully, FALSE otherwise
4806 \sa DoubleNode(), DoubleNodeGroup(), DoubleNodeGroups()
4808 //================================================================================
4810 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodes( const SMESH::long_array& theNodes,
4811 const SMESH::long_array& theModifiedElems )
4815 ::SMESH_MeshEditor aMeshEditor( myMesh );
4816 list< int > aListOfNodes;
4818 for ( i = 0, n = theNodes.length(); i < n; i++ )
4819 aListOfNodes.push_back( theNodes[ i ] );
4821 list< int > aListOfElems;
4822 for ( i = 0, n = theModifiedElems.length(); i < n; i++ )
4823 aListOfElems.push_back( theModifiedElems[ i ] );
4825 bool aResult = aMeshEditor.DoubleNodes( aListOfNodes, aListOfElems );
4827 myMesh->GetMeshDS()->Modified();
4828 storeResult( aMeshEditor) ;
4830 myMesh->SetIsModified( true );
4832 // Update Python script
4833 TPythonDump() << this << ".DoubleNodes( " << theNodes << ", "<< theModifiedElems << " )";
4838 //================================================================================
4840 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
4841 This method provided for convenience works as DoubleNodes() described above.
4842 \param theNodeId - identifier of node to be doubled.
4843 \param theModifiedElems - identifiers of elements to be updated.
4844 \return TRUE if operation has been completed successfully, FALSE otherwise
4845 \sa DoubleNodes(), DoubleNodeGroup(), DoubleNodeGroups()
4847 //================================================================================
4849 CORBA::Boolean SMESH_MeshEditor_i::DoubleNode( CORBA::Long theNodeId,
4850 const SMESH::long_array& theModifiedElems )
4852 SMESH::long_array_var aNodes = new SMESH::long_array;
4853 aNodes->length( 1 );
4854 aNodes[ 0 ] = theNodeId;
4856 TPythonDump pyDump; // suppress dump by the next line
4858 CORBA::Boolean done = DoubleNodes( aNodes, theModifiedElems );
4860 pyDump << this << ".DoubleNode( " << theNodeId << ", " << theModifiedElems << " )";
4865 //================================================================================
4867 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
4868 This method provided for convenience works as DoubleNodes() described above.
4869 \param theNodes - group of nodes to be doubled.
4870 \param theModifiedElems - group of elements to be updated.
4871 \return TRUE if operation has been completed successfully, FALSE otherwise
4872 \sa DoubleNode(), DoubleNodes(), DoubleNodeGroups()
4874 //================================================================================
4876 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroup(SMESH::SMESH_GroupBase_ptr theNodes,
4877 SMESH::SMESH_GroupBase_ptr theModifiedElems )
4879 if ( CORBA::is_nil( theNodes ) && theNodes->GetType() != SMESH::NODE )
4882 SMESH::long_array_var aNodes = theNodes->GetListOfID();
4883 SMESH::long_array_var aModifiedElems;
4884 if ( !CORBA::is_nil( theModifiedElems ) )
4885 aModifiedElems = theModifiedElems->GetListOfID();
4888 aModifiedElems = new SMESH::long_array;
4889 aModifiedElems->length( 0 );
4892 TPythonDump pyDump; // suppress dump by the next line
4894 bool done = DoubleNodes( aNodes, aModifiedElems );
4896 pyDump << this << ".DoubleNodeGroup( " << theNodes << ", " << theModifiedElems << " )";
4902 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements.
4903 * Works as DoubleNodeGroup(), but returns a new group with newly created nodes.
4904 * \param theNodes - group of nodes to be doubled.
4905 * \param theModifiedElems - group of elements to be updated.
4906 * \return a new group with newly created nodes
4907 * \sa DoubleNodeGroup()
4909 SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeGroupNew( SMESH::SMESH_GroupBase_ptr theNodes,
4910 SMESH::SMESH_GroupBase_ptr theModifiedElems )
4912 if ( CORBA::is_nil( theNodes ) && theNodes->GetType() != SMESH::NODE )
4915 SMESH::SMESH_Group_var aNewGroup;
4918 SMESH::long_array_var aNodes = theNodes->GetListOfID();
4919 SMESH::long_array_var aModifiedElems;
4920 if ( !CORBA::is_nil( theModifiedElems ) )
4921 aModifiedElems = theModifiedElems->GetListOfID();
4923 aModifiedElems = new SMESH::long_array;
4924 aModifiedElems->length( 0 );
4927 TPythonDump pyDump; // suppress dump by the next line
4929 bool aResult = DoubleNodes( aNodes, aModifiedElems );
4933 // Create group with newly created nodes
4934 SMESH::long_array_var anIds = GetLastCreatedNodes();
4935 if (anIds->length() > 0) {
4936 string anUnindexedName (theNodes->GetName());
4937 string aNewName = generateGroupName(anUnindexedName + "_double");
4938 aNewGroup = myMesh_i->CreateGroup(SMESH::NODE, aNewName.c_str());
4939 aNewGroup->Add(anIds);
4943 pyDump << "createdNodes = " << this << ".DoubleNodeGroupNew( " << theNodes << ", "
4944 << theModifiedElems << " )";
4946 return aNewGroup._retn();
4949 //================================================================================
4951 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
4952 This method provided for convenience works as DoubleNodes() described above.
4953 \param theNodes - list of groups of nodes to be doubled
4954 \param theModifiedElems - list of groups of elements to be updated.
4955 \return TRUE if operation has been completed successfully, FALSE otherwise
4956 \sa DoubleNode(), DoubleNodeGroup(), DoubleNodes()
4958 //================================================================================
4960 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroups(const SMESH::ListOfGroups& theNodes,
4961 const SMESH::ListOfGroups& theModifiedElems )
4965 ::SMESH_MeshEditor aMeshEditor( myMesh );
4967 std::list< int > aNodes;
4969 for ( i = 0, n = theNodes.length(); i < n; i++ )
4971 SMESH::SMESH_GroupBase_var aGrp = theNodes[ i ];
4972 if ( !CORBA::is_nil( aGrp ) && aGrp->GetType() == SMESH::NODE )
4974 SMESH::long_array_var aCurr = aGrp->GetListOfID();
4975 for ( j = 0, m = aCurr->length(); j < m; j++ )
4976 aNodes.push_back( aCurr[ j ] );
4980 std::list< int > anElems;
4981 for ( i = 0, n = theModifiedElems.length(); i < n; i++ )
4983 SMESH::SMESH_GroupBase_var aGrp = theModifiedElems[ i ];
4984 if ( !CORBA::is_nil( aGrp ) && aGrp->GetType() != SMESH::NODE )
4986 SMESH::long_array_var aCurr = aGrp->GetListOfID();
4987 for ( j = 0, m = aCurr->length(); j < m; j++ )
4988 anElems.push_back( aCurr[ j ] );
4992 bool aResult = aMeshEditor.DoubleNodes( aNodes, anElems );
4994 storeResult( aMeshEditor) ;
4996 myMesh->GetMeshDS()->Modified();
4998 myMesh->SetIsModified( true );
5001 TPythonDump() << this << ".DoubleNodeGroups( " << theNodes << ", " << theModifiedElems << " )";
5006 //================================================================================
5008 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements.
5009 * Works as DoubleNodeGroups(), but returns a new group with newly created nodes.
5010 * \param theNodes - group of nodes to be doubled.
5011 * \param theModifiedElems - group of elements to be updated.
5012 * \return a new group with newly created nodes
5013 * \sa DoubleNodeGroups()
5015 //================================================================================
5017 SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeGroupsNew( const SMESH::ListOfGroups& theNodes,
5018 const SMESH::ListOfGroups& theModifiedElems )
5020 SMESH::SMESH_Group_var aNewGroup;
5022 TPythonDump pyDump; // suppress dump by the next line
5024 bool aResult = DoubleNodeGroups( theNodes, theModifiedElems );
5028 // Create group with newly created nodes
5029 SMESH::long_array_var anIds = GetLastCreatedNodes();
5030 if (anIds->length() > 0) {
5031 string anUnindexedName (theNodes[0]->GetName());
5032 string aNewName = generateGroupName(anUnindexedName + "_double");
5033 aNewGroup = myMesh_i->CreateGroup(SMESH::NODE, aNewName.c_str());
5034 aNewGroup->Add(anIds);
5038 pyDump << "createdNodes = " << this << ".DoubleNodeGroupsNew( " << theNodes << ", "
5039 << theModifiedElems << " )";
5041 return aNewGroup._retn();
5045 //================================================================================
5047 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5048 \param theElems - the list of elements (edges or faces) to be replicated
5049 The nodes for duplication could be found from these elements
5050 \param theNodesNot - list of nodes to NOT replicate
5051 \param theAffectedElems - the list of elements (cells and edges) to which the
5052 replicated nodes should be associated to.
5053 \return TRUE if operation has been completed successfully, FALSE otherwise
5054 \sa DoubleNodeGroup(), DoubleNodeGroups()
5056 //================================================================================
5058 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElem( const SMESH::long_array& theElems,
5059 const SMESH::long_array& theNodesNot,
5060 const SMESH::long_array& theAffectedElems )
5065 ::SMESH_MeshEditor aMeshEditor( myMesh );
5067 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5068 TIDSortedElemSet anElems, aNodes, anAffected;
5069 arrayToSet(theElems, aMeshDS, anElems, SMDSAbs_All);
5070 arrayToSet(theNodesNot, aMeshDS, aNodes, SMDSAbs_Node);
5071 arrayToSet(theAffectedElems, aMeshDS, anAffected, SMDSAbs_All);
5073 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
5075 storeResult( aMeshEditor) ;
5077 myMesh->GetMeshDS()->Modified();
5079 myMesh->SetIsModified( true );
5081 // Update Python script
5082 TPythonDump() << this << ".DoubleNodeElem( " << theElems << ", "
5083 << theNodesNot << ", " << theAffectedElems << " )";
5087 //================================================================================
5089 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5090 \param theElems - the list of elements (edges or faces) to be replicated
5091 The nodes for duplication could be found from these elements
5092 \param theNodesNot - list of nodes to NOT replicate
5093 \param theShape - shape to detect affected elements (element which geometric center
5094 located on or inside shape).
5095 The replicated nodes should be associated to affected elements.
5096 \return TRUE if operation has been completed successfully, FALSE otherwise
5097 \sa DoubleNodeGroupInRegion(), DoubleNodeGroupsInRegion()
5099 //================================================================================
5101 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemInRegion ( const SMESH::long_array& theElems,
5102 const SMESH::long_array& theNodesNot,
5103 GEOM::GEOM_Object_ptr theShape )
5108 ::SMESH_MeshEditor aMeshEditor( myMesh );
5110 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5111 TIDSortedElemSet anElems, aNodes;
5112 arrayToSet(theElems, aMeshDS, anElems, SMDSAbs_All);
5113 arrayToSet(theNodesNot, aMeshDS, aNodes, SMDSAbs_Node);
5115 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape );
5116 bool aResult = aMeshEditor.DoubleNodesInRegion( anElems, aNodes, aShape );
5118 storeResult( aMeshEditor) ;
5120 myMesh->GetMeshDS()->Modified();
5122 myMesh->SetIsModified( true );
5124 // Update Python script
5125 TPythonDump() << "isDone = " << this << ".DoubleNodeElemInRegion( " << theElems << ", "
5126 << theNodesNot << ", " << theShape << " )";
5130 //================================================================================
5132 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5133 \param theElems - group of of elements (edges or faces) to be replicated
5134 \param theNodesNot - group of nodes not to replicated
5135 \param theAffectedElems - group of elements to which the replicated nodes
5136 should be associated to.
5137 \return TRUE if operation has been completed successfully, FALSE otherwise
5138 \sa DoubleNodes(), DoubleNodeGroups()
5140 //================================================================================
5142 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroup(SMESH::SMESH_GroupBase_ptr theElems,
5143 SMESH::SMESH_GroupBase_ptr theNodesNot,
5144 SMESH::SMESH_GroupBase_ptr theAffectedElems)
5146 if ( CORBA::is_nil( theElems ) && theElems->GetType() == SMESH::NODE )
5151 ::SMESH_MeshEditor aMeshEditor( myMesh );
5153 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5154 TIDSortedElemSet anElems, aNodes, anAffected;
5155 idSourceToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
5156 idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
5157 idSourceToSet( theAffectedElems, aMeshDS, anAffected, SMDSAbs_All );
5159 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
5161 storeResult( aMeshEditor) ;
5163 myMesh->GetMeshDS()->Modified();
5165 myMesh->SetIsModified( true );
5167 // Update Python script
5168 TPythonDump() << "isDone = " << this << ".DoubleNodeElemGroup( " << theElems << ", "
5169 << theNodesNot << ", " << theAffectedElems << " )";
5174 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5175 * Works as DoubleNodeElemGroup(), but returns a new group with newly created elements.
5176 * \param theElems - group of of elements (edges or faces) to be replicated
5177 * \param theNodesNot - group of nodes not to replicated
5178 * \param theAffectedElems - group of elements to which the replicated nodes
5179 * should be associated to.
5180 * \return a new group with newly created elements
5181 * \sa DoubleNodeElemGroup()
5183 SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeElemGroupNew(SMESH::SMESH_GroupBase_ptr theElems,
5184 SMESH::SMESH_GroupBase_ptr theNodesNot,
5185 SMESH::SMESH_GroupBase_ptr theAffectedElems)
5187 if ( CORBA::is_nil( theElems ) && theElems->GetType() == SMESH::NODE )
5190 SMESH::SMESH_Group_var aNewGroup;
5194 ::SMESH_MeshEditor aMeshEditor( myMesh );
5196 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5197 TIDSortedElemSet anElems, aNodes, anAffected;
5198 idSourceToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
5199 idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
5200 idSourceToSet( theAffectedElems, aMeshDS, anAffected, SMDSAbs_All );
5203 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
5205 storeResult( aMeshEditor) ;
5208 myMesh->SetIsModified( true );
5210 // Create group with newly created elements
5211 SMESH::long_array_var anIds = GetLastCreatedElems();
5212 if (anIds->length() > 0) {
5213 SMESH::ElementType aGroupType = myMesh_i->GetElementType(anIds[0], true);
5214 string anUnindexedName (theElems->GetName());
5215 string aNewName = generateGroupName(anUnindexedName + "_double");
5216 aNewGroup = myMesh_i->CreateGroup(aGroupType, aNewName.c_str());
5217 aNewGroup->Add(anIds);
5221 // Update Python script
5222 TPythonDump() << "createdElems = " << this << ".DoubleNodeElemGroupNew( " << theElems << ", "
5223 << theNodesNot << ", " << theAffectedElems << " )";
5224 return aNewGroup._retn();
5227 //================================================================================
5229 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5230 \param theElems - group of of elements (edges or faces) to be replicated
5231 \param theNodesNot - group of nodes not to replicated
5232 \param theShape - shape to detect affected elements (element which geometric center
5233 located on or inside shape).
5234 The replicated nodes should be associated to affected elements.
5235 \return TRUE if operation has been completed successfully, FALSE otherwise
5236 \sa DoubleNodesInRegion(), DoubleNodeGroupsInRegion()
5238 //================================================================================
5240 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroupInRegion(SMESH::SMESH_GroupBase_ptr theElems,
5241 SMESH::SMESH_GroupBase_ptr theNodesNot,
5242 GEOM::GEOM_Object_ptr theShape )
5245 if ( CORBA::is_nil( theElems ) && theElems->GetType() == SMESH::NODE )
5250 ::SMESH_MeshEditor aMeshEditor( myMesh );
5252 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5253 TIDSortedElemSet anElems, aNodes, anAffected;
5254 idSourceToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
5255 idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
5257 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape );
5258 bool aResult = aMeshEditor.DoubleNodesInRegion( anElems, aNodes, aShape );
5260 storeResult( aMeshEditor) ;
5262 myMesh->GetMeshDS()->Modified();
5264 myMesh->SetIsModified( true );
5266 // Update Python script
5267 TPythonDump() << "isDone = " << this << ".DoubleNodeElemGroupInRegion( " << theElems << ", "
5268 << theNodesNot << ", " << theShape << " )";
5272 //================================================================================
5274 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5275 This method provided for convenience works as DoubleNodes() described above.
5276 \param theElems - list of groups of elements (edges or faces) to be replicated
5277 \param theNodesNot - list of groups of nodes not to replicated
5278 \param theAffectedElems - group of elements to which the replicated nodes
5279 should be associated to.
5280 \return TRUE if operation has been completed successfully, FALSE otherwise
5281 \sa DoubleNodeGroup(), DoubleNodes(), DoubleNodeElemGroupsNew()
5283 //================================================================================
5285 static void listOfGroupToSet(const SMESH::ListOfGroups& theGrpList,
5286 SMESHDS_Mesh* theMeshDS,
5287 TIDSortedElemSet& theElemSet,
5288 const bool theIsNodeGrp)
5290 for ( int i = 0, n = theGrpList.length(); i < n; i++ )
5292 SMESH::SMESH_GroupBase_var aGrp = theGrpList[ i ];
5293 if ( !CORBA::is_nil( aGrp ) && (theIsNodeGrp ? aGrp->GetType() == SMESH::NODE
5294 : aGrp->GetType() != SMESH::NODE ) )
5296 SMESH::long_array_var anIDs = aGrp->GetIDs();
5297 arrayToSet( anIDs, theMeshDS, theElemSet, theIsNodeGrp ? SMDSAbs_Node : SMDSAbs_All );
5302 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroups(const SMESH::ListOfGroups& theElems,
5303 const SMESH::ListOfGroups& theNodesNot,
5304 const SMESH::ListOfGroups& theAffectedElems)
5308 ::SMESH_MeshEditor aMeshEditor( myMesh );
5310 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5311 TIDSortedElemSet anElems, aNodes, anAffected;
5312 listOfGroupToSet(theElems, aMeshDS, anElems, false );
5313 listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true );
5314 listOfGroupToSet(theAffectedElems, aMeshDS, anAffected, false );
5316 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
5318 storeResult( aMeshEditor) ;
5320 myMesh->GetMeshDS()->Modified();
5322 myMesh->SetIsModified( true );
5324 // Update Python script
5325 TPythonDump() << "isDone = " << this << ".DoubleNodeElemGroups( " << &theElems << ", "
5326 << &theNodesNot << ", " << &theAffectedElems << " )";
5330 //================================================================================
5332 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5333 * Works as DoubleNodeElemGroups(), but returns a new group with newly created elements.
5334 \param theElems - list of groups of elements (edges or faces) to be replicated
5335 \param theNodesNot - list of groups of nodes not to replicated
5336 \param theAffectedElems - group of elements to which the replicated nodes
5337 should be associated to.
5338 * \return a new group with newly created elements
5339 * \sa DoubleNodeElemGroups()
5341 //================================================================================
5343 SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeElemGroupsNew(const SMESH::ListOfGroups& theElems,
5344 const SMESH::ListOfGroups& theNodesNot,
5345 const SMESH::ListOfGroups& theAffectedElems)
5347 SMESH::SMESH_Group_var aNewGroup;
5351 ::SMESH_MeshEditor aMeshEditor( myMesh );
5353 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5354 TIDSortedElemSet anElems, aNodes, anAffected;
5355 listOfGroupToSet(theElems, aMeshDS, anElems, false );
5356 listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true );
5357 listOfGroupToSet(theAffectedElems, aMeshDS, anAffected, false );
5359 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
5361 storeResult( aMeshEditor) ;
5363 myMesh->GetMeshDS()->Modified();
5365 myMesh->SetIsModified( true );
5367 // Create group with newly created elements
5368 SMESH::long_array_var anIds = GetLastCreatedElems();
5369 if (anIds->length() > 0) {
5370 SMESH::ElementType aGroupType = myMesh_i->GetElementType(anIds[0], true);
5371 string anUnindexedName (theElems[0]->GetName());
5372 string aNewName = generateGroupName(anUnindexedName + "_double");
5373 aNewGroup = myMesh_i->CreateGroup(aGroupType, aNewName.c_str());
5374 aNewGroup->Add(anIds);
5378 // Update Python script
5379 TPythonDump() << "createdElems = " << this << ".DoubleNodeElemGroupsNew( " << &theElems << ", "
5380 << &theNodesNot << ", " << &theAffectedElems << " )";
5381 return aNewGroup._retn();
5384 //================================================================================
5386 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5387 This method provided for convenience works as DoubleNodes() described above.
5388 \param theElems - list of groups of elements (edges or faces) to be replicated
5389 \param theNodesNot - list of groups of nodes not to replicated
5390 \param theShape - shape to detect affected elements (element which geometric center
5391 located on or inside shape).
5392 The replicated nodes should be associated to affected elements.
5393 \return TRUE if operation has been completed successfully, FALSE otherwise
5394 \sa DoubleNodeGroupInRegion(), DoubleNodesInRegion()
5396 //================================================================================
5399 SMESH_MeshEditor_i::DoubleNodeElemGroupsInRegion(const SMESH::ListOfGroups& theElems,
5400 const SMESH::ListOfGroups& theNodesNot,
5401 GEOM::GEOM_Object_ptr theShape )
5405 ::SMESH_MeshEditor aMeshEditor( myMesh );
5407 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5408 TIDSortedElemSet anElems, aNodes;
5409 listOfGroupToSet(theElems, aMeshDS, anElems,false );
5410 listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true );
5412 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape );
5413 bool aResult = aMeshEditor.DoubleNodesInRegion( anElems, aNodes, aShape );
5415 storeResult( aMeshEditor) ;
5417 myMesh->GetMeshDS()->Modified();
5419 myMesh->SetIsModified( true );
5421 // Update Python script
5422 TPythonDump() << "isDone = " << this << ".DoubleNodeElemGroupsInRegion( " << &theElems << ", "
5423 << &theNodesNot << ", " << theShape << " )";
5427 //================================================================================
5429 \brief Generated skin mesh (containing 2D cells) from 3D mesh
5430 The created 2D mesh elements based on nodes of free faces of boundary volumes
5431 \return TRUE if operation has been completed successfully, FALSE otherwise
5433 //================================================================================
5435 CORBA::Boolean SMESH_MeshEditor_i::Make2DMeshFrom3D()
5439 ::SMESH_MeshEditor aMeshEditor( myMesh );
5440 bool aResult = aMeshEditor.Make2DMeshFrom3D();
5441 storeResult( aMeshEditor) ;
5442 myMesh->GetMeshDS()->Modified();
5443 TPythonDump() << "isDone = " << this << ".Make2DMeshFrom3D()";
5447 //================================================================================
5449 * \brief Double nodes on shared faces between groups of volumes and create flat elements on demand.
5450 * The list of groups must describe a partition of the mesh volumes.
5451 * The nodes of the internal faces at the boundaries of the groups are doubled.
5452 * In option, the internal faces are replaced by flat elements.
5453 * Triangles are transformed in prisms, and quadrangles in hexahedrons.
5454 * @param theDomains - list of groups of volumes
5455 * @param createJointElems - if TRUE, create the elements
5456 * @return TRUE if operation has been completed successfully, FALSE otherwise
5458 //================================================================================
5460 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodesOnGroupBoundaries( const SMESH::ListOfGroups& theDomains,
5461 CORBA::Boolean createJointElems )
5465 ::SMESH_MeshEditor aMeshEditor( myMesh );
5467 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5469 vector<TIDSortedElemSet> domains;
5472 for ( int i = 0, n = theDomains.length(); i < n; i++ )
5474 SMESH::SMESH_GroupBase_var aGrp = theDomains[ i ];
5475 if ( !CORBA::is_nil( aGrp ) && ( aGrp->GetType() != SMESH::NODE ) )
5477 TIDSortedElemSet domain;
5479 domains.push_back(domain);
5480 SMESH::long_array_var anIDs = aGrp->GetIDs();
5481 arrayToSet( anIDs, aMeshDS, domains[ i ], SMDSAbs_All );
5485 bool aResult = aMeshEditor.DoubleNodesOnGroupBoundaries( domains, createJointElems );
5487 storeResult( aMeshEditor) ;
5488 myMesh->GetMeshDS()->Modified();
5490 // Update Python script
5491 TPythonDump() << "isDone = " << this << ".DoubleNodesOnGroupBoundaries( " << &theDomains
5492 << ", " << createJointElems << " )";
5496 // issue 20749 ===================================================================
5498 * \brief Creates missing boundary elements
5499 * \param elements - elements whose boundary is to be checked
5500 * \param dimension - defines type of boundary elements to create
5501 * \param groupName - a name of group to store created boundary elements in,
5502 * "" means not to create the group
5503 * \param meshName - a name of new mesh to store created boundary elements in,
5504 * "" means not to create the new mesh
5505 * \param toCopyElements - if true, the checked elements will be copied into the new mesh
5506 * \param toCopyExistingBondary - if true, not only new but also pre-existing
5507 * boundary elements will be copied into the new mesh
5508 * \param group - returns the create group, if any
5509 * \retval SMESH::SMESH_Mesh - the mesh where elements were added to
5511 // ================================================================================
5513 SMESH::SMESH_Mesh_ptr
5514 SMESH_MeshEditor_i::MakeBoundaryMesh(SMESH::SMESH_IDSource_ptr idSource,
5515 SMESH::Bnd_Dimension dim,
5516 const char* groupName,
5517 const char* meshName,
5518 CORBA::Boolean toCopyElements,
5519 CORBA::Boolean toCopyExistingBondary,
5520 SMESH::SMESH_Group_out group)
5524 if ( dim > SMESH::BND_1DFROM2D )
5525 THROW_SALOME_CORBA_EXCEPTION("Invalid boundary dimension", SALOME::BAD_PARAM);
5528 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5530 SMESH::SMESH_Mesh_var mesh_var;
5531 SMESH::SMESH_Group_var group_var;
5535 TIDSortedElemSet elements;
5536 SMDSAbs_ElementType elemType = (dim == SMESH::BND_1DFROM2D) ? SMDSAbs_Face : SMDSAbs_Volume;
5537 if ( idSourceToSet( idSource, aMeshDS, elements, elemType,/*emptyIfIsMesh=*/true ))
5541 strlen(meshName) ? makeMesh(meshName) : SMESH::SMESH_Mesh::_duplicate(myMesh_i->_this());
5542 SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh_var );
5544 SMESH_Mesh* smesh_mesh = (mesh_i==myMesh_i) ? (SMESH_Mesh*)0 : &mesh_i->GetImpl();
5546 // group of new boundary elements
5547 SMESH_Group* smesh_group = 0;
5548 if ( strlen(groupName) )
5550 group_var = mesh_i->CreateGroup( SMESH::ElementType(int(elemType)-1),groupName);
5551 if ( SMESH_GroupBase_i* group_i = SMESH::DownCast<SMESH_GroupBase_i*>( group_var ))
5552 smesh_group = group_i->GetSmeshGroup();
5556 ::SMESH_MeshEditor aMeshEditor( myMesh );
5557 aMeshEditor.MakeBoundaryMesh( elements,
5558 ::SMESH_MeshEditor::Bnd_Dimension(dim),
5562 toCopyExistingBondary);
5563 storeResult( aMeshEditor );
5566 const char* dimName[] = { "BND_2DFROM3D", "BND_1DFROM3D", "BND_1DFROM2D" };
5568 // result of MakeBoundaryMesh() is a tuple (mesh, group)
5569 if ( mesh_var->_is_nil() )
5570 pyDump << myMesh_i->_this() << ", ";
5572 pyDump << mesh_var << ", ";
5573 if ( group_var->_is_nil() )
5574 pyDump << "_NoneGroup = "; // assignment to None is forbiden
5576 pyDump << group_var << " = ";
5577 pyDump << this << ".MakeBoundaryMesh( "
5579 << "SMESH." << dimName[int(dim)] << ", "
5580 << "'" << groupName << "', "
5581 << "'" << meshName<< "', "
5582 << toCopyElements << ", "
5583 << toCopyExistingBondary << ")";
5585 group = group_var._retn();
5586 return mesh_var._retn();