0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / TopOpeBRep / TopOpeBRep_Hctxee2d.cxx
CommitLineData
7fd59977 1// File: TopOpeBRep_Hctxee2d.cxx
2// Created: Thu Oct 29 12:46:21 1998
3// Author: Jean Yves LEBEY
4// <jyl@langdox.paris1.matra-dtv.fr>
5
6#include <TopOpeBRep_Hctxee2d.ixx>
7#include <TopOpeBRep_define.hxx>
8#include <TopOpeBRepTool_CurveTool.hxx>
9#include <TopOpeBRepTool_ShapeTool.hxx>
10#include <TopOpeBRepTool_2d.hxx>
11#include <TopOpeBRepTool_GEOMETRY.hxx>
12#include <TopOpeBRepTool_PROJECT.hxx>
13#include <TopExp.hxx>
14#include <TopExp_Explorer.hxx>
15#include <TopAbs.hxx>
16#include <TopoDS.hxx>
17#include <BRep_Tool.hxx>
18
19#ifdef DEB
20#include <GeomTools_SurfaceSet.hxx>
21#include <GeomTools_CurveSet.hxx>
22#include <GeomTools_Curve2dSet.hxx>
23Standard_EXPORT Standard_Boolean TopOpeBRep_GettracePROEDG();
24#endif
25
26//=======================================================================
27//function : TopOpeBRep_Hctxee2d
28//purpose :
29//=======================================================================
30TopOpeBRep_Hctxee2d::TopOpeBRep_Hctxee2d()
31{
32}
33
34//=======================================================================
35//function : SetEdges
36//purpose :
37//=======================================================================
38void TopOpeBRep_Hctxee2d::SetEdges(const TopoDS_Edge& E1,const TopoDS_Edge& E2,
39 const BRepAdaptor_Surface& BAS1,
40 const BRepAdaptor_Surface& BAS2)
41{
42 const TopoDS_Face& F1 = BAS1.Face();
43 GeomAbs_SurfaceType ST1 = BAS1.GetType();
44 const TopoDS_Face& F2 = BAS2.Face();
45#ifdef DEb
46 GeomAbs_SurfaceType ST2 = BAS2.GetType();
47#endif
48
49 myEdge1 = TopoDS::Edge(E1);
50 myEdge2 = TopoDS::Edge(E2);
51
52 Standard_Real first,last,tole,tolpc;
53 gp_Pnt2d pfirst,plast;
54
55 Handle(Geom2d_Curve) PC1;
56 PC1 = FC2D_CurveOnSurface(myEdge1,F1,first,last,tolpc);
57 if (PC1.IsNull()) Standard_Failure::Raise("TopOpeBRep_Hctxee2d::SetEdges : no 2d curve");
58 myCurve1.Load(PC1);
59 BRep_Tool::UVPoints(myEdge1,F1,pfirst,plast);
60 tole = BRep_Tool::Tolerance(myEdge1);
61 myDomain1.SetValues(pfirst,first,tole,plast,last,tole);
62
63#ifdef DEB
64 Standard_Boolean trc = Standard_False;
65 if (trc) {
66 cout<<"ed1 on fa1 : {pfirst=("<<pfirst.X()<<" "<<pfirst.Y()<<"),first="<<first<<"\n";
67 cout<<" plast =("<<plast.X()<<" "<<plast.Y()<<"),last="<<last<<"}"<<endl;}
68#endif
69
70 Standard_Boolean memesfaces = F1.IsSame(F2);
71 Standard_Boolean memesupport = Standard_False;
72 TopLoc_Location L1,L2;
73 const Handle(Geom_Surface) S1 = BRep_Tool::Surface(F1,L1);
74 const Handle(Geom_Surface) S2 = BRep_Tool::Surface(F2,L2);
75 if (S1 == S2 && L1 == L2) memesupport=Standard_True;
76
77 if ( ST1 == GeomAbs_Plane || memesfaces || memesupport) {
78 Handle(Geom2d_Curve) PC2 = FC2D_CurveOnSurface(myEdge2,F1,first,last,tolpc);
79 myCurve2.Load(PC2);
80 BRep_Tool::UVPoints(myEdge2,F1,pfirst,plast);
81 tole = BRep_Tool::Tolerance(myEdge2);
82 myDomain2.SetValues(pfirst,first,tole,plast,last,tole);
83
84#ifdef DEB
85 if (trc) {
86 cout<<"ed2 on fa1 : {pfirst=("<<pfirst.X()<<" "<<pfirst.Y()<<"),first="<<first<<"\n";
87 cout<<" plast =("<<plast.X()<<" "<<plast.Y()<<"),last="<<last<<"}"<<endl;}
88#endif
89
90 }
91 else {
92
93 Handle(Geom2d_Curve) PC2on1; Handle(Geom_Curve) NC;
94 Standard_Boolean dgE2 = BRep_Tool::Degenerated(myEdge2);
95 if (dgE2) { //xpu210998 : cto900Q3
96 TopExp_Explorer exv(myEdge2,TopAbs_VERTEX);
97 const TopoDS_Vertex& v2 = TopoDS::Vertex(exv.Current());
98 gp_Pnt pt2 = BRep_Tool::Pnt(v2);
99 gp_Pnt2d uv2; Standard_Real d; Standard_Boolean ok = FUN_tool_projPonF(pt2,F1,uv2,d);
100 if (!ok) return;//nyiRaise
101 Handle(Geom_Surface) S1 = BRep_Tool::Surface(F1);
102 Standard_Boolean apex = FUN_tool_onapex(uv2,S1);
103 if (apex) {
104 TopoDS_Vertex vf,vl; TopExp::Vertices(myEdge1,vf,vl);
105 gp_Pnt ptf = BRep_Tool::Pnt(vf); Standard_Real df = pt2.Distance(ptf);
106 gp_Pnt ptl = BRep_Tool::Pnt(vl);
107#ifdef DEB
108 Standard_Real dl =
109#endif
110 pt2.Distance(ptl);
111 Standard_Real tolf = BRep_Tool::Tolerance(vf);
112#ifdef DEB
113 Standard_Real toll =
114#endif
115 BRep_Tool::Tolerance(vl);
7fd59977 116 Standard_Boolean onf = (df < tolf);
7fd59977 117 TopoDS_Vertex v1 = onf ? vf : vl;
118 TopTools_IndexedDataMapOfShapeListOfShape mapVE; TopExp::MapShapesAndAncestors(F1,TopAbs_VERTEX,TopAbs_EDGE,mapVE);
119 const TopTools_ListOfShape& Edsanc = mapVE.FindFromKey(v1);
120 TopTools_ListIteratorOfListOfShape it(Edsanc);
121 for (; it.More(); it.Next()){
122 const TopoDS_Edge& ee = TopoDS::Edge(it.Value());
123 Standard_Boolean dgee = BRep_Tool::Degenerated(ee);
124 if (!dgee) continue;
125// Standard_Real f,l;
126 PC2on1 = BRep_Tool::CurveOnSurface(ee,F1,first,last);
127 }
128 }
129 else {} // NYIxpu210998
130 } //dgE2
131 else {
132 // project curve of edge 2 on surface of face 1
133 TopLoc_Location loc ;
134 Handle(Geom_Curve) C = BRep_Tool::Curve(myEdge2,loc,first,last);
135 NC = Handle(Geom_Curve)::DownCast(C->Transformed(loc.Transformation()));
136 Standard_Real tolreached2d; PC2on1 = TopOpeBRepTool_CurveTool::MakePCurveOnFace(F1,NC,tolreached2d);
137 }
138
139 if (!PC2on1.IsNull()) {
140 myCurve2.Load(PC2on1);
141 tole = BRep_Tool::Tolerance(myEdge2);
142 PC2on1->D0(first,pfirst);
143 PC2on1->D0(last,plast);
144 myDomain2.SetValues(pfirst,first,tole,plast,last,tole);
145#ifdef DEB
146 if ( TopOpeBRep_GettracePROEDG() ) {
147 cout<<"------------ projection de curve"<<endl;
148 cout<<"--- Curve : "<<endl;GeomTools_CurveSet::PrintCurve(NC,cout);
149 cout<<"--- nouvelle PCurve : "<<endl;GeomTools_Curve2dSet::PrintCurve2d(PC2on1,cout);
150 Handle(Geom_Surface) S1 = BRep_Tool::Surface(F1);
151 cout<<"--- sur surface : "<<endl;GeomTools_SurfaceSet::PrintSurface(S1,cout);
152 cout<<endl;
153 }
154#endif
155 }
156 }
157
7fd59977 158} // SetEdges
159
160//=======================================================================
161//function : Edge
162//purpose :
163//=======================================================================
164const TopoDS_Shape& TopOpeBRep_Hctxee2d::Edge(const Standard_Integer Index) const
165{
166 if ( Index == 1 ) return myEdge1;
167 else if ( Index == 2 ) return myEdge2;
168 else Standard_Failure::Raise("TopOpeBRep_Hctxee2d::Edge");
169
170 return myEdge1;
171}
172
173//=======================================================================
174//function : Curve
175//purpose :
176//=======================================================================
177const Geom2dAdaptor_Curve& TopOpeBRep_Hctxee2d::Curve(const Standard_Integer Index) const
178{
179 if ( Index == 1 ) return myCurve1;
180 else if ( Index == 2 ) return myCurve2;
181 else Standard_Failure::Raise("TopOpeBRep_Hctxee2d::Curve");
182
183 return myCurve1;
184}
185
186//=======================================================================
187//function : Domain
188//purpose :
189//=======================================================================
190const IntRes2d_Domain& TopOpeBRep_Hctxee2d::Domain(const Standard_Integer Index) const
191{
192 if ( Index == 1 ) return myDomain1;
193 else if ( Index == 2 ) return myDomain2;
194 else Standard_Failure::Raise("TopOpeBRep_Hctxee2d::Domain");
195
196 return myDomain1;
197}