0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / Geom2dHatch / Geom2dHatch_Intersector.cxx
CommitLineData
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
42cf5bc1 17
7fd59977 18#include <ElCLib.hxx>
19#include <Geom2d_Line.hxx>
42cf5bc1 20#include <Geom2dAdaptor_Curve.hxx>
21#include <Geom2dHatch_Intersector.hxx>
7fd59977 22#include <Geom2dLProp_CLProps2d.hxx>
42cf5bc1 23#include <gp_Dir2d.hxx>
24#include <gp_Lin2d.hxx>
25#include <Precision.hxx>
7fd59977 26
27//=======================================================================
28//function : Geom2dHatch_Intersector
29//purpose :
30//=======================================================================
7fd59977 31Geom2dHatch_Intersector::Geom2dHatch_Intersector() :
32myConfusionTolerance(0.0),
33myTangencyTolerance(0.0)
34{
35}
36
37//=======================================================================
38//function : Perform
39//purpose :
40//=======================================================================
41
42void Geom2dHatch_Intersector::Perform(const gp_Lin2d& L,
43 const Standard_Real P,
44 const Standard_Real Tol,
45 const Geom2dAdaptor_Curve& C)
46{
47
48//Standard_Real pfbid,plbid;
49 IntRes2d_Domain DL;
50 if(P!=RealLast())
51 DL.SetValues(L.Location(),0.,Tol,ElCLib::Value(P,L),P,Tol);
52 else
53 DL.SetValues(L.Location(),0.,Tol,Standard_True);
54
55 IntRes2d_Domain DE(C.Value(C.FirstParameter()),
56 C.FirstParameter(),Precision::PIntersection(),
57 C.Value(C.LastParameter()),
58 C.LastParameter(),Precision::PIntersection());
59
60 Handle(Geom2d_Line) GL= new Geom2d_Line(L);
61 Geom2dAdaptor_Curve CGA(GL);
62 void *ptrpoureviterlesproblemesdeconst = (void *)(&C);
63
64 Geom2dInt_GInter Inter(CGA,
65 DL,
66 *((Geom2dAdaptor_Curve *)ptrpoureviterlesproblemesdeconst),
67 DE,
68 Precision::PConfusion(),
69 Precision::PIntersection());
70 this->SetValues(Inter);
71}
72
73//=======================================================================
74//function : LocalGeometry
75//purpose :
76//=======================================================================
77
78void Geom2dHatch_Intersector::LocalGeometry(const Geom2dAdaptor_Curve& E,
79 const Standard_Real U,
80 gp_Dir2d& Tang,
81 gp_Dir2d& Norm,
82 Standard_Real& C) const
83{
84 //Standard_Real f,l;
85 Geom2dLProp_CLProps2d Prop(E.Curve(),U,2,Precision::PConfusion());
86
87 if(!Prop.IsTangentDefined()) return;
88
89 Prop.Tangent(Tang);
90 C = Prop.Curvature();
91 if (C > Precision::PConfusion() && C<RealLast())
92 Prop.Normal(Norm);
93 else
94 Norm.SetCoord(Tang.Y(),-Tang.X());
95}
96
97
98
99
100
101