0022627: Change OCCT memory management defaults
[occt.git] / src / StdPrs / StdPrs_ToolRFace.cxx
1 #include <StdPrs_ToolRFace.ixx>
2 #include <Geom2d_TrimmedCurve.hxx>
3 #include <BRep_Tool.hxx>
4 #include <TopoDS.hxx>
5 #include <Adaptor2d_Curve2d.hxx>
6
7
8 #define OCC316
9
10 //=======================================================================
11 //function : StdPrs_ToolRFace
12 //purpose  : 
13 //=======================================================================
14
15 StdPrs_ToolRFace::StdPrs_ToolRFace()
16 {
17 }
18
19 //=======================================================================
20 //function : StdPrs_ToolRFace
21 //purpose  : 
22 //=======================================================================
23
24 StdPrs_ToolRFace::StdPrs_ToolRFace(const Handle(BRepAdaptor_HSurface)& aSurface) :
25        myFace(((BRepAdaptor_Surface*)&(aSurface->Surface()))->Face())
26 {
27   myFace.Orientation(TopAbs_FORWARD);
28 }
29
30 //=======================================================================
31 //function : IsOriented
32 //purpose  : 
33 //=======================================================================
34
35 Standard_Boolean StdPrs_ToolRFace::IsOriented () const {
36   
37   return Standard_True;
38
39 }
40
41 //=======================================================================
42 //function : Init
43 //purpose  : 
44 //=======================================================================
45
46 void StdPrs_ToolRFace::Init() 
47 {
48   myExplorer.Init(myFace,TopAbs_EDGE);
49   if (myExplorer.More()) {
50     Standard_Real U1,U2;
51     const Handle(Geom2d_Curve)& C = 
52       BRep_Tool::CurveOnSurface(TopoDS::Edge(myExplorer.Current()),
53                                 myFace,
54                                 U1,U2);
55     DummyCurve.Load(C,U1,U2);
56   }
57 }
58
59 //=======================================================================
60 //function : More
61 //purpose  : 
62 //=======================================================================
63
64 Standard_Boolean StdPrs_ToolRFace::More() const
65 {
66   return myExplorer.More();
67 }
68
69 //=======================================================================
70 //function : Next
71 //purpose  : 
72 //=======================================================================
73
74 void StdPrs_ToolRFace::Next()
75 {
76   myExplorer.Next();
77
78   if (myExplorer.More()) {
79     // skip INTERNAL and EXTERNAL edges
80     while (myExplorer.More() && (myExplorer.Current().Orientation() == TopAbs_INTERNAL 
81                               || myExplorer.Current().Orientation() == TopAbs_EXTERNAL)) 
82         myExplorer.Next();
83     if (myExplorer.More()) {
84       Standard_Real U1,U2;
85       const Handle(Geom2d_Curve)& C = 
86         BRep_Tool::CurveOnSurface(TopoDS::Edge(myExplorer.Current()),
87                                   myFace,
88                                   U1,U2);
89 #ifdef OCC316
90       if ( !C.IsNull() )
91 #endif
92         DummyCurve.Load(C,U1,U2);
93     }
94   }
95 }
96
97 //=======================================================================
98 //function : Value
99 //purpose  : 
100 //=======================================================================
101
102 Adaptor2d_Curve2dPtr StdPrs_ToolRFace::Value() const
103 {
104   return (Adaptor2d_Curve2dPtr)&DummyCurve;
105 }
106
107 //=======================================================================
108 //function : Orientation
109 //purpose  : 
110 //=======================================================================
111
112 TopAbs_Orientation StdPrs_ToolRFace::Orientation () const {
113   return myExplorer.Current().Orientation();
114 }
115