1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
23 // File : SMESH_MeshEditor_i.cxx
24 // Author : Nicolas REJNERI
28 #include "SMESH_MeshEditor_i.hxx"
30 #include "SMDS_MeshEdge.hxx"
31 #include "SMDS_MeshFace.hxx"
32 #include "SMDS_MeshVolume.hxx"
33 #include "SMDS_PolyhedralVolumeOfNodes.hxx"
34 #include "SMESH_MeshEditor.hxx"
35 #include "SMESH_subMeshEventListener.hxx"
36 #include "SMESH_Gen_i.hxx"
37 #include "SMESH_Filter_i.hxx"
38 #include "SMESH_PythonDump.hxx"
40 #include "utilities.h"
41 #include "Utils_ExceptHandlers.hxx"
42 #include "Utils_CorbaException.hxx"
44 #include <BRepAdaptor_Surface.hxx>
45 #include <BRep_Tool.hxx>
46 #include <TopExp_Explorer.hxx>
48 #include <TopoDS_Edge.hxx>
49 #include <TopoDS_Face.hxx>
54 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
58 #include <Standard_Failure.hxx>
61 #include <Standard_ErrorHandler.hxx>
66 #define cast2Node(elem) static_cast<const SMDS_MeshNode*>( elem )
69 using SMESH::TPythonDump;
73 //=============================================================================
75 * \brief Mesh to apply modifications for preview purposes
77 //=============================================================================
79 struct TPreviewMesh: public SMESH_Mesh
81 SMDSAbs_ElementType myPreviewType; // type to show
83 TPreviewMesh(SMDSAbs_ElementType previewElements = SMDSAbs_All) {
84 _isShapeToMesh = _id =_studyId =_idDoc = 0;
85 _myMeshDS = new SMESHDS_Mesh( _id, true );
86 myPreviewType = previewElements;
89 virtual ~TPreviewMesh() { delete _myMeshDS; }
90 //!< Copy a set of elements
91 void Copy(const TIDSortedElemSet & theElements,
92 TIDSortedElemSet& theCopyElements,
93 SMDSAbs_ElementType theSelectType = SMDSAbs_All,
94 SMDSAbs_ElementType theAvoidType = SMDSAbs_All)
96 // loop on theIDsOfElements
97 TIDSortedElemSet::const_iterator eIt = theElements.begin();
98 for ( ; eIt != theElements.end(); ++eIt )
100 const SMDS_MeshElement* anElem = *eIt;
101 if ( !anElem ) continue;
102 SMDSAbs_ElementType type = anElem->GetType();
103 if ( type == theAvoidType ||
104 ( theSelectType != SMDSAbs_All && type != theSelectType ))
107 if ( const SMDS_MeshElement* anElemCopy = Copy( anElem ))
108 theCopyElements.insert( theCopyElements.end(), anElemCopy );
112 SMDS_MeshElement* Copy( const SMDS_MeshElement* anElem )
114 // copy element nodes
115 int anElemNbNodes = anElem->NbNodes();
116 vector< int > anElemNodesID( anElemNbNodes ) ;
117 SMDS_ElemIteratorPtr itElemNodes = anElem->nodesIterator();
118 for ( int i = 0; itElemNodes->more(); i++)
120 const SMDS_MeshNode* anElemNode = cast2Node( itElemNodes->next() );
122 anElemNodesID[i] = anElemNode->GetID();
125 // creates a corresponding element on copied nodes
126 SMDS_MeshElement* anElemCopy = 0;
127 if ( anElem->IsPoly() && anElem->GetType() == SMDSAbs_Volume )
129 const SMDS_PolyhedralVolumeOfNodes* ph =
130 dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*> (anElem);
132 anElemCopy = _myMeshDS->AddPolyhedralVolumeWithID
133 (anElemNodesID, ph->GetQuanities(),anElem->GetID());
136 anElemCopy = ::SMESH_MeshEditor(this).AddElement( anElemNodesID,
143 SMDS_MeshNode* Copy( const SMDS_MeshNode* anElemNode )
145 return _myMeshDS->AddNodeWithID(anElemNode->X(), anElemNode->Y(), anElemNode->Z(),
146 anElemNode->GetID());
148 };// struct TPreviewMesh
150 static SMESH_NodeSearcher * myNodeSearcher = 0;
152 //=============================================================================
154 * \brief Deleter of myNodeSearcher at any compute event occured
156 //=============================================================================
158 struct TNodeSearcherDeleter : public SMESH_subMeshEventListener
162 TNodeSearcherDeleter(): SMESH_subMeshEventListener( false ), // won't be deleted by submesh
164 //!< Delete myNodeSearcher
167 if ( myNodeSearcher ) { delete myNodeSearcher; myNodeSearcher = 0; }
169 typedef map < int, SMESH_subMesh * > TDependsOnMap;
170 //!< The meshod called by submesh: do my main job
171 void ProcessEvent(const int, const int eventType, SMESH_subMesh* sm,
172 SMESH_subMeshEventListenerData*,const SMESH_Hypothesis*)
174 if ( eventType == SMESH_subMesh::COMPUTE_EVENT ) {
176 Unset( sm->GetFather() );
179 //!< set self on all submeshes and delete myNodeSearcher if other mesh is set
180 void Set(SMESH_Mesh* mesh)
182 if ( myMesh && myMesh != mesh ) {
187 if ( SMESH_subMesh* myMainSubMesh = mesh->GetSubMeshContaining(1) ) {
188 const TDependsOnMap & subMeshes = myMainSubMesh->DependsOn();
189 TDependsOnMap::const_iterator sm;
190 for (sm = subMeshes.begin(); sm != subMeshes.end(); sm++)
191 sm->second->SetEventListener( this, 0, sm->second );
194 //!< delete self from all submeshes
195 void Unset(SMESH_Mesh* mesh)
197 if ( SMESH_subMesh* myMainSubMesh = mesh->GetSubMeshContaining(1) ) {
198 const TDependsOnMap & subMeshes = myMainSubMesh->DependsOn();
199 TDependsOnMap::const_iterator sm;
200 for (sm = subMeshes.begin(); sm != subMeshes.end(); sm++)
201 sm->second->DeleteEventListener( this );
206 TCollection_AsciiString mirrorTypeName( SMESH::SMESH_MeshEditor::MirrorType theMirrorType )
208 TCollection_AsciiString typeStr;
209 switch ( theMirrorType ) {
210 case SMESH::SMESH_MeshEditor::POINT:
211 typeStr = "SMESH.SMESH_MeshEditor.POINT";
213 case SMESH::SMESH_MeshEditor::AXIS:
214 typeStr = "SMESH.SMESH_MeshEditor.AXIS";
217 typeStr = "SMESH.SMESH_MeshEditor.PLANE";
223 //=============================================================================
227 //=============================================================================
229 SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESH_Mesh_i* theMesh, bool isPreview)
232 myMesh = & theMesh->GetImpl();
233 myPreviewMode = isPreview;
236 //================================================================================
240 //================================================================================
242 SMESH_MeshEditor_i::~SMESH_MeshEditor_i()
246 //================================================================================
248 * \brief Clear members
250 //================================================================================
252 void SMESH_MeshEditor_i::initData()
254 if ( myPreviewMode ) {
255 myPreviewData = new SMESH::MeshPreviewStruct();
258 myLastCreatedElems = new SMESH::long_array();
259 myLastCreatedNodes = new SMESH::long_array();
260 TNodeSearcherDeleter::Delete();
264 //=============================================================================
268 //=============================================================================
271 SMESH_MeshEditor_i::RemoveElements(const SMESH::long_array & IDsOfElements)
275 ::SMESH_MeshEditor anEditor( myMesh );
278 for (int i = 0; i < IDsOfElements.length(); i++)
279 IdList.push_back( IDsOfElements[i] );
281 // Update Python script
282 TPythonDump() << "isDone = " << this << ".RemoveElements( " << IDsOfElements << " )";
284 TPythonDump() << "print 'RemoveElements: ', isDone";
287 return anEditor.Remove( IdList, false );
290 //=============================================================================
294 //=============================================================================
296 CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::long_array & IDsOfNodes)
300 ::SMESH_MeshEditor anEditor( myMesh );
302 for (int i = 0; i < IDsOfNodes.length(); i++)
303 IdList.push_back( IDsOfNodes[i] );
305 // Update Python script
306 TPythonDump() << "isDone = " << this << ".RemoveNodes( " << IDsOfNodes << " )";
308 TPythonDump() << "print 'RemoveNodes: ', isDone";
311 return anEditor.Remove( IdList, true );
314 //=============================================================================
318 //=============================================================================
320 CORBA::Long SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes)
324 int NbNodes = IDsOfNodes.length();
325 SMDS_MeshElement* elem = 0;
328 CORBA::Long index1 = IDsOfNodes[0];
329 CORBA::Long index2 = IDsOfNodes[1];
330 elem = GetMeshDS()->AddEdge(GetMeshDS()->FindNode(index1), GetMeshDS()->FindNode(index2));
332 // Update Python script
333 TPythonDump() << "edge = " << this << ".AddEdge([ "
334 << index1 << ", " << index2 <<" ])";
337 CORBA::Long n1 = IDsOfNodes[0];
338 CORBA::Long n2 = IDsOfNodes[1];
339 CORBA::Long n12 = IDsOfNodes[2];
340 elem = GetMeshDS()->AddEdge(GetMeshDS()->FindNode(n1),
341 GetMeshDS()->FindNode(n2),
342 GetMeshDS()->FindNode(n12));
343 // Update Python script
344 TPythonDump() << "edgeID = " << this << ".AddEdge([ "
345 <<n1<<", "<<n2<<", "<<n12<<" ])";
349 return elem->GetID();
354 //=============================================================================
358 //=============================================================================
360 CORBA::Long SMESH_MeshEditor_i::AddNode(CORBA::Double x,
361 CORBA::Double y, CORBA::Double z)
365 const SMDS_MeshNode* N = GetMeshDS()->AddNode(x, y, z);
367 // Update Python script
368 TPythonDump() << "nodeID = " << this << ".AddNode( "
369 << x << ", " << y << ", " << z << " )";
374 //=============================================================================
378 //=============================================================================
380 CORBA::Long SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
384 int NbNodes = IDsOfNodes.length();
390 std::vector<const SMDS_MeshNode*> nodes (NbNodes);
391 for (int i = 0; i < NbNodes; i++)
392 nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
394 SMDS_MeshElement* elem = 0;
396 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]);
398 else if (NbNodes == 4) {
399 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
401 else if (NbNodes == 6) {
402 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
405 else if (NbNodes == 8) {
406 elem = GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
407 nodes[4], nodes[5], nodes[6], nodes[7]);
410 // Update Python script
411 TPythonDump() << "faceID = " << this << ".AddFace( " << IDsOfNodes << " )";
414 return elem->GetID();
419 //=============================================================================
423 //=============================================================================
424 CORBA::Long SMESH_MeshEditor_i::AddPolygonalFace
425 (const SMESH::long_array & IDsOfNodes)
429 int NbNodes = IDsOfNodes.length();
430 std::vector<const SMDS_MeshNode*> nodes (NbNodes);
431 for (int i = 0; i < NbNodes; i++)
432 nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
434 const SMDS_MeshElement* elem = GetMeshDS()->AddPolygonalFace(nodes);
436 // Update Python script
437 TPythonDump() <<"faceID = "<<this<<".AddPolygonalFace( "<<IDsOfNodes<<" )";
439 TPythonDump() << "print 'AddPolygonalFace: ', faceID";
443 return elem->GetID();
448 //=============================================================================
452 //=============================================================================
454 CORBA::Long SMESH_MeshEditor_i::AddVolume(const SMESH::long_array & IDsOfNodes)
458 int NbNodes = IDsOfNodes.length();
459 vector< const SMDS_MeshNode*> n(NbNodes);
460 for(int i=0;i<NbNodes;i++)
461 n[i]=GetMeshDS()->FindNode(IDsOfNodes[i]);
463 SMDS_MeshElement* elem = 0;
466 case 4 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3]); break;
467 case 5 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4]); break;
468 case 6 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5]); break;
469 case 8 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break;
470 case 10:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],
471 n[6],n[7],n[8],n[9]);
473 case 13:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],
474 n[7],n[8],n[9],n[10],n[11],n[12]);
476 case 15:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],
477 n[9],n[10],n[11],n[12],n[13],n[14]);
479 case 20:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],
480 n[8],n[9],n[10],n[11],n[12],n[13],n[14],
481 n[15],n[16],n[17],n[18],n[19]);
485 // Update Python script
486 TPythonDump() << "volID = " << this << ".AddVolume( " << IDsOfNodes << " )";
488 TPythonDump() << "print 'AddVolume: ', volID";
492 return elem->GetID();
497 //=============================================================================
499 * AddPolyhedralVolume
501 //=============================================================================
502 CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolume
503 (const SMESH::long_array & IDsOfNodes,
504 const SMESH::long_array & Quantities)
508 int NbNodes = IDsOfNodes.length();
509 std::vector<const SMDS_MeshNode*> n (NbNodes);
510 for (int i = 0; i < NbNodes; i++)
511 n[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
513 int NbFaces = Quantities.length();
514 std::vector<int> q (NbFaces);
515 for (int j = 0; j < NbFaces; j++)
516 q[j] = Quantities[j];
518 const SMDS_MeshElement* elem = GetMeshDS()->AddPolyhedralVolume(n, q);
520 // Update Python script
521 TPythonDump() << "volID = " << this << ".AddPolyhedralVolume( "
522 << IDsOfNodes << ", " << Quantities << " )";
524 TPythonDump() << "print 'AddPolyhedralVolume: ', volID";
528 return elem->GetID();
533 //=============================================================================
535 * AddPolyhedralVolumeByFaces
537 //=============================================================================
538 CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces
539 (const SMESH::long_array & IdsOfFaces)
543 int NbFaces = IdsOfFaces.length();
544 std::vector<const SMDS_MeshNode*> poly_nodes;
545 std::vector<int> quantities (NbFaces);
547 for (int i = 0; i < NbFaces; i++) {
548 const SMDS_MeshElement* aFace = GetMeshDS()->FindElement(IdsOfFaces[i]);
549 quantities[i] = aFace->NbNodes();
551 SMDS_ElemIteratorPtr It = aFace->nodesIterator();
553 poly_nodes.push_back(static_cast<const SMDS_MeshNode *>(It->next()));
557 const SMDS_MeshElement* elem = GetMeshDS()->AddPolyhedralVolume(poly_nodes, quantities);
559 // Update Python script
560 TPythonDump() << "volID = " << this << ".AddPolyhedralVolumeByFaces( "
561 << IdsOfFaces << " )";
563 TPythonDump() << "print 'AddPolyhedralVolume: ', volID";
567 return elem->GetID();
572 //=============================================================================
574 * \brief Bind a node to a vertex
575 * \param NodeID - node ID
576 * \param VertexID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
577 * \retval boolean - false if NodeID or VertexID is invalid
579 //=============================================================================
581 void SMESH_MeshEditor_i::SetNodeOnVertex(CORBA::Long NodeID, CORBA::Long VertexID)
582 throw (SALOME::SALOME_Exception)
584 Unexpect aCatch(SALOME_SalomeException);
586 SMESHDS_Mesh * mesh = GetMeshDS();
587 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
589 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
591 if ( mesh->MaxShapeIndex() < VertexID )
592 THROW_SALOME_CORBA_EXCEPTION("Invalid VertexID", SALOME::BAD_PARAM);
594 TopoDS_Shape shape = mesh->IndexToShape( VertexID );
595 if ( shape.ShapeType() != TopAbs_VERTEX )
596 THROW_SALOME_CORBA_EXCEPTION("Invalid VertexID", SALOME::BAD_PARAM);
598 mesh->SetNodeOnVertex( node, VertexID );
601 //=============================================================================
603 * \brief Store node position on an edge
604 * \param NodeID - node ID
605 * \param EdgeID - edge ID available through GEOM_Object.GetSubShapeIndices()[0]
606 * \param paramOnEdge - parameter on edge where the node is located
607 * \retval boolean - false if any parameter is invalid
609 //=============================================================================
611 void SMESH_MeshEditor_i::SetNodeOnEdge(CORBA::Long NodeID, CORBA::Long EdgeID,
612 CORBA::Double paramOnEdge)
613 throw (SALOME::SALOME_Exception)
615 Unexpect aCatch(SALOME_SalomeException);
617 SMESHDS_Mesh * mesh = GetMeshDS();
618 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
620 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
622 if ( mesh->MaxShapeIndex() < EdgeID )
623 THROW_SALOME_CORBA_EXCEPTION("Invalid EdgeID", SALOME::BAD_PARAM);
625 TopoDS_Shape shape = mesh->IndexToShape( EdgeID );
626 if ( shape.ShapeType() != TopAbs_EDGE )
627 THROW_SALOME_CORBA_EXCEPTION("Invalid EdgeID", SALOME::BAD_PARAM);
630 BRep_Tool::Range( TopoDS::Edge( shape ), f,l);
631 if ( paramOnEdge < f || paramOnEdge > l )
632 THROW_SALOME_CORBA_EXCEPTION("Invalid paramOnEdge", SALOME::BAD_PARAM);
634 mesh->SetNodeOnEdge( node, EdgeID, paramOnEdge );
637 //=============================================================================
639 * \brief Store node position on a face
640 * \param NodeID - node ID
641 * \param FaceID - face ID available through GEOM_Object.GetSubShapeIndices()[0]
642 * \param u - U parameter on face where the node is located
643 * \param v - V parameter on face where the node is located
644 * \retval boolean - false if any parameter is invalid
646 //=============================================================================
648 void SMESH_MeshEditor_i::SetNodeOnFace(CORBA::Long NodeID, CORBA::Long FaceID,
649 CORBA::Double u, CORBA::Double v)
650 throw (SALOME::SALOME_Exception)
652 Unexpect aCatch(SALOME_SalomeException);
654 SMESHDS_Mesh * mesh = GetMeshDS();
655 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
657 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
659 if ( mesh->MaxShapeIndex() < FaceID )
660 THROW_SALOME_CORBA_EXCEPTION("Invalid FaceID", SALOME::BAD_PARAM);
662 TopoDS_Shape shape = mesh->IndexToShape( FaceID );
663 if ( shape.ShapeType() != TopAbs_FACE )
664 THROW_SALOME_CORBA_EXCEPTION("Invalid FaceID", SALOME::BAD_PARAM);
666 BRepAdaptor_Surface surf( TopoDS::Face( shape ));
667 bool isOut = ( u < surf.FirstUParameter() ||
668 u > surf.LastUParameter() ||
669 v < surf.FirstVParameter() ||
670 v > surf.LastVParameter() );
674 MESSAGE ( "FACE " << FaceID << " (" << u << "," << v << ") out of "
675 << " u( " << surf.FirstUParameter()
676 << "," << surf.LastUParameter()
677 << ") v( " << surf.FirstVParameter()
678 << "," << surf.LastVParameter() << ")" );
680 THROW_SALOME_CORBA_EXCEPTION("Invalid UV", SALOME::BAD_PARAM);
683 mesh->SetNodeOnFace( node, FaceID, u, v );
686 //=============================================================================
688 * \brief Bind a node to a solid
689 * \param NodeID - node ID
690 * \param SolidID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
691 * \retval boolean - false if NodeID or SolidID is invalid
693 //=============================================================================
695 void SMESH_MeshEditor_i::SetNodeInVolume(CORBA::Long NodeID, CORBA::Long SolidID)
696 throw (SALOME::SALOME_Exception)
698 Unexpect aCatch(SALOME_SalomeException);
700 SMESHDS_Mesh * mesh = GetMeshDS();
701 SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( mesh->FindNode(NodeID) );
703 THROW_SALOME_CORBA_EXCEPTION("Invalid NodeID", SALOME::BAD_PARAM);
705 if ( mesh->MaxShapeIndex() < SolidID )
706 THROW_SALOME_CORBA_EXCEPTION("Invalid SolidID", SALOME::BAD_PARAM);
708 TopoDS_Shape shape = mesh->IndexToShape( SolidID );
709 if ( shape.ShapeType() != TopAbs_SOLID &&
710 shape.ShapeType() != TopAbs_SHELL)
711 THROW_SALOME_CORBA_EXCEPTION("Invalid SolidID", SALOME::BAD_PARAM);
713 mesh->SetNodeInVolume( node, SolidID );
716 //=============================================================================
718 * \brief Bind an element to a shape
719 * \param ElementID - element ID
720 * \param ShapeID - shape ID available through GEOM_Object.GetSubShapeIndices()[0]
721 * \retval boolean - false if ElementID or ShapeID is invalid
723 //=============================================================================
725 void SMESH_MeshEditor_i::SetMeshElementOnShape(CORBA::Long ElementID,
727 throw (SALOME::SALOME_Exception)
729 Unexpect aCatch(SALOME_SalomeException);
731 SMESHDS_Mesh * mesh = GetMeshDS();
732 SMDS_MeshElement* elem = const_cast<SMDS_MeshElement*>(mesh->FindElement(ElementID));
734 THROW_SALOME_CORBA_EXCEPTION("Invalid ElementID", SALOME::BAD_PARAM);
736 if ( mesh->MaxShapeIndex() < ShapeID )
737 THROW_SALOME_CORBA_EXCEPTION("Invalid ShapeID", SALOME::BAD_PARAM);
739 TopoDS_Shape shape = mesh->IndexToShape( ShapeID );
740 if ( shape.ShapeType() != TopAbs_EDGE &&
741 shape.ShapeType() != TopAbs_FACE &&
742 shape.ShapeType() != TopAbs_SOLID &&
743 shape.ShapeType() != TopAbs_SHELL )
744 THROW_SALOME_CORBA_EXCEPTION("Invalid shape type", SALOME::BAD_PARAM);
746 mesh->SetMeshElementOnShape( elem, ShapeID );
750 //=============================================================================
754 //=============================================================================
756 CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long NodeID,
763 const SMDS_MeshNode * node = GetMeshDS()->FindNode( NodeID );
767 GetMeshDS()->MoveNode(node, x, y, z);
769 // Update Python script
770 TPythonDump() << "isDone = " << this << ".MoveNode( "
771 << NodeID << ", " << x << ", " << y << ", " << z << " )";
776 //=============================================================================
780 //=============================================================================
782 CORBA::Boolean SMESH_MeshEditor_i::InverseDiag(CORBA::Long NodeID1,
787 const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
788 const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
792 // Update Python script
793 TPythonDump() << "isDone = " << this << ".InverseDiag( "
794 << NodeID1 << ", " << NodeID2 << " )";
796 ::SMESH_MeshEditor aMeshEditor( myMesh );
797 return aMeshEditor.InverseDiag ( n1, n2 );
800 //=============================================================================
804 //=============================================================================
806 CORBA::Boolean SMESH_MeshEditor_i::DeleteDiag(CORBA::Long NodeID1,
811 const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
812 const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
816 // Update Python script
817 TPythonDump() << "isDone = " << this << ".DeleteDiag( "
818 << NodeID1 << ", " << NodeID2 << " )";
820 ::SMESH_MeshEditor aMeshEditor( myMesh );
822 bool stat = aMeshEditor.DeleteDiag ( n1, n2 );
824 storeResult(aMeshEditor);
829 //=============================================================================
833 //=============================================================================
835 CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::long_array & IDsOfElements)
839 ::SMESH_MeshEditor anEditor( myMesh );
840 for (int i = 0; i < IDsOfElements.length(); i++)
842 CORBA::Long index = IDsOfElements[i];
843 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
845 anEditor.Reorient( elem );
847 // Update Python script
848 TPythonDump() << "isDone = " << this << ".Reorient( " << IDsOfElements << " )";
854 //=============================================================================
858 //=============================================================================
860 CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theObject)
864 SMESH::long_array_var anElementsId = theObject->GetIDs();
865 CORBA::Boolean isDone = Reorient(anElementsId);
867 // Clear python line, created by Reorient()
868 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
869 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
871 // Update Python script
872 TPythonDump() << "isDone = " << this << ".ReorientObject( " << theObject << " )";
879 //================================================================================
881 * \brief function for conversion long_array to TIDSortedElemSet
882 * \param IDs - array of IDs
883 * \param aMesh - mesh
884 * \param aMap - collection to fill
885 * \param aType - element type
887 //================================================================================
889 void arrayToSet(const SMESH::long_array & IDs,
890 const SMESHDS_Mesh* aMesh,
891 TIDSortedElemSet& aMap,
892 const SMDSAbs_ElementType aType = SMDSAbs_All )
894 for (int i=0; i<IDs.length(); i++) {
895 CORBA::Long ind = IDs[i];
896 const SMDS_MeshElement * elem = aMesh->FindElement(ind);
897 if ( elem && ( aType == SMDSAbs_All || elem->GetType() == aType ))
903 //=============================================================================
907 //=============================================================================
908 CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfElements,
909 SMESH::NumericalFunctor_ptr Criterion,
910 CORBA::Double MaxAngle)
914 SMESHDS_Mesh* aMesh = GetMeshDS();
915 TIDSortedElemSet faces;
916 arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
918 SMESH::NumericalFunctor_i* aNumericalFunctor =
919 dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
920 SMESH::Controls::NumericalFunctorPtr aCrit;
921 if ( !aNumericalFunctor )
922 aCrit.reset( new SMESH::Controls::AspectRatio() );
924 aCrit = aNumericalFunctor->GetNumericalFunctor();
926 // Update Python script
927 TPythonDump() << "isDone = " << this << ".TriToQuad( "
928 << IDsOfElements << ", " << aNumericalFunctor << ", " << MaxAngle << " )";
930 TPythonDump() << "print 'TriToQuad: ', isDone";
933 ::SMESH_MeshEditor anEditor( myMesh );
935 bool stat = anEditor.TriToQuad( faces, aCrit, MaxAngle );
937 storeResult(anEditor);
943 //=============================================================================
947 //=============================================================================
948 CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr theObject,
949 SMESH::NumericalFunctor_ptr Criterion,
950 CORBA::Double MaxAngle)
954 SMESH::long_array_var anElementsId = theObject->GetIDs();
955 CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
957 // Clear python line(s), created by TriToQuad()
958 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
959 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
961 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
964 SMESH::NumericalFunctor_i* aNumericalFunctor =
965 SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
967 // Update Python script
968 TPythonDump() << "isDone = " << this << ".TriToQuadObject("
969 << theObject << ", " << aNumericalFunctor << ", " << MaxAngle << " )";
971 TPythonDump() << "print 'TriToQuadObject: ', isDone";
978 //=============================================================================
982 //=============================================================================
983 CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array & IDsOfElements,
984 SMESH::NumericalFunctor_ptr Criterion)
988 SMESHDS_Mesh* aMesh = GetMeshDS();
989 TIDSortedElemSet faces;
990 arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
992 SMESH::NumericalFunctor_i* aNumericalFunctor =
993 dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
994 SMESH::Controls::NumericalFunctorPtr aCrit;
995 if ( !aNumericalFunctor )
996 aCrit.reset( new SMESH::Controls::AspectRatio() );
998 aCrit = aNumericalFunctor->GetNumericalFunctor();
1001 // Update Python script
1002 TPythonDump() << "isDone = " << this << ".QuadToTri( " << IDsOfElements << ", " << aNumericalFunctor << " )";
1004 TPythonDump() << "print 'QuadToTri: ', isDone";
1007 ::SMESH_MeshEditor anEditor( myMesh );
1008 CORBA::Boolean stat = anEditor.QuadToTri( faces, aCrit );
1010 storeResult(anEditor);
1016 //=============================================================================
1020 //=============================================================================
1021 CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr theObject,
1022 SMESH::NumericalFunctor_ptr Criterion)
1026 SMESH::long_array_var anElementsId = theObject->GetIDs();
1027 CORBA::Boolean isDone = QuadToTri(anElementsId, Criterion);
1029 // Clear python line(s), created by QuadToTri()
1030 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1031 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1033 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1036 SMESH::NumericalFunctor_i* aNumericalFunctor =
1037 SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
1039 // Update Python script
1040 TPythonDump() << "isDone = " << this << ".QuadToTriObject( " << theObject << ", " << aNumericalFunctor << " )";
1042 TPythonDump() << "print 'QuadToTriObject: ', isDone";
1049 //=============================================================================
1053 //=============================================================================
1054 CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfElements,
1055 CORBA::Boolean Diag13)
1059 SMESHDS_Mesh* aMesh = GetMeshDS();
1060 TIDSortedElemSet faces;
1061 arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
1063 // Update Python script
1064 TPythonDump() << "isDone = " << this << ".SplitQuad( "
1065 << IDsOfElements << ", " << Diag13 << " )";
1067 TPythonDump() << "print 'SplitQuad: ', isDone";
1070 ::SMESH_MeshEditor anEditor( myMesh );
1071 CORBA::Boolean stat = anEditor.QuadToTri( faces, Diag13 );
1073 storeResult(anEditor);
1079 //=============================================================================
1083 //=============================================================================
1084 CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr theObject,
1085 CORBA::Boolean Diag13)
1089 SMESH::long_array_var anElementsId = theObject->GetIDs();
1090 CORBA::Boolean isDone = SplitQuad(anElementsId, Diag13);
1092 // Clear python line(s), created by SplitQuad()
1093 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1094 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1096 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1099 // Update Python script
1100 TPythonDump() << "isDone = " << this << ".SplitQuadObject( "
1101 << theObject << ", " << Diag13 << " )";
1103 TPythonDump() << "print 'SplitQuadObject: ', isDone";
1110 //=============================================================================
1114 //=============================================================================
1115 CORBA::Long SMESH_MeshEditor_i::BestSplit (CORBA::Long IDOfQuad,
1116 SMESH::NumericalFunctor_ptr Criterion)
1118 const SMDS_MeshElement* quad = GetMeshDS()->FindElement(IDOfQuad);
1119 if (quad && quad->GetType() == SMDSAbs_Face && quad->NbNodes() == 4)
1121 SMESH::NumericalFunctor_i* aNumericalFunctor =
1122 dynamic_cast<SMESH::NumericalFunctor_i*>(SMESH_Gen_i::GetServant(Criterion).in());
1123 SMESH::Controls::NumericalFunctorPtr aCrit;
1124 if (aNumericalFunctor)
1125 aCrit = aNumericalFunctor->GetNumericalFunctor();
1127 aCrit.reset(new SMESH::Controls::AspectRatio());
1129 ::SMESH_MeshEditor anEditor (myMesh);
1130 return anEditor.BestSplit(quad, aCrit);
1136 //=======================================================================
1139 //=======================================================================
1142 SMESH_MeshEditor_i::Smooth(const SMESH::long_array & IDsOfElements,
1143 const SMESH::long_array & IDsOfFixedNodes,
1144 CORBA::Long MaxNbOfIterations,
1145 CORBA::Double MaxAspectRatio,
1146 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1148 return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations,
1149 MaxAspectRatio, Method, false );
1153 //=======================================================================
1154 //function : SmoothParametric
1156 //=======================================================================
1159 SMESH_MeshEditor_i::SmoothParametric(const SMESH::long_array & IDsOfElements,
1160 const SMESH::long_array & IDsOfFixedNodes,
1161 CORBA::Long MaxNbOfIterations,
1162 CORBA::Double MaxAspectRatio,
1163 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1165 return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations,
1166 MaxAspectRatio, Method, true );
1170 //=======================================================================
1171 //function : SmoothObject
1173 //=======================================================================
1176 SMESH_MeshEditor_i::SmoothObject(SMESH::SMESH_IDSource_ptr theObject,
1177 const SMESH::long_array & IDsOfFixedNodes,
1178 CORBA::Long MaxNbOfIterations,
1179 CORBA::Double MaxAspectRatio,
1180 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1182 return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations,
1183 MaxAspectRatio, Method, false);
1187 //=======================================================================
1188 //function : SmoothParametricObject
1190 //=======================================================================
1193 SMESH_MeshEditor_i::SmoothParametricObject(SMESH::SMESH_IDSource_ptr theObject,
1194 const SMESH::long_array & IDsOfFixedNodes,
1195 CORBA::Long MaxNbOfIterations,
1196 CORBA::Double MaxAspectRatio,
1197 SMESH::SMESH_MeshEditor::Smooth_Method Method)
1199 return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations,
1200 MaxAspectRatio, Method, true);
1204 //=============================================================================
1208 //=============================================================================
1211 SMESH_MeshEditor_i::smooth(const SMESH::long_array & IDsOfElements,
1212 const SMESH::long_array & IDsOfFixedNodes,
1213 CORBA::Long MaxNbOfIterations,
1214 CORBA::Double MaxAspectRatio,
1215 SMESH::SMESH_MeshEditor::Smooth_Method Method,
1220 SMESHDS_Mesh* aMesh = GetMeshDS();
1222 TIDSortedElemSet elements;
1223 arrayToSet(IDsOfElements, aMesh, elements, SMDSAbs_Face);
1225 set<const SMDS_MeshNode*> fixedNodes;
1226 for (int i = 0; i < IDsOfFixedNodes.length(); i++) {
1227 CORBA::Long index = IDsOfFixedNodes[i];
1228 const SMDS_MeshNode * node = aMesh->FindNode(index);
1230 fixedNodes.insert( node );
1232 ::SMESH_MeshEditor::SmoothMethod method = ::SMESH_MeshEditor::LAPLACIAN;
1233 if ( Method != SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH )
1234 method = ::SMESH_MeshEditor::CENTROIDAL;
1236 ::SMESH_MeshEditor anEditor( myMesh );
1237 anEditor.Smooth(elements, fixedNodes, method,
1238 MaxNbOfIterations, MaxAspectRatio, IsParametric );
1240 storeResult(anEditor);
1242 // Update Python script
1243 TPythonDump() << "isDone = " << this << "."
1244 << (IsParametric ? "SmoothParametric( " : "Smooth( ")
1245 << IDsOfElements << ", " << IDsOfFixedNodes << ", "
1246 << MaxNbOfIterations << ", " << MaxAspectRatio << ", "
1247 << "SMESH.SMESH_MeshEditor."
1248 << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
1249 "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
1251 TPythonDump() << "print 'Smooth: ', isDone";
1258 //=============================================================================
1262 //=============================================================================
1265 SMESH_MeshEditor_i::smoothObject(SMESH::SMESH_IDSource_ptr theObject,
1266 const SMESH::long_array & IDsOfFixedNodes,
1267 CORBA::Long MaxNbOfIterations,
1268 CORBA::Double MaxAspectRatio,
1269 SMESH::SMESH_MeshEditor::Smooth_Method Method,
1274 SMESH::long_array_var anElementsId = theObject->GetIDs();
1275 CORBA::Boolean isDone = smooth (anElementsId, IDsOfFixedNodes, MaxNbOfIterations,
1276 MaxAspectRatio, Method, IsParametric);
1278 // Clear python line(s), created by Smooth()
1279 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1280 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1282 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1285 // Update Python script
1286 TPythonDump() << "isDone = " << this << "."
1287 << (IsParametric ? "SmoothParametricObject( " : "SmoothObject( ")
1288 << theObject << ", " << IDsOfFixedNodes << ", "
1289 << MaxNbOfIterations << ", " << MaxAspectRatio << ", "
1290 << "SMESH.SMESH_MeshEditor."
1291 << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
1292 "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
1294 TPythonDump() << "print 'SmoothObject: ', isDone";
1301 //=============================================================================
1305 //=============================================================================
1307 void SMESH_MeshEditor_i::RenumberNodes()
1309 // Update Python script
1310 TPythonDump() << this << ".RenumberNodes()";
1312 GetMeshDS()->Renumber( true );
1316 //=============================================================================
1320 //=============================================================================
1322 void SMESH_MeshEditor_i::RenumberElements()
1324 // Update Python script
1325 TPythonDump() << this << ".RenumberElements()";
1327 GetMeshDS()->Renumber( false );
1330 //=======================================================================
1332 * \brief Return groups by their IDs
1334 //=======================================================================
1336 SMESH::ListOfGroups* SMESH_MeshEditor_i::getGroups(const std::list<int>* groupIDs)
1340 myMesh_i->CreateGroupServants();
1341 return myMesh_i->GetGroups( *groupIDs );
1344 //=======================================================================
1345 //function : rotationSweep
1347 //=======================================================================
1349 SMESH::ListOfGroups*
1350 SMESH_MeshEditor_i::rotationSweep(const SMESH::long_array & theIDsOfElements,
1351 const SMESH::AxisStruct & theAxis,
1352 CORBA::Double theAngleInRadians,
1353 CORBA::Long theNbOfSteps,
1354 CORBA::Double theTolerance,
1355 const bool theMakeGroups)
1359 TIDSortedElemSet inElements, copyElements;
1360 arrayToSet(theIDsOfElements, GetMeshDS(), inElements);
1362 TIDSortedElemSet* workElements = & inElements;
1363 TPreviewMesh tmpMesh( SMDSAbs_Face );
1364 SMESH_Mesh* mesh = 0;
1365 bool makeWalls=true;
1366 if ( myPreviewMode )
1368 SMDSAbs_ElementType select = SMDSAbs_All, avoid = SMDSAbs_Volume;
1369 tmpMesh.Copy( inElements, copyElements, select, avoid );
1371 workElements = & copyElements;
1372 //makeWalls = false;
1379 gp_Ax1 Ax1 (gp_Pnt( theAxis.x, theAxis.y, theAxis.z ),
1380 gp_Vec( theAxis.vx, theAxis.vy, theAxis.vz ));
1382 ::SMESH_MeshEditor anEditor( mesh );
1383 ::SMESH_MeshEditor::PGroupIDs groupIds =
1384 anEditor.RotationSweep (*workElements, Ax1, theAngleInRadians,
1385 theNbOfSteps, theTolerance, theMakeGroups, makeWalls);
1386 storeResult(anEditor);
1388 return theMakeGroups ? getGroups(groupIds.get()) : 0;
1391 //=======================================================================
1392 //function : RotationSweep
1394 //=======================================================================
1396 void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElements,
1397 const SMESH::AxisStruct & theAxis,
1398 CORBA::Double theAngleInRadians,
1399 CORBA::Long theNbOfSteps,
1400 CORBA::Double theTolerance)
1402 if ( !myPreviewMode ) {
1403 TPythonDump() << "axis = " << theAxis;
1404 TPythonDump() << this << ".RotationSweep( "
1407 << theAngleInRadians << ", "
1408 << theNbOfSteps << ", "
1409 << theTolerance << " )";
1411 rotationSweep(theIDsOfElements,
1419 //=======================================================================
1420 //function : RotationSweepMakeGroups
1422 //=======================================================================
1424 SMESH::ListOfGroups*
1425 SMESH_MeshEditor_i::RotationSweepMakeGroups(const SMESH::long_array& theIDsOfElements,
1426 const SMESH::AxisStruct& theAxis,
1427 CORBA::Double theAngleInRadians,
1428 CORBA::Long theNbOfSteps,
1429 CORBA::Double theTolerance)
1431 SMESH::ListOfGroups *aGroups = rotationSweep(theIDsOfElements,
1437 if ( !myPreviewMode ) {
1438 TPythonDump()<< "axis = " << theAxis;
1439 TPythonDump aPythonDump;
1440 DumpGroupsList(aPythonDump,aGroups);
1441 aPythonDump<< this << ".RotationSweepMakeGroups( "
1444 << theAngleInRadians << ", "
1445 << theNbOfSteps << ", "
1446 << theTolerance << " )";
1451 //=======================================================================
1452 //function : RotationSweepObject
1454 //=======================================================================
1456 void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject,
1457 const SMESH::AxisStruct & theAxis,
1458 CORBA::Double theAngleInRadians,
1459 CORBA::Long theNbOfSteps,
1460 CORBA::Double theTolerance)
1462 if ( !myPreviewMode ) {
1463 TPythonDump() << "axis = " << theAxis;
1464 TPythonDump() << this << ".RotationSweepObject( "
1467 << theAngleInRadians << ", "
1468 << theNbOfSteps << ", "
1469 << theTolerance << " )";
1471 SMESH::long_array_var anElementsId = theObject->GetIDs();
1472 rotationSweep(anElementsId,
1480 //=======================================================================
1481 //function : RotationSweepObjectMakeGroups
1483 //=======================================================================
1485 SMESH::ListOfGroups*
1486 SMESH_MeshEditor_i::RotationSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1487 const SMESH::AxisStruct& theAxis,
1488 CORBA::Double theAngleInRadians,
1489 CORBA::Long theNbOfSteps,
1490 CORBA::Double theTolerance)
1492 SMESH::long_array_var anElementsId = theObject->GetIDs();
1493 SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
1499 if ( !myPreviewMode ) {
1500 TPythonDump() << "axis = " << theAxis;
1501 TPythonDump aPythonDump;
1502 DumpGroupsList(aPythonDump,aGroups);
1503 aPythonDump<< this << ".RotationSweepObjectMakeGroups( "
1506 << theAngleInRadians << ", "
1507 << theNbOfSteps << ", "
1508 << theTolerance << " )";
1514 //=======================================================================
1515 //function : extrusionSweep
1517 //=======================================================================
1519 SMESH::ListOfGroups*
1520 SMESH_MeshEditor_i::extrusionSweep(const SMESH::long_array & theIDsOfElements,
1521 const SMESH::DirStruct & theStepVector,
1522 CORBA::Long theNbOfSteps,
1523 const bool theMakeGroups,
1524 const SMDSAbs_ElementType theElementType)
1532 TIDSortedElemSet elements;
1533 arrayToSet(theIDsOfElements, GetMeshDS(), elements, theElementType);
1535 const SMESH::PointStruct * P = &theStepVector.PS;
1536 gp_Vec stepVec( P->x, P->y, P->z );
1538 TElemOfElemListMap aHystory;
1539 ::SMESH_MeshEditor anEditor( myMesh );
1540 ::SMESH_MeshEditor::PGroupIDs groupIds =
1541 anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory, theMakeGroups);
1543 storeResult(anEditor);
1545 return theMakeGroups ? getGroups(groupIds.get()) : 0;
1547 } catch(Standard_Failure) {
1548 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1549 INFOS( "SMESH_MeshEditor_i::ExtrusionSweep fails - "<< aFail->GetMessageString() );
1554 //=======================================================================
1555 //function : ExtrusionSweep
1557 //=======================================================================
1559 void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElements,
1560 const SMESH::DirStruct & theStepVector,
1561 CORBA::Long theNbOfSteps)
1563 extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false );
1564 if ( !myPreviewMode ) {
1565 TPythonDump() << "stepVector = " << theStepVector;
1566 TPythonDump() << this << ".ExtrusionSweep( "
1567 << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )";
1572 //=======================================================================
1573 //function : ExtrusionSweepObject
1575 //=======================================================================
1577 void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObject,
1578 const SMESH::DirStruct & theStepVector,
1579 CORBA::Long theNbOfSteps)
1581 SMESH::long_array_var anElementsId = theObject->GetIDs();
1582 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false );
1583 if ( !myPreviewMode ) {
1584 TPythonDump() << "stepVector = " << theStepVector;
1585 TPythonDump() << this << ".ExtrusionSweepObject( "
1586 << theObject << ", stepVector, " << theNbOfSteps << " )";
1590 //=======================================================================
1591 //function : ExtrusionSweepObject1D
1593 //=======================================================================
1595 void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
1596 const SMESH::DirStruct & theStepVector,
1597 CORBA::Long theNbOfSteps)
1599 SMESH::long_array_var anElementsId = theObject->GetIDs();
1600 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Edge );
1601 if ( !myPreviewMode ) {
1602 TPythonDump() << "stepVector = " << theStepVector;
1603 TPythonDump() << this << ".ExtrusionSweepObject1D( "
1604 << theObject << ", stepVector, " << theNbOfSteps << " )";
1608 //=======================================================================
1609 //function : ExtrusionSweepObject2D
1611 //=======================================================================
1613 void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
1614 const SMESH::DirStruct & theStepVector,
1615 CORBA::Long theNbOfSteps)
1617 SMESH::long_array_var anElementsId = theObject->GetIDs();
1618 extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Face );
1619 if ( !myPreviewMode ) {
1620 TPythonDump() << "stepVector = " << theStepVector;
1621 TPythonDump() << this << ".ExtrusionSweepObject2D( "
1622 << theObject << ", stepVector, " << theNbOfSteps << " )";
1626 //=======================================================================
1627 //function : ExtrusionSweepMakeGroups
1629 //=======================================================================
1631 SMESH::ListOfGroups*
1632 SMESH_MeshEditor_i::ExtrusionSweepMakeGroups(const SMESH::long_array& theIDsOfElements,
1633 const SMESH::DirStruct& theStepVector,
1634 CORBA::Long theNbOfSteps)
1636 SMESH::ListOfGroups* aGroups = extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, true );
1638 if ( !myPreviewMode ) {
1639 TPythonDump() << "stepVector = " << theStepVector;
1640 TPythonDump aPythonDump;
1641 DumpGroupsList(aPythonDump,aGroups);
1642 aPythonDump << this << ".ExtrusionSweepMakeGroups( "
1643 << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )";
1647 //=======================================================================
1648 //function : ExtrusionSweepObjectMakeGroups
1650 //=======================================================================
1652 SMESH::ListOfGroups*
1653 SMESH_MeshEditor_i::ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1654 const SMESH::DirStruct& theStepVector,
1655 CORBA::Long theNbOfSteps)
1657 SMESH::long_array_var anElementsId = theObject->GetIDs();
1658 SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true );
1660 if ( !myPreviewMode ) {
1661 TPythonDump() << "stepVector = " << theStepVector;
1662 TPythonDump aPythonDump;
1663 DumpGroupsList(aPythonDump,aGroups);
1664 aPythonDump<< this << ".ExtrusionSweepObjectMakeGroups( "
1665 << theObject << ", stepVector, " << theNbOfSteps << " )";
1670 //=======================================================================
1671 //function : ExtrusionSweepObject1DMakeGroups
1673 //=======================================================================
1675 SMESH::ListOfGroups*
1676 SMESH_MeshEditor_i::ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1677 const SMESH::DirStruct& theStepVector,
1678 CORBA::Long theNbOfSteps)
1680 SMESH::long_array_var anElementsId = theObject->GetIDs();
1681 SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Edge );
1682 if ( !myPreviewMode ) {
1683 TPythonDump() << "stepVector = " << theStepVector;
1684 TPythonDump aPythonDump;
1685 DumpGroupsList(aPythonDump,aGroups);
1686 aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( "
1687 << theObject << ", stepVector, " << theNbOfSteps << " )";
1692 //=======================================================================
1693 //function : ExtrusionSweepObject2DMakeGroups
1695 //=======================================================================
1697 SMESH::ListOfGroups*
1698 SMESH_MeshEditor_i::ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
1699 const SMESH::DirStruct& theStepVector,
1700 CORBA::Long theNbOfSteps)
1702 SMESH::long_array_var anElementsId = theObject->GetIDs();
1703 SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Face );
1704 if ( !myPreviewMode ) {
1705 TPythonDump() << "stepVector = " << theStepVector;
1706 TPythonDump aPythonDump;
1707 DumpGroupsList(aPythonDump,aGroups);
1708 aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( "
1709 << theObject << ", stepVector, " << theNbOfSteps << " )";
1715 //=======================================================================
1716 //function : advancedExtrusion
1718 //=======================================================================
1720 SMESH::ListOfGroups*
1721 SMESH_MeshEditor_i::advancedExtrusion(const SMESH::long_array & theIDsOfElements,
1722 const SMESH::DirStruct & theStepVector,
1723 CORBA::Long theNbOfSteps,
1724 CORBA::Long theExtrFlags,
1725 CORBA::Double theSewTolerance,
1726 const bool theMakeGroups)
1730 TIDSortedElemSet elements;
1731 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
1733 const SMESH::PointStruct * P = &theStepVector.PS;
1734 gp_Vec stepVec( P->x, P->y, P->z );
1736 ::SMESH_MeshEditor anEditor( myMesh );
1737 TElemOfElemListMap aHystory;
1738 ::SMESH_MeshEditor::PGroupIDs groupIds =
1739 anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory,
1740 theMakeGroups, theExtrFlags, theSewTolerance);
1741 storeResult(anEditor);
1743 return theMakeGroups ? getGroups(groupIds.get()) : 0;
1746 //=======================================================================
1747 //function : AdvancedExtrusion
1749 //=======================================================================
1751 void SMESH_MeshEditor_i::AdvancedExtrusion(const SMESH::long_array & theIDsOfElements,
1752 const SMESH::DirStruct & theStepVector,
1753 CORBA::Long theNbOfSteps,
1754 CORBA::Long theExtrFlags,
1755 CORBA::Double theSewTolerance)
1757 if ( !myPreviewMode ) {
1758 TPythonDump() << "stepVector = " << theStepVector;
1759 TPythonDump() << this << ".AdvancedExtrusion("
1762 << theNbOfSteps << ","
1763 << theExtrFlags << ", "
1764 << theSewTolerance << " )";
1766 advancedExtrusion( theIDsOfElements,
1774 //=======================================================================
1775 //function : AdvancedExtrusionMakeGroups
1777 //=======================================================================
1779 SMESH::ListOfGroups*
1780 SMESH_MeshEditor_i::AdvancedExtrusionMakeGroups(const SMESH::long_array& theIDsOfElements,
1781 const SMESH::DirStruct& theStepVector,
1782 CORBA::Long theNbOfSteps,
1783 CORBA::Long theExtrFlags,
1784 CORBA::Double theSewTolerance)
1786 SMESH::ListOfGroups * aGroups = advancedExtrusion( theIDsOfElements,
1793 if ( !myPreviewMode ) {
1794 TPythonDump() << "stepVector = " << theStepVector;
1795 TPythonDump aPythonDump;
1796 DumpGroupsList(aPythonDump,aGroups);
1797 aPythonDump << this << ".AdvancedExtrusionMakeGroups("
1800 << theNbOfSteps << ","
1801 << theExtrFlags << ", "
1802 << theSewTolerance << " )";
1808 //================================================================================
1810 * \brief Convert extrusion error to IDL enum
1812 //================================================================================
1814 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
1816 static SMESH::SMESH_MeshEditor::Extrusion_Error convExtrError( const::SMESH_MeshEditor::Extrusion_Error e )
1820 RETCASE( EXTR_NO_ELEMENTS );
1821 RETCASE( EXTR_PATH_NOT_EDGE );
1822 RETCASE( EXTR_BAD_PATH_SHAPE );
1823 RETCASE( EXTR_BAD_STARTING_NODE );
1824 RETCASE( EXTR_BAD_ANGLES_NUMBER );
1825 RETCASE( EXTR_CANT_GET_TANGENT );
1827 return SMESH::SMESH_MeshEditor::EXTR_OK;
1831 //=======================================================================
1832 //function : extrusionAlongPath
1834 //=======================================================================
1836 SMESH::ListOfGroups*
1837 SMESH_MeshEditor_i::extrusionAlongPath(const SMESH::long_array & theIDsOfElements,
1838 SMESH::SMESH_Mesh_ptr thePathMesh,
1839 GEOM::GEOM_Object_ptr thePathShape,
1840 CORBA::Long theNodeStart,
1841 CORBA::Boolean theHasAngles,
1842 const SMESH::double_array & theAngles,
1843 CORBA::Boolean theHasRefPoint,
1844 const SMESH::PointStruct & theRefPoint,
1845 const bool theMakeGroups,
1846 SMESH::SMESH_MeshEditor::Extrusion_Error & theError)
1850 if ( thePathMesh->_is_nil() || thePathShape->_is_nil() ) {
1851 theError = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
1854 SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( thePathMesh );
1856 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
1857 SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
1859 if ( !aSubMesh || !aSubMesh->GetSubMeshDS()) {
1860 theError = SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
1864 SMDS_MeshNode* nodeStart = (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(theNodeStart);
1866 theError = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
1870 TIDSortedElemSet elements;
1871 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
1873 list<double> angles;
1874 for (int i = 0; i < theAngles.length(); i++) {
1875 angles.push_back( theAngles[i] );
1878 gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z );
1880 int nbOldGroups = myMesh->NbGroup();
1882 ::SMESH_MeshEditor anEditor( myMesh );
1883 ::SMESH_MeshEditor::Extrusion_Error error =
1884 anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart,
1885 theHasAngles, angles,
1886 theHasRefPoint, refPnt, theMakeGroups );
1887 storeResult(anEditor);
1888 theError = convExtrError( error );
1890 if ( theMakeGroups ) {
1891 list<int> groupIDs = myMesh->GetGroupIds();
1892 list<int>::iterator newBegin = groupIDs.begin();
1893 std::advance( newBegin, nbOldGroups ); // skip old groups
1894 groupIDs.erase( groupIDs.begin(), newBegin );
1895 return getGroups( & groupIDs );
1900 //=======================================================================
1901 //function : ExtrusionAlongPath
1903 //=======================================================================
1905 SMESH::SMESH_MeshEditor::Extrusion_Error
1906 SMESH_MeshEditor_i::ExtrusionAlongPath(const SMESH::long_array & theIDsOfElements,
1907 SMESH::SMESH_Mesh_ptr thePathMesh,
1908 GEOM::GEOM_Object_ptr thePathShape,
1909 CORBA::Long theNodeStart,
1910 CORBA::Boolean theHasAngles,
1911 const SMESH::double_array & theAngles,
1912 CORBA::Boolean theHasRefPoint,
1913 const SMESH::PointStruct & theRefPoint)
1915 if ( !myPreviewMode ) {
1916 TPythonDump() << "rotAngles = " << theAngles;
1918 if ( theHasRefPoint )
1919 TPythonDump() << "refPoint = SMESH.PointStruct( "
1920 << theRefPoint.x << ", "
1921 << theRefPoint.y << ", "
1922 << theRefPoint.z << " )";
1924 TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )";
1926 TPythonDump() << "error = " << this << ".ExtrusionAlongPath( "
1927 << theIDsOfElements << ", "
1928 << thePathMesh << ", "
1929 << thePathShape << ", "
1930 << theNodeStart << ", "
1931 << theHasAngles << ", "
1932 << "rotAngles" << ", "
1933 << theHasRefPoint << ", refPoint )";
1935 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
1936 extrusionAlongPath( theIDsOfElements,
1949 //=======================================================================
1950 //function : ExtrusionAlongPathObject
1952 //=======================================================================
1954 SMESH::SMESH_MeshEditor::Extrusion_Error
1955 SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject,
1956 SMESH::SMESH_Mesh_ptr thePathMesh,
1957 GEOM::GEOM_Object_ptr thePathShape,
1958 CORBA::Long theNodeStart,
1959 CORBA::Boolean theHasAngles,
1960 const SMESH::double_array & theAngles,
1961 CORBA::Boolean theHasRefPoint,
1962 const SMESH::PointStruct & theRefPoint)
1964 if ( !myPreviewMode ) {
1965 TPythonDump() << "rotAngles = " << theAngles;
1967 if ( theHasRefPoint )
1968 TPythonDump() << "refPoint = SMESH.PointStruct( "
1969 << theRefPoint.x << ", "
1970 << theRefPoint.y << ", "
1971 << theRefPoint.z << " )";
1973 TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )";
1975 TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject( "
1976 << theObject << ", "
1977 << thePathMesh << ", "
1978 << thePathShape << ", "
1979 << theNodeStart << ", "
1980 << theHasAngles << ", "
1981 << "rotAngles" << ", "
1982 << theHasRefPoint << ", refPoint )";
1984 SMESH::SMESH_MeshEditor::Extrusion_Error anError;
1985 SMESH::long_array_var anElementsId = theObject->GetIDs();
1986 extrusionAlongPath( anElementsId,
2000 //=======================================================================
2001 //function : ExtrusionAlongPathMakeGroups
2003 //=======================================================================
2005 SMESH::ListOfGroups*
2006 SMESH_MeshEditor_i::ExtrusionAlongPathMakeGroups(const SMESH::long_array& theIDsOfElements,
2007 SMESH::SMESH_Mesh_ptr thePathMesh,
2008 GEOM::GEOM_Object_ptr thePathShape,
2009 CORBA::Long theNodeStart,
2010 CORBA::Boolean theHasAngles,
2011 const SMESH::double_array& theAngles,
2012 CORBA::Boolean theHasRefPoint,
2013 const SMESH::PointStruct& theRefPoint,
2014 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2016 SMESH::ListOfGroups * aGroups = extrusionAlongPath( theIDsOfElements,
2026 if ( !myPreviewMode ) {
2027 TPythonDump() << "rotAngles = " << theAngles;
2029 if ( theHasRefPoint )
2030 TPythonDump() << "refPoint = SMESH.PointStruct( "
2031 << theRefPoint.x << ", "
2032 << theRefPoint.y << ", "
2033 << theRefPoint.z << " )";
2035 TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )";
2037 bool isDumpGroups = aGroups && aGroups->length() > 0;
2038 TPythonDump aPythonDump;
2040 aPythonDump << "("<<aGroups;
2043 aPythonDump << ", error)";
2045 aPythonDump <<"error";
2047 aPythonDump<<" = "<< this << ".ExtrusionAlongPathMakeGroups( "
2048 << theIDsOfElements << ", "
2049 << thePathMesh << ", "
2050 << thePathShape << ", "
2051 << theNodeStart << ", "
2052 << theHasAngles << ", "
2053 << "rotAngles" << ", "
2054 << theHasRefPoint << ", refPoint )";
2059 //=======================================================================
2060 //function : ExtrusionAlongPathObjectMakeGroups
2062 //=======================================================================
2064 SMESH::ListOfGroups* SMESH_MeshEditor_i::
2065 ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2066 SMESH::SMESH_Mesh_ptr thePathMesh,
2067 GEOM::GEOM_Object_ptr thePathShape,
2068 CORBA::Long theNodeStart,
2069 CORBA::Boolean theHasAngles,
2070 const SMESH::double_array& theAngles,
2071 CORBA::Boolean theHasRefPoint,
2072 const SMESH::PointStruct& theRefPoint,
2073 SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
2075 SMESH::long_array_var anElementsId = theObject->GetIDs();
2076 SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
2087 if ( !myPreviewMode ) {
2088 TPythonDump() << "rotAngles = " << theAngles;
2090 if ( theHasRefPoint )
2091 TPythonDump() << "refPoint = SMESH.PointStruct( "
2092 << theRefPoint.x << ", "
2093 << theRefPoint.y << ", "
2094 << theRefPoint.z << " )";
2096 TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )";
2098 bool isDumpGroups = aGroups && aGroups->length() > 0;
2099 TPythonDump aPythonDump;
2101 aPythonDump << "("<<aGroups;
2104 aPythonDump << ", error)";
2106 aPythonDump <<"error";
2108 aPythonDump << " = " << this << ".ExtrusionAlongPathObjectMakeGroups( "
2109 << theObject << ", "
2110 << thePathMesh << ", "
2111 << thePathShape << ", "
2112 << theNodeStart << ", "
2113 << theHasAngles << ", "
2114 << "rotAngles" << ", "
2115 << theHasRefPoint << ", refPoint )";
2120 //================================================================================
2122 * \brief Compute rotation angles for ExtrusionAlongPath as linear variation
2123 * of given angles along path steps
2124 * \param PathMesh mesh containing a 1D sub-mesh on the edge, along
2125 * which proceeds the extrusion
2126 * \param PathShape is shape(edge); as the mesh can be complex, the edge
2127 * is used to define the sub-mesh for the path
2129 //================================================================================
2131 SMESH::double_array*
2132 SMESH_MeshEditor_i::LinearAnglesVariation(SMESH::SMESH_Mesh_ptr thePathMesh,
2133 GEOM::GEOM_Object_ptr thePathShape,
2134 const SMESH::double_array & theAngles)
2136 SMESH::double_array_var aResult = new SMESH::double_array();
2137 int nbAngles = theAngles.length();
2138 if ( nbAngles > 0 && !thePathMesh->_is_nil() && !thePathShape->_is_nil() )
2140 SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( thePathMesh );
2141 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
2142 SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
2143 if ( !aSubMesh || !aSubMesh->GetSubMeshDS())
2144 return aResult._retn();
2145 int nbSteps = aSubMesh->GetSubMeshDS()->NbElements();
2146 if ( nbSteps == nbAngles )
2148 aResult.inout() = theAngles;
2152 aResult->length( nbSteps );
2153 double rAn2St = double( nbAngles ) / double( nbSteps );
2154 double angPrev = 0, angle;
2155 for ( int iSt = 0; iSt < nbSteps; ++iSt )
2157 double angCur = rAn2St * ( iSt+1 );
2158 double angCurFloor = floor( angCur );
2159 double angPrevFloor = floor( angPrev );
2160 if ( angPrevFloor == angCurFloor )
2161 angle = rAn2St * theAngles[ int( angCurFloor ) ];
2164 int iP = int( angPrevFloor );
2165 double angPrevCeil = ceil(angPrev);
2166 angle = ( angPrevCeil - angPrev ) * theAngles[ iP ];
2168 int iC = int( angCurFloor );
2169 if ( iC < nbAngles )
2170 angle += ( angCur - angCurFloor ) * theAngles[ iC ];
2172 iP = int( angPrevCeil );
2174 angle += theAngles[ iC ];
2176 aResult[ iSt ] = angle;
2181 // Update Python script
2182 TPythonDump() << "rotAngles = " << theAngles;
2183 TPythonDump() << "rotAngles = " << this << ".LinearAnglesVariation( "
2184 << thePathMesh << ", "
2185 << thePathShape << ", "
2188 return aResult._retn();
2192 //=======================================================================
2195 //=======================================================================
2197 SMESH::ListOfGroups*
2198 SMESH_MeshEditor_i::mirror(const SMESH::long_array & theIDsOfElements,
2199 const SMESH::AxisStruct & theAxis,
2200 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
2201 CORBA::Boolean theCopy,
2202 const bool theMakeGroups,
2203 ::SMESH_Mesh* theTargetMesh)
2207 TIDSortedElemSet elements;
2208 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
2210 gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
2211 gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
2214 switch ( theMirrorType ) {
2215 case SMESH::SMESH_MeshEditor::POINT:
2216 aTrsf.SetMirror( P );
2218 case SMESH::SMESH_MeshEditor::AXIS:
2219 aTrsf.SetMirror( gp_Ax1( P, V ));
2222 aTrsf.SetMirror( gp_Ax2( P, V ));
2225 ::SMESH_MeshEditor anEditor( myMesh );
2226 ::SMESH_MeshEditor::PGroupIDs groupIds =
2227 anEditor.Transform (elements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
2230 storeResult(anEditor);
2232 return theMakeGroups ? getGroups(groupIds.get()) : 0;
2235 //=======================================================================
2238 //=======================================================================
2240 void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElements,
2241 const SMESH::AxisStruct & theAxis,
2242 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
2243 CORBA::Boolean theCopy)
2245 if ( !myPreviewMode ) {
2246 TPythonDump() << this << ".Mirror( "
2247 << theIDsOfElements << ", "
2249 << mirrorTypeName(theMirrorType) << ", "
2252 mirror(theIDsOfElements, theAxis, theMirrorType, theCopy, false);
2256 //=======================================================================
2257 //function : MirrorObject
2259 //=======================================================================
2261 void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObject,
2262 const SMESH::AxisStruct & theAxis,
2263 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
2264 CORBA::Boolean theCopy)
2266 if ( !myPreviewMode ) {
2267 TPythonDump() << this << ".MirrorObject( "
2268 << theObject << ", "
2270 << mirrorTypeName(theMirrorType) << ", "
2273 SMESH::long_array_var anElementsId = theObject->GetIDs();
2274 mirror(anElementsId, theAxis, theMirrorType, theCopy, false);
2277 //=======================================================================
2278 //function : MirrorMakeGroups
2280 //=======================================================================
2282 SMESH::ListOfGroups*
2283 SMESH_MeshEditor_i::MirrorMakeGroups(const SMESH::long_array& theIDsOfElements,
2284 const SMESH::AxisStruct& theMirror,
2285 SMESH::SMESH_MeshEditor::MirrorType theMirrorType)
2287 SMESH::ListOfGroups * aGroups = mirror(theIDsOfElements, theMirror, theMirrorType, true, true);
2288 if ( !myPreviewMode ) {
2289 TPythonDump()<<"axis = "<<theMirror;
2290 TPythonDump aPythonDump;
2291 DumpGroupsList(aPythonDump,aGroups);
2292 aPythonDump << this << ".MirrorMakeGroups( "
2293 << theIDsOfElements << ", "
2295 << mirrorTypeName(theMirrorType) << " )";
2300 //=======================================================================
2301 //function : MirrorObjectMakeGroups
2303 //=======================================================================
2305 SMESH::ListOfGroups*
2306 SMESH_MeshEditor_i::MirrorObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2307 const SMESH::AxisStruct& theMirror,
2308 SMESH::SMESH_MeshEditor::MirrorType theMirrorType)
2310 SMESH::long_array_var anElementsId = theObject->GetIDs();
2311 SMESH::ListOfGroups * aGroups = mirror(anElementsId, theMirror, theMirrorType, true, true);
2312 if ( !myPreviewMode ) {
2313 TPythonDump()<<"axis = "<<theMirror;
2314 TPythonDump aPythonDump;
2315 DumpGroupsList(aPythonDump,aGroups);
2316 aPythonDump << this << ".MirrorObjectMakeGroups( "
2317 << theObject << ", "
2319 << mirrorTypeName(theMirrorType) << " )";
2324 //=======================================================================
2325 //function : MirrorMakeMesh
2327 //=======================================================================
2329 SMESH::SMESH_Mesh_ptr
2330 SMESH_MeshEditor_i::MirrorMakeMesh(const SMESH::long_array& theIDsOfElements,
2331 const SMESH::AxisStruct& theMirror,
2332 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
2333 CORBA::Boolean theCopyGroups,
2334 const char* theMeshName)
2336 SMESH_Mesh_i* mesh_i;
2337 SMESH::SMESH_Mesh_var mesh;
2338 { // open new scope to dump "MakeMesh" command
2339 // and then "GetGroups" using SMESH_Mesh::GetGroups()
2341 TPythonDump pydump; // to prevent dump at mesh creation
2343 mesh = makeMesh( theMeshName );
2344 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
2346 mirror(theIDsOfElements, theMirror, theMirrorType,
2347 false, theCopyGroups, & mesh_i->GetImpl());
2348 mesh_i->CreateGroupServants();
2351 if ( !myPreviewMode ) {
2352 pydump << mesh << " = " << this << ".MirrorMakeMesh( "
2353 << theIDsOfElements << ", "
2354 << theMirror << ", "
2355 << mirrorTypeName(theMirrorType) << ", "
2356 << theCopyGroups << ", '"
2357 << theMeshName << "' )";
2362 if(!myPreviewMode && mesh_i)
2363 mesh_i->GetGroups();
2365 return mesh._retn();
2368 //=======================================================================
2369 //function : MirrorObjectMakeMesh
2371 //=======================================================================
2373 SMESH::SMESH_Mesh_ptr
2374 SMESH_MeshEditor_i::MirrorObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
2375 const SMESH::AxisStruct& theMirror,
2376 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
2377 CORBA::Boolean theCopyGroups,
2378 const char* theMeshName)
2380 SMESH_Mesh_i* mesh_i;
2381 SMESH::SMESH_Mesh_var mesh;
2382 { // open new scope to dump "MakeMesh" command
2383 // and then "GetGroups" using SMESH_Mesh::GetGroups()
2385 TPythonDump pydump; // to prevent dump at mesh creation
2387 mesh = makeMesh( theMeshName );
2388 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
2390 SMESH::long_array_var anElementsId = theObject->GetIDs();
2391 mirror(anElementsId, theMirror, theMirrorType,
2392 false, theCopyGroups, & mesh_i->GetImpl());
2393 mesh_i->CreateGroupServants();
2396 if ( !myPreviewMode ) {
2397 pydump << mesh << " = " << this << ".MirrorObjectMakeMesh( "
2398 << theObject << ", "
2399 << theMirror << ", "
2400 << mirrorTypeName(theMirrorType) << ", "
2401 << theCopyGroups << ", '"
2402 << theMeshName << "' )";
2407 if(!myPreviewMode && mesh_i)
2408 mesh_i->GetGroups();
2410 return mesh._retn();
2413 //=======================================================================
2414 //function : translate
2416 //=======================================================================
2418 SMESH::ListOfGroups*
2419 SMESH_MeshEditor_i::translate(const SMESH::long_array & theIDsOfElements,
2420 const SMESH::DirStruct & theVector,
2421 CORBA::Boolean theCopy,
2422 const bool theMakeGroups,
2423 ::SMESH_Mesh* theTargetMesh)
2427 TIDSortedElemSet elements;
2428 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
2431 const SMESH::PointStruct * P = &theVector.PS;
2432 aTrsf.SetTranslation( gp_Vec( P->x, P->y, P->z ));
2434 ::SMESH_MeshEditor anEditor( myMesh );
2435 ::SMESH_MeshEditor::PGroupIDs groupIds =
2436 anEditor.Transform (elements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
2439 storeResult(anEditor);
2441 return theMakeGroups ? getGroups(groupIds.get()) : 0;
2444 //=======================================================================
2445 //function : Translate
2447 //=======================================================================
2449 void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements,
2450 const SMESH::DirStruct & theVector,
2451 CORBA::Boolean theCopy)
2453 if ( !myPreviewMode ) {
2454 TPythonDump() << "vector = " << theVector;
2455 TPythonDump() << this << ".Translate( "
2460 translate(theIDsOfElements,
2466 //=======================================================================
2467 //function : TranslateObject
2469 //=======================================================================
2471 void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject,
2472 const SMESH::DirStruct & theVector,
2473 CORBA::Boolean theCopy)
2475 if ( !myPreviewMode ) {
2476 TPythonDump() << this << ".TranslateObject( "
2481 SMESH::long_array_var anElementsId = theObject->GetIDs();
2482 translate(anElementsId,
2488 //=======================================================================
2489 //function : TranslateMakeGroups
2491 //=======================================================================
2493 SMESH::ListOfGroups*
2494 SMESH_MeshEditor_i::TranslateMakeGroups(const SMESH::long_array& theIDsOfElements,
2495 const SMESH::DirStruct& theVector)
2497 SMESH::ListOfGroups * aGroups = translate(theIDsOfElements,theVector,true,true);
2498 if ( !myPreviewMode ) {
2499 TPythonDump() << "vector = " << theVector;
2500 TPythonDump aPythonDump;
2501 DumpGroupsList(aPythonDump,aGroups);
2502 aPythonDump << this << ".TranslateMakeGroups( "
2509 //=======================================================================
2510 //function : TranslateObjectMakeGroups
2512 //=======================================================================
2514 SMESH::ListOfGroups*
2515 SMESH_MeshEditor_i::TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2516 const SMESH::DirStruct& theVector)
2518 SMESH::long_array_var anElementsId = theObject->GetIDs();
2519 SMESH::ListOfGroups * aGroups = translate(anElementsId, theVector, true, true);
2521 if ( !myPreviewMode ) {
2523 TPythonDump() << "vector = " << theVector;
2524 TPythonDump aPythonDump;
2525 DumpGroupsList(aPythonDump,aGroups);
2526 aPythonDump << this << ".TranslateObjectMakeGroups( "
2533 //=======================================================================
2534 //function : TranslateMakeMesh
2536 //=======================================================================
2538 SMESH::SMESH_Mesh_ptr
2539 SMESH_MeshEditor_i::TranslateMakeMesh(const SMESH::long_array& theIDsOfElements,
2540 const SMESH::DirStruct& theVector,
2541 CORBA::Boolean theCopyGroups,
2542 const char* theMeshName)
2544 SMESH_Mesh_i* mesh_i;
2545 SMESH::SMESH_Mesh_var mesh;
2547 { // open new scope to dump "MakeMesh" command
2548 // and then "GetGroups" using SMESH_Mesh::GetGroups()
2550 TPythonDump pydump; // to prevent dump at mesh creation
2552 mesh = makeMesh( theMeshName );
2553 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
2556 translate(theIDsOfElements, theVector,
2557 false, theCopyGroups, & mesh_i->GetImpl());
2558 mesh_i->CreateGroupServants();
2561 if ( !myPreviewMode ) {
2562 pydump << mesh << " = " << this << ".TranslateMakeMesh( "
2563 << theIDsOfElements << ", "
2564 << theVector << ", "
2565 << theCopyGroups << ", '"
2566 << theMeshName << "' )";
2571 if(!myPreviewMode && mesh_i)
2572 mesh_i->GetGroups();
2574 return mesh._retn();
2577 //=======================================================================
2578 //function : TranslateObjectMakeMesh
2580 //=======================================================================
2582 SMESH::SMESH_Mesh_ptr
2583 SMESH_MeshEditor_i::TranslateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
2584 const SMESH::DirStruct& theVector,
2585 CORBA::Boolean theCopyGroups,
2586 const char* theMeshName)
2588 SMESH_Mesh_i* mesh_i;
2589 SMESH::SMESH_Mesh_var mesh;
2590 { // open new scope to dump "MakeMesh" command
2591 // and then "GetGroups" using SMESH_Mesh::GetGroups()
2593 TPythonDump pydump; // to prevent dump at mesh creation
2594 mesh = makeMesh( theMeshName );
2595 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
2598 SMESH::long_array_var anElementsId = theObject->GetIDs();
2599 translate(anElementsId, theVector,
2600 false, theCopyGroups, & mesh_i->GetImpl());
2601 mesh_i->CreateGroupServants();
2603 if ( !myPreviewMode ) {
2604 pydump << mesh << " = " << this << ".TranslateObjectMakeMesh( "
2605 << theObject << ", "
2606 << theVector << ", "
2607 << theCopyGroups << ", '"
2608 << theMeshName << "' )";
2613 if(!myPreviewMode && mesh_i)
2614 mesh_i->GetGroups();
2616 return mesh._retn();
2619 //=======================================================================
2622 //=======================================================================
2624 SMESH::ListOfGroups*
2625 SMESH_MeshEditor_i::rotate(const SMESH::long_array & theIDsOfElements,
2626 const SMESH::AxisStruct & theAxis,
2627 CORBA::Double theAngle,
2628 CORBA::Boolean theCopy,
2629 const bool theMakeGroups,
2630 ::SMESH_Mesh* theTargetMesh)
2634 TIDSortedElemSet elements;
2635 arrayToSet(theIDsOfElements, GetMeshDS(), elements);
2637 gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
2638 gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
2641 aTrsf.SetRotation( gp_Ax1( P, V ), theAngle);
2643 ::SMESH_MeshEditor anEditor( myMesh );
2644 ::SMESH_MeshEditor::PGroupIDs groupIds =
2645 anEditor.Transform (elements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
2648 storeResult(anEditor);
2650 return theMakeGroups ? getGroups(groupIds.get()) : 0;
2653 //=======================================================================
2656 //=======================================================================
2658 void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements,
2659 const SMESH::AxisStruct & theAxis,
2660 CORBA::Double theAngle,
2661 CORBA::Boolean theCopy)
2663 if ( !myPreviewMode ) {
2664 TPythonDump() << "axis = " << theAxis;
2665 TPythonDump() << this << ".Rotate( "
2671 rotate(theIDsOfElements,
2678 //=======================================================================
2679 //function : RotateObject
2681 //=======================================================================
2683 void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject,
2684 const SMESH::AxisStruct & theAxis,
2685 CORBA::Double theAngle,
2686 CORBA::Boolean theCopy)
2688 if ( !myPreviewMode ) {
2689 TPythonDump() << "axis = " << theAxis;
2690 TPythonDump() << this << ".RotateObject( "
2696 SMESH::long_array_var anElementsId = theObject->GetIDs();
2697 rotate(anElementsId,
2704 //=======================================================================
2705 //function : RotateMakeGroups
2707 //=======================================================================
2709 SMESH::ListOfGroups*
2710 SMESH_MeshEditor_i::RotateMakeGroups(const SMESH::long_array& theIDsOfElements,
2711 const SMESH::AxisStruct& theAxis,
2712 CORBA::Double theAngle)
2714 SMESH::ListOfGroups * aGroups = rotate(theIDsOfElements,theAxis,theAngle,true,true);
2715 if ( !myPreviewMode ) {
2716 TPythonDump() << "axis = " << theAxis;
2717 TPythonDump aPythonDump;
2718 DumpGroupsList(aPythonDump,aGroups);
2719 aPythonDump << this << ".RotateMakeGroups( "
2722 << theAngle << " )";
2727 //=======================================================================
2728 //function : RotateObjectMakeGroups
2730 //=======================================================================
2732 SMESH::ListOfGroups*
2733 SMESH_MeshEditor_i::RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
2734 const SMESH::AxisStruct& theAxis,
2735 CORBA::Double theAngle)
2737 SMESH::long_array_var anElementsId = theObject->GetIDs();
2738 SMESH::ListOfGroups * aGroups = rotate(anElementsId,theAxis,theAngle,true,true);
2740 if ( !myPreviewMode ) {
2741 TPythonDump() << "axis = " << theAxis;
2742 TPythonDump aPythonDump;
2743 DumpGroupsList(aPythonDump,aGroups);
2744 aPythonDump << this << ".RotateObjectMakeGroups( "
2747 << theAngle << " )";
2752 //=======================================================================
2753 //function : RotateMakeMesh
2755 //=======================================================================
2757 SMESH::SMESH_Mesh_ptr
2758 SMESH_MeshEditor_i::RotateMakeMesh(const SMESH::long_array& theIDsOfElements,
2759 const SMESH::AxisStruct& theAxis,
2760 CORBA::Double theAngleInRadians,
2761 CORBA::Boolean theCopyGroups,
2762 const char* theMeshName)
2764 SMESH::SMESH_Mesh_var mesh;
2765 SMESH_Mesh_i* mesh_i;
2767 { // open new scope to dump "MakeMesh" command
2768 // and then "GetGroups" using SMESH_Mesh::GetGroups()
2770 TPythonDump pydump; // to prevent dump at mesh creation
2772 mesh = makeMesh( theMeshName );
2773 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
2776 rotate(theIDsOfElements, theAxis, theAngleInRadians,
2777 false, theCopyGroups, & mesh_i->GetImpl());
2778 mesh_i->CreateGroupServants();
2780 if ( !myPreviewMode ) {
2781 pydump << mesh << " = " << this << ".RotateMakeMesh( "
2782 << theIDsOfElements << ", "
2784 << theAngleInRadians << ", "
2785 << theCopyGroups << ", '"
2786 << theMeshName << "' )";
2791 if(!myPreviewMode && mesh_i)
2792 mesh_i->GetGroups();
2794 return mesh._retn();
2797 //=======================================================================
2798 //function : RotateObjectMakeMesh
2800 //=======================================================================
2802 SMESH::SMESH_Mesh_ptr
2803 SMESH_MeshEditor_i::RotateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
2804 const SMESH::AxisStruct& theAxis,
2805 CORBA::Double theAngleInRadians,
2806 CORBA::Boolean theCopyGroups,
2807 const char* theMeshName)
2809 SMESH::SMESH_Mesh_var mesh;
2810 SMESH_Mesh_i* mesh_i;
2812 {// open new scope to dump "MakeMesh" command
2813 // and then "GetGroups" using SMESH_Mesh::GetGroups()
2815 TPythonDump pydump; // to prevent dump at mesh creation
2816 mesh = makeMesh( theMeshName );
2817 mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
2820 SMESH::long_array_var anElementsId = theObject->GetIDs();
2821 rotate(anElementsId, theAxis, theAngleInRadians,
2822 false, theCopyGroups, & mesh_i->GetImpl());
2823 mesh_i->CreateGroupServants();
2825 if ( !myPreviewMode ) {
2826 pydump << mesh << " = " << this << ".RotateObjectMakeMesh( "
2827 << theObject << ", "
2829 << theAngleInRadians << ", "
2830 << theCopyGroups << ", '"
2831 << theMeshName << "' )";
2836 if(!myPreviewMode && mesh_i)
2837 mesh_i->GetGroups();
2839 return mesh._retn();
2842 //=======================================================================
2843 //function : FindCoincidentNodes
2845 //=======================================================================
2847 void SMESH_MeshEditor_i::FindCoincidentNodes (CORBA::Double Tolerance,
2848 SMESH::array_of_long_array_out GroupsOfNodes)
2852 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
2853 ::SMESH_MeshEditor anEditor( myMesh );
2854 set<const SMDS_MeshNode*> nodes; // no input nodes
2855 anEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
2857 GroupsOfNodes = new SMESH::array_of_long_array;
2858 GroupsOfNodes->length( aListOfListOfNodes.size() );
2859 ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
2860 for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ ) {
2861 list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
2862 list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
2863 SMESH::long_array& aGroup = (*GroupsOfNodes)[ i ];
2864 aGroup.length( aListOfNodes.size() );
2865 for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
2866 aGroup[ j ] = (*lIt)->GetID();
2868 TPythonDump() << "coincident_nodes = " << this << ".FindCoincidentNodes( "
2869 << Tolerance << " )";
2872 //=======================================================================
2873 //function : FindCoincidentNodesOnPart
2875 //=======================================================================
2876 void SMESH_MeshEditor_i::FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr theObject,
2877 CORBA::Double Tolerance,
2878 SMESH::array_of_long_array_out GroupsOfNodes)
2881 SMESH::long_array_var aElementsId = theObject->GetIDs();
2883 SMESHDS_Mesh* aMesh = GetMeshDS();
2884 set<const SMDS_MeshNode*> nodes;
2886 if ( !CORBA::is_nil(SMESH::SMESH_GroupBase::_narrow(theObject)) &&
2887 SMESH::SMESH_GroupBase::_narrow(theObject)->GetType() == SMESH::NODE) {
2888 for(int i = 0; i < aElementsId->length(); i++) {
2889 CORBA::Long ind = aElementsId[i];
2890 const SMDS_MeshNode * elem = aMesh->FindNode(ind);
2896 for(int i = 0; i < aElementsId->length(); i++) {
2897 CORBA::Long ind = aElementsId[i];
2898 const SMDS_MeshElement * elem = aMesh->FindElement(ind);
2900 SMDS_ElemIteratorPtr nIt = elem->nodesIterator();
2901 while ( nIt->more() )
2902 nodes.insert( nodes.end(),static_cast<const SMDS_MeshNode*>(nIt->next()));
2908 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
2909 ::SMESH_MeshEditor anEditor( myMesh );
2911 anEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
2913 GroupsOfNodes = new SMESH::array_of_long_array;
2914 GroupsOfNodes->length( aListOfListOfNodes.size() );
2915 ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
2916 for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ ) {
2917 list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
2918 list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
2919 SMESH::long_array& aGroup = (*GroupsOfNodes)[ i ];
2920 aGroup.length( aListOfNodes.size() );
2921 for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
2922 aGroup[ j ] = (*lIt)->GetID();
2924 TPythonDump() << "coincident_nodes_on_part = " << this << ".FindCoincidentNodesOnPart( "
2926 << Tolerance << " )";
2929 //=======================================================================
2930 //function : MergeNodes
2932 //=======================================================================
2934 void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes)
2938 SMESHDS_Mesh* aMesh = GetMeshDS();
2940 TPythonDump aTPythonDump;
2941 aTPythonDump << this << ".MergeNodes([";
2942 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
2943 for (int i = 0; i < GroupsOfNodes.length(); i++)
2945 const SMESH::long_array& aNodeGroup = GroupsOfNodes[ i ];
2946 aListOfListOfNodes.push_back( list< const SMDS_MeshNode* >() );
2947 list< const SMDS_MeshNode* >& aListOfNodes = aListOfListOfNodes.back();
2948 for ( int j = 0; j < aNodeGroup.length(); j++ )
2950 CORBA::Long index = aNodeGroup[ j ];
2951 const SMDS_MeshNode * node = aMesh->FindNode(index);
2953 aListOfNodes.push_back( node );
2955 if ( aListOfNodes.size() < 2 )
2956 aListOfListOfNodes.pop_back();
2958 if ( i > 0 ) aTPythonDump << ", ";
2959 aTPythonDump << aNodeGroup;
2961 ::SMESH_MeshEditor anEditor( myMesh );
2962 anEditor.MergeNodes( aListOfListOfNodes );
2964 aTPythonDump << "])";
2967 //=======================================================================
2968 //function : FindEqualElements
2970 //=======================================================================
2971 void SMESH_MeshEditor_i::FindEqualElements(SMESH::SMESH_IDSource_ptr theObject,
2972 SMESH::array_of_long_array_out GroupsOfElementsID)
2975 if ( !(!CORBA::is_nil(SMESH::SMESH_GroupBase::_narrow(theObject)) &&
2976 SMESH::SMESH_GroupBase::_narrow(theObject)->GetType() == SMESH::NODE) ) {
2977 typedef list<int> TListOfIDs;
2978 set<const SMDS_MeshElement*> elems;
2979 SMESH::long_array_var aElementsId = theObject->GetIDs();
2980 SMESHDS_Mesh* aMesh = GetMeshDS();
2982 for(int i = 0; i < aElementsId->length(); i++) {
2983 CORBA::Long anID = aElementsId[i];
2984 const SMDS_MeshElement * elem = aMesh->FindElement(anID);
2990 ::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
2991 ::SMESH_MeshEditor anEditor( myMesh );
2992 anEditor.FindEqualElements( elems, aListOfListOfElementsID );
2994 GroupsOfElementsID = new SMESH::array_of_long_array;
2995 GroupsOfElementsID->length( aListOfListOfElementsID.size() );
2997 ::SMESH_MeshEditor::TListOfListOfElementsID::iterator arraysIt = aListOfListOfElementsID.begin();
2998 for (CORBA::Long j = 0; arraysIt != aListOfListOfElementsID.end(); ++arraysIt, ++j) {
2999 SMESH::long_array& aGroup = (*GroupsOfElementsID)[ j ];
3000 TListOfIDs& listOfIDs = *arraysIt;
3001 aGroup.length( listOfIDs.size() );
3002 TListOfIDs::iterator idIt = listOfIDs.begin();
3003 for (int k = 0; idIt != listOfIDs.end(); ++idIt, ++k ) {
3004 aGroup[ k ] = *idIt;
3008 TPythonDump() << "equal_elements = " << this << ".FindEqualElements( "
3013 //=======================================================================
3014 //function : MergeElements
3016 //=======================================================================
3018 void SMESH_MeshEditor_i::MergeElements(const SMESH::array_of_long_array& GroupsOfElementsID)
3022 TPythonDump aTPythonDump;
3023 aTPythonDump << this << ".MergeElements( [";
3025 ::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
3027 for (int i = 0; i < GroupsOfElementsID.length(); i++) {
3028 const SMESH::long_array& anElemsIDGroup = GroupsOfElementsID[ i ];
3029 aListOfListOfElementsID.push_back( list< int >() );
3030 list< int >& aListOfElemsID = aListOfListOfElementsID.back();
3031 for ( int j = 0; j < anElemsIDGroup.length(); j++ ) {
3032 CORBA::Long id = anElemsIDGroup[ j ];
3033 aListOfElemsID.push_back( id );
3035 if ( aListOfElemsID.size() < 2 )
3036 aListOfListOfElementsID.pop_back();
3037 if ( i > 0 ) aTPythonDump << ", ";
3038 aTPythonDump << anElemsIDGroup;
3041 ::SMESH_MeshEditor anEditor( myMesh );
3042 anEditor.MergeElements(aListOfListOfElementsID);
3044 aTPythonDump << "] )";
3047 //=======================================================================
3048 //function : MergeEqualElements
3050 //=======================================================================
3052 void SMESH_MeshEditor_i::MergeEqualElements()
3056 ::SMESH_MeshEditor anEditor( myMesh );
3057 anEditor.MergeEqualElements();
3059 TPythonDump() << this << ".MergeEqualElements()";
3062 //================================================================================
3064 * \brief If the given ID is a valid node ID (nodeID > 0), just move this node, else
3065 * move the node closest to the point to point's location and return ID of the node
3067 //================================================================================
3069 CORBA::Long SMESH_MeshEditor_i::MoveClosestNodeToPoint(CORBA::Double x,
3072 CORBA::Long theNodeID)
3074 // We keep myNodeSearcher until any mesh modification:
3075 // 1) initData() deletes myNodeSearcher at any edition,
3076 // 2) TNodeSearcherDeleter - at any mesh compute event and mesh change
3080 int nodeID = theNodeID;
3081 const SMDS_MeshNode* node = GetMeshDS()->FindNode( nodeID );
3084 static TNodeSearcherDeleter deleter;
3085 deleter.Set( myMesh );
3086 if ( !myNodeSearcher ) {
3087 ::SMESH_MeshEditor anEditor( myMesh );
3088 myNodeSearcher = anEditor.GetNodeSearcher();
3091 node = myNodeSearcher->FindClosestTo( p );
3094 nodeID = node->GetID();
3095 if ( myPreviewMode ) // make preview data
3097 // in a preview mesh, make edges linked to a node
3098 TPreviewMesh tmpMesh;
3099 TIDSortedElemSet linkedNodes;
3100 ::SMESH_MeshEditor::GetLinkedNodes( node, linkedNodes );
3101 TIDSortedElemSet::iterator nIt = linkedNodes.begin();
3102 for ( ; nIt != linkedNodes.end(); ++nIt )
3104 SMDS_MeshEdge edge( node, cast2Node( *nIt ));
3105 tmpMesh.Copy( &edge );
3108 node = tmpMesh.GetMeshDS()->FindNode( nodeID );
3110 tmpMesh.GetMeshDS()->MoveNode(node, x, y, z);
3111 // fill preview data
3112 ::SMESH_MeshEditor anEditor( & tmpMesh );
3113 storeResult( anEditor );
3117 GetMeshDS()->MoveNode(node, x, y, z);
3121 if ( !myPreviewMode ) {
3122 TPythonDump() << "nodeID = " << this
3123 << ".MoveClosestNodeToPoint( "<< x << ", " << y << ", " << z
3124 << ", " << nodeID << " )";
3130 //=======================================================================
3131 //function : convError
3133 //=======================================================================
3135 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
3137 static SMESH::SMESH_MeshEditor::Sew_Error convError( const::SMESH_MeshEditor::Sew_Error e )
3141 RETCASE( SEW_BORDER1_NOT_FOUND );
3142 RETCASE( SEW_BORDER2_NOT_FOUND );
3143 RETCASE( SEW_BOTH_BORDERS_NOT_FOUND );
3144 RETCASE( SEW_BAD_SIDE_NODES );
3145 RETCASE( SEW_VOLUMES_TO_SPLIT );
3146 RETCASE( SEW_DIFF_NB_OF_ELEMENTS );
3147 RETCASE( SEW_TOPO_DIFF_SETS_OF_ELEMENTS );
3148 RETCASE( SEW_BAD_SIDE1_NODES );
3149 RETCASE( SEW_BAD_SIDE2_NODES );
3151 return SMESH::SMESH_MeshEditor::SEW_OK;
3154 //=======================================================================
3155 //function : SewFreeBorders
3157 //=======================================================================
3159 SMESH::SMESH_MeshEditor::Sew_Error
3160 SMESH_MeshEditor_i::SewFreeBorders(CORBA::Long FirstNodeID1,
3161 CORBA::Long SecondNodeID1,
3162 CORBA::Long LastNodeID1,
3163 CORBA::Long FirstNodeID2,
3164 CORBA::Long SecondNodeID2,
3165 CORBA::Long LastNodeID2,
3166 CORBA::Boolean CreatePolygons,
3167 CORBA::Boolean CreatePolyedrs)
3171 SMESHDS_Mesh* aMesh = GetMeshDS();
3173 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
3174 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
3175 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
3176 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
3177 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
3178 const SMDS_MeshNode* aSide2ThirdNode = aMesh->FindNode( LastNodeID2 );
3180 if (!aBorderFirstNode ||
3181 !aBorderSecondNode||
3183 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
3184 if (!aSide2FirstNode ||
3185 !aSide2SecondNode ||
3187 return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
3189 TPythonDump() << "error = " << this << ".SewFreeBorders( "
3190 << FirstNodeID1 << ", "
3191 << SecondNodeID1 << ", "
3192 << LastNodeID1 << ", "
3193 << FirstNodeID2 << ", "
3194 << SecondNodeID2 << ", "
3195 << LastNodeID2 << ", "
3196 << CreatePolygons<< ", "
3197 << CreatePolyedrs<< " )";
3199 ::SMESH_MeshEditor anEditor( myMesh );
3200 SMESH::SMESH_MeshEditor::Sew_Error error =
3201 convError( anEditor.SewFreeBorder (aBorderFirstNode,
3211 storeResult(anEditor);
3217 //=======================================================================
3218 //function : SewConformFreeBorders
3220 //=======================================================================
3222 SMESH::SMESH_MeshEditor::Sew_Error
3223 SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1,
3224 CORBA::Long SecondNodeID1,
3225 CORBA::Long LastNodeID1,
3226 CORBA::Long FirstNodeID2,
3227 CORBA::Long SecondNodeID2)
3231 SMESHDS_Mesh* aMesh = GetMeshDS();
3233 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
3234 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
3235 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
3236 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
3237 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
3238 const SMDS_MeshNode* aSide2ThirdNode = 0;
3240 if (!aBorderFirstNode ||
3241 !aBorderSecondNode||
3243 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
3244 if (!aSide2FirstNode ||
3246 return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
3248 TPythonDump() << "error = " << this << ".SewConformFreeBorders( "
3249 << FirstNodeID1 << ", "
3250 << SecondNodeID1 << ", "
3251 << LastNodeID1 << ", "
3252 << FirstNodeID2 << ", "
3253 << SecondNodeID2 << " )";
3255 ::SMESH_MeshEditor anEditor( myMesh );
3256 SMESH::SMESH_MeshEditor::Sew_Error error =
3257 convError( anEditor.SewFreeBorder (aBorderFirstNode,
3266 storeResult(anEditor);
3272 //=======================================================================
3273 //function : SewBorderToSide
3275 //=======================================================================
3277 SMESH::SMESH_MeshEditor::Sew_Error
3278 SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder,
3279 CORBA::Long SecondNodeIDOnFreeBorder,
3280 CORBA::Long LastNodeIDOnFreeBorder,
3281 CORBA::Long FirstNodeIDOnSide,
3282 CORBA::Long LastNodeIDOnSide,
3283 CORBA::Boolean CreatePolygons,
3284 CORBA::Boolean CreatePolyedrs)
3288 SMESHDS_Mesh* aMesh = GetMeshDS();
3290 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeIDOnFreeBorder );
3291 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeIDOnFreeBorder );
3292 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeIDOnFreeBorder );
3293 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeIDOnSide );
3294 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( LastNodeIDOnSide );
3295 const SMDS_MeshNode* aSide2ThirdNode = 0;
3297 if (!aBorderFirstNode ||
3298 !aBorderSecondNode||
3300 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
3301 if (!aSide2FirstNode ||
3303 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE_NODES;
3305 TPythonDump() << "error = " << this << ".SewBorderToSide( "
3306 << FirstNodeIDOnFreeBorder << ", "
3307 << SecondNodeIDOnFreeBorder << ", "
3308 << LastNodeIDOnFreeBorder << ", "
3309 << FirstNodeIDOnSide << ", "
3310 << LastNodeIDOnSide << ", "
3311 << CreatePolygons << ", "
3312 << CreatePolyedrs << ") ";
3314 ::SMESH_MeshEditor anEditor( myMesh );
3315 SMESH::SMESH_MeshEditor::Sew_Error error =
3316 convError( anEditor.SewFreeBorder (aBorderFirstNode,
3326 storeResult(anEditor);
3332 //=======================================================================
3333 //function : SewSideElements
3335 //=======================================================================
3337 SMESH::SMESH_MeshEditor::Sew_Error
3338 SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements,
3339 const SMESH::long_array& IDsOfSide2Elements,
3340 CORBA::Long NodeID1OfSide1ToMerge,
3341 CORBA::Long NodeID1OfSide2ToMerge,
3342 CORBA::Long NodeID2OfSide1ToMerge,
3343 CORBA::Long NodeID2OfSide2ToMerge)
3347 SMESHDS_Mesh* aMesh = GetMeshDS();
3349 const SMDS_MeshNode* aFirstNode1ToMerge = aMesh->FindNode( NodeID1OfSide1ToMerge );
3350 const SMDS_MeshNode* aFirstNode2ToMerge = aMesh->FindNode( NodeID1OfSide2ToMerge );
3351 const SMDS_MeshNode* aSecondNode1ToMerge = aMesh->FindNode( NodeID2OfSide1ToMerge );
3352 const SMDS_MeshNode* aSecondNode2ToMerge = aMesh->FindNode( NodeID2OfSide2ToMerge );
3354 if (!aFirstNode1ToMerge ||
3355 !aFirstNode2ToMerge )
3356 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE1_NODES;
3357 if (!aSecondNode1ToMerge||
3358 !aSecondNode2ToMerge)
3359 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE2_NODES;
3361 TIDSortedElemSet aSide1Elems, aSide2Elems;
3362 arrayToSet(IDsOfSide1Elements, aMesh, aSide1Elems);
3363 arrayToSet(IDsOfSide2Elements, aMesh, aSide2Elems);
3365 TPythonDump() << "error = " << this << ".SewSideElements( "
3366 << IDsOfSide1Elements << ", "
3367 << IDsOfSide2Elements << ", "
3368 << NodeID1OfSide1ToMerge << ", "
3369 << NodeID1OfSide2ToMerge << ", "
3370 << NodeID2OfSide1ToMerge << ", "
3371 << NodeID2OfSide2ToMerge << ")";
3373 ::SMESH_MeshEditor anEditor( myMesh );
3374 SMESH::SMESH_MeshEditor::Sew_Error error =
3375 convError( anEditor.SewSideElements (aSide1Elems, aSide2Elems,
3378 aSecondNode1ToMerge,
3379 aSecondNode2ToMerge));
3381 storeResult(anEditor);
3386 //================================================================================
3388 * \brief Set new nodes for given element
3389 * \param ide - element id
3390 * \param newIDs - new node ids
3391 * \retval CORBA::Boolean - true if result is OK
3393 //================================================================================
3395 CORBA::Boolean SMESH_MeshEditor_i::ChangeElemNodes(CORBA::Long ide,
3396 const SMESH::long_array& newIDs)
3400 const SMDS_MeshElement* elem = GetMeshDS()->FindElement(ide);
3401 if(!elem) return false;
3403 int nbn = newIDs.length();
3405 vector<const SMDS_MeshNode*> aNodes(nbn);
3408 const SMDS_MeshNode* aNode = GetMeshDS()->FindNode(newIDs[i]);
3411 aNodes[nbn1] = aNode;
3414 TPythonDump() << "isDone = " << this << ".ChangeElemNodes( "
3415 << ide << ", " << newIDs << " )";
3417 TPythonDump() << "print 'ChangeElemNodes: ', isDone";
3420 return GetMeshDS()->ChangeElementNodes( elem, & aNodes[0], nbn1+1 );
3423 //================================================================================
3425 * \brief Update myLastCreated* or myPreviewData
3426 * \param anEditor - it contains last modification results
3428 //================================================================================
3430 void SMESH_MeshEditor_i::storeResult(::SMESH_MeshEditor& anEditor)
3432 if ( myPreviewMode ) { // --- MeshPreviewStruct filling ---
3434 list<int> aNodesConnectivity;
3435 typedef map<int, int> TNodesMap;
3438 TPreviewMesh * aPreviewMesh = dynamic_cast< TPreviewMesh* >( anEditor.GetMesh() );
3439 SMDSAbs_ElementType previewType = aPreviewMesh->myPreviewType;
3441 SMESHDS_Mesh* aMeshDS = anEditor.GetMeshDS();
3442 int nbEdges = aMeshDS->NbEdges();
3443 int nbFaces = aMeshDS->NbFaces();
3444 int nbVolum = aMeshDS->NbVolumes();
3445 switch ( previewType ) {
3446 case SMDSAbs_Edge : nbFaces = nbVolum = 0; break;
3447 case SMDSAbs_Face : nbEdges = nbVolum = 0; break;
3448 case SMDSAbs_Volume: nbEdges = nbFaces = 0; break;
3451 myPreviewData->nodesXYZ.length(aMeshDS->NbNodes());
3452 myPreviewData->elementTypes.length(nbEdges + nbFaces + nbVolum);
3454 SMDS_ElemIteratorPtr itMeshElems = aMeshDS->elementsIterator();
3456 while ( itMeshElems->more() ) {
3457 const SMDS_MeshElement* aMeshElem = itMeshElems->next();
3458 if ( previewType != SMDSAbs_All && aMeshElem->GetType() != previewType )
3461 SMDS_ElemIteratorPtr itElemNodes = aMeshElem->nodesIterator();
3462 while ( itElemNodes->more() ) {
3463 const SMDS_MeshNode* aMeshNode =
3464 static_cast<const SMDS_MeshNode*>( itElemNodes->next() );
3465 int aNodeID = aMeshNode->GetID();
3466 TNodesMap::iterator anIter = nodesMap.find(aNodeID);
3467 if ( anIter == nodesMap.end() ) {
3468 // filling the nodes coordinates
3469 myPreviewData->nodesXYZ[j].x = aMeshNode->X();
3470 myPreviewData->nodesXYZ[j].y = aMeshNode->Y();
3471 myPreviewData->nodesXYZ[j].z = aMeshNode->Z();
3472 anIter = nodesMap.insert( make_pair(aNodeID, j) ).first;
3475 aNodesConnectivity.push_back(anIter->second);
3478 // filling the elements types
3479 SMDSAbs_ElementType aType;
3481 /*if (aMeshElem->GetType() == SMDSAbs_Volume) {
3482 aType = SMDSAbs_Node;
3486 aType = aMeshElem->GetType();
3487 isPoly = aMeshElem->IsPoly();
3490 myPreviewData->elementTypes[i].SMDS_ElementType = (SMESH::ElementType) aType;
3491 myPreviewData->elementTypes[i].isPoly = isPoly;
3492 myPreviewData->elementTypes[i].nbNodesInElement = aMeshElem->NbNodes();
3496 myPreviewData->nodesXYZ.length( j );
3498 // filling the elements connectivities
3499 list<int>::iterator aConnIter = aNodesConnectivity.begin();
3500 myPreviewData->elementConnectivities.length(aNodesConnectivity.size());
3501 for( int i = 0; aConnIter != aNodesConnectivity.end(); aConnIter++, i++ )
3502 myPreviewData->elementConnectivities[i] = *aConnIter;
3508 // add new nodes into myLastCreatedNodes
3509 const SMESH_SequenceOfElemPtr& aSeq = anEditor.GetLastCreatedNodes();
3510 myLastCreatedNodes->length(aSeq.Length());
3511 for(int i=0; i<aSeq.Length(); i++)
3512 myLastCreatedNodes[i] = aSeq.Value(i+1)->GetID();
3515 // add new elements into myLastCreatedElems
3516 const SMESH_SequenceOfElemPtr& aSeq = anEditor.GetLastCreatedElems();
3517 myLastCreatedElems->length(aSeq.Length());
3518 for(int i=0; i<aSeq.Length(); i++)
3519 myLastCreatedElems[i] = aSeq.Value(i+1)->GetID();
3523 //================================================================================
3525 * Return data of mesh edition preview
3527 //================================================================================
3529 SMESH::MeshPreviewStruct* SMESH_MeshEditor_i::GetPreviewData()
3531 return myPreviewData._retn();
3534 //================================================================================
3536 * \brief Returns list of it's IDs of created nodes
3537 * \retval SMESH::long_array* - list of node ID
3539 //================================================================================
3541 SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedNodes()
3543 return myLastCreatedNodes._retn();
3546 //================================================================================
3548 * \brief Returns list of it's IDs of created elements
3549 * \retval SMESH::long_array* - list of elements' ID
3551 //================================================================================
3553 SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedElems()
3555 return myLastCreatedElems._retn();
3558 //=======================================================================
3559 //function : ConvertToQuadratic
3561 //=======================================================================
3563 void SMESH_MeshEditor_i::ConvertToQuadratic(CORBA::Boolean theForce3d)
3565 ::SMESH_MeshEditor anEditor( myMesh );
3566 anEditor.ConvertToQuadratic(theForce3d);
3567 TPythonDump() << this << ".ConvertToQuadratic( " << theForce3d << " )";
3570 //=======================================================================
3571 //function : ConvertFromQuadratic
3573 //=======================================================================
3575 CORBA::Boolean SMESH_MeshEditor_i::ConvertFromQuadratic()
3577 ::SMESH_MeshEditor anEditor( myMesh );
3578 CORBA::Boolean isDone = anEditor.ConvertFromQuadratic();
3579 TPythonDump() << this << ".ConvertFromQuadratic()";
3583 //=======================================================================
3584 //function : makeMesh
3585 //purpose : create a named imported mesh
3586 //=======================================================================
3588 SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::makeMesh(const char* theMeshName)
3590 SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen();
3591 SMESH::SMESH_Mesh_var mesh = gen->CreateEmptyMesh();
3592 SALOMEDS::Study_var study = gen->GetCurrentStudy();
3593 SALOMEDS::SObject_var meshSO = gen->ObjectToSObject( study, mesh );
3594 gen->SetName( meshSO, theMeshName, "Mesh" );
3596 SALOMEDS::StudyBuilder_var builder = study->NewBuilder();
3597 SALOMEDS::GenericAttribute_var anAttr
3598 = builder->FindOrCreateAttribute( meshSO, "AttributePixMap" );
3599 SALOMEDS::AttributePixMap::_narrow( anAttr )->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
3601 return mesh._retn();
3604 //=======================================================================
3605 //function : DumpGroupsList
3607 //=======================================================================
3608 void SMESH_MeshEditor_i::DumpGroupsList(TPythonDump & theDumpPython,
3609 const SMESH::ListOfGroups * theGroupList)
3611 bool isDumpGroupList = theGroupList && theGroupList->length() > 0;
3612 if(isDumpGroupList) {
3613 theDumpPython << theGroupList << " = ";