#include <NCollection_Array1.hxx>
#include <Precision.hxx>
#include <ShapeAnalysis.hxx>
+#include <ShapeAnalysis_Curve.hxx>
#include <ShapeAnalysis_Edge.hxx>
#include <ShapeAnalysis_Surface.hxx>
#include <ShapeAnalysis_Wire.hxx>
myFwd = Standard_True;
myStatus = 0;
myFixWire = new ShapeFix_Wire;
+ myTorusReverseFlag = Standard_True;
ClearModes();
}
myFwd = Standard_True;
myStatus = 0;
myFixWire = new ShapeFix_Wire;
+ myTorusReverseFlag = Standard_True;
ClearModes();
Init( face );
}
{
myStatus = 0;
mySurf = surf;
+ myTorusReverseFlag = Standard_True;
SetPrecision ( preci );
BRep_Builder B;
B.MakeFace ( myFace, mySurf->Surface(), ::Precision::Confusion() );
{
myStatus = 0;
mySurf = new ShapeAnalysis_Surface ( BRep_Tool::Surface (face) );
+ myTorusReverseFlag = Standard_True;
myFwd = ( face.Orientation() != TopAbs_REVERSED );
myFace = face;
+
+ if (mySurf->Surface()->IsKind(STANDARD_TYPE(Geom_ToroidalSurface)))
+ {
+ // it is needed to check if face includes temporary created natural bound.
+ // this bound was created in order to detect cases where face has only one
+ // wire and this wire is outer. it means that if material is placed out of it
+ // this wire haven`t be reversed - for such face must be created correct
+ // natural bound and existed wire becames hole.
+ // temporary natural bound must be removed.
+ TopoDS_Wire outW;
+ Standard_Integer nbw = 0;
+ for (TopExp_Explorer exp(myFace, TopAbs_WIRE); exp.More(); exp.Next())
+ {
+ nbw++;
+ TopoDS_Wire aW = TopoDS::Wire(exp.Current());
+ TopExp_Explorer ex(aW, TopAbs_EDGE);
+ Bnd_Box2d aBox;
+ ShapeAnalysis_Edge sae;
+ ShapeAnalysis_Curve sac;
+ for (; ex.More(); ex.Next()) {
+ TopoDS_Edge edge = TopoDS::Edge(ex.Current());
+ Handle(Geom2d_Curve) c2d;
+ Standard_Real f, l;
+ if (!sae.PCurve(edge, myFace, c2d, f, l, Standard_False)) continue;
+ sac.FillBndBox(c2d, f, l, 20, Standard_True, aBox);
+ }
+ if (aBox.IsVoid()) continue;
+ Standard_Real UMin, VMin, UMax, VMax;
+ aBox.Get(UMin, VMin, UMax, VMax);
+ Standard_Boolean hasOutW =
+ fabs(UMin) < Precision::PConfusion() && fabs(2 * M_PI - UMax) < Precision::PConfusion() &&
+ fabs(VMin) < Precision::PConfusion() && fabs(2 * M_PI - VMax) < Precision::PConfusion();
+ if (hasOutW)
+ {
+ // it is a temporary added natural bound
+ myTorusReverseFlag = Standard_False;
+ outW = aW;
+ }
+ }
+ if (nbw==2 && !myTorusReverseFlag)
+ {
+ // remove temporary added natural bound
+ BRep_Builder B;
+ myFace.Free(Standard_True);
+ B.Remove(myFace, outW);
+ }
+ }
+
myShape = myFace;
// myFace = TopoDS::Face(face.EmptyCopied());
// for (TopoDS_Iterator ws (face,Standard_False); ws.More(); ws.Next())
TopoDS_Face af = TopoDS::Face ( dummy );
af.Orientation ( TopAbs_FORWARD );
B.Add (af,ws.Value(1));
-
+
if ((myFixAddNaturalBoundMode != 1 ||
!IsSurfaceUVPeriodic(mySurf->Adaptor3d())) &&
!ShapeAnalysis::IsOuterBound(af))
{
- Handle(ShapeExtend_WireData) sbdw =
- new ShapeExtend_WireData(TopoDS::Wire(ws.Value(1)));
- sbdw->Reverse(myFace);
- ws.SetValue(1, sbdw->Wire());
- SendWarning(sbdw->Wire(), Message_Msg("FixAdvFace.FixOrientation.MSG5"));// Wire on face was reversed
- done = Standard_True;
+ Standard_Boolean needReverse = Standard_True;
+ if (mySurf->Surface()->IsKind(STANDARD_TYPE(Geom_ToroidalSurface)))
+ {
+ // detect situation when we have to use special flag for decision
+ // what part of torus must be used
+ Standard_Real SUF, SUL, SVF, SVL;
+ mySurf->Bounds(SUF, SUL, SVF, SVL);
+ Standard_Real aUmin, aUmax, aVmin, aVmax;
+ ShapeAnalysis::GetFaceUVBounds(myFace, aUmin, aUmax, aVmin, aVmax);
+ Standard_Boolean isInUmin = (aUmin > (SUF - Precision::PConfusion())) && (aUmin < (SUL + Precision::PConfusion()));
+ Standard_Boolean isInUmax = (aUmax > (SUF - Precision::PConfusion())) && (aUmax < (SUL + Precision::PConfusion()));
+ if ((isInUmin && !isInUmax) || (!isInUmin && isInUmax))
+ {
+ needReverse = myTorusReverseFlag;
+ }
+ }
+ if (needReverse)
+ {
+ Handle(ShapeExtend_WireData) sbdw =
+ new ShapeExtend_WireData(TopoDS::Wire(ws.Value(1)));
+ sbdw->Reverse(myFace);
+ ws.SetValue(1, sbdw->Wire());
+ SendWarning(sbdw->Wire(), Message_Msg("FixAdvFace.FixOrientation.MSG5"));// Wire on face was reversed
+ done = Standard_True;
+ }
}
}
// in case of several wires, perform complex analysis