b311480e |
1 | // Created on: 1993-06-17 |
2 | // Created by: Jean Yves LEBEY |
3 | // Copyright (c) 1993-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 | // |
d5f74e42 |
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 |
973c2be1 |
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 | #ifdef DRAW |
18 | #include <DBRep.hxx> |
7fd59977 |
19 | static TCollection_AsciiString PRODINS("dins "); |
20 | #endif |
21 | |
7fd59977 |
22 | #include <BRep_Tool.hxx> |
42cf5bc1 |
23 | #include <BRepAdaptor_Curve.hxx> |
24 | #include <BRepAdaptor_Surface.hxx> |
7fd59977 |
25 | #include <Geom2d_Curve.hxx> |
26 | #include <Geom2d_Line.hxx> |
7fd59977 |
27 | #include <Geom_Curve.hxx> |
28 | #include <Geom_Surface.hxx> |
7fd59977 |
29 | #include <GeomAbs_CurveType.hxx> |
42cf5bc1 |
30 | #include <GeomAbs_SurfaceType.hxx> |
31 | #include <GeomAPI_ProjectPointOnSurf.hxx> |
32 | #include <gp_Dir2d.hxx> |
33 | #include <gp_Pnt2d.hxx> |
34 | #include <gp_Vec.hxx> |
35 | #include <gp_Vec2d.hxx> |
36 | #include <Precision.hxx> |
37 | #include <Standard_ProgramError.hxx> |
38 | #include <TCollection_AsciiString.hxx> |
39 | #include <TopAbs.hxx> |
40 | #include <TopoDS.hxx> |
41 | #include <TopoDS_Edge.hxx> |
42 | #include <TopoDS_Face.hxx> |
43 | #include <TopoDS_Shape.hxx> |
7fd59977 |
44 | #include <TopOpeBRepBuild_define.hxx> |
42cf5bc1 |
45 | #include <TopOpeBRepBuild_WireEdgeSet.hxx> |
7fd59977 |
46 | #include <TopOpeBRepTool_2d.hxx> |
42cf5bc1 |
47 | #include <TopOpeBRepTool_CurveTool.hxx> |
7fd59977 |
48 | |
0797d9d3 |
49 | #ifdef OCCT_DEBUG |
1d0a9d4d |
50 | extern Standard_Boolean TopOpeBRep_GettraceSHA(const Standard_Integer i); |
51 | extern Standard_Boolean TopOpeBRepBuild_GettraceSS(); |
52 | extern Standard_Boolean TopOpeBRepBuild_GetcontextSSCONNEX(); |
53 | extern Standard_Boolean TopOpeBRepBuild_GettraceCHK(); |
54 | TopOpeBRepBuild_Builder* LOCAL_PBUILDER_DEB = NULL; |
7fd59977 |
55 | void debwesclo(const Standard_Integer) {} |
56 | #endif |
57 | |
58 | //======================================================================= |
59 | //function : TopOpeBRepBuild_WireEdgeSet |
60 | //purpose : |
61 | //======================================================================= |
62 | TopOpeBRepBuild_WireEdgeSet::TopOpeBRepBuild_WireEdgeSet(const TopoDS_Shape& F, |
63 | const Standard_Address /*A*/) : |
64 | TopOpeBRepBuild_ShapeSet(TopAbs_VERTEX) |
65 | { |
66 | myFace = TopoDS::Face(F); |
67 | |
68 | #ifdef DRAW |
69 | myDEBName = "WES"; |
70 | LOCAL_PBUILDER_DEB = (TopOpeBRepBuild_Builder*)((void*)A); |
71 | if (LOCAL_PBUILDER_DEB != NULL) { |
72 | myDEBNumber = LOCAL_PBUILDER_DEB->GdumpSHASETindex(); |
73 | Standard_Integer iF; Standard_Boolean tSPS = LOCAL_PBUILDER_DEB->GtraceSPS(F,iF); |
74 | if(tSPS){DumpName(cout,"creation ");cout<<" on ";} |
75 | if(tSPS){LOCAL_PBUILDER_DEB->GdumpSHA(F,NULL);cout<<endl;} |
76 | } |
77 | if (TopOpeBRepBuild_GettraceCHK() && !myCheckShape) { |
78 | DumpName(cout,"no checkshape in creation of ");cout<<endl; |
79 | } |
80 | #endif |
81 | } |
82 | |
83 | //======================================================================= |
84 | //function : AddShape |
85 | //purpose : |
86 | //======================================================================= |
87 | void TopOpeBRepBuild_WireEdgeSet::AddShape(const TopoDS_Shape& S) |
88 | { |
89 | Standard_Boolean tocheck = Standard_True; |
90 | Standard_Boolean iswire = ( S.ShapeType() == TopAbs_WIRE ); |
91 | if ( iswire ) { |
92 | BRepAdaptor_Surface bas(myFace,Standard_False); |
93 | Standard_Boolean uc = bas.IsUClosed(); |
94 | Standard_Boolean vc = bas.IsVClosed(); |
95 | if ( uc || vc ) tocheck = Standard_False; |
96 | } |
97 | Standard_Boolean chk = Standard_True; |
98 | if ( tocheck ) chk = CheckShape(S); |
99 | |
100 | #ifdef DRAW |
101 | if (TopOpeBRepBuild_GettraceCHK() && CheckShape()) { |
102 | if (!tocheck) DumpCheck(cout," AddShape WIRE on closed face",S,chk); |
103 | else DumpCheck(cout," AddShape redefined",S,chk); |
104 | } |
105 | #endif |
106 | |
107 | if (!chk) return; |
108 | ProcessAddShape(S); |
109 | } |
110 | |
111 | //======================================================================= |
112 | //function : AddStartElement |
113 | //purpose : |
114 | //======================================================================= |
115 | void TopOpeBRepBuild_WireEdgeSet::AddStartElement(const TopoDS_Shape& S) |
116 | { |
0797d9d3 |
117 | #ifdef OCCT_DEBUG |
7fd59977 |
118 | |
119 | #endif |
120 | Standard_Boolean tocheck = Standard_True; |
121 | Standard_Boolean isedge = ( S.ShapeType() == TopAbs_EDGE ); |
122 | if ( isedge ) { |
123 | BRepAdaptor_Curve cac(TopoDS::Edge(S)); |
124 | GeomAbs_CurveType t = cac.GetType(); |
125 | Standard_Boolean b = (t==GeomAbs_BSplineCurve || t==GeomAbs_BezierCurve); |
126 | tocheck = !b; |
127 | } |
128 | Standard_Boolean chk = Standard_True; |
129 | if ( tocheck ) chk = CheckShape(S); |
130 | |
131 | if (!chk) return; |
132 | ProcessAddStartElement(S); |
133 | } |
134 | |
135 | //======================================================================= |
136 | //function : AddElement |
137 | //purpose : |
138 | //======================================================================= |
139 | void TopOpeBRepBuild_WireEdgeSet::AddElement(const TopoDS_Shape& S) |
140 | { |
141 | TopOpeBRepBuild_ShapeSet::AddElement(S); |
142 | } |
143 | |
144 | //======================================================================= |
145 | //function : Face |
146 | //purpose : |
147 | //======================================================================= |
148 | const TopoDS_Face& TopOpeBRepBuild_WireEdgeSet::Face() const |
149 | { |
150 | return myFace; |
151 | } |
152 | |
153 | //======================================================================= |
154 | //function : InitNeighbours |
155 | //purpose : |
156 | //======================================================================= |
157 | void TopOpeBRepBuild_WireEdgeSet::InitNeighbours(const TopoDS_Shape& E) |
158 | { |
159 | |
160 | #ifdef DRAW |
161 | Standard_Boolean traceSS = TopOpeBRepBuild_GettraceSS(); |
162 | Standard_Integer ista=myOMSS.FindIndex(E);Standard_Boolean tsh=(ista)?TopOpeBRep_GettraceSHA(ista) : Standard_False; |
163 | |
164 | if (traceSS || tsh) { |
165 | TCollection_AsciiString str("#**** InitNeighbours"); |
166 | if (tsh) str = str + " on WES edge " + SNameori(E); |
167 | str = str + " #****"; |
168 | cout<<endl<<str<<endl; |
169 | if (tsh) debwesclo(ista); |
170 | } |
171 | #endif |
172 | |
173 | mySubShapeExplorer.Init(E,mySubShapeType); |
174 | myCurrentShape = E; |
175 | FindNeighbours(); |
176 | } |
177 | |
178 | |
179 | //======================================================================= |
180 | //function : FindNeighbours |
181 | //purpose : |
182 | //======================================================================= |
183 | void TopOpeBRepBuild_WireEdgeSet::FindNeighbours() |
184 | { |
185 | while (mySubShapeExplorer.More()) { |
186 | |
187 | // l = list of edges neighbour of edge myCurrentShape trough |
188 | // the vertex mySubShapeExplorer.Current(), which is a vertex of the |
189 | // edge myCurrentShape. |
190 | const TopoDS_Shape& V = mySubShapeExplorer.Current(); |
191 | const TopTools_ListOfShape & l = MakeNeighboursList(myCurrentShape,V); |
192 | |
193 | // myIncidentShapesIter iterates on the neighbour edges of the edge |
194 | // given as InitNeighbours() argument (this edge has been stored |
195 | // in the field myCurrentShape). |
196 | |
197 | myIncidentShapesIter.Initialize(l); |
198 | if (myIncidentShapesIter.More()) break; |
199 | else mySubShapeExplorer.Next(); |
200 | } |
201 | } |
202 | |
203 | |
204 | //======================================================================= |
205 | //function : MakeNeighboursList |
206 | //purpose : recherche des edges connexes a Earg par Varg |
207 | //======================================================================= |
208 | const TopTools_ListOfShape & TopOpeBRepBuild_WireEdgeSet::MakeNeighboursList(const TopoDS_Shape& Earg, const TopoDS_Shape& Varg) |
209 | { |
210 | const TopoDS_Edge& E = TopoDS::Edge(Earg); |
211 | const TopoDS_Vertex& V = TopoDS::Vertex(Varg); |
212 | const TopTools_ListOfShape& l = mySubShapeMap.FindFromKey(V); |
213 | |
214 | Standard_Integer nclosing = NbClosingShapes(l); |
215 | |
216 | #ifdef DRAW |
217 | Standard_Boolean traceSS = TopOpeBRepBuild_GettraceSS(); |
218 | if ( traceSS ) { |
219 | TCollection_AsciiString svel = SNameVEL(V,E,l); |
220 | cout<<PRODINS<<svel<<"; #---- WES MNL"<<endl; |
221 | } |
222 | #endif |
223 | |
224 | if (nclosing) { |
225 | // build myCurrentShapeNeighbours = |
226 | // edge list made of connected shapes to Earg through Varg |
227 | |
228 | myCurrentShapeNeighbours.Clear(); |
229 | |
230 | Standard_Integer iapp = 0; |
231 | for (TopTools_ListIteratorOfListOfShape it(l); it.More(); it.Next()) { |
232 | iapp++; |
233 | const TopoDS_Shape& curn = it.Value(); // current neighbour |
234 | Standard_Boolean k = VertexConnectsEdgesClosing(V,E,curn); |
235 | if (k) { |
236 | myCurrentShapeNeighbours.Append(curn); |
237 | |
238 | #ifdef DRAW |
239 | if ( traceSS ) { |
240 | Standard_Integer rang = myCurrentShapeNeighbours.Extent(); |
241 | const TopoDS_Edge& EE = TopoDS::Edge(curn); |
242 | cout <<"+ EE "<<iapp<<" , rang "<<rang<<" "; |
243 | TCollection_AsciiString svee=SNameVEE(V,E,EE);cout<<svee<<endl; |
244 | } |
245 | #endif |
246 | } |
247 | } |
248 | |
249 | Standard_Integer newn = NbClosingShapes(myCurrentShapeNeighbours); |
250 | #ifdef DRAW |
251 | if ( traceSS ) { |
252 | cout<<"#~~~~connexes apres VertexConnectsEdgesClosing : "; |
253 | TCollection_AsciiString svel=SNameVEL(V,E,myCurrentShapeNeighbours); |
254 | cout<<svel<<endl; |
255 | } |
256 | #endif |
257 | |
258 | if (newn >= 2 ) { |
259 | |
260 | const TopoDS_Face& F = myFace; |
261 | |
262 | // plusieurs aretes de couture connexes a E par V et telles que : |
263 | // orientation de V dans E # orientation de V dans ces aretes. |
264 | // on ne garde,parmi les aretes de couture connexes, |
265 | // que l'arete A qui verifie tg(E) ^ tg(A) > 0 |
266 | |
267 | gp_Vec2d d1E; gp_Pnt2d pE; |
268 | Standard_Real parE = BRep_Tool::Parameter(V,E); |
269 | Standard_Real fiE,laE,tolpc; |
270 | Standard_Boolean trim3d = Standard_True; |
271 | Handle(Geom2d_Curve) PCE = FC2D_CurveOnSurface(E,F,fiE,laE,tolpc,trim3d); |
272 | |
273 | if (!PCE.IsNull()) PCE->D1(parE,pE,d1E); |
274 | else LocalD1(F,E,V,pE,d1E); |
275 | |
276 | TopAbs_Orientation Eori = E.Orientation(); |
277 | if (Eori == TopAbs_REVERSED) d1E.Reverse(); |
278 | |
279 | TopTools_ListIteratorOfListOfShape lclo(myCurrentShapeNeighbours); |
280 | Standard_Integer rang = 0; |
281 | while (lclo.More()) { |
282 | rang++; |
283 | |
284 | if ( ! IsClosed(lclo.Value()) ) { |
285 | lclo.Next(); |
286 | continue; |
287 | } |
288 | |
289 | const TopoDS_Edge& EE = TopoDS::Edge(lclo.Value()); |
290 | gp_Vec2d d1EE; gp_Pnt2d pEE; |
291 | Standard_Real parEE = BRep_Tool::Parameter(V,EE); |
292 | Standard_Real fiEE,laEE,tolpc1; |
293 | Handle(Geom2d_Curve) PCEE = FC2D_CurveOnSurface(EE,F,fiEE,laEE,tolpc1,trim3d); |
294 | |
295 | if (!PCEE.IsNull()) PCEE->D1(parEE,pEE,d1EE); |
296 | else LocalD1(F,EE,V,pEE,d1EE); |
297 | |
298 | TopAbs_Orientation EEori = EE.Orientation(); |
299 | if (EEori == TopAbs_REVERSED) d1EE.Reverse(); |
300 | |
301 | Standard_Real cross = d1E.Crossed(d1EE); |
302 | TopAbs_Orientation oVE,oVEE; |
303 | VertexConnectsEdges(V,E,EE,oVE,oVEE); |
304 | |
305 | Standard_Boolean t2 = ( (cross > 0) && oVE == TopAbs_REVERSED ) || |
306 | ( (cross < 0) && oVE == TopAbs_FORWARD ); |
307 | |
308 | #ifdef DRAW |
309 | if ( traceSS ) { |
310 | cout<<"#-------- rang "<<rang<<endl; |
311 | TCollection_AsciiString svee=SNameVEE(V,E,EE);cout<<svee<<endl; |
312 | |
313 | cout<<" fiE,laE : "<<fiE<<" "<<laE<<endl; |
314 | cout<<" parE "<<parE<<endl; |
315 | cout<<" puE,pvE "<<pE.X()<<" "<<pE.Y(); |
316 | cout<<" d1uE,d1vE "<<d1E.X()<<" "<<d1E.Y()<<endl; |
317 | cout<<endl; |
318 | cout<<" fiEE,laEE : "<<fiEE<<" "<<laEE<<endl; |
319 | cout<<" parEE "<<parEE<<endl; |
320 | cout<<" puEE,pvEE "<<pEE.X()<<" "<<pEE.Y(); |
321 | cout<<" d1uEE,d1vEE "<<d1EE.X()<<" "<<d1EE.Y()<<endl; |
586db386 |
322 | cout<<" --> cross "<<cross<<endl; |
7fd59977 |
323 | |
324 | if ( t2 ) cout<<" t2 --> on garde EE"<<endl<<endl; |
325 | else cout<<" t2 --> on vire EE"<<endl<<endl; |
326 | } |
327 | #endif |
328 | |
329 | if ( t2 ) { //-- t1 |
330 | // c'est la bonne IsClosed,on ne garde qu'elle parmi les IsClosed |
331 | lclo.Next(); |
332 | } |
333 | else { |
334 | // on vire l'arete IsClosed |
335 | myCurrentShapeNeighbours.Remove(lclo); |
336 | } |
337 | } |
338 | |
339 | #ifdef DRAW |
340 | if ( traceSS ) { |
341 | cout<<"#~~~~connexes apres filtre geom : "; |
342 | TCollection_AsciiString svel=SNameVEL(Varg,Earg,myCurrentShapeNeighbours);cout<<svel<<endl; |
343 | } |
344 | #endif |
345 | |
346 | } |
347 | return myCurrentShapeNeighbours; |
348 | } |
349 | else { |
350 | return l; |
351 | } |
352 | |
353 | } // MakeNeighoursList |
354 | |
7fd59977 |
355 | //======================================================================= |
356 | //function : VertexConnectsEdges |
357 | //purpose : |
358 | //======================================================================= |
359 | Standard_Boolean TopOpeBRepBuild_WireEdgeSet::VertexConnectsEdges(const TopoDS_Shape& V,const TopoDS_Shape& E1,const TopoDS_Shape& E2,TopAbs_Orientation& o1,TopAbs_Orientation& o2) const |
360 | { |
361 | TopOpeBRepTool_ShapeExplorer ex1,ex2; |
362 | for(ex1.Init(E1,TopAbs_VERTEX);ex1.More();ex1.Next()) { |
363 | if (V.IsSame(ex1.Current())) { |
364 | for(ex2.Init(E2,TopAbs_VERTEX);ex2.More();ex2.Next()) { |
365 | if (V.IsSame(ex2.Current())) { |
366 | o1 = ex1.Current().Orientation(); |
367 | o2 = ex2.Current().Orientation(); |
368 | if ( o1 != o2 ) return Standard_True; |
369 | } |
370 | } |
371 | } |
372 | } |
373 | return Standard_False; |
374 | } |
375 | |
376 | |
377 | //======================================================================= |
378 | //function : VertexConnectEdgesClosing |
379 | //purpose : |
380 | //======================================================================= |
381 | Standard_Boolean TopOpeBRepBuild_WireEdgeSet::VertexConnectsEdgesClosing(const TopoDS_Shape& V, const TopoDS_Shape& E1, const TopoDS_Shape& E2) const |
382 | { |
383 | |
384 | //----------------------------------------------------------------------- |
385 | //Standard_Boolean VertexConnectsEdgesClosing : |
386 | // Let S the set of incident edges on vertex V. |
387 | // S contains at least one closed edge on the periodic face to build. |
388 | // (the face implied in closing test of edge is myFace) |
389 | // E1,E2 are S shapes (sharing V). |
390 | // |
391 | // if E1 and E2 are not closed : edges are NOT connected |
392 | // if E1 or E2 is/are closed : |
393 | // if V changes of relative orientation between E1,E2 : edges are connected |
394 | // else : edges are NOT connected |
395 | // |
396 | // example with E1 NOT closed, E2 closed : |
397 | // |
398 | // E1 FORWARD, V REVERSED on E1 |
399 | // E2 FORWARD, V FORWARD on E2 --> edges are connected |
400 | // |
401 | // E1 FORWARD, V REVERSED on E1 |
402 | // E2 REVERSED, V FORWARD on E2 --> edges are NOT connected |
403 | //----------------------------------------------------------------------- |
404 | |
405 | Standard_Boolean c1 = IsClosed(E1); |
406 | Standard_Boolean c2 = IsClosed(E2); |
407 | |
408 | Standard_Boolean testconnect = c1 || c2; |
409 | Standard_Boolean resu = Standard_False; |
410 | TopAbs_Orientation o1,o2; |
411 | |
412 | // SSCONNEX = False ==> on selectionne E2 de facon a creer ulterieurement |
413 | // (defaut) autant de faces que de composantes connexes en UV. |
414 | // SSCONNEX = True ==> on prend toute arete E2 qui partage V avec E1 |
415 | // et telle que orientation(V/E1) # orientation(V/E2) |
416 | // ==> face de part et d'autre des coutures |
417 | |
418 | #ifdef DRAW |
419 | if ( TopOpeBRepBuild_GetcontextSSCONNEX() ) { |
420 | if (testconnect) resu = VertexConnectsEdges(V,E1,E2,o1,o2); |
421 | return resu; |
422 | } |
423 | #endif |
424 | |
425 | if ((c1 && c2)) { |
426 | Standard_Boolean u1 = c1 ? IsUClosed(E1) : Standard_False; |
427 | Standard_Boolean v1 = c1 ? IsVClosed(E1) : Standard_False; |
428 | Standard_Boolean u2 = c2 ? IsUClosed(E2) : Standard_False; |
429 | Standard_Boolean v2 = c2 ? IsVClosed(E2) : Standard_False; |
430 | Standard_Boolean uvdiff = (u1 && v2) || (u2 && v1); |
431 | testconnect = uvdiff; |
432 | } |
433 | |
434 | if (testconnect) { |
435 | resu = VertexConnectsEdges(V,E1,E2,o1,o2); |
436 | } |
437 | else { |
438 | // cto 012 O2 arete de couture de face cylindrique |
439 | // chainage des composantes splitees ON et OUT de meme orientation |
440 | TopAbs_Orientation oe1 = E1.Orientation(); |
441 | TopAbs_Orientation oe2 = E2.Orientation(); |
442 | Standard_Boolean iseq = E1.IsEqual(E2); |
443 | if ( (c1 && c2) && (oe1 == oe2) && (!iseq) ) { |
444 | resu = VertexConnectsEdges(V,E1,E2,o1,o2); |
445 | } |
446 | } |
447 | return resu; |
448 | } |
449 | |
450 | //======================================================================= |
451 | //function : NbClosingShapes |
452 | //purpose : |
453 | //======================================================================= |
454 | Standard_Integer TopOpeBRepBuild_WireEdgeSet::NbClosingShapes(const TopTools_ListOfShape & L) const |
455 | { |
456 | Standard_Integer n = 0; |
457 | for (TopTools_ListIteratorOfListOfShape it(L); it.More(); it.Next()) { |
458 | const TopoDS_Shape& S = it.Value(); |
459 | if ( IsClosed(S) ) n++; |
460 | } |
461 | return n; |
462 | } |
463 | |
464 | //======================================================================= |
465 | //function : LocalD1 |
466 | //purpose : |
467 | //======================================================================= |
468 | void TopOpeBRepBuild_WireEdgeSet::LocalD1(const TopoDS_Shape& SF,const TopoDS_Shape& SE,const TopoDS_Shape& SV, |
469 | gp_Pnt2d& pE, gp_Vec2d& d1E) const |
470 | { |
471 | const TopoDS_Face& F = TopoDS::Face(SF); |
472 | const TopoDS_Edge& E = TopoDS::Edge(SE); |
473 | const TopoDS_Vertex& V = TopoDS::Vertex(SV); |
474 | Standard_Real parE = BRep_Tool::Parameter(V,E); |
475 | |
476 | TopLoc_Location Loc; Standard_Real fiE,laE; |
477 | Handle(Geom_Curve) CE = BRep_Tool::Curve(E,Loc,fiE,laE); |
478 | CE = Handle(Geom_Curve)::DownCast(CE->Transformed(Loc.Transformation())); |
479 | |
480 | gp_Pnt p3dE; gp_Vec d3dE; |
481 | CE->D1(parE,p3dE,d3dE); |
482 | |
483 | Handle(Geom_Surface) S = BRep_Tool::Surface(F); |
484 | GeomAPI_ProjectPointOnSurf proj(p3dE,S); |
485 | Standard_Real u,v; |
486 | proj.LowerDistanceParameters(u,v); |
487 | pE.SetCoord(u,v); |
488 | gp_Pnt bid; gp_Vec d1u,d1v; |
489 | S->D1(u,v,bid,d1u,d1v); |
490 | u = d3dE.Dot(d1u); |
491 | v = d3dE.Dot(d1v); |
492 | d1E.SetCoord(u,v); |
493 | } |
494 | |
495 | //======================================================================= |
496 | //function : IsClosed |
497 | //purpose : |
498 | //======================================================================= |
499 | Standard_Boolean TopOpeBRepBuild_WireEdgeSet::IsClosed(const TopoDS_Shape& E) const |
500 | { |
0797d9d3 |
501 | #ifdef OCCT_DEBUG |
7fd59977 |
502 | Standard_Integer ista=myOMSS.FindIndex(E);Standard_Boolean tsh=(ista)?TopOpeBRep_GettraceSHA(ista):Standard_False; |
503 | if (tsh) debwesclo(ista); |
504 | #endif |
505 | |
506 | const TopoDS_Edge& EE = TopoDS::Edge(E); |
507 | Standard_Boolean closed = BRep_Tool::IsClosed(EE,myFace); |
508 | if ( closed ) return Standard_True; |
509 | |
510 | return Standard_False; |
511 | } |
512 | |
513 | //======================================================================= |
514 | //function : IsUVISO |
515 | //purpose : |
516 | //======================================================================= |
517 | void TopOpeBRepBuild_WireEdgeSet::IsUVISO(const TopoDS_Edge& E,const TopoDS_Face& F,Standard_Boolean& uiso,Standard_Boolean& viso) |
518 | { |
519 | uiso = viso = Standard_False; |
520 | Standard_Real fE,lE,tolpc;Handle(Geom2d_Curve) PC; |
521 | Standard_Boolean trim3d = Standard_True; |
522 | PC = FC2D_CurveOnSurface(E,F,fE,lE,tolpc,trim3d); |
9775fa61 |
523 | if (PC.IsNull()) throw Standard_ProgramError("TopOpeBRepBuild_WireEdgeSet::IsUVISO"); |
7fd59977 |
524 | |
7fd59977 |
525 | Handle(Standard_Type) TheType = PC->DynamicType(); |
526 | if (TheType == STANDARD_TYPE(Geom2d_Line)) { |
c5f3a425 |
527 | Handle(Geom2d_Line) HL (Handle(Geom2d_Line)::DownCast (PC)); |
7fd59977 |
528 | const gp_Dir2d& D = HL->Direction(); |
529 | Standard_Real tol = Precision::Angular(); |
530 | |
531 | if (D.IsParallel(gp_Dir2d(0.,1.),tol)) uiso = Standard_True; |
532 | else if (D.IsParallel(gp_Dir2d(1.,0.),tol)) viso = Standard_True; |
533 | } |
534 | } |
535 | |
536 | //======================================================================= |
537 | //function : IsUClosed |
538 | //purpose : |
539 | //======================================================================= |
540 | Standard_Boolean TopOpeBRepBuild_WireEdgeSet::IsUClosed(const TopoDS_Shape& E) const |
541 | { |
542 | const TopoDS_Edge& EE = TopoDS::Edge(E); |
543 | Standard_Boolean bid,closed; |
544 | IsUVISO(EE,myFace,closed,bid); |
545 | return closed; |
546 | } |
547 | |
548 | |
549 | //======================================================================= |
550 | //function : IsVClosed |
551 | //purpose : |
552 | //======================================================================= |
553 | Standard_Boolean TopOpeBRepBuild_WireEdgeSet::IsVClosed(const TopoDS_Shape& E) const |
554 | { |
555 | const TopoDS_Edge& EE = TopoDS::Edge(E); |
556 | Standard_Boolean bid,closed; |
557 | IsUVISO(EE,myFace,bid,closed); |
558 | return closed; |
559 | } |
560 | |
561 | //======================================================================= |
562 | //function : SNameVEE |
563 | //purpose : |
564 | //======================================================================= |
565 | #ifdef DRAW |
566 | TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameVEE(const TopoDS_Shape& VV, |
567 | const TopoDS_Shape& EE1, |
568 | const TopoDS_Shape& EE2) const |
569 | { |
570 | TCollection_AsciiString str; |
571 | const TopoDS_Vertex& V = TopoDS::Vertex(VV); |
572 | const TopoDS_Shape& E1 = TopoDS::Edge(EE1); |
573 | const TopoDS_Shape& E2 = TopoDS::Edge(EE2); |
574 | TopAbs_Orientation oVE1,oVE2; Standard_Boolean conn = VertexConnectsEdges(V,E1,E2,oVE1,oVE2); |
575 | str=SName(VV)+" "; |
576 | str=str+SNameori(E1)+" V/E1 : "; |
d2e60688 |
577 | TCollection_AsciiString so1 = TopAbs::ShapeOrientationToString (oVE1); |
7fd59977 |
578 | str=str+so1.SubString(1,1)+" "; |
579 | str=str+SNameori(E2)+" V/E2 : "; |
d2e60688 |
580 | TCollection_AsciiString so2 = TopAbs::ShapeOrientationToString (oVE2); |
7fd59977 |
581 | str=str+so2.SubString(1,1)+" "; |
582 | return str; |
583 | } |
584 | #else |
585 | TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameVEE(const TopoDS_Shape&, |
586 | const TopoDS_Shape&, |
587 | const TopoDS_Shape&) const |
588 | { |
589 | TCollection_AsciiString str; |
590 | return str; |
591 | } |
592 | #endif |
593 | |
594 | //======================================================================= |
595 | //function : SNameVEL |
596 | //purpose : |
597 | //======================================================================= |
598 | #ifdef DRAW |
599 | TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameVEL(const TopoDS_Shape& V, const TopoDS_Shape& E, |
600 | const TopTools_ListOfShape& L) const |
601 | #else |
602 | TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameVEL(const TopoDS_Shape&, const TopoDS_Shape&, |
603 | const TopTools_ListOfShape&) const |
604 | #endif |
605 | { |
606 | TCollection_AsciiString str; |
607 | #ifdef DRAW |
608 | Standard_Integer nc = NbClosingShapes(L), nl = L.Extent(); |
609 | str=SNameori(E)+" "+SName(V)+" "+SNameori(L); |
610 | #endif |
611 | return str; |
612 | } |
613 | |
614 | //======================================================================= |
615 | //function : DumpSS |
616 | //purpose : |
617 | //======================================================================= |
618 | void TopOpeBRepBuild_WireEdgeSet::DumpSS() |
619 | { |
620 | #ifdef DRAW |
621 | TopOpeBRepBuild_ShapeSet::DumpSS(); |
622 | #endif |
623 | } |
624 | |
625 | //======================================================================= |
626 | //function : SName |
627 | //purpose : |
628 | //======================================================================= |
629 | #ifdef DRAW |
630 | TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SName(const TopoDS_Shape& S, |
631 | const TCollection_AsciiString& sb, |
632 | const TCollection_AsciiString& sa) const |
633 | #else |
634 | TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SName(const TopoDS_Shape&, |
635 | const TCollection_AsciiString& sb, |
636 | const TCollection_AsciiString&) const |
637 | #endif |
638 | { |
639 | TCollection_AsciiString str=sb; |
640 | #ifdef DRAW |
641 | str=str+TopOpeBRepBuild_ShapeSet::SName(S); |
642 | str=str+sa; |
643 | DBRep::Set(str.ToCString(),S); |
644 | #endif |
645 | return str; |
646 | } |
647 | |
648 | //======================================================================= |
649 | //function : SNameori |
650 | //purpose : |
651 | //======================================================================= |
652 | #ifdef DRAW |
653 | TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameori(const TopoDS_Shape& S, |
654 | const TCollection_AsciiString& sb, |
655 | const TCollection_AsciiString& sa) const |
656 | #else |
657 | TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameori(const TopoDS_Shape&, |
658 | const TCollection_AsciiString& sb, |
659 | const TCollection_AsciiString&) const |
660 | #endif |
661 | { |
662 | TCollection_AsciiString str=sb; |
663 | #ifdef DRAW |
664 | str=str+TopOpeBRepBuild_ShapeSet::SNameori(S); |
665 | if ( S.ShapeType() == TopAbs_EDGE ) { |
666 | const TopoDS_Shape& E = TopoDS::Edge(S); |
667 | Standard_Boolean c = IsClosed(E), u = IsUClosed(E), v = IsVClosed(E); |
668 | if (c) str=str+"c"; |
669 | if (u) str=str+"u"; |
670 | if (v) str=str+"v"; |
671 | str=str+sa; |
672 | DBRep::Set(str.ToCString(),S); |
673 | } |
674 | #endif |
675 | return str; |
676 | } |
677 | |
678 | //======================================================================= |
679 | //function : SName |
680 | //purpose : |
681 | //======================================================================= |
682 | #ifdef DRAW |
683 | TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SName(const TopTools_ListOfShape& L, |
684 | const TCollection_AsciiString& sb, |
685 | const TCollection_AsciiString& sa) const |
686 | #else |
687 | TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SName(const TopTools_ListOfShape&, |
688 | const TCollection_AsciiString&, |
689 | const TCollection_AsciiString&) const |
690 | #endif |
691 | { |
692 | TCollection_AsciiString str; |
693 | #ifdef DRAW |
694 | for (TopTools_ListIteratorOfListOfShape it(L);it.More();it.Next()) |
695 | str=str+sb+SName(it.Value())+sa+" "; |
696 | #endif |
697 | return str; |
698 | } |
699 | |
700 | //======================================================================= |
701 | //function : SNameori |
702 | //purpose : |
703 | //======================================================================= |
704 | #ifdef DRAW |
705 | TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameori(const TopTools_ListOfShape& L, |
706 | const TCollection_AsciiString& sb, |
707 | const TCollection_AsciiString& sa) const |
708 | #else |
709 | TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameori(const TopTools_ListOfShape&, |
710 | const TCollection_AsciiString&, |
711 | const TCollection_AsciiString&) const |
712 | #endif |
713 | { |
714 | TCollection_AsciiString str; |
715 | #ifdef DRAW |
716 | for (TopTools_ListIteratorOfListOfShape it(L);it.More();it.Next()) |
717 | str=str+sb+SNameori(it.Value())+sa+" "; |
718 | #endif |
719 | return str; |
720 | } |