1 // Created on: 1993-06-23
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
24 #include <TopOpeBRepDS_Curve.ixx>
25 #include <TopOpeBRepDS_SurfaceCurveInterference.hxx>
26 #include <TopOpeBRepDS_Dumper.hxx>
27 #include <Precision.hxx>
30 //=======================================================================
31 //function : TopOpeBRepDS_Curve
33 //=======================================================================
35 TopOpeBRepDS_Curve::TopOpeBRepDS_Curve() :
36 myFirst(0.0), myLast(0.0),
37 myRangeDefined(Standard_False),
38 myTolerance(Precision::Confusion()),
39 myIsWalk(Standard_False),
40 myKeep(Standard_True),
46 //=======================================================================
47 //function : TopOpeBRepDS_Curve
49 //=======================================================================
51 TopOpeBRepDS_Curve::TopOpeBRepDS_Curve
52 (const Handle(Geom_Curve)& C,
53 const Standard_Real T,
54 const Standard_Boolean IsWalk) :
55 myFirst(0.0), myLast(0.0),
56 myRangeDefined(Standard_False),
57 myKeep(Standard_True),
61 DefineCurve(C,T,IsWalk);
64 //=======================================================================
65 //function : DefineCurve
67 //=======================================================================
69 void TopOpeBRepDS_Curve::DefineCurve
70 (const Handle(Geom_Curve)& C,
71 const Standard_Real T,
72 const Standard_Boolean IsWalk)
79 //=======================================================================
80 //function : Tolerance
82 //=======================================================================
84 void TopOpeBRepDS_Curve::Tolerance(const Standard_Real T)
89 //=======================================================================
92 //=======================================================================
94 void TopOpeBRepDS_Curve::SetSCI(const Handle(TopOpeBRepDS_Interference)& SCI1,
95 const Handle(TopOpeBRepDS_Interference)& SCI2)
101 //=======================================================================
104 //=======================================================================
106 void TopOpeBRepDS_Curve::GetSCI(Handle(TopOpeBRepDS_Interference)& SCI1,
107 Handle(TopOpeBRepDS_Interference)& SCI2) const
113 //=======================================================================
116 //=======================================================================
118 const Handle(TopOpeBRepDS_Interference)& TopOpeBRepDS_Curve::GetSCI1() const
123 //=======================================================================
126 //=======================================================================
128 const Handle(TopOpeBRepDS_Interference)& TopOpeBRepDS_Curve::GetSCI2() const
133 //=======================================================================
134 //function : SetShapes
136 //=======================================================================
138 void TopOpeBRepDS_Curve::SetShapes(const TopoDS_Shape& S1,
139 const TopoDS_Shape& S2)
145 //=======================================================================
146 //function : GetShapes
148 //=======================================================================
150 void TopOpeBRepDS_Curve::GetShapes(TopoDS_Shape& S1,
151 TopoDS_Shape& S2) const
157 //=======================================================================
160 //=======================================================================
162 const TopoDS_Shape& TopOpeBRepDS_Curve::Shape1() const
167 //=======================================================================
168 //function : ChangeShape1
170 //=======================================================================
172 TopoDS_Shape& TopOpeBRepDS_Curve::ChangeShape1()
177 //=======================================================================
180 //=======================================================================
182 const TopoDS_Shape& TopOpeBRepDS_Curve::Shape2() const
187 //=======================================================================
188 //function : ChangeShape2
190 //=======================================================================
192 TopoDS_Shape& TopOpeBRepDS_Curve::ChangeShape2()
197 //=======================================================================
198 //function : ChangeCurve
200 //=======================================================================
202 Handle(Geom_Curve)& TopOpeBRepDS_Curve::ChangeCurve()
207 //=======================================================================
210 //=======================================================================
212 const Handle(Geom_Curve)& TopOpeBRepDS_Curve::Curve()const
217 //=======================================================================
218 //function : SetRange
220 //=======================================================================
222 void TopOpeBRepDS_Curve::SetRange(const Standard_Real First,
223 const Standard_Real Last)
227 myRangeDefined = Standard_True;
231 //=======================================================================
234 //=======================================================================
236 Standard_Boolean TopOpeBRepDS_Curve::Range(Standard_Real& First,
237 Standard_Real& Last) const
239 if (myRangeDefined) {
243 return myRangeDefined;
247 //=======================================================================
248 //function : Tolerance
250 //=======================================================================
252 Standard_Real TopOpeBRepDS_Curve::Tolerance()const
257 //=======================================================================
260 //=======================================================================
262 void TopOpeBRepDS_Curve::Curve(const Handle(Geom_Curve)& C3D,
263 const Standard_Real Tol)
270 //=======================================================================
273 //=======================================================================
275 const Handle(Geom2d_Curve)& TopOpeBRepDS_Curve::Curve1()const
277 if ( ! mySCI1.IsNull() ) {
279 (*((Handle(TopOpeBRepDS_SurfaceCurveInterference)*)&mySCI1))->PCurve();
282 static Handle(Geom2d_Curve) STALOC_Geom2dCurveNull1;
283 return STALOC_Geom2dCurveNull1;
287 //=======================================================================
290 //=======================================================================
292 void TopOpeBRepDS_Curve::Curve1(const Handle(Geom2d_Curve)& PC1)
294 if ( ! mySCI1.IsNull() ) {
295 (*((Handle(TopOpeBRepDS_SurfaceCurveInterference)*)&mySCI1))->PCurve(PC1);
300 //=======================================================================
303 //=======================================================================
305 const Handle(Geom2d_Curve)& TopOpeBRepDS_Curve::Curve2()const
307 if ( ! mySCI2.IsNull() ) {
309 (*((Handle(TopOpeBRepDS_SurfaceCurveInterference)*)&mySCI2))->PCurve();
312 static Handle(Geom2d_Curve) STALOC_Geom2dCurveNull2;
313 return STALOC_Geom2dCurveNull2;
317 //=======================================================================
320 //=======================================================================
322 void TopOpeBRepDS_Curve::Curve2(const Handle(Geom2d_Curve)& PC2)
324 if ( ! mySCI2.IsNull() ) {
325 (*((Handle(TopOpeBRepDS_SurfaceCurveInterference)*)&mySCI2))->PCurve(PC2);
330 //=======================================================================
333 //=======================================================================
335 Standard_Boolean TopOpeBRepDS_Curve::IsWalk() const
340 //=======================================================================
341 //function : ChangeIsWalk
343 //=======================================================================
345 void TopOpeBRepDS_Curve::ChangeIsWalk(const Standard_Boolean B)
351 //=======================================================================
354 //=======================================================================
357 Standard_OStream& TopOpeBRepDS_Curve::Dump (Standard_OStream& OS,
358 const Standard_Integer index,
359 const Standard_Boolean compact)const
361 OS<<"Curve : "; if (index != 0) OS<<index<<" ";
362 if (!Curve().IsNull()) {
363 TopOpeBRepDS_Dumper::Print(Curve(),OS,compact);
365 if (Range(f,l)) OS<<"has range of "<<f<<","<<l<<endl;
366 else OS<<"has no range defined"<<endl;
371 #define DSCI(tut) (*((Handle(TopOpeBRepDS_SurfaceCurveInterference)*)&(tut)))
373 Handle(TopOpeBRepDS_Interference) I1,I2;
377 if (!I1.IsNull()) DSCI(I1)->DumpPCurve(OS,compact);
382 if (!I2.IsNull()) DSCI(I2)->DumpPCurve(OS,compact);
389 Standard_OStream& TopOpeBRepDS_Curve::Dump (Standard_OStream& OS,
390 const Standard_Integer,
391 const Standard_Boolean)const
398 //=======================================================================
401 //=======================================================================
403 Standard_Boolean TopOpeBRepDS_Curve::Keep() const
409 //=======================================================================
410 //function : ChangeKeep
412 //=======================================================================
414 void TopOpeBRepDS_Curve::ChangeKeep(const Standard_Boolean b)
420 //=======================================================================
423 //=======================================================================
425 Standard_Integer TopOpeBRepDS_Curve::Mother() const
431 //=======================================================================
432 //function : ChangeMother
434 //=======================================================================
436 void TopOpeBRepDS_Curve::ChangeMother(const Standard_Integer b)
441 //=======================================================================
444 //=======================================================================
446 Standard_Integer TopOpeBRepDS_Curve::DSIndex() const
452 //=======================================================================
453 //function : ChangeDSIndex
455 //=======================================================================
457 void TopOpeBRepDS_Curve::ChangeDSIndex(const Standard_Integer b)