0023024: Update headers of OCCT files
[occt.git] / src / ChFiKPart / ChFiKPart_ComputeData_FilPlnPln.cxx
CommitLineData
b311480e 1// Created on: 1994-02-03
2// Created by: Isabelle GRIGNON
3// Copyright (c) 1994-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#include <ChFiKPart_ComputeData.jxx>
23#include <Precision.hxx>
24#include <gp.hxx>
25#include <gp_Pnt2d.hxx>
26#include <gp_Dir2d.hxx>
27#include <gp_Lin2d.hxx>
28#include <gp_Pnt.hxx>
29#include <gp_Dir.hxx>
30#include <gp_Vec.hxx>
31#include <gp_Lin.hxx>
32#include <gp_Ax2.hxx>
33#include <gp_Ax3.hxx>
34#include <gp_Pln.hxx>
35#include <gp_Cylinder.hxx>
36
37#include <ElCLib.hxx>
38#include <ElSLib.hxx>
39
40#include <Geom2d_Line.hxx>
41#include <Geom_Line.hxx>
42#include <Geom_CylindricalSurface.hxx>
43
44#include <IntAna_QuadQuadGeo.hxx>
45
46#include <ChFiKPart_ComputeData_Fcts.hxx>
47
48//=======================================================================
49//function : MakeFillet
50//Purpose : cas plan/plan.
51//=======================================================================
52
53Standard_Boolean ChFiKPart_MakeFillet(TopOpeBRepDS_DataStructure& DStr,
54 const Handle(ChFiDS_SurfData)& Data,
55 const gp_Pln& Pl1,
56 const gp_Pln& Pl2,
57 const TopAbs_Orientation Or1,
58 const TopAbs_Orientation Or2,
59 const Standard_Real Radius,
60 const gp_Lin& Spine,
61 const Standard_Real First,
62 const TopAbs_Orientation Of1)
63{
64
65//calcul du cylindre
66 gp_Ax3 Pos1 = Pl1.Position();
67 gp_Dir D1 = Pos1.XDirection().Crossed(Pos1.YDirection());
68 if (Or1 == TopAbs_REVERSED) { D1.Reverse(); }
69 gp_Ax3 Pos2 = Pl2.Position();
70 gp_Dir D2 = Pos2.XDirection().Crossed(Pos2.YDirection());
71 if (Or2 == TopAbs_REVERSED) { D2.Reverse(); }
72 IntAna_QuadQuadGeo LInt (Pl1,Pl2,Precision::Angular(),
73 Precision::Confusion());
74 gp_Pnt Pv;
75 if (LInt.IsDone()) {
76 //On met l origine du cylindre au point de depart fourni sur la
77 //ligne guide.
78 Pv = ElCLib::Value(ElCLib::Parameter(LInt.Line(1),
79 ElCLib::Value(First,Spine)),
80 LInt.Line(1));
81 }
82 else { return Standard_False; }
83 gp_Dir AxisCylinder = Spine.Direction();
84 Standard_Real Ang = D1.Angle(D2);
85 gp_Vec V = gp_Vec(D1)+gp_Vec(D2);
86 gp_Dir S(V);
87 gp_Pnt C;
88 Standard_Real Fac = Radius/Cos(Ang/2.);
89 C.SetCoord(Pv.X()+Fac*S.X(),Pv.Y()+Fac*S.Y(),Pv.Z()+Fac*S.Z());
90 gp_Dir xdir = D1.Reversed();
91 gp_Ax3 CylAx3(C,AxisCylinder,xdir);
92 if (CylAx3.YDirection().Dot(D2) >= 0.){ CylAx3.YReverse(); }
93 Handle(Geom_CylindricalSurface)
94 gcyl = new Geom_CylindricalSurface(CylAx3,Radius);
95 Data->ChangeSurf(ChFiKPart_IndexSurfaceInDS(gcyl,DStr));
96
97 // On regarde si l orientation du cylindre est la meme que celle
98 // des faces.
99 gp_Pnt P;
100 gp_Vec deru,derv;
101 ElSLib::CylinderD1(0.,0.,CylAx3,Radius,P,deru,derv);
102 gp_Dir norcyl(deru.Crossed(derv));
103 gp_Dir norpl = Pos1.XDirection().Crossed(Pos1.YDirection());
104 gp_Dir norface = norpl;
105 if (Of1 == TopAbs_REVERSED ) { norface.Reverse(); }
106 Standard_Boolean toreverse = ( norcyl.Dot(norface) <= 0. );
107 if (toreverse) { Data->ChangeOrientation() = TopAbs_REVERSED; }
108 else { Data->ChangeOrientation() = TopAbs_FORWARD; }
109
110 // On charge les FaceInterferences avec les pcurves et courbes 3d.
111
112 Standard_Real u,v;
113 // La face 1.
114 ElSLib::PlaneParameters(Pos1,P,u,v);
115 gp_Pnt2d p2dPln(u,v);
116 gp_Dir2d dir2dPln(AxisCylinder.Dot(Pos1.XDirection()),
117 AxisCylinder.Dot(Pos1.YDirection()));
118 gp_Lin2d lin2dPln(p2dPln,dir2dPln);
119 Handle(Geom2d_Line) GLin2dPln1 = new Geom2d_Line(lin2dPln);
120 gp_Lin linPln(P,AxisCylinder);
121 Handle(Geom_Line) GLinPln1 = new Geom_Line(linPln);
122 gp_Lin2d lin2dCyl(gp_Pnt2d(0.,0.),gp::DY2d());
123 Handle(Geom2d_Line) GLin2dCyl1 = new Geom2d_Line(lin2dCyl);
124 TopAbs_Orientation trans;
125 toreverse = ( norcyl.Dot(norpl) <= 0. );
126 if (toreverse){ trans = TopAbs_REVERSED; }
127 else { trans = TopAbs_FORWARD; }
128 Data->ChangeInterferenceOnS1().
129 SetInterference(ChFiKPart_IndexCurveInDS(GLinPln1,DStr),
130 trans,GLin2dPln1,GLin2dCyl1);
131
132 // La face 2.
133 ElSLib::CylinderD1(Ang,0.,CylAx3,Radius,P,deru,derv);
134 norcyl = deru.Crossed(derv);
135 norpl = Pos2.XDirection().Crossed(Pos2.YDirection());
136 toreverse = ( norcyl.Dot(norpl) <= 0. );
137 ElSLib::PlaneParameters(Pos2,P,u,v);
138 p2dPln.SetCoord(u,v);
139 dir2dPln.SetCoord(AxisCylinder.Dot(Pos2.XDirection()),
140 AxisCylinder.Dot(Pos2.YDirection()));
141 lin2dPln.SetLocation(p2dPln);
142 lin2dPln.SetDirection(dir2dPln);
143 Handle(Geom2d_Line) GLin2dPln2 = new Geom2d_Line(lin2dPln);
144 linPln.SetLocation(P);
145 linPln.SetDirection(AxisCylinder);
146 Handle(Geom_Line) GLinPln2 = new Geom_Line(linPln);
147 lin2dCyl.SetLocation(gp_Pnt2d(Ang,0.));
148 Handle(Geom2d_Line) GLin2dCyl2 = new Geom2d_Line(lin2dCyl);
149 if (toreverse){ trans = TopAbs_FORWARD; }
150 else { trans = TopAbs_REVERSED; }
151 Data->ChangeInterferenceOnS2().
152 SetInterference(ChFiKPart_IndexCurveInDS(GLinPln2,DStr),
153 trans,GLin2dPln2,GLin2dCyl2);
154 return Standard_True;
155}
156