Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1994-04-01 |
2 | // Created by: Laurent BUCHARD | |
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 | // |
973c2be1 | 8 | // This library is free software; you can redistribute it and / or modify it |
9 | // under the terms of the GNU Lesser General Public 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. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
b311480e | 16 | |
7fd59977 | 17 | #include <BRepClass3d_Intersector3d.ixx> |
18 | ||
19 | #include <IntCurveSurface_IntersectionPoint.hxx> | |
20 | #include <gp_Lin.hxx> | |
21 | #include <TopoDS_Face.hxx> | |
22 | #include <TopAbs.hxx> | |
23 | ||
7fd59977 | 24 | #include <IntCurveSurface_HInter.hxx> |
25 | #include <BRepAdaptor_HSurface.hxx> | |
26 | #include <Geom_Line.hxx> | |
27 | #include <gp_Pnt2d.hxx> | |
28 | #include <BRepClass_FaceClassifier.hxx> | |
29 | ||
30 | #include <GeomAdaptor_Curve.hxx> | |
31 | ||
32 | #include <GeomAdaptor_HCurve.hxx> | |
33 | #include <BRepAdaptor_HSurface.hxx> | |
34 | ||
35 | //============================================================================ | |
36 | BRepClass3d_Intersector3d::BRepClass3d_Intersector3d() | |
37 | : done(Standard_False),hasapoint(Standard_False) | |
38 | { | |
39 | } | |
40 | //============================================================================ | |
41 | void BRepClass3d_Intersector3d::Perform(const gp_Lin& L, | |
42 | const Standard_Real /*Prm*/, | |
43 | const Standard_Real Tol, | |
44 | const TopoDS_Face& Face) { | |
45 | ||
41194117 K |
46 | IntCurveSurface_HInter HICS; |
47 | BRepAdaptor_Surface surface; | |
48 | BRepClass_FaceClassifier classifier2d; | |
7fd59977 | 49 | |
50 | Handle(Geom_Line) geomline = new Geom_Line(L); | |
51 | GeomAdaptor_Curve LL(geomline); | |
52 | ||
53 | surface.Initialize(Face,Standard_True); | |
54 | ||
773f53f1 | 55 | const Standard_Boolean IsUPer = surface.IsUPeriodic(); |
56 | const Standard_Boolean IsVPer = surface.IsVPeriodic(); | |
57 | const Standard_Real uperiod = IsUPer ? surface.UPeriod() : 0.0; | |
58 | const Standard_Real vperiod = IsVPer ? surface.VPeriod() : 0.0; | |
59 | ||
60 | Standard_Real U1 = surface.FirstUParameter(); | |
61 | Standard_Real U2 = surface.LastUParameter(); | |
62 | Standard_Real V1 = surface.FirstVParameter(); | |
63 | Standard_Real V2 = surface.LastVParameter(); | |
7fd59977 | 64 | |
65 | //-- | |
66 | Handle(GeomAdaptor_HCurve) HLL = new GeomAdaptor_HCurve(LL); | |
67 | Handle(BRepAdaptor_HSurface) Hsurface = new BRepAdaptor_HSurface(surface); | |
68 | //-- | |
69 | HICS.Perform(HLL,Hsurface); | |
70 | ||
71 | W=RealLast(); | |
72 | if(HICS.IsDone()) { | |
73 | for(Standard_Integer index=HICS.NbPoints(); index>=1; index--) { | |
74 | gp_Pnt2d Puv(HICS.Point(index).U(),HICS.Point(index).V()); | |
75 | ||
76 | Standard_Integer N1 = 0; | |
77 | Standard_Integer N2 = 0; | |
78 | ||
79 | Standard_Real X = Puv.X(); | |
80 | Standard_Real Y = Puv.Y(); | |
81 | ||
82 | if(IsUPer) { | |
83 | if(X > U2) { | |
84 | N1 = RealToInt( (X - U1) / uperiod ); | |
85 | } | |
86 | if(X < U1) { | |
87 | N1 = RealToInt( (X - U2) / uperiod ); | |
88 | } | |
89 | Puv.SetX(X - uperiod * N1); | |
90 | } | |
91 | ||
92 | if(IsVPer) { | |
93 | if(Y > V2) { | |
94 | N2 = RealToInt ( (Y - V1) / vperiod ); | |
95 | } | |
96 | if(Y < V1) { | |
97 | N2 = RealToInt ( (Y - V2) / vperiod ); | |
98 | } | |
99 | Puv.SetY(Y - vperiod * N2); | |
100 | } | |
101 | ||
102 | classifier2d.Perform(Face,Puv,Tol); | |
103 | TopAbs_State currentstate = classifier2d.State(); | |
104 | if(currentstate==TopAbs_IN || currentstate==TopAbs_ON) { | |
105 | const IntCurveSurface_IntersectionPoint& HICSPoint = HICS.Point(index); | |
106 | Standard_Real HICSW = HICSPoint.W(); | |
107 | // Modified by skv - Fri Mar 4 12:07:34 2005 OCC7966 Begin | |
108 | if((W > HICSW) && (HICSW>-Tol)) { | |
109 | // if(W > HICSW) { | |
110 | // Modified by skv - Fri Mar 4 12:07:34 2005 OCC7966 End | |
111 | hasapoint = Standard_True; | |
112 | U = HICSPoint.U(); | |
113 | V = HICSPoint.V(); | |
114 | W = HICSW; | |
115 | transition = HICSPoint.Transition(); | |
116 | pnt = HICSPoint.Pnt(); | |
117 | state = currentstate; | |
118 | face = Face; | |
119 | if(Face.Orientation()==TopAbs_REVERSED) { | |
120 | if(transition == IntCurveSurface_In) | |
121 | transition = IntCurveSurface_Out; | |
122 | else | |
123 | transition = IntCurveSurface_In; | |
124 | } | |
125 | } | |
126 | } //-- classifier state is IN or ON | |
127 | done = Standard_True; | |
128 | } //-- Loop on Intersection points. | |
129 | } //-- HICS.IsDone() | |
130 | } |