7fd59977 |
1 | // File: BRepClass_Intersector.cxx |
2 | // Created: Thu Nov 19 15:04:21 1992 |
3 | // Author: Remi LEQUETTE |
4 | // <rle@phylox> |
5 | |
6 | |
7 | #include <BRepClass_Intersector.ixx> |
8 | #include <BRep_Tool.hxx> |
9 | #include <BRepAdaptor_Curve2d.hxx> |
10 | #include <BRepAdaptor_Surface.hxx> |
11 | #include <TopoDS_Vertex.hxx> |
12 | #include <TopExp.hxx> |
13 | #include <IntRes2d_Domain.hxx> |
14 | #include <Geom2dLProp_CLProps2d.hxx> |
15 | #include <Geom2d_Curve.hxx> |
16 | #include <ElCLib.hxx> |
17 | #include <Precision.hxx> |
18 | |
19 | #include <Geom2d_Line.hxx> |
20 | |
21 | #include <Geom2dInt_GInter.hxx> |
22 | |
23 | //======================================================================= |
24 | //function : BRepClass_Intersector |
25 | //purpose : |
26 | //======================================================================= |
27 | |
28 | BRepClass_Intersector::BRepClass_Intersector() |
29 | { |
30 | } |
31 | |
32 | //======================================================================= |
33 | //function : Perform |
34 | //purpose : |
35 | //======================================================================= |
36 | |
37 | void BRepClass_Intersector::Perform(const gp_Lin2d& L, |
38 | const Standard_Real P, |
39 | const Standard_Real Tol, |
40 | const BRepClass_Edge& E) |
41 | { |
42 | |
43 | Standard_Real pfbid,plbid; |
44 | if (BRep_Tool::CurveOnSurface(E.Edge(),E.Face(),pfbid,plbid).IsNull()) { |
45 | done = Standard_False; // !IsDone() |
46 | } |
47 | else { |
48 | IntRes2d_Domain DL; |
49 | if(P!=RealLast()) |
50 | DL.SetValues(L.Location(),0.,Tol,ElCLib::Value(P,L),P,Tol); |
51 | else |
52 | DL.SetValues(L.Location(),0.,Tol,Standard_True); |
53 | |
54 | const TopoDS_Edge& EE = E.Edge(); |
55 | const TopoDS_Face& F = E.Face(); |
56 | TopoDS_Vertex Vdeb, Vfin; |
57 | TopExp::Vertices(EE, Vdeb, Vfin); |
58 | BRepAdaptor_Curve2d C(EE,F); |
59 | Standard_Real deb = C.FirstParameter(), fin = C.LastParameter(); |
60 | gp_Pnt2d pdeb,pfin; |
61 | C.D0(deb,pdeb); |
62 | C.D0(fin,pfin); |
63 | Standard_Real toldeb = 1.e-5, tolfin = 1.e-5; |
64 | #if 0 |
65 | // essai de calcul juste des tolerances du domaine |
66 | // qui ne couche pas avec les modeles pourris de |
67 | // styler !! |
68 | BRepAdaptor_Surface S(F); |
69 | gp_Vec2d vdeb,vfin; |
70 | C.D1(deb,pdeb,vdeb); |
71 | C.D1(fin,pfin,vfin); |
72 | gp_Pnt P; gp_Vec DU, DV; |
73 | S.D1(pdeb.X(),pdeb.Y(),P,DU,DV); |
74 | Standard_Real scaldeb = (vdeb.X()*DU + vdeb.Y()*DV).Magnitude(); |
75 | scaldeb = Max(scaldeb, 1.e-5); |
76 | toldeb = BRep_Tool::Tolerance(Vdeb)/scaldeb; |
77 | S.D1(pfin.X(),pfin.Y(),P,DU,DV); |
78 | Standard_Real scalfin = (vfin.X()*DU + vfin.Y()*DV).Magnitude(); |
79 | scalfin = Max(scalfin, 1.e-5); |
80 | tolfin = BRep_Tool::Tolerance(Vfin)/scalfin; |
81 | #endif |
82 | |
83 | IntRes2d_Domain DE(pdeb,deb,toldeb,pfin,fin,tolfin); |
84 | // temporary periodic domain |
85 | if (C.Curve()->IsPeriodic()) { |
86 | DE.SetEquivalentParameters(C.FirstParameter(), |
87 | C.FirstParameter() + |
88 | C.Curve()->LastParameter() - |
89 | C.Curve()->FirstParameter()); |
90 | } |
91 | |
92 | Handle(Geom2d_Line) GL= new Geom2d_Line(L); |
93 | Geom2dAdaptor_Curve CGA(GL); |
94 | Geom2dInt_GInter Inter(CGA,DL,C,DE, |
95 | Precision::PConfusion(), |
96 | Precision::PIntersection()); |
97 | this->SetValues(Inter); |
98 | } |
99 | } |
100 | |
101 | //======================================================================= |
102 | //function : LocalGeometry |
103 | //purpose : |
104 | //======================================================================= |
105 | |
106 | void BRepClass_Intersector::LocalGeometry(const BRepClass_Edge& E, |
107 | const Standard_Real U, |
108 | gp_Dir2d& Tang, |
109 | gp_Dir2d& Norm, |
110 | Standard_Real& C) const |
111 | { |
112 | Standard_Real f,l; |
113 | Geom2dLProp_CLProps2d Prop(BRep_Tool::CurveOnSurface(E.Edge(),E.Face(),f,l), |
114 | U,2,Precision::PConfusion()); |
115 | Prop.Tangent(Tang); |
116 | C = Prop.Curvature(); |
117 | if (C > Precision::PConfusion()) |
118 | Prop.Normal(Norm); |
119 | else |
120 | Norm.SetCoord(Tang.Y(),-Tang.X()); |
121 | } |
122 | |
123 | |
124 | |
125 | |
126 | |