1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-16 10:08:36 +03:00

0031986: Visualization - Regression in StdPrs_WFDeflectionRestrictedFace::Add()

Fixed misplaced closing bracket after #0030146 fix.
This commit is contained in:
kgv 2020-12-07 13:39:07 +03:00 committed by bugmaster
parent 954caad094
commit c74e3dc300

View File

@ -107,30 +107,26 @@ void StdPrs_WFDeflectionRestrictedFace::Add
const Standard_Integer NBUiso, const Standard_Integer NBUiso,
const Standard_Integer NBViso, const Standard_Integer NBViso,
const Handle(Prs3d_Drawer)& aDrawer, const Handle(Prs3d_Drawer)& aDrawer,
Prs3d_NListOfSequenceOfPnt& Curves) { Prs3d_NListOfSequenceOfPnt& Curves)
{
#ifdef OCCT_DEBUG_MESH #ifdef OCCT_DEBUG_MESH
FFaceTimer1.Start(); FFaceTimer1.Start();
#endif #endif
StdPrs_ToolRFace ToolRst (aFace); StdPrs_ToolRFace ToolRst (aFace);
Standard_Real UF, UL, VF, VL; const Standard_Real UF = aFace->FirstUParameter();
UF = aFace->FirstUParameter(); const Standard_Real UL = aFace->LastUParameter();
UL = aFace->LastUParameter(); const Standard_Real VF = aFace->FirstVParameter();
VF = aFace->FirstVParameter(); const Standard_Real VL = aFace->LastVParameter();
VL = aFace->LastVParameter();
Standard_Real aLimit = aDrawer->MaximalParameterValue(); const Standard_Real aLimit = aDrawer->MaximalParameterValue();
// compute bounds of the restriction // compute bounds of the restriction
Standard_Real UMin,UMax,VMin,VMax; Standard_Real UMin = Max (UF, -aLimit);
//Standard_Real u,v,step; Standard_Real UMax = Min (UL, aLimit);
Standard_Integer i;//,nbPoints = 10; Standard_Real VMin = Max (VF, -aLimit);
Standard_Real VMax = Min (VL, aLimit);
UMin = Max(UF, -aLimit);
UMax = Min(UL, aLimit);
VMin = Max(VF, -aLimit);
VMax = Min(VL, aLimit);
// update min max for the hatcher. // update min max for the hatcher.
@ -144,96 +140,112 @@ void StdPrs_WFDeflectionRestrictedFace::Add
UMin = VMin = 1.e100; UMin = VMin = 1.e100;
UMax = VMax = -1.e100; UMax = VMax = -1.e100;
for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) { for (ToolRst.Init(); ToolRst.More(); ToolRst.Next())
TopAbs_Orientation Orient = ToolRst.Orientation(); {
const Adaptor2d_Curve2d* TheRCurve = &ToolRst.Value(); const TopAbs_Orientation anOrient = ToolRst.Orientation();
if (TheRCurve->GetType() != GeomAbs_Line) { const Adaptor2d_Curve2d* TheRCurve = &ToolRst.Value();
GCPnts_QuasiUniformDeflection UDP(*TheRCurve, ddefle); if (TheRCurve->GetType() != GeomAbs_Line)
if (UDP.IsDone()) { {
Standard_Integer NumberOfPoints = UDP.NbPoints(); GCPnts_QuasiUniformDeflection UDP (*TheRCurve, ddefle);
if ( NumberOfPoints >= 2 ) { if (UDP.IsDone())
dummypnt = UDP.Value(1); {
P2.SetCoord(dummypnt.X(), dummypnt.Y()); const Standard_Integer aNumberOfPoints = UDP.NbPoints();
UMin = Min(P2.X(), UMin); if (aNumberOfPoints >= 2)
UMax = Max(P2.X(), UMax); {
VMin = Min(P2.Y(), VMin); dummypnt = UDP.Value (1);
VMax = Max(P2.Y(), VMax); P2.SetCoord (dummypnt.X(), dummypnt.Y());
for (i = 2; i <= NumberOfPoints; i++) { UMin = Min(P2.X(), UMin);
P1 = P2; UMax = Max(P2.X(), UMax);
dummypnt = UDP.Value(i); VMin = Min(P2.Y(), VMin);
P2.SetCoord(dummypnt.X(), dummypnt.Y()); VMax = Max(P2.Y(), VMax);
UMin = Min(P2.X(), UMin); for (Standard_Integer i = 2; i <= aNumberOfPoints; i++)
UMax = Max(P2.X(), UMax); {
VMin = Min(P2.Y(), VMin); P1 = P2;
VMax = Max(P2.Y(), VMax); dummypnt = UDP.Value(i);
aHatchingTol = Min(P1.SquareDistance(P2), aHatchingTol); P2.SetCoord(dummypnt.X(), dummypnt.Y());
UMin = Min(P2.X(), UMin);
UMax = Max(P2.X(), UMax);
VMin = Min(P2.Y(), VMin);
VMax = Max(P2.Y(), VMax);
aHatchingTol = Min (P1.SquareDistance (P2), aHatchingTol);
if(Orient == TopAbs_FORWARD ) { if (anOrient == TopAbs_FORWARD)
//isobuild.Trim(P1,P2); {
tabP.Append(P1); //isobuild.Trim (P1, P2);
tabP.Append(P2); tabP.Append (P1);
} tabP.Append (P2);
else { }
//isobuild.Trim(P2,P1); else
tabP.Append(P2); {
tabP.Append(P1); //isobuild.Trim (P2, P1);
} tabP.Append (P2);
} tabP.Append (P1);
} }
#ifdef OCCT_DEBUG }
else {
std::cout << "Cannot evaluate curve on surface"<<std::endl;
}
#endif
}
else {
U1 = TheRCurve->FirstParameter();
U2 = TheRCurve->LastParameter();
// MSV 17.08.06 OCC13144: U2 occured less than U1, to overcome it
// ensure that distance U2-U1 is not greater than aLimit*2,
// if greater then choose an origin and use aLimit to define
// U1 and U2 anew
Standard_Real aOrigin = 0.;
if (!Precision::IsNegativeInfinite(U1) || !Precision::IsPositiveInfinite(U2)) {
if (Precision::IsNegativeInfinite(U1))
aOrigin = U2 - aLimit;
else if (Precision::IsPositiveInfinite(U2))
aOrigin = U1 + aLimit;
else
aOrigin = (U1 + U2) * 0.5;
} }
U1 = Max(aOrigin - aLimit, U1); }
U2 = Min(aOrigin + aLimit, U2); else
P1 = TheRCurve->Value(U1); {
P2 = TheRCurve->Value(U2); #ifdef OCCT_DEBUG
UMin = Min(P1.X(), UMin); std::cout << "Cannot evaluate curve on surface" << std::endl;
UMax = Max(P1.X(), UMax); #endif
VMin = Min(P1.Y(), VMin); }
VMax = Max(P1.Y(), VMax); }
UMin = Min(P2.X(), UMin); else
UMax = Max(P2.X(), UMax); {
VMin = Min(P2.Y(), VMin); U1 = TheRCurve->FirstParameter();
VMax = Max(P2.Y(), VMax); U2 = TheRCurve->LastParameter();
aHatchingTol = Min(P1.SquareDistance(P2), aHatchingTol); // MSV 17.08.06 OCC13144: U2 occurred less than U1,
// to overcome it ensure that distance U2-U1 is not greater than aLimit*2,
// if greater then choose an origin and use aLimit to define U1 and U2 anew
Standard_Real aOrigin = 0.;
if (!Precision::IsNegativeInfinite (U1)
|| !Precision::IsPositiveInfinite (U2))
{
if (Precision::IsNegativeInfinite (U1))
{
aOrigin = U2 - aLimit;
}
else if (Precision::IsPositiveInfinite (U2))
{
aOrigin = U1 + aLimit;
}
else
{
aOrigin = (U1 + U2) * 0.5;
}
}
U1 = Max(aOrigin - aLimit, U1);
U2 = Min(aOrigin + aLimit, U2);
P1 = TheRCurve->Value(U1);
P2 = TheRCurve->Value(U2);
UMin = Min(P1.X(), UMin);
UMax = Max(P1.X(), UMax);
VMin = Min(P1.Y(), VMin);
VMax = Max(P1.Y(), VMax);
UMin = Min(P2.X(), UMin);
UMax = Max(P2.X(), UMax);
VMin = Min(P2.Y(), VMin);
VMax = Max(P2.Y(), VMax);
aHatchingTol = Min(P1.SquareDistance(P2), aHatchingTol);
if(Orient == TopAbs_FORWARD ) { if (anOrient == TopAbs_FORWARD)
// isobuild.Trim(P1,P2); {
tabP.Append(P1); // isobuild.Trim (P1, P2);
tabP.Append(P2); tabP.Append (P1);
} tabP.Append (P2);
else { }
//isobuild.Trim(P2,P1); else
tabP.Append(P2); {
tabP.Append(P1); //isobuild.Trim (P2, P1);
} tabP.Append (P2);
tabP.Append (P1);
} }
} }
} }
#ifdef OCCT_DEBUG_MESH #ifdef OCCT_DEBUG_MESH
FFaceTimer1.Stop(); FFaceTimer1.Stop();
FFaceTimer2.Start(); FFaceTimer2.Start();
#endif #endif
@ -243,35 +255,41 @@ void StdPrs_WFDeflectionRestrictedFace::Add
aHatchingTol = Min(1.e-5, aHatchingTol); aHatchingTol = Min(1.e-5, aHatchingTol);
// load the isos // load the isos
Hatch_Hatcher isobuild(aHatchingTol, ToolRst.IsOriented()); Hatch_Hatcher isobuild (aHatchingTol, ToolRst.IsOriented());
Standard_Boolean UClosed = aFace->IsUClosed(); Standard_Boolean isUClosed = aFace->IsUClosed();
Standard_Boolean VClosed = aFace->IsVClosed(); Standard_Boolean isVClosed = aFace->IsVClosed();
if (!isUClosed)
if ( ! UClosed ) { {
UMin = UMin + ( UMax - UMin) /1000.; UMin = UMin + (UMax - UMin) / 1000.;
UMax = UMax - ( UMax - UMin) /1000.; UMax = UMax - (UMax - UMin) / 1000.;
}
if (!isVClosed)
{
VMin = VMin + (VMax - VMin) / 1000.;
VMax = VMax - (VMax - VMin) / 1000.;
} }
if ( ! VClosed ) { if (DrawUIso)
VMin = VMin + ( VMax - VMin) /1000.; {
VMax = VMax - ( VMax - VMin) /1000.; if (NBUiso > 0)
} {
isUClosed = Standard_False; // En attendant un hatcher de course.
if (DrawUIso){ Standard_Real du= isUClosed ? (UMax - UMin) / NBUiso : (UMax - UMin) / (1 + NBUiso);
if (NBUiso > 0) { for (Standard_Integer i = 1; i <= NBUiso; i++)
UClosed = Standard_False; // En attendant un hatcher de course. {
Standard_Real du= UClosed ? (UMax-UMin)/NBUiso : (UMax-UMin)/(1+NBUiso); isobuild.AddXLine (UMin + du * i);
for (i=1; i<=NBUiso;i++){
isobuild.AddXLine(UMin+du*i);
} }
} }
} }
if (DrawVIso){ if (DrawVIso)
if ( NBViso > 0) { {
VClosed = Standard_False; if (NBViso > 0)
Standard_Real dv= VClosed ?(VMax-VMin)/NBViso : (VMax-VMin)/(1+NBViso); {
for (i=1; i<=NBViso;i++){ isVClosed = Standard_False;
isobuild.AddYLine(VMin+dv*i); Standard_Real dv= isVClosed ? (VMax - VMin) / NBViso : (VMax - VMin) / (1 + NBViso);
for (Standard_Integer i = 1; i <= NBViso; i++)
{
isobuild.AddYLine (VMin + dv * i);
} }
} }
} }
@ -283,11 +301,11 @@ void StdPrs_WFDeflectionRestrictedFace::Add
Standard_Integer ll = tabP.Length(); Standard_Integer ll = tabP.Length();
for (i = 1; i <= ll; i+=2) { for (Standard_Integer i = 1; i <= ll; i+=2)
isobuild.Trim(tabP(i),tabP(i+1)); {
isobuild.Trim (tabP(i), tabP(i+1));
} }
#ifdef OCCT_DEBUG_MESH #ifdef OCCT_DEBUG_MESH
FFaceTimer3.Stop(); FFaceTimer3.Stop();
FFaceTimer4.Start(); FFaceTimer4.Start();
@ -301,50 +319,65 @@ void StdPrs_WFDeflectionRestrictedFace::Add
const BRepAdaptor_Surface& BS = *(BRepAdaptor_Surface*)&(aFace->Surface()); const BRepAdaptor_Surface& BS = *(BRepAdaptor_Surface*)&(aFace->Surface());
GeomAbs_SurfaceType thetype = aFace->GetType(); GeomAbs_SurfaceType thetype = aFace->GetType();
Standard_Integer NumberOfLines = isobuild.NbLines();
Handle(Geom_Surface) GB; Handle(Geom_Surface) GB;
if (thetype == GeomAbs_BezierSurface) { if (thetype == GeomAbs_BezierSurface)
{
GB = BS.Bezier(); GB = BS.Bezier();
} }
else if (thetype == GeomAbs_BSplineSurface){ else if (thetype == GeomAbs_BSplineSurface)
{
GB = BS.BSpline(); GB = BS.BSpline();
} }
Standard_Real anAngle = aDrawer->DeviationAngle(); const Standard_Real anAngle = aDrawer->DeviationAngle();
const Standard_Integer aNumberOfLines = isobuild.NbLines();
for (i = 1; i <= NumberOfLines; i++) { for (Standard_Integer i = 1; i <= aNumberOfLines; i++)
{
Standard_Integer NumberOfIntervals = isobuild.NbIntervals(i); Standard_Integer NumberOfIntervals = isobuild.NbIntervals(i);
Standard_Real Coord = isobuild.Coordinate(i); Standard_Real Coord = isobuild.Coordinate(i);
for (Standard_Integer j = 1; j <= NumberOfIntervals; j++) { for (Standard_Integer j = 1; j <= NumberOfIntervals; j++)
Standard_Real b1=isobuild.Start(i,j),b2=isobuild.End(i,j); {
Standard_Real b1 = isobuild.Start (i, j), b2 = isobuild.End (i, j);
if (!GB.IsNull())
{
if (isobuild.IsXLine (i))
{
BC = GB->UIso (Coord);
}
else
{
BC = GB->VIso (Coord);
}
GeomAdaptor_Curve GC (BC);
if (!GB.IsNull()) { FindLimits (GC, aLimit,b1, b2);
if (isobuild.IsXLine(i)) if (b2 - b1 > Precision::Confusion())
BC = GB->UIso(Coord); {
else Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
BC = GB->VIso(Coord); StdPrs_DeflectionCurve::Add (aPresentation, GC, b1, b2, Deflection,
GeomAdaptor_Curve GC(BC); aPoints->ChangeSequence(), anAngle, Standard_False);
FindLimits(GC, aLimit,b1, b2); Curves.Append (aPoints);
if (b2-b1>Precision::Confusion()) { }
Handle(TColgp_HSequenceOfPnt) Points = new TColgp_HSequenceOfPnt;
StdPrs_DeflectionCurve::Add (aPresentation, GC, b1, b2, Deflection,
Points->ChangeSequence(), anAngle, Standard_False);
Curves.Append(Points);
}
} }
else { else
if (isobuild.IsXLine(i)) {
anIso.Load(GeomAbs_IsoU,Coord,b1,b2); if (isobuild.IsXLine (i))
else {
anIso.Load(GeomAbs_IsoV,Coord,b1,b2); anIso.Load (GeomAbs_IsoU,Coord,b1,b2);
FindLimits(anIso, aLimit,b1, b2); }
if (b2-b1>Precision::Confusion()) { else
Handle(TColgp_HSequenceOfPnt) Points = new TColgp_HSequenceOfPnt; {
StdPrs_DeflectionCurve::Add (aPresentation, anIso, b1, b2, Deflection, anIso.Load (GeomAbs_IsoV,Coord,b1,b2);
Points->ChangeSequence(), anAngle, Standard_False); }
Curves.Append(Points);
} FindLimits (anIso, aLimit, b1, b2);
if (b2 - b1 > Precision::Confusion())
{
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
StdPrs_DeflectionCurve::Add (aPresentation, anIso, b1, b2, Deflection,
aPoints->ChangeSequence(), anAngle, Standard_False);
Curves.Append (aPoints);
}
} }
} }
} }