1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
|
#include <LocalAnalysis_CurveContinuity.ixx>
#include <LocalAnalysis_StatusErrorType.hxx>
#include <GeomLProp_CLProps.hxx>
#include <gp.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
#include <StdFail_NotDone.hxx>
/***********************************************************************/
void LocalAnalysis_CurveContinuity::CurvC0( GeomLProp_CLProps& Curv1,
GeomLProp_CLProps& Curv2)
{ myContC0= (Curv1.Value()).Distance(Curv2.Value());
}
/****************************************************************************/
void LocalAnalysis_CurveContinuity::CurvC1( GeomLProp_CLProps& Curv1,
GeomLProp_CLProps& Curv2)
{ gp_Vec V1, V2;
Standard_Real ang;
V1 = Curv1.D1();
V2 = Curv2.D1();
Standard_Real norm1,norm2;
norm1 = V1.Magnitude();
norm2 = V2.Magnitude();
if ((norm1>myepsnul)&&(norm2>myepsnul))
{ if ( norm1 >= norm2 )
{ myLambda1 = norm2 / norm1;}
else { myLambda1 = norm1 / norm2;}
ang= V1.Angle(V2);
if (ang>PI/2) myContC1=PI-ang;
else myContC1=ang;
}
else {myIsDone= Standard_False;
myErrorStatus=LocalAnalysis_NullFirstDerivative;}
}
/*********************************************************************************/
void LocalAnalysis_CurveContinuity::CurvC2(GeomLProp_CLProps& Curv1,
GeomLProp_CLProps& Curv2)
{ gp_Vec V1, V2, V12, V22;
// gp_Dir D1, D2;
Standard_Real norm1, norm2, norm12, norm22,ang;
V1 = Curv1.D1();
V2 = Curv2.D1();
V12 = Curv1.D2();
V22 = Curv2.D2();
norm1 = V1.Magnitude();
norm2 = V2.Magnitude();
norm12 = V12.Magnitude();
norm22 = V22.Magnitude();
if ((norm1>myepsnul)&&(norm2>myepsnul))
{if((norm12>myepsnul)&&(norm22>myepsnul))
{if (norm1 >= norm2 )
{ myLambda1 = norm2 / norm1;
myLambda2 = norm22 / norm12;}
else {myLambda1 = norm1 / norm2;
myLambda2 = norm12 / norm22;}
ang=V12.Angle(V22);
if (ang>PI/2) myContC2=PI-ang;
else myContC2=ang; }
else{myIsDone= Standard_False ;
myErrorStatus=LocalAnalysis_NullSecondDerivative;} }
else {myIsDone= Standard_False ;
myErrorStatus=LocalAnalysis_NullFirstDerivative;}
}
/*********************************************************************************/
void LocalAnalysis_CurveContinuity::CurvG1 ( GeomLProp_CLProps& Curv1,
GeomLProp_CLProps & Curv2)
{ gp_Dir Tang1,Tang2;
Standard_Real ang;
if (Curv1.IsTangentDefined() && Curv2.IsTangentDefined ())
{ Curv1.Tangent(Tang1);
Curv2.Tangent(Tang2);
ang=Tang1.Angle(Tang2);
if (ang>PI/2) myContG1=PI-ang;
else myContG1=ang;
}
else {myIsDone= Standard_False ;
myErrorStatus=LocalAnalysis_TangentNotDefined;}
}
/*********************************************************************************/
void LocalAnalysis_CurveContinuity::CurvG2( GeomLProp_CLProps& Curv1,
GeomLProp_CLProps & Curv2 )
{ gp_Vec V1, V2;
gp_Dir D1, D2;
Standard_Real ang;
Standard_Real epscrb= 8*myepsC0/(myMaxLon*myMaxLon);
if (Curv1.IsTangentDefined() && Curv2.IsTangentDefined())
{ myCourbC1= Curv1.Curvature();
myCourbC2 = Curv2.Curvature();
if( (Abs(myCourbC1)>epscrb)&& (Abs(myCourbC2)>epscrb))
{ V1 = Curv1.D1();
V2 = Curv2.D1();
Curv1.Normal(D1);
Curv2.Normal(D2);
ang =D1.Angle(D2);
if (ang>PI/2) myContG2=PI-ang;
else myContG2=ang;
myCourbC1= Curv1.Curvature();
myCourbC2 = Curv2.Curvature();
myG2Variation= Abs(myCourbC1-myCourbC2) / sqrt (myCourbC1* myCourbC2);}
else {myIsDone = Standard_False ;
myErrorStatus=LocalAnalysis_NormalNotDefined; }
}
else { myIsDone = Standard_False ;
myErrorStatus=LocalAnalysis_TangentNotDefined;}
}
/*********************************************************************************/
LocalAnalysis_CurveContinuity::LocalAnalysis_CurveContinuity(const Handle(Geom_Curve)& Curv1,
const Standard_Real u1, const Handle(Geom_Curve)& Curv2, const Standard_Real u2,
const GeomAbs_Shape Order,
const Standard_Real Epsnul,
const Standard_Real EpsC0,
const Standard_Real EpsC1,
const Standard_Real EpsC2,
const Standard_Real EpsG1,
const Standard_Real EpsG2,
const Standard_Real Percent,
const Standard_Real Maxlen )
{ myTypeCont = Order;
myepsnul= Epsnul;
myMaxLon=Maxlen;
myepsC0= EpsC0;
myepsC1= EpsC1;
myepsC2= EpsC2;
myepsG1= EpsG1;
myepsG2= EpsG2;
myperce=Percent;
myIsDone = Standard_True;
switch ( Order)
{ case GeomAbs_C0 : { //TypeCont=GeomAbs_C0;
GeomLProp_CLProps Curve1 ( Curv1, u1, 0, myepsnul);
GeomLProp_CLProps Curve2 ( Curv2, u2, 0, myepsnul);
CurvC0(Curve1, Curve2);}
break;
case GeomAbs_C1 : { //TypeCont=GeomAbs_C1;
GeomLProp_CLProps Curve1 ( Curv1, u1, 1, myepsnul);
GeomLProp_CLProps Curve2 ( Curv2, u2, 1, myepsnul );
CurvC0(Curve1, Curve2);
CurvC1(Curve1, Curve2);}
break;
case GeomAbs_C2 : { //TypeCont=GeomAbs_C2;
GeomLProp_CLProps Curve1 ( Curv1, u1, 2, myepsnul);
GeomLProp_CLProps Curve2 ( Curv2, u2, 2, myepsnul);
CurvC0(Curve1, Curve2);
CurvC1(Curve1, Curve2);
CurvC2(Curve1, Curve2);}
break;
case GeomAbs_G1 : { //TypeCont=GeomAbs_G1;
GeomLProp_CLProps Curve1 ( Curv1, u1, 1, myepsnul);
GeomLProp_CLProps Curve2 ( Curv2, u2, 1, myepsnul);
CurvC0(Curve1, Curve2);
CurvG1(Curve1, Curve2);}
break;
case GeomAbs_G2 : { //TypeCont=GeomAbs_G2;
GeomLProp_CLProps Curve1 ( Curv1, u1, 2, myepsnul);
GeomLProp_CLProps Curve2 ( Curv2, u2, 2, myepsnul);
CurvC0(Curve1, Curve2);
CurvG1(Curve1, Curve2);
CurvG2(Curve1, Curve2);}
break;
default : {}
}
}
/*********************************************************************************/
Standard_Boolean LocalAnalysis_CurveContinuity::IsC0() const
{
if (!myIsDone) { StdFail_NotDone::Raise();}
if (myContC0 <= myepsC0 )
return Standard_True;
else return Standard_False;
}
/*********************************************************************************/
Standard_Boolean LocalAnalysis_CurveContinuity::IsC1() const
{
if (!myIsDone) { StdFail_NotDone::Raise();}
if ( IsC0() && ( (myContC1 <= myepsC1)||(Abs(myContC1-PI)<=myepsC1)))
return Standard_True;
else return Standard_False;
}
/*********************************************************************************/
Standard_Boolean LocalAnalysis_CurveContinuity::IsC2() const
{ Standard_Real epsil1, epsil2;
if (!myIsDone) { StdFail_NotDone::Raise();}
if ( IsC1())
{ if ((myContC2 <= myepsC2)||(Abs(myContC2-PI)<=myepsC2))
{ epsil1 = 0.5*myepsC1*myepsC1*myLambda1;
epsil2 = 0.5*myepsC2*myepsC2*myLambda2;
if ( (Abs(myLambda1*myLambda1-myLambda2)) <= (epsil1*epsil1+epsil2))
return Standard_True;}
else return Standard_False;
}
return Standard_False;
}
/*********************************************************************************/
Standard_Boolean LocalAnalysis_CurveContinuity::IsG1() const
{
if (!myIsDone) { StdFail_NotDone::Raise();}
if ( IsC0() && (( myContG1 <= myepsG1||(Abs(myContG1-PI)<=myepsG1))))
return Standard_True;
else return Standard_False;
}
/*********************************************************************************/
Standard_Boolean LocalAnalysis_CurveContinuity::IsG2()const
{ Standard_Real CRBINF, CRBNUL;
Standard_Integer IETA1, IETA2;
// etat des coubures IETA. -> 0 Crbure nulle
// -> 1 Crbure finie
// -> 2 Crbure infinie
if (!myIsDone) { StdFail_NotDone::Raise();}
if ( IsG1 ())
{ CRBINF = 1/myepsC0;
CRBNUL = 8*myepsC0/(myMaxLon*myMaxLon);
if (myCourbC1 > CRBINF) IETA1=2;
else if (myCourbC1 < CRBNUL) IETA1=0;
else IETA1=1;
if (myCourbC2 > CRBINF) IETA2=2;
else if (myCourbC2 < CRBNUL) IETA2=0;
else IETA2=1;
if (IETA1 == IETA2)
{ if (IETA1 == 1)
{ Standard_Real eps= RealPart( (myContG2+myepsG2)/PI) * PI;
if (Abs( eps - myepsG2) < myepsG2)
{if (myG2Variation < myperce )
return Standard_True;
else return Standard_False;}
else return Standard_False;
}
else return Standard_True;
}
else return Standard_False;
}
else return Standard_False;
}
/*********************************************************************************/
Standard_Real LocalAnalysis_CurveContinuity::C0Value() const
{
if (!myIsDone) {StdFail_NotDone::Raise();}
return ( myContC0 );
}
/*********************************************************************************/
Standard_Real LocalAnalysis_CurveContinuity::C1Angle() const
{
if (!myIsDone) { StdFail_NotDone::Raise();}
return ( myContC1 );
}
/*********************************************************************************/
Standard_Real LocalAnalysis_CurveContinuity::C2Angle() const
{
if (!myIsDone) { StdFail_NotDone::Raise();}
return ( myContC2 );
}
/*********************************************************************************/
Standard_Real LocalAnalysis_CurveContinuity::G1Angle() const
{
if (!myIsDone) { StdFail_NotDone::Raise();}
return ( myContG1 );
}
/*********************************************************************************/
Standard_Real LocalAnalysis_CurveContinuity::G2Angle() const
{
if (!myIsDone) { StdFail_NotDone::Raise();}
return ( myContG2 );
}
/*********************************************************************************/
Standard_Real LocalAnalysis_CurveContinuity::C1Ratio() const
{
if (!myIsDone) {StdFail_NotDone::Raise();}
return ( myLambda1 );
}
/*********************************************************************************/
Standard_Real LocalAnalysis_CurveContinuity::C2Ratio() const
{
if (!myIsDone) {StdFail_NotDone::Raise();}
return ( myLambda2 );
}
/********************************************************************************/
Standard_Real LocalAnalysis_CurveContinuity::G2CurvatureVariation() const
{
if (!myIsDone) {StdFail_NotDone::Raise();}
return ( myG2Variation);
}
/********************************************************************************/
Standard_Boolean LocalAnalysis_CurveContinuity::IsDone() const
{ return ( myIsDone );
}
/*********************************************************************************/
LocalAnalysis_StatusErrorType LocalAnalysis_CurveContinuity::StatusError() const
{
return myErrorStatus;
}
/*************************************************************************/
GeomAbs_Shape LocalAnalysis_CurveContinuity::ContinuityStatus() const
{
if (!myIsDone) { StdFail_NotDone::Raise();}
return (myTypeCont);
}
/*********************************************************************************/
|