0023948: Wrong intersection between a surface of revolution and a plane.
[occt.git] / src / TestTopOpe / TestTopOpe_VarsTopo.cxx
1 // Created on: 1996-02-05
2 // Created by: Jea Yves LEBEY
3 // Copyright (c) 1996-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 #ifdef HAVE_CONFIG_H
18 # include <config.h>
19 #endif
20 #include <TestTopOpe_VarsTopo.hxx>
21 #include <TopOpeBRepTool.hxx>
22 #ifdef HAVE_STRINGS_H
23 # include <strings.h>
24 #endif
25
26 VarsTopo::VarsTopo() : mytolarc(0.), mytoltan(0.)
27 {
28   Init();
29 }
30
31 void VarsTopo::Init()
32 {
33   myOCT = TopOpeBRepTool_APPROX;
34   myC2D = Standard_True;
35   mytol3xdef = mytol2xdef = mytol3x = mytol2x = 1.e-7;
36   myforcetoli = Standard_False;
37   myclear = Standard_True;
38   myexecmode = 0;
39   myverbmode = 0;
40 }
41
42 void VarsTopo::SetTolxDef()
43 {
44   mytol3x = mytol3xdef; 
45   mytol2x = mytol2xdef;
46 }
47
48 void VarsTopo::SetTolx(const Standard_Real tol3x, const Standard_Real tol2x)
49
50   mytol3x = tol3x;
51   mytol2x = tol2x;
52 }
53
54 void VarsTopo::GetTolx(Standard_Real& tol3x, Standard_Real& tol2x) const
55 {
56   tol3x = mytol3x;
57   tol2x = mytol2x;
58 }
59
60 void VarsTopo::SetToliDef()
61 {
62   myforcetoli = Standard_False;
63 }
64
65 void VarsTopo::SetToli(const Standard_Real tolarc,const Standard_Real toltan)
66 {
67   mytolarc = tolarc;
68   mytoltan = toltan;
69   myforcetoli = Standard_True;
70 }
71
72 void VarsTopo::GetToli(Standard_Real& tolarc, Standard_Real& toltan) const
73 {
74   tolarc = mytolarc;
75   toltan = mytoltan;
76 }
77
78 Standard_Boolean VarsTopo::GetForceToli() const
79 {
80   return myforcetoli;
81 }
82
83 void VarsTopo::SetClear(const Standard_Boolean b)
84 {
85   myclear = b;
86 }
87
88 Standard_Boolean VarsTopo::GetClear() const
89 {
90   return myclear;
91 }
92
93 void VarsTopo::SetOCT(char* noct)
94 {
95   if      (noct == NULL) return;
96   else if (!strcmp(noct,"-a")) SetOCT(TopOpeBRepTool_APPROX);
97   else if (!strcmp(noct,"-p")) SetOCT(TopOpeBRepTool_BSPLINE1);
98   else if (!strcmp(noct,"-i")) SetOCT(TopOpeBRepTool_INTERPOL);
99 }
100
101 void VarsTopo::SetOCT(const TopOpeBRepTool_OutCurveType oct)
102 {
103   myOCT = oct;
104 }
105
106 TopOpeBRepTool_OutCurveType VarsTopo::GetOCT() const
107 {
108   return myOCT;
109 }
110
111 void VarsTopo::SetC2D(char* nc2d)
112 {
113   if      (nc2d == NULL) return;  
114   else if (!strcasecmp(nc2d,"-no2d")) SetC2D(Standard_True);
115   else if (!strcasecmp(nc2d,"-2d"))   SetC2D(Standard_False);
116 }
117
118 void VarsTopo::SetC2D(const Standard_Boolean c2d)
119 {
120   myC2D = c2d;
121 }
122
123 Standard_Boolean VarsTopo::GetC2D() const
124 {
125   return myC2D;
126 }
127
128 void VarsTopo::DumpOCT(Standard_OStream& OS) const
129 {
130   if (myOCT == TopOpeBRepTool_APPROX) 
131     OS<<"section curves approximated"<<"\n";
132   if (myOCT == TopOpeBRepTool_BSPLINE1) 
133     OS<<"section curves discretizated"<<"\n";
134 }
135
136 void VarsTopo::DumpC2D(Standard_OStream& OS) const
137 {
138   if (!myC2D) {
139     OS<<"section without pcurve";  OS<<"\n";
140   }
141   else {
142     OS<<"section with pcurve";  OS<<"\n";
143   }
144 }
145
146 void VarsTopo::DumpTolx(Standard_OStream& OS) const
147 {
148   OS<<"approximation tolerances : ";
149   OS<<"(3d "<<mytol3x<<"), (2d "<<mytol2x<<")"<<"\n";
150 }
151
152 void VarsTopo::DumpToli(Standard_OStream& OS) const
153 {
154   if (myforcetoli) {
155     OS<<"intersection tolerances : ";
156     OS<<"(tolarc "<<mytolarc<<"), (toltan "<<mytoltan<<")"<<"\n";
157   }
158   else {
159     OS<<"intersection with shape tolerances"<<"\n";
160   }
161 }
162
163 void VarsTopo::DumpClear(Standard_OStream& OS) const
164 {
165   if (myclear) OS<<"clear ON"<<"\n";
166   else         OS<<"clear OFF"<<"\n";
167 }
168
169 void VarsTopo::DumpMode(Standard_OStream& OS) const
170 {
171   OS<<"execution mode : "<<myexecmode<<"\n";
172 }
173
174 void VarsTopo::DumpVerbose(Standard_OStream& OS) const
175 {
176   OS<<"verbose mode : "<<myverbmode<<"\n";
177 }
178
179 void VarsTopo::Dump(Standard_OStream& OS) const 
180 {
181   OS<<"# "; DumpOCT(OS);
182   OS<<"# "; DumpC2D(OS);
183   OS<<"# "; DumpTolx(OS);
184   OS<<"# "; DumpToli(OS);
185   OS<<"# "; DumpMode(OS);
186   OS<<"# "; DumpVerbose(OS);
187   OS<<"# "; DumpClear(OS);
188 }
189
190 void VarsTopo::SetMode(const Standard_Integer mode) {myexecmode = mode;}
191 Standard_Integer VarsTopo::GetMode() const {return myexecmode;}
192 void VarsTopo::SetVerbose(const Standard_Integer mode) {myverbmode = mode;}
193 Standard_Integer VarsTopo::GetVerbose() const {return myverbmode;}