1 // Created on: 1993-04-16
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <IntCurveSurface_Intersection.hxx>
19 #include <IntCurveSurface_IntersectionPoint.hxx>
20 #include <IntCurveSurface_IntersectionSegment.hxx>
21 #include <IntCurveSurface_TransitionOnCurve.hxx>
22 #include <StdFail_NotDone.hxx>
24 #define PARAMEQUAL(a,b) (Abs((a)-(b))< (1e-8))
26 //================================================================================
27 IntCurveSurface_Intersection::IntCurveSurface_Intersection():
29 myIsParallel(Standard_False)
32 //================================================================================
33 Standard_Boolean IntCurveSurface_Intersection::IsDone() const { return(done); }
34 //================================================================================
35 Standard_Boolean IntCurveSurface_Intersection::IsParallel() const
39 //================================================================================
40 Standard_Integer IntCurveSurface_Intersection::NbPoints() const {
41 if (!done) {throw StdFail_NotDone();}
44 //================================================================================
45 Standard_Integer IntCurveSurface_Intersection::NbSegments() const {
46 if (!done) {throw StdFail_NotDone();}
49 //================================================================================
50 const IntCurveSurface_IntersectionPoint& IntCurveSurface_Intersection::Point( const Standard_Integer N) const {
51 if (!done) {throw StdFail_NotDone();}
54 //================================================================================
55 const IntCurveSurface_IntersectionSegment& IntCurveSurface_Intersection::Segment( const Standard_Integer N) const {
56 if (!done) {throw StdFail_NotDone();}
59 //================================================================================
60 void IntCurveSurface_Intersection::SetValues(const IntCurveSurface_Intersection& Other) {
64 Standard_Integer N = Other.lpnt.Length();
66 for( i=1; i<= N ; i++) {
67 lpnt.Append(Other.lpnt.Value(i));
69 N = Other.lseg.Length();
70 for(i=1; i<= N ; i++) {
71 lseg.Append(Other.lseg.Value(i));
79 //================================================================================
80 void IntCurveSurface_Intersection::Append(const IntCurveSurface_Intersection& Other,
81 // const Standard_Real a,
83 // const Standard_Real b)
86 Standard_Integer i,ni;
88 ni = Other.lpnt.Length();
89 for(i=1;i<=ni;i++) { Append(Other.Point(i)); }
90 ni = Other.lseg.Length();
91 for(i=1;i<=ni;i++) { Append(Other.Segment(i)); }
94 //================================================================================
95 void IntCurveSurface_Intersection::Append(const IntCurveSurface_IntersectionPoint& OtherPoint) {
96 Standard_Integer i,ni;
97 Standard_Real anu,anv,anw,u,v,w;
98 IntCurveSurface_TransitionOnCurve TrOnCurve,anTrOnCurve;
102 OtherPoint.Values(P,u,v,w,TrOnCurve);
103 lpnt(i).Values(anP,anu,anv,anw,anTrOnCurve);
104 if(PARAMEQUAL(u,anu)) {
105 if(PARAMEQUAL(v,anv)) {
106 if(PARAMEQUAL(w,anw)) {
107 if(anTrOnCurve==TrOnCurve) {
114 lpnt.Append(OtherPoint);
116 //================================================================================
117 void IntCurveSurface_Intersection::Append(const IntCurveSurface_IntersectionSegment& OtherSegment) {
118 lseg.Append(OtherSegment);
120 //================================================================================
121 void IntCurveSurface_Intersection::ResetFields() {
126 myIsParallel = Standard_False;
129 //================================================================================
130 void IntCurveSurface_Intersection::Dump() const {
132 Standard_Integer i,ni;
134 for(i=1;i<=ni;i++) { Point(i).Dump(); }
136 for(i=1;i<=ni;i++) { Segment(i).Dump(); }
139 std::cout<<" Intersection NotDone"<<std::endl;