1 // Created on: 1994-06-27
2 // Created by: Laurent BOURESCHE
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Adaptor3d_HSurface.hxx>
19 #include <ChFiDS_Spine.hxx>
20 #include <ChFiDS_SurfData.hxx>
21 #include <ChFiKPart_ComputeData.hxx>
22 #include <ChFiKPart_ComputeData_Fcts.hxx>
25 #include <Geom2d_Circle.hxx>
26 #include <Geom2d_Line.hxx>
27 #include <Geom_Circle.hxx>
28 #include <Geom_Line.hxx>
29 #include <Geom_ToroidalSurface.hxx>
33 #include <gp_Ax22d.hxx>
35 #include <gp_Dir2d.hxx>
37 #include <gp_Lin2d.hxx>
40 #include <gp_Pnt2d.hxx>
42 #include <IntAna_QuadQuadGeo.hxx>
43 #include <Precision.hxx>
44 #include <TopOpeBRepDS_DataStructure.hxx>
46 //=======================================================================
47 //function : MakeRotule
48 //Purpose : cas plan/plan.
49 //=======================================================================
50 Standard_Boolean ChFiKPart_MakeRotule(TopOpeBRepDS_DataStructure& DStr,
51 const Handle(ChFiDS_SurfData)& Data,
55 const TopAbs_Orientation opl,
56 const TopAbs_Orientation opl1,
57 const TopAbs_Orientation opl2,
58 const Standard_Real r,
59 const TopAbs_Orientation ofpl)
64 gp_Ax3 pos = pl.Position();
65 gp_Dir dpl = pos.XDirection().Crossed(pos.YDirection());
68 if (opl == TopAbs_REVERSED) { dpl.Reverse(); }
69 if (ofpl == TopAbs_REVERSED) { dfpl.Reverse(); }
71 gp_Dir dpl1 = pos.XDirection().Crossed(pos.YDirection());
72 if (opl1 == TopAbs_REVERSED) { dpl1.Reverse(); }
74 gp_Dir dpl2 = pos.XDirection().Crossed(pos.YDirection());
75 if (opl2 == TopAbs_REVERSED) { dpl2.Reverse(); }
77 Standard_Real alpha = dpl1.Angle(dpl2);
79 IntAna_QuadQuadGeo LInt (pl1,pl2,Precision::Angular(),
80 Precision::Confusion());
84 pcirc = ElCLib::Value(ElCLib::Parameter(LInt.Line(1),pl.Location()),
86 ptor.SetCoord(pcirc.X()+r*dpl.X(),
90 else { return Standard_False; }
92 gp_Ax3 ppos(ptor,dpl.Reversed(),dpl1);
93 if(ppos.YDirection().Dot(dpl2) < 0.) ppos.YReverse();
94 Handle(Geom_ToroidalSurface)
95 gtor = new Geom_ToroidalSurface(ppos,r,r);
96 Data->ChangeSurf(ChFiKPart_IndexSurfaceInDS(gtor,DStr));
98 //on compare l orientation du tore a celle de la face en bout.
99 //------------------------------------------------------------
102 ElSLib::TorusD1(0.,M_PI/2,ppos,r,r,pp,du,dv);
103 gp_Dir drot(du.Crossed(dv));
104 Standard_Boolean reversecur = ( drot.Dot(dplnat) <= 0. );
105 Standard_Boolean reversefil = ( drot.Dot(dfpl) <= 0. );
106 if (reversefil) { Data->ChangeOrientation() = TopAbs_REVERSED; }
107 else { Data->ChangeOrientation() = TopAbs_FORWARD; }
109 //on charge les FaceInterferences avec les pcurves et courbes 3d.
110 //-----------------------------------------------------------------
114 gp_Ax2 circAx2 = ppos.Ax2();
115 circAx2.SetLocation(pcirc);
116 Handle(Geom_Circle) GC = new Geom_Circle(circAx2,r);
118 ElSLib::Parameters(pl,pcirc,u,v);
119 gp_Pnt2d p2dcirc(u,v);
120 gp_Dir2d dx2d(dpl1.Dot(pl.Position().XDirection()),
121 dpl1.Dot(pl.Position().YDirection()));
122 gp_Dir2d dy2d(ppos.YDirection().Dot(pl.Position().XDirection()),
123 ppos.YDirection().Dot(pl.Position().YDirection()));
124 gp_Ax22d circ2dax(p2dcirc,dx2d,dy2d);
125 Handle(Geom2d_Circle) GC2d = new Geom2d_Circle(circ2dax,r);
126 gp_Pnt2d p2dlin(0.,M_PI/2);
127 Handle(Geom2d_Line) GL2d = new Geom2d_Line(p2dlin,gp::DX2d());
128 TopAbs_Orientation trans = TopAbs_REVERSED;
129 if (reversecur) trans = TopAbs_FORWARD;
130 Data->ChangeInterferenceOnS1().
131 SetInterference(ChFiKPart_IndexCurveInDS(GC,DStr),trans,GC2d,GL2d);
135 Handle(Geom_Curve) bid;
136 Handle(Geom2d_Curve) bid2d;
137 p2dlin.SetCoord(0.,M_PI);
138 Handle(Geom2d_Line) GL2dcoin = new Geom2d_Line(p2dlin,gp::DX2d());
139 Data->ChangeInterferenceOnS2().
140 SetInterference(ChFiKPart_IndexCurveInDS(bid,DStr),trans,bid2d,GL2dcoin);
144 Data->ChangeVertexFirstOnS1().SetPoint(pp);
145 ElSLib::TorusD0(alpha,M_PI/2,ppos,r,r,pp);
146 Data->ChangeVertexLastOnS1().SetPoint(pp);
147 Data->ChangeInterferenceOnS1().SetFirstParameter(0.);
148 Data->ChangeInterferenceOnS1().SetLastParameter(alpha);
149 Data->ChangeInterferenceOnS2().SetFirstParameter(0.);
150 Data->ChangeInterferenceOnS2().SetLastParameter(alpha);
152 return Standard_True;