0023024: Update headers of OCCT files
[occt.git] / src / BRepClass / BRepClass_Intersector.cxx
CommitLineData
b311480e 1// Created on: 1992-11-19
2// Created by: Remi LEQUETTE
3// Copyright (c) 1992-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22
23#include <BRepClass_Intersector.ixx>
24#include <BRep_Tool.hxx>
25#include <BRepAdaptor_Curve2d.hxx>
26#include <BRepAdaptor_Surface.hxx>
27#include <TopoDS_Vertex.hxx>
28#include <TopExp.hxx>
29#include <IntRes2d_Domain.hxx>
30#include <Geom2dLProp_CLProps2d.hxx>
31#include <Geom2d_Curve.hxx>
32#include <ElCLib.hxx>
33#include <Precision.hxx>
34
35#include <Geom2d_Line.hxx>
36
37#include <Geom2dInt_GInter.hxx>
38
39//=======================================================================
40//function : BRepClass_Intersector
41//purpose :
42//=======================================================================
43
44BRepClass_Intersector::BRepClass_Intersector()
45{
46}
47
48//=======================================================================
49//function : Perform
50//purpose :
51//=======================================================================
52
53void BRepClass_Intersector::Perform(const gp_Lin2d& L,
54 const Standard_Real P,
55 const Standard_Real Tol,
56 const BRepClass_Edge& E)
57{
58
59 Standard_Real pfbid,plbid;
60 if (BRep_Tool::CurveOnSurface(E.Edge(),E.Face(),pfbid,plbid).IsNull()) {
61 done = Standard_False; // !IsDone()
62 }
63 else {
64 IntRes2d_Domain DL;
65 if(P!=RealLast())
66 DL.SetValues(L.Location(),0.,Tol,ElCLib::Value(P,L),P,Tol);
67 else
68 DL.SetValues(L.Location(),0.,Tol,Standard_True);
69
70 const TopoDS_Edge& EE = E.Edge();
71 const TopoDS_Face& F = E.Face();
72 TopoDS_Vertex Vdeb, Vfin;
73 TopExp::Vertices(EE, Vdeb, Vfin);
74 BRepAdaptor_Curve2d C(EE,F);
75 Standard_Real deb = C.FirstParameter(), fin = C.LastParameter();
76 gp_Pnt2d pdeb,pfin;
77 C.D0(deb,pdeb);
78 C.D0(fin,pfin);
79 Standard_Real toldeb = 1.e-5, tolfin = 1.e-5;
80#if 0
81 // essai de calcul juste des tolerances du domaine
82 // qui ne couche pas avec les modeles pourris de
83 // styler !!
84 BRepAdaptor_Surface S(F);
85 gp_Vec2d vdeb,vfin;
86 C.D1(deb,pdeb,vdeb);
87 C.D1(fin,pfin,vfin);
88 gp_Pnt P; gp_Vec DU, DV;
89 S.D1(pdeb.X(),pdeb.Y(),P,DU,DV);
90 Standard_Real scaldeb = (vdeb.X()*DU + vdeb.Y()*DV).Magnitude();
91 scaldeb = Max(scaldeb, 1.e-5);
92 toldeb = BRep_Tool::Tolerance(Vdeb)/scaldeb;
93 S.D1(pfin.X(),pfin.Y(),P,DU,DV);
94 Standard_Real scalfin = (vfin.X()*DU + vfin.Y()*DV).Magnitude();
95 scalfin = Max(scalfin, 1.e-5);
96 tolfin = BRep_Tool::Tolerance(Vfin)/scalfin;
97#endif
98
99 IntRes2d_Domain DE(pdeb,deb,toldeb,pfin,fin,tolfin);
100 // temporary periodic domain
101 if (C.Curve()->IsPeriodic()) {
102 DE.SetEquivalentParameters(C.FirstParameter(),
103 C.FirstParameter() +
104 C.Curve()->LastParameter() -
105 C.Curve()->FirstParameter());
106 }
107
108 Handle(Geom2d_Line) GL= new Geom2d_Line(L);
109 Geom2dAdaptor_Curve CGA(GL);
110 Geom2dInt_GInter Inter(CGA,DL,C,DE,
111 Precision::PConfusion(),
112 Precision::PIntersection());
113 this->SetValues(Inter);
114 }
115}
116
117//=======================================================================
118//function : LocalGeometry
119//purpose :
120//=======================================================================
121
122void BRepClass_Intersector::LocalGeometry(const BRepClass_Edge& E,
123 const Standard_Real U,
124 gp_Dir2d& Tang,
125 gp_Dir2d& Norm,
126 Standard_Real& C) const
127{
128 Standard_Real f,l;
129 Geom2dLProp_CLProps2d Prop(BRep_Tool::CurveOnSurface(E.Edge(),E.Face(),f,l),
130 U,2,Precision::PConfusion());
131 Prop.Tangent(Tang);
132 C = Prop.Curvature();
133 if (C > Precision::PConfusion())
134 Prop.Normal(Norm);
135 else
136 Norm.SetCoord(Tang.Y(),-Tang.X());
137}
138
139
140
141
142