From 091686637e5b8a5faa6ba788264e20e57a2d74fb Mon Sep 17 00:00:00 2001 From: asl Date: Mon, 12 Oct 2015 11:39:57 +0300 Subject: [PATCH] refs #527, #577: more exact polyline presentation --- src/HYDROGUI/HYDROGUI_Polyline.cxx | 38 +++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/HYDROGUI/HYDROGUI_Polyline.cxx b/src/HYDROGUI/HYDROGUI_Polyline.cxx index 7d312cb5..91e0a06a 100644 --- a/src/HYDROGUI/HYDROGUI_Polyline.cxx +++ b/src/HYDROGUI/HYDROGUI_Polyline.cxx @@ -39,6 +39,10 @@ #include #include #include +#include +#include +#include +#include IMPLEMENT_STANDARD_HANDLE (HYDROGUI_Polyline, AIS_Shape) IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_Polyline, AIS_Shape) @@ -53,11 +57,43 @@ HYDROGUI_Polyline::~HYDROGUI_Polyline() { } +Handle( Graphic3d_ArrayOfPolylines ) BuildEdgePresentation( const TopoDS_Edge& theEdge, double theDeviation ) +{ + BRepAdaptor_Curve aCurveAdaptor( theEdge ); + GCPnts_QuasiUniformDeflection aPnts( aCurveAdaptor, theDeviation ); + + Handle( Graphic3d_ArrayOfPolylines ) anArray; + if( !aPnts.IsDone() ) + return anArray; + + int n = aPnts.NbPoints(); + anArray = new Graphic3d_ArrayOfPolylines( n ); + for( int i=1; i<=n; i++ ) + anArray->AddVertex( aPnts.Value( i ) ); + + return anArray; +} + void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPrs, const Standard_Integer aMode) { - AIS_Shape::Compute(aPresentationManager, aPrs, aMode); + //AIS_Shape::Compute(aPresentationManager, aPrs, aMode); + + aPrs->Clear(); + Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( aPrs ); + Handle(Graphic3d_AspectLine3d) anAspect = Attributes()->FaceBoundaryAspect()->Aspect(); + aGroup->SetGroupPrimitivesAspect( anAspect ); + + TopExp_Explorer Exp1 ( myshape, TopAbs_EDGE ); + for ( ; Exp1.More(); Exp1.Next() ) + { + TopoDS_Edge anEdge = TopoDS::Edge( Exp1.Current() ); + Handle( Graphic3d_ArrayOfPolylines ) anArray = BuildEdgePresentation( anEdge, 0.1 ); + if( !anArray.IsNull() ) + aGroup->AddPrimitiveArray ( anArray ); + } + TopExp_Explorer Exp ( myshape, TopAbs_EDGE ); for ( ; Exp.More(); Exp.Next() ) { -- 2.39.2