1 // Created on: 1997-04-21
2 // Created by: Denis PASCAL
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <BRepAdaptor_Surface.hxx>
19 #include <Draw_Display.hxx>
20 #include <DrawDim_Radius.hxx>
21 #include <GC_MakeCircle.hxx>
22 #include <Geom_Circle.hxx>
23 #include <Geom_Curve.hxx>
24 #include <Geom_Surface.hxx>
25 #include <Geom_ToroidalSurface.hxx>
26 #include <gp_Circ.hxx>
28 #include <Standard_Type.hxx>
30 #include <TopoDS_Face.hxx>
32 IMPLEMENT_STANDARD_RTTIEXT(DrawDim_Radius,DrawDim_Dimension)
34 //=======================================================================
35 //function : DrawDim_Radius
37 //=======================================================================
38 DrawDim_Radius::DrawDim_Radius(const TopoDS_Face& cylinder)
40 myCylinder = cylinder;
43 //=======================================================================
46 //=======================================================================
48 const TopoDS_Face& DrawDim_Radius::Cylinder() const
53 //=======================================================================
56 //=======================================================================
58 void DrawDim_Radius::Cylinder(const TopoDS_Face& face)
64 //=======================================================================
67 //=======================================================================
69 void DrawDim_Radius::DrawOn(Draw_Display& dis) const
72 TopoDS_Shape myFShape = myCylinder;
78 //=======================================================================
79 //function : ComputeOneFaceRadius
81 //=======================================================================
83 //void AIS_RadiusDimension::ComputeOneFaceRadius(const Handle(Prs3d_Presentation)& aPresentation)
86 cout << "entree dans computeonefaceradius"<< endl;
88 BRepAdaptor_Surface surfAlgo (TopoDS::Face(myFShape));
89 Standard_Real uFirst, uLast, vFirst, vLast;
90 uFirst = surfAlgo.FirstUParameter();
91 uLast = surfAlgo.LastUParameter();
92 vFirst = surfAlgo.FirstVParameter();
93 vLast = surfAlgo.LastVParameter();
94 Standard_Real uMoy = (uFirst + uLast)/2;
95 Standard_Real vMoy = (vFirst + vLast)/2;
97 surfAlgo.D0(uMoy, vMoy, curpos);
98 const Handle(Geom_Surface)& surf = surfAlgo.Surface().Surface();
99 Handle(Geom_Curve) aCurve;
100 if (surf->DynamicType() == STANDARD_TYPE(Geom_ToroidalSurface)) {
101 aCurve = surf->UIso(uMoy);
106 aCurve = surf->VIso(vMoy);
109 if (aCurve->DynamicType() == STANDARD_TYPE(Geom_Circle)) {
110 myCircle = Handle(Geom_Circle)::DownCast(aCurve)->Circ();
111 } // if (aCurve->DynamicType() ...
114 // compute a circle from 3 points on "aCurve"
116 surfAlgo.D0(uFirst, vMoy, P1);
117 surfAlgo.D0(uLast, vMoy, P2);
118 GC_MakeCircle mkCirc(P1, curpos, P2);
119 myCircle = mkCirc.Value()->Circ();
125 // Add(myText, curpos, mCircle, uFirst, uLast)
127 dis.Draw(myCircle,uFirst,uLast);
128 dis.DrawMarker(myPosition, Draw_Losange);