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 <<" ])";
134 //=============================================================================
138 //=============================================================================
140 CORBA::Boolean SMESH_MeshEditor_i::AddNode(CORBA::Double x,
141 CORBA::Double y, CORBA::Double z)
143 GetMeshDS()->AddNode(x, y, z);
145 // Update Python script
146 TPythonDump() << "isDone = " << this << ".AddNode( "
147 << x << ", " << y << ", " << z << " )";
152 //=============================================================================
156 //=============================================================================
158 CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
160 int NbNodes = IDsOfNodes.length();
166 std::vector<const SMDS_MeshNode*> nodes (NbNodes);
167 for (int i = 0; i < NbNodes; i++)
168 nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
172 GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]);
174 else if (NbNodes == 4)
176 GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
180 GetMeshDS()->AddPolygonalFace(nodes);
183 // Update Python script
184 TPythonDump() << "isDone = " << this << ".AddFace( " << IDsOfNodes << " )";
186 TPythonDump() << "print 'AddFace: ', isDone";
192 //=============================================================================
196 //=============================================================================
198 CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH::long_array & IDsOfNodes)
200 int NbNodes = IDsOfNodes.length();
201 vector< const SMDS_MeshNode*> n(NbNodes);
202 for(int i=0;i<NbNodes;i++)
203 n[i]=GetMeshDS()->FindNode(IDsOfNodes[i]);
207 case 4:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3]); break;
208 case 5:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4]); break;
209 case 6:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5]); break;
210 case 8:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break;
212 // Update Python script
213 TPythonDump() << "isDone = " << this << ".AddVolume( " << IDsOfNodes << " )";
215 TPythonDump() << "print 'AddVolume: ', isDone";
221 //=============================================================================
223 * AddPolyhedralVolume
225 //=============================================================================
226 CORBA::Boolean SMESH_MeshEditor_i::AddPolyhedralVolume
227 (const SMESH::long_array & IDsOfNodes,
228 const SMESH::long_array & Quantities)
230 int NbNodes = IDsOfNodes.length();
231 std::vector<const SMDS_MeshNode*> n (NbNodes);
232 for (int i = 0; i < NbNodes; i++)
233 n[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
235 int NbFaces = Quantities.length();
236 std::vector<int> q (NbFaces);
237 for (int j = 0; j < NbFaces; j++)
238 q[j] = Quantities[j];
240 GetMeshDS()->AddPolyhedralVolume(n, q);
242 // Update Python script
243 TPythonDump() << "isDone = " << this << ".AddPolyhedralVolume( "
244 << IDsOfNodes << ", " << Quantities << " )";
246 TPythonDump() << "print 'AddPolyhedralVolume: ', isDone";
252 //=============================================================================
254 * AddPolyhedralVolumeByFaces
256 //=============================================================================
257 CORBA::Boolean SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces
258 (const SMESH::long_array & IdsOfFaces)
260 int NbFaces = IdsOfFaces.length();
261 std::vector<const SMDS_MeshNode*> poly_nodes;
262 std::vector<int> quantities (NbFaces);
264 for (int i = 0; i < NbFaces; i++) {
265 const SMDS_MeshElement* aFace = GetMeshDS()->FindElement(IdsOfFaces[i]);
266 quantities[i] = aFace->NbNodes();
268 SMDS_ElemIteratorPtr It = aFace->nodesIterator();
270 poly_nodes.push_back(static_cast<const SMDS_MeshNode *>(It->next()));
274 GetMeshDS()->AddPolyhedralVolume(poly_nodes, quantities);
276 // Update Python script
277 TPythonDump() << "isDone = " << this << ".AddPolyhedralVolumeByFaces( "
278 << IdsOfFaces << " )";
280 TPythonDump() << "print 'AddPolyhedralVolume: ', isDone";
286 //=============================================================================
290 //=============================================================================
292 CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long NodeID,
297 const SMDS_MeshNode * node = GetMeshDS()->FindNode( NodeID );
301 GetMeshDS()->MoveNode(node, x, y, z);
303 // Update Python script
304 TPythonDump() << "isDone = " << this << ".MoveNode( "
305 << NodeID << ", " << x << ", " << y << ", " << z << " )";
310 //=============================================================================
314 //=============================================================================
316 CORBA::Boolean SMESH_MeshEditor_i::InverseDiag(CORBA::Long NodeID1,
319 const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
320 const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
324 // Update Python script
325 TPythonDump() << "isDone = " << this << ".InverseDiag( "
326 << NodeID1 << ", " << NodeID2 << " )";
328 ::SMESH_MeshEditor aMeshEditor( _myMesh );
329 return aMeshEditor.InverseDiag ( n1, n2 );
332 //=============================================================================
336 //=============================================================================
338 CORBA::Boolean SMESH_MeshEditor_i::DeleteDiag(CORBA::Long NodeID1,
341 const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
342 const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
346 // Update Python script
347 TPythonDump() << "isDone = " << this << ".DeleteDiag( "
348 << NodeID1 << ", " << NodeID2 << " )";
350 ::SMESH_MeshEditor aMeshEditor( _myMesh );
351 return aMeshEditor.DeleteDiag ( n1, n2 );
354 //=============================================================================
358 //=============================================================================
360 CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::long_array & IDsOfElements)
362 ::SMESH_MeshEditor anEditor( _myMesh );
363 for (int i = 0; i < IDsOfElements.length(); i++)
365 CORBA::Long index = IDsOfElements[i];
366 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
368 anEditor.Reorient( elem );
370 // Update Python script
371 TPythonDump() << "isDone = " << this << ".Reorient( " << IDsOfElements << " )";
377 //=============================================================================
381 //=============================================================================
383 CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theObject)
385 SMESH::long_array_var anElementsId = theObject->GetIDs();
386 CORBA::Boolean isDone = Reorient(anElementsId);
388 // Clear python line, created by Reorient()
389 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
390 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
392 // Update Python script
393 TPythonDump() << "isDone = " << this << ".ReorientObject( " << theObject << " )";
398 //=============================================================================
402 //=============================================================================
403 CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfElements,
404 SMESH::NumericalFunctor_ptr Criterion,
405 CORBA::Double MaxAngle)
407 set<const SMDS_MeshElement*> faces;
408 for (int i = 0; i < IDsOfElements.length(); i++)
410 CORBA::Long index = IDsOfElements[i];
411 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
412 if ( elem && elem->GetType() == SMDSAbs_Face)
413 faces.insert( elem );
415 SMESH::NumericalFunctor_i* aNumericalFunctor =
416 dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
417 SMESH::Controls::NumericalFunctorPtr aCrit;
418 if ( !aNumericalFunctor )
419 aCrit.reset( new SMESH::Controls::AspectRatio() );
421 aCrit = aNumericalFunctor->GetNumericalFunctor();
423 // Update Python script
424 TPythonDump() << "isDone = " << this << ".TriToQuad( "
425 << IDsOfElements << ", None, " << MaxAngle << " )";
427 TPythonDump() << "print 'TriToQuad: ', isDone";
430 ::SMESH_MeshEditor anEditor( _myMesh );
431 return anEditor.TriToQuad( faces, aCrit, MaxAngle );
434 //=============================================================================
438 //=============================================================================
439 CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr theObject,
440 SMESH::NumericalFunctor_ptr Criterion,
441 CORBA::Double MaxAngle)
443 SMESH::long_array_var anElementsId = theObject->GetIDs();
444 CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
446 // Clear python line(s), created by TriToQuad()
447 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
448 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
450 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
453 // Update Python script
454 TPythonDump() << "isDone = " << this << ".TriToQuadObject("
455 << theObject << ", None, " << MaxAngle << " )";
457 TPythonDump() << "print 'TriToQuadObject: ', isDone";
463 //=============================================================================
467 //=============================================================================
468 CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array & IDsOfElements,
469 SMESH::NumericalFunctor_ptr Criterion)
471 set<const SMDS_MeshElement*> faces;
472 for (int i = 0; i < IDsOfElements.length(); i++)
474 CORBA::Long index = IDsOfElements[i];
475 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
476 if ( elem && elem->GetType() == SMDSAbs_Face)
477 faces.insert( elem );
479 SMESH::NumericalFunctor_i* aNumericalFunctor =
480 dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
481 SMESH::Controls::NumericalFunctorPtr aCrit;
482 if ( !aNumericalFunctor )
483 aCrit.reset( new SMESH::Controls::AspectRatio() );
485 aCrit = aNumericalFunctor->GetNumericalFunctor();
488 // Update Python script
489 TPythonDump() << "isDone = " << this << ".QuadToTri( " << IDsOfElements << ", None )";
491 TPythonDump() << "print 'QuadToTri: ', isDone";
494 ::SMESH_MeshEditor anEditor( _myMesh );
495 return anEditor.QuadToTri( faces, aCrit );
498 //=============================================================================
502 //=============================================================================
503 CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr theObject,
504 SMESH::NumericalFunctor_ptr Criterion)
506 SMESH::long_array_var anElementsId = theObject->GetIDs();
507 CORBA::Boolean isDone = QuadToTri(anElementsId, Criterion);
509 // Clear python line(s), created by QuadToTri()
510 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
511 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
513 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
516 // Update Python script
517 TPythonDump() << "isDone = " << this << ".QuadToTriObject(" << theObject << ", None )";
519 TPythonDump() << "print 'QuadToTriObject: ', isDone";
525 //=============================================================================
529 //=============================================================================
530 CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfElements,
531 CORBA::Boolean Diag13)
533 set<const SMDS_MeshElement*> faces;
534 for (int i = 0; i < IDsOfElements.length(); i++)
536 CORBA::Long index = IDsOfElements[i];
537 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
538 if ( elem && elem->GetType() == SMDSAbs_Face)
539 faces.insert( elem );
542 // Update Python script
543 TPythonDump() << "isDone = " << this << ".SplitQuad( "
544 << IDsOfElements << ", " << Diag13 << " )";
546 TPythonDump() << "print 'SplitQuad: ', isDone";
549 ::SMESH_MeshEditor anEditor( _myMesh );
550 return anEditor.QuadToTri( faces, Diag13 );
553 //=============================================================================
557 //=============================================================================
558 CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr theObject,
559 CORBA::Boolean Diag13)
561 SMESH::long_array_var anElementsId = theObject->GetIDs();
562 CORBA::Boolean isDone = SplitQuad(anElementsId, Diag13);
564 // Clear python line(s), created by SplitQuad()
565 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
566 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
568 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
571 // Update Python script
572 TPythonDump() << "isDone = " << this << ".SplitQuadObject( "
573 << theObject << ", " << Diag13 << " )";
575 TPythonDump() << "print 'SplitQuadObject: ', isDone";
581 //=============================================================================
585 //=============================================================================
586 CORBA::Long SMESH_MeshEditor_i::BestSplit (CORBA::Long IDOfQuad,
587 SMESH::NumericalFunctor_ptr Criterion)
589 const SMDS_MeshElement* quad = GetMeshDS()->FindElement(IDOfQuad);
590 if (quad && quad->GetType() == SMDSAbs_Face && quad->NbNodes() == 4)
592 SMESH::NumericalFunctor_i* aNumericalFunctor =
593 dynamic_cast<SMESH::NumericalFunctor_i*>(SMESH_Gen_i::GetServant(Criterion).in());
594 SMESH::Controls::NumericalFunctorPtr aCrit;
595 if (aNumericalFunctor)
596 aCrit = aNumericalFunctor->GetNumericalFunctor();
598 aCrit.reset(new SMESH::Controls::AspectRatio());
600 ::SMESH_MeshEditor anEditor (_myMesh);
601 return anEditor.BestSplit(quad, aCrit);
606 //=======================================================================
609 //=======================================================================
612 SMESH_MeshEditor_i::Smooth(const SMESH::long_array & IDsOfElements,
613 const SMESH::long_array & IDsOfFixedNodes,
614 CORBA::Long MaxNbOfIterations,
615 CORBA::Double MaxAspectRatio,
616 SMESH::SMESH_MeshEditor::Smooth_Method Method)
618 return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations,
619 MaxAspectRatio, Method, false );
622 //=======================================================================
623 //function : SmoothParametric
625 //=======================================================================
628 SMESH_MeshEditor_i::SmoothParametric(const SMESH::long_array & IDsOfElements,
629 const SMESH::long_array & IDsOfFixedNodes,
630 CORBA::Long MaxNbOfIterations,
631 CORBA::Double MaxAspectRatio,
632 SMESH::SMESH_MeshEditor::Smooth_Method Method)
634 return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations,
635 MaxAspectRatio, Method, true );
638 //=======================================================================
639 //function : SmoothObject
641 //=======================================================================
644 SMESH_MeshEditor_i::SmoothObject(SMESH::SMESH_IDSource_ptr theObject,
645 const SMESH::long_array & IDsOfFixedNodes,
646 CORBA::Long MaxNbOfIterations,
647 CORBA::Double MaxAspectRatio,
648 SMESH::SMESH_MeshEditor::Smooth_Method Method)
650 return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations,
651 MaxAspectRatio, Method, false);
654 //=======================================================================
655 //function : SmoothParametricObject
657 //=======================================================================
660 SMESH_MeshEditor_i::SmoothParametricObject(SMESH::SMESH_IDSource_ptr theObject,
661 const SMESH::long_array & IDsOfFixedNodes,
662 CORBA::Long MaxNbOfIterations,
663 CORBA::Double MaxAspectRatio,
664 SMESH::SMESH_MeshEditor::Smooth_Method Method)
666 return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations,
667 MaxAspectRatio, Method, true);
670 //=============================================================================
674 //=============================================================================
677 SMESH_MeshEditor_i::smooth(const SMESH::long_array & IDsOfElements,
678 const SMESH::long_array & IDsOfFixedNodes,
679 CORBA::Long MaxNbOfIterations,
680 CORBA::Double MaxAspectRatio,
681 SMESH::SMESH_MeshEditor::Smooth_Method Method,
684 SMESHDS_Mesh* aMesh = GetMeshDS();
686 set<const SMDS_MeshElement*> elements;
687 for (int i = 0; i < IDsOfElements.length(); i++)
689 CORBA::Long index = IDsOfElements[i];
690 const SMDS_MeshElement * elem = aMesh->FindElement(index);
691 if ( elem && elem->GetType() == SMDSAbs_Face)
692 elements.insert( elem );
695 set<const SMDS_MeshNode*> fixedNodes;
696 for (int i = 0; i < IDsOfFixedNodes.length(); i++)
698 CORBA::Long index = IDsOfFixedNodes[i];
699 const SMDS_MeshNode * node = aMesh->FindNode(index);
701 fixedNodes.insert( node );
703 ::SMESH_MeshEditor::SmoothMethod method = ::SMESH_MeshEditor::LAPLACIAN;
704 if ( Method != SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH )
705 method = ::SMESH_MeshEditor::CENTROIDAL;
707 ::SMESH_MeshEditor anEditor( _myMesh );
708 anEditor.Smooth(elements, fixedNodes, method,
709 MaxNbOfIterations, MaxAspectRatio, IsParametric );
711 // Update Python script
712 TPythonDump() << "isDone = " << this << "."
713 << (IsParametric ? "SmoothParametric( " : "Smooth( ")
714 << IDsOfElements << ", " << IDsOfFixedNodes << ", "
715 << MaxNbOfIterations << ", " << MaxAspectRatio << ", "
716 << "SMESH.SMESH_MeshEditor."
717 << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
718 "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
720 TPythonDump() << "print 'Smooth: ', isDone";
726 //=============================================================================
730 //=============================================================================
733 SMESH_MeshEditor_i::smoothObject(SMESH::SMESH_IDSource_ptr theObject,
734 const SMESH::long_array & IDsOfFixedNodes,
735 CORBA::Long MaxNbOfIterations,
736 CORBA::Double MaxAspectRatio,
737 SMESH::SMESH_MeshEditor::Smooth_Method Method,
740 SMESH::long_array_var anElementsId = theObject->GetIDs();
741 CORBA::Boolean isDone = smooth (anElementsId, IDsOfFixedNodes, MaxNbOfIterations,
742 MaxAspectRatio, Method, IsParametric);
744 // Clear python line(s), created by Smooth()
745 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
746 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
748 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
751 // Update Python script
752 TPythonDump() << "isDone = " << this << "."
753 << (IsParametric ? "SmoothParametricObject( " : "SmoothObject( ")
754 << theObject << ", " << IDsOfFixedNodes << ", "
755 << MaxNbOfIterations << ", " << MaxAspectRatio << ", "
756 << "SMESH.SMESH_MeshEditor."
757 << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
758 "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
760 TPythonDump() << "print 'SmoothObject: ', isDone";
766 //=============================================================================
770 //=============================================================================
772 void SMESH_MeshEditor_i::RenumberNodes()
774 // Update Python script
775 TPythonDump() << this << ".RenumberNodes()";
777 GetMeshDS()->Renumber( true );
780 //=============================================================================
784 //=============================================================================
786 void SMESH_MeshEditor_i::RenumberElements()
788 // Update Python script
789 TPythonDump() << this << ".RenumberElements()";
791 GetMeshDS()->Renumber( false );
794 //=======================================================================
795 //function : RotationSweep
797 //=======================================================================
799 void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElements,
800 const SMESH::AxisStruct & theAxis,
801 CORBA::Double theAngleInRadians,
802 CORBA::Long theNbOfSteps,
803 CORBA::Double theTolerance)
805 SMESHDS_Mesh* aMesh = GetMeshDS();
807 set<const SMDS_MeshElement*> elements;
808 for (int i = 0; i < theIDsOfElements.length(); i++)
810 CORBA::Long index = theIDsOfElements[i];
811 const SMDS_MeshElement * elem = aMesh->FindElement(index);
813 elements.insert( elem );
815 gp_Ax1 Ax1 (gp_Pnt( theAxis.x, theAxis.y, theAxis.z ),
816 gp_Vec( theAxis.vx, theAxis.vy, theAxis.vz ));
818 ::SMESH_MeshEditor anEditor( _myMesh );
819 anEditor.RotationSweep (elements, Ax1, theAngleInRadians,
820 theNbOfSteps, theTolerance);
822 // Update Python script
823 TPythonDump() << "axis = " << theAxis;
824 TPythonDump() << this << ".RotationSweep( "
827 << theAngleInRadians << ", "
828 << theNbOfSteps << ", "
829 << theTolerance << " )";
832 //=======================================================================
833 //function : RotationSweepObject
835 //=======================================================================
837 void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject,
838 const SMESH::AxisStruct & theAxis,
839 CORBA::Double theAngleInRadians,
840 CORBA::Long theNbOfSteps,
841 CORBA::Double theTolerance)
843 SMESH::long_array_var anElementsId = theObject->GetIDs();
844 RotationSweep(anElementsId, theAxis, theAngleInRadians, theNbOfSteps, theTolerance);
846 // Clear python line, created by RotationSweep()
847 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
848 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
850 // Update Python script
851 TPythonDump() << this << ".RotationSweepObject( "
854 << theAngleInRadians << ", "
855 << theNbOfSteps << ", "
856 << theTolerance << " )";
859 //=======================================================================
860 //function : ExtrusionSweep
862 //=======================================================================
864 void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElements,
865 const SMESH::DirStruct & theStepVector,
866 CORBA::Long theNbOfSteps)
868 SMESHDS_Mesh* aMesh = GetMeshDS();
870 set<const SMDS_MeshElement*> elements;
871 for (int i = 0; i < theIDsOfElements.length(); i++)
873 CORBA::Long index = theIDsOfElements[i];
874 const SMDS_MeshElement * elem = aMesh->FindElement(index);
876 elements.insert( elem );
878 const SMESH::PointStruct * P = &theStepVector.PS;
879 gp_Vec stepVec( P->x, P->y, P->z );
881 ::SMESH_MeshEditor anEditor( _myMesh );
882 //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
883 TElemOfElemListMap aHystory;
884 anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory);
886 // Update Python script
887 TPythonDump() << "stepVector = " << theStepVector;
888 TPythonDump() << this << ".ExtrusionSweep( "
889 << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )";
893 //=======================================================================
894 //function : ExtrusionSweepObject
896 //=======================================================================
898 void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObject,
899 const SMESH::DirStruct & theStepVector,
900 CORBA::Long theNbOfSteps)
902 SMESH::long_array_var anElementsId = theObject->GetIDs();
903 ExtrusionSweep(anElementsId, theStepVector, theNbOfSteps);
905 // Clear python line, created by ExtrusionSweep()
906 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
907 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
909 // Update Python script
910 TPythonDump() << this << ".ExtrusionSweepObject( "
911 << theObject << ", stepVector, " << theNbOfSteps << " )";
914 //=======================================================================
915 //function : ExtrusionSweepObject1D
917 //=======================================================================
919 void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
920 const SMESH::DirStruct & theStepVector,
921 CORBA::Long theNbOfSteps)
923 SMESHDS_Mesh* aMesh = GetMeshDS();
925 SMESH::long_array_var allElementsId = theObject->GetIDs();
927 set<const SMDS_MeshElement*> elements;
928 for (int i = 0; i < allElementsId->length(); i++)
930 CORBA::Long index = allElementsId[i];
931 const SMDS_MeshElement * elem = aMesh->FindElement(index);
932 if ( elem && elem->GetType() == SMDSAbs_Edge )
933 elements.insert( elem );
935 const SMESH::PointStruct * P = &theStepVector.PS;
936 gp_Vec stepVec( P->x, P->y, P->z );
938 ::SMESH_MeshEditor anEditor( _myMesh );
939 //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
940 TElemOfElemListMap aHystory;
941 anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory);
943 // Update Python script
944 TPythonDump() << "stepVector = " << theStepVector;
945 TPythonDump() << this << ".ExtrusionSweepObject1D( "
946 << theObject << ", stepVector, " << theNbOfSteps << " )";
949 //=======================================================================
950 //function : ExtrusionSweepObject2D
952 //=======================================================================
954 void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
955 const SMESH::DirStruct & theStepVector,
956 CORBA::Long theNbOfSteps)
958 SMESHDS_Mesh* aMesh = GetMeshDS();
960 SMESH::long_array_var allElementsId = theObject->GetIDs();
962 set<const SMDS_MeshElement*> elements;
963 for (int i = 0; i < allElementsId->length(); i++)
965 CORBA::Long index = allElementsId[i];
966 const SMDS_MeshElement * elem = aMesh->FindElement(index);
967 if ( elem && elem->GetType() == SMDSAbs_Face )
968 elements.insert( elem );
970 const SMESH::PointStruct * P = &theStepVector.PS;
971 gp_Vec stepVec( P->x, P->y, P->z );
973 ::SMESH_MeshEditor anEditor( _myMesh );
974 //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
975 TElemOfElemListMap aHystory;
976 anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory);
978 // Update Python script
979 TPythonDump() << "stepVector = " << theStepVector;
980 TPythonDump() << this << ".ExtrusionSweepObject2D( "
981 << theObject << ", stepVector, " << theNbOfSteps << " )";
985 //=======================================================================
986 //function : AdvancedExtrusion
988 //=======================================================================
990 void SMESH_MeshEditor_i::AdvancedExtrusion(const SMESH::long_array & theIDsOfElements,
991 const SMESH::DirStruct & theStepVector,
992 CORBA::Long theNbOfSteps,
993 CORBA::Long theExtrFlags,
994 CORBA::Double theSewTolerance)
996 SMESHDS_Mesh* aMesh = GetMeshDS();
998 set<const SMDS_MeshElement*> elements;
999 for (int i = 0; i < theIDsOfElements.length(); i++)
1001 CORBA::Long index = theIDsOfElements[i];
1002 const SMDS_MeshElement * elem = aMesh->FindElement(index);
1004 elements.insert( elem );
1006 const SMESH::PointStruct * P = &theStepVector.PS;
1007 gp_Vec stepVec( P->x, P->y, P->z );
1009 ::SMESH_MeshEditor anEditor( _myMesh );
1010 TElemOfElemListMap aHystory;
1011 anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory,
1012 theExtrFlags, theSewTolerance);
1014 // Update Python script
1015 TPythonDump() << "stepVector = " << theStepVector;
1016 TPythonDump() << this << ".AdvancedExtrusion("
1019 << theNbOfSteps << ","
1020 << theExtrFlags << ", "
1021 << theSewTolerance << " )";
1025 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
1027 static SMESH::SMESH_MeshEditor::Extrusion_Error convExtrError( const::SMESH_MeshEditor::Extrusion_Error e )
1031 RETCASE( EXTR_NO_ELEMENTS );
1032 RETCASE( EXTR_PATH_NOT_EDGE );
1033 RETCASE( EXTR_BAD_PATH_SHAPE );
1034 RETCASE( EXTR_BAD_STARTING_NODE );
1035 RETCASE( EXTR_BAD_ANGLES_NUMBER );
1036 RETCASE( EXTR_CANT_GET_TANGENT );
1038 return SMESH::SMESH_MeshEditor::EXTR_OK;
1041 //=======================================================================
1042 //function : ExtrusionAlongPath
1044 //=======================================================================
1046 SMESH::SMESH_MeshEditor::Extrusion_Error
1047 SMESH_MeshEditor_i::ExtrusionAlongPath(const SMESH::long_array & theIDsOfElements,
1048 SMESH::SMESH_Mesh_ptr thePathMesh,
1049 GEOM::GEOM_Object_ptr thePathShape,
1050 CORBA::Long theNodeStart,
1051 CORBA::Boolean theHasAngles,
1052 const SMESH::double_array & theAngles,
1053 CORBA::Boolean theHasRefPoint,
1054 const SMESH::PointStruct & theRefPoint)
1056 SMESHDS_Mesh* aMesh = GetMeshDS();
1058 if ( thePathMesh->_is_nil() || thePathShape->_is_nil() )
1059 return SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
1061 SMESH_Mesh_i* aMeshImp = dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetServant( thePathMesh ).in() );
1062 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
1063 SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
1066 return SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
1068 SMDS_MeshNode* nodeStart = (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(theNodeStart);
1070 return SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
1072 set<const SMDS_MeshElement*> elements;
1073 for (int i = 0; i < theIDsOfElements.length(); i++)
1075 CORBA::Long index = theIDsOfElements[i];
1076 const SMDS_MeshElement * elem = aMesh->FindElement(index);
1078 elements.insert( elem );
1081 list<double> angles;
1082 for (int i = 0; i < theAngles.length(); i++)
1084 angles.push_back( theAngles[i] );
1087 gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z );
1089 // Update Python script
1090 TPythonDump() << "refPoint = SMESH.PointStruct( "
1091 << refPnt.X() << ", "
1092 << refPnt.Y() << ", "
1093 << refPnt.Z() << " )";
1094 TPythonDump() << "error = " << this << ".ExtrusionAlongPath( "
1095 << theIDsOfElements << ", "
1096 << thePathMesh << ", "
1097 << thePathShape << ", "
1098 << theNodeStart << ", "
1099 << theHasAngles << ", "
1100 << theAngles << ", "
1101 << theHasRefPoint << ", refPoint )";
1103 ::SMESH_MeshEditor anEditor( _myMesh );
1104 return convExtrError( anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart,
1105 theHasAngles, angles,
1106 theHasRefPoint, refPnt ) );
1109 //=======================================================================
1110 //function : ExtrusionAlongPathObject
1112 //=======================================================================
1114 SMESH::SMESH_MeshEditor::Extrusion_Error
1115 SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject,
1116 SMESH::SMESH_Mesh_ptr thePathMesh,
1117 GEOM::GEOM_Object_ptr thePathShape,
1118 CORBA::Long theNodeStart,
1119 CORBA::Boolean theHasAngles,
1120 const SMESH::double_array & theAngles,
1121 CORBA::Boolean theHasRefPoint,
1122 const SMESH::PointStruct & theRefPoint)
1124 SMESH::long_array_var anElementsId = theObject->GetIDs();
1125 SMESH::SMESH_MeshEditor::Extrusion_Error error = ExtrusionAlongPath
1126 (anElementsId, thePathMesh, thePathShape, theNodeStart,
1127 theHasAngles, theAngles, theHasRefPoint, theRefPoint);
1129 // Clear python line, created by ExtrusionAlongPath()
1130 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1131 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1133 // Update Python script
1134 TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject( "
1135 << theObject << ", "
1136 << thePathMesh << ", "
1137 << thePathShape << ", "
1138 << theNodeStart << ", "
1139 << theHasAngles << ", "
1140 << theAngles << ", "
1141 << theHasRefPoint << ", refPoint )";
1146 //=======================================================================
1149 //=======================================================================
1151 void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElements,
1152 const SMESH::AxisStruct & theAxis,
1153 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
1154 CORBA::Boolean theCopy)
1156 SMESHDS_Mesh* aMesh = GetMeshDS();
1158 set<const SMDS_MeshElement*> elements;
1159 for (int i = 0; i < theIDsOfElements.length(); i++)
1161 CORBA::Long index = theIDsOfElements[i];
1162 const SMDS_MeshElement * elem = aMesh->FindElement(index);
1164 elements.insert( elem );
1166 gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
1167 gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
1170 TCollection_AsciiString typeStr;
1171 switch ( theMirrorType ) {
1172 case SMESH::SMESH_MeshEditor::POINT:
1173 aTrsf.SetMirror( P );
1174 typeStr = "SMESH.SMESH_MeshEditor.POINT";
1176 case SMESH::SMESH_MeshEditor::AXIS:
1177 aTrsf.SetMirror( gp_Ax1( P, V ));
1178 typeStr = "SMESH.SMESH_MeshEditor.AXIS";
1181 aTrsf.SetMirror( gp_Ax2( P, V ));
1182 typeStr = "SMESH.SMESH_MeshEditor.PLANE";
1185 // Update Python script
1186 TPythonDump() << this << ".Mirror( "
1187 << theIDsOfElements << ", "
1192 ::SMESH_MeshEditor anEditor( _myMesh );
1193 anEditor.Transform (elements, aTrsf, theCopy);
1196 //=======================================================================
1197 //function : MirrorObject
1199 //=======================================================================
1201 void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObject,
1202 const SMESH::AxisStruct & theAxis,
1203 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
1204 CORBA::Boolean theCopy)
1206 SMESH::long_array_var anElementsId = theObject->GetIDs();
1207 Mirror(anElementsId, theAxis, theMirrorType, theCopy);
1209 // Clear python line, created by Mirror()
1210 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1211 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1213 // Update Python script
1214 TCollection_AsciiString typeStr;
1215 switch ( theMirrorType ) {
1216 case SMESH::SMESH_MeshEditor::POINT:
1217 typeStr = "SMESH.SMESH_MeshEditor.POINT";
1219 case SMESH::SMESH_MeshEditor::AXIS:
1220 typeStr = "SMESH.SMESH_MeshEditor.AXIS";
1223 typeStr = "SMESH.SMESH_MeshEditor.PLANE";
1225 TPythonDump() << "axis = " << theAxis;
1226 TPythonDump() << this << ".MirrorObject( "
1227 << theObject << ", "
1233 //=======================================================================
1234 //function : Translate
1236 //=======================================================================
1238 void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements,
1239 const SMESH::DirStruct & theVector,
1240 CORBA::Boolean theCopy)
1242 SMESHDS_Mesh* aMesh = GetMeshDS();
1244 set<const SMDS_MeshElement*> elements;
1245 for (int i = 0; i < theIDsOfElements.length(); i++)
1247 CORBA::Long index = theIDsOfElements[i];
1248 const SMDS_MeshElement * elem = aMesh->FindElement(index);
1250 elements.insert( elem );
1253 const SMESH::PointStruct * P = &theVector.PS;
1254 aTrsf.SetTranslation( gp_Vec( P->x, P->y, P->z ));
1256 ::SMESH_MeshEditor anEditor( _myMesh );
1257 anEditor.Transform (elements, aTrsf, theCopy);
1259 // Update Python script
1260 TPythonDump() << "vector = " << theVector;
1261 TPythonDump() << this << ".Translate( "
1267 //=======================================================================
1268 //function : TranslateObject
1270 //=======================================================================
1272 void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject,
1273 const SMESH::DirStruct & theVector,
1274 CORBA::Boolean theCopy)
1276 SMESH::long_array_var anElementsId = theObject->GetIDs();
1277 Translate(anElementsId, theVector, theCopy);
1279 // Clear python line, created by Translate()
1280 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1281 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1283 // Update Python script
1284 TPythonDump() << this << ".TranslateObject( "
1290 //=======================================================================
1293 //=======================================================================
1295 void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements,
1296 const SMESH::AxisStruct & theAxis,
1297 CORBA::Double theAngle,
1298 CORBA::Boolean theCopy)
1300 SMESHDS_Mesh* aMesh = GetMeshDS();
1302 set<const SMDS_MeshElement*> elements;
1303 for (int i = 0; i < theIDsOfElements.length(); i++)
1305 CORBA::Long index = theIDsOfElements[i];
1306 const SMDS_MeshElement * elem = aMesh->FindElement(index);
1308 elements.insert( elem );
1310 gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
1311 gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
1314 aTrsf.SetRotation( gp_Ax1( P, V ), theAngle);
1316 ::SMESH_MeshEditor anEditor( _myMesh );
1317 anEditor.Transform (elements, aTrsf, theCopy);
1319 // Update Python script
1320 TPythonDump() << "axis = " << theAxis;
1321 TPythonDump() << this << ".Rotate( "
1328 //=======================================================================
1329 //function : RotateObject
1331 //=======================================================================
1333 void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject,
1334 const SMESH::AxisStruct & theAxis,
1335 CORBA::Double theAngle,
1336 CORBA::Boolean theCopy)
1338 SMESH::long_array_var anElementsId = theObject->GetIDs();
1339 Rotate(anElementsId, theAxis, theAngle, theCopy);
1341 // Clear python line, created by Rotate()
1342 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1343 aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1345 // Update Python script
1346 TPythonDump() << this << ".RotateObject( "
1353 //=======================================================================
1354 //function : FindCoincidentNodes
1356 //=======================================================================
1358 void SMESH_MeshEditor_i::FindCoincidentNodes (CORBA::Double Tolerance,
1359 SMESH::array_of_long_array_out GroupsOfNodes)
1361 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
1362 ::SMESH_MeshEditor anEditor( _myMesh );
1363 set<const SMDS_MeshNode*> nodes; // no input nodes
1364 anEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
1366 GroupsOfNodes = new SMESH::array_of_long_array;
1367 GroupsOfNodes->length( aListOfListOfNodes.size() );
1368 ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
1369 for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ )
1371 list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
1372 list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
1373 SMESH::long_array& aGroup = (*GroupsOfNodes)[i];
1374 aGroup.length( aListOfNodes.size() );
1375 for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
1376 aGroup[ j ] = (*lIt)->GetID();
1378 // Update Python script
1379 TPythonDump() << "coincident_nodes = " << this << ".FindCoincidentNodes( "
1380 << Tolerance << " )";
1383 //=======================================================================
1384 //function : MergeNodes
1386 //=======================================================================
1388 void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes)
1390 SMESHDS_Mesh* aMesh = GetMeshDS();
1392 TPythonDump aTPythonDump;
1393 aTPythonDump << this << ".MergeNodes([";
1394 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
1395 for (int i = 0; i < GroupsOfNodes.length(); i++)
1397 const SMESH::long_array& aNodeGroup = GroupsOfNodes[ i ];
1398 aListOfListOfNodes.push_back( list< const SMDS_MeshNode* >() );
1399 list< const SMDS_MeshNode* >& aListOfNodes = aListOfListOfNodes.back();
1400 for ( int j = 0; j < aNodeGroup.length(); j++ )
1402 CORBA::Long index = aNodeGroup[ j ];
1403 const SMDS_MeshNode * node = aMesh->FindNode(index);
1405 aListOfNodes.push_back( node );
1407 if ( aListOfNodes.size() < 2 )
1408 aListOfListOfNodes.pop_back();
1410 if ( i > 0 ) aTPythonDump << ", ";
1411 aTPythonDump << aNodeGroup;
1413 ::SMESH_MeshEditor anEditor( _myMesh );
1414 anEditor.MergeNodes( aListOfListOfNodes );
1416 // Update Python script
1417 aTPythonDump << "])";
1420 //=======================================================================
1421 //function : MergeEqualElements
1423 //=======================================================================
1425 void SMESH_MeshEditor_i::MergeEqualElements()
1427 ::SMESH_MeshEditor anEditor( _myMesh );
1428 anEditor.MergeEqualElements();
1430 // Update Python script
1431 TPythonDump() << this << ".MergeEqualElements()";
1434 //=======================================================================
1435 //function : operator
1437 //=======================================================================
1439 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
1441 static SMESH::SMESH_MeshEditor::Sew_Error convError( const::SMESH_MeshEditor::Sew_Error e )
1445 RETCASE( SEW_BORDER1_NOT_FOUND );
1446 RETCASE( SEW_BORDER2_NOT_FOUND );
1447 RETCASE( SEW_BOTH_BORDERS_NOT_FOUND );
1448 RETCASE( SEW_BAD_SIDE_NODES );
1449 RETCASE( SEW_VOLUMES_TO_SPLIT );
1450 RETCASE( SEW_DIFF_NB_OF_ELEMENTS );
1451 RETCASE( SEW_TOPO_DIFF_SETS_OF_ELEMENTS );
1452 RETCASE( SEW_BAD_SIDE1_NODES );
1453 RETCASE( SEW_BAD_SIDE2_NODES );
1455 return SMESH::SMESH_MeshEditor::SEW_OK;
1458 //=======================================================================
1459 //function : SewFreeBorders
1461 //=======================================================================
1463 SMESH::SMESH_MeshEditor::Sew_Error
1464 SMESH_MeshEditor_i::SewFreeBorders(CORBA::Long FirstNodeID1,
1465 CORBA::Long SecondNodeID1,
1466 CORBA::Long LastNodeID1,
1467 CORBA::Long FirstNodeID2,
1468 CORBA::Long SecondNodeID2,
1469 CORBA::Long LastNodeID2,
1470 CORBA::Boolean CreatePolygons,
1471 CORBA::Boolean CreatePolyedrs)
1473 SMESHDS_Mesh* aMesh = GetMeshDS();
1475 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
1476 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
1477 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
1478 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
1479 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
1480 const SMDS_MeshNode* aSide2ThirdNode = aMesh->FindNode( LastNodeID2 );
1482 if (!aBorderFirstNode ||
1483 !aBorderSecondNode||
1485 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
1486 if (!aSide2FirstNode ||
1487 !aSide2SecondNode ||
1489 return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
1491 // Update Python script
1492 TPythonDump() << "error = " << this << ".SewFreeBorders( "
1493 << FirstNodeID1 << ", "
1494 << SecondNodeID1 << ", "
1495 << LastNodeID1 << ", "
1496 << FirstNodeID2 << ", "
1497 << SecondNodeID2 << ", "
1498 << LastNodeID2 << ", "
1499 << CreatePolygons<< ", "
1500 << CreatePolyedrs<< " )";
1502 ::SMESH_MeshEditor anEditor( _myMesh );
1503 return convError( anEditor.SewFreeBorder (aBorderFirstNode,
1514 //=======================================================================
1515 //function : SewConformFreeBorders
1517 //=======================================================================
1519 SMESH::SMESH_MeshEditor::Sew_Error
1520 SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1,
1521 CORBA::Long SecondNodeID1,
1522 CORBA::Long LastNodeID1,
1523 CORBA::Long FirstNodeID2,
1524 CORBA::Long SecondNodeID2)
1526 SMESHDS_Mesh* aMesh = GetMeshDS();
1528 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
1529 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
1530 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
1531 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
1532 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
1533 const SMDS_MeshNode* aSide2ThirdNode = 0;
1535 if (!aBorderFirstNode ||
1536 !aBorderSecondNode||
1538 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
1539 if (!aSide2FirstNode ||
1541 return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
1543 // Update Python script
1544 TPythonDump() << "error = " << this << ".SewConformFreeBorders( "
1545 << FirstNodeID1 << ", "
1546 << SecondNodeID1 << ", "
1547 << LastNodeID1 << ", "
1548 << FirstNodeID2 << ", "
1549 << SecondNodeID2 << " )";
1551 ::SMESH_MeshEditor anEditor( _myMesh );
1552 return convError( anEditor.SewFreeBorder (aBorderFirstNode,
1562 //=======================================================================
1563 //function : SewBorderToSide
1565 //=======================================================================
1567 SMESH::SMESH_MeshEditor::Sew_Error
1568 SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder,
1569 CORBA::Long SecondNodeIDOnFreeBorder,
1570 CORBA::Long LastNodeIDOnFreeBorder,
1571 CORBA::Long FirstNodeIDOnSide,
1572 CORBA::Long LastNodeIDOnSide,
1573 CORBA::Boolean CreatePolygons,
1574 CORBA::Boolean CreatePolyedrs)
1576 SMESHDS_Mesh* aMesh = GetMeshDS();
1578 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeIDOnFreeBorder );
1579 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeIDOnFreeBorder );
1580 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeIDOnFreeBorder );
1581 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeIDOnSide );
1582 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( LastNodeIDOnSide );
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_BAD_SIDE_NODES;
1593 // Update Python script
1594 TPythonDump() << "error = " << this << ".SewBorderToSide( "
1595 << FirstNodeIDOnFreeBorder << ", "
1596 << SecondNodeIDOnFreeBorder << ", "
1597 << LastNodeIDOnFreeBorder << ", "
1598 << FirstNodeIDOnSide << ", "
1599 << LastNodeIDOnSide << ", "
1600 << CreatePolygons << ", "
1601 << CreatePolyedrs << ") ";
1603 ::SMESH_MeshEditor anEditor( _myMesh );
1604 return convError( anEditor.SewFreeBorder (aBorderFirstNode,
1615 //=======================================================================
1616 //function : SewSideElements
1618 //=======================================================================
1620 SMESH::SMESH_MeshEditor::Sew_Error
1621 SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements,
1622 const SMESH::long_array& IDsOfSide2Elements,
1623 CORBA::Long NodeID1OfSide1ToMerge,
1624 CORBA::Long NodeID1OfSide2ToMerge,
1625 CORBA::Long NodeID2OfSide1ToMerge,
1626 CORBA::Long NodeID2OfSide2ToMerge)
1628 SMESHDS_Mesh* aMesh = GetMeshDS();
1630 const SMDS_MeshNode* aFirstNode1ToMerge = aMesh->FindNode( NodeID1OfSide1ToMerge );
1631 const SMDS_MeshNode* aFirstNode2ToMerge = aMesh->FindNode( NodeID1OfSide2ToMerge );
1632 const SMDS_MeshNode* aSecondNode1ToMerge = aMesh->FindNode( NodeID2OfSide1ToMerge );
1633 const SMDS_MeshNode* aSecondNode2ToMerge = aMesh->FindNode( NodeID2OfSide2ToMerge );
1635 if (!aFirstNode1ToMerge ||
1636 !aFirstNode2ToMerge )
1637 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE1_NODES;
1638 if (!aSecondNode1ToMerge||
1639 !aSecondNode2ToMerge)
1640 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE2_NODES;
1642 set<const SMDS_MeshElement*> aSide1Elems, aSide2Elems;
1643 for (int i = 0; i < IDsOfSide1Elements.length(); i++)
1645 CORBA::Long index = IDsOfSide1Elements[i];
1646 const SMDS_MeshElement * elem = aMesh->FindElement(index);
1648 aSide1Elems.insert( elem );
1650 for (int i = 0; i < IDsOfSide2Elements.length(); i++)
1652 CORBA::Long index = IDsOfSide2Elements[i];
1653 const SMDS_MeshElement * elem = aMesh->FindElement(index);
1655 aSide2Elems.insert( elem );
1657 // Update Python script
1658 TPythonDump() << "error = " << this << ".SewSideElements( "
1659 << IDsOfSide1Elements << ", "
1660 << IDsOfSide2Elements << ", "
1661 << NodeID1OfSide1ToMerge << ", "
1662 << NodeID1OfSide2ToMerge << ", "
1663 << NodeID2OfSide1ToMerge << ", "
1664 << NodeID2OfSide2ToMerge << ")";
1666 ::SMESH_MeshEditor anEditor( _myMesh );
1667 return convError( anEditor.SewSideElements (aSide1Elems, aSide2Elems,
1670 aSecondNode1ToMerge,
1671 aSecondNode2ToMerge));