1 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESH_MeshEditor_i.cxx
25 // Author : Nicolas REJNERI
29 #include "SMESH_MeshEditor_i.hxx"
31 #include "SMDS_MeshEdge.hxx"
32 #include "SMDS_MeshFace.hxx"
33 #include "SMDS_MeshVolume.hxx"
35 #include "SMESH_MeshEditor.hxx"
37 #include "SMESH_Gen_i.hxx"
38 #include "SMESH_Filter_i.hxx"
39 #include "SMESH_PythonDump.hxx"
41 #include "utilities.h"
49 typedef map<const SMDS_MeshElement*,
50 list<const SMDS_MeshElement*> > TElemOfElemListMap;
53 using SMESH::TPythonDump;
55 //=============================================================================
59 //=============================================================================
61 SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESH_Mesh* theMesh)
66 //=============================================================================
70 //=============================================================================
73 SMESH_MeshEditor_i::RemoveElements(const SMESH::long_array & IDsOfElements)
75 ::SMESH_MeshEditor anEditor( _myMesh );
78 for (int i = 0; i < IDsOfElements.length(); i++)
79 IdList.push_back( IDsOfElements[i] );
81 // Update Python script
82 TPythonDump() << "isDone = " << this << ".RemoveElements( " << IDsOfElements << " )";
84 TPythonDump() << "print 'RemoveElements: ', isDone";
87 return anEditor.Remove( IdList, false );
90 //=============================================================================
94 //=============================================================================
96 CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::long_array & IDsOfNodes)
98 ::SMESH_MeshEditor anEditor( _myMesh );
100 for (int i = 0; i < IDsOfNodes.length(); i++)
101 IdList.push_back( IDsOfNodes[i] );
103 // Update Python script
104 TPythonDump() << "isDone = " << this << ".RemoveNodes( " << IDsOfNodes << " )";
106 TPythonDump() << "print 'RemoveNodes: ', isDone";
109 return anEditor.Remove( IdList, true );
112 //=============================================================================
116 //=============================================================================
118 CORBA::Boolean SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes)
120 int NbNodes = IDsOfNodes.length();
123 CORBA::Long index1 = IDsOfNodes[0];
124 CORBA::Long index2 = IDsOfNodes[1];
125 GetMeshDS()->AddEdge(GetMeshDS()->FindNode(index1), GetMeshDS()->FindNode(index2));
127 // Update Python script
128 TPythonDump() << "isDone = " << this << ".AddEdge([ "
129 << index1 << ", " << index2 <<" ])";
132 CORBA::Long n1 = IDsOfNodes[0];
133 CORBA::Long n2 = IDsOfNodes[1];
134 CORBA::Long n12 = IDsOfNodes[2];
135 GetMeshDS()->AddEdge(GetMeshDS()->FindNode(n1),
136 GetMeshDS()->FindNode(n2),
137 GetMeshDS()->FindNode(n12));
138 // Update Python script
139 TPythonDump() << "isDone = " << this << ".AddEdge([ "
140 <<n1<<", "<<n2<<", "<<n12<<" ])";
145 //=============================================================================
149 //=============================================================================
151 CORBA::Boolean SMESH_MeshEditor_i::AddNode(CORBA::Double x,
152 CORBA::Double y, CORBA::Double z)
154 GetMeshDS()->AddNode(x, y, z);
156 // Update Python script
157 TPythonDump() << "isDone = " << this << ".AddNode( "
158 << x << ", " << y << ", " << z << " )";
163 //=============================================================================
167 //=============================================================================
169 CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
171 int NbNodes = IDsOfNodes.length();
177 std::vector<const SMDS_MeshNode*> nodes (NbNodes);
178 for (int i = 0; i < NbNodes; i++)
179 nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
183 GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]);
185 else if (NbNodes == 4)
187 GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
189 else if (NbNodes == 6)
191 GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
194 else if (NbNodes == 8)
196 GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
197 nodes[4], nodes[5], nodes[6], nodes[7]);
200 // Update Python script
201 TPythonDump() << "isDone = " << this << ".AddFace( " << IDsOfNodes << " )";
203 TPythonDump() << "print 'AddFace: ', isDone";
209 //=============================================================================
213 //=============================================================================
214 CORBA::Boolean SMESH_MeshEditor_i::AddPolygonalFace
215 (const SMESH::long_array & IDsOfNodes)
217 int NbNodes = IDsOfNodes.length();
218 std::vector<const SMDS_MeshNode*> nodes (NbNodes);
219 for (int i = 0; i < NbNodes; i++)
220 nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
222 GetMeshDS()->AddPolygonalFace(nodes);
224 // Update Python script
225 TPythonDump() <<"isDone = "<<this<<".AddPolygonalFace( "<<IDsOfNodes<<" )";
227 TPythonDump() << "print 'AddPolygonalFace: ', isDone";
233 //=============================================================================
237 //=============================================================================
239 CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH::long_array & IDsOfNodes)
241 int NbNodes = IDsOfNodes.length();
242 vector< const SMDS_MeshNode*> n(NbNodes);
243 for(int i=0;i<NbNodes;i++)
244 n[i]=GetMeshDS()->FindNode(IDsOfNodes[i]);
248 case 4:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3]); break;
249 case 5:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4]); break;
250 case 6:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5]); break;
251 case 8:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break;
252 case 10:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],
253 n[6],n[7],n[8],n[9]); break;
254 case 13:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],
255 n[7],n[8],n[9],n[10],n[11],n[12]); break;
256 case 15:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],
257 n[9],n[10],n[11],n[12],n[13],n[14]); break;
258 case 20:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],
259 n[8],n[9],n[10],n[11],n[12],n[13],n[14],
260 n[15],n[16],n[17],n[18],n[19]); break;
262 // Update Python script
263 TPythonDump() << "isDone = " << this << ".AddVolume( " << IDsOfNodes << " )";
265 TPythonDump() << "print 'AddVolume: ', isDone";
271 //=============================================================================
273 * AddPolyhedralVolume
275 //=============================================================================
276 CORBA::Boolean SMESH_MeshEditor_i::AddPolyhedralVolume
277 (const SMESH::long_array & IDsOfNodes,
278 const SMESH::long_array & Quantities)
280 int NbNodes = IDsOfNodes.length();
281 std::vector<const SMDS_MeshNode*> n (NbNodes);
282 for (int i = 0; i < NbNodes; i++)
283 n[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
285 int NbFaces = Quantities.length();
286 std::vector<int> q (NbFaces);
287 for (int j = 0; j < NbFaces; j++)
288 q[j] = Quantities[j];
290 GetMeshDS()->AddPolyhedralVolume(n, q);
292 // Update Python script
293 TPythonDump() << "isDone = " << this << ".AddPolyhedralVolume( "
294 << IDsOfNodes << ", " << Quantities << " )";
296 TPythonDump() << "print 'AddPolyhedralVolume: ', isDone";
302 //=============================================================================
304 * AddPolyhedralVolumeByFaces
306 //=============================================================================
307 CORBA::Boolean SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces
308 (const SMESH::long_array & IdsOfFaces)
310 int NbFaces = IdsOfFaces.length();
311 std::vector<const SMDS_MeshNode*> poly_nodes;
312 std::vector<int> quantities (NbFaces);
314 for (int i = 0; i < NbFaces; i++) {
315 const SMDS_MeshElement* aFace = GetMeshDS()->FindElement(IdsOfFaces[i]);
316 quantities[i] = aFace->NbNodes();
318 SMDS_ElemIteratorPtr It = aFace->nodesIterator();
320 poly_nodes.push_back(static_cast<const SMDS_MeshNode *>(It->next()));
324 GetMeshDS()->AddPolyhedralVolume(poly_nodes, quantities);
326 // Update Python script
327 TPythonDump() << "isDone = " << this << ".AddPolyhedralVolumeByFaces( "
328 << IdsOfFaces << " )";
330 TPythonDump() << "print 'AddPolyhedralVolume: ', isDone";
336 //=============================================================================
340 //=============================================================================
342 CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long NodeID,
347 const SMDS_MeshNode * node = GetMeshDS()->FindNode( NodeID );
351 GetMeshDS()->MoveNode(node, x, y, z);
353 // Update Python script
354 TPythonDump() << "isDone = " << this << ".MoveNode( "
355 << NodeID << ", " << x << ", " << y << ", " << z << " )";
360 //=============================================================================
364 //=============================================================================
366 CORBA::Boolean SMESH_MeshEditor_i::InverseDiag(CORBA::Long NodeID1,
369 const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
370 const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
374 // Update Python script
375 TPythonDump() << "isDone = " << this << ".InverseDiag( "
376 << NodeID1 << ", " << NodeID2 << " )";
378 ::SMESH_MeshEditor aMeshEditor( _myMesh );
379 return aMeshEditor.InverseDiag ( n1, n2 );
382 //=============================================================================
386 //=============================================================================
388 CORBA::Boolean SMESH_MeshEditor_i::DeleteDiag(CORBA::Long NodeID1,
391 const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
392 const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
396 // Update Python script
397 TPythonDump() << "isDone = " << this << ".DeleteDiag( "
398 << NodeID1 << ", " << NodeID2 << " )";
400 ::SMESH_MeshEditor aMeshEditor( _myMesh );
401 return aMeshEditor.DeleteDiag ( n1, n2 );
404 //=============================================================================
408 //=============================================================================
410 CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::long_array & IDsOfElements)
412 ::SMESH_MeshEditor anEditor( _myMesh );
413 for (int i = 0; i < IDsOfElements.length(); i++)
415 CORBA::Long index = IDsOfElements[i];
416 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
418 anEditor.Reorient( elem );
420 // Update Python script
421 TPythonDump() << "isDone = " << this << ".Reorient( " << IDsOfElements << " )";
427 //=============================================================================
431 //=============================================================================
433 CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theObject)
435 SMESH::long_array_var anElementsId = theObject->GetIDs();
436 CORBA::Boolean isDone = Reorient(anElementsId);
438 // Clear python line, created by Reorient()
439 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
440 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
442 // Update Python script
443 TPythonDump() << "isDone = " << this << ".ReorientObject( " << theObject << " )";
448 //=============================================================================
452 //=============================================================================
453 CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfElements,
454 SMESH::NumericalFunctor_ptr Criterion,
455 CORBA::Double MaxAngle)
457 set<const SMDS_MeshElement*> faces;
458 for (int i = 0; i < IDsOfElements.length(); i++)
460 CORBA::Long index = IDsOfElements[i];
461 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
462 if ( elem && elem->GetType() == SMDSAbs_Face)
463 faces.insert( elem );
465 SMESH::NumericalFunctor_i* aNumericalFunctor =
466 dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
467 SMESH::Controls::NumericalFunctorPtr aCrit;
468 if ( !aNumericalFunctor )
469 aCrit.reset( new SMESH::Controls::AspectRatio() );
471 aCrit = aNumericalFunctor->GetNumericalFunctor();
473 // Update Python script
474 TPythonDump() << "isDone = " << this << ".TriToQuad( "
475 << IDsOfElements << ", None, " << MaxAngle << " )";
477 TPythonDump() << "print 'TriToQuad: ', isDone";
480 ::SMESH_MeshEditor anEditor( _myMesh );
481 return anEditor.TriToQuad( faces, aCrit, MaxAngle );
484 //=============================================================================
488 //=============================================================================
489 CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr theObject,
490 SMESH::NumericalFunctor_ptr Criterion,
491 CORBA::Double MaxAngle)
493 SMESH::long_array_var anElementsId = theObject->GetIDs();
494 CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
496 // Clear python line(s), created by TriToQuad()
497 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
498 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
500 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
503 // Update Python script
504 TPythonDump() << "isDone = " << this << ".TriToQuadObject("
505 << theObject << ", None, " << MaxAngle << " )";
507 TPythonDump() << "print 'TriToQuadObject: ', isDone";
513 //=============================================================================
517 //=============================================================================
518 CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array & IDsOfElements,
519 SMESH::NumericalFunctor_ptr Criterion)
521 set<const SMDS_MeshElement*> faces;
522 for (int i = 0; i < IDsOfElements.length(); i++)
524 CORBA::Long index = IDsOfElements[i];
525 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
526 if ( elem && elem->GetType() == SMDSAbs_Face)
527 faces.insert( elem );
529 SMESH::NumericalFunctor_i* aNumericalFunctor =
530 dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
531 SMESH::Controls::NumericalFunctorPtr aCrit;
532 if ( !aNumericalFunctor )
533 aCrit.reset( new SMESH::Controls::AspectRatio() );
535 aCrit = aNumericalFunctor->GetNumericalFunctor();
538 // Update Python script
539 TPythonDump() << "isDone = " << this << ".QuadToTri( " << IDsOfElements << ", None )";
541 TPythonDump() << "print 'QuadToTri: ', isDone";
544 ::SMESH_MeshEditor anEditor( _myMesh );
545 return anEditor.QuadToTri( faces, aCrit );
548 //=============================================================================
552 //=============================================================================
553 CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr theObject,
554 SMESH::NumericalFunctor_ptr Criterion)
556 SMESH::long_array_var anElementsId = theObject->GetIDs();
557 CORBA::Boolean isDone = QuadToTri(anElementsId, Criterion);
559 // Clear python line(s), created by QuadToTri()
560 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
561 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
563 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
566 // Update Python script
567 TPythonDump() << "isDone = " << this << ".QuadToTriObject(" << theObject << ", None )";
569 TPythonDump() << "print 'QuadToTriObject: ', isDone";
575 //=============================================================================
579 //=============================================================================
580 CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfElements,
581 CORBA::Boolean Diag13)
583 set<const SMDS_MeshElement*> faces;
584 for (int i = 0; i < IDsOfElements.length(); i++)
586 CORBA::Long index = IDsOfElements[i];
587 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
588 if ( elem && elem->GetType() == SMDSAbs_Face)
589 faces.insert( elem );
592 // Update Python script
593 TPythonDump() << "isDone = " << this << ".SplitQuad( "
594 << IDsOfElements << ", " << Diag13 << " )";
596 TPythonDump() << "print 'SplitQuad: ', isDone";
599 ::SMESH_MeshEditor anEditor( _myMesh );
600 return anEditor.QuadToTri( faces, Diag13 );
603 //=============================================================================
607 //=============================================================================
608 CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr theObject,
609 CORBA::Boolean Diag13)
611 SMESH::long_array_var anElementsId = theObject->GetIDs();
612 CORBA::Boolean isDone = SplitQuad(anElementsId, Diag13);
614 // Clear python line(s), created by SplitQuad()
615 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
616 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
618 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
621 // Update Python script
622 TPythonDump() << "isDone = " << this << ".SplitQuadObject( "
623 << theObject << ", " << Diag13 << " )";
625 TPythonDump() << "print 'SplitQuadObject: ', isDone";
631 //=============================================================================
635 //=============================================================================
636 CORBA::Long SMESH_MeshEditor_i::BestSplit (CORBA::Long IDOfQuad,
637 SMESH::NumericalFunctor_ptr Criterion)
639 const SMDS_MeshElement* quad = GetMeshDS()->FindElement(IDOfQuad);
640 if (quad && quad->GetType() == SMDSAbs_Face && quad->NbNodes() == 4)
642 SMESH::NumericalFunctor_i* aNumericalFunctor =
643 dynamic_cast<SMESH::NumericalFunctor_i*>(SMESH_Gen_i::GetServant(Criterion).in());
644 SMESH::Controls::NumericalFunctorPtr aCrit;
645 if (aNumericalFunctor)
646 aCrit = aNumericalFunctor->GetNumericalFunctor();
648 aCrit.reset(new SMESH::Controls::AspectRatio());
650 ::SMESH_MeshEditor anEditor (_myMesh);
651 return anEditor.BestSplit(quad, aCrit);
656 //=======================================================================
659 //=======================================================================
662 SMESH_MeshEditor_i::Smooth(const SMESH::long_array & IDsOfElements,
663 const SMESH::long_array & IDsOfFixedNodes,
664 CORBA::Long MaxNbOfIterations,
665 CORBA::Double MaxAspectRatio,
666 SMESH::SMESH_MeshEditor::Smooth_Method Method)
668 return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations,
669 MaxAspectRatio, Method, false );
672 //=======================================================================
673 //function : SmoothParametric
675 //=======================================================================
678 SMESH_MeshEditor_i::SmoothParametric(const SMESH::long_array & IDsOfElements,
679 const SMESH::long_array & IDsOfFixedNodes,
680 CORBA::Long MaxNbOfIterations,
681 CORBA::Double MaxAspectRatio,
682 SMESH::SMESH_MeshEditor::Smooth_Method Method)
684 return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations,
685 MaxAspectRatio, Method, true );
688 //=======================================================================
689 //function : SmoothObject
691 //=======================================================================
694 SMESH_MeshEditor_i::SmoothObject(SMESH::SMESH_IDSource_ptr theObject,
695 const SMESH::long_array & IDsOfFixedNodes,
696 CORBA::Long MaxNbOfIterations,
697 CORBA::Double MaxAspectRatio,
698 SMESH::SMESH_MeshEditor::Smooth_Method Method)
700 return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations,
701 MaxAspectRatio, Method, false);
704 //=======================================================================
705 //function : SmoothParametricObject
707 //=======================================================================
710 SMESH_MeshEditor_i::SmoothParametricObject(SMESH::SMESH_IDSource_ptr theObject,
711 const SMESH::long_array & IDsOfFixedNodes,
712 CORBA::Long MaxNbOfIterations,
713 CORBA::Double MaxAspectRatio,
714 SMESH::SMESH_MeshEditor::Smooth_Method Method)
716 return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations,
717 MaxAspectRatio, Method, true);
720 //=============================================================================
724 //=============================================================================
727 SMESH_MeshEditor_i::smooth(const SMESH::long_array & IDsOfElements,
728 const SMESH::long_array & IDsOfFixedNodes,
729 CORBA::Long MaxNbOfIterations,
730 CORBA::Double MaxAspectRatio,
731 SMESH::SMESH_MeshEditor::Smooth_Method Method,
734 SMESHDS_Mesh* aMesh = GetMeshDS();
736 set<const SMDS_MeshElement*> elements;
737 for (int i = 0; i < IDsOfElements.length(); i++)
739 CORBA::Long index = IDsOfElements[i];
740 const SMDS_MeshElement * elem = aMesh->FindElement(index);
741 if ( elem && elem->GetType() == SMDSAbs_Face)
742 elements.insert( elem );
745 set<const SMDS_MeshNode*> fixedNodes;
746 for (int i = 0; i < IDsOfFixedNodes.length(); i++)
748 CORBA::Long index = IDsOfFixedNodes[i];
749 const SMDS_MeshNode * node = aMesh->FindNode(index);
751 fixedNodes.insert( node );
753 ::SMESH_MeshEditor::SmoothMethod method = ::SMESH_MeshEditor::LAPLACIAN;
754 if ( Method != SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH )
755 method = ::SMESH_MeshEditor::CENTROIDAL;
757 ::SMESH_MeshEditor anEditor( _myMesh );
758 anEditor.Smooth(elements, fixedNodes, method,
759 MaxNbOfIterations, MaxAspectRatio, IsParametric );
761 // Update Python script
762 TPythonDump() << "isDone = " << this << "."
763 << (IsParametric ? "SmoothParametric( " : "Smooth( ")
764 << IDsOfElements << ", " << IDsOfFixedNodes << ", "
765 << MaxNbOfIterations << ", " << MaxAspectRatio << ", "
766 << "SMESH.SMESH_MeshEditor."
767 << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
768 "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
770 TPythonDump() << "print 'Smooth: ', isDone";
776 //=============================================================================
780 //=============================================================================
783 SMESH_MeshEditor_i::smoothObject(SMESH::SMESH_IDSource_ptr theObject,
784 const SMESH::long_array & IDsOfFixedNodes,
785 CORBA::Long MaxNbOfIterations,
786 CORBA::Double MaxAspectRatio,
787 SMESH::SMESH_MeshEditor::Smooth_Method Method,
790 SMESH::long_array_var anElementsId = theObject->GetIDs();
791 CORBA::Boolean isDone = smooth (anElementsId, IDsOfFixedNodes, MaxNbOfIterations,
792 MaxAspectRatio, Method, IsParametric);
794 // Clear python line(s), created by Smooth()
795 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
796 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
798 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
801 // Update Python script
802 TPythonDump() << "isDone = " << this << "."
803 << (IsParametric ? "SmoothParametricObject( " : "SmoothObject( ")
804 << theObject << ", " << IDsOfFixedNodes << ", "
805 << MaxNbOfIterations << ", " << MaxAspectRatio << ", "
806 << "SMESH.SMESH_MeshEditor."
807 << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
808 "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
810 TPythonDump() << "print 'SmoothObject: ', isDone";
816 //=============================================================================
820 //=============================================================================
822 void SMESH_MeshEditor_i::RenumberNodes()
824 // Update Python script
825 TPythonDump() << this << ".RenumberNodes()";
827 GetMeshDS()->Renumber( true );
830 //=============================================================================
834 //=============================================================================
836 void SMESH_MeshEditor_i::RenumberElements()
838 // Update Python script
839 TPythonDump() << this << ".RenumberElements()";
841 GetMeshDS()->Renumber( false );
844 //=======================================================================
845 //function : RotationSweep
847 //=======================================================================
849 void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElements,
850 const SMESH::AxisStruct & theAxis,
851 CORBA::Double theAngleInRadians,
852 CORBA::Long theNbOfSteps,
853 CORBA::Double theTolerance)
855 SMESHDS_Mesh* aMesh = GetMeshDS();
857 set<const SMDS_MeshElement*> elements;
858 for (int i = 0; i < theIDsOfElements.length(); i++)
860 CORBA::Long index = theIDsOfElements[i];
861 const SMDS_MeshElement * elem = aMesh->FindElement(index);
863 elements.insert( elem );
865 gp_Ax1 Ax1 (gp_Pnt( theAxis.x, theAxis.y, theAxis.z ),
866 gp_Vec( theAxis.vx, theAxis.vy, theAxis.vz ));
868 ::SMESH_MeshEditor anEditor( _myMesh );
869 anEditor.RotationSweep (elements, Ax1, theAngleInRadians,
870 theNbOfSteps, theTolerance);
872 // Update Python script
873 TPythonDump() << "axis = " << theAxis;
874 TPythonDump() << this << ".RotationSweep( "
877 << theAngleInRadians << ", "
878 << theNbOfSteps << ", "
879 << theTolerance << " )";
882 //=======================================================================
883 //function : RotationSweepObject
885 //=======================================================================
887 void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject,
888 const SMESH::AxisStruct & theAxis,
889 CORBA::Double theAngleInRadians,
890 CORBA::Long theNbOfSteps,
891 CORBA::Double theTolerance)
893 SMESH::long_array_var anElementsId = theObject->GetIDs();
894 RotationSweep(anElementsId, theAxis, theAngleInRadians, theNbOfSteps, theTolerance);
896 // Clear python line, created by RotationSweep()
897 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
898 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
900 // Update Python script
901 TPythonDump() << this << ".RotationSweepObject( "
904 << theAngleInRadians << ", "
905 << theNbOfSteps << ", "
906 << theTolerance << " )";
909 //=======================================================================
910 //function : ExtrusionSweep
912 //=======================================================================
914 void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElements,
915 const SMESH::DirStruct & theStepVector,
916 CORBA::Long theNbOfSteps)
918 SMESHDS_Mesh* aMesh = GetMeshDS();
920 set<const SMDS_MeshElement*> elements;
921 for (int i = 0; i < theIDsOfElements.length(); i++)
923 CORBA::Long index = theIDsOfElements[i];
924 const SMDS_MeshElement * elem = aMesh->FindElement(index);
926 elements.insert( elem );
928 const SMESH::PointStruct * P = &theStepVector.PS;
929 gp_Vec stepVec( P->x, P->y, P->z );
931 ::SMESH_MeshEditor anEditor( _myMesh );
932 //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
933 TElemOfElemListMap aHystory;
934 anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory);
936 // Update Python script
937 TPythonDump() << "stepVector = " << theStepVector;
938 TPythonDump() << this << ".ExtrusionSweep( "
939 << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )";
943 //=======================================================================
944 //function : ExtrusionSweepObject
946 //=======================================================================
948 void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObject,
949 const SMESH::DirStruct & theStepVector,
950 CORBA::Long theNbOfSteps)
952 SMESH::long_array_var anElementsId = theObject->GetIDs();
953 ExtrusionSweep(anElementsId, theStepVector, theNbOfSteps);
955 // Clear python line, created by ExtrusionSweep()
956 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
957 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
959 // Update Python script
960 TPythonDump() << this << ".ExtrusionSweepObject( "
961 << theObject << ", stepVector, " << theNbOfSteps << " )";
964 //=======================================================================
965 //function : ExtrusionSweepObject1D
967 //=======================================================================
969 void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
970 const SMESH::DirStruct & theStepVector,
971 CORBA::Long theNbOfSteps)
973 SMESHDS_Mesh* aMesh = GetMeshDS();
975 SMESH::long_array_var allElementsId = theObject->GetIDs();
977 set<const SMDS_MeshElement*> elements;
978 for (int i = 0; i < allElementsId->length(); i++)
980 CORBA::Long index = allElementsId[i];
981 const SMDS_MeshElement * elem = aMesh->FindElement(index);
982 if ( elem && elem->GetType() == SMDSAbs_Edge )
983 elements.insert( elem );
985 const SMESH::PointStruct * P = &theStepVector.PS;
986 gp_Vec stepVec( P->x, P->y, P->z );
988 ::SMESH_MeshEditor anEditor( _myMesh );
989 //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
990 TElemOfElemListMap aHystory;
991 anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory);
993 // Update Python script
994 TPythonDump() << "stepVector = " << theStepVector;
995 TPythonDump() << this << ".ExtrusionSweepObject1D( "
996 << theObject << ", stepVector, " << theNbOfSteps << " )";
999 //=======================================================================
1000 //function : ExtrusionSweepObject2D
1002 //=======================================================================
1004 void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
1005 const SMESH::DirStruct & theStepVector,
1006 CORBA::Long theNbOfSteps)
1008 SMESHDS_Mesh* aMesh = GetMeshDS();
1010 SMESH::long_array_var allElementsId = theObject->GetIDs();
1012 set<const SMDS_MeshElement*> elements;
1013 for (int i = 0; i < allElementsId->length(); i++)
1015 CORBA::Long index = allElementsId[i];
1016 const SMDS_MeshElement * elem = aMesh->FindElement(index);
1017 if ( elem && elem->GetType() == SMDSAbs_Face )
1018 elements.insert( elem );
1020 const SMESH::PointStruct * P = &theStepVector.PS;
1021 gp_Vec stepVec( P->x, P->y, P->z );
1023 ::SMESH_MeshEditor anEditor( _myMesh );
1024 //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
1025 TElemOfElemListMap aHystory;
1026 anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory);
1028 // Update Python script
1029 TPythonDump() << "stepVector = " << theStepVector;
1030 TPythonDump() << this << ".ExtrusionSweepObject2D( "
1031 << theObject << ", stepVector, " << theNbOfSteps << " )";
1035 //=======================================================================
1036 //function : AdvancedExtrusion
1038 //=======================================================================
1040 void SMESH_MeshEditor_i::AdvancedExtrusion(const SMESH::long_array & theIDsOfElements,
1041 const SMESH::DirStruct & theStepVector,
1042 CORBA::Long theNbOfSteps,
1043 CORBA::Long theExtrFlags,
1044 CORBA::Double theSewTolerance)
1046 SMESHDS_Mesh* aMesh = GetMeshDS();
1048 set<const SMDS_MeshElement*> elements;
1049 for (int i = 0; i < theIDsOfElements.length(); i++)
1051 CORBA::Long index = theIDsOfElements[i];
1052 const SMDS_MeshElement * elem = aMesh->FindElement(index);
1054 elements.insert( elem );
1056 const SMESH::PointStruct * P = &theStepVector.PS;
1057 gp_Vec stepVec( P->x, P->y, P->z );
1059 ::SMESH_MeshEditor anEditor( _myMesh );
1060 TElemOfElemListMap aHystory;
1061 anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory,
1062 theExtrFlags, theSewTolerance);
1064 // Update Python script
1065 TPythonDump() << "stepVector = " << theStepVector;
1066 TPythonDump() << this << ".AdvancedExtrusion("
1069 << theNbOfSteps << ","
1070 << theExtrFlags << ", "
1071 << theSewTolerance << " )";
1075 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
1077 static SMESH::SMESH_MeshEditor::Extrusion_Error convExtrError( const::SMESH_MeshEditor::Extrusion_Error e )
1081 RETCASE( EXTR_NO_ELEMENTS );
1082 RETCASE( EXTR_PATH_NOT_EDGE );
1083 RETCASE( EXTR_BAD_PATH_SHAPE );
1084 RETCASE( EXTR_BAD_STARTING_NODE );
1085 RETCASE( EXTR_BAD_ANGLES_NUMBER );
1086 RETCASE( EXTR_CANT_GET_TANGENT );
1088 return SMESH::SMESH_MeshEditor::EXTR_OK;
1091 //=======================================================================
1092 //function : ExtrusionAlongPath
1094 //=======================================================================
1096 SMESH::SMESH_MeshEditor::Extrusion_Error
1097 SMESH_MeshEditor_i::ExtrusionAlongPath(const SMESH::long_array & theIDsOfElements,
1098 SMESH::SMESH_Mesh_ptr thePathMesh,
1099 GEOM::GEOM_Object_ptr thePathShape,
1100 CORBA::Long theNodeStart,
1101 CORBA::Boolean theHasAngles,
1102 const SMESH::double_array & theAngles,
1103 CORBA::Boolean theHasRefPoint,
1104 const SMESH::PointStruct & theRefPoint)
1106 SMESHDS_Mesh* aMesh = GetMeshDS();
1108 if ( thePathMesh->_is_nil() || thePathShape->_is_nil() )
1109 return SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
1111 SMESH_Mesh_i* aMeshImp = dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetServant( thePathMesh ).in() );
1112 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
1113 SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
1116 return SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
1118 SMDS_MeshNode* nodeStart = (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(theNodeStart);
1120 return SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
1122 set<const SMDS_MeshElement*> elements;
1123 for (int i = 0; i < theIDsOfElements.length(); i++)
1125 CORBA::Long index = theIDsOfElements[i];
1126 const SMDS_MeshElement * elem = aMesh->FindElement(index);
1128 elements.insert( elem );
1131 list<double> angles;
1132 for (int i = 0; i < theAngles.length(); i++)
1134 angles.push_back( theAngles[i] );
1137 gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z );
1139 // Update Python script
1140 TPythonDump() << "refPoint = SMESH.PointStruct( "
1141 << refPnt.X() << ", "
1142 << refPnt.Y() << ", "
1143 << refPnt.Z() << " )";
1144 TPythonDump() << "error = " << this << ".ExtrusionAlongPath( "
1145 << theIDsOfElements << ", "
1146 << thePathMesh << ", "
1147 << thePathShape << ", "
1148 << theNodeStart << ", "
1149 << theHasAngles << ", "
1150 << theAngles << ", "
1151 << theHasRefPoint << ", refPoint )";
1153 ::SMESH_MeshEditor anEditor( _myMesh );
1154 return convExtrError( anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart,
1155 theHasAngles, angles,
1156 theHasRefPoint, refPnt ) );
1159 //=======================================================================
1160 //function : ExtrusionAlongPathObject
1162 //=======================================================================
1164 SMESH::SMESH_MeshEditor::Extrusion_Error
1165 SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject,
1166 SMESH::SMESH_Mesh_ptr thePathMesh,
1167 GEOM::GEOM_Object_ptr thePathShape,
1168 CORBA::Long theNodeStart,
1169 CORBA::Boolean theHasAngles,
1170 const SMESH::double_array & theAngles,
1171 CORBA::Boolean theHasRefPoint,
1172 const SMESH::PointStruct & theRefPoint)
1174 SMESH::long_array_var anElementsId = theObject->GetIDs();
1175 SMESH::SMESH_MeshEditor::Extrusion_Error error = ExtrusionAlongPath
1176 (anElementsId, thePathMesh, thePathShape, theNodeStart,
1177 theHasAngles, theAngles, theHasRefPoint, theRefPoint);
1179 // Clear python line, created by ExtrusionAlongPath()
1180 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1181 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1183 // Update Python script
1184 TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject( "
1185 << theObject << ", "
1186 << thePathMesh << ", "
1187 << thePathShape << ", "
1188 << theNodeStart << ", "
1189 << theHasAngles << ", "
1190 << theAngles << ", "
1191 << theHasRefPoint << ", refPoint )";
1196 //=======================================================================
1199 //=======================================================================
1201 void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElements,
1202 const SMESH::AxisStruct & theAxis,
1203 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
1204 CORBA::Boolean theCopy)
1206 SMESHDS_Mesh* aMesh = GetMeshDS();
1208 set<const SMDS_MeshElement*> elements;
1209 for (int i = 0; i < theIDsOfElements.length(); i++)
1211 CORBA::Long index = theIDsOfElements[i];
1212 const SMDS_MeshElement * elem = aMesh->FindElement(index);
1214 elements.insert( elem );
1216 gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
1217 gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
1220 TCollection_AsciiString typeStr;
1221 switch ( theMirrorType ) {
1222 case SMESH::SMESH_MeshEditor::POINT:
1223 aTrsf.SetMirror( P );
1224 typeStr = "SMESH.SMESH_MeshEditor.POINT";
1226 case SMESH::SMESH_MeshEditor::AXIS:
1227 aTrsf.SetMirror( gp_Ax1( P, V ));
1228 typeStr = "SMESH.SMESH_MeshEditor.AXIS";
1231 aTrsf.SetMirror( gp_Ax2( P, V ));
1232 typeStr = "SMESH.SMESH_MeshEditor.PLANE";
1235 // Update Python script
1236 TPythonDump() << this << ".Mirror( "
1237 << theIDsOfElements << ", "
1242 ::SMESH_MeshEditor anEditor( _myMesh );
1243 anEditor.Transform (elements, aTrsf, theCopy);
1246 //=======================================================================
1247 //function : MirrorObject
1249 //=======================================================================
1251 void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObject,
1252 const SMESH::AxisStruct & theAxis,
1253 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
1254 CORBA::Boolean theCopy)
1256 SMESH::long_array_var anElementsId = theObject->GetIDs();
1257 Mirror(anElementsId, theAxis, theMirrorType, theCopy);
1259 // Clear python line, created by Mirror()
1260 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1261 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1263 // Update Python script
1264 TCollection_AsciiString typeStr;
1265 switch ( theMirrorType ) {
1266 case SMESH::SMESH_MeshEditor::POINT:
1267 typeStr = "SMESH.SMESH_MeshEditor.POINT";
1269 case SMESH::SMESH_MeshEditor::AXIS:
1270 typeStr = "SMESH.SMESH_MeshEditor.AXIS";
1273 typeStr = "SMESH.SMESH_MeshEditor.PLANE";
1275 TPythonDump() << "axis = " << theAxis;
1276 TPythonDump() << this << ".MirrorObject( "
1277 << theObject << ", "
1283 //=======================================================================
1284 //function : Translate
1286 //=======================================================================
1288 void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements,
1289 const SMESH::DirStruct & theVector,
1290 CORBA::Boolean theCopy)
1292 SMESHDS_Mesh* aMesh = GetMeshDS();
1294 set<const SMDS_MeshElement*> elements;
1295 for (int i = 0; i < theIDsOfElements.length(); i++)
1297 CORBA::Long index = theIDsOfElements[i];
1298 const SMDS_MeshElement * elem = aMesh->FindElement(index);
1300 elements.insert( elem );
1303 const SMESH::PointStruct * P = &theVector.PS;
1304 aTrsf.SetTranslation( gp_Vec( P->x, P->y, P->z ));
1306 ::SMESH_MeshEditor anEditor( _myMesh );
1307 anEditor.Transform (elements, aTrsf, theCopy);
1309 // Update Python script
1310 TPythonDump() << "vector = " << theVector;
1311 TPythonDump() << this << ".Translate( "
1317 //=======================================================================
1318 //function : TranslateObject
1320 //=======================================================================
1322 void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject,
1323 const SMESH::DirStruct & theVector,
1324 CORBA::Boolean theCopy)
1326 SMESH::long_array_var anElementsId = theObject->GetIDs();
1327 Translate(anElementsId, theVector, theCopy);
1329 // Clear python line, created by Translate()
1330 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1331 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1333 // Update Python script
1334 TPythonDump() << this << ".TranslateObject( "
1340 //=======================================================================
1343 //=======================================================================
1345 void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements,
1346 const SMESH::AxisStruct & theAxis,
1347 CORBA::Double theAngle,
1348 CORBA::Boolean theCopy)
1350 SMESHDS_Mesh* aMesh = GetMeshDS();
1352 set<const SMDS_MeshElement*> elements;
1353 for (int i = 0; i < theIDsOfElements.length(); i++)
1355 CORBA::Long index = theIDsOfElements[i];
1356 const SMDS_MeshElement * elem = aMesh->FindElement(index);
1358 elements.insert( elem );
1360 gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
1361 gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
1364 aTrsf.SetRotation( gp_Ax1( P, V ), theAngle);
1366 ::SMESH_MeshEditor anEditor( _myMesh );
1367 anEditor.Transform (elements, aTrsf, theCopy);
1369 // Update Python script
1370 TPythonDump() << "axis = " << theAxis;
1371 TPythonDump() << this << ".Rotate( "
1378 //=======================================================================
1379 //function : RotateObject
1381 //=======================================================================
1383 void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject,
1384 const SMESH::AxisStruct & theAxis,
1385 CORBA::Double theAngle,
1386 CORBA::Boolean theCopy)
1388 SMESH::long_array_var anElementsId = theObject->GetIDs();
1389 Rotate(anElementsId, theAxis, theAngle, theCopy);
1391 // Clear python line, created by Rotate()
1392 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1393 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1395 // Update Python script
1396 TPythonDump() << this << ".RotateObject( "
1403 //=======================================================================
1404 //function : FindCoincidentNodes
1406 //=======================================================================
1408 void SMESH_MeshEditor_i::FindCoincidentNodes (CORBA::Double Tolerance,
1409 SMESH::array_of_long_array_out GroupsOfNodes)
1411 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
1412 ::SMESH_MeshEditor anEditor( _myMesh );
1413 set<const SMDS_MeshNode*> nodes; // no input nodes
1414 anEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
1416 GroupsOfNodes = new SMESH::array_of_long_array;
1417 GroupsOfNodes->length( aListOfListOfNodes.size() );
1418 ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
1419 for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ )
1421 list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
1422 list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
1423 SMESH::long_array& aGroup = GroupsOfNodes[ i ];
1424 aGroup.length( aListOfNodes.size() );
1425 for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
1426 aGroup[ j ] = (*lIt)->GetID();
1428 // Update Python script
1429 TPythonDump() << "coincident_nodes = " << this << ".FindCoincidentNodes( "
1430 << Tolerance << " )";
1433 //=======================================================================
1434 //function : MergeNodes
1436 //=======================================================================
1438 void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes)
1440 SMESHDS_Mesh* aMesh = GetMeshDS();
1442 TPythonDump aTPythonDump;
1443 aTPythonDump << this << ".MergeNodes([";
1444 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
1445 for (int i = 0; i < GroupsOfNodes.length(); i++)
1447 const SMESH::long_array& aNodeGroup = GroupsOfNodes[ i ];
1448 aListOfListOfNodes.push_back( list< const SMDS_MeshNode* >() );
1449 list< const SMDS_MeshNode* >& aListOfNodes = aListOfListOfNodes.back();
1450 for ( int j = 0; j < aNodeGroup.length(); j++ )
1452 CORBA::Long index = aNodeGroup[ j ];
1453 const SMDS_MeshNode * node = aMesh->FindNode(index);
1455 aListOfNodes.push_back( node );
1457 if ( aListOfNodes.size() < 2 )
1458 aListOfListOfNodes.pop_back();
1460 if ( i > 0 ) aTPythonDump << ", ";
1461 aTPythonDump << aNodeGroup;
1463 ::SMESH_MeshEditor anEditor( _myMesh );
1464 anEditor.MergeNodes( aListOfListOfNodes );
1466 // Update Python script
1467 aTPythonDump << "])";
1470 //=======================================================================
1471 //function : MergeEqualElements
1473 //=======================================================================
1475 void SMESH_MeshEditor_i::MergeEqualElements()
1477 ::SMESH_MeshEditor anEditor( _myMesh );
1478 anEditor.MergeEqualElements();
1480 // Update Python script
1481 TPythonDump() << this << ".MergeEqualElements()";
1484 //=======================================================================
1485 //function : operator
1487 //=======================================================================
1489 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
1491 static SMESH::SMESH_MeshEditor::Sew_Error convError( const::SMESH_MeshEditor::Sew_Error e )
1495 RETCASE( SEW_BORDER1_NOT_FOUND );
1496 RETCASE( SEW_BORDER2_NOT_FOUND );
1497 RETCASE( SEW_BOTH_BORDERS_NOT_FOUND );
1498 RETCASE( SEW_BAD_SIDE_NODES );
1499 RETCASE( SEW_VOLUMES_TO_SPLIT );
1500 RETCASE( SEW_DIFF_NB_OF_ELEMENTS );
1501 RETCASE( SEW_TOPO_DIFF_SETS_OF_ELEMENTS );
1502 RETCASE( SEW_BAD_SIDE1_NODES );
1503 RETCASE( SEW_BAD_SIDE2_NODES );
1505 return SMESH::SMESH_MeshEditor::SEW_OK;
1508 //=======================================================================
1509 //function : SewFreeBorders
1511 //=======================================================================
1513 SMESH::SMESH_MeshEditor::Sew_Error
1514 SMESH_MeshEditor_i::SewFreeBorders(CORBA::Long FirstNodeID1,
1515 CORBA::Long SecondNodeID1,
1516 CORBA::Long LastNodeID1,
1517 CORBA::Long FirstNodeID2,
1518 CORBA::Long SecondNodeID2,
1519 CORBA::Long LastNodeID2,
1520 CORBA::Boolean CreatePolygons,
1521 CORBA::Boolean CreatePolyedrs)
1523 SMESHDS_Mesh* aMesh = GetMeshDS();
1525 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
1526 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
1527 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
1528 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
1529 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
1530 const SMDS_MeshNode* aSide2ThirdNode = aMesh->FindNode( LastNodeID2 );
1532 if (!aBorderFirstNode ||
1533 !aBorderSecondNode||
1535 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
1536 if (!aSide2FirstNode ||
1537 !aSide2SecondNode ||
1539 return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
1541 // Update Python script
1542 TPythonDump() << "error = " << this << ".SewFreeBorders( "
1543 << FirstNodeID1 << ", "
1544 << SecondNodeID1 << ", "
1545 << LastNodeID1 << ", "
1546 << FirstNodeID2 << ", "
1547 << SecondNodeID2 << ", "
1548 << LastNodeID2 << ", "
1549 << CreatePolygons<< ", "
1550 << CreatePolyedrs<< " )";
1552 ::SMESH_MeshEditor anEditor( _myMesh );
1553 return convError( anEditor.SewFreeBorder (aBorderFirstNode,
1564 //=======================================================================
1565 //function : SewConformFreeBorders
1567 //=======================================================================
1569 SMESH::SMESH_MeshEditor::Sew_Error
1570 SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1,
1571 CORBA::Long SecondNodeID1,
1572 CORBA::Long LastNodeID1,
1573 CORBA::Long FirstNodeID2,
1574 CORBA::Long SecondNodeID2)
1576 SMESHDS_Mesh* aMesh = GetMeshDS();
1578 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
1579 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
1580 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
1581 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
1582 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
1583 const SMDS_MeshNode* aSide2ThirdNode = 0;
1585 if (!aBorderFirstNode ||
1586 !aBorderSecondNode||
1588 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
1589 if (!aSide2FirstNode ||
1591 return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
1593 // Update Python script
1594 TPythonDump() << "error = " << this << ".SewConformFreeBorders( "
1595 << FirstNodeID1 << ", "
1596 << SecondNodeID1 << ", "
1597 << LastNodeID1 << ", "
1598 << FirstNodeID2 << ", "
1599 << SecondNodeID2 << " )";
1601 ::SMESH_MeshEditor anEditor( _myMesh );
1602 return convError( anEditor.SewFreeBorder (aBorderFirstNode,
1612 //=======================================================================
1613 //function : SewBorderToSide
1615 //=======================================================================
1617 SMESH::SMESH_MeshEditor::Sew_Error
1618 SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder,
1619 CORBA::Long SecondNodeIDOnFreeBorder,
1620 CORBA::Long LastNodeIDOnFreeBorder,
1621 CORBA::Long FirstNodeIDOnSide,
1622 CORBA::Long LastNodeIDOnSide,
1623 CORBA::Boolean CreatePolygons,
1624 CORBA::Boolean CreatePolyedrs)
1626 SMESHDS_Mesh* aMesh = GetMeshDS();
1628 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeIDOnFreeBorder );
1629 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeIDOnFreeBorder );
1630 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeIDOnFreeBorder );
1631 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeIDOnSide );
1632 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( LastNodeIDOnSide );
1633 const SMDS_MeshNode* aSide2ThirdNode = 0;
1635 if (!aBorderFirstNode ||
1636 !aBorderSecondNode||
1638 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
1639 if (!aSide2FirstNode ||
1641 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE_NODES;
1643 // Update Python script
1644 TPythonDump() << "error = " << this << ".SewBorderToSide( "
1645 << FirstNodeIDOnFreeBorder << ", "
1646 << SecondNodeIDOnFreeBorder << ", "
1647 << LastNodeIDOnFreeBorder << ", "
1648 << FirstNodeIDOnSide << ", "
1649 << LastNodeIDOnSide << ", "
1650 << CreatePolygons << ", "
1651 << CreatePolyedrs << ") ";
1653 ::SMESH_MeshEditor anEditor( _myMesh );
1654 return convError( anEditor.SewFreeBorder (aBorderFirstNode,
1665 //=======================================================================
1666 //function : SewSideElements
1668 //=======================================================================
1670 SMESH::SMESH_MeshEditor::Sew_Error
1671 SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements,
1672 const SMESH::long_array& IDsOfSide2Elements,
1673 CORBA::Long NodeID1OfSide1ToMerge,
1674 CORBA::Long NodeID1OfSide2ToMerge,
1675 CORBA::Long NodeID2OfSide1ToMerge,
1676 CORBA::Long NodeID2OfSide2ToMerge)
1678 SMESHDS_Mesh* aMesh = GetMeshDS();
1680 const SMDS_MeshNode* aFirstNode1ToMerge = aMesh->FindNode( NodeID1OfSide1ToMerge );
1681 const SMDS_MeshNode* aFirstNode2ToMerge = aMesh->FindNode( NodeID1OfSide2ToMerge );
1682 const SMDS_MeshNode* aSecondNode1ToMerge = aMesh->FindNode( NodeID2OfSide1ToMerge );
1683 const SMDS_MeshNode* aSecondNode2ToMerge = aMesh->FindNode( NodeID2OfSide2ToMerge );
1685 if (!aFirstNode1ToMerge ||
1686 !aFirstNode2ToMerge )
1687 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE1_NODES;
1688 if (!aSecondNode1ToMerge||
1689 !aSecondNode2ToMerge)
1690 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE2_NODES;
1692 set<const SMDS_MeshElement*> aSide1Elems, aSide2Elems;
1693 for (int i = 0; i < IDsOfSide1Elements.length(); i++)
1695 CORBA::Long index = IDsOfSide1Elements[i];
1696 const SMDS_MeshElement * elem = aMesh->FindElement(index);
1698 aSide1Elems.insert( elem );
1700 for (int i = 0; i < IDsOfSide2Elements.length(); i++)
1702 CORBA::Long index = IDsOfSide2Elements[i];
1703 const SMDS_MeshElement * elem = aMesh->FindElement(index);
1705 aSide2Elems.insert( elem );
1707 // Update Python script
1708 TPythonDump() << "error = " << this << ".SewSideElements( "
1709 << IDsOfSide1Elements << ", "
1710 << IDsOfSide2Elements << ", "
1711 << NodeID1OfSide1ToMerge << ", "
1712 << NodeID1OfSide2ToMerge << ", "
1713 << NodeID2OfSide1ToMerge << ", "
1714 << NodeID2OfSide2ToMerge << ")";
1716 ::SMESH_MeshEditor anEditor( _myMesh );
1717 return convError( anEditor.SewSideElements (aSide1Elems, aSide2Elems,
1720 aSecondNode1ToMerge,
1721 aSecondNode2ToMerge));