0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / BRep / BRep_TEdge.cxx
1 // Created on: 1992-08-25
2 // Created by: Modelistation
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <BRep_CurveOn2Surfaces.hxx>
19 #include <BRep_CurveRepresentation.hxx>
20 #include <BRep_GCurve.hxx>
21 #include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
22 #include <BRep_ListOfCurveRepresentation.hxx>
23 #include <BRep_TEdge.hxx>
24 #include <Standard_Type.hxx>
25 #include <TopAbs.hxx>
26 #include <TopoDS_Shape.hxx>
27
28 IMPLEMENT_STANDARD_RTTIEXT(BRep_TEdge,TopoDS_TEdge)
29
30 static const Standard_Integer ParameterMask       = 1;
31 static const Standard_Integer RangeMask           = 2;
32 static const Standard_Integer DegeneratedMask     = 4;
33
34 //=======================================================================
35 //function : BRep_TEdge
36 //purpose  : 
37 //=======================================================================
38
39 BRep_TEdge::BRep_TEdge() :
40        TopoDS_TEdge(),
41        myTolerance(RealEpsilon()),
42        myFlags(0)
43 {
44   SameParameter(Standard_True);
45   SameRange(Standard_True);
46 }
47
48 //=======================================================================
49 //function : SameParameter
50 //purpose  : 
51 //=======================================================================
52
53 Standard_Boolean BRep_TEdge::SameParameter() const
54 {
55   return (myFlags & ParameterMask) != 0;
56 }
57
58
59 //=======================================================================
60 //function : SameParameter
61 //purpose  : 
62 //=======================================================================
63
64  void  BRep_TEdge::SameParameter(const Standard_Boolean S)
65 {
66   if (S) myFlags |= ParameterMask;
67   else   myFlags &= ~ParameterMask;
68 }
69
70
71 //=======================================================================
72 //function : SameRange
73 //purpose  : 
74 //=======================================================================
75
76 Standard_Boolean BRep_TEdge::SameRange() const
77 {
78   return (myFlags & RangeMask) != 0;
79 }
80
81 //=======================================================================
82 //function : SameRange
83 //purpose  : 
84 //=======================================================================
85
86  void  BRep_TEdge::SameRange(const Standard_Boolean S)
87 {
88   if (S) myFlags |= RangeMask;
89   else   myFlags &= ~RangeMask;
90 }
91
92
93 //=======================================================================
94 //function : Degenerated
95 //purpose  : 
96 //=======================================================================
97
98 Standard_Boolean BRep_TEdge::Degenerated() const
99 {
100   return (myFlags & DegeneratedMask) != 0;
101 }
102
103 //=======================================================================
104 //function : Degenerated
105 //purpose  : 
106 //=======================================================================
107
108  void  BRep_TEdge::Degenerated(const Standard_Boolean S)
109 {
110   if (S) myFlags |= DegeneratedMask; 
111   else   myFlags &= ~DegeneratedMask;
112 }
113
114 //=======================================================================
115 //function : EmptyCopy
116 //purpose  : 
117 //=======================================================================
118
119 Handle(TopoDS_TShape) BRep_TEdge::EmptyCopy() const
120 {
121   Handle(BRep_TEdge) TE = 
122     new BRep_TEdge();
123   TE->Tolerance(myTolerance);
124   // copy the curves representations
125   BRep_ListOfCurveRepresentation& l = TE->ChangeCurves();
126   BRep_ListIteratorOfListOfCurveRepresentation itr(myCurves);
127   
128   while (itr.More()) {
129     // on ne recopie PAS les polygones
130     if ( itr.Value()->IsKind(STANDARD_TYPE(BRep_GCurve)) ||
131          itr.Value()->IsKind(STANDARD_TYPE(BRep_CurveOn2Surfaces)) ) {
132       l.Append(itr.Value()->Copy());
133     }
134     itr.Next();
135   }
136
137   TE->Degenerated(Degenerated());
138   TE->SameParameter(SameParameter());
139   TE->SameRange(SameRange());
140   
141   return TE;
142 }
143
144 //=======================================================================
145 //function : DumpJson
146 //purpose  : 
147 //=======================================================================
148 void BRep_TEdge::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
149 {
150   OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
151
152   OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TopoDS_TEdge)
153
154   OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTolerance)
155   OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFlags)
156
157   for (BRep_ListIteratorOfListOfCurveRepresentation itr(myCurves); itr.More(); itr.Next())
158   {
159     const Handle(BRep_CurveRepresentation)& aCurveRepresentation = itr.Value();
160     OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aCurveRepresentation.get())
161   }
162 }