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"
40 #include "utilities.h"
48 //=============================================================================
52 //=============================================================================
54 SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESH_Mesh* theMesh)
59 //=============================================================================
63 //=============================================================================
65 CORBA::Boolean SMESH_MeshEditor_i::RemoveElements(const SMESH::
66 long_array & IDsOfElements)
68 ::SMESH_MeshEditor anEditor( _myMesh );
70 for (int i = 0; i < IDsOfElements.length(); i++)
71 IdList.push_back( IDsOfElements[i] );
73 return anEditor.Remove( IdList, false );
76 //=============================================================================
80 //=============================================================================
82 CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::
83 long_array & IDsOfNodes)
85 ::SMESH_MeshEditor anEditor( _myMesh );
87 for (int i = 0; i < IDsOfNodes.length(); i++)
88 IdList.push_back( IDsOfNodes[i] );
90 return anEditor.Remove( IdList, true );
93 //=============================================================================
97 //=============================================================================
99 CORBA::Boolean SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes)
101 int NbNodes = IDsOfNodes.length();
104 CORBA::Long index1 = IDsOfNodes[0];
105 CORBA::Long index2 = IDsOfNodes[1];
106 GetMeshDS()->AddEdge(GetMeshDS()->FindNode(index1), GetMeshDS()->FindNode(index2));
111 //=============================================================================
115 //=============================================================================
117 CORBA::Boolean SMESH_MeshEditor_i::AddNode(CORBA::Double x,
118 CORBA::Double y, CORBA::Double z)
120 MESSAGE(" AddNode " << x << " , " << y << " , " << z)
121 int idNode = GetMeshDS()->AddNode(x, y, z)->GetID();
122 MESSAGE(" idNode " << idNode) return true;
125 //=============================================================================
129 //=============================================================================
131 CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
133 int NbNodes = IDsOfNodes.length();
134 const SMDS_MeshNode* nodes[4];
135 for(int i=0;i<NbNodes;i++) nodes[i]=GetMeshDS()->FindNode(IDsOfNodes[i]);
138 GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]);
140 else if (NbNodes == 4)
142 GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
147 //=============================================================================
151 //=============================================================================
153 CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH::
154 long_array & IDsOfNodes)
156 int NbNodes = IDsOfNodes.length();
157 const SMDS_MeshNode* n[8];
158 for(int i=0;i<NbNodes;i++) n[i]=GetMeshDS()->FindNode(IDsOfNodes[i]);
162 case 4:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3]); break;
163 case 5:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4]); break;
164 case 6:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5]); break;
165 case 8:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break;
170 //=============================================================================
174 //=============================================================================
176 CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long NodeID,
181 const SMDS_MeshNode * node = GetMeshDS()->FindNode( NodeID );
185 GetMeshDS()->MoveNode(node, x, y, z);
190 //=============================================================================
194 //=============================================================================
196 CORBA::Boolean SMESH_MeshEditor_i::InverseDiag(CORBA::Long NodeID1,
199 const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
200 const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
204 ::SMESH_MeshEditor aMeshEditor( _myMesh );
205 return aMeshEditor.InverseDiag ( n1, n2 );
208 //=============================================================================
212 //=============================================================================
214 CORBA::Boolean SMESH_MeshEditor_i::DeleteDiag(CORBA::Long NodeID1,
217 const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 );
218 const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 );
222 ::SMESH_MeshEditor aMeshEditor( _myMesh );
223 return aMeshEditor.DeleteDiag ( n1, n2 );
226 //=============================================================================
230 //=============================================================================
232 CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::long_array & IDsOfElements)
234 ::SMESH_MeshEditor anEditor( _myMesh );
235 for (int i = 0; i < IDsOfElements.length(); i++)
237 CORBA::Long index = IDsOfElements[i];
238 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
240 anEditor.Reorient( elem );
246 //=============================================================================
250 //=============================================================================
252 CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theObject)
254 SMESH::long_array_var anElementsId = theObject->GetIDs();
255 return Reorient(anElementsId);
258 //=============================================================================
262 //=============================================================================
265 SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfElements,
266 SMESH::NumericalFunctor_ptr Criterion,
267 CORBA::Double MaxAngle)
269 set<const SMDS_MeshElement*> faces;
270 for (int i = 0; i < IDsOfElements.length(); i++)
272 CORBA::Long index = IDsOfElements[i];
273 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
274 if ( elem && elem->GetType() == SMDSAbs_Face)
275 faces.insert( elem );
277 SMESH::NumericalFunctor_i* aNumericalFunctor =
278 dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
279 SMESH::Controls::NumericalFunctorPtr aCrit;
280 if ( !aNumericalFunctor )
281 aCrit.reset( new SMESH::Controls::AspectRatio() );
283 aCrit = aNumericalFunctor->GetNumericalFunctor();
285 ::SMESH_MeshEditor anEditor( _myMesh );
286 return anEditor.TriToQuad( faces, aCrit, MaxAngle );
289 //=============================================================================
293 //=============================================================================
296 SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr theObject,
297 SMESH::NumericalFunctor_ptr Criterion,
298 CORBA::Double MaxAngle)
300 SMESH::long_array_var anElementsId = theObject->GetIDs();
301 return TriToQuad(anElementsId, Criterion, MaxAngle);
304 //=============================================================================
308 //=============================================================================
311 SMESH_MeshEditor_i::QuadToTri(const SMESH::long_array & IDsOfElements,
312 SMESH::NumericalFunctor_ptr Criterion)
314 set<const SMDS_MeshElement*> faces;
315 for (int i = 0; i < IDsOfElements.length(); i++)
317 CORBA::Long index = IDsOfElements[i];
318 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
319 if ( elem && elem->GetType() == SMDSAbs_Face)
320 faces.insert( elem );
322 SMESH::NumericalFunctor_i* aNumericalFunctor =
323 dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
324 SMESH::Controls::NumericalFunctorPtr aCrit;
325 if ( !aNumericalFunctor )
326 aCrit.reset( new SMESH::Controls::AspectRatio() );
328 aCrit = aNumericalFunctor->GetNumericalFunctor();
330 ::SMESH_MeshEditor anEditor( _myMesh );
331 return anEditor.QuadToTri( faces, aCrit );
334 //=============================================================================
338 //=============================================================================
341 SMESH_MeshEditor_i::SplitQuad(const SMESH::long_array & IDsOfElements,
342 CORBA::Boolean Diag13)
344 set<const SMDS_MeshElement*> faces;
345 for (int i = 0; i < IDsOfElements.length(); i++)
347 CORBA::Long index = IDsOfElements[i];
348 const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index);
349 if ( elem && elem->GetType() == SMDSAbs_Face)
350 faces.insert( elem );
353 ::SMESH_MeshEditor anEditor( _myMesh );
354 return anEditor.QuadToTri( faces, Diag13 );
357 //=============================================================================
361 //=============================================================================
364 SMESH_MeshEditor_i::SplitQuadObject(SMESH::SMESH_IDSource_ptr theObject,
365 CORBA::Boolean Diag13)
367 SMESH::long_array_var anElementsId = theObject->GetIDs();
368 return SplitQuad(anElementsId, Diag13);
371 //=============================================================================
375 //=============================================================================
378 SMESH_MeshEditor_i::Smooth(const SMESH::long_array & IDsOfElements,
379 const SMESH::long_array & IDsOfFixedNodes,
380 CORBA::Long MaxNbOfIterations,
381 CORBA::Double MaxAspectRatio,
382 SMESH::SMESH_MeshEditor::Smooth_Method Method)
384 SMESHDS_Mesh* aMesh = GetMeshDS();
386 set<const SMDS_MeshElement*> elements;
387 for (int i = 0; i < IDsOfElements.length(); i++)
389 CORBA::Long index = IDsOfElements[i];
390 const SMDS_MeshElement * elem = aMesh->FindElement(index);
391 if ( elem && elem->GetType() == SMDSAbs_Face)
392 elements.insert( elem );
395 set<const SMDS_MeshNode*> fixedNodes;
396 for (int i = 0; i < IDsOfFixedNodes.length(); i++)
398 CORBA::Long index = IDsOfFixedNodes[i];
399 const SMDS_MeshNode * node = aMesh->FindNode(index);
401 fixedNodes.insert( node );
403 ::SMESH_MeshEditor::SmoothMethod method = ::SMESH_MeshEditor::LAPLACIAN;
404 if ( Method != SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH )
405 method = ::SMESH_MeshEditor::CENTROIDAL;
407 ::SMESH_MeshEditor anEditor( _myMesh );
408 anEditor.Smooth( elements, fixedNodes, method, MaxNbOfIterations, MaxAspectRatio );
413 //=============================================================================
417 //=============================================================================
420 SMESH_MeshEditor_i::SmoothObject(SMESH::SMESH_IDSource_ptr theObject,
421 const SMESH::long_array & IDsOfFixedNodes,
422 CORBA::Long MaxNbOfIterations,
423 CORBA::Double MaxAspectRatio,
424 SMESH::SMESH_MeshEditor::Smooth_Method Method)
426 SMESH::long_array_var anElementsId = theObject->GetIDs();
427 return Smooth(anElementsId, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method);
430 //=============================================================================
434 //=============================================================================
436 void SMESH_MeshEditor_i::RenumberNodes()
438 GetMeshDS()->Renumber( true );
441 //=============================================================================
445 //=============================================================================
447 void SMESH_MeshEditor_i::RenumberElements()
449 GetMeshDS()->Renumber( false );
452 //=======================================================================
453 //function : RotationSweep
455 //=======================================================================
457 void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElements,
458 const SMESH::AxisStruct & theAxis,
459 CORBA::Double theAngleInRadians,
460 CORBA::Long theNbOfSteps,
461 CORBA::Double theTolerance)
463 SMESHDS_Mesh* aMesh = GetMeshDS();
465 set<const SMDS_MeshElement*> elements;
466 for (int i = 0; i < theIDsOfElements.length(); i++)
468 CORBA::Long index = theIDsOfElements[i];
469 const SMDS_MeshElement * elem = aMesh->FindElement(index);
471 elements.insert( elem );
473 gp_Ax1 Ax1 (gp_Pnt( theAxis.x, theAxis.y, theAxis.z ),
474 gp_Vec( theAxis.vx, theAxis.vy, theAxis.vz ));
476 ::SMESH_MeshEditor anEditor( _myMesh );
477 anEditor.RotationSweep (elements, Ax1, theAngleInRadians,
478 theNbOfSteps, theTolerance);
481 //=======================================================================
482 //function : RotationSweepObject
484 //=======================================================================
486 void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject,
487 const SMESH::AxisStruct & theAxis,
488 CORBA::Double theAngleInRadians,
489 CORBA::Long theNbOfSteps,
490 CORBA::Double theTolerance)
492 SMESH::long_array_var anElementsId = theObject->GetIDs();
493 RotationSweep(anElementsId, theAxis, theAngleInRadians, theNbOfSteps, theTolerance);
496 //=======================================================================
497 //function : ExtrusionSweep
499 //=======================================================================
501 void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElements,
502 const SMESH::DirStruct & theStepVector,
503 CORBA::Long theNbOfSteps)
505 SMESHDS_Mesh* aMesh = GetMeshDS();
507 set<const SMDS_MeshElement*> elements;
508 for (int i = 0; i < theIDsOfElements.length(); i++)
510 CORBA::Long index = theIDsOfElements[i];
511 const SMDS_MeshElement * elem = aMesh->FindElement(index);
513 elements.insert( elem );
515 const SMESH::PointStruct * P = &theStepVector.PS;
516 gp_Vec stepVec( P->x, P->y, P->z );
518 ::SMESH_MeshEditor anEditor( _myMesh );
519 anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
523 //=======================================================================
524 //function : ExtrusionSweepObject
526 //=======================================================================
528 void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObject,
529 const SMESH::DirStruct & theStepVector,
530 CORBA::Long theNbOfSteps)
532 SMESH::long_array_var anElementsId = theObject->GetIDs();
533 ExtrusionSweep(anElementsId, theStepVector, theNbOfSteps);
536 //=======================================================================
537 //function : ExtrusionAlongPath
539 //=======================================================================
541 void SMESH_MeshEditor_i::ExtrusionAlongPath(const SMESH::long_array & theIDsOfElements,
542 SMESH::SMESH_Mesh_ptr thePathMesh,
543 GEOM::GEOM_Object_ptr thePathShape,
544 CORBA::Long theNodeStart,
545 CORBA::Boolean theHasAngles,
546 const SMESH::double_array & theAngles,
547 CORBA::Boolean theHasRefPoint,
548 const SMESH::PointStruct & theRefPoint)
550 SMESHDS_Mesh* aMesh = GetMeshDS();
552 if ( thePathMesh->_is_nil() || thePathShape->_is_nil() )
555 SMESH_Mesh_i* aMeshImp = dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetServant( thePathMesh ).in() );
556 TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
557 SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
562 SMDS_MeshNode* nodeStart = (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(theNodeStart);
566 set<const SMDS_MeshElement*> elements;
567 for (int i = 0; i < theIDsOfElements.length(); i++)
569 CORBA::Long index = theIDsOfElements[i];
570 const SMDS_MeshElement * elem = aMesh->FindElement(index);
572 elements.insert( elem );
576 for (int i = 0; i < theAngles.length(); i++)
578 angles.push_back( theAngles[i] );
581 gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z );
583 ::SMESH_MeshEditor anEditor( _myMesh );
584 int res = anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart, theHasAngles, angles, theHasRefPoint, refPnt );
587 //=======================================================================
588 //function : ExtrusionAlongPathObject
590 //=======================================================================
592 void SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject,
593 SMESH::SMESH_Mesh_ptr thePathMesh,
594 GEOM::GEOM_Object_ptr thePathShape,
595 CORBA::Long theNodeStart,
596 CORBA::Boolean theHasAngles,
597 const SMESH::double_array & theAngles,
598 CORBA::Boolean theHasRefPoint,
599 const SMESH::PointStruct & theRefPoint)
601 SMESH::long_array_var anElementsId = theObject->GetIDs();
602 ExtrusionAlongPath( anElementsId, thePathMesh, thePathShape, theNodeStart, theHasAngles, theAngles, theHasRefPoint, theRefPoint );
605 //=======================================================================
608 //=======================================================================
610 void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElements,
611 const SMESH::AxisStruct & theAxis,
612 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
613 CORBA::Boolean theCopy)
615 SMESHDS_Mesh* aMesh = GetMeshDS();
617 set<const SMDS_MeshElement*> elements;
618 for (int i = 0; i < theIDsOfElements.length(); i++)
620 CORBA::Long index = theIDsOfElements[i];
621 const SMDS_MeshElement * elem = aMesh->FindElement(index);
623 elements.insert( elem );
625 gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
626 gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
629 switch ( theMirrorType ) {
630 case SMESH::SMESH_MeshEditor::POINT:
631 aTrsf.SetMirror( P );
633 case SMESH::SMESH_MeshEditor::AXIS:
634 aTrsf.SetMirror( gp_Ax1( P, V ));
637 aTrsf.SetMirror( gp_Ax2( P, V ));
640 ::SMESH_MeshEditor anEditor( _myMesh );
641 anEditor.Transform (elements, aTrsf, theCopy);
644 //=======================================================================
645 //function : MirrorObject
647 //=======================================================================
649 void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObject,
650 const SMESH::AxisStruct & theAxis,
651 SMESH::SMESH_MeshEditor::MirrorType theMirrorType,
652 CORBA::Boolean theCopy)
654 SMESH::long_array_var anElementsId = theObject->GetIDs();
655 Mirror(anElementsId, theAxis, theMirrorType, theCopy);
658 //=======================================================================
659 //function : Translate
661 //=======================================================================
663 void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements,
664 const SMESH::DirStruct & theVector,
665 CORBA::Boolean theCopy)
667 SMESHDS_Mesh* aMesh = GetMeshDS();
669 set<const SMDS_MeshElement*> elements;
670 for (int i = 0; i < theIDsOfElements.length(); i++)
672 CORBA::Long index = theIDsOfElements[i];
673 const SMDS_MeshElement * elem = aMesh->FindElement(index);
675 elements.insert( elem );
678 const SMESH::PointStruct * P = &theVector.PS;
679 aTrsf.SetTranslation( gp_Vec( P->x, P->y, P->z ));
681 ::SMESH_MeshEditor anEditor( _myMesh );
682 anEditor.Transform (elements, aTrsf, theCopy);
685 //=======================================================================
686 //function : TranslateObject
688 //=======================================================================
690 void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject,
691 const SMESH::DirStruct & theVector,
692 CORBA::Boolean theCopy)
694 SMESH::long_array_var anElementsId = theObject->GetIDs();
695 Translate(anElementsId, theVector, theCopy);
698 //=======================================================================
701 //=======================================================================
703 void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements,
704 const SMESH::AxisStruct & theAxis,
705 CORBA::Double theAngle,
706 CORBA::Boolean theCopy)
708 SMESHDS_Mesh* aMesh = GetMeshDS();
710 set<const SMDS_MeshElement*> elements;
711 for (int i = 0; i < theIDsOfElements.length(); i++)
713 CORBA::Long index = theIDsOfElements[i];
714 const SMDS_MeshElement * elem = aMesh->FindElement(index);
716 elements.insert( elem );
718 gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
719 gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
722 aTrsf.SetRotation( gp_Ax1( P, V ), theAngle);
725 ::SMESH_MeshEditor anEditor( _myMesh );
726 anEditor.Transform (elements, aTrsf, theCopy);
729 //=======================================================================
730 //function : RotateObject
732 //=======================================================================
734 void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject,
735 const SMESH::AxisStruct & theAxis,
736 CORBA::Double theAngle,
737 CORBA::Boolean theCopy)
739 SMESH::long_array_var anElementsId = theObject->GetIDs();
740 Rotate(anElementsId, theAxis, theAngle, theCopy);
743 //=======================================================================
744 //function : FindCoincidentNodes
746 //=======================================================================
748 void SMESH_MeshEditor_i::FindCoincidentNodes (CORBA::Double Tolerance,
749 SMESH::array_of_long_array_out GroupsOfNodes)
751 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
752 ::SMESH_MeshEditor anEditor( _myMesh );
753 set<const SMDS_MeshNode*> nodes; // no input nodes
754 anEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
756 GroupsOfNodes = new SMESH::array_of_long_array;
757 GroupsOfNodes->length( aListOfListOfNodes.size() );
758 ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin();
759 for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ )
761 list< const SMDS_MeshNode* >& aListOfNodes = *llIt;
762 list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();;
763 SMESH::long_array& aGroup = GroupsOfNodes[ i ];
764 aGroup.length( aListOfNodes.size() );
765 for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
766 aGroup[ j ] = (*lIt)->GetID();
770 //=======================================================================
771 //function : MergeNodes
773 //=======================================================================
775 void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes)
777 SMESHDS_Mesh* aMesh = GetMeshDS();
779 ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
780 list<const SMDS_MeshElement*> elements;
781 for (int i = 0; i < GroupsOfNodes.length(); i++)
783 const SMESH::long_array& aNodeGroup = GroupsOfNodes[ i ];
784 aListOfListOfNodes.push_back( list< const SMDS_MeshNode* >() );
785 list< const SMDS_MeshNode* >& aListOfNodes = aListOfListOfNodes.back();
786 for ( int j = 0; j < aNodeGroup.length(); j++ )
788 CORBA::Long index = aNodeGroup[ j ];
789 const SMDS_MeshNode * node = aMesh->FindNode(index);
791 aListOfNodes.push_back( node );
793 if ( aListOfNodes.size() < 2 )
794 aListOfListOfNodes.pop_back();
796 ::SMESH_MeshEditor anEditor( _myMesh );
797 anEditor.MergeNodes( aListOfListOfNodes );
800 //=======================================================================
801 //function : MergeEqualElements
803 //=======================================================================
805 void SMESH_MeshEditor_i::MergeEqualElements()
807 ::SMESH_MeshEditor anEditor( _myMesh );
808 anEditor.MergeEqualElements();
811 //=======================================================================
812 //function : operator
814 //=======================================================================
816 #define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
818 SMESH::SMESH_MeshEditor::Sew_Error convError( const::SMESH_MeshEditor::Sew_Error e )
822 RETCASE( SEW_BORDER1_NOT_FOUND );
823 RETCASE( SEW_BORDER2_NOT_FOUND );
824 RETCASE( SEW_BOTH_BORDERS_NOT_FOUND );
825 RETCASE( SEW_BAD_SIDE_NODES );
826 RETCASE( SEW_VOLUMES_TO_SPLIT );
827 RETCASE( SEW_DIFF_NB_OF_ELEMENTS );
828 RETCASE( SEW_TOPO_DIFF_SETS_OF_ELEMENTS );
829 RETCASE( SEW_BAD_SIDE1_NODES );
830 RETCASE( SEW_BAD_SIDE2_NODES );
832 return SMESH::SMESH_MeshEditor::SEW_OK;
835 //=======================================================================
836 //function : SewFreeBorders
838 //=======================================================================
840 SMESH::SMESH_MeshEditor::Sew_Error
841 SMESH_MeshEditor_i::SewFreeBorders(CORBA::Long FirstNodeID1,
842 CORBA::Long SecondNodeID1,
843 CORBA::Long LastNodeID1,
844 CORBA::Long FirstNodeID2,
845 CORBA::Long SecondNodeID2,
846 CORBA::Long LastNodeID2)
848 SMESHDS_Mesh* aMesh = GetMeshDS();
850 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
851 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
852 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
853 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
854 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
855 const SMDS_MeshNode* aSide2ThirdNode = aMesh->FindNode( LastNodeID2 );
857 if (!aBorderFirstNode ||
860 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
861 if (!aSide2FirstNode ||
864 return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
866 ::SMESH_MeshEditor anEditor( _myMesh );
867 return convError( anEditor.SewFreeBorder (aBorderFirstNode,
876 //=======================================================================
877 //function : SewConformFreeBorders
879 //=======================================================================
881 SMESH::SMESH_MeshEditor::Sew_Error
882 SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1,
883 CORBA::Long SecondNodeID1,
884 CORBA::Long LastNodeID1,
885 CORBA::Long FirstNodeID2,
886 CORBA::Long SecondNodeID2)
888 SMESHDS_Mesh* aMesh = GetMeshDS();
890 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 );
891 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 );
892 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 );
893 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 );
894 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 );
895 const SMDS_MeshNode* aSide2ThirdNode = 0;
897 if (!aBorderFirstNode ||
900 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
901 if (!aSide2FirstNode ||
903 return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
905 ::SMESH_MeshEditor anEditor( _myMesh );
906 return convError( anEditor.SewFreeBorder (aBorderFirstNode,
915 //=======================================================================
916 //function : SewBorderToSide
918 //=======================================================================
920 SMESH::SMESH_MeshEditor::Sew_Error
921 SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder,
922 CORBA::Long SecondNodeIDOnFreeBorder,
923 CORBA::Long LastNodeIDOnFreeBorder,
924 CORBA::Long FirstNodeIDOnSide,
925 CORBA::Long LastNodeIDOnSide)
927 SMESHDS_Mesh* aMesh = GetMeshDS();
929 const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeIDOnFreeBorder );
930 const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeIDOnFreeBorder );
931 const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeIDOnFreeBorder );
932 const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeIDOnSide );
933 const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( LastNodeIDOnSide );
934 const SMDS_MeshNode* aSide2ThirdNode = 0;
936 if (!aBorderFirstNode ||
939 return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND;
940 if (!aSide2FirstNode ||
942 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE_NODES;
944 ::SMESH_MeshEditor anEditor( _myMesh );
945 return convError( anEditor.SewFreeBorder (aBorderFirstNode,
954 //=======================================================================
955 //function : SewSideElements
957 //=======================================================================
959 SMESH::SMESH_MeshEditor::Sew_Error
960 SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements,
961 const SMESH::long_array& IDsOfSide2Elements,
962 CORBA::Long NodeID1OfSide1ToMerge,
963 CORBA::Long NodeID1OfSide2ToMerge,
964 CORBA::Long NodeID2OfSide1ToMerge,
965 CORBA::Long NodeID2OfSide2ToMerge)
967 SMESHDS_Mesh* aMesh = GetMeshDS();
969 const SMDS_MeshNode* aFirstNode1ToMerge = aMesh->FindNode( NodeID1OfSide1ToMerge );
970 const SMDS_MeshNode* aFirstNode2ToMerge = aMesh->FindNode( NodeID1OfSide2ToMerge );
971 const SMDS_MeshNode* aSecondNode1ToMerge = aMesh->FindNode( NodeID2OfSide1ToMerge );
972 const SMDS_MeshNode* aSecondNode2ToMerge = aMesh->FindNode( NodeID2OfSide2ToMerge );
974 if (!aFirstNode1ToMerge ||
975 !aFirstNode2ToMerge )
976 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE1_NODES;
977 if (!aSecondNode1ToMerge||
978 !aSecondNode2ToMerge)
979 return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE2_NODES;
981 set<const SMDS_MeshElement*> aSide1Elems, aSide2Elems;
982 for (int i = 0; i < IDsOfSide1Elements.length(); i++)
984 CORBA::Long index = IDsOfSide1Elements[i];
985 const SMDS_MeshElement * elem = aMesh->FindElement(index);
987 aSide1Elems.insert( elem );
989 for (int i = 0; i < IDsOfSide2Elements.length(); i++)
991 CORBA::Long index = IDsOfSide2Elements[i];
992 const SMDS_MeshElement * elem = aMesh->FindElement(index);
994 aSide2Elems.insert( elem );
996 ::SMESH_MeshEditor anEditor( _myMesh );
997 return convError( anEditor.SewSideElements (aSide1Elems, aSide2Elems,
1000 aSecondNode1ToMerge,
1001 aSecondNode2ToMerge));