0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / IntCurveSurface / IntCurveSurface_Intersection.cxx
CommitLineData
b311480e 1// Created on: 1993-04-16
2// Created by: Laurent BUCHARD
3// Copyright (c) 1993-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17
42cf5bc1 18#include <IntCurveSurface_Intersection.hxx>
7fd59977 19#include <IntCurveSurface_IntersectionPoint.hxx>
20#include <IntCurveSurface_IntersectionSegment.hxx>
21#include <IntCurveSurface_TransitionOnCurve.hxx>
42cf5bc1 22#include <StdFail_NotDone.hxx>
7fd59977 23
24#define PARAMEQUAL(a,b) (Abs((a)-(b))< (1e-8))
25
26//================================================================================
f84edf58 27IntCurveSurface_Intersection::IntCurveSurface_Intersection():
28done(Standard_False),
29myIsParallel(Standard_False)
30{
7fd59977 31}
32//================================================================================
33Standard_Boolean IntCurveSurface_Intersection::IsDone() const { return(done); }
34//================================================================================
f84edf58 35Standard_Boolean IntCurveSurface_Intersection::IsParallel() const
36{
37 return(myIsParallel);
38}
39//================================================================================
7fd59977 40Standard_Integer IntCurveSurface_Intersection::NbPoints() const {
9775fa61 41 if (!done) {throw StdFail_NotDone();}
7fd59977 42 return lpnt.Length();
43}
44//================================================================================
45Standard_Integer IntCurveSurface_Intersection::NbSegments() const {
9775fa61 46 if (!done) {throw StdFail_NotDone();}
7fd59977 47 return lseg.Length();
48}
49//================================================================================
50const IntCurveSurface_IntersectionPoint& IntCurveSurface_Intersection::Point( const Standard_Integer N) const {
9775fa61 51 if (!done) {throw StdFail_NotDone();}
7fd59977 52 return lpnt.Value(N);
53}
54//================================================================================
55const IntCurveSurface_IntersectionSegment& IntCurveSurface_Intersection::Segment( const Standard_Integer N) const {
9775fa61 56 if (!done) {throw StdFail_NotDone();}
7fd59977 57 return lseg.Value(N);
58}
59//================================================================================
60void IntCurveSurface_Intersection::SetValues(const IntCurveSurface_Intersection& Other) {
61 if(Other.done) {
62 lseg.Clear();
63 lpnt.Clear();
64 Standard_Integer N = Other.lpnt.Length();
65 Standard_Integer i ;
66 for( i=1; i<= N ; i++) {
67 lpnt.Append(Other.lpnt.Value(i));
68 }
69 N = Other.lseg.Length();
70 for(i=1; i<= N ; i++) {
71 lseg.Append(Other.lseg.Value(i));
72 }
73 done=Standard_True;
74 }
75 else {
76 done=Standard_False;
77 }
78}
79//================================================================================
80void IntCurveSurface_Intersection::Append(const IntCurveSurface_Intersection& Other,
81// const Standard_Real a,
82 const Standard_Real ,
83// const Standard_Real b)
84 const Standard_Real )
85{
86 Standard_Integer i,ni;
87 if(Other.done) {
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)); }
92 }
93}
94//================================================================================
95void 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;
99 gp_Pnt P,anP;
100 ni = lpnt.Length();
101 for(i=1;i<=ni;i++) {
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) {
108 return;
109 }
110 }
111 }
112 }
113 }
114 lpnt.Append(OtherPoint);
115}
116//================================================================================
117void IntCurveSurface_Intersection::Append(const IntCurveSurface_IntersectionSegment& OtherSegment) {
118 lseg.Append(OtherSegment);
119}
120//================================================================================
121void IntCurveSurface_Intersection::ResetFields() {
122 if(done) {
123 lseg.Clear();
124 lpnt.Clear();
125 done=Standard_False;
f84edf58 126 myIsParallel = Standard_False;
7fd59977 127 }
128}
129//================================================================================
130void IntCurveSurface_Intersection::Dump() const {
131 if(done) {
132 Standard_Integer i,ni;
133 ni = lpnt.Length();
134 for(i=1;i<=ni;i++) { Point(i).Dump(); }
135 ni = lseg.Length();
136 for(i=1;i<=ni;i++) { Segment(i).Dump(); }
137 }
138 else {
04232180 139 std::cout<<" Intersection NotDone"<<std::endl;
7fd59977 140 }
141}