Integration of OCCT 6.5.0 from SVN
[occt.git] / src / BRep / BRep_TEdge.cxx
1 // File:        BRep_TEdge.cxx
2 // Created:     Tue Aug 25 15:37:58 1992
3 // Author:      Modelistation
4 //              <model@phylox>
5
6
7 #include <BRep_TEdge.ixx>
8 #include <TopAbs.hxx>
9 #include <BRep_CurveRepresentation.hxx>
10 #include <BRep_ListOfCurveRepresentation.hxx>
11 #include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
12 #include <BRep_GCurve.hxx>
13 #include <BRep_CurveOn2Surfaces.hxx>
14
15 static const Standard_Integer ParameterMask       = 1;
16 static const Standard_Integer RangeMask           = 2;
17 static const Standard_Integer DegeneratedMask     = 4;
18
19 //=======================================================================
20 //function : BRep_TEdge
21 //purpose  : 
22 //=======================================================================
23
24 BRep_TEdge::BRep_TEdge() :
25        TopoDS_TEdge(),
26        myTolerance(RealEpsilon()),
27        myFlags(0)
28 {
29   SameParameter(Standard_True);
30   SameRange(Standard_True);
31 }
32
33 //=======================================================================
34 //function : SameParameter
35 //purpose  : 
36 //=======================================================================
37
38  Standard_Boolean  BRep_TEdge::SameParameter()const 
39 {
40   return myFlags & ParameterMask;
41 }
42
43
44 //=======================================================================
45 //function : SameParameter
46 //purpose  : 
47 //=======================================================================
48
49  void  BRep_TEdge::SameParameter(const Standard_Boolean S)
50 {
51   if (S) myFlags |= ParameterMask;
52   else   myFlags &= ~ParameterMask;
53 }
54
55
56 //=======================================================================
57 //function : SameRange
58 //purpose  : 
59 //=======================================================================
60
61  Standard_Boolean  BRep_TEdge::SameRange()const 
62 {
63   return myFlags & RangeMask;
64 }
65
66
67 //=======================================================================
68 //function : SameRange
69 //purpose  : 
70 //=======================================================================
71
72  void  BRep_TEdge::SameRange(const Standard_Boolean S)
73 {
74   if (S) myFlags |= RangeMask;
75   else   myFlags &= ~RangeMask;
76 }
77
78
79 //=======================================================================
80 //function : Degenerated
81 //purpose  : 
82 //=======================================================================
83
84  Standard_Boolean  BRep_TEdge::Degenerated()const 
85 {
86   return myFlags & DegeneratedMask;
87 }
88
89
90 //=======================================================================
91 //function : Degenerated
92 //purpose  : 
93 //=======================================================================
94
95  void  BRep_TEdge::Degenerated(const Standard_Boolean S)
96 {
97   if (S) myFlags |= DegeneratedMask; 
98   else   myFlags &= ~DegeneratedMask;
99 }
100
101 //=======================================================================
102 //function : EmptyCopy
103 //purpose  : 
104 //=======================================================================
105
106 Handle(TopoDS_TShape) BRep_TEdge::EmptyCopy() const
107 {
108   Handle(BRep_TEdge) TE = 
109     new BRep_TEdge();
110   TE->Tolerance(myTolerance);
111   // copy the curves representations
112   BRep_ListOfCurveRepresentation& l = TE->ChangeCurves();
113   BRep_ListIteratorOfListOfCurveRepresentation itr(myCurves);
114   
115   while (itr.More()) {
116     // on ne recopie PAS les polygones
117     if ( itr.Value()->IsKind(STANDARD_TYPE(BRep_GCurve)) ||
118          itr.Value()->IsKind(STANDARD_TYPE(BRep_CurveOn2Surfaces)) ) {
119       l.Append(itr.Value()->Copy());
120     }
121     itr.Next();
122   }
123
124   TE->Degenerated(Degenerated());
125   TE->SameParameter(SameParameter());
126   TE->SameRange(SameRange());
127   
128   return TE;
129 }
130