--- /dev/null
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include <HYDROGUI_Polyline.h>
+
+#include <AIS_InteractiveContext.hxx>
+#include <BRep_Tool.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+#include <Prs3d_Arrow.hxx>
+#include <TopExp.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <BRepBndLib.hxx>
+#include <Precision.hxx>
+
+IMPLEMENT_STANDARD_HANDLE (HYDROGUI_Polyline, AIS_Shape)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_Polyline, AIS_Shape)
+
+
+HYDROGUI_Polyline::HYDROGUI_Polyline(const TopoDS_Shape& shape)
+ : AIS_Shape(shape)
+{
+}
+
+HYDROGUI_Polyline::~HYDROGUI_Polyline()
+{
+}
+
+void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+ const Handle(Prs3d_Presentation)& aPrs,
+ const Standard_Integer aMode)
+{
+ AIS_Shape::Compute(aPresentationManager, aPrs, aMode);
+
+ TopExp_Explorer Exp ( myshape, TopAbs_EDGE );
+ for ( ; Exp.More(); Exp.Next() ) {
+ TopoDS_Vertex aV1, aV2;
+ TopoDS_Edge anEdge = TopoDS::Edge(Exp.Current());
+
+ if ( anEdge.IsNull() )
+ continue;
+ TopExp::Vertices(anEdge, aV1, aV2);
+ gp_Pnt aP = BRep_Tool::Pnt(aV1);
+ gp_Vec aDirVec;
+ double aFp, aLp;
+ Handle(Geom_Curve) C = BRep_Tool::Curve(anEdge,aFp,aLp);
+ if ( C.IsNull() )
+ continue;
+
+ Bnd_Box aBB;
+ BRepBndLib::Add(anEdge, aBB);
+ Standard_Real aXmin,aYmin,aZmin,aXmax,aYmax,aZmax;
+ aBB.Get(aXmin,aYmin,aZmin,aXmax,aYmax,aZmax);
+ Standard_Real aLen = Max(Abs(aXmax - aXmin), Max (Abs(aZmax - aZmin), Abs(aYmax - aYmin)));
+
+ GeomAdaptor_Curve aAdC;
+ aAdC.Load(C, aFp, aLp);
+ double aLenC;
+ double aLenH;
+ int aNbSegments = 20;
+ double aArrLen = aLen / 10.;
+ double anIncr = (aLp-aFp)/aNbSegments;
+ double aMaxRatio = 0;
+ double aMaxRatioStep = 1;
+ for (double t = aFp; t < aLp - anIncr; t += anIncr)
+ {
+ aLenC = GCPnts_AbscissaPoint::Length(aAdC, t, t + anIncr);
+ aLenH = C->Value (t).Distance (C->Value (t + anIncr));
+ if ( aLenH / aLenC > aMaxRatio) {
+ aMaxRatio = aLenH / aLenC;
+ aMaxRatioStep = t;
+ }
+ }
+
+ bool UseD1 = false;
+ if (Abs(aMaxRatioStep) < Precision::Confusion())
+ {
+ aMaxRatioStep = (aLp - aFp)/2.0;
+ UseD1 = true;
+ }
+
+ if (Abs(aLp - aMaxRatioStep) < Precision::Confusion())
+ {
+ aMaxRatioStep = (aLp - aFp)/2.0;
+ UseD1 = true;
+ }
+
+ gp_Pnt aPnt1 = C->Value (aMaxRatioStep);
+ gp_Vec aDir;
+ if (!UseD1) {
+ GCPnts_AbscissaPoint aAbsPoint(aAdC, -aArrLen, aMaxRatioStep);
+ double aParam = aAbsPoint.Parameter();
+ gp_Pnt aPnt2 = C->Value (aParam);
+ gp_XYZ D = aPnt1.XYZ();
+ D.Subtract (aPnt2.XYZ());
+ aDir = D;
+ }
+ else
+ C->D1(aMaxRatioStep, C->Value (aMaxRatioStep), aDir);
+
+ if ( anEdge.Orientation() == TopAbs_REVERSED )
+ aDir = -aDir;
+
+ Prs3d_Arrow::Draw(aPrs, aPnt1, aDir, M_PI/180.*12., aArrLen);
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef _HYDROGUI_Polyline_HeaderFile
+#define _HYDROGUI_Polyline_HeaderFile
+
+#include <AIS_Shape.hxx>
+#include <AIS_InteractiveObject.hxx>
+
+#include <Standard.hxx>
+#include <Standard_DefineHandle.hxx>
+#include <PrsMgr_PresentationManager.hxx>
+#include <Handle_Prs3d_Presentation.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <AIS_DisplayMode.hxx>
+
+class TopoDS_Shape;
+
+class HYDROGUI_Polyline : public AIS_Shape
+{
+public:
+
+ Standard_EXPORT HYDROGUI_Polyline(const TopoDS_Shape& shape);
+ Standard_EXPORT ~HYDROGUI_Polyline();
+
+ Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+ const Handle(Prs3d_Presentation)& aPresentation,
+ const Standard_Integer aMode = 0);
+
+public:
+ DEFINE_STANDARD_RTTI(HYDROGUI_Polyline);
+};
+
+DEFINE_STANDARD_HANDLE(HYDROGUI_Polyline, AIS_Shape)
+
+#endif