1 // Created on: 1994-02-23
2 // Created by: Laurent BOURESCHE
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Geom_BSplineCurve.hxx>
19 #include <Geom_Curve.hxx>
20 #include <Geom_TrimmedCurve.hxx>
21 #include <GeomAbs_Shape.hxx>
22 #include <GeomLProp.hxx>
23 #include <GeomLProp_CLProps.hxx>
26 #include <Precision.hxx>
28 static Standard_Integer GeomAbsToInteger(const GeomAbs_Shape gcont)
30 Standard_Integer cont=0 ;
56 //=======================================================================
57 //function : Continuity
59 //=======================================================================
61 GeomAbs_Shape GeomLProp::Continuity(const Handle(Geom_Curve)& C1,
62 const Handle(Geom_Curve)& C2,
63 const Standard_Real u1,
64 const Standard_Real u2,
65 const Standard_Boolean r1,
66 const Standard_Boolean r2,
67 const Standard_Real tl,
68 const Standard_Real ta)
70 GeomAbs_Shape cont = GeomAbs_C0;
71 Standard_Integer index1,
73 Standard_Real tolerance ;
74 Standard_Boolean fini = Standard_False;
77 Standard_Integer cont1, cont2 ;
78 GeomAbs_Shape gcont1 = C1->Continuity(), gcont2 = C2->Continuity();
79 cont1 = GeomAbsToInteger(gcont1) ;
80 cont2 = GeomAbsToInteger(gcont2) ;
82 Handle(Geom_Curve) aCurve1 = C1 ;
83 Handle(Geom_Curve) aCurve2 = C2 ;
84 if (C1->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))){
85 Handle(Geom_TrimmedCurve) aTrimmed =
86 Handle(Geom_TrimmedCurve) ::DownCast(aCurve1) ;
87 aCurve1 = aTrimmed->BasisCurve() ;
89 if (C2->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))){
90 Handle(Geom_TrimmedCurve) aTrimmed =
91 Handle(Geom_TrimmedCurve) ::DownCast(aCurve2) ;
92 aCurve2 = aTrimmed->BasisCurve() ;
94 if (aCurve1->IsKind(STANDARD_TYPE(Geom_BSplineCurve))){
95 Handle(Geom_BSplineCurve) BSplineCurve =
96 Handle(Geom_BSplineCurve)::DownCast(aCurve1) ;
97 BSplineCurve->Resolution(tl,
99 BSplineCurve->LocateU(
105 if (index1 > 1 && index2 < BSplineCurve->NbKnots() && index1 == index2) {
106 cont1 = BSplineCurve->Degree() - BSplineCurve->Multiplicity(index1) ;
112 if (aCurve2->IsKind(STANDARD_TYPE(Geom_BSplineCurve))){
113 Handle(Geom_BSplineCurve) BSplineCurve =
114 Handle(Geom_BSplineCurve)::DownCast(aCurve2) ;
115 BSplineCurve->Resolution(tl,
117 BSplineCurve->LocateU(
123 if (index1 > 1 && index2 < BSplineCurve->NbKnots() && index1 == index2) {
124 cont2 = BSplineCurve->Degree() - BSplineCurve->Multiplicity(index1) ;
130 Standard_Integer n1 = 0, n2 = 0;
131 if (cont1 >= 5) n1 = 3;
132 else if(cont1 == 4) n1 = 2;
133 else if(cont1 == 2) n1 = 1;
134 if (cont2 >= 5) n2 = 3;
135 else if(cont2 == 4) n2 = 2;
136 else if(cont2 == 2) n2 = 1;
137 GeomLProp_CLProps clp1(C1,u1,n1,tl);
138 GeomLProp_CLProps clp2(C2,u2,n2,tl);
139 if(!(clp1.Value().IsEqual(clp2.Value(),tl))) {
140 throw Standard_Failure("Courbes non jointives");
142 Standard_Integer min = Min(n1,n2);
148 if(d1.IsEqual(d2,tl,ta)) {
151 else if(clp1.IsTangentDefined() && clp2.IsTangentDefined()){
154 if(r1) dir1.Reverse();
155 if(r2) dir2.Reverse();
156 if(dir1.IsEqual(dir2,ta)){
159 fini = Standard_True;
161 else {fini = Standard_True; }
163 if ( min >= 2 && !fini ) {
166 if(d1.IsEqual(d2,tl,ta)){
174 //=======================================================================
175 //function : Continuity
177 //=======================================================================
179 GeomAbs_Shape GeomLProp::Continuity(const Handle(Geom_Curve)& C1,
180 const Handle(Geom_Curve)& C2,
181 const Standard_Real u1,
182 const Standard_Real u2,
183 const Standard_Boolean r1,
184 const Standard_Boolean r2)
186 return Continuity(C1,C2,u1,u2,r1,r2,
187 Precision::Confusion(),Precision::Angular());