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
23 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
24 // File : SMESH_MeshEditor_i.cxx
25 // Author : Nicolas REJNERI
28 #include "SMESH_MeshEditor_i.hxx"
30 #include "SMDS_Mesh0DElement.hxx"
31 #include "SMDS_MeshEdge.hxx"
32 #include "SMDS_MeshFace.hxx"
33 #include "SMDS_MeshVolume.hxx"
34 #include "SMDS_PolyhedralVolumeOfNodes.hxx"
35 #include "SMESH_MeshEditor.hxx"
36 #include "SMESH_subMeshEventListener.hxx"
37 #include "SMESH_Gen_i.hxx"
38 #include "SMESH_Filter_i.hxx"
39 #include "SMESH_subMesh_i.hxx"
40 #include "SMESH_Group_i.hxx"
41 #include "SMESH_PythonDump.hxx"
42 #include "SMESH_ControlsDef.hxx"
44 #include "utilities.h"
45 #include "Utils_ExceptHandlers.hxx"
46 #include "Utils_CorbaException.hxx"
48 #include <BRepAdaptor_Surface.hxx>
49 #include <BRep_Tool.hxx>
50 #include <TopExp_Explorer.hxx>
52 #include <TopoDS_Edge.hxx>
53 #include <TopoDS_Face.hxx>
58 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
62 #include <Standard_Failure.hxx>
65 #include <Standard_ErrorHandler.hxx>
70 #define cast2Node(elem) static_cast<const SMDS_MeshNode*>( elem )
73 using SMESH::TPythonDump;
77 //=============================================================================
79 * \brief Mesh to apply modifications for preview purposes
81 //=============================================================================
83 struct TPreviewMesh: public SMESH_Mesh
85 SMDSAbs_ElementType myPreviewType; // type to show
87 TPreviewMesh(SMDSAbs_ElementType previewElements = SMDSAbs_All) {
88 _isShapeToMesh = (_id =_studyId =_idDoc = 0);
89 _myMeshDS = new SMESHDS_Mesh( _id, true );
90 myPreviewType = previewElements;
93 virtual ~TPreviewMesh() { delete _myMeshDS; }
94 //!< Copy a set of elements
95 void Copy(const TIDSortedElemSet & theElements,
96 TIDSortedElemSet& theCopyElements,
97 SMDSAbs_ElementType theSelectType = SMDSAbs_All,
98 SMDSAbs_ElementType theAvoidType = SMDSAbs_All)
100 // loop on theIDsOfElements
101 TIDSortedElemSet::const_iterator eIt = theElements.begin();
102 for ( ; eIt != theElements.end(); ++eIt )
104 const SMDS_MeshElement* anElem = *eIt;
105 if ( !anElem ) continue;
106 SMDSAbs_ElementType type = anElem->GetType();
107 if ( type == theAvoidType ||
108 ( theSelectType != SMDSAbs_All && type != theSelectType ))
111 if ( const SMDS_MeshElement* anElemCopy = Copy( anElem ))
112 theCopyElements.insert( theCopyElements.end(), anElemCopy );
116 SMDS_MeshElement* Copy( const SMDS_MeshElement* anElem )
118 // copy element nodes
119 int anElemNbNodes = anElem->NbNodes();
120 vector< int > anElemNodesID( anElemNbNodes ) ;
121 SMDS_ElemIteratorPtr itElemNodes = anElem->nodesIterator();
122 for ( int i = 0; itElemNodes->more(); i++)
124 const SMDS_MeshNode* anElemNode = cast2Node( itElemNodes->next() );
126 anElemNodesID[i] = anElemNode->GetID();
129 // creates a corresponding element on copied nodes
130 SMDS_MeshElement* anElemCopy = 0;
131 if ( anElem->IsPoly() && anElem->GetType() == SMDSAbs_Volume )
133 const SMDS_PolyhedralVolumeOfNodes* ph =
134 dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*> (anElem);
136 anElemCopy = _myMeshDS->AddPolyhedralVolumeWithID
137 (anElemNodesID, ph->GetQuanities(),anElem->GetID());
140 anElemCopy = ::SMESH_MeshEditor(this).AddElement( anElemNodesID,
147 SMDS_MeshNode* Copy( const SMDS_MeshNode* anElemNode )
149 return _myMeshDS->AddNodeWithID(anElemNode->X(), anElemNode->Y(), anElemNode->Z(),
150 anElemNode->GetID());
152 };// struct TPreviewMesh
154 static SMESH_NodeSearcher * theNodeSearcher = 0;
155 static SMESH_ElementSearcher * theElementSearcher = 0;
157 //=============================================================================
159 * \brief Deleter of theNodeSearcher at any compute event occured
161 //=============================================================================
163 struct TSearchersDeleter : public SMESH_subMeshEventListener
167 TSearchersDeleter(): SMESH_subMeshEventListener( false ), // won't be deleted by submesh
169 //!< Delete theNodeSearcher
172 if ( theNodeSearcher ) delete theNodeSearcher; theNodeSearcher = 0;
173 if ( theElementSearcher ) delete theElementSearcher; theElementSearcher = 0;
175 typedef map < int, SMESH_subMesh * > TDependsOnMap;
176 //!< The meshod called by submesh: do my main job
177 void ProcessEvent(const int, const int eventType, SMESH_subMesh* sm,
178 SMESH_subMeshEventListenerData*,const SMESH_Hypothesis*)
180 if ( eventType == SMESH_subMesh::COMPUTE_EVENT ) {
182 Unset( sm->GetFather() );
185 //!< set self on all submeshes and delete theNodeSearcher if other mesh is set
186 void Set(SMESH_Mesh* mesh)
188 if ( myMesh != mesh )
195 if ( SMESH_subMesh* myMainSubMesh = mesh->GetSubMeshContaining(1) ) {
196 const TDependsOnMap & subMeshes = myMainSubMesh->DependsOn();
197 TDependsOnMap::const_iterator sm;
198 for (sm = subMeshes.begin(); sm != subMeshes.end(); sm++)
199 sm->second->SetEventListener( this, 0, sm->second );
203 //!< delete self from all submeshes
204 void Unset(SMESH_Mesh* mesh)
206 if ( SMESH_subMesh* myMainSubMesh = mesh->GetSubMeshContaining(1) ) {
207 const TDependsOnMap & subMeshes = myMainSubMesh->DependsOn();
208 TDependsOnMap::const_iterator sm;
209 for (sm = subMeshes.begin(); sm != subMeshes.end(); sm++)
210 sm->second->DeleteEventListener( this );
215 } theSearchersDeleter;
217 TCollection_AsciiString mirrorTypeName( SMESH::SMESH_MeshEditor::MirrorType theMirrorType )
219 TCollection_AsciiString typeStr;
220 switch ( theMirrorType ) {
221 case SMESH::SMESH_MeshEditor::POINT:
222 typeStr = "SMESH.SMESH_MeshEditor.POINT";
224 case SMESH::SMESH_MeshEditor::AXIS:
225 typeStr = "SMESH.SMESH_MeshEditor.AXIS";
228 typeStr = "SMESH.SMESH_MeshEditor.PLANE";
234 //=============================================================================
238 //=============================================================================
240 SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESH_Mesh_i* theMesh, bool isPreview)
243 myMesh = & theMesh->GetImpl();
244 myPreviewMode = isPreview;
247 //================================================================================
251 //================================================================================
253 SMESH_MeshEditor_i::~SMESH_MeshEditor_i()
257 //================================================================================
259 * \brief Clear members
261 //================================================================================
263 void SMESH_MeshEditor_i::initData(bool deleteSearchers)
265 if ( myPreviewMode ) {
266 myPreviewData = new SMESH::MeshPreviewStruct();
269 myLastCreatedElems = new SMESH::long_array();
270 myLastCreatedNodes = new SMESH::long_array();
271 if ( deleteSearchers )
272 TSearchersDeleter::Delete();
276 //=======================================================================
277 //function : MakeIDSource
278 //purpose : Wrap a sequence of ids in a SMESH_IDSource
279 //=======================================================================
281 struct _IDSource : public POA_SMESH::SMESH_IDSource
283 SMESH::long_array _ids;
284 SMESH::long_array* GetIDs() { return new SMESH::long_array( _ids ); }
285 SMESH::long_array* GetMeshInfo() { return 0; }
288 SMESH::SMESH_IDSource_ptr SMESH_MeshEditor_i::MakeIDSource(const SMESH::long_array& ids)
290 _IDSource* anIDSource = new _IDSource;
291 anIDSource->_ids = ids;
292 SMESH::SMESH_IDSource_var anIDSourceVar = anIDSource->_this();
294 return anIDSourceVar._retn();
297 //=============================================================================
301 //=============================================================================
304 SMESH_MeshEditor_i::RemoveElements(const SMESH::long_array & IDsOfElements)
308 ::SMESH_MeshEditor anEditor( myMesh );
311 for (int i = 0; i < IDsOfElements.length(); i++)
312 IdList.push_back( IDsOfElements[i] );
314 // Update Python script
315 TPythonDump() << "isDone = " << this << ".RemoveElements( " << IDsOfElements << " )";
317 if ( IDsOfElements.length() )
318 myMesh->SetIsModified( true ); // issue 0020693
321 return anEditor.Remove( IdList, false );
324 //=============================================================================
328 //=============================================================================
330 CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::long_array & IDsOfNodes)
334 ::SMESH_MeshEditor anEditor( myMesh );
336 for (int i = 0; i < IDsOfNodes.length(); i++)
337 IdList.push_back( IDsOfNodes[i] );
339 // Update Python script
340 TPythonDump() << "isDone = " << this << ".RemoveNodes( " << IDsOfNodes << " )";
342 if ( IDsOfNodes.length() )
343 myMesh->SetIsModified( true ); // issue 0020693
345 return anEditor.Remove( IdList, true );
348 //=============================================================================
352 //=============================================================================
354 CORBA::Long SMESH_MeshEditor_i::RemoveOrphanNodes()
358 ::SMESH_MeshEditor anEditor( myMesh );
360 // Update Python script
361 TPythonDump() << "nbRemoved = " << this << ".RemoveOrphanNodes()";
363 // Create filter to find all orphan nodes
364 SMESH::Controls::Filter::TIdSequence seq;
365 SMESH::Controls::PredicatePtr predicate( new SMESH::Controls::FreeNodes() );
366 SMESH::Controls::Filter::GetElementsId( GetMeshDS(), predicate, seq );
368 // remove orphan nodes (if there are any)
370 for ( int i = 0; i < seq.size(); i++ )
371 IdList.push_back( seq[i] );
374 myMesh->SetIsModified( true );
376 return anEditor.Remove( IdList, true );
379 //=============================================================================
383 //=============================================================================
385 CORBA::Long SMESH_MeshEditor_i::AddNode(CORBA::Double x,
386 CORBA::Double y, CORBA::Double z)
390 const SMDS_MeshNode* N = GetMeshDS()->AddNode(x, y, z);
392 // Update Python script
393 TPythonDump() << "nodeID = " << this << ".AddNode( "
394 << x << ", " << y << ", " << z << " )";
396 myMesh->SetIsModified( true ); // issue 0020693
401 //=============================================================================
405 //=============================================================================
406 CORBA::Long SMESH_MeshEditor_i::Add0DElement(CORBA::Long IDOfNode)
410 const SMDS_MeshNode* aNode = GetMeshDS()->FindNode(IDOfNode);
411 SMDS_MeshElement* elem = GetMeshDS()->Add0DElement(aNode);
413 // Update Python script
414 TPythonDump() << "elem0d = " << this << ".Add0DElement( " << IDOfNode <<" )";
416 myMesh->SetIsModified( true ); // issue 0020693
419 return elem->GetID();
424 //=============================================================================
428 //=============================================================================
430 CORBA::Long SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes)
434 int NbNodes = IDsOfNodes.length();
435 SMDS_MeshElement* elem = 0;
438 CORBA::Long index1 = IDsOfNodes[0];
439 CORBA::Long index2 = IDsOfNodes[1];
440 elem = GetMeshDS()->AddEdge(GetMeshDS()->FindNode(index1), GetMeshDS()->FindNode(index2));
442 // Update Python script
443 TPythonDump() << "edge = " << this << ".AddEdge([ "
444 << index1 << ", " << index2 <<" ])";
447 CORBA::Long n1 = IDsOfNodes[0];
448 CORBA::Long n2 = IDsOfNodes[1];
449 CORBA::Long n12 = IDsOfNodes[2];
450 elem = GetMeshDS()->AddEdge(GetMeshDS()->FindNode(n1),
451 GetMeshDS()->FindNode(n2),
452 GetMeshDS()->FindNode(n12));
453 // Update Python script
454 TPythonDump() << "edgeID = " << this << ".AddEdge([ "
455 <<n1<<", "<<n2<<", "<<n12<<" ])";
459 return myMesh->SetIsModified( true ), elem->GetID();
464 //=============================================================================
468 //=============================================================================
470 CORBA::Long SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
474 int NbNodes = IDsOfNodes.length();
480 std::vector<const SMDS_MeshNode*> nodes (NbNodes);
481 for (int i = 0; i < NbNodes; i++)
482 nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
484 SMDS_MeshElement* elem = 0;
486 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]);
488 else if (NbNodes == 4) {
489 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
491 else if (NbNodes == 6) {
492 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
495 else if (NbNodes == 8) {
496 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
497 nodes[4], nodes[5], nodes[6], nodes[7]);
499 else if (NbNodes > 2) {
500 elem = GetMeshDS()->AddPolygonalFace(nodes);
503 // Update Python script
504 TPythonDump() << "faceID = " << this << ".AddFace( " << IDsOfNodes << " )";
507 return myMesh->SetIsModified( true ), elem->GetID();
512 //=============================================================================
516 //=============================================================================
517 CORBA::Long SMESH_MeshEditor_i::AddPolygonalFace (const SMESH::long_array & IDsOfNodes)
521 int NbNodes = IDsOfNodes.length();
522 std::vector<const SMDS_MeshNode*> nodes (NbNodes);
523 for (int i = 0; i < NbNodes; i++)
524 nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
526 const SMDS_MeshElement* elem = GetMeshDS()->AddPolygonalFace(nodes);
528 // Update Python script
529 TPythonDump() <<"faceID = "<<this<<".AddPolygonalFace( "<<IDsOfNodes<<" )";
531 return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0;
534 //=============================================================================
538 //=============================================================================
540 CORBA::Long SMESH_MeshEditor_i::AddVolume(const SMESH::long_array & IDsOfNodes)
544 int NbNodes = IDsOfNodes.length();
545 vector< const SMDS_MeshNode*> n(NbNodes);
546 for(int i=0;i<NbNodes;i++)
547 n[i]=GetMeshDS()->FindNode(IDsOfNodes[i]);
549 SMDS_MeshElement* elem = 0;
552 case 4 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3]); break;
553 case 5 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4]); break;
554 case 6 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5]); break;
555 case 8 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break;
556 case 10:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],
557 n[6],n[7],n[8],n[9]);
559 case 13:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],
560 n[7],n[8],n[9],n[10],n[11],n[12]);
562 case 15:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],
563 n[9],n[10],n[11],n[12],n[13],n[14]);
565 case 20:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],
566 n[8],n[9],n[10],n[11],n[12],n[13],n[14],
567 n[15],n[16],n[17],n[18],n[19]);
571 // Update Python script
572 TPythonDump() << "volID = " << this << ".AddVolume( " << IDsOfNodes << " )";
575 return myMesh->SetIsModified( true ), elem->GetID();
580 //=============================================================================
582 * AddPolyhedralVolume
584 //=============================================================================
585 CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolume (const SMESH::long_array & IDsOfNodes,
586 const SMESH::long_array & Quantities)
590 int NbNodes = IDsOfNodes.length();
591 std::vector<const SMDS_MeshNode*> n (NbNodes);
592 for (int i = 0; i < NbNodes; i++)
593 n[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
595 int NbFaces = Quantities.length();
596 std::vector<int> q (NbFaces);
597 for (int j = 0; j < NbFaces; j++)
598 q[j] = Quantities[j];
600 const SMDS_MeshElement* elem = GetMeshDS()->AddPolyhedralVolume(n, q);
602 // Update Python script
603 TPythonDump() << "volID = " << this << ".AddPolyhedralVolume( "
604 << IDsOfNodes << ", " << Quantities << " )";
606 return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0;
609 //=============================================================================
611 * AddPolyhedralVolumeByFaces
613 //=============================================================================
614 CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces (const SMESH::long_array & IdsOfFaces)
618 int NbFaces = IdsOfFaces.length();
619 std::vector<const SMDS_MeshNode*> poly_nodes;
620 std::vector<int> quantities (NbFaces);
622 for (int i = 0; i < NbFaces; i++) {
623 const SMDS_MeshElement* aFace = GetMeshDS()->FindElement(IdsOfFaces[i]);
624 quantities[i] = aFace->NbNodes();
626 SMDS_ElemIteratorPtr It = aFace->nodesIterator();
628 poly_nodes.push_back(static_cast<const SMDS_MeshNode *>(It->next()));
632 const SMDS_MeshElement* elem = GetMeshDS()->AddPolyhedralVolume(poly_nodes, quantities);
634 // Update Python script
635 TPythonDump() << "volID = " << this << ".AddPolyhedralVolumeByFaces( "
636 << IdsOfFaces << " )";
638 return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0;
641 //=============================================================================
643 * \brief Bind a node to a vertex
644 * \param NodeID - node ID
645 * \param VertexID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
646 * \retval boolean - false if NodeID or VertexID is invalid
648 //=============================================================================
650 void SMESH_MeshEditor_i::SetNodeOnVertex(CORBA::Long NodeID, CORBA::Long VertexID)
651 throw (SALOME::SALOME_Exception)
653 Unexpect aCatch(SALOME_SalomeException);
655 SMESHDS_Mesh * mesh = GetMeshDS();
656 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
658 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
660 if ( mesh->MaxShapeIndex() < VertexID )
661 THROW_SALOME_CORBA_EXCEPTION("Invalid VertexID", SALOME::BAD_PARAM);
663 TopoDS_Shape shape = mesh->IndexToShape( VertexID );
664 if ( shape.ShapeType() != TopAbs_VERTEX )
665 THROW_SALOME_CORBA_EXCEPTION("Invalid VertexID", SALOME::BAD_PARAM);
667 mesh->SetNodeOnVertex( node, VertexID );
669 myMesh->SetIsModified( true );
672 //=============================================================================
674 * \brief Store node position on an edge
675 * \param NodeID - node ID
676 * \param EdgeID - edge ID available through GEOM_Object.GetSubShapeIndices()[0]
677 * \param paramOnEdge - parameter on edge where the node is located
678 * \retval boolean - false if any parameter is invalid
680 //=============================================================================
682 void SMESH_MeshEditor_i::SetNodeOnEdge(CORBA::Long NodeID, CORBA::Long EdgeID,
683 CORBA::Double paramOnEdge)
684 throw (SALOME::SALOME_Exception)
686 Unexpect aCatch(SALOME_SalomeException);
688 SMESHDS_Mesh * mesh = GetMeshDS();
689 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
691 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
693 if ( mesh->MaxShapeIndex() < EdgeID )
694 THROW_SALOME_CORBA_EXCEPTION("Invalid EdgeID", SALOME::BAD_PARAM);
696 TopoDS_Shape shape = mesh->IndexToShape( EdgeID );
697 if ( shape.ShapeType() != TopAbs_EDGE )
698 THROW_SALOME_CORBA_EXCEPTION("Invalid EdgeID", SALOME::BAD_PARAM);
701 BRep_Tool::Range( TopoDS::Edge( shape ), f,l);
702 if ( paramOnEdge < f || paramOnEdge > l )
703 THROW_SALOME_CORBA_EXCEPTION("Invalid paramOnEdge", SALOME::BAD_PARAM);
705 mesh->SetNodeOnEdge( node, EdgeID, paramOnEdge );
707 myMesh->SetIsModified( true );
710 //=============================================================================
712 * \brief Store node position on a face
713 * \param NodeID - node ID
714 * \param FaceID - face ID available through GEOM_Object.GetSubShapeIndices()[0]
715 * \param u - U parameter on face where the node is located
716 * \param v - V parameter on face where the node is located
717 * \retval boolean - false if any parameter is invalid
719 //=============================================================================
721 void SMESH_MeshEditor_i::SetNodeOnFace(CORBA::Long NodeID, CORBA::Long FaceID,
722 CORBA::Double u, CORBA::Double v)
723 throw (SALOME::SALOME_Exception)
725 Unexpect aCatch(SALOME_SalomeException);
727 SMESHDS_Mesh * mesh = GetMeshDS();
728 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
730 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
732 if ( mesh->MaxShapeIndex() < FaceID )
733 THROW_SALOME_CORBA_EXCEPTION("Invalid FaceID", SALOME::BAD_PARAM);
735 TopoDS_Shape shape = mesh->IndexToShape( FaceID );
736 if ( shape.ShapeType() != TopAbs_FACE )
737 THROW_SALOME_CORBA_EXCEPTION("Invalid FaceID", SALOME::BAD_PARAM);
739 BRepAdaptor_Surface surf( TopoDS::Face( shape ));
740 bool isOut = ( u < surf.FirstUParameter() ||
741 u > surf.LastUParameter() ||
742 v < surf.FirstVParameter() ||
743 v > surf.LastVParameter() );
747 MESSAGE ( "FACE " << FaceID << " (" << u << "," << v << ") out of "
748 << " u( " << surf.FirstUParameter()
749 << "," << surf.LastUParameter()
750 << ") v( " << surf.FirstVParameter()
751 << "," << surf.LastVParameter() << ")" );
753 THROW_SALOME_CORBA_EXCEPTION("Invalid UV", SALOME::BAD_PARAM);
756 mesh->SetNodeOnFace( node, FaceID, u, v );
758 myMesh->SetIsModified( true );
761 //=============================================================================
763 * \brief Bind a node to a solid
764 * \param NodeID - node ID
765 * \param SolidID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
766 * \retval boolean - false if NodeID or SolidID is invalid
768 //=============================================================================
770 void SMESH_MeshEditor_i::SetNodeInVolume(CORBA::Long NodeID, CORBA::Long SolidID)
771 throw (SALOME::SALOME_Exception)
773 Unexpect aCatch(SALOME_SalomeException);
775 SMESHDS_Mesh * mesh = GetMeshDS();
776 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
778 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
780 if ( mesh->MaxShapeIndex() < SolidID )
781 THROW_SALOME_CORBA_EXCEPTION("Invalid SolidID", SALOME::BAD_PARAM);
783 TopoDS_Shape shape = mesh->IndexToShape( SolidID );
784 if ( shape.ShapeType() != TopAbs_SOLID &&
785 shape.ShapeType() != TopAbs_SHELL)
786 THROW_SALOME_CORBA_EXCEPTION("Invalid SolidID", SALOME::BAD_PARAM);
788 mesh->SetNodeInVolume( node, SolidID );
790 // myMesh->SetIsModified( true ); - SetNodeInVolume() can't prevent re-compute, I believe
793 //=============================================================================
795 * \brief Bind an element to a shape
796 * \param ElementID - element ID
797 * \param ShapeID - shape ID available through GEOM_Object.GetSubShapeIndices()[0]
798 * \retval boolean - false if ElementID or ShapeID is invalid
800 //=============================================================================
802 void SMESH_MeshEditor_i::SetMeshElementOnShape(CORBA::Long ElementID,
804 throw (SALOME::SALOME_Exception)
806 Unexpect aCatch(SALOME_SalomeException);
808 SMESHDS_Mesh * mesh = GetMeshDS();
809 SMDS_MeshElement* elem = const_cast<SMDS_MeshElement*>(mesh->FindElement(ElementID));
811 THROW_SALOME_CORBA_EXCEPTION("Invalid ElementID", SALOME::BAD_PARAM);
813 if ( mesh->MaxShapeIndex() < ShapeID )
814 THROW_SALOME_CORBA_EXCEPTION("Invalid ShapeID", SALOME::BAD_PARAM);
816 TopoDS_Shape shape = mesh->IndexToShape( ShapeID );
817 if ( shape.ShapeType() != TopAbs_EDGE &&
818 shape.ShapeType() != TopAbs_FACE &&
819 shape.ShapeType() != TopAbs_SOLID &&
820 shape.ShapeType() != TopAbs_SHELL )
821 THROW_SALOME_CORBA_EXCEPTION("Invalid shape type", SALOME::BAD_PARAM);
823 mesh->SetMeshElementOnShape( elem, ShapeID );
825 myMesh->SetIsModified( true );
828 //=============================================================================
832 //=============================================================================
834 CORBA::Boolean SMESH_MeshEditor_i::InverseDiag(CORBA::Long NodeID1,
839 const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
840 const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
844 // Update Python script
845 TPythonDump() << "isDone = " << this << ".InverseDiag( "
846 << NodeID1 << ", " << NodeID2 << " )";
848 myMesh->SetIsModified( true );
850 ::SMESH_MeshEditor aMeshEditor( myMesh );
851 return aMeshEditor.InverseDiag ( n1, n2 );
854 //=============================================================================
858 //=============================================================================
860 CORBA::Boolean SMESH_MeshEditor_i::DeleteDiag(CORBA::Long NodeID1,
865 const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
866 const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
870 // Update Python script
871 TPythonDump() << "isDone = " << this << ".DeleteDiag( "
872 << NodeID1 << ", " << NodeID2 << " )";
874 ::SMESH_MeshEditor aMeshEditor( myMesh );
876 bool stat = aMeshEditor.DeleteDiag ( n1, n2 );
879 myMesh->SetIsModified( true ); // issue 0020693
881 storeResult(aMeshEditor);
886 //=============================================================================
890 //=============================================================================
892 CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::long_array & IDsOfElements)
896 ::SMESH_MeshEditor anEditor( myMesh );
897 for (int i = 0; i < IDsOfElements.length(); i++)
899 CORBA::Long index = IDsOfElements[i];
900 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
902 anEditor.Reorient( elem );
904 // Update Python script
905 TPythonDump() << "isDone = " << this << ".Reorient( " << IDsOfElements << " )";
907 if ( IDsOfElements.length() )
908 myMesh->SetIsModified( true ); // issue 0020693
914 //=============================================================================
918 //=============================================================================
920 CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theObject)
924 TPythonDump aTPythonDump; // suppress dump in Reorient()
926 SMESH::long_array_var anElementsId = theObject->GetIDs();
927 CORBA::Boolean isDone = Reorient(anElementsId);
929 // Update Python script
930 aTPythonDump << "isDone = " << this << ".ReorientObject( " << theObject << " )";
937 //================================================================================
939 * \brief function for conversion long_array to TIDSortedElemSet
940 * \param IDs - array of IDs
941 * \param aMesh - mesh
942 * \param aMap - collection to fill
943 * \param aType - element type
945 //================================================================================
947 void arrayToSet(const SMESH::long_array & IDs,
948 const SMESHDS_Mesh* aMesh,
949 TIDSortedElemSet& aMap,
950 const SMDSAbs_ElementType aType = SMDSAbs_All )
952 for (int i=0; i<IDs.length(); i++) {
953 CORBA::Long ind = IDs[i];
954 const SMDS_MeshElement * elem =
955 (aType == SMDSAbs_Node ? aMesh->FindNode(ind)
956 : aMesh->FindElement(ind));
957 if ( elem && ( aType == SMDSAbs_All || elem->GetType() == aType ))
963 //=============================================================================
967 //=============================================================================
968 CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfElements,
969 SMESH::NumericalFunctor_ptr Criterion,
970 CORBA::Double MaxAngle)
974 SMESHDS_Mesh* aMesh = GetMeshDS();
975 TIDSortedElemSet faces;
976 arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
978 SMESH::NumericalFunctor_i* aNumericalFunctor =
979 dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
980 SMESH::Controls::NumericalFunctorPtr aCrit;
981 if ( !aNumericalFunctor )
982 aCrit.reset( new SMESH::Controls::AspectRatio() );
984 aCrit = aNumericalFunctor->GetNumericalFunctor();
986 // Update Python script
987 TPythonDump() << "isDone = " << this << ".TriToQuad( "
988 << IDsOfElements << ", " << aNumericalFunctor << ", " << MaxAngle << " )";
990 ::SMESH_MeshEditor anEditor( myMesh );
992 bool stat = anEditor.TriToQuad( faces, aCrit, MaxAngle );
994 myMesh->SetIsModified( true ); // issue 0020693
996 storeResult(anEditor);
1002 //=============================================================================
1006 //=============================================================================
1007 CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr theObject,
1008 SMESH::NumericalFunctor_ptr Criterion,
1009 CORBA::Double MaxAngle)
1013 TPythonDump aTPythonDump; // suppress dump in TriToQuad()
1014 SMESH::long_array_var anElementsId = theObject->GetIDs();
1015 CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
1017 SMESH::NumericalFunctor_i* aNumericalFunctor =
1018 SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
1020 // Update Python script
1021 aTPythonDump << "isDone = " << this << ".TriToQuadObject("
1022 << theObject << ", " << aNumericalFunctor << ", " << MaxAngle << " )";
1028 //=============================================================================
1032 //=============================================================================
1033 CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array & IDsOfElements,
1034 SMESH::NumericalFunctor_ptr Criterion)
1038 SMESHDS_Mesh* aMesh = GetMeshDS();
1039 TIDSortedElemSet faces;
1040 arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
1042 SMESH::NumericalFunctor_i* aNumericalFunctor =
1043 dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
1044 SMESH::Controls::NumericalFunctorPtr aCrit;
1045 if ( !aNumericalFunctor )
1046 aCrit.reset( new SMESH::Controls::AspectRatio() );
1048 aCrit = aNumericalFunctor->GetNumericalFunctor();
1051 // Update Python script
1052 TPythonDump() << "isDone = " << this << ".QuadToTri( " << IDsOfElements << ", " << aNumericalFunctor << " )";
1054 ::SMESH_MeshEditor anEditor( myMesh );
1055 CORBA::Boolean stat = anEditor.QuadToTri( faces, aCrit );
1057 myMesh->SetIsModified( true ); // issue 0020693
1059 storeResult(anEditor);
1065 //=============================================================================
1069 //=============================================================================
1070 CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr theObject,
1071 SMESH::NumericalFunctor_ptr Criterion)
1075 TPythonDump aTPythonDump; // suppress dump in QuadToTri()
1077 SMESH::long_array_var anElementsId = theObject->GetIDs();
1078 CORBA::Boolean isDone = QuadToTri(anElementsId, Criterion);
1080 SMESH::NumericalFunctor_i* aNumericalFunctor =
1081 SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
1083 // Update Python script
1084 aTPythonDump << "isDone = " << this << ".QuadToTriObject( " << theObject << ", " << aNumericalFunctor << " )";
1090 //=============================================================================
1094 //=============================================================================
1095 CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfElements,
1096 CORBA::Boolean Diag13)
1100 SMESHDS_Mesh* aMesh = GetMeshDS();
1101 TIDSortedElemSet faces;
1102 arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
1104 // Update Python script
1105 TPythonDump() << "isDone = " << this << ".SplitQuad( "
1106 << IDsOfElements << ", " << Diag13 << " )";
1108 ::SMESH_MeshEditor anEditor( myMesh );
1109 CORBA::Boolean stat = anEditor.QuadToTri( faces, Diag13 );
1111 myMesh->SetIsModified( true ); // issue 0020693
1114 storeResult(anEditor);
1120 //=============================================================================
1124 //=============================================================================
1125 CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr theObject,
1126 CORBA::Boolean Diag13)
1130 TPythonDump aTPythonDump; // suppress dump in SplitQuad()
1132 SMESH::long_array_var anElementsId = theObject->GetIDs();
1133 CORBA::Boolean isDone = SplitQuad(anElementsId, Diag13);
1135 // Update Python script
1136 aTPythonDump << "isDone = " << this << ".SplitQuadObject( "
1137 << theObject << ", " << Diag13 << " )";
1143 //=============================================================================
1147 //=============================================================================
1148 CORBA::Long SMESH_MeshEditor_i::BestSplit (CORBA::Long IDOfQuad,
1149 SMESH::NumericalFunctor_ptr Criterion)
1151 const SMDS_MeshElement* quad = GetMeshDS()->FindElement(IDOfQuad);
1152 if (quad && quad->GetType() == SMDSAbs_Face && quad->NbNodes() == 4)
1154 SMESH::NumericalFunctor_i* aNumericalFunctor =
1155 dynamic_cast<SMESH::NumericalFunctor_i*>(SMESH_Gen_i::GetServant(Criterion).in());
1156 SMESH::Controls::NumericalFunctorPtr aCrit;
1157 if (aNumericalFunctor)
1158 aCrit = aNumericalFunctor->GetNumericalFunctor();
1160 aCrit.reset(new SMESH::Controls::AspectRatio());
1162 ::SMESH_MeshEditor anEditor (myMesh);
1163 return anEditor.BestSplit(quad, aCrit);
1168 //================================================================================
1170 * \brief Split volumic elements into tetrahedrons
1172 //================================================================================
1174 void SMESH_MeshEditor_i::SplitVolumesIntoTetra (SMESH::SMESH_IDSource_ptr elems,
1175 CORBA::Short methodFlags)
1176 throw (SALOME::SALOME_Exception)
1178 Unexpect aCatch(SALOME_SalomeException);
1180 SMESH::long_array_var anElementsId = elems->GetIDs();
1181 TIDSortedElemSet elemSet;
1182 arrayToSet( anElementsId, GetMeshDS(), elemSet, SMDSAbs_Volume );
1184 ::SMESH_MeshEditor anEditor (myMesh);
1185 anEditor.SplitVolumesIntoTetra( elemSet, int( methodFlags ));
1187 storeResult(anEditor);
1189 // if ( myLastCreatedElems.length() ) - it does not influence Compute()
1190 // myMesh->SetIsModified( true ); // issue 0020693
1192 TPythonDump() << this << ".SplitVolumesIntoTetra( "
1193 << elems << ", " << methodFlags << " )";
1196 //=======================================================================
1199 //=======================================================================
1202 SMESH_MeshEditor_i::Smooth(const SMESH::long_array & IDsOfElements,
1203 const SMESH::long_array & IDsOfFixedNodes,
1204 CORBA::Long MaxNbOfIterations,
1205 CORBA::Double MaxAspectRatio,
1206 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1208 return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations,
1209 MaxAspectRatio, Method, false );
1213 //=======================================================================
1214 //function : SmoothParametric
1216 //=======================================================================
1219 SMESH_MeshEditor_i::SmoothParametric(const SMESH::long_array & IDsOfElements,
1220 const SMESH::long_array & IDsOfFixedNodes,
1221 CORBA::Long MaxNbOfIterations,
1222 CORBA::Double MaxAspectRatio,
1223 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1225 return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations,
1226 MaxAspectRatio, Method, true );
1230 //=======================================================================
1231 //function : SmoothObject
1233 //=======================================================================
1236 SMESH_MeshEditor_i::SmoothObject(SMESH::SMESH_IDSource_ptr theObject,
1237 const SMESH::long_array & IDsOfFixedNodes,
1238 CORBA::Long MaxNbOfIterations,
1239 CORBA::Double MaxAspectRatio,
1240 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1242 return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations,
1243 MaxAspectRatio, Method, false);
1247 //=======================================================================
1248 //function : SmoothParametricObject
1250 //=======================================================================
1253 SMESH_MeshEditor_i::SmoothParametricObject(SMESH::SMESH_IDSource_ptr theObject,
1254 const SMESH::long_array & IDsOfFixedNodes,
1255 CORBA::Long MaxNbOfIterations,
1256 CORBA::Double MaxAspectRatio,
1257 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1259 return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations,
1260 MaxAspectRatio, Method, true);
1264 //=============================================================================
1268 //=============================================================================
1271 SMESH_MeshEditor_i::smooth(const SMESH::long_array & IDsOfElements,
1272 const SMESH::long_array & IDsOfFixedNodes,
1273 CORBA::Long MaxNbOfIterations,
1274 CORBA::Double MaxAspectRatio,
1275 SMESH::SMESH_MeshEditor::Smooth_Method Method,
1280 SMESHDS_Mesh* aMesh = GetMeshDS();
1282 TIDSortedElemSet elements;
1283 arrayToSet(IDsOfElements, aMesh, elements, SMDSAbs_Face);
1285 set<const SMDS_MeshNode*> fixedNodes;
1286 for (int i = 0; i < IDsOfFixedNodes.length(); i++) {
1287 CORBA::Long index = IDsOfFixedNodes[i];
1288 const SMDS_MeshNode * node = aMesh->FindNode(index);
1290 fixedNodes.insert( node );
1292 ::SMESH_MeshEditor::SmoothMethod method = ::SMESH_MeshEditor::LAPLACIAN;
1293 if ( Method != SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH )
1294 method = ::SMESH_MeshEditor::CENTROIDAL;
1296 ::SMESH_MeshEditor anEditor( myMesh );
1297 anEditor.Smooth(elements, fixedNodes, method,
1298 MaxNbOfIterations, MaxAspectRatio, IsParametric );
1300 myMesh->SetIsModified( true ); // issue 0020693
1302 storeResult(anEditor);
1304 // Update Python script
1305 TPythonDump() << "isDone = " << this << "."
1306 << (IsParametric ? "SmoothParametric( " : "Smooth( ")
1307 << IDsOfElements << ", " << IDsOfFixedNodes << ", "
1308 << MaxNbOfIterations << ", " << MaxAspectRatio << ", "
1309 << "SMESH.SMESH_MeshEditor."
1310 << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
1311 "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
1317 //=============================================================================
1321 //=============================================================================
1324 SMESH_MeshEditor_i::smoothObject(SMESH::SMESH_IDSource_ptr theObject,
1325 const SMESH::long_array & IDsOfFixedNodes,
1326 CORBA::Long MaxNbOfIterations,
1327 CORBA::Double MaxAspectRatio,
1328 SMESH::SMESH_MeshEditor::Smooth_Method Method,
1333 TPythonDump aTPythonDump; // suppress dump in smooth()
1335 SMESH::long_array_var anElementsId = theObject->GetIDs();
1336 CORBA::Boolean isDone = smooth (anElementsId, IDsOfFixedNodes, MaxNbOfIterations,
1337 MaxAspectRatio, Method, IsParametric);
1339 // Update Python script
1340 aTPythonDump << "isDone = " << this << "."
1341 << (IsParametric ? "SmoothParametricObject( " : "SmoothObject( ")
1342 << theObject << ", " << IDsOfFixedNodes << ", "
1343 << MaxNbOfIterations << ", " << MaxAspectRatio << ", "
1344 << "SMESH.SMESH_MeshEditor."
1345 << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
1346 "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
1352 //=============================================================================
1356 //=============================================================================
1358 void SMESH_MeshEditor_i::RenumberNodes()
1360 // Update Python script
1361 TPythonDump() << this << ".RenumberNodes()";
1363 GetMeshDS()->Renumber( true );
1367 //=============================================================================
1371 //=============================================================================
1373 void SMESH_MeshEditor_i::RenumberElements()
1375 // Update Python script
1376 TPythonDump() << this << ".RenumberElements()";
1378 GetMeshDS()->Renumber( false );
1381 //=======================================================================
1383 * \brief Return groups by their IDs
1385 //=======================================================================
1387 SMESH::ListOfGroups* SMESH_MeshEditor_i::getGroups(const std::list<int>* groupIDs)
1391 myMesh_i->CreateGroupServants();
1392 return myMesh_i->GetGroups( *groupIDs );
1395 //=======================================================================
1396 //function : rotationSweep
1398 //=======================================================================
1400 SMESH::ListOfGroups*
1401 SMESH_MeshEditor_i::rotationSweep(const SMESH::long_array & theIDsOfElements,
1402 const SMESH::AxisStruct & theAxis,
1403 CORBA::Double theAngleInRadians,
1404 CORBA::Long theNbOfSteps,
1405 CORBA::Double theTolerance,
1406 const bool theMakeGroups,
1407 const SMDSAbs_ElementType theElementType)
1411 TIDSortedElemSet inElements, copyElements;
1412 arrayToSet(theIDsOfElements, GetMeshDS(), inElements, theElementType);
1414 TIDSortedElemSet* workElements = & inElements;
1415 TPreviewMesh tmpMesh( SMDSAbs_Face );
1416 SMESH_Mesh* mesh = 0;
1417 bool makeWalls=true;
1418 if ( myPreviewMode )
1420 SMDSAbs_ElementType select = SMDSAbs_All, avoid = SMDSAbs_Volume;
1421 tmpMesh.Copy( inElements, copyElements, select, avoid );
1423 workElements = & copyElements;
1424 //makeWalls = false;
1431 gp_Ax1 Ax1 (gp_Pnt( theAxis.x, theAxis.y, theAxis.z ),
1432 gp_Vec( theAxis.vx, theAxis.vy, theAxis.vz ));
1434 ::SMESH_MeshEditor anEditor( mesh );
1435 ::SMESH_MeshEditor::PGroupIDs groupIds =
1436 anEditor.RotationSweep (*workElements, Ax1, theAngleInRadians,
1437 theNbOfSteps, theTolerance, theMakeGroups, makeWalls);
1438 storeResult(anEditor);
1440 // myMesh->SetIsModified( true ); -- it does not influence Compute()
1442 return theMakeGroups ? getGroups(groupIds.get()) : 0;
1445 //=======================================================================
1446 //function : RotationSweep
1448 //=======================================================================
1450 void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElements,
1451 const SMESH::AxisStruct & theAxis,
1452 CORBA::Double theAngleInRadians,
1453 CORBA::Long theNbOfSteps,
1454 CORBA::Double theTolerance)
1456 if ( !myPreviewMode ) {
1457 TPythonDump() << this << ".RotationSweep( "
1458 << theIDsOfElements << ", "
1460 << theAngleInRadians << ", "
1461 << theNbOfSteps << ", "
1462 << theTolerance << " )";
1464 rotationSweep(theIDsOfElements,
1472 //=======================================================================
1473 //function : RotationSweepMakeGroups
1475 //=======================================================================
1477 SMESH::ListOfGroups*
1478 SMESH_MeshEditor_i::RotationSweepMakeGroups(const SMESH::long_array& theIDsOfElements,
1479 const SMESH::AxisStruct& theAxis,
1480 CORBA::Double theAngleInRadians,
1481 CORBA::Long theNbOfSteps,
1482 CORBA::Double theTolerance)
1484 SMESH::ListOfGroups *aGroups = rotationSweep(theIDsOfElements,
1490 if ( !myPreviewMode ) {
1491 TPythonDump aPythonDump;
1492 DumpGroupsList(aPythonDump,aGroups);
1493 aPythonDump<< this << ".RotationSweepMakeGroups( "
1494 << theIDsOfElements << ", "
1496 << theAngleInRadians << ", "
1497 << theNbOfSteps << ", "
1498 << theTolerance << " )";
1503 //=======================================================================
1504 //function : RotationSweepObject
1506 //=======================================================================
1508 void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject,
1509 const SMESH::AxisStruct & theAxis,
1510 CORBA::Double theAngleInRadians,
1511 CORBA::Long theNbOfSteps,
1512 CORBA::Double theTolerance)
1514 if ( !myPreviewMode ) {
1515 TPythonDump() << this << ".RotationSweepObject( "
1516 << theObject << ", "
1518 << theAngleInRadians << ", "
1519 << theNbOfSteps << ", "
1520 << theTolerance << " )";
1522 SMESH::long_array_var anElementsId = theObject->GetIDs();
1523 rotationSweep(anElementsId,
1531 //=======================================================================
1532 //function : RotationSweepObject1D
1534 //=======================================================================
1536 void SMESH_MeshEditor_i::RotationSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
1537 const SMESH::AxisStruct & theAxis,
1538 CORBA::Double theAngleInRadians,
1539 CORBA::Long theNbOfSteps,
1540 CORBA::Double theTolerance)
1542 if ( !myPreviewMode ) {
1543 TPythonDump() << this << ".RotationSweepObject1D( "
1544 << theObject << ", "
1546 << theAngleInRadians << ", "
1547 << theNbOfSteps << ", "
1548 << theTolerance << " )";
1550 SMESH::long_array_var anElementsId = theObject->GetIDs();
1551 rotationSweep(anElementsId,
1560 //=======================================================================
1561 //function : RotationSweepObject2D
1563 //=======================================================================
1565 void SMESH_MeshEditor_i::RotationSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
1566 const SMESH::AxisStruct & theAxis,
1567 CORBA::Double theAngleInRadians,
1568 CORBA::Long theNbOfSteps,
1569 CORBA::Double theTolerance)
1571 if ( !myPreviewMode ) {
1572 TPythonDump() << this << ".RotationSweepObject2D( "
1573 << theObject << ", "
1575 << theAngleInRadians << ", "
1576 << theNbOfSteps << ", "
1577 << theTolerance << " )";
1579 SMESH::long_array_var anElementsId = theObject->GetIDs();
1580 rotationSweep(anElementsId,
1589 //=======================================================================
1590 //function : RotationSweepObjectMakeGroups
1592 //=======================================================================
1594 SMESH::ListOfGroups*
1595 SMESH_MeshEditor_i::RotationSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1596 const SMESH::AxisStruct& theAxis,
1597 CORBA::Double theAngleInRadians,
1598 CORBA::Long theNbOfSteps,
1599 CORBA::Double theTolerance)
1601 SMESH::long_array_var anElementsId = theObject->GetIDs();
1602 SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
1608 if ( !myPreviewMode ) {
1609 TPythonDump aPythonDump;
1610 DumpGroupsList(aPythonDump,aGroups);
1611 aPythonDump<< this << ".RotationSweepObjectMakeGroups( "
1612 << theObject << ", "
1614 << theAngleInRadians << ", "
1615 << theNbOfSteps << ", "
1616 << theTolerance << " )";
1621 //=======================================================================
1622 //function : RotationSweepObject1DMakeGroups
1624 //=======================================================================
1626 SMESH::ListOfGroups*
1627 SMESH_MeshEditor_i::RotationSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1628 const SMESH::AxisStruct& theAxis,
1629 CORBA::Double theAngleInRadians,
1630 CORBA::Long theNbOfSteps,
1631 CORBA::Double theTolerance)
1633 SMESH::long_array_var anElementsId = theObject->GetIDs();
1634 SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
1641 if ( !myPreviewMode ) {
1642 TPythonDump aPythonDump;
1643 DumpGroupsList(aPythonDump,aGroups);
1644 aPythonDump<< this << ".RotationSweepObject1DMakeGroups( "
1645 << theObject << ", "
1647 << theAngleInRadians << ", "
1648 << theNbOfSteps << ", "
1649 << theTolerance << " )";
1654 //=======================================================================
1655 //function : RotationSweepObject2DMakeGroups
1657 //=======================================================================
1659 SMESH::ListOfGroups*
1660 SMESH_MeshEditor_i::RotationSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1661 const SMESH::AxisStruct& theAxis,
1662 CORBA::Double theAngleInRadians,
1663 CORBA::Long theNbOfSteps,
1664 CORBA::Double theTolerance)
1666 SMESH::long_array_var anElementsId = theObject->GetIDs();
1667 SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
1674 if ( !myPreviewMode ) {
1675 TPythonDump aPythonDump;
1676 DumpGroupsList(aPythonDump,aGroups);
1677 aPythonDump<< this << ".RotationSweepObject2DMakeGroups( "
1678 << theObject << ", "
1680 << theAngleInRadians << ", "
1681 << theNbOfSteps << ", "
1682 << theTolerance << " )";
1688 //=======================================================================
1689 //function : extrusionSweep
1691 //=======================================================================
1693 SMESH::ListOfGroups*
1694 SMESH_MeshEditor_i::extrusionSweep(const SMESH::long_array & theIDsOfElements,
1695 const SMESH::DirStruct & theStepVector,
1696 CORBA::Long theNbOfSteps,
1697 const bool theMakeGroups,
1698 const SMDSAbs_ElementType theElementType)
1706 TIDSortedElemSet elements;
1707 arrayToSet(theIDsOfElements, GetMeshDS(), elements, theElementType);
1709 const SMESH::PointStruct * P = &theStepVector.PS;
1710 gp_Vec stepVec( P->x, P->y, P->z );
1712 TElemOfElemListMap aHystory;
1713 ::SMESH_MeshEditor anEditor( myMesh );
1714 ::SMESH_MeshEditor::PGroupIDs groupIds =
1715 anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory, theMakeGroups);
1717 storeResult(anEditor);
1719 return theMakeGroups ? getGroups(groupIds.get()) : 0;
1721 } catch(Standard_Failure) {
1722 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1723 INFOS( "SMESH_MeshEditor_i::ExtrusionSweep fails - "<< aFail->GetMessageString() );
1728 //=======================================================================
1729 //function : ExtrusionSweep
1731 //=======================================================================
1733 void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElements,
1734 const SMESH::DirStruct & theStepVector,
1735 CORBA::Long theNbOfSteps)
1737 extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false );
1738 if ( !myPreviewMode ) {
1739 TPythonDump() << this << ".ExtrusionSweep( "
1740 << theIDsOfElements << ", " << theStepVector <<", " << theNbOfSteps << " )";
1745 //=======================================================================
1746 //function : ExtrusionSweepObject
1748 //=======================================================================
1750 void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObject,
1751 const SMESH::DirStruct & theStepVector,
1752 CORBA::Long theNbOfSteps)
1754 SMESH::long_array_var anElementsId = theObject->GetIDs();
1755 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false );
1756 if ( !myPreviewMode ) {
1757 TPythonDump() << this << ".ExtrusionSweepObject( "
1758 << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
1762 //=======================================================================
1763 //function : ExtrusionSweepObject1D
1765 //=======================================================================
1767 void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
1768 const SMESH::DirStruct & theStepVector,
1769 CORBA::Long theNbOfSteps)
1771 SMESH::long_array_var anElementsId = theObject->GetIDs();
1772 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Edge );
1773 if ( !myPreviewMode ) {
1774 TPythonDump() << this << ".ExtrusionSweepObject1D( "
1775 << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
1779 //=======================================================================
1780 //function : ExtrusionSweepObject2D
1782 //=======================================================================
1784 void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
1785 const SMESH::DirStruct & theStepVector,
1786 CORBA::Long theNbOfSteps)
1788 SMESH::long_array_var anElementsId = theObject->GetIDs();
1789 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Face );
1790 if ( !myPreviewMode ) {
1791 TPythonDump() << this << ".ExtrusionSweepObject2D( "
1792 << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
1796 //=======================================================================
1797 //function : ExtrusionSweepMakeGroups
1799 //=======================================================================
1801 SMESH::ListOfGroups*
1802 SMESH_MeshEditor_i::ExtrusionSweepMakeGroups(const SMESH::long_array& theIDsOfElements,
1803 const SMESH::DirStruct& theStepVector,
1804 CORBA::Long theNbOfSteps)
1806 SMESH::ListOfGroups* aGroups = extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, true );
1808 if ( !myPreviewMode ) {
1809 TPythonDump aPythonDump;
1810 DumpGroupsList(aPythonDump,aGroups);
1811 aPythonDump << this << ".ExtrusionSweepMakeGroups( "
1812 << theIDsOfElements << ", " << theStepVector <<", " << theNbOfSteps << " )";
1816 //=======================================================================
1817 //function : ExtrusionSweepObjectMakeGroups
1819 //=======================================================================
1821 SMESH::ListOfGroups*
1822 SMESH_MeshEditor_i::ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1823 const SMESH::DirStruct& theStepVector,
1824 CORBA::Long theNbOfSteps)
1826 SMESH::long_array_var anElementsId = theObject->GetIDs();
1827 SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true );
1829 if ( !myPreviewMode ) {
1830 TPythonDump aPythonDump;
1831 DumpGroupsList(aPythonDump,aGroups);
1832 aPythonDump<< this << ".ExtrusionSweepObjectMakeGroups( "
1833 << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
1838 //=======================================================================
1839 //function : ExtrusionSweepObject1DMakeGroups
1841 //=======================================================================
1843 SMESH::ListOfGroups*
1844 SMESH_MeshEditor_i::ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1845 const SMESH::DirStruct& theStepVector,
1846 CORBA::Long theNbOfSteps)
1848 SMESH::long_array_var anElementsId = theObject->GetIDs();
1849 SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Edge );
1850 if ( !myPreviewMode ) {
1851 TPythonDump aPythonDump;
1852 DumpGroupsList(aPythonDump,aGroups);
1853 aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( "
1854 << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
1859 //=======================================================================
1860 //function : ExtrusionSweepObject2DMakeGroups
1862 //=======================================================================
1864 SMESH::ListOfGroups*
1865 SMESH_MeshEditor_i::ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1866 const SMESH::DirStruct& theStepVector,
1867 CORBA::Long theNbOfSteps)
1869 SMESH::long_array_var anElementsId = theObject->GetIDs();
1870 SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Face );
1871 if ( !myPreviewMode ) {
1872 TPythonDump aPythonDump;
1873 DumpGroupsList(aPythonDump,aGroups);
1874 aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( "
1875 << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
1881 //=======================================================================
1882 //function : advancedExtrusion
1884 //=======================================================================
1886 SMESH::ListOfGroups*
1887 SMESH_MeshEditor_i::advancedExtrusion(const SMESH::long_array & theIDsOfElements,
1888 const SMESH::DirStruct & theStepVector,
1889 CORBA::Long theNbOfSteps,
1890 CORBA::Long theExtrFlags,
1891 CORBA::Double theSewTolerance,
1892 const bool theMakeGroups)
1896 TIDSortedElemSet elements;
1897 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
1899 const SMESH::PointStruct * P = &theStepVector.PS;
1900 gp_Vec stepVec( P->x, P->y, P->z );
1902 ::SMESH_MeshEditor anEditor( myMesh );
1903 TElemOfElemListMap aHystory;
1904 ::SMESH_MeshEditor::PGroupIDs groupIds =
1905 anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory,
1906 theMakeGroups, theExtrFlags, theSewTolerance);
1907 storeResult(anEditor);
1909 return theMakeGroups ? getGroups(groupIds.get()) : 0;
1912 //=======================================================================
1913 //function : AdvancedExtrusion
1915 //=======================================================================
1917 void SMESH_MeshEditor_i::AdvancedExtrusion(const SMESH::long_array & theIDsOfElements,
1918 const SMESH::DirStruct & theStepVector,
1919 CORBA::Long theNbOfSteps,
1920 CORBA::Long theExtrFlags,
1921 CORBA::Double theSewTolerance)
1923 if ( !myPreviewMode ) {
1924 TPythonDump() << "stepVector = " << theStepVector;
1925 TPythonDump() << this << ".AdvancedExtrusion("
1928 << theNbOfSteps << ","
1929 << theExtrFlags << ", "
1930 << theSewTolerance << " )";
1932 advancedExtrusion( theIDsOfElements,
1940 //=======================================================================
1941 //function : AdvancedExtrusionMakeGroups
1943 //=======================================================================
1945 SMESH::ListOfGroups*
1946 SMESH_MeshEditor_i::AdvancedExtrusionMakeGroups(const SMESH::long_array& theIDsOfElements,
1947 const SMESH::DirStruct& theStepVector,
1948 CORBA::Long theNbOfSteps,
1949 CORBA::Long theExtrFlags,
1950 CORBA::Double theSewTolerance)
1952 SMESH::ListOfGroups * aGroups = advancedExtrusion( theIDsOfElements,
1959 if ( !myPreviewMode ) {
1960 TPythonDump() << "stepVector = " << theStepVector;
1961 TPythonDump aPythonDump;
1962 DumpGroupsList(aPythonDump,aGroups);
1963 aPythonDump << this << ".AdvancedExtrusionMakeGroups("
1966 << theNbOfSteps << ","
1967 << theExtrFlags << ", "
1968 << theSewTolerance << " )";
1974 //================================================================================
1976 * \brief Convert extrusion error to IDL enum
1978 //================================================================================
1980 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
1982 static SMESH::SMESH_MeshEditor::Extrusion_Error convExtrError( const::SMESH_MeshEditor::Extrusion_Error e )
1986 RETCASE( EXTR_NO_ELEMENTS );
1987 RETCASE( EXTR_PATH_NOT_EDGE );
1988 RETCASE( EXTR_BAD_PATH_SHAPE );
1989 RETCASE( EXTR_BAD_STARTING_NODE );
1990 RETCASE( EXTR_BAD_ANGLES_NUMBER );
1991 RETCASE( EXTR_CANT_GET_TANGENT );
1993 return SMESH::SMESH_MeshEditor::EXTR_OK;
1997 //=======================================================================
1998 //function : extrusionAlongPath
2000 //=======================================================================
2002 SMESH::ListOfGroups*
2003 SMESH_MeshEditor_i::extrusionAlongPath(const SMESH::long_array & theIDsOfElements,
2004 SMESH::SMESH_Mesh_ptr thePathMesh,
2005 GEOM::GEOM_Object_ptr thePathShape,
2006 CORBA::Long theNodeStart,
2007 CORBA::Boolean theHasAngles,
2008 const SMESH::double_array & theAngles,
2009 CORBA::Boolean theHasRefPoint,
2010 const SMESH::PointStruct & theRefPoint,
2011 const bool theMakeGroups,
2012 SMESH::SMESH_MeshEditor::Extrusion_Error & theError,
2013 const SMDSAbs_ElementType theElementType)
2017 if ( thePathMesh->_is_nil() || thePathShape->_is_nil() ) {
2018 theError = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
2021 SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( thePathMesh );
2023 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
2024 SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
2026 if ( !aSubMesh || !aSubMesh->GetSubMeshDS()) {
2027 theError = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
2031 SMDS_MeshNode* nodeStart = (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(theNodeStart);
2033 theError = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
2037 TIDSortedElemSet elements;
2038 arrayToSet(theIDsOfElements, GetMeshDS(), elements, theElementType);
2040 list<double> angles;
2041 for (int i = 0; i < theAngles.length(); i++) {
2042 angles.push_back( theAngles[i] );
2045 gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z );
2047 int nbOldGroups = myMesh->NbGroup();
2049 ::SMESH_MeshEditor anEditor( myMesh );
2050 ::SMESH_MeshEditor::Extrusion_Error error =
2051 anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart,
2052 theHasAngles, angles, false,
2053 theHasRefPoint, refPnt, theMakeGroups );
2054 storeResult(anEditor);
2055 theError = convExtrError( error );
2057 if ( theMakeGroups ) {
2058 list<int> groupIDs = myMesh->GetGroupIds();
2059 list<int>::iterator newBegin = groupIDs.begin();
2060 std::advance( newBegin, nbOldGroups ); // skip old groups
2061 groupIDs.erase( groupIDs.begin(), newBegin );
2062 return getGroups( & groupIDs );
2068 //=======================================================================
2069 //function : extrusionAlongPathX
2071 //=======================================================================
2073 SMESH::ListOfGroups*
2074 SMESH_MeshEditor_i::extrusionAlongPathX(const SMESH::long_array & IDsOfElements,
2075 SMESH::SMESH_IDSource_ptr Path,
2076 CORBA::Long NodeStart,
2077 CORBA::Boolean HasAngles,
2078 const SMESH::double_array& Angles,
2079 CORBA::Boolean LinearVariation,
2080 CORBA::Boolean HasRefPoint,
2081 const SMESH::PointStruct& RefPoint,
2082 const bool MakeGroups,
2083 const SMDSAbs_ElementType ElementType,
2084 SMESH::SMESH_MeshEditor::Extrusion_Error & Error)
2086 SMESH::ListOfGroups* EmptyGr = new SMESH::ListOfGroups;
2090 list<double> angles;
2091 for (int i = 0; i < Angles.length(); i++) {
2092 angles.push_back( Angles[i] );
2094 gp_Pnt refPnt( RefPoint.x, RefPoint.y, RefPoint.z );
2095 int nbOldGroups = myMesh->NbGroup();
2097 if ( Path->_is_nil() ) {
2098 Error = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
2102 TIDSortedElemSet elements;
2103 arrayToSet(IDsOfElements, GetMeshDS(), elements, ElementType);
2105 ::SMESH_MeshEditor anEditor( myMesh );
2106 ::SMESH_MeshEditor::Extrusion_Error error;
2108 SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( Path );
2111 SMDS_MeshNode* aNodeStart =
2112 (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(NodeStart);
2113 if ( !aNodeStart ) {
2114 Error = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
2117 error = anEditor.ExtrusionAlongTrack( elements, &(aMeshImp->GetImpl()), aNodeStart,
2118 HasAngles, angles, LinearVariation,
2119 HasRefPoint, refPnt, MakeGroups );
2122 SMESH_subMesh_i* aSubMeshImp = SMESH::DownCast<SMESH_subMesh_i*>( Path );
2125 SMESH::SMESH_Mesh_ptr aPathMesh = aSubMeshImp->GetFather();
2126 aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( aPathMesh );
2127 SMDS_MeshNode* aNodeStart =
2128 (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(NodeStart);
2129 if ( !aNodeStart ) {
2130 Error = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
2133 SMESH_subMesh* aSubMesh =
2134 aMeshImp->GetImpl().GetSubMeshContaining(aSubMeshImp->GetId());
2135 error = anEditor.ExtrusionAlongTrack( elements, aSubMesh, aNodeStart,
2136 HasAngles, angles, LinearVariation,
2137 HasRefPoint, refPnt, MakeGroups );
2140 SMESH_Group_i* aGroupImp = SMESH::DownCast<SMESH_Group_i*>( Path );
2142 // path as group of 1D elements
2146 Error = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
2152 storeResult(anEditor);
2153 Error = convExtrError( error );
2156 list<int> groupIDs = myMesh->GetGroupIds();
2157 list<int>::iterator newBegin = groupIDs.begin();
2158 std::advance( newBegin, nbOldGroups ); // skip old groups
2159 groupIDs.erase( groupIDs.begin(), newBegin );
2160 return getGroups( & groupIDs );
2166 //=======================================================================
2167 //function : ExtrusionAlongPath
2169 //=======================================================================
2171 SMESH::SMESH_MeshEditor::Extrusion_Error
2172 SMESH_MeshEditor_i::ExtrusionAlongPath(const SMESH::long_array & theIDsOfElements,
2173 SMESH::SMESH_Mesh_ptr thePathMesh,
2174 GEOM::GEOM_Object_ptr thePathShape,
2175 CORBA::Long theNodeStart,
2176 CORBA::Boolean theHasAngles,
2177 const SMESH::double_array & theAngles,
2178 CORBA::Boolean theHasRefPoint,
2179 const SMESH::PointStruct & theRefPoint)
2181 if ( !myPreviewMode ) {
2182 TPythonDump() << "error = " << this << ".ExtrusionAlongPath( "
2183 << theIDsOfElements << ", "
2184 << thePathMesh << ", "
2185 << thePathShape << ", "
2186 << theNodeStart << ", "
2187 << theHasAngles << ", "
2188 << theAngles << ", "
2189 << theHasRefPoint << ", "
2190 << "SMESH.PointStruct( "
2191 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2192 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2193 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2195 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
2196 extrusionAlongPath( theIDsOfElements,
2209 //=======================================================================
2210 //function : ExtrusionAlongPathObject
2212 //=======================================================================
2214 SMESH::SMESH_MeshEditor::Extrusion_Error
2215 SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject,
2216 SMESH::SMESH_Mesh_ptr thePathMesh,
2217 GEOM::GEOM_Object_ptr thePathShape,
2218 CORBA::Long theNodeStart,
2219 CORBA::Boolean theHasAngles,
2220 const SMESH::double_array & theAngles,
2221 CORBA::Boolean theHasRefPoint,
2222 const SMESH::PointStruct & theRefPoint)
2224 if ( !myPreviewMode ) {
2225 TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject( "
2226 << theObject << ", "
2227 << thePathMesh << ", "
2228 << thePathShape << ", "
2229 << theNodeStart << ", "
2230 << theHasAngles << ", "
2231 << theAngles << ", "
2232 << theHasRefPoint << ", "
2233 << "SMESH.PointStruct( "
2234 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2235 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2236 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2238 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
2239 SMESH::long_array_var anElementsId = theObject->GetIDs();
2240 extrusionAlongPath( anElementsId,
2253 //=======================================================================
2254 //function : ExtrusionAlongPathObject1D
2256 //=======================================================================
2258 SMESH::SMESH_MeshEditor::Extrusion_Error
2259 SMESH_MeshEditor_i::ExtrusionAlongPathObject1D(SMESH::SMESH_IDSource_ptr theObject,
2260 SMESH::SMESH_Mesh_ptr thePathMesh,
2261 GEOM::GEOM_Object_ptr thePathShape,
2262 CORBA::Long theNodeStart,
2263 CORBA::Boolean theHasAngles,
2264 const SMESH::double_array & theAngles,
2265 CORBA::Boolean theHasRefPoint,
2266 const SMESH::PointStruct & theRefPoint)
2268 if ( !myPreviewMode ) {
2269 TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject1D( "
2270 << theObject << ", "
2271 << thePathMesh << ", "
2272 << thePathShape << ", "
2273 << theNodeStart << ", "
2274 << theHasAngles << ", "
2275 << theAngles << ", "
2276 << theHasRefPoint << ", "
2277 << "SMESH.PointStruct( "
2278 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2279 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2280 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2282 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
2283 SMESH::long_array_var anElementsId = theObject->GetIDs();
2284 extrusionAlongPath( anElementsId,
2298 //=======================================================================
2299 //function : ExtrusionAlongPathObject2D
2301 //=======================================================================
2303 SMESH::SMESH_MeshEditor::Extrusion_Error
2304 SMESH_MeshEditor_i::ExtrusionAlongPathObject2D(SMESH::SMESH_IDSource_ptr theObject,
2305 SMESH::SMESH_Mesh_ptr thePathMesh,
2306 GEOM::GEOM_Object_ptr thePathShape,
2307 CORBA::Long theNodeStart,
2308 CORBA::Boolean theHasAngles,
2309 const SMESH::double_array & theAngles,
2310 CORBA::Boolean theHasRefPoint,
2311 const SMESH::PointStruct & theRefPoint)
2313 if ( !myPreviewMode ) {
2314 TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject2D( "
2315 << theObject << ", "
2316 << thePathMesh << ", "
2317 << thePathShape << ", "
2318 << theNodeStart << ", "
2319 << theHasAngles << ", "
2320 << theAngles << ", "
2321 << theHasRefPoint << ", "
2322 << "SMESH.PointStruct( "
2323 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2324 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2325 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2327 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
2328 SMESH::long_array_var anElementsId = theObject->GetIDs();
2329 extrusionAlongPath( anElementsId,
2344 //=======================================================================
2345 //function : ExtrusionAlongPathMakeGroups
2347 //=======================================================================
2349 SMESH::ListOfGroups*
2350 SMESH_MeshEditor_i::ExtrusionAlongPathMakeGroups(const SMESH::long_array& theIDsOfElements,
2351 SMESH::SMESH_Mesh_ptr thePathMesh,
2352 GEOM::GEOM_Object_ptr thePathShape,
2353 CORBA::Long theNodeStart,
2354 CORBA::Boolean theHasAngles,
2355 const SMESH::double_array& theAngles,
2356 CORBA::Boolean theHasRefPoint,
2357 const SMESH::PointStruct& theRefPoint,
2358 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2360 SMESH::ListOfGroups * aGroups = extrusionAlongPath( theIDsOfElements,
2370 if ( !myPreviewMode ) {
2371 bool isDumpGroups = aGroups && aGroups->length() > 0;
2372 TPythonDump aPythonDump;
2374 aPythonDump << "("<<aGroups;
2377 aPythonDump << ", error)";
2379 aPythonDump <<"error";
2381 aPythonDump<<" = "<< this << ".ExtrusionAlongPathMakeGroups( "
2382 << theIDsOfElements << ", "
2383 << thePathMesh << ", "
2384 << thePathShape << ", "
2385 << theNodeStart << ", "
2386 << theHasAngles << ", "
2387 << theAngles << ", "
2388 << theHasRefPoint << ", "
2389 << "SMESH.PointStruct( "
2390 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2391 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2392 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2397 //=======================================================================
2398 //function : ExtrusionAlongPathObjectMakeGroups
2400 //=======================================================================
2402 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2403 ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2404 SMESH::SMESH_Mesh_ptr thePathMesh,
2405 GEOM::GEOM_Object_ptr thePathShape,
2406 CORBA::Long theNodeStart,
2407 CORBA::Boolean theHasAngles,
2408 const SMESH::double_array& theAngles,
2409 CORBA::Boolean theHasRefPoint,
2410 const SMESH::PointStruct& theRefPoint,
2411 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2413 SMESH::long_array_var anElementsId = theObject->GetIDs();
2414 SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
2425 if ( !myPreviewMode ) {
2426 bool isDumpGroups = aGroups && aGroups->length() > 0;
2427 TPythonDump aPythonDump;
2429 aPythonDump << "("<<aGroups;
2432 aPythonDump << ", error)";
2434 aPythonDump <<"error";
2436 aPythonDump << " = " << this << ".ExtrusionAlongPathObjectMakeGroups( "
2437 << theObject << ", "
2438 << thePathMesh << ", "
2439 << thePathShape << ", "
2440 << theNodeStart << ", "
2441 << theHasAngles << ", "
2442 << theAngles << ", "
2443 << theHasRefPoint << ", "
2444 << "SMESH.PointStruct( "
2445 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2446 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2447 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2452 //=======================================================================
2453 //function : ExtrusionAlongPathObject1DMakeGroups
2455 //=======================================================================
2457 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2458 ExtrusionAlongPathObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2459 SMESH::SMESH_Mesh_ptr thePathMesh,
2460 GEOM::GEOM_Object_ptr thePathShape,
2461 CORBA::Long theNodeStart,
2462 CORBA::Boolean theHasAngles,
2463 const SMESH::double_array& theAngles,
2464 CORBA::Boolean theHasRefPoint,
2465 const SMESH::PointStruct& theRefPoint,
2466 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2468 SMESH::long_array_var anElementsId = theObject->GetIDs();
2469 SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
2481 if ( !myPreviewMode ) {
2482 bool isDumpGroups = aGroups && aGroups->length() > 0;
2483 TPythonDump aPythonDump;
2485 aPythonDump << "("<<aGroups;
2488 aPythonDump << ", error)";
2490 aPythonDump <<"error";
2492 aPythonDump << " = " << this << ".ExtrusionAlongPathObject1DMakeGroups( "
2493 << theObject << ", "
2494 << thePathMesh << ", "
2495 << thePathShape << ", "
2496 << theNodeStart << ", "
2497 << theHasAngles << ", "
2498 << theAngles << ", "
2499 << theHasRefPoint << ", "
2500 << "SMESH.PointStruct( "
2501 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2502 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2503 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2508 //=======================================================================
2509 //function : ExtrusionAlongPathObject2DMakeGroups
2511 //=======================================================================
2513 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2514 ExtrusionAlongPathObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2515 SMESH::SMESH_Mesh_ptr thePathMesh,
2516 GEOM::GEOM_Object_ptr thePathShape,
2517 CORBA::Long theNodeStart,
2518 CORBA::Boolean theHasAngles,
2519 const SMESH::double_array& theAngles,
2520 CORBA::Boolean theHasRefPoint,
2521 const SMESH::PointStruct& theRefPoint,
2522 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2524 SMESH::long_array_var anElementsId = theObject->GetIDs();
2525 SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
2537 if ( !myPreviewMode ) {
2538 bool isDumpGroups = aGroups && aGroups->length() > 0;
2539 TPythonDump aPythonDump;
2541 aPythonDump << "("<<aGroups;
2544 aPythonDump << ", error)";
2546 aPythonDump <<"error";
2548 aPythonDump << " = " << this << ".ExtrusionAlongPathObject2DMakeGroups( "
2549 << theObject << ", "
2550 << thePathMesh << ", "
2551 << thePathShape << ", "
2552 << theNodeStart << ", "
2553 << theHasAngles << ", "
2554 << theAngles << ", "
2555 << theHasRefPoint << ", "
2556 << "SMESH.PointStruct( "
2557 << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
2558 << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
2559 << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
2565 //=======================================================================
2566 //function : ExtrusionAlongPathObjX
2568 //=======================================================================
2569 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2570 ExtrusionAlongPathObjX(SMESH::SMESH_IDSource_ptr Object,
2571 SMESH::SMESH_IDSource_ptr Path,
2572 CORBA::Long NodeStart,
2573 CORBA::Boolean HasAngles,
2574 const SMESH::double_array& Angles,
2575 CORBA::Boolean LinearVariation,
2576 CORBA::Boolean HasRefPoint,
2577 const SMESH::PointStruct& RefPoint,
2578 CORBA::Boolean MakeGroups,
2579 SMESH::ElementType ElemType,
2580 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2582 SMESH::long_array_var anElementsId = Object->GetIDs();
2583 SMESH::ListOfGroups * aGroups = extrusionAlongPathX(anElementsId,
2592 (SMDSAbs_ElementType)ElemType,
2595 if ( !myPreviewMode ) {
2596 bool isDumpGroups = aGroups && aGroups->length() > 0;
2597 TPythonDump aPythonDump;
2599 aPythonDump << "("<<aGroups;
2602 aPythonDump << ", error)";
2604 aPythonDump <<"error";
2606 aPythonDump << " = " << this << ".ExtrusionAlongPathObjX( "
2609 << NodeStart << ", "
2610 << HasAngles << ", "
2612 << LinearVariation << ", "
2613 << HasRefPoint << ", "
2614 << "SMESH.PointStruct( "
2615 << ( HasRefPoint ? RefPoint.x : 0 ) << ", "
2616 << ( HasRefPoint ? RefPoint.y : 0 ) << ", "
2617 << ( HasRefPoint ? RefPoint.z : 0 ) << " ), "
2618 << MakeGroups << ", "
2619 << ElemType << " )";
2625 //=======================================================================
2626 //function : ExtrusionAlongPathX
2628 //=======================================================================
2629 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2630 ExtrusionAlongPathX(const SMESH::long_array& IDsOfElements,
2631 SMESH::SMESH_IDSource_ptr Path,
2632 CORBA::Long NodeStart,
2633 CORBA::Boolean HasAngles,
2634 const SMESH::double_array& Angles,
2635 CORBA::Boolean LinearVariation,
2636 CORBA::Boolean HasRefPoint,
2637 const SMESH::PointStruct& RefPoint,
2638 CORBA::Boolean MakeGroups,
2639 SMESH::ElementType ElemType,
2640 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2642 SMESH::ListOfGroups * aGroups = extrusionAlongPathX(IDsOfElements,
2651 (SMDSAbs_ElementType)ElemType,
2654 if ( !myPreviewMode ) {
2655 bool isDumpGroups = aGroups && aGroups->length() > 0;
2656 TPythonDump aPythonDump;
2658 aPythonDump << "("<<aGroups;
2661 aPythonDump << ", error)";
2663 aPythonDump <<"error";
2665 aPythonDump << " = " << this << ".ExtrusionAlongPathX( "
2666 << IDsOfElements << ", "
2668 << NodeStart << ", "
2669 << HasAngles << ", "
2671 << LinearVariation << ", "
2672 << HasRefPoint << ", "
2673 << "SMESH.PointStruct( "
2674 << ( HasRefPoint ? RefPoint.x : 0 ) << ", "
2675 << ( HasRefPoint ? RefPoint.y : 0 ) << ", "
2676 << ( HasRefPoint ? RefPoint.z : 0 ) << " ), "
2677 << ElemType << " )";
2683 //================================================================================
2685 * \brief Compute rotation angles for ExtrusionAlongPath as linear variation
2686 * of given angles along path steps
2687 * \param PathMesh mesh containing a 1D sub-mesh on the edge, along
2688 * which proceeds the extrusion
2689 * \param PathShape is shape(edge); as the mesh can be complex, the edge
2690 * is used to define the sub-mesh for the path
2692 //================================================================================
2694 SMESH::double_array*
2695 SMESH_MeshEditor_i::LinearAnglesVariation(SMESH::SMESH_Mesh_ptr thePathMesh,
2696 GEOM::GEOM_Object_ptr thePathShape,
2697 const SMESH::double_array & theAngles)
2699 SMESH::double_array_var aResult = new SMESH::double_array();
2700 int nbAngles = theAngles.length();
2701 if ( nbAngles > 0 && !thePathMesh->_is_nil() && !thePathShape->_is_nil() )
2703 SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( thePathMesh );
2704 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
2705 SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
2706 if ( !aSubMesh || !aSubMesh->GetSubMeshDS())
2707 return aResult._retn();
2708 int nbSteps = aSubMesh->GetSubMeshDS()->NbElements();
2709 if ( nbSteps == nbAngles )
2711 aResult.inout() = theAngles;
2715 aResult->length( nbSteps );
2716 double rAn2St = double( nbAngles ) / double( nbSteps );
2717 double angPrev = 0, angle;
2718 for ( int iSt = 0; iSt < nbSteps; ++iSt )
2720 double angCur = rAn2St * ( iSt+1 );
2721 double angCurFloor = floor( angCur );
2722 double angPrevFloor = floor( angPrev );
2723 if ( angPrevFloor == angCurFloor )
2724 angle = rAn2St * theAngles[ int( angCurFloor ) ];
2727 int iP = int( angPrevFloor );
2728 double angPrevCeil = ceil(angPrev);
2729 angle = ( angPrevCeil - angPrev ) * theAngles[ iP ];
2731 int iC = int( angCurFloor );
2732 if ( iC < nbAngles )
2733 angle += ( angCur - angCurFloor ) * theAngles[ iC ];
2735 iP = int( angPrevCeil );
2737 angle += theAngles[ iC ];
2739 aResult[ iSt ] = angle;
2744 // Update Python script
2745 TPythonDump() << "rotAngles = " << theAngles;
2746 TPythonDump() << "rotAngles = " << this << ".LinearAnglesVariation( "
2747 << thePathMesh << ", "
2748 << thePathShape << ", "
2751 return aResult._retn();
2755 //=======================================================================
2758 //=======================================================================
2760 SMESH::ListOfGroups*
2761 SMESH_MeshEditor_i::mirror(const SMESH::long_array & theIDsOfElements,
2762 const SMESH::AxisStruct & theAxis,
2763 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
2764 CORBA::Boolean theCopy,
2765 const bool theMakeGroups,
2766 ::SMESH_Mesh* theTargetMesh)
2770 TIDSortedElemSet elements;
2771 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
2773 gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
2774 gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
2777 switch ( theMirrorType ) {
2778 case SMESH::SMESH_MeshEditor::POINT:
2779 aTrsf.SetMirror( P );
2781 case SMESH::SMESH_MeshEditor::AXIS:
2782 aTrsf.SetMirror( gp_Ax1( P, V ));
2785 aTrsf.SetMirror( gp_Ax2( P, V ));
2788 ::SMESH_MeshEditor anEditor( myMesh );
2789 ::SMESH_MeshEditor::PGroupIDs groupIds =
2790 anEditor.Transform (elements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
2793 storeResult(anEditor);
2795 myMesh->SetIsModified( true );
2797 return theMakeGroups ? getGroups(groupIds.get()) : 0;
2800 //=======================================================================
2803 //=======================================================================
2805 void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElements,
2806 const SMESH::AxisStruct & theAxis,
2807 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
2808 CORBA::Boolean theCopy)
2810 if ( !myPreviewMode ) {
2811 TPythonDump() << this << ".Mirror( "
2812 << theIDsOfElements << ", "
2814 << mirrorTypeName(theMirrorType) << ", "
2817 mirror(theIDsOfElements, theAxis, theMirrorType, theCopy, false);
2821 //=======================================================================
2822 //function : MirrorObject
2824 //=======================================================================
2826 void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObject,
2827 const SMESH::AxisStruct & theAxis,
2828 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
2829 CORBA::Boolean theCopy)
2831 if ( !myPreviewMode ) {
2832 TPythonDump() << this << ".MirrorObject( "
2833 << theObject << ", "
2835 << mirrorTypeName(theMirrorType) << ", "
2838 SMESH::long_array_var anElementsId = theObject->GetIDs();
2839 mirror(anElementsId, theAxis, theMirrorType, theCopy, false);
2842 //=======================================================================
2843 //function : MirrorMakeGroups
2845 //=======================================================================
2847 SMESH::ListOfGroups*
2848 SMESH_MeshEditor_i::MirrorMakeGroups(const SMESH::long_array& theIDsOfElements,
2849 const SMESH::AxisStruct& theMirror,
2850 SMESH::SMESH_MeshEditor::MirrorType theMirrorType)
2852 SMESH::ListOfGroups * aGroups = mirror(theIDsOfElements, theMirror, theMirrorType, true, true);
2853 if ( !myPreviewMode ) {
2854 TPythonDump aPythonDump;
2855 DumpGroupsList(aPythonDump,aGroups);
2856 aPythonDump << this << ".MirrorMakeGroups( "
2857 << theIDsOfElements << ", "
2858 << theMirror << ", "
2859 << mirrorTypeName(theMirrorType) << " )";
2864 //=======================================================================
2865 //function : MirrorObjectMakeGroups
2867 //=======================================================================
2869 SMESH::ListOfGroups*
2870 SMESH_MeshEditor_i::MirrorObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2871 const SMESH::AxisStruct& theMirror,
2872 SMESH::SMESH_MeshEditor::MirrorType theMirrorType)
2874 SMESH::long_array_var anElementsId = theObject->GetIDs();
2875 SMESH::ListOfGroups * aGroups = mirror(anElementsId, theMirror, theMirrorType, true, true);
2876 if ( !myPreviewMode ) {
2877 TPythonDump aPythonDump;
2878 DumpGroupsList(aPythonDump,aGroups);
2879 aPythonDump << this << ".MirrorObjectMakeGroups( "
2880 << theObject << ", "
2881 << theMirror << ", "
2882 << mirrorTypeName(theMirrorType) << " )";
2887 //=======================================================================
2888 //function : MirrorMakeMesh
2890 //=======================================================================
2892 SMESH::SMESH_Mesh_ptr
2893 SMESH_MeshEditor_i::MirrorMakeMesh(const SMESH::long_array& theIDsOfElements,
2894 const SMESH::AxisStruct& theMirror,
2895 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
2896 CORBA::Boolean theCopyGroups,
2897 const char* theMeshName)
2899 SMESH_Mesh_i* mesh_i;
2900 SMESH::SMESH_Mesh_var mesh;
2901 { // open new scope to dump "MakeMesh" command
2902 // and then "GetGroups" using SMESH_Mesh::GetGroups()
2904 TPythonDump pydump; // to prevent dump at mesh creation
2906 mesh = makeMesh( theMeshName );
2907 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
2909 mirror(theIDsOfElements, theMirror, theMirrorType,
2910 false, theCopyGroups, & mesh_i->GetImpl());
2911 mesh_i->CreateGroupServants();
2914 if ( !myPreviewMode ) {
2915 pydump << mesh << " = " << this << ".MirrorMakeMesh( "
2916 << theIDsOfElements << ", "
2917 << theMirror << ", "
2918 << mirrorTypeName(theMirrorType) << ", "
2919 << theCopyGroups << ", '"
2920 << theMeshName << "' )";
2925 if(!myPreviewMode && mesh_i)
2926 mesh_i->GetGroups();
2928 return mesh._retn();
2931 //=======================================================================
2932 //function : MirrorObjectMakeMesh
2934 //=======================================================================
2936 SMESH::SMESH_Mesh_ptr
2937 SMESH_MeshEditor_i::MirrorObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
2938 const SMESH::AxisStruct& theMirror,
2939 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
2940 CORBA::Boolean theCopyGroups,
2941 const char* theMeshName)
2943 SMESH_Mesh_i* mesh_i;
2944 SMESH::SMESH_Mesh_var mesh;
2945 { // open new scope to dump "MakeMesh" command
2946 // and then "GetGroups" using SMESH_Mesh::GetGroups()
2948 TPythonDump pydump; // to prevent dump at mesh creation
2950 mesh = makeMesh( theMeshName );
2951 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
2953 SMESH::long_array_var anElementsId = theObject->GetIDs();
2954 mirror(anElementsId, theMirror, theMirrorType,
2955 false, theCopyGroups, & mesh_i->GetImpl());
2956 mesh_i->CreateGroupServants();
2959 if ( !myPreviewMode ) {
2960 pydump << mesh << " = " << this << ".MirrorObjectMakeMesh( "
2961 << theObject << ", "
2962 << theMirror << ", "
2963 << mirrorTypeName(theMirrorType) << ", "
2964 << theCopyGroups << ", '"
2965 << theMeshName << "' )";
2970 if(!myPreviewMode && mesh_i)
2971 mesh_i->GetGroups();
2973 return mesh._retn();
2976 //=======================================================================
2977 //function : translate
2979 //=======================================================================
2981 SMESH::ListOfGroups*
2982 SMESH_MeshEditor_i::translate(const SMESH::long_array & theIDsOfElements,
2983 const SMESH::DirStruct & theVector,
2984 CORBA::Boolean theCopy,
2985 const bool theMakeGroups,
2986 ::SMESH_Mesh* theTargetMesh)
2990 TIDSortedElemSet elements;
2991 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
2994 const SMESH::PointStruct * P = &theVector.PS;
2995 aTrsf.SetTranslation( gp_Vec( P->x, P->y, P->z ));
2997 ::SMESH_MeshEditor anEditor( myMesh );
2998 ::SMESH_MeshEditor::PGroupIDs groupIds =
2999 anEditor.Transform (elements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
3002 storeResult(anEditor);
3004 myMesh->SetIsModified( true );
3006 return theMakeGroups ? getGroups(groupIds.get()) : 0;
3009 //=======================================================================
3010 //function : Translate
3012 //=======================================================================
3014 void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements,
3015 const SMESH::DirStruct & theVector,
3016 CORBA::Boolean theCopy)
3018 if ( !myPreviewMode ) {
3019 TPythonDump() << this << ".Translate( "
3020 << theIDsOfElements << ", "
3021 << theVector << ", "
3024 translate(theIDsOfElements,
3030 //=======================================================================
3031 //function : TranslateObject
3033 //=======================================================================
3035 void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject,
3036 const SMESH::DirStruct & theVector,
3037 CORBA::Boolean theCopy)
3039 if ( !myPreviewMode ) {
3040 TPythonDump() << this << ".TranslateObject( "
3041 << theObject << ", "
3042 << theVector << ", "
3045 SMESH::long_array_var anElementsId = theObject->GetIDs();
3046 translate(anElementsId,
3052 //=======================================================================
3053 //function : TranslateMakeGroups
3055 //=======================================================================
3057 SMESH::ListOfGroups*
3058 SMESH_MeshEditor_i::TranslateMakeGroups(const SMESH::long_array& theIDsOfElements,
3059 const SMESH::DirStruct& theVector)
3061 SMESH::ListOfGroups * aGroups = translate(theIDsOfElements,theVector,true,true);
3062 if ( !myPreviewMode ) {
3063 TPythonDump aPythonDump;
3064 DumpGroupsList(aPythonDump,aGroups);
3065 aPythonDump << this << ".TranslateMakeGroups( "
3066 << theIDsOfElements << ", "
3067 << theVector << " )";
3072 //=======================================================================
3073 //function : TranslateObjectMakeGroups
3075 //=======================================================================
3077 SMESH::ListOfGroups*
3078 SMESH_MeshEditor_i::TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
3079 const SMESH::DirStruct& theVector)
3081 SMESH::long_array_var anElementsId = theObject->GetIDs();
3082 SMESH::ListOfGroups * aGroups = translate(anElementsId, theVector, true, true);
3084 if ( !myPreviewMode ) {
3086 TPythonDump aPythonDump;
3087 DumpGroupsList(aPythonDump,aGroups);
3088 aPythonDump << this << ".TranslateObjectMakeGroups( "
3089 << theObject << ", "
3090 << theVector << " )";
3095 //=======================================================================
3096 //function : TranslateMakeMesh
3098 //=======================================================================
3100 SMESH::SMESH_Mesh_ptr
3101 SMESH_MeshEditor_i::TranslateMakeMesh(const SMESH::long_array& theIDsOfElements,
3102 const SMESH::DirStruct& theVector,
3103 CORBA::Boolean theCopyGroups,
3104 const char* theMeshName)
3106 SMESH_Mesh_i* mesh_i;
3107 SMESH::SMESH_Mesh_var mesh;
3109 { // open new scope to dump "MakeMesh" command
3110 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3112 TPythonDump pydump; // to prevent dump at mesh creation
3114 mesh = makeMesh( theMeshName );
3115 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3118 translate(theIDsOfElements, theVector,
3119 false, theCopyGroups, & mesh_i->GetImpl());
3120 mesh_i->CreateGroupServants();
3123 if ( !myPreviewMode ) {
3124 pydump << mesh << " = " << this << ".TranslateMakeMesh( "
3125 << theIDsOfElements << ", "
3126 << theVector << ", "
3127 << theCopyGroups << ", '"
3128 << theMeshName << "' )";
3133 if(!myPreviewMode && mesh_i)
3134 mesh_i->GetGroups();
3136 return mesh._retn();
3139 //=======================================================================
3140 //function : TranslateObjectMakeMesh
3142 //=======================================================================
3144 SMESH::SMESH_Mesh_ptr
3145 SMESH_MeshEditor_i::TranslateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
3146 const SMESH::DirStruct& theVector,
3147 CORBA::Boolean theCopyGroups,
3148 const char* theMeshName)
3150 SMESH_Mesh_i* mesh_i;
3151 SMESH::SMESH_Mesh_var mesh;
3152 { // open new scope to dump "MakeMesh" command
3153 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3155 TPythonDump pydump; // to prevent dump at mesh creation
3156 mesh = makeMesh( theMeshName );
3157 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3160 SMESH::long_array_var anElementsId = theObject->GetIDs();
3161 translate(anElementsId, theVector,
3162 false, theCopyGroups, & mesh_i->GetImpl());
3163 mesh_i->CreateGroupServants();
3165 if ( !myPreviewMode ) {
3166 pydump << mesh << " = " << this << ".TranslateObjectMakeMesh( "
3167 << theObject << ", "
3168 << theVector << ", "
3169 << theCopyGroups << ", '"
3170 << theMeshName << "' )";
3175 if(!myPreviewMode && mesh_i)
3176 mesh_i->GetGroups();
3178 return mesh._retn();
3181 //=======================================================================
3184 //=======================================================================
3186 SMESH::ListOfGroups*
3187 SMESH_MeshEditor_i::rotate(const SMESH::long_array & theIDsOfElements,
3188 const SMESH::AxisStruct & theAxis,
3189 CORBA::Double theAngle,
3190 CORBA::Boolean theCopy,
3191 const bool theMakeGroups,
3192 ::SMESH_Mesh* theTargetMesh)
3196 TIDSortedElemSet elements;
3197 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3199 gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
3200 gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
3203 aTrsf.SetRotation( gp_Ax1( P, V ), theAngle);
3205 ::SMESH_MeshEditor anEditor( myMesh );
3206 ::SMESH_MeshEditor::PGroupIDs groupIds =
3207 anEditor.Transform (elements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
3210 storeResult(anEditor);
3212 myMesh->SetIsModified( true );
3214 return theMakeGroups ? getGroups(groupIds.get()) : 0;
3217 //=======================================================================
3220 //=======================================================================
3222 void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements,
3223 const SMESH::AxisStruct & theAxis,
3224 CORBA::Double theAngle,
3225 CORBA::Boolean theCopy)
3227 if ( !myPreviewMode ) {
3228 TPythonDump() << this << ".Rotate( "
3229 << theIDsOfElements << ", "
3234 rotate(theIDsOfElements,
3241 //=======================================================================
3242 //function : RotateObject
3244 //=======================================================================
3246 void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject,
3247 const SMESH::AxisStruct & theAxis,
3248 CORBA::Double theAngle,
3249 CORBA::Boolean theCopy)
3251 if ( !myPreviewMode ) {
3252 TPythonDump() << this << ".RotateObject( "
3253 << theObject << ", "
3258 SMESH::long_array_var anElementsId = theObject->GetIDs();
3259 rotate(anElementsId,
3266 //=======================================================================
3267 //function : RotateMakeGroups
3269 //=======================================================================
3271 SMESH::ListOfGroups*
3272 SMESH_MeshEditor_i::RotateMakeGroups(const SMESH::long_array& theIDsOfElements,
3273 const SMESH::AxisStruct& theAxis,
3274 CORBA::Double theAngle)
3276 SMESH::ListOfGroups * aGroups = rotate(theIDsOfElements,theAxis,theAngle,true,true);
3277 if ( !myPreviewMode ) {
3278 TPythonDump aPythonDump;
3279 DumpGroupsList(aPythonDump,aGroups);
3280 aPythonDump << this << ".RotateMakeGroups( "
3281 << theIDsOfElements << ", "
3283 << theAngle << " )";
3288 //=======================================================================
3289 //function : RotateObjectMakeGroups
3291 //=======================================================================
3293 SMESH::ListOfGroups*
3294 SMESH_MeshEditor_i::RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
3295 const SMESH::AxisStruct& theAxis,
3296 CORBA::Double theAngle)
3298 SMESH::long_array_var anElementsId = theObject->GetIDs();
3299 SMESH::ListOfGroups * aGroups = rotate(anElementsId,theAxis,theAngle,true,true);
3301 if ( !myPreviewMode ) {
3302 TPythonDump aPythonDump;
3303 DumpGroupsList(aPythonDump,aGroups);
3304 aPythonDump << this << ".RotateObjectMakeGroups( "
3305 << theObject << ", "
3307 << theAngle << " )";
3312 //=======================================================================
3313 //function : RotateMakeMesh
3315 //=======================================================================
3317 SMESH::SMESH_Mesh_ptr
3318 SMESH_MeshEditor_i::RotateMakeMesh(const SMESH::long_array& theIDsOfElements,
3319 const SMESH::AxisStruct& theAxis,
3320 CORBA::Double theAngleInRadians,
3321 CORBA::Boolean theCopyGroups,
3322 const char* theMeshName)
3324 SMESH::SMESH_Mesh_var mesh;
3325 SMESH_Mesh_i* mesh_i;
3327 { // open new scope to dump "MakeMesh" command
3328 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3330 TPythonDump pydump; // to prevent dump at mesh creation
3332 mesh = makeMesh( theMeshName );
3333 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3336 rotate(theIDsOfElements, theAxis, theAngleInRadians,
3337 false, theCopyGroups, & mesh_i->GetImpl());
3338 mesh_i->CreateGroupServants();
3340 if ( !myPreviewMode ) {
3341 pydump << mesh << " = " << this << ".RotateMakeMesh( "
3342 << theIDsOfElements << ", "
3344 << theAngleInRadians << ", "
3345 << theCopyGroups << ", '"
3346 << theMeshName << "' )";
3351 if(!myPreviewMode && mesh_i)
3352 mesh_i->GetGroups();
3354 return mesh._retn();
3357 //=======================================================================
3358 //function : RotateObjectMakeMesh
3360 //=======================================================================
3362 SMESH::SMESH_Mesh_ptr
3363 SMESH_MeshEditor_i::RotateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
3364 const SMESH::AxisStruct& theAxis,
3365 CORBA::Double theAngleInRadians,
3366 CORBA::Boolean theCopyGroups,
3367 const char* theMeshName)
3369 SMESH::SMESH_Mesh_var mesh;
3370 SMESH_Mesh_i* mesh_i;
3372 {// open new scope to dump "MakeMesh" command
3373 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3375 TPythonDump pydump; // to prevent dump at mesh creation
3376 mesh = makeMesh( theMeshName );
3377 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3380 SMESH::long_array_var anElementsId = theObject->GetIDs();
3381 rotate(anElementsId, theAxis, theAngleInRadians,
3382 false, theCopyGroups, & mesh_i->GetImpl());
3383 mesh_i->CreateGroupServants();
3385 if ( !myPreviewMode ) {
3386 pydump << mesh << " = " << this << ".RotateObjectMakeMesh( "
3387 << theObject << ", "
3389 << theAngleInRadians << ", "
3390 << theCopyGroups << ", '"
3391 << theMeshName << "' )";
3396 if(!myPreviewMode && mesh_i)
3397 mesh_i->GetGroups();
3399 return mesh._retn();
3403 //=======================================================================
3406 //=======================================================================
3408 SMESH::ListOfGroups*
3409 SMESH_MeshEditor_i::scale(const SMESH::long_array & theIDsOfElements,
3410 const SMESH::PointStruct& thePoint,
3411 const SMESH::double_array& theScaleFact,
3412 CORBA::Boolean theCopy,
3413 const bool theMakeGroups,
3414 ::SMESH_Mesh* theTargetMesh)
3418 TIDSortedElemSet elements;
3419 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
3421 gp_Pnt aPnt( thePoint.x, thePoint.y, thePoint.z );
3422 list<double> aScaleFact;
3423 for (int i = 0; i < theScaleFact.length(); i++) {
3424 aScaleFact.push_back( theScaleFact[i] );
3427 ::SMESH_MeshEditor anEditor( myMesh );
3428 ::SMESH_MeshEditor::PGroupIDs groupIds =
3429 anEditor.Scale (elements, aPnt, aScaleFact, theCopy,
3430 theMakeGroups, theTargetMesh);
3433 storeResult(anEditor);
3435 myMesh->SetIsModified( true );
3437 return theMakeGroups ? getGroups(groupIds.get()) : 0;
3441 //=======================================================================
3444 //=======================================================================
3446 void SMESH_MeshEditor_i::Scale(SMESH::SMESH_IDSource_ptr theObject,
3447 const SMESH::PointStruct& thePoint,
3448 const SMESH::double_array& theScaleFact,
3449 CORBA::Boolean theCopy)
3451 if ( !myPreviewMode ) {
3452 TPythonDump() << this << ".Scale( "
3453 << theObject << ", "
3454 << "SMESH.PointStruct( " << thePoint.x << ", "
3455 << thePoint.y << ", " << thePoint.z << " ) ,"
3456 << theScaleFact << ", "
3459 SMESH::long_array_var anElementsId = theObject->GetIDs();
3460 scale(anElementsId, thePoint, theScaleFact, theCopy, false);
3464 //=======================================================================
3465 //function : ScaleMakeGroups
3467 //=======================================================================
3469 SMESH::ListOfGroups*
3470 SMESH_MeshEditor_i::ScaleMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
3471 const SMESH::PointStruct& thePoint,
3472 const SMESH::double_array& theScaleFact)
3474 SMESH::long_array_var anElementsId = theObject->GetIDs();
3475 SMESH::ListOfGroups * aGroups =
3476 scale(anElementsId, thePoint, theScaleFact, true, true);
3478 if ( !myPreviewMode ) {
3480 TPythonDump aPythonDump;
3481 DumpGroupsList(aPythonDump,aGroups);
3482 aPythonDump << this << ".Scale("
3484 << "SMESH.PointStruct(" <<thePoint.x << ","
3485 << thePoint.y << "," << thePoint.z << "),"
3486 << theScaleFact << ",True,True)";
3492 //=======================================================================
3493 //function : ScaleMakeMesh
3495 //=======================================================================
3497 SMESH::SMESH_Mesh_ptr
3498 SMESH_MeshEditor_i::ScaleMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
3499 const SMESH::PointStruct& thePoint,
3500 const SMESH::double_array& theScaleFact,
3501 CORBA::Boolean theCopyGroups,
3502 const char* theMeshName)
3504 SMESH_Mesh_i* mesh_i;
3505 SMESH::SMESH_Mesh_var mesh;
3506 { // open new scope to dump "MakeMesh" command
3507 // and then "GetGroups" using SMESH_Mesh::GetGroups()
3509 TPythonDump pydump; // to prevent dump at mesh creation
3510 mesh = makeMesh( theMeshName );
3511 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
3514 SMESH::long_array_var anElementsId = theObject->GetIDs();
3515 scale(anElementsId, thePoint, theScaleFact,
3516 false, theCopyGroups, & mesh_i->GetImpl());
3517 mesh_i->CreateGroupServants();
3519 if ( !myPreviewMode ) {
3520 pydump << mesh << " = " << this << ".ScaleMakeMesh( "
3521 << theObject << ", "
3522 << "SMESH.PointStruct( " << thePoint.x << ", "
3523 << thePoint.y << ", " << thePoint.z << " ) ,"
3524 << theScaleFact << ", "
3525 << theCopyGroups << ", '"
3526 << theMeshName << "' )";
3531 if(!myPreviewMode && mesh_i)
3532 mesh_i->GetGroups();
3534 return mesh._retn();
3538 //=======================================================================
3539 //function : FindCoincidentNodes
3541 //=======================================================================
3543 void SMESH_MeshEditor_i::FindCoincidentNodes (CORBA::Double Tolerance,
3544 SMESH::array_of_long_array_out GroupsOfNodes)
3548 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
3549 ::SMESH_MeshEditor anEditor( myMesh );
3550 set<const SMDS_MeshNode*> nodes; // no input nodes
3551 anEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
3553 GroupsOfNodes = new SMESH::array_of_long_array;
3554 GroupsOfNodes->length( aListOfListOfNodes.size() );
3555 ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
3556 for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ ) {
3557 list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
3558 list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
3559 SMESH::long_array& aGroup = (*GroupsOfNodes)[ i ];
3560 aGroup.length( aListOfNodes.size() );
3561 for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
3562 aGroup[ j ] = (*lIt)->GetID();
3564 TPythonDump() << "coincident_nodes = " << this << ".FindCoincidentNodes( "
3565 << Tolerance << " )";
3568 //=======================================================================
3569 //function : FindCoincidentNodesOnPart
3571 //=======================================================================
3572 void SMESH_MeshEditor_i::FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr theObject,
3573 CORBA::Double Tolerance,
3574 SMESH::array_of_long_array_out GroupsOfNodes)
3577 SMESH::long_array_var aElementsId = theObject->GetIDs();
3579 SMESHDS_Mesh* aMesh = GetMeshDS();
3580 set<const SMDS_MeshNode*> nodes;
3582 SMESH::SMESH_GroupBase_var group = SMESH::SMESH_GroupBase::_narrow(theObject);
3583 if ( !group->_is_nil() && group->GetType() == SMESH::NODE)
3585 for(int i = 0; i < aElementsId->length(); i++) {
3586 CORBA::Long ind = aElementsId[i];
3587 const SMDS_MeshNode * elem = aMesh->FindNode(ind);
3593 for(int i = 0; i < aElementsId->length(); i++) {
3594 CORBA::Long ind = aElementsId[i];
3595 const SMDS_MeshElement * elem = aMesh->FindElement(ind);
3597 SMDS_ElemIteratorPtr nIt = elem->nodesIterator();
3598 while ( nIt->more() )
3599 nodes.insert( nodes.end(),static_cast<const SMDS_MeshNode*>(nIt->next()));
3605 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
3606 ::SMESH_MeshEditor anEditor( myMesh );
3608 anEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
3610 GroupsOfNodes = new SMESH::array_of_long_array;
3611 GroupsOfNodes->length( aListOfListOfNodes.size() );
3612 ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
3613 for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ ) {
3614 list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
3615 list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
3616 SMESH::long_array& aGroup = (*GroupsOfNodes)[ i ];
3617 aGroup.length( aListOfNodes.size() );
3618 for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
3619 aGroup[ j ] = (*lIt)->GetID();
3621 TPythonDump() << "coincident_nodes_on_part = " << this << ".FindCoincidentNodesOnPart( "
3623 << Tolerance << " )";
3626 //=======================================================================
3627 //function : MergeNodes
3629 //=======================================================================
3631 void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes)
3635 SMESHDS_Mesh* aMesh = GetMeshDS();
3637 TPythonDump aTPythonDump;
3638 aTPythonDump << this << ".MergeNodes([";
3639 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
3640 for (int i = 0; i < GroupsOfNodes.length(); i++)
3642 const SMESH::long_array& aNodeGroup = GroupsOfNodes[ i ];
3643 aListOfListOfNodes.push_back( list< const SMDS_MeshNode* >() );
3644 list< const SMDS_MeshNode* >& aListOfNodes = aListOfListOfNodes.back();
3645 for ( int j = 0; j < aNodeGroup.length(); j++ )
3647 CORBA::Long index = aNodeGroup[ j ];
3648 const SMDS_MeshNode * node = aMesh->FindNode(index);
3650 aListOfNodes.push_back( node );
3652 if ( aListOfNodes.size() < 2 )
3653 aListOfListOfNodes.pop_back();
3655 if ( i > 0 ) aTPythonDump << ", ";
3656 aTPythonDump << aNodeGroup;
3658 ::SMESH_MeshEditor anEditor( myMesh );
3659 anEditor.MergeNodes( aListOfListOfNodes );
3661 aTPythonDump << "])";
3663 myMesh->SetIsModified( true );
3666 //=======================================================================
3667 //function : FindEqualElements
3669 //=======================================================================
3670 void SMESH_MeshEditor_i::FindEqualElements(SMESH::SMESH_IDSource_ptr theObject,
3671 SMESH::array_of_long_array_out GroupsOfElementsID)
3675 SMESH::SMESH_GroupBase_var group = SMESH::SMESH_GroupBase::_narrow(theObject);
3676 if ( !(!group->_is_nil() && group->GetType() == SMESH::NODE) )
3678 typedef list<int> TListOfIDs;
3679 set<const SMDS_MeshElement*> elems;
3680 SMESH::long_array_var aElementsId = theObject->GetIDs();
3681 SMESHDS_Mesh* aMesh = GetMeshDS();
3683 for(int i = 0; i < aElementsId->length(); i++) {
3684 CORBA::Long anID = aElementsId[i];
3685 const SMDS_MeshElement * elem = aMesh->FindElement(anID);
3691 ::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
3692 ::SMESH_MeshEditor anEditor( myMesh );
3693 anEditor.FindEqualElements( elems, aListOfListOfElementsID );
3695 GroupsOfElementsID = new SMESH::array_of_long_array;
3696 GroupsOfElementsID->length( aListOfListOfElementsID.size() );
3698 ::SMESH_MeshEditor::TListOfListOfElementsID::iterator arraysIt = aListOfListOfElementsID.begin();
3699 for (CORBA::Long j = 0; arraysIt != aListOfListOfElementsID.end(); ++arraysIt, ++j) {
3700 SMESH::long_array& aGroup = (*GroupsOfElementsID)[ j ];
3701 TListOfIDs& listOfIDs = *arraysIt;
3702 aGroup.length( listOfIDs.size() );
3703 TListOfIDs::iterator idIt = listOfIDs.begin();
3704 for (int k = 0; idIt != listOfIDs.end(); ++idIt, ++k ) {
3705 aGroup[ k ] = *idIt;
3709 TPythonDump() << "equal_elements = " << this << ".FindEqualElements( "
3714 //=======================================================================
3715 //function : MergeElements
3717 //=======================================================================
3719 void SMESH_MeshEditor_i::MergeElements(const SMESH::array_of_long_array& GroupsOfElementsID)
3723 TPythonDump aTPythonDump;
3724 aTPythonDump << this << ".MergeElements( [";
3726 ::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
3728 for (int i = 0; i < GroupsOfElementsID.length(); i++) {
3729 const SMESH::long_array& anElemsIDGroup = GroupsOfElementsID[ i ];
3730 aListOfListOfElementsID.push_back( list< int >() );
3731 list< int >& aListOfElemsID = aListOfListOfElementsID.back();
3732 for ( int j = 0; j < anElemsIDGroup.length(); j++ ) {
3733 CORBA::Long id = anElemsIDGroup[ j ];
3734 aListOfElemsID.push_back( id );
3736 if ( aListOfElemsID.size() < 2 )
3737 aListOfListOfElementsID.pop_back();
3738 if ( i > 0 ) aTPythonDump << ", ";
3739 aTPythonDump << anElemsIDGroup;
3742 ::SMESH_MeshEditor anEditor( myMesh );
3743 anEditor.MergeElements(aListOfListOfElementsID);
3745 myMesh->SetIsModified( true );
3747 aTPythonDump << "] )";
3750 //=======================================================================
3751 //function : MergeEqualElements
3753 //=======================================================================
3755 void SMESH_MeshEditor_i::MergeEqualElements()
3759 ::SMESH_MeshEditor anEditor( myMesh );
3760 anEditor.MergeEqualElements();
3762 TPythonDump() << this << ".MergeEqualElements()";
3765 //=============================================================================
3767 * Move the node to a given point
3769 //=============================================================================
3771 CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long NodeID,
3776 initData(/*deleteSearchers=*/false);
3778 const SMDS_MeshNode * node = GetMeshDS()->FindNode( NodeID );
3782 if ( theNodeSearcher )
3783 theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
3785 if ( myPreviewMode ) // make preview data
3787 // in a preview mesh, make edges linked to a node
3788 TPreviewMesh tmpMesh;
3789 TIDSortedElemSet linkedNodes;
3790 ::SMESH_MeshEditor::GetLinkedNodes( node, linkedNodes );
3791 TIDSortedElemSet::iterator nIt = linkedNodes.begin();
3792 for ( ; nIt != linkedNodes.end(); ++nIt )
3794 SMDS_MeshEdge edge( node, cast2Node( *nIt ));
3795 tmpMesh.Copy( &edge );
3798 node = tmpMesh.GetMeshDS()->FindNode( NodeID );
3800 tmpMesh.GetMeshDS()->MoveNode(node, x, y, z);
3801 // fill preview data
3802 ::SMESH_MeshEditor anEditor( & tmpMesh );
3803 storeResult( anEditor );
3805 else if ( theNodeSearcher ) // move node and update theNodeSearcher data accordingly
3806 theNodeSearcher->MoveNode(node, gp_Pnt( x,y,z ));
3808 GetMeshDS()->MoveNode(node, x, y, z);
3810 if ( !myPreviewMode )
3812 // Update Python script
3813 TPythonDump() << "isDone = " << this << ".MoveNode( "
3814 << NodeID << ", " << x << ", " << y << ", " << z << " )";
3816 myMesh->SetIsModified( true );
3822 //================================================================================
3824 * \brief Return ID of node closest to a given point
3826 //================================================================================
3828 CORBA::Long SMESH_MeshEditor_i::FindNodeClosestTo(CORBA::Double x,
3832 theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
3834 if ( !theNodeSearcher ) {
3835 ::SMESH_MeshEditor anEditor( myMesh );
3836 theNodeSearcher = anEditor.GetNodeSearcher();
3839 if ( const SMDS_MeshNode* node = theNodeSearcher->FindClosestTo( p ))
3840 return node->GetID();
3845 //================================================================================
3847 * \brief If the given ID is a valid node ID (nodeID > 0), just move this node, else
3848 * move the node closest to the point to point's location and return ID of the node
3850 //================================================================================
3852 CORBA::Long SMESH_MeshEditor_i::MoveClosestNodeToPoint(CORBA::Double x,
3855 CORBA::Long theNodeID)
3857 // We keep theNodeSearcher until any mesh modification:
3858 // 1) initData() deletes theNodeSearcher at any edition,
3859 // 2) TSearchersDeleter - at any mesh compute event and mesh change
3861 initData(/*deleteSearchers=*/false);
3863 theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
3865 int nodeID = theNodeID;
3866 const SMDS_MeshNode* node = GetMeshDS()->FindNode( nodeID );
3867 if ( !node ) // preview moving node
3869 if ( !theNodeSearcher ) {
3870 ::SMESH_MeshEditor anEditor( myMesh );
3871 theNodeSearcher = anEditor.GetNodeSearcher();
3874 node = theNodeSearcher->FindClosestTo( p );
3877 nodeID = node->GetID();
3878 if ( myPreviewMode ) // make preview data
3880 // in a preview mesh, make edges linked to a node
3881 TPreviewMesh tmpMesh;
3882 TIDSortedElemSet linkedNodes;
3883 ::SMESH_MeshEditor::GetLinkedNodes( node, linkedNodes );
3884 TIDSortedElemSet::iterator nIt = linkedNodes.begin();
3885 for ( ; nIt != linkedNodes.end(); ++nIt )
3887 SMDS_MeshEdge edge( node, cast2Node( *nIt ));
3888 tmpMesh.Copy( &edge );
3891 node = tmpMesh.GetMeshDS()->FindNode( nodeID );
3893 tmpMesh.GetMeshDS()->MoveNode(node, x, y, z);
3894 // fill preview data
3895 ::SMESH_MeshEditor anEditor( & tmpMesh );
3896 storeResult( anEditor );
3898 else if ( theNodeSearcher ) // move node and update theNodeSearcher data accordingly
3900 theNodeSearcher->MoveNode(node, gp_Pnt( x,y,z ));
3904 GetMeshDS()->MoveNode(node, x, y, z);
3908 if ( !myPreviewMode )
3910 TPythonDump() << "nodeID = " << this
3911 << ".MoveClosestNodeToPoint( "<< x << ", " << y << ", " << z
3912 << ", " << nodeID << " )";
3914 myMesh->SetIsModified( true );
3920 //=======================================================================
3922 * Return elements of given type where the given point is IN or ON.
3924 * 'ALL' type means elements of any type excluding nodes
3926 //=======================================================================
3928 SMESH::long_array* SMESH_MeshEditor_i::FindElementsByPoint(CORBA::Double x,
3931 SMESH::ElementType type)
3933 SMESH::long_array_var res = new SMESH::long_array;
3934 vector< const SMDS_MeshElement* > foundElems;
3936 theSearchersDeleter.Set( myMesh );
3937 if ( !theElementSearcher ) {
3938 ::SMESH_MeshEditor anEditor( myMesh );
3939 theElementSearcher = anEditor.GetElementSearcher();
3941 theElementSearcher->FindElementsByPoint( gp_Pnt( x,y,z ),
3942 SMDSAbs_ElementType( type ),
3944 res->length( foundElems.size() );
3945 for ( int i = 0; i < foundElems.size(); ++i )
3946 res[i] = foundElems[i]->GetID();
3948 if ( !myPreviewMode ) // call from tui
3949 TPythonDump() << res << " = " << this << ".FindElementsByPoint( "
3958 //=======================================================================
3959 //function : GetPointState
3960 //purpose : Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
3961 // TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
3962 //=======================================================================
3964 CORBA::Short SMESH_MeshEditor_i::GetPointState(CORBA::Double x,
3968 theSearchersDeleter.Set( myMesh );
3969 if ( !theElementSearcher ) {
3970 ::SMESH_MeshEditor anEditor( myMesh );
3971 theElementSearcher = anEditor.GetElementSearcher();
3973 return CORBA::Short( theElementSearcher->GetPointState( gp_Pnt( x,y,z )));
3976 //=======================================================================
3977 //function : convError
3979 //=======================================================================
3981 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
3983 static SMESH::SMESH_MeshEditor::Sew_Error convError( const::SMESH_MeshEditor::Sew_Error e )
3987 RETCASE( SEW_BORDER1_NOT_FOUND );
3988 RETCASE( SEW_BORDER2_NOT_FOUND );
3989 RETCASE( SEW_BOTH_BORDERS_NOT_FOUND );
3990 RETCASE( SEW_BAD_SIDE_NODES );
3991 RETCASE( SEW_VOLUMES_TO_SPLIT );
3992 RETCASE( SEW_DIFF_NB_OF_ELEMENTS );
3993 RETCASE( SEW_TOPO_DIFF_SETS_OF_ELEMENTS );
3994 RETCASE( SEW_BAD_SIDE1_NODES );
3995 RETCASE( SEW_BAD_SIDE2_NODES );
3997 return SMESH::SMESH_MeshEditor::SEW_OK;
4000 //=======================================================================
4001 //function : SewFreeBorders
4003 //=======================================================================
4005 SMESH::SMESH_MeshEditor::Sew_Error
4006 SMESH_MeshEditor_i::SewFreeBorders(CORBA::Long FirstNodeID1,
4007 CORBA::Long SecondNodeID1,
4008 CORBA::Long LastNodeID1,
4009 CORBA::Long FirstNodeID2,
4010 CORBA::Long SecondNodeID2,
4011 CORBA::Long LastNodeID2,
4012 CORBA::Boolean CreatePolygons,
4013 CORBA::Boolean CreatePolyedrs)
4017 SMESHDS_Mesh* aMesh = GetMeshDS();
4019 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
4020 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
4021 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
4022 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
4023 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
4024 const SMDS_MeshNode* aSide2ThirdNode = aMesh->FindNode( LastNodeID2 );
4026 if (!aBorderFirstNode ||
4027 !aBorderSecondNode||
4029 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
4030 if (!aSide2FirstNode ||
4031 !aSide2SecondNode ||
4033 return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
4035 TPythonDump() << "error = " << this << ".SewFreeBorders( "
4036 << FirstNodeID1 << ", "
4037 << SecondNodeID1 << ", "
4038 << LastNodeID1 << ", "
4039 << FirstNodeID2 << ", "
4040 << SecondNodeID2 << ", "
4041 << LastNodeID2 << ", "
4042 << CreatePolygons<< ", "
4043 << CreatePolyedrs<< " )";
4045 ::SMESH_MeshEditor anEditor( myMesh );
4046 SMESH::SMESH_MeshEditor::Sew_Error error =
4047 convError( anEditor.SewFreeBorder (aBorderFirstNode,
4057 storeResult(anEditor);
4059 myMesh->SetIsModified( true );
4065 //=======================================================================
4066 //function : SewConformFreeBorders
4068 //=======================================================================
4070 SMESH::SMESH_MeshEditor::Sew_Error
4071 SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1,
4072 CORBA::Long SecondNodeID1,
4073 CORBA::Long LastNodeID1,
4074 CORBA::Long FirstNodeID2,
4075 CORBA::Long SecondNodeID2)
4079 SMESHDS_Mesh* aMesh = GetMeshDS();
4081 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
4082 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
4083 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
4084 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
4085 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
4086 const SMDS_MeshNode* aSide2ThirdNode = 0;
4088 if (!aBorderFirstNode ||
4089 !aBorderSecondNode||
4091 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
4092 if (!aSide2FirstNode ||
4094 return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
4096 TPythonDump() << "error = " << this << ".SewConformFreeBorders( "
4097 << FirstNodeID1 << ", "
4098 << SecondNodeID1 << ", "
4099 << LastNodeID1 << ", "
4100 << FirstNodeID2 << ", "
4101 << SecondNodeID2 << " )";
4103 ::SMESH_MeshEditor anEditor( myMesh );
4104 SMESH::SMESH_MeshEditor::Sew_Error error =
4105 convError( anEditor.SewFreeBorder (aBorderFirstNode,
4114 storeResult(anEditor);
4116 myMesh->SetIsModified( true );
4122 //=======================================================================
4123 //function : SewBorderToSide
4125 //=======================================================================
4127 SMESH::SMESH_MeshEditor::Sew_Error
4128 SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder,
4129 CORBA::Long SecondNodeIDOnFreeBorder,
4130 CORBA::Long LastNodeIDOnFreeBorder,
4131 CORBA::Long FirstNodeIDOnSide,
4132 CORBA::Long LastNodeIDOnSide,
4133 CORBA::Boolean CreatePolygons,
4134 CORBA::Boolean CreatePolyedrs)
4138 SMESHDS_Mesh* aMesh = GetMeshDS();
4140 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeIDOnFreeBorder );
4141 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeIDOnFreeBorder );
4142 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeIDOnFreeBorder );
4143 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeIDOnSide );
4144 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( LastNodeIDOnSide );
4145 const SMDS_MeshNode* aSide2ThirdNode = 0;
4147 if (!aBorderFirstNode ||
4148 !aBorderSecondNode||
4150 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
4151 if (!aSide2FirstNode ||
4153 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE_NODES;
4155 TPythonDump() << "error = " << this << ".SewBorderToSide( "
4156 << FirstNodeIDOnFreeBorder << ", "
4157 << SecondNodeIDOnFreeBorder << ", "
4158 << LastNodeIDOnFreeBorder << ", "
4159 << FirstNodeIDOnSide << ", "
4160 << LastNodeIDOnSide << ", "
4161 << CreatePolygons << ", "
4162 << CreatePolyedrs << ") ";
4164 ::SMESH_MeshEditor anEditor( myMesh );
4165 SMESH::SMESH_MeshEditor::Sew_Error error =
4166 convError( anEditor.SewFreeBorder (aBorderFirstNode,
4176 storeResult(anEditor);
4178 myMesh->SetIsModified( true );
4184 //=======================================================================
4185 //function : SewSideElements
4187 //=======================================================================
4189 SMESH::SMESH_MeshEditor::Sew_Error
4190 SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements,
4191 const SMESH::long_array& IDsOfSide2Elements,
4192 CORBA::Long NodeID1OfSide1ToMerge,
4193 CORBA::Long NodeID1OfSide2ToMerge,
4194 CORBA::Long NodeID2OfSide1ToMerge,
4195 CORBA::Long NodeID2OfSide2ToMerge)
4199 SMESHDS_Mesh* aMesh = GetMeshDS();
4201 const SMDS_MeshNode* aFirstNode1ToMerge = aMesh->FindNode( NodeID1OfSide1ToMerge );
4202 const SMDS_MeshNode* aFirstNode2ToMerge = aMesh->FindNode( NodeID1OfSide2ToMerge );
4203 const SMDS_MeshNode* aSecondNode1ToMerge = aMesh->FindNode( NodeID2OfSide1ToMerge );
4204 const SMDS_MeshNode* aSecondNode2ToMerge = aMesh->FindNode( NodeID2OfSide2ToMerge );
4206 if (!aFirstNode1ToMerge ||
4207 !aFirstNode2ToMerge )
4208 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE1_NODES;
4209 if (!aSecondNode1ToMerge||
4210 !aSecondNode2ToMerge)
4211 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE2_NODES;
4213 TIDSortedElemSet aSide1Elems, aSide2Elems;
4214 arrayToSet(IDsOfSide1Elements, aMesh, aSide1Elems);
4215 arrayToSet(IDsOfSide2Elements, aMesh, aSide2Elems);
4217 TPythonDump() << "error = " << this << ".SewSideElements( "
4218 << IDsOfSide1Elements << ", "
4219 << IDsOfSide2Elements << ", "
4220 << NodeID1OfSide1ToMerge << ", "
4221 << NodeID1OfSide2ToMerge << ", "
4222 << NodeID2OfSide1ToMerge << ", "
4223 << NodeID2OfSide2ToMerge << ")";
4225 ::SMESH_MeshEditor anEditor( myMesh );
4226 SMESH::SMESH_MeshEditor::Sew_Error error =
4227 convError( anEditor.SewSideElements (aSide1Elems, aSide2Elems,
4230 aSecondNode1ToMerge,
4231 aSecondNode2ToMerge));
4233 storeResult(anEditor);
4235 myMesh->SetIsModified( true );
4240 //================================================================================
4242 * \brief Set new nodes for given element
4243 * \param ide - element id
4244 * \param newIDs - new node ids
4245 * \retval CORBA::Boolean - true if result is OK
4247 //================================================================================
4249 CORBA::Boolean SMESH_MeshEditor_i::ChangeElemNodes(CORBA::Long ide,
4250 const SMESH::long_array& newIDs)
4254 const SMDS_MeshElement* elem = GetMeshDS()->FindElement(ide);
4255 if(!elem) return false;
4257 int nbn = newIDs.length();
4259 vector<const SMDS_MeshNode*> aNodes(nbn);
4262 const SMDS_MeshNode* aNode = GetMeshDS()->FindNode(newIDs[i]);
4265 aNodes[nbn1] = aNode;
4268 TPythonDump() << "isDone = " << this << ".ChangeElemNodes( "
4269 << ide << ", " << newIDs << " )";
4271 bool res = GetMeshDS()->ChangeElementNodes( elem, & aNodes[0], nbn1+1 );
4274 myMesh->SetIsModified( true );
4279 //================================================================================
4281 * \brief Update myLastCreated* or myPreviewData
4282 * \param anEditor - it contains last modification results
4284 //================================================================================
4286 void SMESH_MeshEditor_i::storeResult(::SMESH_MeshEditor& anEditor)
4288 if ( myPreviewMode ) { // --- MeshPreviewStruct filling ---
4290 list<int> aNodesConnectivity;
4291 typedef map<int, int> TNodesMap;
4294 TPreviewMesh * aPreviewMesh = dynamic_cast< TPreviewMesh* >( anEditor.GetMesh() );
4295 SMDSAbs_ElementType previewType = aPreviewMesh->myPreviewType;
4297 SMESHDS_Mesh* aMeshDS = anEditor.GetMeshDS();
4298 int nbEdges = aMeshDS->NbEdges();
4299 int nbFaces = aMeshDS->NbFaces();
4300 int nbVolum = aMeshDS->NbVolumes();
4301 switch ( previewType ) {
4302 case SMDSAbs_Edge : nbFaces = nbVolum = 0; break;
4303 case SMDSAbs_Face : nbEdges = nbVolum = 0; break;
4304 case SMDSAbs_Volume: nbEdges = nbFaces = 0; break;
4307 myPreviewData->nodesXYZ.length(aMeshDS->NbNodes());
4308 myPreviewData->elementTypes.length(nbEdges + nbFaces + nbVolum);
4310 SMDS_ElemIteratorPtr itMeshElems = aMeshDS->elementsIterator();
4312 while ( itMeshElems->more() ) {
4313 const SMDS_MeshElement* aMeshElem = itMeshElems->next();
4314 if ( previewType != SMDSAbs_All && aMeshElem->GetType() != previewType )
4317 SMDS_ElemIteratorPtr itElemNodes = aMeshElem->nodesIterator();
4318 while ( itElemNodes->more() ) {
4319 const SMDS_MeshNode* aMeshNode =
4320 static_cast<const SMDS_MeshNode*>( itElemNodes->next() );
4321 int aNodeID = aMeshNode->GetID();
4322 TNodesMap::iterator anIter = nodesMap.find(aNodeID);
4323 if ( anIter == nodesMap.end() ) {
4324 // filling the nodes coordinates
4325 myPreviewData->nodesXYZ[j].x = aMeshNode->X();
4326 myPreviewData->nodesXYZ[j].y = aMeshNode->Y();
4327 myPreviewData->nodesXYZ[j].z = aMeshNode->Z();
4328 anIter = nodesMap.insert( make_pair(aNodeID, j) ).first;
4331 aNodesConnectivity.push_back(anIter->second);
4334 // filling the elements types
4335 SMDSAbs_ElementType aType;
4337 /*if (aMeshElem->GetType() == SMDSAbs_Volume) {
4338 aType = SMDSAbs_Node;
4342 aType = aMeshElem->GetType();
4343 isPoly = aMeshElem->IsPoly();
4346 myPreviewData->elementTypes[i].SMDS_ElementType = (SMESH::ElementType) aType;
4347 myPreviewData->elementTypes[i].isPoly = isPoly;
4348 myPreviewData->elementTypes[i].nbNodesInElement = aMeshElem->NbNodes();
4352 myPreviewData->nodesXYZ.length( j );
4354 // filling the elements connectivities
4355 list<int>::iterator aConnIter = aNodesConnectivity.begin();
4356 myPreviewData->elementConnectivities.length(aNodesConnectivity.size());
4357 for( int i = 0; aConnIter != aNodesConnectivity.end(); aConnIter++, i++ )
4358 myPreviewData->elementConnectivities[i] = *aConnIter;
4364 // add new nodes into myLastCreatedNodes
4365 const SMESH_SequenceOfElemPtr& aSeq = anEditor.GetLastCreatedNodes();
4366 myLastCreatedNodes->length(aSeq.Length());
4367 for(int i=0; i<aSeq.Length(); i++)
4368 myLastCreatedNodes[i] = aSeq.Value(i+1)->GetID();
4371 // add new elements into myLastCreatedElems
4372 const SMESH_SequenceOfElemPtr& aSeq = anEditor.GetLastCreatedElems();
4373 myLastCreatedElems->length(aSeq.Length());
4374 for(int i=0; i<aSeq.Length(); i++)
4375 myLastCreatedElems[i] = aSeq.Value(i+1)->GetID();
4379 //================================================================================
4381 * Return data of mesh edition preview
4383 //================================================================================
4385 SMESH::MeshPreviewStruct* SMESH_MeshEditor_i::GetPreviewData()
4387 return myPreviewData._retn();
4390 //================================================================================
4392 * \brief Returns list of it's IDs of created nodes
4393 * \retval SMESH::long_array* - list of node ID
4395 //================================================================================
4397 SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedNodes()
4399 return myLastCreatedNodes._retn();
4402 //================================================================================
4404 * \brief Returns list of it's IDs of created elements
4405 * \retval SMESH::long_array* - list of elements' ID
4407 //================================================================================
4409 SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedElems()
4411 return myLastCreatedElems._retn();
4414 //=======================================================================
4415 //function : ConvertToQuadratic
4417 //=======================================================================
4419 void SMESH_MeshEditor_i::ConvertToQuadratic(CORBA::Boolean theForce3d)
4421 ::SMESH_MeshEditor anEditor( myMesh );
4422 anEditor.ConvertToQuadratic(theForce3d);
4423 TPythonDump() << this << ".ConvertToQuadratic( " << theForce3d << " )";
4424 myMesh->SetIsModified( true );
4427 //=======================================================================
4428 //function : ConvertFromQuadratic
4430 //=======================================================================
4432 CORBA::Boolean SMESH_MeshEditor_i::ConvertFromQuadratic()
4434 ::SMESH_MeshEditor anEditor( myMesh );
4435 CORBA::Boolean isDone = anEditor.ConvertFromQuadratic();
4436 TPythonDump() << this << ".ConvertFromQuadratic()";
4438 myMesh->SetIsModified( true );
4442 //=======================================================================
4443 //function : makeMesh
4444 //purpose : create a named imported mesh
4445 //=======================================================================
4447 SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::makeMesh(const char* theMeshName)
4449 SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen();
4450 SMESH::SMESH_Mesh_var mesh = gen->CreateEmptyMesh();
4451 SALOMEDS::Study_var study = gen->GetCurrentStudy();
4452 SALOMEDS::SObject_var meshSO = gen->ObjectToSObject( study, mesh );
4453 gen->SetName( meshSO, theMeshName, "Mesh" );
4454 gen->SetPixMap( meshSO, "ICON_SMESH_TREE_MESH_IMPORTED");
4456 return mesh._retn();
4459 //=======================================================================
4460 //function : DumpGroupsList
4462 //=======================================================================
4463 void SMESH_MeshEditor_i::DumpGroupsList(TPythonDump & theDumpPython,
4464 const SMESH::ListOfGroups * theGroupList)
4466 bool isDumpGroupList = theGroupList && theGroupList->length() > 0;
4467 if(isDumpGroupList) {
4468 theDumpPython << theGroupList << " = ";
4472 //================================================================================
4474 \brief Generates the unique group name.
4475 \param thePrefix name prefix
4478 //================================================================================
4479 string SMESH_MeshEditor_i::generateGroupName(const string& thePrefix)
4481 SMESH::ListOfGroups_var groups = myMesh_i->GetGroups();
4482 set<string> groupNames;
4484 // Get existing group names
4485 for (int i = 0, nbGroups = groups->length(); i < nbGroups; i++ ) {
4486 SMESH::SMESH_GroupBase_var aGroup = groups[i];
4487 if (CORBA::is_nil(aGroup))
4490 groupNames.insert(aGroup->GetName());
4494 string name = thePrefix;
4497 while (!groupNames.insert(name).second) {
4502 TCollection_AsciiString nbStr(index+1);
4503 name.resize( name.rfind('_')+1 );
4504 name += nbStr.ToCString();
4512 //================================================================================
4514 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
4515 \param theNodes - identifiers of nodes to be doubled
4516 \param theModifiedElems - identifiers of elements to be updated by the new (doubled)
4517 nodes. If list of element identifiers is empty then nodes are doubled but
4518 they not assigned to elements
4519 \return TRUE if operation has been completed successfully, FALSE otherwise
4520 \sa DoubleNode(), DoubleNodeGroup(), DoubleNodeGroups()
4522 //================================================================================
4524 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodes( const SMESH::long_array& theNodes,
4525 const SMESH::long_array& theModifiedElems )
4529 ::SMESH_MeshEditor aMeshEditor( myMesh );
4530 list< int > aListOfNodes;
4532 for ( i = 0, n = theNodes.length(); i < n; i++ )
4533 aListOfNodes.push_back( theNodes[ i ] );
4535 list< int > aListOfElems;
4536 for ( i = 0, n = theModifiedElems.length(); i < n; i++ )
4537 aListOfElems.push_back( theModifiedElems[ i ] );
4539 bool aResult = aMeshEditor.DoubleNodes( aListOfNodes, aListOfElems );
4541 storeResult( aMeshEditor) ;
4543 myMesh->SetIsModified( true );
4545 // Update Python script
4546 TPythonDump() << this << ".DoubleNodes( " << theNodes << ", "<< theModifiedElems << " )";
4551 //================================================================================
4553 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
4554 This method provided for convenience works as DoubleNodes() described above.
4555 \param theNodeId - identifier of node to be doubled.
4556 \param theModifiedElems - identifiers of elements to be updated.
4557 \return TRUE if operation has been completed successfully, FALSE otherwise
4558 \sa DoubleNodes(), DoubleNodeGroup(), DoubleNodeGroups()
4560 //================================================================================
4562 CORBA::Boolean SMESH_MeshEditor_i::DoubleNode( CORBA::Long theNodeId,
4563 const SMESH::long_array& theModifiedElems )
4565 SMESH::long_array_var aNodes = new SMESH::long_array;
4566 aNodes->length( 1 );
4567 aNodes[ 0 ] = theNodeId;
4569 TPythonDump pyDump; // suppress dump by the next line
4571 CORBA::Boolean done = DoubleNodes( aNodes, theModifiedElems );
4573 pyDump << this << ".DoubleNode( " << theNodeId << ", " << theModifiedElems << " )";
4578 //================================================================================
4580 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
4581 This method provided for convenience works as DoubleNodes() described above.
4582 \param theNodes - group of nodes to be doubled.
4583 \param theModifiedElems - group of elements to be updated.
4584 \return TRUE if operation has been completed successfully, FALSE otherwise
4585 \sa DoubleNode(), DoubleNodes(), DoubleNodeGroups()
4587 //================================================================================
4589 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroup(SMESH::SMESH_GroupBase_ptr theNodes,
4590 SMESH::SMESH_GroupBase_ptr theModifiedElems )
4592 if ( CORBA::is_nil( theNodes ) && theNodes->GetType() != SMESH::NODE )
4595 SMESH::long_array_var aNodes = theNodes->GetListOfID();
4596 SMESH::long_array_var aModifiedElems;
4597 if ( !CORBA::is_nil( theModifiedElems ) )
4598 aModifiedElems = theModifiedElems->GetListOfID();
4601 aModifiedElems = new SMESH::long_array;
4602 aModifiedElems->length( 0 );
4605 TPythonDump pyDump; // suppress dump by the next line
4607 bool done = DoubleNodes( aNodes, aModifiedElems );
4609 pyDump << this << ".DoubleNodeGroup( " << theNodes << ", " << theModifiedElems << " )";
4615 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements.
4616 * Works as DoubleNodeGroup(), but returns a new group with newly created nodes.
4617 * \param theNodes - group of nodes to be doubled.
4618 * \param theModifiedElems - group of elements to be updated.
4619 * \return a new group with newly created nodes
4620 * \sa DoubleNodeGroup()
4622 SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeGroupNew( SMESH::SMESH_GroupBase_ptr theNodes,
4623 SMESH::SMESH_GroupBase_ptr theModifiedElems )
4625 if ( CORBA::is_nil( theNodes ) && theNodes->GetType() != SMESH::NODE )
4628 SMESH::SMESH_Group_var aNewGroup;
4631 SMESH::long_array_var aNodes = theNodes->GetListOfID();
4632 SMESH::long_array_var aModifiedElems;
4633 if ( !CORBA::is_nil( theModifiedElems ) )
4634 aModifiedElems = theModifiedElems->GetListOfID();
4636 aModifiedElems = new SMESH::long_array;
4637 aModifiedElems->length( 0 );
4640 TPythonDump pyDump; // suppress dump by the next line
4642 bool aResult = DoubleNodes( aNodes, aModifiedElems );
4646 // Create group with newly created nodes
4647 SMESH::long_array_var anIds = GetLastCreatedNodes();
4648 if (anIds->length() > 0) {
4649 string anUnindexedName (theNodes->GetName());
4650 string aNewName = generateGroupName(anUnindexedName + "_double");
4651 aNewGroup = myMesh_i->CreateGroup(SMESH::NODE, aNewName.c_str());
4652 aNewGroup->Add(anIds);
4656 pyDump << "createdNodes = " << this << ".DoubleNodeGroupNew( " << theNodes << ", "
4657 << theModifiedElems << " )";
4659 return aNewGroup._retn();
4662 //================================================================================
4664 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
4665 This method provided for convenience works as DoubleNodes() described above.
4666 \param theNodes - list of groups of nodes to be doubled
4667 \param theModifiedElems - list of groups of elements to be updated.
4668 \return TRUE if operation has been completed successfully, FALSE otherwise
4669 \sa DoubleNode(), DoubleNodeGroup(), DoubleNodes()
4671 //================================================================================
4673 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroups(const SMESH::ListOfGroups& theNodes,
4674 const SMESH::ListOfGroups& theModifiedElems )
4678 ::SMESH_MeshEditor aMeshEditor( myMesh );
4680 std::list< int > aNodes;
4682 for ( i = 0, n = theNodes.length(); i < n; i++ )
4684 SMESH::SMESH_GroupBase_var aGrp = theNodes[ i ];
4685 if ( !CORBA::is_nil( aGrp ) && aGrp->GetType() == SMESH::NODE )
4687 SMESH::long_array_var aCurr = aGrp->GetListOfID();
4688 for ( j = 0, m = aCurr->length(); j < m; j++ )
4689 aNodes.push_back( aCurr[ j ] );
4693 std::list< int > anElems;
4694 for ( i = 0, n = theModifiedElems.length(); i < n; i++ )
4696 SMESH::SMESH_GroupBase_var aGrp = theModifiedElems[ i ];
4697 if ( !CORBA::is_nil( aGrp ) && aGrp->GetType() != SMESH::NODE )
4699 SMESH::long_array_var aCurr = aGrp->GetListOfID();
4700 for ( j = 0, m = aCurr->length(); j < m; j++ )
4701 anElems.push_back( aCurr[ j ] );
4705 bool aResult = aMeshEditor.DoubleNodes( aNodes, anElems );
4707 storeResult( aMeshEditor) ;
4710 myMesh->SetIsModified( true );
4713 TPythonDump() << this << ".DoubleNodeGroups( " << theNodes << ", " << theModifiedElems << " )";
4718 //================================================================================
4720 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
4721 \param theElems - the list of elements (edges or faces) to be replicated
4722 The nodes for duplication could be found from these elements
4723 \param theNodesNot - list of nodes to NOT replicate
4724 \param theAffectedElems - the list of elements (cells and edges) to which the
4725 replicated nodes should be associated to.
4726 \return TRUE if operation has been completed successfully, FALSE otherwise
4727 \sa DoubleNodeGroup(), DoubleNodeGroups()
4729 //================================================================================
4731 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElem( const SMESH::long_array& theElems,
4732 const SMESH::long_array& theNodesNot,
4733 const SMESH::long_array& theAffectedElems )
4738 ::SMESH_MeshEditor aMeshEditor( myMesh );
4740 SMESHDS_Mesh* aMeshDS = GetMeshDS();
4741 TIDSortedElemSet anElems, aNodes, anAffected;
4742 arrayToSet(theElems, aMeshDS, anElems, SMDSAbs_All);
4743 arrayToSet(theNodesNot, aMeshDS, aNodes, SMDSAbs_Node);
4744 arrayToSet(theAffectedElems, aMeshDS, anAffected, SMDSAbs_All);
4746 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
4748 storeResult( aMeshEditor) ;
4751 myMesh->SetIsModified( true );
4753 // Update Python script
4754 TPythonDump() << this << ".DoubleNodeElem( " << theElems << ", "
4755 << theNodesNot << ", " << theAffectedElems << " )";
4759 //================================================================================
4761 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
4762 \param theElems - the list of elements (edges or faces) to be replicated
4763 The nodes for duplication could be found from these elements
4764 \param theNodesNot - list of nodes to NOT replicate
4765 \param theShape - shape to detect affected elements (element which geometric center
4766 located on or inside shape).
4767 The replicated nodes should be associated to affected elements.
4768 \return TRUE if operation has been completed successfully, FALSE otherwise
4769 \sa DoubleNodeGroupInRegion(), DoubleNodeGroupsInRegion()
4771 //================================================================================
4773 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemInRegion ( const SMESH::long_array& theElems,
4774 const SMESH::long_array& theNodesNot,
4775 GEOM::GEOM_Object_ptr theShape )
4780 ::SMESH_MeshEditor aMeshEditor( myMesh );
4782 SMESHDS_Mesh* aMeshDS = GetMeshDS();
4783 TIDSortedElemSet anElems, aNodes;
4784 arrayToSet(theElems, aMeshDS, anElems, SMDSAbs_All);
4785 arrayToSet(theNodesNot, aMeshDS, aNodes, SMDSAbs_Node);
4787 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape );
4788 bool aResult = aMeshEditor.DoubleNodesInRegion( anElems, aNodes, aShape );
4790 storeResult( aMeshEditor) ;
4793 myMesh->SetIsModified( true );
4795 // Update Python script
4796 TPythonDump() << "isDone = " << this << ".DoubleNodeElemInRegion( " << theElems << ", "
4797 << theNodesNot << ", " << theShape << " )";
4801 //================================================================================
4803 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
4804 \param theElems - group of of elements (edges or faces) to be replicated
4805 \param theNodesNot - group of nodes not to replicated
4806 \param theAffectedElems - group of elements to which the replicated nodes
4807 should be associated to.
4808 \return TRUE if operation has been completed successfully, FALSE otherwise
4809 \sa DoubleNodes(), DoubleNodeGroups()
4811 //================================================================================
4813 static void groupToSet(SMESH::SMESH_GroupBase_ptr theGrp,
4814 SMESHDS_Mesh* theMeshDS,
4815 TIDSortedElemSet& theElemSet,
4816 const SMDSAbs_ElementType theType)
4819 if ( CORBA::is_nil( theGrp ) )
4821 SMESH::long_array_var anIDs = theGrp->GetIDs();
4822 arrayToSet( anIDs, theMeshDS, theElemSet, theType);
4825 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroup(SMESH::SMESH_GroupBase_ptr theElems,
4826 SMESH::SMESH_GroupBase_ptr theNodesNot,
4827 SMESH::SMESH_GroupBase_ptr theAffectedElems)
4829 if ( CORBA::is_nil( theElems ) && theElems->GetType() == SMESH::NODE )
4834 ::SMESH_MeshEditor aMeshEditor( myMesh );
4836 SMESHDS_Mesh* aMeshDS = GetMeshDS();
4837 TIDSortedElemSet anElems, aNodes, anAffected;
4838 groupToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
4839 groupToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
4840 groupToSet( theAffectedElems, aMeshDS, anAffected, SMDSAbs_All );
4842 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
4844 storeResult( aMeshEditor) ;
4847 myMesh->SetIsModified( true );
4849 // Update Python script
4850 TPythonDump() << "isDone = " << this << ".DoubleNodeElemGroup( " << theElems << ", "
4851 << theNodesNot << ", " << theAffectedElems << " )";
4856 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
4857 * Works as DoubleNodeElemGroup(), but returns a new group with newly created elements.
4858 * \param theElems - group of of elements (edges or faces) to be replicated
4859 * \param theNodesNot - group of nodes not to replicated
4860 * \param theAffectedElems - group of elements to which the replicated nodes
4861 * should be associated to.
4862 * \return a new group with newly created elements
4863 * \sa DoubleNodeElemGroup()
4865 SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeElemGroupNew(SMESH::SMESH_GroupBase_ptr theElems,
4866 SMESH::SMESH_GroupBase_ptr theNodesNot,
4867 SMESH::SMESH_GroupBase_ptr theAffectedElems)
4869 if ( CORBA::is_nil( theElems ) && theElems->GetType() == SMESH::NODE )
4872 SMESH::SMESH_Group_var aNewGroup;
4876 ::SMESH_MeshEditor aMeshEditor( myMesh );
4878 SMESHDS_Mesh* aMeshDS = GetMeshDS();
4879 TIDSortedElemSet anElems, aNodes, anAffected;
4880 groupToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
4881 groupToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
4882 groupToSet( theAffectedElems, aMeshDS, anAffected, SMDSAbs_All );
4885 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
4887 storeResult( aMeshEditor) ;
4890 myMesh->SetIsModified( true );
4892 // Create group with newly created elements
4893 SMESH::long_array_var anIds = GetLastCreatedElems();
4894 if (anIds->length() > 0) {
4895 SMESH::ElementType aGroupType = myMesh_i->GetElementType(anIds[0], true);
4896 string anUnindexedName (theElems->GetName());
4897 string aNewName = generateGroupName(anUnindexedName + "_double");
4898 aNewGroup = myMesh_i->CreateGroup(aGroupType, aNewName.c_str());
4899 aNewGroup->Add(anIds);
4903 // Update Python script
4904 TPythonDump() << "createdElems = " << this << ".DoubleNodeElemGroupNew( " << theElems << ", "
4905 << theNodesNot << ", " << theAffectedElems << " )";
4906 return aNewGroup._retn();
4909 //================================================================================
4911 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
4912 \param theElems - group of of elements (edges or faces) to be replicated
4913 \param theNodesNot - group of nodes not to replicated
4914 \param theShape - shape to detect affected elements (element which geometric center
4915 located on or inside shape).
4916 The replicated nodes should be associated to affected elements.
4917 \return TRUE if operation has been completed successfully, FALSE otherwise
4918 \sa DoubleNodesInRegion(), DoubleNodeGroupsInRegion()
4920 //================================================================================
4922 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroupInRegion(SMESH::SMESH_GroupBase_ptr theElems,
4923 SMESH::SMESH_GroupBase_ptr theNodesNot,
4924 GEOM::GEOM_Object_ptr theShape )
4927 if ( CORBA::is_nil( theElems ) && theElems->GetType() == SMESH::NODE )
4932 ::SMESH_MeshEditor aMeshEditor( myMesh );
4934 SMESHDS_Mesh* aMeshDS = GetMeshDS();
4935 TIDSortedElemSet anElems, aNodes, anAffected;
4936 groupToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
4937 groupToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
4939 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape );
4940 bool aResult = aMeshEditor.DoubleNodesInRegion( anElems, aNodes, aShape );
4942 storeResult( aMeshEditor) ;
4945 myMesh->SetIsModified( true );
4947 // Update Python script
4948 TPythonDump() << "isDone = " << this << ".DoubleNodeElemGroupInRegion( " << theElems << ", "
4949 << theNodesNot << ", " << theShape << " )";
4953 //================================================================================
4955 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
4956 This method provided for convenience works as DoubleNodes() described above.
4957 \param theElems - list of groups of elements (edges or faces) to be replicated
4958 \param theNodesNot - list of groups of nodes not to replicated
4959 \param theAffectedElems - group of elements to which the replicated nodes
4960 should be associated to.
4961 \return TRUE if operation has been completed successfully, FALSE otherwise
4962 \sa DoubleNodeGroup(), DoubleNodes()
4964 //================================================================================
4966 static void listOfGroupToSet(const SMESH::ListOfGroups& theGrpList,
4967 SMESHDS_Mesh* theMeshDS,
4968 TIDSortedElemSet& theElemSet,
4969 const bool theIsNodeGrp)
4971 for ( int i = 0, n = theGrpList.length(); i < n; i++ )
4973 SMESH::SMESH_GroupBase_var aGrp = theGrpList[ i ];
4974 if ( !CORBA::is_nil( aGrp ) && (theIsNodeGrp ? aGrp->GetType() == SMESH::NODE
4975 : aGrp->GetType() != SMESH::NODE ) )
4977 SMESH::long_array_var anIDs = aGrp->GetIDs();
4978 arrayToSet( anIDs, theMeshDS, theElemSet, theIsNodeGrp ? SMDSAbs_Node : SMDSAbs_All );
4983 CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroups(const SMESH::ListOfGroups& theElems,
4984 const SMESH::ListOfGroups& theNodesNot,
4985 const SMESH::ListOfGroups& theAffectedElems)
4989 ::SMESH_MeshEditor aMeshEditor( myMesh );
4991 SMESHDS_Mesh* aMeshDS = GetMeshDS();
4992 TIDSortedElemSet anElems, aNodes, anAffected;
4993 listOfGroupToSet(theElems, aMeshDS, anElems, false );
4994 listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true );
4995 listOfGroupToSet(theAffectedElems, aMeshDS, anAffected, false );
4997 bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
4999 storeResult( aMeshEditor) ;
5002 myMesh->SetIsModified( true );
5004 // Update Python script
5005 TPythonDump() << "isDone = " << this << ".DoubleNodeElemGroups( " << &theElems << ", "
5006 << &theNodesNot << ", " << &theAffectedElems << " )";
5010 //================================================================================
5012 \brief Creates a hole in a mesh by doubling the nodes of some particular elements
5013 This method provided for convenience works as DoubleNodes() described above.
5014 \param theElems - list of groups of elements (edges or faces) to be replicated
5015 \param theNodesNot - list of groups of nodes not to replicated
5016 \param theShape - shape to detect affected elements (element which geometric center
5017 located on or inside shape).
5018 The replicated nodes should be associated to affected elements.
5019 \return TRUE if operation has been completed successfully, FALSE otherwise
5020 \sa DoubleNodeGroupInRegion(), DoubleNodesInRegion()
5022 //================================================================================
5025 SMESH_MeshEditor_i::DoubleNodeElemGroupsInRegion(const SMESH::ListOfGroups& theElems,
5026 const SMESH::ListOfGroups& theNodesNot,
5027 GEOM::GEOM_Object_ptr theShape )
5031 ::SMESH_MeshEditor aMeshEditor( myMesh );
5033 SMESHDS_Mesh* aMeshDS = GetMeshDS();
5034 TIDSortedElemSet anElems, aNodes;
5035 listOfGroupToSet(theElems, aMeshDS, anElems,false );
5036 listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true );
5038 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape );
5039 bool aResult = aMeshEditor.DoubleNodesInRegion( anElems, aNodes, aShape );
5041 storeResult( aMeshEditor) ;
5044 myMesh->SetIsModified( true );
5046 // Update Python script
5047 TPythonDump() << "isDone = " << this << ".DoubleNodeElemGroupsInRegion( " << &theElems << ", "
5048 << &theNodesNot << ", " << theShape << " )";
5052 //================================================================================
5054 \brief Generated skin mesh (containing 2D cells) from 3D mesh
5055 The created 2D mesh elements based on nodes of free faces of boundary volumes
5056 \return TRUE if operation has been completed successfully, FALSE otherwise
5058 //================================================================================
5060 CORBA::Boolean SMESH_MeshEditor_i::Make2DMeshFrom3D()
5064 ::SMESH_MeshEditor aMeshEditor( myMesh );
5065 bool aResult = aMeshEditor.Make2DMeshFrom3D();
5066 storeResult( aMeshEditor) ;
5068 TPythonDump() << "isDone = " << this << ".Make2DMeshFrom3D()";