b311480e |
1 | // Created on: 1994-02-24 |
2 | // Created by: Laurent BOURESCHE |
3 | // Copyright (c) 1994-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
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. |
10 | // |
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. |
13 | // |
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. |
20 | |
7fd59977 |
21 | |
22 | |
23 | #include <BRepLProp.ixx> |
24 | #include <Precision.hxx> |
25 | #include <BRepLProp_CLProps.hxx> |
26 | #include <gp_Dir.hxx> |
27 | #include <gp_Vec.hxx> |
28 | #include <TopoDS_Edge.hxx> |
29 | #include <TopAbs_Orientation.hxx> |
30 | |
31 | //======================================================================= |
32 | //function : Continuity |
33 | //purpose : |
34 | //======================================================================= |
35 | |
36 | GeomAbs_Shape BRepLProp::Continuity(const BRepAdaptor_Curve& C1, |
37 | const BRepAdaptor_Curve& C2, |
38 | const Standard_Real u1, |
39 | const Standard_Real u2, |
40 | const Standard_Real tl, |
41 | const Standard_Real ta) |
42 | { |
43 | GeomAbs_Shape cont = GeomAbs_C0; |
44 | Standard_Boolean fini = Standard_False; |
45 | gp_Vec d1,d2; |
46 | gp_Dir dir1,dir2; |
47 | GeomAbs_Shape cont1 = C1.Continuity(), cont2 = C2.Continuity(); |
48 | Standard_Integer n1 = 0, n2 = 0; |
49 | if (cont1 >= 5) n1 = 3; |
50 | else if(cont1 == 4) n1 = 2; |
51 | else if(cont1 == 2) n1 = 1; |
52 | if (cont2 >= 5) n2 = 3; |
53 | else if(cont2 == 4) n2 = 2; |
54 | else if(cont2 == 2) n2 = 1; |
55 | BRepLProp_CLProps clp1(C1,u1,n1,tl); |
56 | BRepLProp_CLProps clp2(C2,u2,n2,tl); |
57 | if(!(clp1.Value().IsEqual(clp2.Value(),tl))) { |
58 | Standard_Failure::Raise("Courbes non jointives"); |
59 | } |
60 | Standard_Integer min = Min(n1,n2); |
61 | if ( min >= 1 ) { |
62 | d1 = clp1.D1(); |
63 | d2 = clp2.D1(); |
64 | if(C1.Edge().Orientation() == TopAbs_REVERSED) d1.Reverse(); |
65 | if(C2.Edge().Orientation() == TopAbs_REVERSED) d2.Reverse(); |
66 | if(d1.IsEqual(d2,tl,ta)) { |
67 | cont = GeomAbs_C1; |
68 | } |
69 | else if(clp1.IsTangentDefined() && clp2.IsTangentDefined()){ |
70 | clp1.Tangent(dir1); |
71 | clp2.Tangent(dir2); |
72 | if(C1.Edge().Orientation() == TopAbs_REVERSED) dir1.Reverse(); |
73 | if(C2.Edge().Orientation() == TopAbs_REVERSED) dir2.Reverse(); |
74 | if(dir1.IsEqual(dir2,ta)){ |
75 | cont = GeomAbs_G1; |
76 | } |
77 | fini = Standard_True; |
78 | } |
79 | else {fini = Standard_True; } |
80 | } |
81 | if ( min >= 2 && !fini ) { |
82 | d1 = clp1.D2(); |
83 | d2 = clp2.D2(); |
84 | if(d1.IsEqual(d2,tl,ta)){ |
85 | cont = GeomAbs_C2; |
86 | } |
87 | } |
88 | const TopoDS_Edge& E1 = C1.Edge(); |
89 | const TopoDS_Edge& E2 = C2.Edge(); |
90 | if (E1.IsSame(E2) && C1.IsPeriodic() && cont >= GeomAbs_G1) |
91 | cont = GeomAbs_CN; |
92 | return cont; |
93 | } |
94 | |
95 | |
96 | //======================================================================= |
97 | //function : Continuity |
98 | //purpose : |
99 | //======================================================================= |
100 | |
101 | GeomAbs_Shape BRepLProp::Continuity(const BRepAdaptor_Curve& C1, |
102 | const BRepAdaptor_Curve& C2, |
103 | const Standard_Real u1, |
104 | const Standard_Real u2) |
105 | { |
106 | return Continuity(C1,C2,u1,u2,Precision::Confusion(),Precision::Angular()); |
107 | } |
108 | |
109 | |