Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/smesh.git] / src / SMESH_I / SMESH_MeshEditor_i.cxx
1 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //
24 //  File   : SMESH_MeshEditor_i.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SMESH
27 //  $Header$
28
29 #include "SMESH_MeshEditor_i.hxx"
30
31 #include "SMDS_MeshEdge.hxx"
32 #include "SMDS_MeshFace.hxx"
33 #include "SMDS_MeshVolume.hxx"
34
35 #include "SMESH_MeshEditor.hxx"
36
37 #include "SMESH_Gen_i.hxx"
38 #include "SMESH_Filter_i.hxx"
39 #include "SMESH_PythonDump.hxx"
40
41 #include "utilities.h"
42
43 #include <gp_Ax1.hxx>
44 #include <gp_Ax2.hxx>
45 #include <gp_Vec.hxx>
46
47 #include <sstream>
48
49 typedef map<const SMDS_MeshElement*,
50             list<const SMDS_MeshElement*> > TElemOfElemListMap;
51
52 using namespace std;
53 using SMESH::TPythonDump;
54
55 //=============================================================================
56 /*!
57  *
58  */
59 //=============================================================================
60
61 SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESH_Mesh* theMesh)
62 {
63         _myMesh = theMesh;
64 };
65
66 //=============================================================================
67 /*!
68  *
69  */
70 //=============================================================================
71
72 CORBA::Boolean
73   SMESH_MeshEditor_i::RemoveElements(const SMESH::long_array & IDsOfElements)
74 {
75   ::SMESH_MeshEditor anEditor( _myMesh );
76   list< int > IdList;
77
78   for (int i = 0; i < IDsOfElements.length(); i++)
79     IdList.push_back( IDsOfElements[i] );
80
81   // Update Python script
82   TPythonDump() << "isDone = " << this << ".RemoveElements( " << IDsOfElements << " )";
83 #ifdef _DEBUG_
84   TPythonDump() << "print 'RemoveElements: ', isDone";
85 #endif
86   // Remove Elements
87   return anEditor.Remove( IdList, false );
88 };
89
90 //=============================================================================
91 /*!
92  *
93  */
94 //=============================================================================
95
96 CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::long_array & IDsOfNodes)
97 {
98   ::SMESH_MeshEditor anEditor( _myMesh );
99   list< int > IdList;
100   for (int i = 0; i < IDsOfNodes.length(); i++)
101     IdList.push_back( IDsOfNodes[i] );
102
103   // Update Python script
104   TPythonDump() << "isDone = " << this << ".RemoveNodes( " << IDsOfNodes << " )";
105 #ifdef _DEBUG_
106   TPythonDump() << "print 'RemoveNodes: ', isDone";
107 #endif
108
109   return anEditor.Remove( IdList, true );
110 };
111
112 //=============================================================================
113 /*!
114  *
115  */
116 //=============================================================================
117
118 CORBA::Boolean SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes)
119 {
120   int NbNodes = IDsOfNodes.length();
121   if (NbNodes == 2)
122   {
123     CORBA::Long index1 = IDsOfNodes[0];
124     CORBA::Long index2 = IDsOfNodes[1];
125     GetMeshDS()->AddEdge(GetMeshDS()->FindNode(index1), GetMeshDS()->FindNode(index2));
126
127     // Update Python script
128     TPythonDump() << "isDone = " << this << ".AddEdge([ "
129                   << index1 << ", " << index2 <<" ])";
130   }
131   if (NbNodes == 3) {
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<<" ])";
141   }
142   return true;
143 }
144
145 //=============================================================================
146 /*!
147  *
148  */
149 //=============================================================================
150
151 CORBA::Boolean SMESH_MeshEditor_i::AddNode(CORBA::Double x,
152                                            CORBA::Double y, CORBA::Double z)
153 {
154   GetMeshDS()->AddNode(x, y, z);
155
156   // Update Python script
157   TPythonDump() << "isDone = " << this << ".AddNode( "
158                 << x << ", " << y << ", " << z << " )";
159
160   return true;
161 }
162
163 //=============================================================================
164 /*!
165  *  AddFace
166  */
167 //=============================================================================
168
169 CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
170 {
171   int NbNodes = IDsOfNodes.length();
172   if (NbNodes < 3)
173   {
174     return false;
175   }
176
177   std::vector<const SMDS_MeshNode*> nodes (NbNodes);
178   for (int i = 0; i < NbNodes; i++)
179     nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
180
181   if (NbNodes == 3)
182   {
183     GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]);
184   }
185   else if (NbNodes == 4)
186   {
187     GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
188   }
189   else if (NbNodes == 6)
190   {
191     GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
192                          nodes[4], nodes[5]);
193   }
194   else if (NbNodes == 8)
195   {
196     GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
197                          nodes[4], nodes[5], nodes[6], nodes[7]);
198   }
199
200   // Update Python script
201   TPythonDump() << "isDone = " << this << ".AddFace( " << IDsOfNodes << " )";
202 #ifdef _DEBUG_
203   TPythonDump() << "print 'AddFace: ', isDone";
204 #endif
205
206   return true;
207 };
208
209 //=============================================================================
210 /*!
211  *  AddPolygonalFace
212  */
213 //=============================================================================
214 CORBA::Boolean SMESH_MeshEditor_i::AddPolygonalFace
215                                    (const SMESH::long_array & IDsOfNodes)
216 {
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]);
221
222   GetMeshDS()->AddPolygonalFace(nodes);
223   
224   // Update Python script
225   TPythonDump() <<"isDone = "<<this<<".AddPolygonalFace( "<<IDsOfNodes<<" )";
226 #ifdef _DEBUG_
227   TPythonDump() << "print 'AddPolygonalFace: ', isDone";
228 #endif
229
230   return true;
231 };
232
233 //=============================================================================
234 /*!
235  *
236  */
237 //=============================================================================
238
239 CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH::long_array & IDsOfNodes)
240 {
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]);
245
246   SMDS_MeshElement* elem = 0;
247   switch(NbNodes)
248   {
249   case 4 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3]); break;
250   case 5 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4]); break;
251   case 6 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5]); break;
252   case 8 :elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break;
253   case 10:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],
254                                         n[6],n[7],n[8],n[9]);
255     break;
256   case 13:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],
257                                         n[7],n[8],n[9],n[10],n[11],n[12]);
258     break;
259   case 15:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],
260                                         n[9],n[10],n[11],n[12],n[13],n[14]);
261     break;
262   case 20:elem = GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],
263                                         n[8],n[9],n[10],n[11],n[12],n[13],n[14],
264                                         n[15],n[16],n[17],n[18],n[19]);
265     break;
266   }
267   // Update Python script
268   TPythonDump() << "isDone = " << this << ".AddVolume( " << IDsOfNodes << " )";
269 #ifdef _DEBUG_
270   TPythonDump() << "print 'AddVolume: ', isDone";
271 #endif
272
273   return elem;
274 };
275
276 //=============================================================================
277 /*!
278  *  AddPolyhedralVolume
279  */
280 //=============================================================================
281 CORBA::Boolean SMESH_MeshEditor_i::AddPolyhedralVolume
282                                    (const SMESH::long_array & IDsOfNodes,
283                                     const SMESH::long_array & Quantities)
284 {
285   int NbNodes = IDsOfNodes.length();
286   std::vector<const SMDS_MeshNode*> n (NbNodes);
287   for (int i = 0; i < NbNodes; i++)
288     n[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
289
290   int NbFaces = Quantities.length();
291   std::vector<int> q (NbFaces);
292   for (int j = 0; j < NbFaces; j++)
293     q[j] = Quantities[j];
294
295   GetMeshDS()->AddPolyhedralVolume(n, q);
296
297   // Update Python script
298   TPythonDump() << "isDone = " << this << ".AddPolyhedralVolume( "
299                 << IDsOfNodes << ", " << Quantities << " )";
300 #ifdef _DEBUG_
301   TPythonDump() << "print 'AddPolyhedralVolume: ', isDone";
302 #endif
303
304   return true;
305 };
306
307 //=============================================================================
308 /*!
309  *  AddPolyhedralVolumeByFaces
310  */
311 //=============================================================================
312 CORBA::Boolean SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces
313                                    (const SMESH::long_array & IdsOfFaces)
314 {
315   int NbFaces = IdsOfFaces.length();
316   std::vector<const SMDS_MeshNode*> poly_nodes;
317   std::vector<int> quantities (NbFaces);
318
319   for (int i = 0; i < NbFaces; i++) {
320     const SMDS_MeshElement* aFace = GetMeshDS()->FindElement(IdsOfFaces[i]);
321     quantities[i] = aFace->NbNodes();
322
323     SMDS_ElemIteratorPtr It = aFace->nodesIterator();
324     while (It->more()) {
325       poly_nodes.push_back(static_cast<const SMDS_MeshNode *>(It->next()));
326     }
327   }
328
329   GetMeshDS()->AddPolyhedralVolume(poly_nodes, quantities);
330
331   // Update Python script
332   TPythonDump() << "isDone = " << this << ".AddPolyhedralVolumeByFaces( "
333                 << IdsOfFaces << " )";
334 #ifdef _DEBUG_
335   TPythonDump() << "print 'AddPolyhedralVolume: ', isDone";
336 #endif
337
338   return true;
339 };
340
341 //=============================================================================
342 /*!
343  *
344  */
345 //=============================================================================
346
347 CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long   NodeID,
348                                             CORBA::Double x,
349                                             CORBA::Double y,
350                                             CORBA::Double z)
351 {
352   const SMDS_MeshNode * node = GetMeshDS()->FindNode( NodeID );
353   if ( !node )
354     return false;
355
356   GetMeshDS()->MoveNode(node, x, y, z);
357
358   // Update Python script
359   TPythonDump() << "isDone = " << this << ".MoveNode( "
360                 << NodeID << ", " << x << ", " << y << ", " << z << " )";
361
362   return true;
363 }
364
365 //=============================================================================
366 /*!
367  *
368  */
369 //=============================================================================
370
371 CORBA::Boolean SMESH_MeshEditor_i::InverseDiag(CORBA::Long NodeID1,
372                                                CORBA::Long NodeID2)
373 {
374   const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
375   const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
376   if ( !n1 || !n2 )
377     return false;
378
379   // Update Python script
380   TPythonDump() << "isDone = " << this << ".InverseDiag( "
381                 << NodeID1 << ", " << NodeID2 << " )";
382
383   ::SMESH_MeshEditor aMeshEditor( _myMesh );
384   return aMeshEditor.InverseDiag ( n1, n2 );
385 }
386
387 //=============================================================================
388 /*!
389  *
390  */
391 //=============================================================================
392
393 CORBA::Boolean SMESH_MeshEditor_i::DeleteDiag(CORBA::Long NodeID1,
394                                               CORBA::Long NodeID2)
395 {
396   const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
397   const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
398   if ( !n1 || !n2 )
399     return false;
400
401   // Update Python script
402   TPythonDump() << "isDone = " << this << ".DeleteDiag( "
403                 << NodeID1 << ", " << NodeID2 <<  " )";
404
405   ::SMESH_MeshEditor aMeshEditor( _myMesh );
406   return aMeshEditor.DeleteDiag ( n1, n2 );
407 }
408
409 //=============================================================================
410 /*!
411  *
412  */
413 //=============================================================================
414
415 CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::long_array & IDsOfElements)
416 {
417   ::SMESH_MeshEditor anEditor( _myMesh );
418   for (int i = 0; i < IDsOfElements.length(); i++)
419   {
420     CORBA::Long index = IDsOfElements[i];
421     const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
422     if ( elem )
423       anEditor.Reorient( elem );
424   }
425   // Update Python script
426   TPythonDump() << "isDone = " << this << ".Reorient( " << IDsOfElements << " )";
427
428   return true;
429 }
430
431
432 //=============================================================================
433 /*!
434  *
435  */
436 //=============================================================================
437
438 CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theObject)
439 {
440   SMESH::long_array_var anElementsId = theObject->GetIDs();
441   CORBA::Boolean isDone = Reorient(anElementsId);
442
443   // Clear python line, created by Reorient()
444   SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
445   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
446
447   // Update Python script
448   TPythonDump() << "isDone = " << this << ".ReorientObject( " << theObject << " )";
449
450   return isDone;
451 }
452
453 //=============================================================================
454 /*!
455  *
456  */
457 //=============================================================================
458 CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array &   IDsOfElements,
459                                               SMESH::NumericalFunctor_ptr Criterion,
460                                               CORBA::Double               MaxAngle)
461 {
462   set<const SMDS_MeshElement*> faces;
463   for (int i = 0; i < IDsOfElements.length(); i++)
464   {
465     CORBA::Long index = IDsOfElements[i];
466     const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
467     if ( elem && elem->GetType() == SMDSAbs_Face)
468       faces.insert( elem );
469   }
470   SMESH::NumericalFunctor_i* aNumericalFunctor =
471     dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
472   SMESH::Controls::NumericalFunctorPtr aCrit;
473   if ( !aNumericalFunctor )
474     aCrit.reset( new SMESH::Controls::AspectRatio() );
475   else
476     aCrit = aNumericalFunctor->GetNumericalFunctor();
477
478   // Update Python script
479   TPythonDump() << "isDone = " << this << ".TriToQuad( "
480                 << IDsOfElements << ", None, " << MaxAngle << " )";
481 #ifdef _DEBUG_
482   TPythonDump() << "print 'TriToQuad: ', isDone";
483 #endif
484
485   ::SMESH_MeshEditor anEditor( _myMesh );
486   return anEditor.TriToQuad( faces, aCrit, MaxAngle );
487 }
488
489 //=============================================================================
490 /*!
491  *
492  */
493 //=============================================================================
494 CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr   theObject,
495                                                     SMESH::NumericalFunctor_ptr Criterion,
496                                                     CORBA::Double               MaxAngle)
497 {
498   SMESH::long_array_var anElementsId = theObject->GetIDs();
499   CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
500
501   // Clear python line(s), created by TriToQuad()
502   SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
503   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
504 #ifdef _DEBUG_
505   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
506 #endif
507
508   // Update Python script
509   TPythonDump() << "isDone = " << this << ".TriToQuadObject("
510                 << theObject << ", None, " << MaxAngle << " )";
511 #ifdef _DEBUG_
512   TPythonDump() << "print 'TriToQuadObject: ', isDone";
513 #endif
514
515   return isDone;
516 }
517
518 //=============================================================================
519 /*!
520  *
521  */
522 //=============================================================================
523 CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array &   IDsOfElements,
524                                               SMESH::NumericalFunctor_ptr Criterion)
525 {
526   set<const SMDS_MeshElement*> faces;
527   for (int i = 0; i < IDsOfElements.length(); i++)
528   {
529     CORBA::Long index = IDsOfElements[i];
530     const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
531     if ( elem && elem->GetType() == SMDSAbs_Face)
532       faces.insert( elem );
533   }
534   SMESH::NumericalFunctor_i* aNumericalFunctor =
535     dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
536   SMESH::Controls::NumericalFunctorPtr aCrit;
537   if ( !aNumericalFunctor )
538     aCrit.reset( new SMESH::Controls::AspectRatio() );
539   else
540     aCrit = aNumericalFunctor->GetNumericalFunctor();
541
542
543   // Update Python script
544   TPythonDump() << "isDone = " << this << ".QuadToTri( " << IDsOfElements << ", None )";
545 #ifdef _DEBUG_
546   TPythonDump() << "print 'QuadToTri: ', isDone";
547 #endif
548
549   ::SMESH_MeshEditor anEditor( _myMesh );
550   return anEditor.QuadToTri( faces, aCrit );
551 }
552
553 //=============================================================================
554 /*!
555  *
556  */
557 //=============================================================================
558 CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr   theObject,
559                                                     SMESH::NumericalFunctor_ptr Criterion)
560 {
561   SMESH::long_array_var anElementsId = theObject->GetIDs();
562   CORBA::Boolean isDone = QuadToTri(anElementsId, Criterion);
563
564   // Clear python line(s), created by QuadToTri()
565   SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
566   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
567 #ifdef _DEBUG_
568   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
569 #endif
570
571   // Update Python script
572   TPythonDump() << "isDone = " << this << ".QuadToTriObject(" << theObject << ", None )";
573 #ifdef _DEBUG_
574   TPythonDump() << "print 'QuadToTriObject: ', isDone";
575 #endif
576
577   return isDone;
578 }
579
580 //=============================================================================
581 /*!
582  *
583  */
584 //=============================================================================
585 CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfElements,
586                                               CORBA::Boolean            Diag13)
587 {
588   set<const SMDS_MeshElement*> faces;
589   for (int i = 0; i < IDsOfElements.length(); i++)
590   {
591     CORBA::Long index = IDsOfElements[i];
592     const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
593     if ( elem && elem->GetType() == SMDSAbs_Face)
594       faces.insert( elem );
595   }
596
597   // Update Python script
598   TPythonDump() << "isDone = " << this << ".SplitQuad( "
599                 << IDsOfElements << ", " << Diag13 << " )";
600 #ifdef _DEBUG_
601   TPythonDump() << "print 'SplitQuad: ', isDone";
602 #endif
603
604   ::SMESH_MeshEditor anEditor( _myMesh );
605   return anEditor.QuadToTri( faces, Diag13 );
606 }
607
608 //=============================================================================
609 /*!
610  *
611  */
612 //=============================================================================
613 CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr theObject,
614                                                     CORBA::Boolean            Diag13)
615 {
616   SMESH::long_array_var anElementsId = theObject->GetIDs();
617   CORBA::Boolean isDone = SplitQuad(anElementsId, Diag13);
618
619   // Clear python line(s), created by SplitQuad()
620   SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
621   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
622 #ifdef _DEBUG_
623   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
624 #endif
625
626   // Update Python script
627   TPythonDump() << "isDone = " << this << ".SplitQuadObject( "
628                 << theObject << ", " << Diag13 << " )";
629 #ifdef _DEBUG_
630   TPythonDump() << "print 'SplitQuadObject: ', isDone";
631 #endif
632
633   return isDone;
634 }
635
636 //=============================================================================
637 /*!
638  *  BestSplit
639  */
640 //=============================================================================
641 CORBA::Long SMESH_MeshEditor_i::BestSplit (CORBA::Long                 IDOfQuad,
642                                            SMESH::NumericalFunctor_ptr Criterion)
643 {
644   const SMDS_MeshElement* quad = GetMeshDS()->FindElement(IDOfQuad);
645   if (quad && quad->GetType() == SMDSAbs_Face && quad->NbNodes() == 4)
646   {
647     SMESH::NumericalFunctor_i* aNumericalFunctor =
648       dynamic_cast<SMESH::NumericalFunctor_i*>(SMESH_Gen_i::GetServant(Criterion).in());
649     SMESH::Controls::NumericalFunctorPtr aCrit;
650     if (aNumericalFunctor)
651       aCrit = aNumericalFunctor->GetNumericalFunctor();
652     else
653       aCrit.reset(new SMESH::Controls::AspectRatio());
654
655     ::SMESH_MeshEditor anEditor (_myMesh);
656     return anEditor.BestSplit(quad, aCrit);
657   }
658   return -1;
659 }
660
661 //=======================================================================
662 //function : Smooth
663 //purpose  :
664 //=======================================================================
665
666 CORBA::Boolean
667   SMESH_MeshEditor_i::Smooth(const SMESH::long_array &              IDsOfElements,
668                              const SMESH::long_array &              IDsOfFixedNodes,
669                              CORBA::Long                            MaxNbOfIterations,
670                              CORBA::Double                          MaxAspectRatio,
671                              SMESH::SMESH_MeshEditor::Smooth_Method Method)
672 {
673   return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations,
674                 MaxAspectRatio, Method, false );
675 }
676
677 //=======================================================================
678 //function : SmoothParametric
679 //purpose  :
680 //=======================================================================
681
682 CORBA::Boolean
683   SMESH_MeshEditor_i::SmoothParametric(const SMESH::long_array &              IDsOfElements,
684                                        const SMESH::long_array &              IDsOfFixedNodes,
685                                        CORBA::Long                            MaxNbOfIterations,
686                                        CORBA::Double                          MaxAspectRatio,
687                                        SMESH::SMESH_MeshEditor::Smooth_Method Method)
688 {
689   return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations,
690                 MaxAspectRatio, Method, true );
691 }
692
693 //=======================================================================
694 //function : SmoothObject
695 //purpose  :
696 //=======================================================================
697
698 CORBA::Boolean
699   SMESH_MeshEditor_i::SmoothObject(SMESH::SMESH_IDSource_ptr              theObject,
700                                    const SMESH::long_array &              IDsOfFixedNodes,
701                                    CORBA::Long                            MaxNbOfIterations,
702                                    CORBA::Double                          MaxAspectRatio,
703                                    SMESH::SMESH_MeshEditor::Smooth_Method Method)
704 {
705   return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations,
706                        MaxAspectRatio, Method, false);
707 }
708
709 //=======================================================================
710 //function : SmoothParametricObject
711 //purpose  :
712 //=======================================================================
713
714 CORBA::Boolean
715   SMESH_MeshEditor_i::SmoothParametricObject(SMESH::SMESH_IDSource_ptr              theObject,
716                                    const SMESH::long_array &              IDsOfFixedNodes,
717                                    CORBA::Long                            MaxNbOfIterations,
718                                    CORBA::Double                          MaxAspectRatio,
719                                    SMESH::SMESH_MeshEditor::Smooth_Method Method)
720 {
721   return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations,
722                        MaxAspectRatio, Method, true);
723 }
724
725 //=============================================================================
726 /*!
727  *
728  */
729 //=============================================================================
730
731 CORBA::Boolean
732   SMESH_MeshEditor_i::smooth(const SMESH::long_array &              IDsOfElements,
733                              const SMESH::long_array &              IDsOfFixedNodes,
734                              CORBA::Long                            MaxNbOfIterations,
735                              CORBA::Double                          MaxAspectRatio,
736                              SMESH::SMESH_MeshEditor::Smooth_Method Method,
737                              bool                                   IsParametric)
738 {
739   SMESHDS_Mesh* aMesh = GetMeshDS();
740
741   set<const SMDS_MeshElement*> elements;
742   for (int i = 0; i < IDsOfElements.length(); i++)
743   {
744     CORBA::Long index = IDsOfElements[i];
745     const SMDS_MeshElement * elem = aMesh->FindElement(index);
746     if ( elem && elem->GetType() == SMDSAbs_Face)
747       elements.insert( elem );
748   }
749
750   set<const SMDS_MeshNode*> fixedNodes;
751   for (int i = 0; i < IDsOfFixedNodes.length(); i++)
752   {
753     CORBA::Long index = IDsOfFixedNodes[i];
754     const SMDS_MeshNode * node = aMesh->FindNode(index);
755     if ( node )
756       fixedNodes.insert( node );
757   }
758   ::SMESH_MeshEditor::SmoothMethod method = ::SMESH_MeshEditor::LAPLACIAN;
759   if ( Method != SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH )
760     method = ::SMESH_MeshEditor::CENTROIDAL;
761
762   ::SMESH_MeshEditor anEditor( _myMesh );
763   anEditor.Smooth(elements, fixedNodes, method,
764                   MaxNbOfIterations, MaxAspectRatio, IsParametric );
765
766   // Update Python script
767   TPythonDump() << "isDone = " << this << "."
768                 << (IsParametric ? "SmoothParametric( " : "Smooth( ")
769                 << IDsOfElements << ", "     << IDsOfFixedNodes << ", "
770                 << MaxNbOfIterations << ", " << MaxAspectRatio << ", "
771                 << "SMESH.SMESH_MeshEditor."
772                 << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
773                      "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
774 #ifdef _DEBUG_
775   TPythonDump() << "print 'Smooth: ', isDone";
776 #endif
777
778   return true;
779 }
780
781 //=============================================================================
782 /*!
783  *
784  */
785 //=============================================================================
786
787 CORBA::Boolean
788 SMESH_MeshEditor_i::smoothObject(SMESH::SMESH_IDSource_ptr              theObject,
789                                  const SMESH::long_array &              IDsOfFixedNodes,
790                                  CORBA::Long                            MaxNbOfIterations,
791                                  CORBA::Double                          MaxAspectRatio,
792                                  SMESH::SMESH_MeshEditor::Smooth_Method Method,
793                                  bool                                   IsParametric)
794 {
795   SMESH::long_array_var anElementsId = theObject->GetIDs();
796   CORBA::Boolean isDone = smooth (anElementsId, IDsOfFixedNodes, MaxNbOfIterations,
797                                   MaxAspectRatio, Method, IsParametric);
798
799   // Clear python line(s), created by Smooth()
800   SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
801   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
802 #ifdef _DEBUG_
803   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
804 #endif
805
806   // Update Python script
807   TPythonDump() << "isDone = " << this << "."
808                 << (IsParametric ? "SmoothParametricObject( " : "SmoothObject( ")
809                 << theObject << ", " << IDsOfFixedNodes << ", "
810                 << MaxNbOfIterations << ", " << MaxAspectRatio << ", "
811                 << "SMESH.SMESH_MeshEditor."
812                 << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
813                      "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
814 #ifdef _DEBUG_
815   TPythonDump() << "print 'SmoothObject: ', isDone";
816 #endif
817
818   return isDone;
819 }
820
821 //=============================================================================
822 /*!
823  *
824  */
825 //=============================================================================
826
827 void SMESH_MeshEditor_i::RenumberNodes()
828 {
829   // Update Python script
830   TPythonDump() << this << ".RenumberNodes()";
831
832   GetMeshDS()->Renumber( true );
833 }
834
835 //=============================================================================
836 /*!
837  *
838  */
839 //=============================================================================
840
841 void SMESH_MeshEditor_i::RenumberElements()
842 {
843   // Update Python script
844   TPythonDump() << this << ".RenumberElements()";
845
846   GetMeshDS()->Renumber( false );
847 }
848
849 //=======================================================================
850 //function : RotationSweep
851 //purpose  :
852 //=======================================================================
853
854 void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElements,
855                                        const SMESH::AxisStruct & theAxis,
856                                        CORBA::Double             theAngleInRadians,
857                                        CORBA::Long               theNbOfSteps,
858                                        CORBA::Double             theTolerance)
859 {
860   SMESHDS_Mesh* aMesh = GetMeshDS();
861
862   set<const SMDS_MeshElement*> elements;
863   for (int i = 0; i < theIDsOfElements.length(); i++)
864   {
865     CORBA::Long index = theIDsOfElements[i];
866     const SMDS_MeshElement * elem = aMesh->FindElement(index);
867     if ( elem )
868       elements.insert( elem );
869   }
870   gp_Ax1 Ax1 (gp_Pnt( theAxis.x, theAxis.y, theAxis.z ),
871               gp_Vec( theAxis.vx, theAxis.vy, theAxis.vz ));
872
873   ::SMESH_MeshEditor anEditor( _myMesh );
874   anEditor.RotationSweep (elements, Ax1, theAngleInRadians,
875                           theNbOfSteps, theTolerance);
876
877   // Update Python script
878   TPythonDump() << "axis = " << theAxis;
879   TPythonDump() << this << ".RotationSweep( "
880                 << theIDsOfElements
881                 << ", axis, "
882                 << theAngleInRadians << ", "
883                 << theNbOfSteps << ", "
884                 << theTolerance << " )";
885 }
886
887 //=======================================================================
888 //function : RotationSweepObject
889 //purpose  :
890 //=======================================================================
891
892 void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject,
893                                              const SMESH::AxisStruct & theAxis,
894                                              CORBA::Double             theAngleInRadians,
895                                              CORBA::Long               theNbOfSteps,
896                                              CORBA::Double             theTolerance)
897 {
898   SMESH::long_array_var anElementsId = theObject->GetIDs();
899   RotationSweep(anElementsId, theAxis, theAngleInRadians, theNbOfSteps, theTolerance);
900
901   // Clear python line, created by RotationSweep()
902   SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
903   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
904
905   // Update Python script
906   TPythonDump() << this << ".RotationSweepObject( "
907                 << theObject
908                 << ", axis, "
909                 << theAngleInRadians << ", "
910                 << theNbOfSteps << ", "
911                 << theTolerance << " )";
912 }
913
914 //=======================================================================
915 //function : ExtrusionSweep
916 //purpose  :
917 //=======================================================================
918
919 void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElements,
920                                         const SMESH::DirStruct &  theStepVector,
921                                         CORBA::Long               theNbOfSteps)
922 {
923   SMESHDS_Mesh* aMesh = GetMeshDS();
924
925   set<const SMDS_MeshElement*> elements;
926   for (int i = 0; i < theIDsOfElements.length(); i++)
927   {
928     CORBA::Long index = theIDsOfElements[i];
929     const SMDS_MeshElement * elem = aMesh->FindElement(index);
930     if ( elem )
931       elements.insert( elem );
932   }
933   const SMESH::PointStruct * P = &theStepVector.PS;
934   gp_Vec stepVec( P->x, P->y, P->z );
935
936   ::SMESH_MeshEditor anEditor( _myMesh );
937   //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
938   TElemOfElemListMap aHystory;
939   anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory);
940
941   // Update Python script
942   TPythonDump() << "stepVector = " << theStepVector;
943   TPythonDump() << this << ".ExtrusionSweep( "
944                 << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )";
945 }
946
947
948 //=======================================================================
949 //function : ExtrusionSweepObject
950 //purpose  :
951 //=======================================================================
952
953 void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObject,
954                                               const SMESH::DirStruct &  theStepVector,
955                                               CORBA::Long               theNbOfSteps)
956 {
957   SMESH::long_array_var anElementsId = theObject->GetIDs();
958   ExtrusionSweep(anElementsId, theStepVector, theNbOfSteps);
959
960   // Clear python line, created by ExtrusionSweep()
961   SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
962   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
963
964   // Update Python script
965   TPythonDump() << this << ".ExtrusionSweepObject( "
966                 << theObject << ", stepVector, " << theNbOfSteps << " )";
967 }
968
969 //=======================================================================
970 //function : ExtrusionSweepObject1D
971 //purpose  :
972 //=======================================================================
973
974 void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
975                                                 const SMESH::DirStruct &  theStepVector,
976                                                 CORBA::Long               theNbOfSteps)
977 {
978   SMESHDS_Mesh* aMesh = GetMeshDS();
979
980   SMESH::long_array_var allElementsId = theObject->GetIDs();
981
982   set<const SMDS_MeshElement*> elements;
983   for (int i = 0; i < allElementsId->length(); i++)
984   {
985     CORBA::Long index = allElementsId[i];
986     const SMDS_MeshElement * elem = aMesh->FindElement(index);
987     if ( elem && elem->GetType() == SMDSAbs_Edge )
988       elements.insert( elem );
989   }
990   const SMESH::PointStruct * P = &theStepVector.PS;
991   gp_Vec stepVec( P->x, P->y, P->z );
992
993   ::SMESH_MeshEditor anEditor( _myMesh );
994   //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
995   TElemOfElemListMap aHystory;
996   anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory);
997
998   // Update Python script
999   TPythonDump() << "stepVector = " << theStepVector;
1000   TPythonDump() << this << ".ExtrusionSweepObject1D( "
1001                 << theObject << ", stepVector, " << theNbOfSteps << " )";
1002 }
1003
1004 //=======================================================================
1005 //function : ExtrusionSweepObject2D
1006 //purpose  :
1007 //=======================================================================
1008
1009 void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
1010                                                 const SMESH::DirStruct &  theStepVector,
1011                                                 CORBA::Long               theNbOfSteps)
1012 {
1013   SMESHDS_Mesh* aMesh = GetMeshDS();
1014
1015   SMESH::long_array_var allElementsId = theObject->GetIDs();
1016
1017   set<const SMDS_MeshElement*> elements;
1018   for (int i = 0; i < allElementsId->length(); i++)
1019   {
1020     CORBA::Long index = allElementsId[i];
1021     const SMDS_MeshElement * elem = aMesh->FindElement(index);
1022     if ( elem && elem->GetType() == SMDSAbs_Face )
1023       elements.insert( elem );
1024   }
1025   const SMESH::PointStruct * P = &theStepVector.PS;
1026   gp_Vec stepVec( P->x, P->y, P->z );
1027
1028   ::SMESH_MeshEditor anEditor( _myMesh );
1029   //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
1030   TElemOfElemListMap aHystory;
1031   anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory);
1032
1033   // Update Python script
1034   TPythonDump() << "stepVector = " << theStepVector;
1035   TPythonDump() << this << ".ExtrusionSweepObject2D( "
1036                 << theObject << ", stepVector, " << theNbOfSteps << " )";
1037 }
1038
1039
1040 //=======================================================================
1041 //function : AdvancedExtrusion
1042 //purpose  :
1043 //=======================================================================
1044
1045 void SMESH_MeshEditor_i::AdvancedExtrusion(const SMESH::long_array & theIDsOfElements,
1046                                            const SMESH::DirStruct &  theStepVector,
1047                                            CORBA::Long               theNbOfSteps,
1048                                            CORBA::Long               theExtrFlags,
1049                                            CORBA::Double             theSewTolerance)
1050 {
1051   SMESHDS_Mesh* aMesh = GetMeshDS();
1052
1053   set<const SMDS_MeshElement*> elements;
1054   for (int i = 0; i < theIDsOfElements.length(); i++)
1055   {
1056     CORBA::Long index = theIDsOfElements[i];
1057     const SMDS_MeshElement * elem = aMesh->FindElement(index);
1058     if ( elem )
1059       elements.insert( elem );
1060   }
1061   const SMESH::PointStruct * P = &theStepVector.PS;
1062   gp_Vec stepVec( P->x, P->y, P->z );
1063
1064   ::SMESH_MeshEditor anEditor( _myMesh );
1065   TElemOfElemListMap aHystory;
1066   anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory,
1067                            theExtrFlags, theSewTolerance);
1068
1069   // Update Python script
1070   TPythonDump() << "stepVector = " << theStepVector;
1071   TPythonDump() << this << ".AdvancedExtrusion("
1072                 << theIDsOfElements
1073                 << ", stepVector, "
1074                 << theNbOfSteps << ","
1075                 << theExtrFlags << ", "
1076                 << theSewTolerance <<  " )";
1077 }
1078
1079
1080 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
1081
1082 static SMESH::SMESH_MeshEditor::Extrusion_Error convExtrError( const::SMESH_MeshEditor::Extrusion_Error e )
1083 {
1084   switch ( e ) {
1085   RETCASE( EXTR_OK );
1086   RETCASE( EXTR_NO_ELEMENTS );
1087   RETCASE( EXTR_PATH_NOT_EDGE );
1088   RETCASE( EXTR_BAD_PATH_SHAPE );
1089   RETCASE( EXTR_BAD_STARTING_NODE );
1090   RETCASE( EXTR_BAD_ANGLES_NUMBER );
1091   RETCASE( EXTR_CANT_GET_TANGENT );
1092   }
1093   return SMESH::SMESH_MeshEditor::EXTR_OK;
1094 }
1095
1096 //=======================================================================
1097 //function : ExtrusionAlongPath
1098 //purpose  :
1099 //=======================================================================
1100
1101 SMESH::SMESH_MeshEditor::Extrusion_Error
1102   SMESH_MeshEditor_i::ExtrusionAlongPath(const SMESH::long_array &   theIDsOfElements,
1103                                          SMESH::SMESH_Mesh_ptr       thePathMesh,
1104                                          GEOM::GEOM_Object_ptr       thePathShape,
1105                                          CORBA::Long                 theNodeStart,
1106                                          CORBA::Boolean              theHasAngles,
1107                                          const SMESH::double_array & theAngles,
1108                                          CORBA::Boolean              theHasRefPoint,
1109                                          const SMESH::PointStruct &  theRefPoint)
1110 {
1111   SMESHDS_Mesh*  aMesh = GetMeshDS();
1112
1113   if ( thePathMesh->_is_nil() || thePathShape->_is_nil() )
1114     return SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
1115
1116   SMESH_Mesh_i* aMeshImp = dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetServant( thePathMesh ).in() );
1117   TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
1118   SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
1119
1120   if ( !aSubMesh )
1121     return SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE;
1122
1123   SMDS_MeshNode* nodeStart = (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(theNodeStart);
1124   if ( !nodeStart )
1125     return SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
1126
1127   set<const SMDS_MeshElement*> elements;
1128   for (int i = 0; i < theIDsOfElements.length(); i++)
1129   {
1130     CORBA::Long index = theIDsOfElements[i];
1131     const SMDS_MeshElement * elem = aMesh->FindElement(index);
1132     if ( elem )
1133       elements.insert( elem );
1134   }
1135
1136   list<double> angles;
1137   for (int i = 0; i < theAngles.length(); i++)
1138   {
1139     angles.push_back( theAngles[i] );
1140   }
1141
1142   gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z );
1143
1144   // Update Python script
1145   TPythonDump() << "refPoint = SMESH.PointStruct( "
1146                 << refPnt.X() << ", "
1147                 << refPnt.Y() << ", "
1148                 << refPnt.Z() << " )";
1149   TPythonDump() << "error = " << this << ".ExtrusionAlongPath( "
1150                 << theIDsOfElements << ", "
1151                 << thePathMesh  <<  ", "
1152                 << thePathShape <<  ", "
1153                 << theNodeStart << ", "
1154                 << theHasAngles << ", "
1155                 << theAngles << ", "
1156                 << theHasRefPoint << ", refPoint )";
1157
1158   ::SMESH_MeshEditor anEditor( _myMesh );
1159   return convExtrError( anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart,
1160                                                       theHasAngles, angles,
1161                                                       theHasRefPoint, refPnt ) );
1162 }
1163
1164 //=======================================================================
1165 //function : ExtrusionAlongPathObject
1166 //purpose  :
1167 //=======================================================================
1168
1169 SMESH::SMESH_MeshEditor::Extrusion_Error
1170 SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr   theObject,
1171                                              SMESH::SMESH_Mesh_ptr       thePathMesh,
1172                                              GEOM::GEOM_Object_ptr       thePathShape,
1173                                              CORBA::Long                 theNodeStart,
1174                                              CORBA::Boolean              theHasAngles,
1175                                              const SMESH::double_array & theAngles,
1176                                              CORBA::Boolean              theHasRefPoint,
1177                                              const SMESH::PointStruct &  theRefPoint)
1178 {
1179   SMESH::long_array_var anElementsId = theObject->GetIDs();
1180   SMESH::SMESH_MeshEditor::Extrusion_Error error = ExtrusionAlongPath
1181     (anElementsId, thePathMesh, thePathShape, theNodeStart,
1182      theHasAngles, theAngles, theHasRefPoint, theRefPoint);
1183
1184   // Clear python line, created by ExtrusionAlongPath()
1185   SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1186   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1187
1188   // Update Python script
1189   TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject( "
1190                 << theObject    << ", "
1191                 << thePathMesh  << ", "
1192                 << thePathShape << ", "
1193                 << theNodeStart << ", "
1194                 << theHasAngles << ", "
1195                 << theAngles << ", "
1196                 << theHasRefPoint << ", refPoint )";
1197
1198   return error;
1199 }
1200
1201 //=======================================================================
1202 //function : Mirror
1203 //purpose  :
1204 //=======================================================================
1205
1206 void SMESH_MeshEditor_i::Mirror(const SMESH::long_array &           theIDsOfElements,
1207                                 const SMESH::AxisStruct &           theAxis,
1208                                 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
1209                                 CORBA::Boolean                      theCopy)
1210 {
1211   SMESHDS_Mesh* aMesh = GetMeshDS();
1212
1213   set<const SMDS_MeshElement*> elements;
1214   for (int i = 0; i < theIDsOfElements.length(); i++)
1215   {
1216     CORBA::Long index = theIDsOfElements[i];
1217     const SMDS_MeshElement * elem = aMesh->FindElement(index);
1218     if ( elem )
1219       elements.insert( elem );
1220   }
1221   gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
1222   gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
1223
1224   gp_Trsf aTrsf;
1225   TCollection_AsciiString typeStr;
1226   switch ( theMirrorType ) {
1227   case  SMESH::SMESH_MeshEditor::POINT:
1228     aTrsf.SetMirror( P );
1229     typeStr = "SMESH.SMESH_MeshEditor.POINT";
1230     break;
1231   case  SMESH::SMESH_MeshEditor::AXIS:
1232     aTrsf.SetMirror( gp_Ax1( P, V ));
1233     typeStr = "SMESH.SMESH_MeshEditor.AXIS";
1234     break;
1235   default:
1236     aTrsf.SetMirror( gp_Ax2( P, V ));
1237     typeStr = "SMESH.SMESH_MeshEditor.PLANE";
1238   }
1239
1240   // Update Python script
1241   TPythonDump() << this << ".Mirror( "
1242                 << theIDsOfElements << ", "
1243                 << theAxis           << ", "
1244                 << typeStr           << ", "
1245                 << theCopy           << " )";
1246
1247   ::SMESH_MeshEditor anEditor( _myMesh );
1248   anEditor.Transform (elements, aTrsf, theCopy);
1249 }
1250
1251 //=======================================================================
1252 //function : MirrorObject
1253 //purpose  :
1254 //=======================================================================
1255
1256 void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr           theObject,
1257                                       const SMESH::AxisStruct &           theAxis,
1258                                       SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
1259                                       CORBA::Boolean                      theCopy)
1260 {
1261   SMESH::long_array_var anElementsId = theObject->GetIDs();
1262   Mirror(anElementsId, theAxis, theMirrorType, theCopy);
1263
1264   // Clear python line, created by Mirror()
1265   SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1266   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1267
1268   // Update Python script
1269   TCollection_AsciiString typeStr;
1270   switch ( theMirrorType ) {
1271   case  SMESH::SMESH_MeshEditor::POINT:
1272     typeStr = "SMESH.SMESH_MeshEditor.POINT";
1273     break;
1274   case  SMESH::SMESH_MeshEditor::AXIS:
1275     typeStr = "SMESH.SMESH_MeshEditor.AXIS";
1276     break;
1277   default:
1278     typeStr = "SMESH.SMESH_MeshEditor.PLANE";
1279   }
1280   TPythonDump() << "axis = " << theAxis;
1281   TPythonDump() << this << ".MirrorObject( "
1282                 << theObject << ", "
1283                 << "axis, "
1284                 << typeStr << ", "
1285                 << theCopy << " )";
1286 }
1287
1288 //=======================================================================
1289 //function : Translate
1290 //purpose  :
1291 //=======================================================================
1292
1293 void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements,
1294                                    const SMESH::DirStruct &  theVector,
1295                                    CORBA::Boolean            theCopy)
1296 {
1297   SMESHDS_Mesh* aMesh = GetMeshDS();
1298
1299   set<const SMDS_MeshElement*> elements;
1300   for (int i = 0; i < theIDsOfElements.length(); i++)
1301   {
1302     CORBA::Long index = theIDsOfElements[i];
1303     const SMDS_MeshElement * elem = aMesh->FindElement(index);
1304     if ( elem )
1305       elements.insert( elem );
1306   }
1307   gp_Trsf aTrsf;
1308   const SMESH::PointStruct * P = &theVector.PS;
1309   aTrsf.SetTranslation( gp_Vec( P->x, P->y, P->z ));
1310
1311   ::SMESH_MeshEditor anEditor( _myMesh );
1312   anEditor.Transform (elements, aTrsf, theCopy);
1313
1314   // Update Python script
1315   TPythonDump() << "vector = " << theVector;
1316   TPythonDump() << this << ".Translate( "
1317                 << theIDsOfElements
1318                 << ", vector, "
1319                 << theCopy << " )";
1320 }
1321
1322 //=======================================================================
1323 //function : TranslateObject
1324 //purpose  :
1325 //=======================================================================
1326
1327 void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject,
1328                                          const SMESH::DirStruct &  theVector,
1329                                          CORBA::Boolean            theCopy)
1330 {
1331   SMESH::long_array_var anElementsId = theObject->GetIDs();
1332   Translate(anElementsId, theVector, theCopy);
1333
1334   // Clear python line, created by Translate()
1335   SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1336   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1337
1338   // Update Python script
1339   TPythonDump() << this << ".TranslateObject( "
1340                 << theObject
1341                 << ", vector, "
1342                 << theCopy << " )";
1343 }
1344
1345 //=======================================================================
1346 //function : Rotate
1347 //purpose  :
1348 //=======================================================================
1349
1350 void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements,
1351                                 const SMESH::AxisStruct & theAxis,
1352                                 CORBA::Double             theAngle,
1353                                 CORBA::Boolean            theCopy)
1354 {
1355   SMESHDS_Mesh* aMesh = GetMeshDS();
1356
1357   set<const SMDS_MeshElement*> elements;
1358   for (int i = 0; i < theIDsOfElements.length(); i++)
1359   {
1360     CORBA::Long index = theIDsOfElements[i];
1361     const SMDS_MeshElement * elem = aMesh->FindElement(index);
1362     if ( elem )
1363       elements.insert( elem );
1364   }
1365   gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
1366   gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
1367
1368   gp_Trsf aTrsf;
1369   aTrsf.SetRotation( gp_Ax1( P, V ), theAngle);
1370
1371   ::SMESH_MeshEditor anEditor( _myMesh );
1372   anEditor.Transform (elements, aTrsf, theCopy);
1373
1374   // Update Python script
1375   TPythonDump() << "axis = " << theAxis;
1376   TPythonDump() << this << ".Rotate( "
1377                 << theIDsOfElements
1378                 << ", axis, "
1379                 << theAngle << ", "
1380                 << theCopy << " )";
1381 }
1382
1383 //=======================================================================
1384 //function : RotateObject
1385 //purpose  :
1386 //=======================================================================
1387
1388 void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject,
1389                                       const SMESH::AxisStruct & theAxis,
1390                                       CORBA::Double             theAngle,
1391                                       CORBA::Boolean            theCopy)
1392 {
1393   SMESH::long_array_var anElementsId = theObject->GetIDs();
1394   Rotate(anElementsId, theAxis, theAngle, theCopy);
1395
1396   // Clear python line, created by Rotate()
1397   SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1398   aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
1399
1400   // Update Python script
1401   TPythonDump() << this << ".RotateObject( "
1402                 << theObject
1403                 << ", axis, "
1404                 << theAngle << ", "
1405                 << theCopy << " )";
1406 }
1407
1408 //=======================================================================
1409 //function : FindCoincidentNodes
1410 //purpose  :
1411 //=======================================================================
1412
1413 void SMESH_MeshEditor_i::FindCoincidentNodes (CORBA::Double                  Tolerance,
1414                                               SMESH::array_of_long_array_out GroupsOfNodes)
1415 {
1416   ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
1417   ::SMESH_MeshEditor anEditor( _myMesh );
1418   set<const SMDS_MeshNode*> nodes; // no input nodes
1419   anEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
1420
1421   GroupsOfNodes = new SMESH::array_of_long_array;
1422   GroupsOfNodes->length( aListOfListOfNodes.size() );
1423   ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
1424   for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ )
1425   {
1426     list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
1427     list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
1428     SMESH::long_array& aGroup = GroupsOfNodes[ i ];
1429     aGroup.length( aListOfNodes.size() );
1430     for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
1431       aGroup[ j ] = (*lIt)->GetID();
1432   }
1433   // Update Python script
1434   TPythonDump() << "coincident_nodes = " << this << ".FindCoincidentNodes( "
1435                 << Tolerance << " )";
1436 }
1437
1438 //=======================================================================
1439 //function : MergeNodes
1440 //purpose  :
1441 //=======================================================================
1442
1443 void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes)
1444 {
1445   SMESHDS_Mesh* aMesh = GetMeshDS();
1446
1447   TPythonDump aTPythonDump;
1448   aTPythonDump << this << ".MergeNodes([";
1449   ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
1450   for (int i = 0; i < GroupsOfNodes.length(); i++)
1451   {
1452     const SMESH::long_array& aNodeGroup = GroupsOfNodes[ i ];
1453     aListOfListOfNodes.push_back( list< const SMDS_MeshNode* >() );
1454     list< const SMDS_MeshNode* >& aListOfNodes = aListOfListOfNodes.back();
1455     for ( int j = 0; j < aNodeGroup.length(); j++ )
1456     {
1457       CORBA::Long index = aNodeGroup[ j ];
1458       const SMDS_MeshNode * node = aMesh->FindNode(index);
1459       if ( node )
1460         aListOfNodes.push_back( node );
1461     }
1462     if ( aListOfNodes.size() < 2 )
1463       aListOfListOfNodes.pop_back();
1464
1465     if ( i > 0 ) aTPythonDump << ", ";
1466     aTPythonDump << aNodeGroup;
1467   }
1468   ::SMESH_MeshEditor anEditor( _myMesh );
1469   anEditor.MergeNodes( aListOfListOfNodes );
1470
1471   // Update Python script
1472   aTPythonDump <<  "])";
1473 }
1474
1475 //=======================================================================
1476 //function : MergeEqualElements
1477 //purpose  :
1478 //=======================================================================
1479
1480 void SMESH_MeshEditor_i::MergeEqualElements()
1481 {
1482   ::SMESH_MeshEditor anEditor( _myMesh );
1483   anEditor.MergeEqualElements();
1484
1485   // Update Python script
1486   TPythonDump() << this << ".MergeEqualElements()";
1487 }
1488
1489 //=======================================================================
1490 //function : operator
1491 //purpose  :
1492 //=======================================================================
1493
1494 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
1495
1496 static SMESH::SMESH_MeshEditor::Sew_Error convError( const::SMESH_MeshEditor::Sew_Error e )
1497 {
1498   switch ( e ) {
1499   RETCASE( SEW_OK );
1500   RETCASE( SEW_BORDER1_NOT_FOUND );
1501   RETCASE( SEW_BORDER2_NOT_FOUND );
1502   RETCASE( SEW_BOTH_BORDERS_NOT_FOUND );
1503   RETCASE( SEW_BAD_SIDE_NODES );
1504   RETCASE( SEW_VOLUMES_TO_SPLIT );
1505   RETCASE( SEW_DIFF_NB_OF_ELEMENTS );
1506   RETCASE( SEW_TOPO_DIFF_SETS_OF_ELEMENTS );
1507   RETCASE( SEW_BAD_SIDE1_NODES );
1508   RETCASE( SEW_BAD_SIDE2_NODES );
1509   }
1510   return SMESH::SMESH_MeshEditor::SEW_OK;
1511 }
1512
1513 //=======================================================================
1514 //function : SewFreeBorders
1515 //purpose  :
1516 //=======================================================================
1517
1518 SMESH::SMESH_MeshEditor::Sew_Error
1519   SMESH_MeshEditor_i::SewFreeBorders(CORBA::Long FirstNodeID1,
1520                                      CORBA::Long SecondNodeID1,
1521                                      CORBA::Long LastNodeID1,
1522                                      CORBA::Long FirstNodeID2,
1523                                      CORBA::Long SecondNodeID2,
1524                                      CORBA::Long LastNodeID2,
1525                                      CORBA::Boolean CreatePolygons,
1526                                      CORBA::Boolean CreatePolyedrs)
1527 {
1528   SMESHDS_Mesh* aMesh = GetMeshDS();
1529
1530   const SMDS_MeshNode* aBorderFirstNode  = aMesh->FindNode( FirstNodeID1  );
1531   const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
1532   const SMDS_MeshNode* aBorderLastNode   = aMesh->FindNode( LastNodeID1   );
1533   const SMDS_MeshNode* aSide2FirstNode   = aMesh->FindNode( FirstNodeID2  );
1534   const SMDS_MeshNode* aSide2SecondNode  = aMesh->FindNode( SecondNodeID2 );
1535   const SMDS_MeshNode* aSide2ThirdNode   = aMesh->FindNode( LastNodeID2   );
1536
1537   if (!aBorderFirstNode ||
1538       !aBorderSecondNode||
1539       !aBorderLastNode)
1540     return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
1541   if (!aSide2FirstNode  ||
1542       !aSide2SecondNode ||
1543       !aSide2ThirdNode)
1544     return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
1545
1546   // Update Python script
1547   TPythonDump() << "error = " << this << ".SewFreeBorders( "
1548                 << FirstNodeID1  << ", "
1549                 << SecondNodeID1 << ", "
1550                 << LastNodeID1   << ", "
1551                 << FirstNodeID2  << ", "
1552                 << SecondNodeID2 << ", "
1553                 << LastNodeID2   << ", "
1554                 << CreatePolygons<< ", "
1555                 << CreatePolyedrs<< " )";
1556
1557   ::SMESH_MeshEditor anEditor( _myMesh );
1558   return convError( anEditor.SewFreeBorder (aBorderFirstNode,
1559                                             aBorderSecondNode,
1560                                             aBorderLastNode,
1561                                             aSide2FirstNode,
1562                                             aSide2SecondNode,
1563                                             aSide2ThirdNode,
1564                                             true,
1565                                             CreatePolygons,
1566                                             CreatePolyedrs) );
1567 }
1568
1569 //=======================================================================
1570 //function : SewConformFreeBorders
1571 //purpose  :
1572 //=======================================================================
1573
1574 SMESH::SMESH_MeshEditor::Sew_Error
1575 SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1,
1576                                           CORBA::Long SecondNodeID1,
1577                                           CORBA::Long LastNodeID1,
1578                                           CORBA::Long FirstNodeID2,
1579                                           CORBA::Long SecondNodeID2)
1580 {
1581   SMESHDS_Mesh* aMesh = GetMeshDS();
1582
1583   const SMDS_MeshNode* aBorderFirstNode  = aMesh->FindNode( FirstNodeID1  );
1584   const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
1585   const SMDS_MeshNode* aBorderLastNode   = aMesh->FindNode( LastNodeID1   );
1586   const SMDS_MeshNode* aSide2FirstNode   = aMesh->FindNode( FirstNodeID2  );
1587   const SMDS_MeshNode* aSide2SecondNode  = aMesh->FindNode( SecondNodeID2 );
1588   const SMDS_MeshNode* aSide2ThirdNode   = 0;
1589
1590   if (!aBorderFirstNode ||
1591       !aBorderSecondNode||
1592       !aBorderLastNode )
1593     return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
1594   if (!aSide2FirstNode  ||
1595       !aSide2SecondNode)
1596     return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
1597
1598   // Update Python script
1599   TPythonDump() << "error = " << this << ".SewConformFreeBorders( "
1600                 << FirstNodeID1  << ", "
1601                 << SecondNodeID1 << ", "
1602                 << LastNodeID1   << ", "
1603                 << FirstNodeID2  << ", "
1604                 << SecondNodeID2 << " )";
1605
1606   ::SMESH_MeshEditor anEditor( _myMesh );
1607   return convError( anEditor.SewFreeBorder (aBorderFirstNode,
1608                                             aBorderSecondNode,
1609                                             aBorderLastNode,
1610                                             aSide2FirstNode,
1611                                             aSide2SecondNode,
1612                                             aSide2ThirdNode,
1613                                             true,
1614                                             false, false) );
1615 }
1616
1617 //=======================================================================
1618 //function : SewBorderToSide
1619 //purpose  :
1620 //=======================================================================
1621
1622 SMESH::SMESH_MeshEditor::Sew_Error
1623 SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder,
1624                                     CORBA::Long SecondNodeIDOnFreeBorder,
1625                                     CORBA::Long LastNodeIDOnFreeBorder,
1626                                     CORBA::Long FirstNodeIDOnSide,
1627                                     CORBA::Long LastNodeIDOnSide,
1628                                     CORBA::Boolean CreatePolygons,
1629                                     CORBA::Boolean CreatePolyedrs)
1630 {
1631   SMESHDS_Mesh* aMesh = GetMeshDS();
1632
1633   const SMDS_MeshNode* aBorderFirstNode  = aMesh->FindNode( FirstNodeIDOnFreeBorder  );
1634   const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeIDOnFreeBorder );
1635   const SMDS_MeshNode* aBorderLastNode   = aMesh->FindNode( LastNodeIDOnFreeBorder   );
1636   const SMDS_MeshNode* aSide2FirstNode   = aMesh->FindNode( FirstNodeIDOnSide  );
1637   const SMDS_MeshNode* aSide2SecondNode  = aMesh->FindNode( LastNodeIDOnSide );
1638   const SMDS_MeshNode* aSide2ThirdNode   = 0;
1639
1640   if (!aBorderFirstNode ||
1641       !aBorderSecondNode||
1642       !aBorderLastNode  )
1643     return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
1644   if (!aSide2FirstNode  ||
1645       !aSide2SecondNode)
1646     return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE_NODES;
1647
1648   // Update Python script
1649   TPythonDump() << "error = " << this << ".SewBorderToSide( "
1650                 << FirstNodeIDOnFreeBorder  << ", "
1651                 << SecondNodeIDOnFreeBorder << ", "
1652                 << LastNodeIDOnFreeBorder   << ", "
1653                 << FirstNodeIDOnSide        << ", "
1654                 << LastNodeIDOnSide         << ", "
1655                 << CreatePolygons           << ", "
1656                 << CreatePolyedrs           << ") ";
1657
1658   ::SMESH_MeshEditor anEditor( _myMesh );
1659   return convError( anEditor.SewFreeBorder (aBorderFirstNode,
1660                                             aBorderSecondNode,
1661                                             aBorderLastNode,
1662                                             aSide2FirstNode,
1663                                             aSide2SecondNode,
1664                                             aSide2ThirdNode,
1665                                             false,
1666                                             CreatePolygons,
1667                                             CreatePolyedrs) );
1668 }
1669
1670 //=======================================================================
1671 //function : SewSideElements
1672 //purpose  :
1673 //=======================================================================
1674
1675 SMESH::SMESH_MeshEditor::Sew_Error
1676 SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements,
1677                                     const SMESH::long_array& IDsOfSide2Elements,
1678                                     CORBA::Long NodeID1OfSide1ToMerge,
1679                                     CORBA::Long NodeID1OfSide2ToMerge,
1680                                     CORBA::Long NodeID2OfSide1ToMerge,
1681                                     CORBA::Long NodeID2OfSide2ToMerge)
1682 {
1683   SMESHDS_Mesh* aMesh = GetMeshDS();
1684
1685   const SMDS_MeshNode* aFirstNode1ToMerge  = aMesh->FindNode( NodeID1OfSide1ToMerge );
1686   const SMDS_MeshNode* aFirstNode2ToMerge  = aMesh->FindNode( NodeID1OfSide2ToMerge );
1687   const SMDS_MeshNode* aSecondNode1ToMerge = aMesh->FindNode( NodeID2OfSide1ToMerge );
1688   const SMDS_MeshNode* aSecondNode2ToMerge = aMesh->FindNode( NodeID2OfSide2ToMerge );
1689
1690   if (!aFirstNode1ToMerge ||
1691       !aFirstNode2ToMerge )
1692     return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE1_NODES;
1693   if (!aSecondNode1ToMerge||
1694       !aSecondNode2ToMerge)
1695     return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE2_NODES;
1696
1697   set<const SMDS_MeshElement*> aSide1Elems, aSide2Elems;
1698   for (int i = 0; i < IDsOfSide1Elements.length(); i++)
1699   {
1700     CORBA::Long index = IDsOfSide1Elements[i];
1701     const SMDS_MeshElement * elem = aMesh->FindElement(index);
1702     if ( elem )
1703       aSide1Elems.insert( elem );
1704   }
1705   for (int i = 0; i < IDsOfSide2Elements.length(); i++)
1706   {
1707     CORBA::Long index = IDsOfSide2Elements[i];
1708     const SMDS_MeshElement * elem = aMesh->FindElement(index);
1709     if ( elem )
1710       aSide2Elems.insert( elem );
1711   }
1712   // Update Python script
1713   TPythonDump() << "error = " << this << ".SewSideElements( "
1714                 << IDsOfSide1Elements << ", "
1715                 << IDsOfSide2Elements << ", "
1716                 << NodeID1OfSide1ToMerge << ", "
1717                 << NodeID1OfSide2ToMerge << ", "
1718                 << NodeID2OfSide1ToMerge << ", "
1719                 << NodeID2OfSide2ToMerge << ")";
1720
1721   ::SMESH_MeshEditor anEditor( _myMesh );
1722   return convError( anEditor.SewSideElements (aSide1Elems, aSide2Elems,
1723                                               aFirstNode1ToMerge,
1724                                               aFirstNode2ToMerge,
1725                                               aSecondNode1ToMerge,
1726                                               aSecondNode2ToMerge));
1727 }