From ff0eb5059635a08e20f3a86f144bc71a56b6aeb3 Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 22 Nov 2012 10:52:00 +0000 Subject: [PATCH] 0021888: [CEA 710] Change orientation does not work on edges Change reversing EDGE's to invert orientation of a curve --- .../ShHealOper_ChangeOrientation.cxx | 60 +++++++++++++++---- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/src/ShHealOper/ShHealOper_ChangeOrientation.cxx b/src/ShHealOper/ShHealOper_ChangeOrientation.cxx index 4d2fba884..2128cd539 100644 --- a/src/ShHealOper/ShHealOper_ChangeOrientation.cxx +++ b/src/ShHealOper/ShHealOper_ChangeOrientation.cxx @@ -26,10 +26,17 @@ #include -#include #include - +#include +#include +#include +#include +#include +#include +#include +#include #include +#include //======================================================================= //function : ShHealOper_ChangeOrientation() @@ -59,7 +66,8 @@ void ShHealOper_ChangeOrientation::Init(const TopoDS_Shape& theShape) Standard_Boolean ShHealOper_ChangeOrientation::Perform() { BRep_Builder B; - if (myInitShape.ShapeType() == TopAbs_SHELL) { + if (myInitShape.ShapeType() == TopAbs_SHELL) + { myResultShape = myInitShape.EmptyCopied(); TopoDS_Iterator itr (myInitShape); while (itr.More()) { @@ -67,7 +75,8 @@ Standard_Boolean ShHealOper_ChangeOrientation::Perform() itr.Next(); } } - else if (myInitShape.ShapeType() == TopAbs_FACE) { + else if (myInitShape.ShapeType() == TopAbs_FACE) + { myResultShape = myInitShape.EmptyCopied(); TopoDS_Iterator itr (myInitShape); while (itr.More()) { @@ -76,16 +85,43 @@ Standard_Boolean ShHealOper_ChangeOrientation::Perform() } myResultShape.Reverse(); } - 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(); + else if ( myInitShape.ShapeType() == TopAbs_WIRE || myInitShape.ShapeType() == TopAbs_EDGE) + { + TopTools_ListOfShape reversedEdges; + for ( TopExp_Explorer edgeIt( myInitShape, TopAbs_EDGE ); edgeIt.More(); edgeIt.Next() ) + { + const TopoDS_Edge& edge = TopoDS::Edge( edgeIt.Current() ); + + double f,l; + Handle(Geom_Curve) curve = BRep_Tool::Curve( edge, f,l ); + Handle(Geom_TrimmedCurve) tc = Handle(Geom_TrimmedCurve)::DownCast(curve); + if ( !tc.IsNull() ) curve = tc->BasisCurve(); + + f = curve->ReversedParameter( f ); + l = curve->ReversedParameter( l ); + curve = curve->Reversed(); + reversedEdges.Prepend( BRepBuilderAPI_MakeEdge( curve, Min( f, l ), Max( f, l ))); } - myResultShape.Reverse(); + if ( myInitShape.ShapeType() == TopAbs_EDGE ) + { + myResultShape = reversedEdges.First(); + } + else + { + BRepBuilderAPI_MakeWire wire; + wire.Add( reversedEdges ); + myResultShape = wire; + } + // myResultShape = myInitShape.EmptyCopied(); + // TopoDS_Iterator itr (myInitShape); + // while (itr.More()) { + // B.Add(myResultShape,itr.Value()); + // itr.Next(); + // } + // myResultShape.Reverse(); } - else { + else + { BRepBuilderAPI_Copy Copy (myInitShape); if (!Copy.IsDone()) return false; -- 2.39.2