0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / TopOpeBRepTool / TopOpeBRepTool_closing.cxx
CommitLineData
7fd59977 1// File: TopOpeBRepTool_closing.cxx
2// Created: Tue Nov 24 14:08:03 1998
3// Author: Xuan PHAM PHU
4// <xpu@poulopox.paris1.matra-dtv.fr>
5
6#include <TopOpeBRepTool_define.hxx>
7#include <TopOpeBRepTool_EXPORT.hxx>
8#include <TopOpeBRepTool_TOOL.hxx>
9#include <TopOpeBRepTool_2d.hxx>
10#include <Geom2d_Curve.hxx>
11#include <gp_Vec2d.hxx>
12#include <TopExp_Explorer.hxx>
13#include <BRep_Tool.hxx>
14#include <TopoDS.hxx>
15#include <TopExp.hxx>
16
17//Standard_IMPORT void FUN_tool_ttranslate(const gp_Vec2d& tvector, const TopoDS_Face& fF, TopoDS_Edge& fyE);
18
19Standard_EXPORT Standard_Boolean FUN_tool_UVonclosing(const TopoDS_Edge& E, const TopoDS_Face& F, const Standard_Boolean onU,
20 const Standard_Real xfirst, const Standard_Real xperiod,
21 const Standard_Real toluv)
22// purpose : returns TRUE if E has UVrep on F, on closing UVrep
23// prequesitory : F is x-closed, its x-2drep describes [xfirst,xfirst+xperiod]
24// if (onU=1), F is u-closed
25{
26 // E :
27 Standard_Real f,l,tol; Handle(Geom2d_Curve) PC = FC2D_CurveOnSurface(E,F,f,l,tol);
28 Standard_Boolean isou,isov; gp_Pnt2d o2d; gp_Dir2d d2d;
29 Standard_Boolean isouv = TopOpeBRepTool_TOOL::UVISO(PC,isou,isov,d2d,o2d);
30 if (!isouv) return Standard_False;
31
32 Standard_Boolean onX = (onU && isou) || ((!onU) && isov);
33 if (!onX) return Standard_False;
34
35 Standard_Real dxx=0;
36 if (onU) dxx = Abs(o2d.X()-xfirst);
37 else dxx = Abs(o2d.Y()-xfirst);
38
39 Standard_Boolean onclo = (dxx < toluv);
40 onclo = onclo || (Abs(xperiod-dxx) < toluv);
41 return onclo;
42}//FUN_UVonclosing
43
44/*Standard_EXPORT Standard_Boolean FUN_tool_getEclo(const TopoDS_Face& F, TopoDS_Edge& Eclo)
45// purpose : get Eclo / closing edge of F
46// rep(Eclo,F) is x-iso, parx=xmin/xmax
47{
48 Eclo.Nullify();
49 TopExp_Explorer ex(F, TopAbs_EDGE);
50 for (; ex.More(); ex.Next()){
51 const TopoDS_Edge& e = TopoDS::Edge(ex.Current());
52 Standard_Boolean clo = BRep_Tool::IsClosed(e,F);
53 if (clo) {Eclo=e; return Standard_True;}
54 }
55 return Standard_False;
56}*/
57
58Standard_EXPORT Standard_Boolean FUN_tool_correctCLO(TopoDS_Edge& E, const TopoDS_Face& F)
59// purpose : correcting "closing edges", returns Standard_True if E pcurve
60// is translated
61{
62 TopoDS_Shape aLocalShape = F.Oriented(TopAbs_FORWARD);
63 TopoDS_Face FFOR = TopoDS::Face(aLocalShape);
64// TopoDS_Face FFOR = TopoDS::Face(F.Oriented(TopAbs_FORWARD));
65 // ************************************************************
66 // prequesitory : in process add(E,F), we'll keep original
67 // E orientation (orientation of E in FFORWARD)
68 // ************************************************************
69 Standard_Boolean inU; Standard_Real xmin,xper;
70 Standard_Boolean closed = FUN_tool_closedS(F,inU,xmin,xper);
71 if (!closed) return Standard_False; // F is not periodic
72 Standard_Real tolu,tolv; FUN_tool_tolUV(TopoDS::Face(F),tolu,tolv);
73 Standard_Real tolx = inU ? tolu : tolv;
74
75 Standard_Real dx=0.45678;
76// Standard_Real f,l,tolpc; Standard_Boolean trim3d = Standard_True;
77// Handle(Geom2d_Curve) PC = FC2D_CurveOnSurface(E,F,f,l,tolpc,trim3d);
78 Standard_Real f,l,tol; Handle(Geom2d_Curve) PC;
7fd59977 79 PC = FC2D_EditableCurveOnSurface(E,FFOR,f,l,tol);
80
81 Standard_Boolean isoU,isoV; gp_Pnt2d o2d; gp_Dir2d d2d;
6e6cd5d9 82 TopOpeBRepTool_TOOL::UVISO(PC,isoU,isoV,d2d,o2d);
7fd59977 83 Standard_Boolean xiso = (inU && isoU)||((!inU) && isoV);
84 if (!xiso) return Standard_False;
85 Standard_Real par = dx*f + (1-dx)*l; gp_Vec2d dxx;
6e6cd5d9 86
87 FUN_tool_getdxx(FFOR,E,par,dxx);
7fd59977 88
89 TopExp_Explorer ex(FFOR, TopAbs_EDGE);
90 for (; ex.More(); ex.Next()){
91 const TopoDS_Edge& e1 = TopoDS::Edge(ex.Current());
92 Standard_Boolean closing = BRep_Tool::IsClosed(e1,F);
93 if (!closing) continue;
94
95// Standard_Real f1,l1; Handle(Geom2d_Curve) PC1 = BRep_Tool::CurveOnSurface(e1,F,f1,l1);
96 Standard_Real f1,l1,tol1; Handle(Geom2d_Curve) PC1;
7fd59977 97 PC1 = FC2D_EditableCurveOnSurface(e1,FFOR,f1,l1,tol1);
98
99 Standard_Boolean isoU1,isoV1; gp_Pnt2d o2d1; gp_Dir2d d2d1;
6e6cd5d9 100 TopOpeBRepTool_TOOL::UVISO(PC1,isoU1,isoV1,d2d1,o2d1);
7fd59977 101
102 // 2d(e1,FFOR) and 2d(E,FFOR) describe the same side of matter
103 Standard_Real par1 = dx*f1 + (1-dx)*l1; gp_Vec2d dxx1;
6e6cd5d9 104 FUN_tool_getdxx(FFOR,e1,par1,dxx1);
7fd59977 105 Standard_Real dot = dxx.Dot(dxx1);
106 if (dot < 0.) continue;
107
108 gp_Vec2d dxx; Standard_Real dd=0;
109 if (inU) {dd = o2d1.X()-o2d.X(); dxx = gp_Vec2d(dd,0.);}
110 else {dd = o2d1.Y()-o2d.Y(); dxx = gp_Vec2d(0.,dd);}
111
112 if (Abs(dd)<tolx) return Standard_False;
113 TopOpeBRepTool_TOOL::TrslUVModifE(dxx,FFOR,E); //FUN_tool_ttranslate(dxx,FFOR,E);
114 } // ex(FFOR)
115 return Standard_False;
116}
117