diff --git a/src/StdPrs/StdPrs_WFDeflectionRestrictedFace.cxx b/src/StdPrs/StdPrs_WFDeflectionRestrictedFace.cxx index b925fcd67c..da03c7de50 100755 --- a/src/StdPrs/StdPrs_WFDeflectionRestrictedFace.cxx +++ b/src/StdPrs/StdPrs_WFDeflectionRestrictedFace.cxx @@ -142,6 +142,7 @@ void StdPrs_WFDeflectionRestrictedFace::Add gp_Pnt dummypnt; Standard_Real ddefle= Max(UMax-UMin, VMax-VMin) * aDrawer->DeviationCoefficient(); TColgp_SequenceOfPnt2d tabP; + Standard_Real aHatchingTol = 1.e100; UMin = VMin = 1.e100; UMax = VMax = -1.e100; @@ -169,6 +170,7 @@ void StdPrs_WFDeflectionRestrictedFace::Add 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 ) { //isobuild.Trim(P1,P2); @@ -215,6 +217,8 @@ void StdPrs_WFDeflectionRestrictedFace::Add 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 ) { // isobuild.Trim(P1,P2); tabP.Append(P1); @@ -236,8 +240,13 @@ void StdPrs_WFDeflectionRestrictedFace::Add FFaceTimer2.Start(); #endif + // Compute the hatching tolerance. + aHatchingTol *= 0.1; + aHatchingTol = Max(Precision::Confusion(), aHatchingTol); + aHatchingTol = Min(1.e-5, aHatchingTol); + // load the isos - Hatch_Hatcher isobuild(1.e-5,ToolRst.IsOriented()); + Hatch_Hatcher isobuild(aHatchingTol, ToolRst.IsOriented()); Standard_Boolean UClosed = aFace->IsUClosed(); Standard_Boolean VClosed = aFace->IsVClosed(); diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index 47980f3f3c..e837cd4a34 100755 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -55,8 +55,10 @@ #include #include #include +#include #include #include +#include #ifdef HAVE_CONFIG_H # include @@ -90,6 +92,7 @@ extern int ViewerMainLoop(Standard_Integer argc, const char** argv); #define DEFAULT_COLOR Quantity_NOC_GOLDENROD #define DEFAULT_MATERIAL Graphic3d_NOM_BRASS + //======================================================================= //function : GetColorFromName //purpose : get the Quantity_NameOfColor from a string @@ -578,6 +581,122 @@ void ViewerTest::StandardModeActivation(const Standard_Integer mode ) } } +//============================================================================== +//function : CopyIsoAspect +//purpose : Returns copy Prs3d_IsoAspect with new number of isolines. +//============================================================================== +static Handle(Prs3d_IsoAspect) CopyIsoAspect + (const Handle(Prs3d_IsoAspect) &theIsoAspect, + const Standard_Integer theNbIsos) +{ + Quantity_Color aColor; + Aspect_TypeOfLine aType; + Standard_Real aWidth; + + theIsoAspect->Aspect()->Values(aColor, aType, aWidth); + + Handle(Prs3d_IsoAspect) aResult = + new Prs3d_IsoAspect(aColor, aType, aWidth, theNbIsos); + + return aResult; +} + +//============================================================================== +//function : visos +//purpose : Returns or sets the number of U- and V- isos and isIsoOnPlane flag +//Draw arg : [name1 ...] [nbUIsos nbVIsos IsoOnPlane(0|1)] +//============================================================================== +static int visos (Draw_Interpretor& di, Standard_Integer argc, const char** argv) +{ + if (TheAISContext().IsNull()) { + di << argv[0] << " Call 'vinit' before!\n"; + return 1; + } + + if (argc <= 1) { + di << "Current number of isos : " << + TheAISContext()->IsoNumber(AIS_TOI_IsoU) << " " << + TheAISContext()->IsoNumber(AIS_TOI_IsoV) << "\n"; + di << "IsoOnPlane mode is " << + (TheAISContext()->IsoOnPlane() ? "ON" : "OFF") << "\n"; + + return 0; + } + + Standard_Integer aLastInd = argc - 1; + Standard_Boolean isChanged = Standard_False; + Standard_Integer aNbUIsos; + Standard_Integer aNbVIsos; + + if (aLastInd >= 3) { + Standard_Boolean isIsoOnPlane = Standard_False; + + if (strcmp(argv[aLastInd], "1") == 0) { + isIsoOnPlane = Standard_True; + isChanged = Standard_True; + } else if (strcmp(argv[aLastInd], "0") == 0) { + isIsoOnPlane = Standard_False; + isChanged = Standard_True; + } + + if (isChanged) { + aNbVIsos = Draw::Atoi(argv[aLastInd - 1]); + aNbUIsos = Draw::Atoi(argv[aLastInd - 2]); + aLastInd -= 3; + + di << "New number of isos : " << aNbUIsos << " " << aNbVIsos << "\n"; + di << "New IsoOnPlane mode is " << (isIsoOnPlane ? "ON" : "OFF") << "\n"; + + TheAISContext()->IsoOnPlane(isIsoOnPlane); + + if (aLastInd == 0) { + // If there are no shapes provided set the default numbers. + TheAISContext()->SetIsoNumber(aNbUIsos, AIS_TOI_IsoU); + TheAISContext()->SetIsoNumber(aNbVIsos, AIS_TOI_IsoV); + } + } + } + + Standard_Integer i; + + for (i = 1; i <= aLastInd; i++) { + TCollection_AsciiString name(argv[i]); + Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name); + + if (IsBound) { + const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(name); + if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) { + const Handle(AIS_InteractiveObject) aShape = + Handle(AIS_InteractiveObject)::DownCast (anObj); + Handle(AIS_Drawer) CurDrawer = aShape->Attributes(); + Handle(Prs3d_IsoAspect) aUIso = CurDrawer->UIsoAspect(); + Handle(Prs3d_IsoAspect) aVIso = CurDrawer->VIsoAspect(); + + if (isChanged) { + CurDrawer->SetUIsoAspect(CopyIsoAspect(aUIso, aNbUIsos)); + CurDrawer->SetVIsoAspect(CopyIsoAspect(aVIso, aNbVIsos)); + TheAISContext()->SetLocalAttributes + (aShape, CurDrawer, Standard_False); + TheAISContext()->Redisplay(aShape); + } else { + di << "Number of isos for " << argv[i] << " : " + << aUIso->Number() << " " << aVIso->Number() << "\n"; + } + } else { + di << argv[i] << ": Not an AIS interactive object!\n"; + } + } else { + di << argv[i] << ": Use 'vdisplay' before\n"; + } + } + + if (isChanged) { + TheAISContext()->UpdateCurrentViewer(); + } + + return 0; +} + //============================================================================== //function : VDispAreas,VDispSensitive,... //purpose : Redraw the view @@ -3373,6 +3492,10 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands) const char *group = "AIS_Display"; // display + theCommands.Add("visos", + "visos [name1 ...] [nbUIsos nbVIsos IsoOnPlane(0|1)]\n" + "\tIf last 3 optional parameters are not set prints numbers of U-, V- isolines and IsoOnPlane.\n", + __FILE__, visos, group); theCommands.Add("vdisplay", "vdisplay : vdisplay2 name1 [name2] ... [name n] ", diff --git a/tests/bugs/vis/bug23705 b/tests/bugs/vis/bug23705 new file mode 100755 index 0000000000..c5c35cbaa2 --- /dev/null +++ b/tests/bugs/vis/bug23705 @@ -0,0 +1,22 @@ +puts "========" +puts "CR23705" +puts "========" +puts "" +############################################################### +## Isoline in the AIS viewer is not trimmed +############################################################### + +restore [locate_data_file bug23705_plancher20igs_face.brep] result + +vinit +visos 10 10 1 + +vdisplay result +vfit + +set x 326 +set y 295 + +checkcolor $x $y 0 0 0 + +set only_screen 1