summaryrefslogtreecommitdiff
path: root/src/DrawDim/DrawDim_Radius.cxx
blob: 3ffafcfed09684334a4d00d9008f5f46f353618f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// File:	DrawDim_Radius.cxx
// Created:	Mon Apr 21 14:40:47 1997
// Author:	Denis PASCAL
//		<dp@dingox.paris1.matra-dtv.fr>


#include <DrawDim_Radius.ixx>
#include <BRepAdaptor_Surface.hxx>
#include <Geom_Surface.hxx>
#include <gp_Pnt.hxx>
#include <gp_Circ.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <GC_MakeCircle.hxx>
#include <TopoDS.hxx>
#include <Geom_ToroidalSurface.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Circle.hxx>

//=======================================================================
//function : DrawDim_Radius
//purpose  : 
//=======================================================================

DrawDim_Radius::DrawDim_Radius(const TopoDS_Face& cylinder)
{
  myCylinder = cylinder;
}

//=======================================================================
//function : Cylinder
//purpose  : 
//=======================================================================

const TopoDS_Face& DrawDim_Radius::Cylinder() const
{
  return myCylinder;
}

//=======================================================================
//function : Cylinder
//purpose  : 
//=======================================================================

void DrawDim_Radius::Cylinder(const TopoDS_Face& face) 
{
  myCylinder = face;
}


//=======================================================================
//function : DrawOn
//purpose  : 
//=======================================================================

void DrawDim_Radius::DrawOn(Draw_Display& dis) const
{
  // input  
  TopoDS_Shape myFShape = myCylinder;

  // output
  gp_Pnt myPosition;
  gp_Circ myCircle;

//=======================================================================
//function : ComputeOneFaceRadius
//purpose  : 
//=======================================================================

//void AIS_RadiusDimension::ComputeOneFaceRadius(const Handle(Prs3d_Presentation)& aPresentation)
//{

  cout << "entree dans computeonefaceradius"<< endl;
  BRepAdaptor_Surface surfAlgo (TopoDS::Face(myFShape));
  Standard_Real uFirst, uLast, vFirst, vLast;
  uFirst = surfAlgo.FirstUParameter();
  uLast = surfAlgo.LastUParameter();
  vFirst = surfAlgo.FirstVParameter();
  vLast = surfAlgo.LastVParameter();
  Standard_Real uMoy = (uFirst + uLast)/2;
  Standard_Real vMoy = (vFirst + vLast)/2;
  gp_Pnt curpos ;
  surfAlgo.D0(uMoy, vMoy, curpos);
  const Handle(Geom_Surface)& surf = surfAlgo.Surface().Surface();
  Handle(Geom_Curve) aCurve;
  if (surf->DynamicType() == STANDARD_TYPE(Geom_ToroidalSurface)) {
    aCurve = surf->UIso(uMoy);
    uFirst = vFirst;
    uLast = vLast;
  }
  else {
    aCurve = surf->VIso(vMoy);
  }

  if (aCurve->DynamicType() == STANDARD_TYPE(Geom_Circle)) {
    myCircle = Handle(Geom_Circle)::DownCast(aCurve)->Circ();
  } // if (aCurve->DynamicType() ...

  else {
    // compute a circle from 3 points on "aCurve"
    gp_Pnt P1, P2;
    surfAlgo.D0(uFirst, vMoy, P1);
    surfAlgo.D0(uLast, vMoy, P2);
    GC_MakeCircle mkCirc(P1, curpos, P2);
    myCircle = mkCirc.Value()->Circ();
  } // else ...

  myPosition = curpos;

  // DISPLAY
  // Add(myText, curpos, mCircle, uFirst, uLast)    

  dis.Draw(myCircle,uFirst,uLast);  
  dis.DrawMarker(myPosition, Draw_Losange);
}