1 // File: DrawDim_Distance.cxx
2 // Created: Mon Apr 21 14:38:30 1997
3 // Author: Denis PASCAL
5 #include <DrawDim_Distance.ixx>
7 #include <TopoDS_Shape.hxx>
9 #include <BRepAdaptor_Surface.hxx>
15 #include <TopExp_Explorer.hxx>
16 #include <TopoDS_Vertex.hxx>
17 #include <BRep_Tool.hxx>
18 #include <Precision.hxx>
19 #include <TCollection_AsciiString.hxx>
22 //=======================================================================
23 //function : DrawDim_Distance
25 //=======================================================================
27 DrawDim_Distance::DrawDim_Distance (const TopoDS_Face& plane1,
28 const TopoDS_Face& plane2)
35 //=======================================================================
36 //function : DrawDim_Distance
38 //=======================================================================
40 DrawDim_Distance::DrawDim_Distance (const TopoDS_Face& plane1)
46 //=======================================================================
49 //=======================================================================
51 const TopoDS_Face& DrawDim_Distance::Plane1() const
56 //=======================================================================
59 //=======================================================================
61 void DrawDim_Distance::Plane1(const TopoDS_Face& face)
66 //=======================================================================
69 //=======================================================================
71 const TopoDS_Face& DrawDim_Distance::Plane2() const
76 //=======================================================================
79 //=======================================================================
81 void DrawDim_Distance::Plane2(const TopoDS_Face& face)
87 //=======================================================================
90 //=======================================================================
92 void DrawDim_Distance::DrawOn(Draw_Display& dis) const
95 // compute the points and the direction
96 BRepAdaptor_Surface surf1(myPlane1);
98 // today we process only planar faces
99 if (surf1.GetType() != GeomAbs_Plane)
102 const gp_Ax1& anAx1 = surf1.Plane().Axis();
103 gp_Vec V = anAx1.Direction();
106 gp_Pnt FAttach; // first attach point
107 gp_Pnt SAttach; // second attach point
109 // first point, try a vertex
110 TopExp_Explorer explo(myPlane1,TopAbs_VERTEX);
112 FAttach = BRep_Tool::Pnt(TopoDS::Vertex(explo.Current()));
115 // no vertex, use the origin
116 FAttach = anAx1.Location();
120 if (!myPlane2.IsNull()) {
121 // translate the point until the second face
122 BRepAdaptor_Surface surf2(myPlane2);
123 surf2.D0(0,0,SAttach);
124 Standard_Real r = V.Dot(gp_Vec(FAttach,SAttach));
129 SAttach.Translate(V);
132 dis.Draw (FAttach,SAttach);
134 FAttach.Translate(V);
135 dis.DrawMarker(FAttach, Draw_Losange);
136 DrawText(FAttach,dis);