b311480e |
1 | // Created on: 1994-03-23 |
2 | // Created by: Jean Marc LACHAUME |
3 | // Copyright (c) 1994-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | #include <Geom2dHatch_Intersector.ixx> |
18 | #include <ElCLib.hxx> |
19 | #include <Geom2d_Line.hxx> |
20 | #include <Precision.hxx> |
21 | #include <Geom2dLProp_CLProps2d.hxx> |
22 | |
23 | |
24 | //======================================================================= |
25 | //function : Geom2dHatch_Intersector |
26 | //purpose : |
27 | //======================================================================= |
28 | |
29 | Geom2dHatch_Intersector::Geom2dHatch_Intersector() : |
30 | myConfusionTolerance(0.0), |
31 | myTangencyTolerance(0.0) |
32 | { |
33 | } |
34 | |
35 | //======================================================================= |
36 | //function : Perform |
37 | //purpose : |
38 | //======================================================================= |
39 | |
40 | void Geom2dHatch_Intersector::Perform(const gp_Lin2d& L, |
41 | const Standard_Real P, |
42 | const Standard_Real Tol, |
43 | const Geom2dAdaptor_Curve& C) |
44 | { |
45 | |
46 | //Standard_Real pfbid,plbid; |
47 | IntRes2d_Domain DL; |
48 | if(P!=RealLast()) |
49 | DL.SetValues(L.Location(),0.,Tol,ElCLib::Value(P,L),P,Tol); |
50 | else |
51 | DL.SetValues(L.Location(),0.,Tol,Standard_True); |
52 | |
53 | IntRes2d_Domain DE(C.Value(C.FirstParameter()), |
54 | C.FirstParameter(),Precision::PIntersection(), |
55 | C.Value(C.LastParameter()), |
56 | C.LastParameter(),Precision::PIntersection()); |
57 | |
58 | Handle(Geom2d_Line) GL= new Geom2d_Line(L); |
59 | Geom2dAdaptor_Curve CGA(GL); |
60 | void *ptrpoureviterlesproblemesdeconst = (void *)(&C); |
61 | |
62 | Geom2dInt_GInter Inter(CGA, |
63 | DL, |
64 | *((Geom2dAdaptor_Curve *)ptrpoureviterlesproblemesdeconst), |
65 | DE, |
66 | Precision::PConfusion(), |
67 | Precision::PIntersection()); |
68 | this->SetValues(Inter); |
69 | } |
70 | |
71 | //======================================================================= |
72 | //function : LocalGeometry |
73 | //purpose : |
74 | //======================================================================= |
75 | |
76 | void Geom2dHatch_Intersector::LocalGeometry(const Geom2dAdaptor_Curve& E, |
77 | const Standard_Real U, |
78 | gp_Dir2d& Tang, |
79 | gp_Dir2d& Norm, |
80 | Standard_Real& C) const |
81 | { |
82 | //Standard_Real f,l; |
83 | Geom2dLProp_CLProps2d Prop(E.Curve(),U,2,Precision::PConfusion()); |
84 | |
85 | if(!Prop.IsTangentDefined()) return; |
86 | |
87 | Prop.Tangent(Tang); |
88 | C = Prop.Curvature(); |
89 | if (C > Precision::PConfusion() && C<RealLast()) |
90 | Prop.Normal(Norm); |
91 | else |
92 | Norm.SetCoord(Tang.Y(),-Tang.X()); |
93 | } |
94 | |
95 | |
96 | |
97 | |
98 | |
99 | |