0021888: [CEA 710] Change orientation does not work on edges

Change reversing EDGE's to invert orientation of a curve
This commit is contained in:
eap 2012-11-22 10:52:00 +00:00
parent 5ad7147996
commit ff0eb50596

View File

@ -26,10 +26,17 @@
#include <ShHealOper_ChangeOrientation.hxx> #include <ShHealOper_ChangeOrientation.hxx>
#include <BRep_Builder.hxx>
#include <BRepBuilderAPI_Copy.hxx> #include <BRepBuilderAPI_Copy.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRep_Builder.hxx>
#include <Geom_Curve.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Iterator.hxx> #include <TopoDS_Iterator.hxx>
#include <Geom_TrimmedCurve.hxx>
//======================================================================= //=======================================================================
//function : ShHealOper_ChangeOrientation() //function : ShHealOper_ChangeOrientation()
@ -59,7 +66,8 @@ void ShHealOper_ChangeOrientation::Init(const TopoDS_Shape& theShape)
Standard_Boolean ShHealOper_ChangeOrientation::Perform() Standard_Boolean ShHealOper_ChangeOrientation::Perform()
{ {
BRep_Builder B; BRep_Builder B;
if (myInitShape.ShapeType() == TopAbs_SHELL) { if (myInitShape.ShapeType() == TopAbs_SHELL)
{
myResultShape = myInitShape.EmptyCopied(); myResultShape = myInitShape.EmptyCopied();
TopoDS_Iterator itr (myInitShape); TopoDS_Iterator itr (myInitShape);
while (itr.More()) { while (itr.More()) {
@ -67,7 +75,8 @@ Standard_Boolean ShHealOper_ChangeOrientation::Perform()
itr.Next(); itr.Next();
} }
} }
else if (myInitShape.ShapeType() == TopAbs_FACE) { else if (myInitShape.ShapeType() == TopAbs_FACE)
{
myResultShape = myInitShape.EmptyCopied(); myResultShape = myInitShape.EmptyCopied();
TopoDS_Iterator itr (myInitShape); TopoDS_Iterator itr (myInitShape);
while (itr.More()) { while (itr.More()) {
@ -76,16 +85,43 @@ Standard_Boolean ShHealOper_ChangeOrientation::Perform()
} }
myResultShape.Reverse(); myResultShape.Reverse();
} }
else if ( myInitShape.ShapeType() == TopAbs_WIRE || myInitShape.ShapeType() == TopAbs_EDGE) { else if ( myInitShape.ShapeType() == TopAbs_WIRE || myInitShape.ShapeType() == TopAbs_EDGE)
myResultShape = myInitShape.EmptyCopied(); {
TopoDS_Iterator itr (myInitShape); TopTools_ListOfShape reversedEdges;
while (itr.More()) { for ( TopExp_Explorer edgeIt( myInitShape, TopAbs_EDGE ); edgeIt.More(); edgeIt.Next() )
B.Add(myResultShape,itr.Value()); {
itr.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 { 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
{
BRepBuilderAPI_Copy Copy (myInitShape); BRepBuilderAPI_Copy Copy (myInitShape);
if (!Copy.IsDone()) return false; if (!Copy.IsDone()) return false;