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