0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / DrawDim / DrawDim_PlanarDiameter.cxx
CommitLineData
b311480e 1// Created on: 1998-11-25
2// Created by: Denis PASCAL
3// Copyright (c) 1998-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17
7fd59977 18#include <BRep_Tool.hxx>
7fd59977 19#include <Draw_Color.hxx>
42cf5bc1 20#include <Draw_Display.hxx>
21#include <DrawDim_PlanarDiameter.hxx>
7fd59977 22#include <ElCLib.hxx>
42cf5bc1 23#include <Geom_Circle.hxx>
24#include <Geom_Curve.hxx>
25#include <gp_Circ.hxx>
26#include <gp_Pnt.hxx>
27#include <Standard_Type.hxx>
28#include <TCollection_AsciiString.hxx>
7fd59977 29#include <TopExp.hxx>
30#include <TopoDS.hxx>
42cf5bc1 31#include <TopoDS_Face.hxx>
32#include <TopoDS_Shape.hxx>
7fd59977 33#include <TopoDS_Vertex.hxx>
34
92efcf78 35IMPLEMENT_STANDARD_RTTIEXT(DrawDim_PlanarDiameter,DrawDim_PlanarDimension)
36
7fd59977 37//=======================================================================
38//function : DrawDim_PlanarDiameter
39//purpose :
40//=======================================================================
7fd59977 41DrawDim_PlanarDiameter::DrawDim_PlanarDiameter(const TopoDS_Face& face, const TopoDS_Shape& c)
42{
43 myPlane = face;
44 myCircle = c;
45}
46
47
48//=======================================================================
49//function : DrawDim_PlanarDiameter
50//purpose :
51//=======================================================================
52
53DrawDim_PlanarDiameter::DrawDim_PlanarDiameter(const TopoDS_Shape& c)
54{
55 myCircle = c;
56}
57
58
59//=======================================================================
60//function : DrawOn
61//purpose :
62//=======================================================================
63
64void DrawDim_PlanarDiameter::DrawOn(Draw_Display& dis) const
65{
66 if (myCircle.ShapeType() == TopAbs_EDGE) {
67 Standard_Real f,l;
68 Handle(Geom_Curve) curve = BRep_Tool::Curve (TopoDS::Edge(myCircle),f,l);
69 if (curve->IsKind(STANDARD_TYPE(Geom_Circle))) {
70 gp_Circ circle = Handle(Geom_Circle)::DownCast(curve)->Circ();
71 TopoDS_Vertex vf, vl;
72 TopExp::Vertices(TopoDS::Edge(myCircle),vf,vl);
73 const gp_Pnt first = BRep_Tool::Pnt(vf);
74 Standard_Real parfirst = ElCLib::Parameter(circle,first);
c6541a0c 75 Standard_Real parlast = (parfirst + M_PI);
7fd59977 76 gp_Pnt last = ElCLib::Value(parlast,circle);
77 //
78 dis.Draw (first,last);
79 gp_Pnt p ((first.X()+ last.X())/2,(first.Y()+ last.Y())/2,(first.Z()+ last.Z())/2);
80 DrawText(p,dis);
81 return;
82 }
83 }
0797d9d3 84#ifdef OCCT_DEBUG
7fd59977 85 cout << " DrawDim_PlanarDiameter::DrawOn : dimension error" << endl;
63c629aa 86#endif
7fd59977 87}