Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1995-08-04 |
2 | // Created by: Jean Yves LEBEY | |
3 | // Copyright (c) 1995-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
973c2be1 | 8 | // This library is free software; you can redistribute it and / or modify it |
9 | // under the terms of the GNU Lesser General Public 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. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
7fd59977 | 16 | |
17 | #include <TopOpeBRep_FacesFiller.ixx> | |
18 | ||
19 | #include <TopOpeBRepTool_ShapeTool.hxx> | |
20 | #include <TopOpeBRepTool_EXPORT.hxx> | |
21 | #include <TopOpeBRepTool_makeTransition.hxx> | |
22 | ||
23 | #include <TopOpeBRepDS_PointIterator.hxx> | |
24 | #include <TopOpeBRepDS_define.hxx> | |
25 | #include <TopOpeBRepDS_repvg.hxx> // LOIinfsup | |
26 | #include <TopOpeBRepDS_EXPORT.hxx> | |
27 | ||
28 | #include <TopOpeBRep_define.hxx> | |
29 | ||
30 | #include <Precision.hxx> | |
31 | #include <TopoDS.hxx> | |
32 | #include <TopExp.hxx> | |
33 | #include <BRep_Tool.hxx> | |
34 | #include <BRepAdaptor_Curve.hxx> | |
35 | #include <gp_Vec.hxx> | |
36 | ||
37 | ||
38 | #define M_ON(st) (st == TopAbs_ON) | |
39 | #define M_REVERSED(st) (st == TopAbs_REVERSED) | |
40 | ||
41 | #ifdef DEB | |
1d0a9d4d | 42 | extern Standard_Boolean TopOpeBRepDS_GettraceDSF(); |
43 | extern Standard_Boolean TopOpeBRepDS_GettraceSPSX(const Standard_Integer i1); | |
7fd59977 | 44 | Standard_EXPORT void debarc(const Standard_Integer i); |
45 | Standard_EXPORT void debooarc(const Standard_Integer i); | |
46 | #endif | |
47 | ||
48 | Standard_EXPORT Handle(TopOpeBRepDS_Interference) MakeEPVInterference | |
49 | (const TopOpeBRepDS_Transition& T, // transition | |
50 | const Standard_Integer S, // curve/edge index | |
51 | const Standard_Integer G, // point/vertex index | |
52 | const Standard_Real P, // parameter of G on S | |
53 | const TopOpeBRepDS_Kind GK, | |
54 | const Standard_Boolean B); // G is a vertex (or not) of the interference master | |
55 | Standard_EXPORT Handle(TopOpeBRepDS_Interference) MakeEPVInterference | |
56 | (const TopOpeBRepDS_Transition& T, // transition | |
57 | const Standard_Integer S, // curve/edge index | |
58 | const Standard_Integer G, // point/vertex index | |
59 | const Standard_Real P, // parameter of G on S | |
60 | const TopOpeBRepDS_Kind GK, // POINT/VERTEX | |
61 | const TopOpeBRepDS_Kind SK, | |
62 | const Standard_Boolean B); // G is a vertex (or not) of the interference master | |
63 | ||
64 | ||
65 | static Standard_Boolean FUN_INlos(const TopoDS_Shape& S, const TopTools_ListOfShape& loS) | |
66 | { | |
67 | TopTools_ListIteratorOfListOfShape it(loS); | |
68 | for (; it.More(); it.Next()) | |
69 | if (it.Value().IsSame(S)) return Standard_True; | |
70 | return Standard_False; | |
71 | } | |
72 | ||
73 | //======================================================================= | |
74 | //function : GetEdgeTrans | |
75 | //purpose : Computes E<Sind> transition on <F> at point <VP> | |
76 | // Computes FORWARD or REVERSED transitions, | |
77 | // returns transition UNKNOWN elsewhere. | |
78 | //======================================================================= | |
79 | TopOpeBRepDS_Transition TopOpeBRep_FacesFiller::GetEdgeTrans(const TopOpeBRep_VPointInter& VP,const TopOpeBRepDS_Kind PVKind, | |
80 | const Standard_Integer PVIndex,const Standard_Integer ShapeIndex,const TopoDS_Face& F) | |
81 | { | |
82 | // VP is on couture <Ec> of rank <sind> | |
83 | // on face <F> of rank <oosind>. | |
84 | Standard_Integer OOShapeIndex = (ShapeIndex == 1) ? 2 : 1; | |
85 | Standard_Integer vpsind = VP.ShapeIndex(); | |
86 | Standard_Boolean on2edges = (vpsind == 3); | |
87 | Standard_Boolean isvalid = on2edges || (vpsind == ShapeIndex); | |
88 | if (!isvalid) Standard_Failure::Raise("TopOpeBRep_FacesFiller::GetEdgeTrans"); | |
89 | ||
90 | const TopoDS_Edge& edge = TopoDS::Edge(VP.Edge(ShapeIndex)); | |
91 | Standard_Real paredge = VP.EdgeParameter(ShapeIndex); | |
92 | ||
93 | TopoDS_Edge OOedge; | |
1d47d8d0 | 94 | |
95 | Standard_Real OOparedge = 0.; | |
96 | ||
7fd59977 | 97 | Standard_Boolean hasONedge = (VP.State(OOShapeIndex) == TopAbs_ON); |
98 | Standard_Boolean hasOOedge = (on2edges) ? Standard_True : hasONedge; | |
99 | if ( hasOOedge ) { | |
100 | if (on2edges) OOparedge = VP.EdgeParameter(OOShapeIndex); | |
101 | else OOparedge = VP.EdgeONParameter(OOShapeIndex); | |
102 | TopoDS_Shape OOe; | |
103 | if (on2edges) OOe = VP.Edge(OOShapeIndex); | |
104 | else OOe = VP.EdgeON(OOShapeIndex); | |
105 | OOedge = TopoDS::Edge(OOe); | |
106 | } | |
107 | gp_Pnt2d OOuv = VP.SurfaceParameters(OOShapeIndex); | |
108 | ||
109 | Standard_Real par1,par2; | |
110 | Standard_Integer SIedgeIndex = (myHDS->HasShape(edge)) ? myHDS->Shape(edge) : 0; | |
111 | // if (SIedgeIndex != 0) FDS_getupperlower(myHDS,SIedgeIndex,paredge,par1,par2); | |
112 | if (SIedgeIndex != 0) { | |
113 | Standard_Boolean isonboundper; | |
114 | FDS_LOIinfsup(myHDS->DS(),edge,paredge,PVKind,PVIndex, | |
115 | myHDS->DS().ShapeInterferences(edge),par1,par2,isonboundper); | |
116 | } | |
117 | else | |
118 | FUN_tool_bounds(edge,par1,par2); | |
119 | ||
120 | TopOpeBRepDS_Transition T; | |
121 | // xpu : 16-01-98 | |
122 | // <Tr> relative to 3d <OOface> matter, | |
123 | // we take into account <Tr> / 2d <OOface> only if <edge> is normal to <OOface> | |
124 | Standard_Real tola = Precision::Angular()*1.e+2; //dealing with tolerances | |
125 | Standard_Boolean EtgF = FUN_tool_EtgF(paredge,edge,OOuv,F,tola); | |
126 | Standard_Boolean rest = FUN_INlos(edge,myERL); | |
127 | Standard_Boolean isse = myHDS->DS().IsSectionEdge(edge); | |
128 | rest = rest || isse; | |
129 | Standard_Boolean interf2d = EtgF && hasOOedge && rest; | |
130 | ||
131 | Standard_Real factor = 1.e-4; | |
132 | TopOpeBRepTool_makeTransition MKT; | |
133 | Standard_Boolean ok = MKT.Initialize(edge,par1,par2,paredge, F,OOuv, factor); | |
134 | if (!ok) return T; | |
135 | Standard_Boolean isT2d = MKT.IsT2d(); | |
136 | interf2d = interf2d && isT2d; | |
137 | if (interf2d) ok = MKT.SetRest(OOedge,OOparedge); | |
138 | if (!ok) return T; | |
139 | ||
140 | TopAbs_State stb,sta; ok = MKT.MkTonE(stb,sta); | |
141 | if (!ok) return T; | |
142 | T.Before(stb); T.After(sta); | |
143 | return T; | |
144 | } | |
145 | ||
146 | //======================================================================= | |
147 | //function : ProcessVPonclosingR | |
148 | //purpose : SUPPLYING INTPATCH when <VP> is on closing arc. | |
149 | //======================================================================= | |
150 | void TopOpeBRep_FacesFiller::ProcessVPonclosingR(const TopOpeBRep_VPointInter& VP, | |
151 | // const TopoDS_Shape& GFace, | |
152 | const TopoDS_Shape& , | |
153 | const Standard_Integer ShapeIndex, | |
154 | const TopOpeBRepDS_Transition& transEdge,const TopOpeBRepDS_Kind PVKind, const Standard_Integer PVIndex, | |
155 | // const Standard_Boolean EPIfound, | |
156 | const Standard_Boolean , | |
157 | // const Handle(TopOpeBRepDS_Interference)& IEPI) | |
158 | const Handle(TopOpeBRepDS_Interference)& ) | |
159 | { | |
160 | // Standard_Boolean isvertex = VP.IsVertex(ShapeIndex); | |
161 | Standard_Boolean isvertex = (PVKind == TopOpeBRepDS_VERTEX); | |
162 | Standard_Integer absindex = VP.ShapeIndex(); // 0,1,2,3 | |
7fd59977 | 163 | Standard_Boolean OOShapeIndex = (ShapeIndex == 1) ? 2 : 1; |
164 | Standard_Boolean on2edges = (absindex == 3); | |
165 | Standard_Boolean hasONedge = (VP.State(OOShapeIndex) == TopAbs_ON); | |
166 | Standard_Boolean hasOOedge = (on2edges) ? Standard_True : hasONedge; | |
167 | ||
168 | TopoDS_Face Face = (*this).Face(ShapeIndex); | |
7fd59977 | 169 | TopoDS_Face OOFace = (*this).Face(OOShapeIndex); |
170 | Standard_Integer iOOFace = myDS->Shape(OOFace); | |
171 | if (iOOFace == 0) iOOFace = myDS->AddShape(OOFace,OOShapeIndex); | |
172 | ||
173 | // current VPoint is on <edge> | |
96a95605 | 174 | #ifdef DEB |
7fd59977 | 175 | Standard_Integer SIedgeIndex = 0; |
96a95605 | 176 | #endif |
7fd59977 | 177 | const TopoDS_Edge& edge = TopoDS::Edge(VP.Edge(ShapeIndex)); |
96a95605 DB |
178 | if (!myDS->HasShape(edge)) myDS->AddShape(edge,ShapeIndex); |
179 | #ifdef DEB | |
180 | else SIedgeIndex = myDS->Shape(edge); | |
181 | #endif | |
6e6cd5d9 | 182 | |
7fd59977 | 183 | Standard_Real paredge = VP.EdgeParameter(ShapeIndex); |
184 | ||
185 | // dummy if !<hasOOedge> | |
186 | Standard_Integer OOedgeIndex = 0; | |
7fd59977 | 187 | TopoDS_Edge OOedge; |
188 | if ( hasOOedge ) { | |
189 | TopoDS_Shape OOe; | |
190 | if (on2edges) OOe = VP.Edge(OOShapeIndex); | |
191 | else OOe = VP.EdgeON(OOShapeIndex); | |
192 | OOedge = TopoDS::Edge(OOe); | |
7fd59977 | 193 | if (myDS->HasShape(OOedge)) OOedgeIndex = myDS->Shape(OOedge); |
194 | else OOedgeIndex = myDS->AddShape(OOedge,OOShapeIndex); | |
195 | } | |
196 | ||
197 | #ifdef DEB | |
198 | Standard_Boolean traceDSF = TopOpeBRepDS_GettraceDSF(); | |
199 | Standard_Boolean trce = TopOpeBRepDS_GettraceSPSX(SIedgeIndex); if(trce) debarc(SIedgeIndex); | |
200 | Standard_Boolean trcooe = TopOpeBRepDS_GettraceSPSX(OOedgeIndex); if(trcooe) debooarc(OOedgeIndex); | |
201 | #endif | |
202 | ||
203 | // =================================================================== | |
204 | // --- Edge/(POINT,VERTEX) Interference (EPI) creation --- | |
205 | // =================================================================== | |
206 | ||
207 | // 1. <edge> enters or outers myF<OOShapeIndex> at <VP>, | |
208 | // transition <transEdge> returned by IntPatch is valid (FORWARD/REVERSED). | |
209 | // 2. <edge> is tangent to myF<OOShapeIndex> : | |
210 | // transEdge should be INTERNAL/EXTERNAL. | |
211 | ||
212 | Standard_Boolean Tunk = transEdge.IsUnknown(); | |
213 | #ifdef DEB | |
214 | if (!Tunk && traceDSF) cout<<"-> on closing : transAdd = "<<endl; | |
215 | #endif | |
216 | TopOpeBRepDS_Transition transAdd; | |
217 | Standard_Boolean newtransEdge = Tunk; | |
218 | if (newtransEdge) transAdd = GetEdgeTrans(VP,PVKind,PVIndex,ShapeIndex,OOFace); | |
219 | else transAdd = transEdge; | |
220 | ||
221 | // !!! if the compute of <transAdd> fails, we add transEdge. | |
222 | // hasOOedge : <VP> is ON edge <edge> and ON <OOFace> | |
223 | // !hasOOedge : <VP> is ON edge <edge> and IN <OOFace> | |
224 | { | |
225 | TopOpeBRepDS_Transition T = transAdd; T.Index(iOOFace); | |
226 | Handle(TopOpeBRepDS_Interference) EPI = ::MakeEPVInterference | |
227 | (T,iOOFace,PVIndex,paredge,PVKind,TopOpeBRepDS_FACE,isvertex); | |
228 | myHDS->StoreInterference(EPI,edge); | |
229 | } | |
230 | if (hasOOedge) { | |
231 | TopOpeBRepDS_Transition T = transAdd; T.Index(iOOFace); | |
232 | Handle(TopOpeBRepDS_Interference) EPI = ::MakeEPVInterference | |
233 | (T,OOedgeIndex,PVIndex,paredge,PVKind,isvertex); | |
234 | myHDS->StoreInterference(EPI,edge); | |
235 | } | |
236 | ||
237 | } // ProcessVPonclosingR |