geom/src/ShHealOper/ShHealOper_ChangeOrientation.cxx

103 lines
3.2 KiB
C++
Raw Normal View History

2012-08-09 13:58:02 +06:00
// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
//
2012-08-09 13:58:02 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
2012-08-09 13:58:02 +06:00
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
2012-08-09 13:58:02 +06:00
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
2012-08-09 13:58:02 +06:00
// File: ShHealOper_ChangeOrientation.cxx
// Created: 11.07.06 11:46:45
// Author: Sergey KUUL
2012-08-09 13:58:02 +06:00
#include <ShHealOper_ChangeOrientation.hxx>
#include <BRep_Builder.hxx>
2012-08-09 13:58:02 +06:00
#include <BRepBuilderAPI_Copy.hxx>
#include <TopoDS_Iterator.hxx>
//=======================================================================
//function : ShHealOper_ChangeOrientation()
//purpose : Constructor
//=======================================================================
ShHealOper_ChangeOrientation::ShHealOper_ChangeOrientation ( const TopoDS_Shape& theShape )
{
Init(theShape);
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void ShHealOper_ChangeOrientation::Init(const TopoDS_Shape& theShape)
{
ShHealOper_Tool::Init(theShape);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
Standard_Boolean ShHealOper_ChangeOrientation::Perform()
{
BRep_Builder B;
if (myInitShape.ShapeType() == TopAbs_SHELL) {
myResultShape = myInitShape.EmptyCopied();
2012-08-09 13:58:02 +06:00
TopoDS_Iterator itr (myInitShape);
while (itr.More()) {
B.Add(myResultShape,itr.Value().Reversed());
itr.Next();
}
}
else if (myInitShape.ShapeType() == TopAbs_FACE) {
myResultShape = myInitShape.EmptyCopied();
2012-08-09 13:58:02 +06:00
TopoDS_Iterator itr (myInitShape);
while (itr.More()) {
B.Add(myResultShape,itr.Value());
itr.Next();
}
myResultShape.Reverse();
}
2012-08-09 13:58:02 +06:00
else if ( myInitShape.ShapeType() == TopAbs_WIRE || myInitShape.ShapeType() == TopAbs_EDGE) {
myResultShape = myInitShape.EmptyCopied();
TopoDS_Iterator itr (myInitShape);
while (itr.More()) {
B.Add(myResultShape,itr.Value());
itr.Next();
}
myResultShape.Reverse();
}
else {
2012-08-09 13:58:02 +06:00
BRepBuilderAPI_Copy Copy (myInitShape);
if (!Copy.IsDone()) return false;
myResultShape = Copy.Shape();
if (myResultShape.IsNull()) return false;
if (myResultShape.Orientation() == TopAbs_FORWARD)
myResultShape.Orientation(TopAbs_REVERSED);
else
myResultShape.Orientation(TopAbs_FORWARD);
}
return true;
}