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