7fd59977 |
1 | // File: DrawDim_PlanarRadius.cxx |
2 | // Created: Fri Jan 12 17:59:57 1996 |
3 | // Author: Denis PASCAL |
4 | // <dp@zerox> |
5 | |
6 | |
7 | #include <DrawDim_PlanarRadius.ixx> |
8 | #include <DrawDim.hxx> |
9 | #include <Geom_Curve.hxx> |
10 | #include <Geom_Circle.hxx> |
11 | #include <gp_Pnt.hxx> |
12 | #include <gp_Circ.hxx> |
13 | #include <BRep_Tool.hxx> |
14 | #include <TCollection_AsciiString.hxx> |
15 | #include <Draw_Color.hxx> |
16 | #include <ElCLib.hxx> |
17 | #include <TopExp.hxx> |
18 | #include <TopoDS.hxx> |
19 | #include <TopoDS_Vertex.hxx> |
20 | |
21 | //======================================================================= |
22 | //function : DrawDim_PlanarRadius |
23 | //purpose : |
24 | //======================================================================= |
25 | |
26 | DrawDim_PlanarRadius::DrawDim_PlanarRadius(const TopoDS_Face& face, const TopoDS_Shape& c) |
27 | { |
28 | myPlane = face; |
29 | myCircle = c; |
30 | } |
31 | |
32 | |
33 | //======================================================================= |
34 | //function : DrawDim_PlanarRadius |
35 | //purpose : |
36 | //======================================================================= |
37 | |
38 | DrawDim_PlanarRadius::DrawDim_PlanarRadius(const TopoDS_Shape& c) |
39 | { |
40 | myCircle = c; |
41 | } |
42 | |
43 | |
44 | //======================================================================= |
45 | //function : DrawOn |
46 | //purpose : |
47 | //======================================================================= |
48 | |
49 | void DrawDim_PlanarRadius::DrawOn(Draw_Display& dis) const |
50 | { |
51 | if (myCircle.ShapeType() == TopAbs_EDGE) { |
52 | Standard_Real f,l; |
53 | Handle(Geom_Curve) curve = BRep_Tool::Curve (TopoDS::Edge(myCircle),f,l); |
54 | if (curve->IsKind(STANDARD_TYPE(Geom_Circle))) { |
55 | gp_Circ circle = Handle(Geom_Circle)::DownCast(curve)->Circ(); |
56 | const gp_Pnt& first = circle.Location(); |
57 | TopoDS_Vertex vf, vl; |
58 | TopExp::Vertices(TopoDS::Edge(myCircle),vf,vl); |
59 | const gp_Pnt last = BRep_Tool::Pnt(vf); |
60 | // |
61 | dis.Draw (first,last); |
62 | gp_Pnt p ((first.X()+ last.X())/2,(first.Y()+ last.Y())/2,(first.Z()+ last.Z())/2); |
63 | DrawText(p,dis); |
64 | return; |
65 | } |
66 | } |
67 | cout << " DrawDim_PlanarRadius::DrawOn : dimension error" << endl; |
68 | } |