b311480e |
1 | // Created on: 1994-06-27 |
2 | // Created by: Laurent BOURESCHE |
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 | |
23 | #include <ChFiKPart_ComputeData.jxx> |
24 | #include <ChFiKPart_ComputeData_Fcts.hxx> |
25 | |
26 | #include <Precision.hxx> |
27 | #include <gp.hxx> |
28 | #include <gp_Pnt2d.hxx> |
29 | #include <gp_Dir2d.hxx> |
30 | #include <gp_Ax22d.hxx> |
31 | #include <gp_Lin2d.hxx> |
32 | #include <gp_Pnt.hxx> |
33 | #include <gp_Dir.hxx> |
34 | #include <gp_Vec.hxx> |
35 | #include <gp_Lin.hxx> |
36 | #include <gp_Ax2.hxx> |
37 | #include <gp_Ax3.hxx> |
38 | #include <gp_Pln.hxx> |
39 | |
40 | #include <ElCLib.hxx> |
41 | #include <ElSLib.hxx> |
42 | |
43 | #include <Geom2d_Line.hxx> |
44 | #include <Geom_Line.hxx> |
45 | #include <Geom2d_Circle.hxx> |
46 | #include <Geom_Circle.hxx> |
47 | #include <Geom_ToroidalSurface.hxx> |
48 | |
49 | #include <IntAna_QuadQuadGeo.hxx> |
50 | |
51 | //======================================================================= |
52 | //function : MakeRotule |
53 | //Purpose : cas plan/plan. |
54 | //======================================================================= |
55 | |
56 | Standard_Boolean ChFiKPart_MakeRotule(TopOpeBRepDS_DataStructure& DStr, |
57 | const Handle(ChFiDS_SurfData)& Data, |
58 | const gp_Pln& pl, |
59 | const gp_Pln& pl1, |
60 | const gp_Pln& pl2, |
61 | const TopAbs_Orientation opl, |
62 | const TopAbs_Orientation opl1, |
63 | const TopAbs_Orientation opl2, |
64 | const Standard_Real r, |
65 | const TopAbs_Orientation ofpl) |
66 | { |
67 | |
68 | //calcul du tore. |
69 | //--------------- |
70 | gp_Ax3 pos = pl.Position(); |
71 | gp_Dir dpl = pos.XDirection().Crossed(pos.YDirection()); |
72 | gp_Dir dfpl = dpl; |
73 | gp_Dir dplnat = dpl; |
74 | if (opl == TopAbs_REVERSED) { dpl.Reverse(); } |
75 | if (ofpl == TopAbs_REVERSED) { dfpl.Reverse(); } |
76 | pos = pl1.Position(); |
77 | gp_Dir dpl1 = pos.XDirection().Crossed(pos.YDirection()); |
78 | if (opl1 == TopAbs_REVERSED) { dpl1.Reverse(); } |
79 | pos = pl2.Position(); |
80 | gp_Dir dpl2 = pos.XDirection().Crossed(pos.YDirection()); |
81 | if (opl2 == TopAbs_REVERSED) { dpl2.Reverse(); } |
82 | |
83 | Standard_Real alpha = dpl1.Angle(dpl2); |
84 | |
85 | IntAna_QuadQuadGeo LInt (pl1,pl2,Precision::Angular(), |
86 | Precision::Confusion()); |
87 | gp_Pnt ptor,pcirc; |
88 | if (LInt.IsDone()) { |
89 | |
90 | pcirc = ElCLib::Value(ElCLib::Parameter(LInt.Line(1),pl.Location()), |
91 | LInt.Line(1)); |
92 | ptor.SetCoord(pcirc.X()+r*dpl.X(), |
93 | pcirc.Y()+r*dpl.Y(), |
94 | pcirc.Z()+r*dpl.Z()); |
95 | } |
96 | else { return Standard_False; } |
97 | |
98 | gp_Ax3 ppos(ptor,dpl.Reversed(),dpl1); |
99 | if(ppos.YDirection().Dot(dpl2) < 0.) ppos.YReverse(); |
100 | Handle(Geom_ToroidalSurface) |
101 | gtor = new Geom_ToroidalSurface(ppos,r,r); |
102 | Data->ChangeSurf(ChFiKPart_IndexSurfaceInDS(gtor,DStr)); |
103 | |
104 | //on compare l orientation du tore a celle de la face en bout. |
105 | //------------------------------------------------------------ |
106 | gp_Pnt pp; |
107 | gp_Vec du,dv; |
c6541a0c |
108 | ElSLib::TorusD1(0.,M_PI/2,ppos,r,r,pp,du,dv); |
7fd59977 |
109 | gp_Dir drot(du.Crossed(dv)); |
110 | Standard_Boolean reversecur = ( drot.Dot(dplnat) <= 0. ); |
111 | Standard_Boolean reversefil = ( drot.Dot(dfpl) <= 0. ); |
112 | if (reversefil) { Data->ChangeOrientation() = TopAbs_REVERSED; } |
113 | else { Data->ChangeOrientation() = TopAbs_FORWARD; } |
114 | |
115 | //on charge les FaceInterferences avec les pcurves et courbes 3d. |
116 | //----------------------------------------------------------------- |
117 | |
118 | //du cote du plan |
119 | //--------------- |
120 | gp_Ax2 circAx2 = ppos.Ax2(); |
121 | circAx2.SetLocation(pcirc); |
122 | Handle(Geom_Circle) GC = new Geom_Circle(circAx2,r); |
123 | Standard_Real u,v; |
124 | ElSLib::Parameters(pl,pcirc,u,v); |
125 | gp_Pnt2d p2dcirc(u,v); |
126 | gp_Dir2d dx2d(dpl1.Dot(pl.Position().XDirection()), |
127 | dpl1.Dot(pl.Position().YDirection())); |
128 | gp_Dir2d dy2d(ppos.YDirection().Dot(pl.Position().XDirection()), |
129 | ppos.YDirection().Dot(pl.Position().YDirection())); |
130 | gp_Ax22d circ2dax(p2dcirc,dx2d,dy2d); |
131 | Handle(Geom2d_Circle) GC2d = new Geom2d_Circle(circ2dax,r); |
c6541a0c |
132 | gp_Pnt2d p2dlin(0.,M_PI/2); |
7fd59977 |
133 | Handle(Geom2d_Line) GL2d = new Geom2d_Line(p2dlin,gp::DX2d()); |
134 | TopAbs_Orientation trans = TopAbs_REVERSED; |
135 | if (reversecur) trans = TopAbs_FORWARD; |
136 | Data->ChangeInterferenceOnS1(). |
137 | SetInterference(ChFiKPart_IndexCurveInDS(GC,DStr),trans,GC2d,GL2d); |
138 | |
139 | //du cote pointu |
140 | //-------------- |
141 | Handle(Geom_Curve) bid; |
142 | Handle(Geom2d_Curve) bid2d; |
c6541a0c |
143 | p2dlin.SetCoord(0.,M_PI); |
7fd59977 |
144 | Handle(Geom2d_Line) GL2dcoin = new Geom2d_Line(p2dlin,gp::DX2d()); |
145 | Data->ChangeInterferenceOnS2(). |
146 | SetInterference(ChFiKPart_IndexCurveInDS(bid,DStr),trans,bid2d,GL2dcoin); |
147 | |
148 | //et les points |
149 | //------------- |
150 | Data->ChangeVertexFirstOnS1().SetPoint(pp); |
c6541a0c |
151 | ElSLib::TorusD0(alpha,M_PI/2,ppos,r,r,pp); |
7fd59977 |
152 | Data->ChangeVertexLastOnS1().SetPoint(pp); |
153 | Data->ChangeInterferenceOnS1().SetFirstParameter(0.); |
154 | Data->ChangeInterferenceOnS1().SetLastParameter(alpha); |
155 | Data->ChangeInterferenceOnS2().SetFirstParameter(0.); |
156 | Data->ChangeInterferenceOnS2().SetLastParameter(alpha); |
157 | |
158 | return Standard_True; |
159 | } |