diff --git a/samples/tcl/ANC101.tcl b/samples/tcl/ANC101.tcl index 9944fe7d2c..2bfb1eaeb7 100644 --- a/samples/tcl/ANC101.tcl +++ b/samples/tcl/ANC101.tcl @@ -277,7 +277,6 @@ blend result _model 2 _model_161 pload VISUALIZATION vinit Driver1/Viewer1/View1 vsetcolorbg 200 200 255 -vdisplay result +vdisplay -dispMode 1 result vfit -vsetdispmode 1 -vshowfaceboundary result 1 +vaspects result -setFaceBoundaryDraw 1 -mostContinuity c2 diff --git a/samples/tcl/MBBGehauseRohteil.tcl b/samples/tcl/MBBGehauseRohteil.tcl index 26860c05bd..da5de6b393 100644 --- a/samples/tcl/MBBGehauseRohteil.tcl +++ b/samples/tcl/MBBGehauseRohteil.tcl @@ -263,7 +263,6 @@ unifysamedom result p_1 pload VISUALIZATION vinit Driver1/Viewer1/View1 vsetcolorbg 200 200 255 -vdisplay result +vdisplay -dispMode 1 result vfit -vsetdispmode 1 -vshowfaceboundary result 1 +vaspects result -setFaceBoundaryDraw 1 diff --git a/samples/tcl/cad.tcl b/samples/tcl/cad.tcl index fadd61119f..b2c903e4e8 100644 --- a/samples/tcl/cad.tcl +++ b/samples/tcl/cad.tcl @@ -57,9 +57,7 @@ bcommon res b9 c2 # show result donly res trotate res 0 0 0 0 0 1 90 -vinit -vdisplay res -vsetdispmode 1 -vshowfaceboundary res 1 255 255 255 -vaspects -isoontriangulation 1 +vinit View1 +vdisplay -dispMode 1 res +vaspects res -setFaceBoundaryDraw 1 -setFaceBoundaryColor WHITE -isoontriangulation 1 vfit diff --git a/src/AIS/AIS_ColoredShape.cxx b/src/AIS/AIS_ColoredShape.cxx index ef8b54a09c..c53bddb675 100644 --- a/src/AIS/AIS_ColoredShape.cxx +++ b/src/AIS/AIS_ColoredShape.cxx @@ -610,7 +610,7 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation const DataMapOfDrawerCompd& theDrawerClosedFaces, const Standard_Integer theMode) { - Handle(Graphic3d_Group) anOpenGroup, aClosedGroup; + Handle(Graphic3d_Group) anOpenGroup, aClosedGroup, anEdgesGroup; for (size_t aShType = 0; aShType <= (size_t )TopAbs_SHAPE; ++aShType) { const Standard_Boolean isClosed = aShType == TopAbs_SHAPE; @@ -664,7 +664,7 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation { if (aShadedGroup.IsNull()) { - aShadedGroup = Prs3d_Root::NewGroup (thePrs); + aShadedGroup = thePrs->NewGroup(); aShadedGroup->SetClosed (isClosed); } aShadedGroup->SetPrimitivesAspect (aDrawer->ShadingAspect()->Aspect()); @@ -673,18 +673,15 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation if (aDrawer->FaceBoundaryDraw()) { - Handle(Graphic3d_ArrayOfSegments) aBndSegments = StdPrs_ShadedShape::FillFaceBoundaries (aShapeDraw); - if (!aBndSegments.IsNull()) + if (Handle(Graphic3d_ArrayOfSegments) aBndSegments = StdPrs_ShadedShape::FillFaceBoundaries (aShapeDraw, aDrawer->FaceBoundaryUpperContinuity())) { - if (aShadedGroup.IsNull()) + if (anEdgesGroup.IsNull()) { - aShadedGroup = Prs3d_Root::NewGroup (thePrs); - aShadedGroup->SetClosed (isClosed); + anEdgesGroup = thePrs->NewGroup(); } - Handle(Graphic3d_AspectLine3d) aBoundaryAspect = aDrawer->FaceBoundaryAspect()->Aspect(); - aShadedGroup->SetPrimitivesAspect (aBoundaryAspect); - aShadedGroup->AddPrimitiveArray (aBndSegments); + anEdgesGroup->SetPrimitivesAspect (aDrawer->FaceBoundaryAspect()->Aspect()); + anEdgesGroup->AddPrimitiveArray (aBndSegments); } } } diff --git a/src/BRep/BRep_Tool.cxx b/src/BRep/BRep_Tool.cxx index 9a2e3ed833..37c4f2213e 100644 --- a/src/BRep/BRep_Tool.cxx +++ b/src/BRep/BRep_Tool.cxx @@ -1182,6 +1182,29 @@ Standard_Boolean BRep_Tool::HasContinuity(const TopoDS_Edge& E) return Standard_False; } +//======================================================================= +//function : MaxContinuity +//purpose : +//======================================================================= +GeomAbs_Shape BRep_Tool::MaxContinuity (const TopoDS_Edge& theEdge) +{ + GeomAbs_Shape aMaxCont = GeomAbs_C0; + for (BRep_ListIteratorOfListOfCurveRepresentation aReprIter ((*((Handle(BRep_TEdge)*)&theEdge.TShape()))->ChangeCurves()); + aReprIter.More(); aReprIter.Next()) + { + const Handle(BRep_CurveRepresentation)& aRepr = aReprIter.Value(); + if (aRepr->IsRegularity()) + { + const GeomAbs_Shape aCont = aRepr->Continuity(); + if ((Standard_Integer )aCont > (Standard_Integer )aMaxCont) + { + aMaxCont = aCont; + } + } + } + return aMaxCont; +} + //======================================================================= //function : Pnt //purpose : Returns the 3d point. diff --git a/src/BRep/BRep_Tool.hxx b/src/BRep/BRep_Tool.hxx index ed66f8412c..6fdc110c06 100644 --- a/src/BRep/BRep_Tool.hxx +++ b/src/BRep/BRep_Tool.hxx @@ -242,6 +242,9 @@ public: //! Returns True if the edge has regularity on some //! two surfaces Standard_EXPORT static Standard_Boolean HasContinuity (const TopoDS_Edge& E); + + //! Returns the max continuity of edge between some surfaces or GeomAbs_C0 if there no such surfaces. + Standard_EXPORT static GeomAbs_Shape MaxContinuity (const TopoDS_Edge& theEdge); //! Returns the 3d point. Standard_EXPORT static gp_Pnt Pnt (const TopoDS_Vertex& V); diff --git a/src/Prs3d/Prs3d_Drawer.cxx b/src/Prs3d/Prs3d_Drawer.cxx index 8d4bb7a7f8..bf474f3eb2 100644 --- a/src/Prs3d/Prs3d_Drawer.cxx +++ b/src/Prs3d/Prs3d_Drawer.cxx @@ -99,6 +99,7 @@ Prs3d_Drawer::Prs3d_Drawer() myHasOwnUnFreeBoundaryAspect (Standard_False), myUnFreeBoundaryDraw (Standard_True), myHasOwnUnFreeBoundaryDraw (Standard_False), + myFaceBoundaryUpperContinuity(-1), myHasOwnFaceBoundaryAspect (Standard_False), myFaceBoundaryDraw (Standard_False), myHasOwnFaceBoundaryDraw (Standard_False), @@ -1120,6 +1121,28 @@ void Prs3d_Drawer::ClearLocalAttributes() myTypeOfHLR = Prs3d_TOH_NotSet; } +// ======================================================================= +// function : SetupOwnFaceBoundaryAspect +// purpose : +// ======================================================================= +Standard_Boolean Prs3d_Drawer::SetupOwnFaceBoundaryAspect (const Handle(Prs3d_Drawer)& theDefaults) +{ + if (myHasOwnFaceBoundaryAspect) + { + return false; + } + + myFaceBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FaceBoundary, Aspect_TOL_SOLID, 1.0); + myHasOwnFaceBoundaryAspect = true; + + const Handle(Prs3d_Drawer)& aLink = (!theDefaults.IsNull() && theDefaults != this) ? theDefaults : myLink; + if (!aLink.IsNull()) + { + *myFaceBoundaryAspect->Aspect() = *aLink->FaceBoundaryAspect()->Aspect(); + } + return true; +} + // ======================================================================= // function : SetOwnLineAspects // purpose : @@ -1210,16 +1233,7 @@ Standard_Boolean Prs3d_Drawer::SetOwnLineAspects (const Handle(Prs3d_Drawer)& th *myUnFreeBoundaryAspect->Aspect() = *aLink->UnFreeBoundaryAspect()->Aspect(); } } - if (!myHasOwnFaceBoundaryAspect) - { - isUpdateNeeded = true; - myFaceBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FaceBoundary, Aspect_TOL_SOLID, 1.0); - myHasOwnFaceBoundaryAspect = true; - if (!aLink.IsNull()) - { - *myFaceBoundaryAspect->Aspect() = *aLink->FaceBoundaryAspect()->Aspect(); - } - } + isUpdateNeeded = SetupOwnFaceBoundaryAspect (theDefaults) || isUpdateNeeded; return isUpdateNeeded; } diff --git a/src/Prs3d/Prs3d_Drawer.hxx b/src/Prs3d/Prs3d_Drawer.hxx index a2a80ac7c8..292a87a846 100644 --- a/src/Prs3d/Prs3d_Drawer.hxx +++ b/src/Prs3d/Prs3d_Drawer.hxx @@ -29,6 +29,7 @@ #include #include #include +#include class Prs3d_IsoAspect; class Prs3d_LineAspect; @@ -738,6 +739,10 @@ public: //! face boundaries aspect that overrides the one in the link. Standard_Boolean HasOwnFaceBoundaryAspect() const { return myHasOwnFaceBoundaryAspect; } + //! Sets own face boundary aspect. + //! Returns FALSE if the drawer already has its own attribute for face boundary aspect. + Standard_EXPORT Standard_Boolean SetupOwnFaceBoundaryAspect (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)()); + //! Enables or disables face boundary drawing for shading presentations. //! The method sets drawing flag owned by the drawer that will be used during //! visualization instead of the one set in link. @@ -756,6 +761,25 @@ public: //! "draw face boundaries" flag that overrides the one in the link. Standard_Boolean HasOwnFaceBoundaryDraw() const { return myHasOwnFaceBoundaryDraw; } + //! Returns true if the drawer has its own attribute for face boundaries upper edge continuity class that overrides the one in the link. + Standard_Boolean HasOwnFaceBoundaryUpperContinuity() const { return myFaceBoundaryUpperContinuity != -1; } + + //! Get the most edge continuity class; GeomAbs_CN by default (all edges). + GeomAbs_Shape FaceBoundaryUpperContinuity() const + { + return HasOwnFaceBoundaryUpperContinuity() + ? (GeomAbs_Shape )myFaceBoundaryUpperContinuity + : (!myLink.IsNull() + ? myLink->FaceBoundaryUpperContinuity() + : GeomAbs_CN); + } + + //! Set the most edge continuity class for face boundaries. + void SetFaceBoundaryUpperContinuity (GeomAbs_Shape theMostAllowedEdgeClass) { myFaceBoundaryUpperContinuity = theMostAllowedEdgeClass; } + + //! Unset the most edge continuity class for face boundaries. + void UnsetFaceBoundaryUpperContinuity() { myFaceBoundaryUpperContinuity = -1; } + //! Returns settings for the appearance of dimensions. Standard_EXPORT const Handle(Prs3d_DimensionAspect)& DimensionAspect(); @@ -944,6 +968,7 @@ protected: Standard_Boolean myUnFreeBoundaryDraw; Standard_Boolean myHasOwnUnFreeBoundaryDraw; Handle(Prs3d_LineAspect) myFaceBoundaryAspect; + Standard_Integer myFaceBoundaryUpperContinuity; //!< the most edge continuity class (GeomAbs_Shape) to be included to face boundaries presentation, or -1 if undefined Standard_Boolean myHasOwnFaceBoundaryAspect; Standard_Boolean myFaceBoundaryDraw; Standard_Boolean myHasOwnFaceBoundaryDraw; @@ -956,7 +981,6 @@ protected: Prs3d_DimensionUnits myDimensionDisplayUnits; Standard_Boolean myHasOwnDimLengthDisplayUnits; Standard_Boolean myHasOwnDimAngleDisplayUnits; - }; Standard_DEPRECATED("Class name is deprecated - use Prs3d_Drawer instead") diff --git a/src/StdPrs/StdPrs_ShadedShape.cxx b/src/StdPrs/StdPrs_ShadedShape.cxx index 8f2de978c8..06647a8c8a 100644 --- a/src/StdPrs/StdPrs_ShadedShape.cxx +++ b/src/StdPrs/StdPrs_ShadedShape.cxx @@ -301,7 +301,8 @@ namespace } //! Compute boundary presentation for faces of the shape. - static Handle(Graphic3d_ArrayOfSegments) fillFaceBoundaries (const TopoDS_Shape& theShape) + static Handle(Graphic3d_ArrayOfSegments) fillFaceBoundaries (const TopoDS_Shape& theShape, + GeomAbs_Shape theUpperContinuity) { // collection of all triangulation nodes on edges // for computing boundaries presentation @@ -340,6 +341,13 @@ namespace } const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeIter.Key()); + if (theUpperContinuity < GeomAbs_CN + && anEdgeIter.Value().Extent() >= 2 + && BRep_Tool::MaxContinuity (anEdge) > theUpperContinuity) + { + continue; + } + Handle(Poly_PolygonOnTriangulation) anEdgePoly = BRep_Tool::PolygonOnTriangulation (anEdge, aTriangulation, aTrsf); if (!anEdgePoly.IsNull() && anEdgePoly->Nodes().Length() >= 2) @@ -383,6 +391,13 @@ namespace } const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeIter.Key()); + if (theUpperContinuity < GeomAbs_CN + && anEdgeIter.Value().Extent() >= 2 + && BRep_Tool::MaxContinuity (anEdge) > theUpperContinuity) + { + continue; + } + Handle(Poly_PolygonOnTriangulation) anEdgePoly = BRep_Tool::PolygonOnTriangulation (anEdge, aTriangulation, aTrsf); if (anEdgePoly.IsNull() || anEdgePoly->Nodes().Length () < 2) @@ -575,12 +590,10 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs, if (theDrawer->FaceBoundaryDraw()) { - Handle(Graphic3d_ArrayOfSegments) aBndSegments = fillFaceBoundaries (theShape); - if (!aBndSegments.IsNull()) + if (Handle(Graphic3d_ArrayOfSegments) aBndSegments = fillFaceBoundaries (theShape, theDrawer->FaceBoundaryUpperContinuity())) { - Handle(Graphic3d_AspectLine3d) aBoundaryAspect = theDrawer->FaceBoundaryAspect()->Aspect(); Handle(Graphic3d_Group) aPrsGrp = Prs3d_Root::CurrentGroup (thePrs); - aPrsGrp->SetGroupPrimitivesAspect (aBoundaryAspect); + aPrsGrp->SetGroupPrimitivesAspect (theDrawer->FaceBoundaryAspect()->Aspect()); aPrsGrp->AddPrimitiveArray (aBndSegments); } } @@ -603,9 +616,10 @@ Handle(Graphic3d_ArrayOfTriangles) StdPrs_ShadedShape::FillTriangles (const Topo // function : FillFaceBoundaries // purpose : // ======================================================================= -Handle(Graphic3d_ArrayOfSegments) StdPrs_ShadedShape::FillFaceBoundaries (const TopoDS_Shape& theShape) +Handle(Graphic3d_ArrayOfSegments) StdPrs_ShadedShape::FillFaceBoundaries (const TopoDS_Shape& theShape, + GeomAbs_Shape theUpperContinuity) { - return fillFaceBoundaries (theShape); + return fillFaceBoundaries (theShape, theUpperContinuity); } // ======================================================================= diff --git a/src/StdPrs/StdPrs_ShadedShape.hxx b/src/StdPrs/StdPrs_ShadedShape.hxx index cbb2a7df75..0bd9d8bd34 100644 --- a/src/StdPrs/StdPrs_ShadedShape.hxx +++ b/src/StdPrs/StdPrs_ShadedShape.hxx @@ -17,10 +17,7 @@ #ifndef _StdPrs_ShadedShape_HeaderFile #define _StdPrs_ShadedShape_HeaderFile -#include -#include -#include - +#include #include #include #include @@ -90,7 +87,9 @@ public: //! Define primitive array of boundary segments for specified shape. //! @param theShape segments array or NULL if specified face does not have computed triangulation - Standard_EXPORT static Handle(Graphic3d_ArrayOfSegments) FillFaceBoundaries (const TopoDS_Shape& theShape); + //! @param theUpperContinuity the most edge continuity class to be included to result (edges with more continuity will be ignored) + Standard_EXPORT static Handle(Graphic3d_ArrayOfSegments) FillFaceBoundaries (const TopoDS_Shape& theShape, + GeomAbs_Shape theUpperContinuity = GeomAbs_CN); }; diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index b9f592bad5..930a32a2a5 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -1556,6 +1556,19 @@ struct ViewerTest_AspectsChangeSet Standard_Integer ToEnableIsoOnTriangulation; + Standard_Integer ToSetFaceBoundaryDraw; + Standard_Integer ToSetFaceBoundaryUpperContinuity; + GeomAbs_Shape FaceBoundaryUpperContinuity; + + Standard_Integer ToSetFaceBoundaryColor; + Quantity_Color FaceBoundaryColor; + + Standard_Integer ToSetFaceBoundaryWidth; + Standard_Real FaceBoundaryWidth; + + Standard_Integer ToSetTypeOfFaceBoundaryLine; + Aspect_TypeOfLine TypeOfFaceBoundaryLine; + Standard_Integer ToSetMaxParamValue; Standard_Real MaxParamValue; @@ -1612,7 +1625,18 @@ struct ViewerTest_AspectsChangeSet FreeBoundaryWidth (1.0), ToSetFreeBoundaryColor (0), FreeBoundaryColor (DEFAULT_FREEBOUNDARY_COLOR), - ToEnableIsoOnTriangulation (-1), + ToEnableIsoOnTriangulation (0), + // + ToSetFaceBoundaryDraw (0), + ToSetFaceBoundaryUpperContinuity (0), + FaceBoundaryUpperContinuity(GeomAbs_CN), + ToSetFaceBoundaryColor (0), + FaceBoundaryColor (Quantity_NOC_BLACK), + ToSetFaceBoundaryWidth (0), + FaceBoundaryWidth (1.0f), + ToSetTypeOfFaceBoundaryLine(0), + TypeOfFaceBoundaryLine (Aspect_TOL_SOLID), + // ToSetMaxParamValue (0), MaxParamValue (500000), ToSetSensitivity (0), @@ -1645,6 +1669,12 @@ struct ViewerTest_AspectsChangeSet && ToSetShowFreeBoundary == 0 && ToSetFreeBoundaryColor == 0 && ToSetFreeBoundaryWidth == 0 + && ToEnableIsoOnTriangulation == 0 + && ToSetFaceBoundaryDraw == 0 + && ToSetFaceBoundaryUpperContinuity == 0 + && ToSetFaceBoundaryColor == 0 + && ToSetFaceBoundaryWidth == 0 + && ToSetTypeOfFaceBoundaryLine == 0 && ToSetMaxParamValue == 0 && ToSetSensitivity == 0 && ToSetHatch == 0 @@ -1799,6 +1829,66 @@ struct ViewerTest_AspectsChangeSet toRecompute = true; } } + if (ToSetFaceBoundaryDraw != 0) + { + if (ToSetFaceBoundaryDraw != -1 + || theDrawer->HasOwnFaceBoundaryDraw()) + { + toRecompute = true; + theDrawer->SetFaceBoundaryDraw (ToSetFaceBoundaryDraw == 1); + } + } + if (ToSetFaceBoundaryUpperContinuity != 0) + { + if (ToSetFaceBoundaryUpperContinuity != -1 + || theDrawer->HasOwnFaceBoundaryUpperContinuity()) + { + toRecompute = true; + if (ToSetFaceBoundaryUpperContinuity == -1) + { + theDrawer->UnsetFaceBoundaryUpperContinuity(); + } + else + { + theDrawer->SetFaceBoundaryUpperContinuity (FaceBoundaryUpperContinuity); + } + } + } + if (ToSetFaceBoundaryColor != 0) + { + if (ToSetFaceBoundaryColor != -1 + || theDrawer->HasOwnFaceBoundaryAspect()) + { + if (ToSetFaceBoundaryColor == -1) + { + toRecompute = true; + theDrawer->SetFaceBoundaryAspect (Handle(Prs3d_LineAspect)()); + } + else + { + toRecompute = theDrawer->SetupOwnFaceBoundaryAspect (aDefDrawer) || toRecompute; + theDrawer->FaceBoundaryAspect()->SetColor (FaceBoundaryColor); + } + } + } + if (ToSetFaceBoundaryWidth != 0) + { + if (ToSetFaceBoundaryWidth != -1 + || theDrawer->HasOwnFaceBoundaryAspect()) + { + toRecompute = theDrawer->SetupOwnFaceBoundaryAspect (aDefDrawer) || toRecompute; + theDrawer->FaceBoundaryAspect()->SetWidth (FaceBoundaryWidth); + } + } + if (ToSetTypeOfFaceBoundaryLine != 0) + { + if (ToSetTypeOfFaceBoundaryLine != -1 + || theDrawer->HasOwnFaceBoundaryAspect()) + { + toRecompute = theDrawer->SetupOwnFaceBoundaryAspect (aDefDrawer) || toRecompute; + theDrawer->FaceBoundaryAspect()->SetTypeOfLine (TypeOfFaceBoundaryLine); + } + } if (ToSetShadingModel != 0) { if (ToSetShadingModel != -1 @@ -2099,6 +2189,50 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, aChangeSet->ToSetTypeOfEdge = -1; aChangeSet->TypeOfEdge = Aspect_TOL_SOLID; } + else if (aCmdName == "vshowfaceboundary") + { + aChangeSet->ToSetFaceBoundaryDraw = 1; + toParseAliasArgs = true; + if (aNames.Size() >= 2 + && aNames.Value (2).IsIntegerValue()) + { + if (aNames.Size() == 7) + { + if (ViewerTest::ParseLineType (aNames.Value (7).ToCString(), aChangeSet->TypeOfFaceBoundaryLine)) + { + aChangeSet->ToSetTypeOfFaceBoundaryLine = 1; + aNames.Remove (7); + } + } + if (aNames.Size() == 6 + && aNames.Value (6).IsRealValue()) + { + aChangeSet->ToSetFaceBoundaryWidth = 1; + aChangeSet->FaceBoundaryWidth = aNames.Value (6).RealValue(); + aNames.Remove (6); + } + if (aNames.Size() == 5 + && aNames.Value (3).IsIntegerValue() + && aNames.Value (4).IsIntegerValue() + && aNames.Value (5).IsIntegerValue()) + { + aChangeSet->ToSetFaceBoundaryColor = 1; + aChangeSet->FaceBoundaryColor = Quantity_Color (aNames.Value (3).IntegerValue() / 255.0, + aNames.Value (4).IntegerValue() / 255.0, + aNames.Value (5).IntegerValue() / 255.0, + Quantity_TOC_RGB); + aNames.Remove (5); + aNames.Remove (4); + aNames.Remove (3); + } + if (aNames.Size() == 2) + { + toParseAliasArgs = false; + aChangeSet->ToSetFaceBoundaryDraw = aNames.Value (2).IntegerValue() == 1 ? 1 : -1; + aNames.Remove (2); + } + } + } else if (anArgIter >= theArgNb) { std::cout << "Error: not enough arguments!\n"; @@ -2121,13 +2255,19 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, || anArg == "-setedgewidth" || anArg == "-setedgeswidth" || anArg == "-edgewidth" - || anArg == "-edgeswidth") + || anArg == "-edgeswidth" + || anArg == "-setfaceboundarywidth" + || anArg == "-setboundarywidth" + || anArg == "-faceboundarywidth" + || anArg == "-boundarywidth") { if (++anArgIter >= theArgNb) { std::cout << "Error: wrong syntax at " << anArg << "\n"; return 1; } + + const Standard_Real aWidth = Draw::Atof (theArgVec[anArgIter]); if (anArg == "-setedgewidth" || anArg == "-setedgeswidth" || anArg == "-edgewidth" @@ -2135,12 +2275,21 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, || aCmdName == "vsetedgetype") { aChangeSet->ToSetEdgeWidth = 1; - aChangeSet->EdgeWidth = Draw::Atof (theArgVec[anArgIter]); + aChangeSet->EdgeWidth = aWidth; + } + else if (anArg == "-setfaceboundarywidth" + || anArg == "-setboundarywidth" + || anArg == "-faceboundarywidth" + || anArg == "-boundarywidth" + || aCmdName == "vshowfaceboundary") + { + aChangeSet->ToSetFaceBoundaryWidth = 1; + aChangeSet->FaceBoundaryWidth = aWidth; } else { aChangeSet->ToSetLineWidth = 1; - aChangeSet->LineWidth = Draw::Atof (theArgVec[anArgIter]); + aChangeSet->LineWidth = aWidth; } } else if (anArg == "-unsetwidth" @@ -2271,7 +2420,11 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, aChangeSet->Transparency = 0.0; } else if (anArg == "-setcolor" - || anArg == "-color") + || anArg == "-color" + || anArg == "-setfaceboundarycolor" + || anArg == "-setboundarycolor" + || anArg == "-faceboundarycolor" + || anArg == "-boundarycolor") { Quantity_Color aColor; Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1, @@ -2288,6 +2441,15 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, aChangeSet->ToSetEdgeColor = 1; aChangeSet->EdgeColor = Quantity_ColorRGBA (aColor); } + else if (aCmdName == "vshowfaceboundary" + || anArg == "-setfaceboundarycolor" + || anArg == "-setboundarycolor" + || anArg == "-faceboundarycolor" + || anArg == "-boundarycolor") + { + aChangeSet->ToSetFaceBoundaryColor = 1; + aChangeSet->FaceBoundaryColor = aColor; + } else { aChangeSet->ToSetColor = 1; @@ -2300,6 +2462,13 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, || anArg == "-setedgestype" || anArg == "-edgetype" || anArg == "-edgestype" + || anArg == "-setfaceboundarystyle" + || anArg == "-faceboundarystyle" + || anArg == "-boundarystyle" + || anArg == "-setfaceboundarytype" + || anArg == "-faceboundarytype" + || anArg == "-setboundarytype" + || anArg == "-boundarytype" || anArg == "-type") { if (++anArgIter >= theArgNb) @@ -2322,6 +2491,18 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, aChangeSet->TypeOfEdge = aLineType; aChangeSet->ToSetTypeOfEdge = 1; } + else if (anArg == "-setfaceboundarystyle" + || anArg == "-faceboundarystyle" + || anArg == "-boundarystyle" + || anArg == "-setfaceboundarytype" + || anArg == "-faceboundarytype" + || anArg == "-setboundarytype" + || anArg == "-boundarytype" + || aCmdName == "vshowfaceboundary") + { + aChangeSet->TypeOfFaceBoundaryLine = aLineType; + aChangeSet->ToSetTypeOfFaceBoundaryLine = 1; + } else { aChangeSet->TypeOfLine = aLineType; @@ -2456,28 +2637,14 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, || anArg == "-setfb" || anArg == "-fb") { - if (++anArgIter >= theArgNb) - { - std::cout << "Error: wrong syntax at " << anArg << "\n"; - return 1; - } - TCollection_AsciiString aValue (theArgVec[anArgIter]); - aValue.LowerCase(); - if (aValue == "on" - || aValue == "1") - { - aChangeSet->ToSetShowFreeBoundary = 1; - } - else if (aValue == "off" - || aValue == "0") - { - aChangeSet->ToSetShowFreeBoundary = -1; - } - else + bool toEnable = true; + if (!ViewerTest::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable)) { std::cout << "Error: wrong syntax at " << anArg << "\n"; return 1; } + ++anArgIter; + aChangeSet->ToSetShowFreeBoundary = toEnable ? 1 : -1; } else if (anArg == "-setfreeboundarywidth" || anArg == "-freeboundarywidth" @@ -2525,28 +2692,86 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, || anArg == "-setisoontriang" || anArg == "-isoontriang") { - if (++anArgIter >= theArgNb) + bool toEnable = true; + if (!ViewerTest::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable)) { std::cout << "Error: wrong syntax at " << anArg << "\n"; return 1; } - TCollection_AsciiString aValue (theArgVec[anArgIter]); - aValue.LowerCase(); - if (aValue == "on" - || aValue == "1") + ++anArgIter; + aChangeSet->ToEnableIsoOnTriangulation = toEnable ? 1 : -1; + } + else if (anArg == "-setfaceboundarydraw" + || anArg == "-setdrawfaceboundary" + || anArg == "-setdrawfaceboundaries" + || anArg == "-setshowfaceboundary" + || anArg == "-setshowfaceboundaries" + || anArg == "-setdrawfaceedges" + || anArg == "-faceboundarydraw" + || anArg == "-drawfaceboundary" + || anArg == "-drawfaceboundaries" + || anArg == "-showfaceboundary" + || anArg == "-showfaceboundaries" + || anArg == "-drawfaceedges" + || anArg == "-faceboundary" + || anArg == "-faceboundaries" + || anArg == "-faceedges") + { + bool toEnable = true; + if (!ViewerTest::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable)) { - aChangeSet->ToEnableIsoOnTriangulation = 1; + std::cout << "Error: wrong syntax at " << anArg << "\n"; + return 1; } - else if (aValue == "off" - || aValue == "0") + ++anArgIter; + aChangeSet->ToSetFaceBoundaryDraw = toEnable ? 1 : -1; + } + else if (anArg == "-unsetfaceboundary" + || anArg == "-unsetboundary") + { + aChangeSet->ToSetFaceBoundaryDraw = -1; + aChangeSet->ToSetFaceBoundaryColor = -1; + } + else if (anArg == "-setmostcontinuity" + || anArg == "-mostcontinuity") + { + TCollection_AsciiString aClassArg (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : ""); + aClassArg.LowerCase(); + GeomAbs_Shape aClass = GeomAbs_CN; + if (aClassArg == "c0" + || aClassArg == "0") { - aChangeSet->ToEnableIsoOnTriangulation = 0; + aClass = GeomAbs_C0; + } + else if (aClassArg == "c1" + || aClassArg == "1") + { + aClass = GeomAbs_C1; + } + else if (aClassArg == "c2" + || aClassArg == "2") + { + aClass = GeomAbs_C2; + } + else if (aClassArg == "c3" + || aClassArg == "3") + { + aClass = GeomAbs_C3; + } + else if (aClassArg == "cn" + || aClassArg == "n") + { + aClass = GeomAbs_CN; } else { - std::cout << "Error: wrong syntax at " << anArg << "\n"; + std::cout << "Syntax error at '" << anArg << "'\n"; return 1; } + + ++anArgIter; + aChangeSet->ToSetFaceBoundaryUpperContinuity = 1; + aChangeSet->FaceBoundaryUpperContinuity = aClass; } else if (anArg == "-setmaxparamvalue" || anArg == "-maxparamvalue") @@ -2730,6 +2955,18 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR; aChangeSet->ToSetFreeBoundaryWidth = -1; aChangeSet->FreeBoundaryWidth = 1.0; + aChangeSet->ToEnableIsoOnTriangulation = -1; + // + aChangeSet->ToSetFaceBoundaryDraw = -1; + aChangeSet->ToSetFaceBoundaryUpperContinuity = -1; + aChangeSet->FaceBoundaryUpperContinuity = GeomAbs_CN; + aChangeSet->ToSetFaceBoundaryColor = -1; + aChangeSet->FaceBoundaryColor = Quantity_NOC_BLACK; + aChangeSet->ToSetFaceBoundaryWidth = -1; + aChangeSet->FaceBoundaryWidth = 1.0f; + aChangeSet->ToSetTypeOfFaceBoundaryLine = -1; + aChangeSet->TypeOfFaceBoundaryLine = Aspect_TOL_SOLID; + // aChangeSet->ToSetHatch = -1; aChangeSet->StdHatchStyle = -1; aChangeSet->PathToHatchPattern.Clear(); @@ -2792,7 +3029,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, { aDrawer->ShadingAspect()->SetMaterial (aChangeSet->Material); } - if (aChangeSet->ToEnableIsoOnTriangulation != -1) + if (aChangeSet->ToEnableIsoOnTriangulation != 0) { aDrawer->SetIsoOnTriangulation (aChangeSet->ToEnableIsoOnTriangulation == 1); } @@ -2889,7 +3126,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, { aCtx->UnsetWidth (aPrs, Standard_False); } - else if (aChangeSet->ToEnableIsoOnTriangulation != -1) + else if (aChangeSet->ToEnableIsoOnTriangulation != 0) { aCtx->IsoOnTriangulation (aChangeSet->ToEnableIsoOnTriangulation == 1, aPrs); toRedisplay = Standard_True; @@ -5953,6 +6190,8 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands) "\n\t\t: [-unsetShadingModel]" "\n\t\t: [-setInterior {solid|hatch|hidenline|point}]" "\n\t\t: [-unsetInterior] [-setHatch HatchStyle]" + "\n\t\t: [-setFaceBoundaryDraw {0|1}] [-setMostContinuity {c0|c1|c2|c3|cn}" + "\n\t\t: [-setFaceBoundaryWidth LineWidth] [-setFaceBoundaryColor R G B] [-setFaceBoundaryType LineType]" "\n\t\t: [-setDrawEdges {0|1}] [-setEdgeType LineType] [-setEdgeColor R G B] [-setQuadEdges {0|1}]" "\n\t\t: [-setAlphaMode {opaque|mask|blend|blendauto} [alphaCutOff=0.5]]" "\n\t\t: Manage presentation properties of all, selected or named objects." @@ -6024,6 +6263,11 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands) "\n\t\t: Alias for vaspects [name] -unsetEdgeType.", __FILE__, VAspects, group); + theCommands.Add ("vshowfaceboundary", + "vshowfaceboundary [name]" + "\n\t\t: Alias for vaspects [name] -setFaceBoundaryDraw on", + __FILE__, VAspects, group); + theCommands.Add("vsensdis", "vsensdis : Display active entities (sensitive entities of one of the standard types corresponding to active selection modes)." "\n\t\t: Standard entity types are those defined in Select3D package:" diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index c0317b7749..e07b56604d 100644 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -4913,113 +4913,7 @@ static Standard_Integer VPolygonOffset(Draw_Interpretor& /*di*/, return 0; } -//======================================================================= -//function : VShowFaceBoundaries -//purpose : Set face boundaries drawing on/off for ais object -//======================================================================= -static Standard_Integer VShowFaceBoundary (Draw_Interpretor& /*di*/, - Standard_Integer argc, - const char ** argv) -{ - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext (); - if (aContext.IsNull ()) - { - std::cout << argv[0] << " Call 'vinit' before!\n"; - return 1; - } - - if ((argc != 3 && argc < 6) || argc > 8) - { - std::cout << "Usage :\n " << argv[0] - << " ObjectName isOn [R G B [LineWidth [LineStyle]]]\n" - << " ObjectName - name of AIS interactive object. \n" - << " if ObjectName = \"\", then set as default\n" - << " settings for all newly displayed objects\n" - << " isOn - flag indicating whether the boundaries\n" - << " should be turned on or off (can be set\n" - << " to 0 (off) or 1 (on)).\n" - << " R, G, B - red, green and blue components of boundary\n" - << " color in range (0 - 255).\n" - << " (default is (0, 0, 0)\n" - << " LineWidth - line width\n" - << " (default is 1)\n" - << " LineStyle - line fill style :\n" - << " 0 - solid \n" - << " 1 - dashed \n" - << " 2 - dot \n" - << " 3 - dashdot\n" - << " (default is solid)"; - return 1; - } - - TCollection_AsciiString aName (argv[1]); - - Standard_Real aRed = 0.0; - Standard_Real aGreen = 0.0; - Standard_Real aBlue = 0.0; - Standard_Real aWidth = 1.0; - Aspect_TypeOfLine aLineType = Aspect_TOL_SOLID; - - // find object - Handle(AIS_InteractiveObject) anInterObj; - - // if name is empty - apply attributes for default aspect - if (!aName.IsEmpty ()) - { - if (!GetMapOfAIS().Find2 (aName, anInterObj) - || anInterObj.IsNull()) - { - std::cout << "Use 'vdisplay' on " << aName << " before" << std::endl; - return 1; - } - } - - const Handle(Prs3d_Drawer)& aDrawer = (aName.IsEmpty ()) ? - TheAISContext ()->DefaultDrawer () : anInterObj->Attributes (); - - // turn boundaries on/off - Standard_Boolean isBoundaryDraw = (Draw::Atoi (argv[2]) == 1); - aDrawer->SetFaceBoundaryDraw (isBoundaryDraw); - - // set boundary line color - if (argc >= 6) - { - // Text color - aRed = Draw::Atof (argv[3])/255.; - aGreen = Draw::Atof (argv[4])/255.; - aBlue = Draw::Atof (argv[5])/255.; - } - - // set line width - if (argc >= 7) - { - aWidth = (Standard_Real)Draw::Atof (argv[6]); - } - - // select appropriate line type - if (argc == 8) - { - if (!ViewerTest::ParseLineType (argv[7], aLineType)) - { - std::cout << "Syntax error: unknown line type '" << argv[7] << "'\n"; - return 1; - } - } - - Quantity_Color aColor (aRed, aGreen, aBlue, Quantity_TOC_RGB); - - Handle(Prs3d_LineAspect) aBoundaryAspect = - new Prs3d_LineAspect (aColor, aLineType, aWidth); - - aDrawer->SetFaceBoundaryAspect (aBoundaryAspect); - - TheAISContext()->Redisplay (anInterObj, Standard_True); - - return 0; -} - // This class is used for testing markers. - class ViewerTest_MarkersArrayObject : public AIS_InteractiveObject { @@ -6436,12 +6330,6 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands) "vpolygonoffset : [object [mode factor units]] - sets/gets polygon offset parameters for an object, without arguments prints the default values", __FILE__, VPolygonOffset, group); - theCommands.Add ("vshowfaceboundary", - "vshowfaceboundary : ObjectName isOn (1/0) [R G B [LineWidth [LineStyle]]]" - "- turns on/off drawing of face boundaries for ais object " - "and defines boundary line style.", - __FILE__, VShowFaceBoundary, group); - theCommands.Add ("vmarkerstest", "vmarkerstest: name X Y Z [PointsOnSide=10] [MarkerType=0] [Scale=1.0] [FileName=ImageFile]\n", __FILE__, VMarkersTest, group); diff --git a/tests/bugs/vis/bug23407_2 b/tests/bugs/vis/bug23407_2 index bf438d515f..121a379011 100755 --- a/tests/bugs/vis/bug23407_2 +++ b/tests/bugs/vis/bug23407_2 @@ -8,7 +8,7 @@ vclear vinit View1 vdisplay b vsetdispmode 1 -vshowfaceboundary b 1 255 0 0 5 1 +vaspects b -setFaceBoundaryDraw 1 -setFaceBoundaryColor RED -setFaceBoundaryWidth 5 -setFaceBoundaryType dash vfit vaspects -setwidth 10 diff --git a/tests/bugs/vis/bug25060 b/tests/bugs/vis/bug25060 index 2271048fb0..342e0e2954 100644 --- a/tests/bugs/vis/bug25060 +++ b/tests/bugs/vis/bug25060 @@ -8,7 +8,7 @@ puts "" vinit View1 box b 10 10 10 vdisplay b -vshowfaceboundary b 1 +vaspects b -setFaceBoundaryDraw 1 vclipplane create pln1 vclipplane set pln1 object b vclipplane change pln1 equation 0 1 0 -5 diff --git a/tests/bugs/vis/bug25071 b/tests/bugs/vis/bug25071 index 9474f6c240..2512a346c2 100644 --- a/tests/bugs/vis/bug25071 +++ b/tests/bugs/vis/bug25071 @@ -13,7 +13,7 @@ vinit View1 pcone c 0 5 10 vdisplay c; vfit vsetdispmode c 1 -vshowfaceboundary c 1 64 64 0 +vaspects c -setFaceBoundaryDraw 1 -setFaceBoundaryColor 0.25 0.25 0 vselect 200 200 vdump $imagedir/${casename}_wf_no_triang.png @@ -25,7 +25,7 @@ vinit View1 # Computing wireframe after triangulation, then checking face boundaries and selection vsetdispmode 1 vdisplay c; vfit -vshowfaceboundary c 1 64 64 0 +vaspects c -setFaceBoundaryDraw 1 -setFaceBoundaryColor 0.25 0.25 0 vselect 200 200 vdump $imagedir/${casename}_wf_with_triang.png diff --git a/tests/bugs/vis/bug27083 b/tests/bugs/vis/bug27083 index bb30320f58..6d3f397948 100644 --- a/tests/bugs/vis/bug27083 +++ b/tests/bugs/vis/bug27083 @@ -13,7 +13,7 @@ vinit View1 vdisplay -noupdate -dispMode 1 b vfit -vshowfaceboundary b 1 255 0 0 3 +vaspects b -setFaceBoundaryDraw 1 -setFaceBoundaryColor RED -setFaceBoundaryWidth 3 vraytrace 1 if {[vreadpixel 295 255 name] != "GOLDENROD4 0"} { diff --git a/tests/bugs/vis/bug27821 b/tests/bugs/vis/bug27821 index f0e5c87506..def3b14c29 100644 --- a/tests/bugs/vis/bug27821 +++ b/tests/bugs/vis/bug27821 @@ -18,7 +18,8 @@ vaxo vdisplay -noupdate -dispMode 0 s vaspects s -subshapes s_1 -setcolor RED vdisplay -noupdate -dispMode 1 s -vshowfaceboundary s 1 255 0 0 2 +vaspects s -unsetFaceBoundary +vaspects s -setFaceBoundaryDraw 1 -setFaceBoundaryColor RED -setFaceBoundaryWidth 2 vfit vselect 250 250 diff --git a/tests/bugs/vis/bug29787 b/tests/bugs/vis/bug29787 new file mode 100644 index 0000000000..eec0d737ab --- /dev/null +++ b/tests/bugs/vis/bug29787 @@ -0,0 +1,25 @@ +puts "========" +puts "0029787: Visualization - Avoid in presentation edges of certain continuity class" +puts "========" +puts "" + +pload MODELING VISUALIZATION + +vclear +vinit View1 +vsetcolorbg 255 255 255 + +psphere s1 1 +psphere s2 1 +psphere s3 1 +ttranslate s2 4 0 0 +ttranslate s3 8 0 0 + +vdisplay -dispMode 0 s1 +vdisplay -dispMode 1 s2 s3 +vfit + +vaspects s2 -setFaceBoundaryDraw 1 -setFaceBoundaryColor RED +vaspects s3 -setFaceBoundaryDraw 1 -setFaceBoundaryColor RED -setMostContinuity c2 + +vdump $::imagedir/${::casename}.png diff --git a/tests/v3d/raytrace/bug26070 b/tests/v3d/raytrace/bug26070 index 74f54fbc05..672def8d62 100755 --- a/tests/v3d/raytrace/bug26070 +++ b/tests/v3d/raytrace/bug26070 @@ -62,7 +62,7 @@ trotate res 0 0 0 0 0 1 90 #vinit vdisplay res vsetdispmode 1 -#vshowfaceboundary res 1 255 255 255 +#vaspects res -setFaceBoundaryDraw 1 -setFaceBoundaryColor WHITE vfit vrenderparams -rayTrace -reflections