Salome HOME
Update copyright
[modules/geom.git] / src / ShHealOper / ShHealOper_ChangeOrientation.cxx
1 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:      ShHealOper_ChangeOrientation.cxx
24 // Created:   11.07.06 11:46:45
25 // Author:    Sergey KUUL
26 //
27 #include <ShHealOper_ChangeOrientation.hxx>
28
29 #include <BRep_Builder.hxx>
30 #include <TopoDS_Iterator.hxx>
31
32 //=======================================================================
33 //function : ShHealOper_ChangeOrientation()
34 //purpose  : Constructor
35 //=======================================================================
36
37 ShHealOper_ChangeOrientation::ShHealOper_ChangeOrientation ( const TopoDS_Shape& theShape )
38 {
39   Init(theShape);
40 }
41
42 //=======================================================================
43 //function : Init
44 //purpose  : 
45 //=======================================================================
46
47 void ShHealOper_ChangeOrientation::Init(const TopoDS_Shape& theShape)
48 {
49   ShHealOper_Tool::Init(theShape);
50 }
51
52 //=======================================================================
53 //function : Perform
54 //purpose  : 
55 //=======================================================================
56
57 Standard_Boolean ShHealOper_ChangeOrientation::Perform()
58 {
59   BRep_Builder B;
60   if (myInitShape.ShapeType() == TopAbs_SHELL) {
61     myResultShape = myInitShape.EmptyCopied();
62     TopoDS_Iterator itr(myInitShape);
63     while (itr.More()) {
64       B.Add(myResultShape,itr.Value().Reversed());
65       itr.Next();
66     }
67   }
68   else if (myInitShape.ShapeType() == TopAbs_FACE) {
69     myResultShape = myInitShape.EmptyCopied();
70     TopoDS_Iterator itr(myInitShape);
71     while (itr.More()) {
72       B.Add(myResultShape,itr.Value());
73       itr.Next();
74     }
75     myResultShape.Reverse();
76   }
77   else if ( myInitShape.ShapeType() == TopAbs_WIRE || myInitShape.ShapeType() == TopAbs_EDGE) {
78     myResultShape = myInitShape.EmptyCopied();
79     TopoDS_Iterator itr(myInitShape);
80     while (itr.More()) {
81       B.Add(myResultShape,itr.Value());
82       itr.Next();
83     }
84     myResultShape.Reverse();
85   }
86   else {
87     return false;
88   }
89
90   return true;
91
92 }