Back to index

salome-geom  6.5.0
ShHealOper_ChangeOrientation.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File:      ShHealOper_ChangeOrientation.cxx
00024 // Created:   11.07.06 11:46:45
00025 // Author:    Sergey KUUL
00026 
00027 #include <ShHealOper_ChangeOrientation.hxx>
00028 
00029 #include <BRep_Builder.hxx>
00030 #include <BRepBuilderAPI_Copy.hxx>
00031 
00032 #include <TopoDS_Iterator.hxx>
00033 
00034 //=======================================================================
00035 //function : ShHealOper_ChangeOrientation()
00036 //purpose  : Constructor
00037 //=======================================================================
00038 
00039 ShHealOper_ChangeOrientation::ShHealOper_ChangeOrientation ( const TopoDS_Shape& theShape )
00040 {
00041   Init(theShape);
00042 }
00043 
00044 //=======================================================================
00045 //function : Init
00046 //purpose  : 
00047 //=======================================================================
00048 
00049 void ShHealOper_ChangeOrientation::Init(const TopoDS_Shape& theShape)
00050 {
00051   ShHealOper_Tool::Init(theShape);
00052 }
00053 
00054 //=======================================================================
00055 //function : Perform
00056 //purpose  : 
00057 //=======================================================================
00058 
00059 Standard_Boolean ShHealOper_ChangeOrientation::Perform()
00060 {
00061   BRep_Builder B;
00062   if (myInitShape.ShapeType() == TopAbs_SHELL) {
00063     myResultShape = myInitShape.EmptyCopied();
00064     TopoDS_Iterator itr (myInitShape);
00065     while (itr.More()) {
00066       B.Add(myResultShape,itr.Value().Reversed());
00067       itr.Next();
00068     }
00069   }
00070   else if (myInitShape.ShapeType() == TopAbs_FACE) {
00071     myResultShape = myInitShape.EmptyCopied();
00072     TopoDS_Iterator itr (myInitShape);
00073     while (itr.More()) {
00074       B.Add(myResultShape,itr.Value());
00075       itr.Next();
00076     }
00077     myResultShape.Reverse();
00078   }
00079   else if ( myInitShape.ShapeType() == TopAbs_WIRE || myInitShape.ShapeType() == TopAbs_EDGE) {
00080     myResultShape = myInitShape.EmptyCopied();
00081     TopoDS_Iterator itr (myInitShape);
00082     while (itr.More()) {
00083       B.Add(myResultShape,itr.Value());
00084       itr.Next();
00085     }
00086     myResultShape.Reverse();
00087   }
00088   else {
00089     BRepBuilderAPI_Copy Copy (myInitShape);
00090     if (!Copy.IsDone()) return false;
00091 
00092     myResultShape = Copy.Shape();
00093     if (myResultShape.IsNull()) return false;
00094 
00095     if (myResultShape.Orientation() == TopAbs_FORWARD)
00096       myResultShape.Orientation(TopAbs_REVERSED);
00097     else
00098       myResultShape.Orientation(TopAbs_FORWARD);
00099   }
00100 
00101   return true;
00102 }