Commit | Line | Data |
---|---|---|
7fd59977 | 1 | // File: DBRep.cxx |
2 | // Created: Wed Jul 21 16:11:15 1993 | |
3 | // Author: Remi LEQUETTE | |
4 | // <rle@nonox> | |
5 | ||
6 | #ifdef HAVE_CONFIG_H | |
7 | # include <config.h> | |
8 | #endif | |
9 | ||
10 | #include <DBRep.ixx> | |
11 | #include <DBRep_DrawableShape.hxx> | |
12 | #include <Draw_Appli.hxx> | |
13 | #include <Draw.hxx> | |
14 | #include <Draw_Segment3D.hxx> | |
15 | #include <TopAbs.hxx> | |
16 | #include <TopoDS.hxx> | |
17 | #include <TopoDS_Iterator.hxx> | |
18 | #include <TopoDS_Compound.hxx> | |
19 | #include <TopTools_MapOfShape.hxx> | |
20 | #include <TopTools_ListOfShape.hxx> | |
21 | #include <TopExp_Explorer.hxx> | |
22 | #include <BRepTools.hxx> | |
23 | #include <BRepTools_WireExplorer.hxx> | |
24 | #include <BRepTools_ShapeSet.hxx> | |
25 | #include <BRepAdaptor_Surface.hxx> | |
26 | #include <Precision.hxx> | |
27 | #include <Poly_Triangulation.hxx> | |
28 | #include <gp_Ax2.hxx> | |
29 | ||
30 | #include <TopExp.hxx> | |
31 | #include <TopTools_Array1OfShape.hxx> | |
32 | #include <TColStd_Array1OfInteger.hxx> | |
33 | #include <GProp.hxx> | |
34 | #include <GProp_GProps.hxx> | |
35 | #include <BRepGProp.hxx> | |
36 | #include <TColStd_Array1OfReal.hxx> | |
37 | #include <Draw_ProgressIndicator.hxx> | |
38 | ||
39 | // memory management | |
40 | #include <Standard.hxx> | |
41 | //#ifdef WNT | |
42 | #include <stdio.h> | |
43 | #ifdef WNT | |
44 | extern Draw_Viewer dout; | |
45 | #endif | |
46 | #ifdef HAVE_STRINGS_H | |
47 | # include <strings.h> | |
48 | #endif | |
49 | ||
50 | #define Characters(IArg) (strspn (Arg[IArg], "0123456789.+-eE") != strlen (Arg[IArg])) | |
51 | #define Float(IArg) (strspn (Arg[IArg], "0123456789+-") != strlen (Arg[IArg])) | |
52 | ||
53 | ||
54 | //========================================== | |
0d969553 | 55 | // useful methods |
7fd59977 | 56 | //========================================== |
57 | ||
58 | Standard_EXPORT void DBRep_WriteColorOrientation () | |
59 | { | |
60 | cout << "\nrouge FORWARD"; | |
61 | cout << "\nbleu REVERSED"; | |
62 | cout << "\nrose EXTERNAL"; | |
63 | cout << "\norange INTERNAL"<<endl; | |
64 | } | |
65 | ||
66 | Standard_EXPORT Draw_Color DBRep_ColorOrientation (const TopAbs_Orientation Or) | |
67 | { | |
68 | Draw_Color col; | |
69 | switch (Or) { | |
70 | ||
71 | case TopAbs_FORWARD : | |
72 | col = Draw_rouge; | |
73 | break; | |
74 | ||
75 | case TopAbs_REVERSED : | |
76 | col = Draw_bleu; | |
77 | break; | |
78 | ||
79 | case TopAbs_EXTERNAL : | |
80 | col = Draw_rose; | |
81 | break; | |
82 | ||
83 | case TopAbs_INTERNAL : | |
84 | col = Draw_orange; | |
85 | break; | |
86 | ||
87 | } | |
88 | return col; | |
89 | } | |
90 | ||
91 | //========================================== | |
92 | // static variables | |
93 | //========================================== | |
94 | ||
95 | static Standard_Integer nbIsos = 2; | |
96 | static Standard_Real size = 100.; | |
97 | static Standard_Integer discret = 30; | |
98 | static Standard_Boolean disptriangles = Standard_False; | |
99 | static Standard_Boolean disppolygons = Standard_False; | |
c6541a0c D |
100 | static Standard_Real anglHLR = 35 * M_PI / 180; |
101 | static Standard_Real HAngMin = 1 * M_PI / 180; | |
102 | static Standard_Real HAngMax = 35 * M_PI / 180; | |
7fd59977 | 103 | static Standard_Boolean withHLR = Standard_False; |
104 | static Standard_Boolean withRg1 = Standard_True; | |
105 | static Standard_Boolean withRgN = Standard_False; | |
106 | static Standard_Boolean withHid = Standard_False; | |
107 | ||
108 | //======================================================================= | |
109 | // isos | |
110 | //======================================================================= | |
111 | ||
112 | static Standard_Integer isos (Draw_Interpretor& di, | |
113 | Standard_Integer NbArg, const char **Arg) | |
114 | { | |
115 | NbArg-- ; | |
116 | ||
117 | if (NbArg <= 0) { | |
118 | di << "Current number of isos : " << nbIsos << "\n" ; | |
119 | return 0 ; | |
120 | } | |
121 | ||
122 | Standard_Integer NbIsos = 0 ; | |
123 | Standard_Boolean Change = Standard_False ; | |
124 | if (!Characters (NbArg) && Float (NbArg)) return 1 ; | |
125 | if (!Characters (NbArg)) { | |
126 | NbIsos = atoi (Arg[NbArg]) ; | |
127 | NbArg-- ; | |
128 | Change = Standard_True ; | |
129 | } | |
130 | ||
131 | if (NbArg <= 0) { | |
132 | nbIsos = NbIsos ; | |
133 | di << "New current number of isos : " << nbIsos << "\n" ; | |
134 | } else { | |
135 | for (Standard_Integer IArg = 1 ; IArg <= NbArg ; IArg++) { | |
136 | Handle (Draw_Drawable3D) Shape1 = Draw::Get (Arg[IArg]) ; | |
137 | if (!Shape1.IsNull()) { | |
138 | Handle (DBRep_DrawableShape) Shape2 = | |
139 | Handle (DBRep_DrawableShape)::DownCast (Shape1) ; | |
140 | if (!Shape2.IsNull()) { | |
141 | if (Change) { | |
142 | Shape2->ChangeNbIsos (NbIsos) ; | |
143 | } else { | |
144 | di << "Number of isos for " << Arg[IArg] << " : " << Shape2->NbIsos() << "\n"; | |
145 | } | |
146 | } | |
147 | } | |
148 | } | |
149 | if (Change) dout.RepaintAll() ; | |
150 | } | |
151 | ||
152 | return 0 ; | |
153 | } | |
154 | ||
155 | //======================================================================= | |
156 | // hlr | |
157 | //======================================================================= | |
158 | ||
159 | static Standard_Integer hlr (Draw_Interpretor& di, | |
160 | Standard_Integer n, const char **a) | |
161 | { | |
162 | if (n <= 1) { | |
163 | if (withHLR) { | |
164 | di << " HLR"; | |
165 | if (withRgN) di << " RgNLines"; | |
166 | else { | |
167 | if (withRg1) di << " Rg1Lines"; | |
168 | else di << " no RegLines"; | |
169 | } | |
170 | if (withHid) di << " HiddenLines"; | |
171 | else di << " no HiddenLines"; | |
172 | di << "\n"; | |
173 | if (withHLR) { | |
0d969553 | 174 | di << "Angle of discretization : "; |
c6541a0c | 175 | di << anglHLR * 180 / M_PI << " degrees" << "\n"; |
7fd59977 | 176 | } |
177 | } | |
178 | else di << " wireframe"; | |
179 | di << "\n"; | |
180 | return 0 ; | |
181 | } | |
182 | ||
183 | if (n == 2) { | |
184 | if (!strcasecmp(a[1],"nohlr")) withHLR = Standard_False; | |
185 | else if (!strcasecmp(a[1],"hlr" )) withHLR = Standard_True; | |
186 | else if (!strcasecmp(a[1],"nohid")) withHid = Standard_False; | |
187 | else if (!strcasecmp(a[1],"hid" )) { | |
188 | withHLR = Standard_True; | |
189 | withHid = Standard_True; | |
190 | } | |
191 | else if (!strcasecmp(a[1],"norg1")) { | |
192 | withRg1 = Standard_False; | |
193 | withRgN = Standard_False; | |
194 | } | |
195 | else if (!strcasecmp(a[1],"rg1" )) { | |
196 | withHLR = Standard_True; | |
197 | withRg1 = Standard_True; | |
198 | withRgN = Standard_False; | |
199 | } | |
200 | else if (!strcasecmp(a[1],"norgn")) { | |
201 | withRgN = Standard_False; | |
202 | } | |
203 | else if (!strcasecmp(a[1],"rgn" )) { | |
204 | withHLR = Standard_True; | |
205 | withRg1 = Standard_True; | |
206 | withRgN = Standard_True; | |
207 | } | |
208 | else if (!strcasecmp(a[1],"ang" )) { | |
209 | di << "Angle de discretisation : "; | |
c6541a0c | 210 | di << anglHLR * 180 / M_PI << " degres" << "\n"; |
7fd59977 | 211 | } |
212 | else return 1; | |
213 | } | |
214 | ||
215 | Standard_Integer nFirst = 2; | |
216 | ||
217 | if (n >= 3 && !strcasecmp(a[1],"ang" )) { | |
218 | nFirst = 3; | |
219 | if (n == 3) { | |
220 | Standard_Real ang = atof(a[2]); | |
c6541a0c | 221 | anglHLR = ang * M_PI / 180; |
7fd59977 | 222 | if (anglHLR < HAngMin) anglHLR = HAngMin; |
223 | if (anglHLR > HAngMax) anglHLR = HAngMax; | |
224 | } | |
0d969553 | 225 | di << "Angle of discretization : "; |
c6541a0c | 226 | di << anglHLR * 180 / M_PI << " degrees" << "\n"; |
7fd59977 | 227 | } |
228 | ||
229 | if (n >= nFirst + 1) { | |
230 | ||
231 | for (Standard_Integer i = nFirst ; i < n; i++) { | |
232 | Handle (Draw_Drawable3D) D = Draw::Get (a[i]) ; | |
233 | if (!D.IsNull()) { | |
234 | Handle (DBRep_DrawableShape) S = | |
235 | Handle (DBRep_DrawableShape)::DownCast (D) ; | |
236 | if (!S.IsNull()) { | |
237 | Standard_Boolean localHLR, localRg1, localRgN, localHid; | |
238 | Standard_Real localAng; | |
239 | S->GetDisplayHLR(localHLR, localRg1, localRgN, localHid, | |
240 | localAng); | |
241 | if (!strcasecmp(a[1],"nohlr")) localHLR = Standard_False; | |
242 | else if (!strcasecmp(a[1],"hlr" )) localHLR = Standard_True; | |
243 | else if (!strcasecmp(a[1],"nohid")) localHid = Standard_False; | |
244 | else if (!strcasecmp(a[1],"hid" )) { | |
245 | localHLR = Standard_True; | |
246 | localHid = Standard_True; | |
247 | } | |
248 | else if (!strcasecmp(a[1],"norg1")) { | |
249 | localRg1 = Standard_False; | |
250 | localRgN = Standard_False; | |
251 | } | |
252 | else if (!strcasecmp(a[1],"rg1" )) { | |
253 | localHLR = Standard_True; | |
254 | localRg1 = Standard_True; | |
255 | localRgN = Standard_False; | |
256 | } | |
257 | else if (!strcasecmp(a[1],"norgn")) { | |
258 | localRgN = Standard_False; | |
259 | } | |
260 | else if (!strcasecmp(a[1],"rgn" )) { | |
261 | localHLR = Standard_True; | |
262 | localRg1 = Standard_True; | |
263 | localRgN = Standard_True; | |
264 | } | |
265 | else if (!strcasecmp(a[1],"ang" )) { | |
266 | Standard_Real ang = atof(a[2]); | |
c6541a0c | 267 | localAng = ang * M_PI / 180; |
7fd59977 | 268 | } |
269 | else return 1; | |
270 | S->DisplayHLR(localHLR, localRg1, localRgN, localHid, | |
271 | localAng); | |
272 | } | |
273 | } | |
274 | } | |
275 | } | |
276 | dout.RepaintAll() ; | |
277 | ||
278 | return 0 ; | |
279 | } | |
280 | ||
281 | ||
282 | //======================================================================= | |
283 | // dispor, dispcon | |
284 | //======================================================================= | |
285 | ||
286 | static Standard_Integer dispor (Draw_Interpretor& , | |
287 | Standard_Integer n, const char** a) | |
288 | { | |
289 | Standard_Boolean d = !strcasecmp(a[0],"vori"); | |
290 | ||
291 | if (d) | |
292 | DBRep_WriteColorOrientation(); | |
293 | ||
294 | Standard_Integer i; | |
295 | for (i = 1; i < n; i++) { | |
296 | Handle(Draw_Drawable3D) d1 = Draw::Get(a[i]); | |
297 | if (!d1.IsNull()) { | |
298 | Handle(DBRep_DrawableShape) d2 = | |
299 | Handle(DBRep_DrawableShape)::DownCast(d1); | |
300 | if (!d2.IsNull()) { | |
301 | d2->DisplayOrientation(d); | |
302 | Draw::Repaint(); | |
303 | } | |
304 | } | |
305 | } | |
306 | return 0; | |
307 | } | |
308 | ||
309 | //======================================================================= | |
310 | // discretisation | |
311 | //======================================================================= | |
312 | ||
313 | static Standard_Integer discretisation(Draw_Interpretor& di, | |
314 | Standard_Integer n, const char** a) | |
315 | { | |
316 | if (n <= 1) | |
317 | di << "Current number of points : "<<discret<<"\n"; | |
318 | else { | |
319 | discret = atoi(a[1]); | |
320 | } | |
321 | return 0; | |
322 | } | |
323 | ||
324 | ||
325 | //======================================================================= | |
326 | // triangles | |
327 | //======================================================================= | |
328 | ||
329 | static Standard_Integer triangles(Draw_Interpretor& , | |
330 | Standard_Integer n, const char** a) | |
331 | { | |
332 | if (n < 1) return 1; | |
333 | ||
334 | if (n == 1) { | |
335 | disptriangles = !disptriangles; | |
336 | #ifdef DEB | |
337 | if (disptriangles) cout <<"Triangulations are always displayed"<<endl; | |
338 | else cout <<"Triangulations are displayed only if there is no geometric representation"<<endl; | |
339 | #endif | |
340 | } | |
341 | else { | |
342 | Standard_Integer i; | |
343 | for (i = 1; i <= n-1; i++) { | |
344 | Handle(Draw_Drawable3D) d1 = Draw::Get(a[i]); | |
345 | if (!d1.IsNull()) { | |
346 | Handle(DBRep_DrawableShape) d2 = | |
347 | Handle(DBRep_DrawableShape)::DownCast(d1); | |
348 | if (!d2.IsNull()) { | |
349 | d2->DisplayTriangulation(!(d2->DisplayTriangulation())); | |
350 | } | |
351 | } | |
352 | } | |
353 | } | |
354 | ||
355 | Draw::Repaint(); | |
356 | return 0; | |
357 | } | |
358 | ||
359 | //======================================================================= | |
360 | // tclean | |
361 | //======================================================================= | |
362 | ||
363 | static Standard_Integer tclean(Draw_Interpretor& , | |
364 | Standard_Integer n, const char** a) | |
365 | { | |
366 | if (n < 1) return 1; | |
367 | ||
368 | for (Standard_Integer i = 1; i < n; i++) { | |
369 | TopoDS_Shape S = DBRep::Get(a[i]); | |
370 | BRepTools::Clean(S); | |
371 | } | |
372 | return 0; | |
373 | } | |
374 | ||
375 | //======================================================================= | |
376 | // polygons | |
377 | //======================================================================= | |
378 | ||
379 | static Standard_Integer polygons(Draw_Interpretor& , | |
380 | Standard_Integer n, const char** a) | |
381 | { | |
382 | if (n < 1) return 1; | |
383 | ||
384 | if (n == 1) { | |
385 | disppolygons = !disppolygons; | |
386 | #ifdef DEB | |
387 | if (disppolygons) cout <<"Polygons are always displayed"<<endl; | |
388 | else cout <<"Polygons are displayed only if there is no geometric representation"<<endl; | |
389 | #endif | |
390 | } | |
391 | else { | |
392 | Standard_Integer i; | |
393 | for (i = 1; i <= n-1; i++) { | |
394 | Handle(Draw_Drawable3D) d1 = Draw::Get(a[i]); | |
395 | if (!d1.IsNull()) { | |
396 | Handle(DBRep_DrawableShape) d2 = | |
397 | Handle(DBRep_DrawableShape)::DownCast(d1); | |
398 | if (!d2.IsNull()) { | |
399 | d2->DisplayPolygons(!(d2->DisplayPolygons())); | |
400 | } | |
401 | } | |
402 | } | |
403 | } | |
404 | ||
405 | Draw::Repaint(); | |
406 | return 0; | |
407 | } | |
408 | ||
409 | ||
410 | //======================================================================= | |
411 | // compound | |
412 | //======================================================================= | |
413 | ||
414 | static Standard_Integer compound(Draw_Interpretor& , | |
415 | Standard_Integer n, const char** a) | |
416 | { | |
417 | if (n <= 1) return 1; | |
418 | BRep_Builder B; | |
419 | TopoDS_Compound C; | |
420 | B.MakeCompound(C); | |
421 | for (Standard_Integer i = 1; i < n-1; i++) { | |
422 | TopoDS_Shape S2 = DBRep::Get(a[i]); | |
423 | if (!S2.IsNull()) B.Add(C,S2); | |
424 | } | |
425 | DBRep::Set(a[n-1],C); | |
426 | return 0; | |
427 | } | |
428 | ||
429 | //======================================================================= | |
430 | // emptycopy | |
431 | //======================================================================= | |
432 | ||
433 | static Standard_Integer emptycopy(Draw_Interpretor& , | |
434 | Standard_Integer n, const char** a) | |
435 | { | |
436 | if (n <= 1) return 1; | |
437 | TopoDS_Shape S = DBRep::Get(a[(n == 2) ? 1 : 2]); | |
438 | if (S.IsNull()) return 1; | |
439 | S.EmptyCopy(); | |
440 | DBRep::Set(a[1],S); | |
441 | return 0; | |
442 | } | |
443 | ||
444 | //======================================================================= | |
445 | // add | |
446 | //======================================================================= | |
447 | ||
448 | static Standard_Integer add(Draw_Interpretor& , | |
449 | Standard_Integer n, const char** a) | |
450 | { | |
451 | if (n < 3) return 1; | |
452 | BRep_Builder B; | |
453 | TopoDS_Shape S1 = DBRep::Get(a[1]); | |
454 | if (S1.IsNull()) return 1; | |
455 | TopoDS_Shape S2 = DBRep::Get(a[2]); | |
456 | if (S2.IsNull()) return 1; | |
457 | B.Add(S2,S1); | |
458 | DBRep::Set(a[2],S2); | |
459 | return 0; | |
460 | } | |
461 | ||
462 | //======================================================================= | |
463 | // explode | |
464 | //======================================================================= | |
465 | ||
466 | static Standard_Integer explode(Draw_Interpretor& di, | |
467 | Standard_Integer n, const char** a) | |
468 | { | |
469 | if (n <= 1) return 1; | |
470 | TopoDS_Shape S = DBRep::Get(a[1]); | |
471 | if (S.IsNull()) return 0; | |
472 | char newname[1024]; | |
473 | strcpy(newname,a[1]); | |
474 | char* p = newname; | |
475 | while (*p != '\0') p++; | |
476 | *p = '_'; | |
477 | p++; | |
478 | Standard_Integer i = 0; | |
479 | if (n == 2) { | |
480 | TopoDS_Iterator itr(S); | |
481 | while (itr.More()) { | |
482 | i++; | |
483 | sprintf(p,"%d",i); | |
484 | DBRep::Set(newname,itr.Value()); | |
485 | di.AppendElement(newname); | |
486 | itr.Next(); | |
487 | } | |
488 | } | |
489 | else { | |
490 | // explode a type | |
491 | TopAbs_ShapeEnum typ; | |
492 | switch (a[2][0]) { | |
493 | ||
494 | case 'C' : | |
495 | case 'c' : | |
496 | if ((a[2][1] == 'd')||(a[2][1] == 'D')) | |
497 | typ = TopAbs_COMPOUND; | |
498 | else | |
499 | typ = TopAbs_COMPSOLID; | |
500 | break; | |
501 | ||
502 | case 'S' : | |
503 | case 's' : | |
504 | if ((a[2][1] == 'O')||(a[2][1] == 'o')) | |
505 | typ = TopAbs_SOLID; | |
506 | else if ((a[2][1] == 'H')||(a[2][1] == 'h')) | |
507 | typ = TopAbs_SHELL; | |
508 | else | |
509 | return 1; | |
510 | break; | |
511 | ||
512 | case 'F' : | |
513 | case 'f' : | |
514 | typ = TopAbs_FACE; | |
515 | break; | |
516 | ||
517 | case 'W' : | |
518 | case 'w' : | |
519 | typ = TopAbs_WIRE; | |
520 | break; | |
521 | ||
522 | case 'E' : | |
523 | case 'e' : | |
524 | typ = TopAbs_EDGE; | |
525 | break; | |
526 | ||
527 | case 'V' : | |
528 | case 'v' : | |
529 | typ = TopAbs_VERTEX; | |
530 | break; | |
531 | ||
532 | default : | |
533 | return 1; | |
534 | } | |
535 | ||
536 | TopTools_MapOfShape M; | |
537 | M.Add(S); | |
538 | TopExp_Explorer ex(S,typ); | |
539 | for (; ex.More(); ex.Next()) { | |
540 | const TopoDS_Shape& Sx = ex.Current(); | |
541 | Standard_Boolean added = M.Add(Sx); | |
542 | if (added) { | |
543 | i++; | |
544 | sprintf(p,"%d",i); | |
545 | DBRep::Set(newname,Sx); | |
546 | di.AppendElement(newname); | |
547 | } | |
548 | } | |
549 | } | |
550 | return 0; | |
551 | } | |
552 | ||
553 | //======================================================================= | |
554 | // nexplode : stable numbered explode (from Serguey Nizhny) | |
555 | //======================================================================= | |
556 | ||
557 | static Standard_Integer nexplode(Draw_Interpretor& di, | |
558 | Standard_Integer n, const char** a) | |
559 | { | |
560 | if (n <= 2) return 1; | |
561 | TopoDS_Shape S = DBRep::Get(a[1]); | |
562 | if (S.IsNull()) return 0; | |
563 | char newname[1024]; | |
564 | strcpy(newname,a[1]); | |
565 | char* p = newname; | |
566 | while (*p != '\0') p++; | |
567 | *p = '_'; | |
568 | p++; | |
569 | TopAbs_ShapeEnum typ; | |
570 | // explode a type | |
571 | switch (a[2][0]) { | |
572 | case 'F' : | |
573 | case 'f' : | |
574 | typ = TopAbs_FACE; | |
575 | break; | |
576 | ||
577 | case 'E' : | |
578 | case 'e' : | |
579 | typ = TopAbs_EDGE; | |
580 | break; | |
581 | ||
582 | default : | |
583 | return 1; | |
584 | } | |
585 | TopTools_IndexedMapOfShape IMOStmp; | |
586 | TopTools_MapOfShape MShape; | |
587 | IMOStmp.Add(S); | |
588 | TopExp::MapShapes(S,typ,IMOStmp); | |
589 | TopExp_Explorer Exp(S,typ); | |
590 | Standard_Integer MaxShapes, Index = 0; | |
591 | MaxShapes = IMOStmp.Extent()-1; | |
592 | TopTools_Array1OfShape aShapes(1,MaxShapes); | |
593 | ||
594 | // explode | |
595 | while (Exp.More()) { | |
596 | if (MShape.Add(Exp.Current())) { | |
597 | Index++; | |
598 | aShapes.SetValue(Index,Exp.Current()); | |
599 | } | |
600 | Exp.Next(); | |
601 | } | |
602 | ||
603 | TColStd_Array1OfInteger OrderInd(1,MaxShapes); | |
604 | // gp_Pnt GPoint; | |
605 | GProp_GProps GPr; | |
606 | // Standard_Integer InOfminX = 1,aTemp; | |
607 | Standard_Integer aTemp; | |
608 | TColStd_Array1OfReal MidXYZ(1,MaxShapes); //X,Y,Z; | |
609 | Standard_Boolean NoSort = Standard_True; | |
610 | ||
611 | // Computing of CentreOfMass | |
612 | for (Index=1; Index <= MaxShapes; Index++) { | |
613 | OrderInd.SetValue(Index,Index); | |
614 | BRepGProp::LinearProperties(aShapes(Index),GPr); | |
615 | gp_Pnt GPoint = GPr.CentreOfMass(); | |
616 | MidXYZ.SetValue(Index, GPoint.X()*999 + GPoint.Y()*99 + | |
617 | GPoint.Z()*0.9); | |
618 | } | |
619 | // Sorting | |
620 | while(NoSort) { | |
621 | NoSort = Standard_False; | |
622 | for (Index=1; Index < MaxShapes; Index++) { | |
623 | if (MidXYZ(OrderInd(Index)) > MidXYZ(OrderInd(Index+1))) { | |
624 | aTemp = OrderInd(Index); | |
625 | OrderInd(Index) = OrderInd(Index+1); | |
626 | OrderInd(Index+1) = aTemp; | |
627 | NoSort = Standard_True; | |
628 | } | |
629 | } | |
630 | } | |
631 | // Check of equality of MidXYZ | |
632 | for (Index=1; Index < MaxShapes; Index++) { | |
633 | if (MidXYZ(OrderInd(Index+1)) == MidXYZ(OrderInd(Index))) | |
634 | di<<"Warning! For this shape the results may be incorrect."<<"\n"; | |
635 | } | |
636 | ||
637 | for (Index=1 ;Index <= MaxShapes; Index++) { | |
638 | sprintf(p,"%d",Index); | |
639 | DBRep::Set(newname,aShapes(OrderInd(Index))); | |
640 | di.AppendElement(newname); | |
641 | } | |
642 | ||
643 | return 0; | |
644 | } | |
645 | ||
646 | //======================================================================= | |
647 | // exwire | |
648 | //======================================================================= | |
649 | ||
650 | static Standard_Integer exwire(Draw_Interpretor& , | |
651 | Standard_Integer n, const char** a) | |
652 | { | |
653 | if (n <= 1) return 1; | |
654 | TopoDS_Shape S = DBRep::Get(a[1]); | |
655 | if (S.IsNull()) return 0; | |
656 | if (S.ShapeType() != TopAbs_WIRE) return 0; | |
657 | char newname[1024]; | |
658 | strcpy(newname,a[1]); | |
659 | char* p = newname; | |
660 | while (*p != '\0') p++; | |
661 | *p = '_'; | |
662 | p++; | |
663 | Standard_Integer i = 0; | |
664 | BRepTools_WireExplorer ex(TopoDS::Wire(S)); | |
665 | while (ex.More()) { | |
666 | i++; | |
667 | sprintf(p,"%d",i); | |
668 | DBRep::Set(newname,ex.Current()); | |
669 | ex.Next(); | |
670 | } | |
671 | return 0; | |
672 | } | |
673 | ||
674 | //======================================================================= | |
675 | // invert | |
676 | //======================================================================= | |
677 | ||
678 | static Standard_Integer invert(Draw_Interpretor& , | |
679 | Standard_Integer n, const char** a) | |
680 | { | |
681 | if (n <= 1) return 1; | |
682 | TopoDS_Shape S = DBRep::Get(a[1]); | |
683 | if (S.IsNull()) return 0; | |
684 | ||
685 | BRep_Builder B; | |
686 | TopoDS_Shape NS = S.EmptyCopied(); | |
687 | TopoDS_Iterator itr(S); | |
688 | ||
689 | while (itr.More()) { | |
690 | B.Add(NS,itr.Value().Reversed()); | |
691 | itr.Next(); | |
692 | } | |
693 | DBRep::Set(a[1],NS); | |
694 | ||
695 | return 0; | |
696 | } | |
697 | ||
698 | //======================================================================= | |
699 | // orientation, reverse, complement | |
700 | //======================================================================= | |
701 | ||
702 | static Standard_Integer orientation(Draw_Interpretor& , | |
703 | Standard_Integer n, const char** a) | |
704 | { | |
705 | if (n <= 1) return 1; | |
706 | Standard_Integer cas = 0; | |
707 | #ifdef DEB | |
708 | TopAbs_Orientation ori; | |
709 | #else | |
710 | TopAbs_Orientation ori=TopAbs_FORWARD; | |
711 | #endif | |
712 | Standard_Integer last = n; | |
713 | if (!strcasecmp(a[0],"orientation")) { | |
714 | if (n <= 2) return 1; | |
715 | last--; | |
716 | switch (*a[n-1]) { | |
717 | ||
718 | case 'F' : | |
719 | ori = TopAbs_FORWARD; | |
720 | break; | |
721 | ||
722 | case 'R' : | |
723 | ori = TopAbs_REVERSED; | |
724 | break; | |
725 | ||
726 | case 'I' : | |
727 | ori = TopAbs_INTERNAL; | |
728 | break; | |
729 | ||
730 | case 'E' : | |
731 | ori = TopAbs_EXTERNAL; | |
732 | break; | |
733 | } | |
734 | } | |
735 | ||
736 | else if (!strcasecmp(a[0],"treverse")) { | |
737 | cas = -1; | |
738 | } | |
739 | ||
740 | else if (!strcasecmp(a[0],"complement")) { | |
741 | cas = -2; | |
742 | } | |
743 | ||
744 | for (Standard_Integer i = 1; i < last; i++) { | |
745 | TopoDS_Shape S = DBRep::Get(a[i]); | |
746 | if (!S.IsNull()) { | |
747 | if (cas == -2) | |
748 | S.Complement(); | |
749 | else if (cas == -1) | |
750 | S.Reverse(); | |
751 | else | |
752 | S.Orientation(ori); | |
753 | DBRep::Set(a[i],S); | |
754 | } | |
755 | } | |
756 | return 0; | |
757 | } | |
758 | ||
759 | #include <TCollection_AsciiString.hxx> | |
760 | ||
761 | //======================================================================= | |
0d969553 | 762 | // numshapes same as nbshapes but the output is cout |
7fd59977 | 763 | //======================================================================= |
764 | ||
765 | static Standard_Integer numshapes(Draw_Interpretor& di, | |
766 | Standard_Integer n, const char** a) | |
767 | { | |
768 | if (n < 2) return 1; | |
769 | ||
770 | Standard_Integer i; | |
771 | TopExp_Explorer ex; | |
772 | for (i = 1; i < n; i++) { | |
773 | TopoDS_Shape S = DBRep::Get(a[i]); | |
774 | if (!S.IsNull()) { | |
775 | BRepTools_ShapeSet BS; | |
776 | BS.Add(S); | |
777 | di <<"Number of shapes in "<<a[i]<<"\n"; | |
778 | TCollection_AsciiString Astr; | |
779 | BS.DumpExtent(Astr); | |
780 | di <<Astr.ToCString(); | |
781 | di << "\n" ; | |
782 | } | |
783 | } | |
784 | ||
785 | return 0; | |
786 | } | |
787 | ||
788 | //======================================================================= | |
789 | // nbshapes | |
790 | //======================================================================= | |
791 | ||
792 | static Standard_Integer nbshapes(Draw_Interpretor& di, | |
793 | Standard_Integer n, const char** a) | |
794 | { | |
795 | if (n < 2) return 1; | |
796 | ||
797 | Standard_Integer i; | |
798 | TopExp_Explorer ex; | |
799 | for (i = 1; i < n; i++) { | |
800 | TopoDS_Shape S = DBRep::Get(a[i]); | |
801 | if (!S.IsNull()) { | |
802 | BRepTools_ShapeSet BS; | |
803 | BS.Add(S); | |
804 | di<<"Number of shapes in "<<a[i]<<"\n"; | |
805 | TCollection_AsciiString Astr; | |
806 | BS.DumpExtent(Astr); | |
807 | di<<Astr.ToCString(); | |
808 | } | |
809 | } | |
810 | ||
811 | return 0; | |
812 | } | |
813 | ||
814 | //======================================================================= | |
815 | // | |
816 | //======================================================================= | |
817 | ||
818 | static Standard_Integer countshapes(Draw_Interpretor& di, | |
819 | Standard_Integer n, const char** a) | |
820 | { | |
821 | if (n < 2) return 1; | |
822 | ||
823 | Standard_Integer i; | |
824 | TopExp_Explorer ex; | |
825 | for (i = 1; i < n; i++) { | |
826 | TopoDS_Shape Sh = DBRep::Get(a[i]); | |
827 | Standard_Integer nbElem = 0; | |
828 | if (!Sh.IsNull()) { | |
829 | di <<"Number of shapes in "<<a[i]<<"\n"; | |
830 | TopTools_MapOfShape M; | |
831 | ||
832 | for (ex.Init (Sh,TopAbs_VERTEX); ex.More(); ex.Next()) { | |
833 | const TopoDS_Shape& S = ex.Current(); | |
834 | Standard_Boolean added = M.Add(S); | |
835 | if (added) { | |
836 | nbElem++; | |
837 | } | |
838 | } | |
839 | di << " VERTEX : " << nbElem << "\n"; | |
840 | nbElem = 0; | |
841 | ||
842 | for (ex.Init (Sh,TopAbs_EDGE); ex.More(); ex.Next()) { | |
843 | const TopoDS_Shape& S = ex.Current(); | |
844 | Standard_Boolean added = M.Add(S); | |
845 | if (added) { | |
846 | nbElem++; | |
847 | } | |
848 | } | |
849 | di << " EDGE : " << nbElem << "\n"; | |
850 | nbElem = 0; | |
851 | ||
852 | for (ex.Init (Sh,TopAbs_WIRE); ex.More(); ex.Next()) { | |
853 | const TopoDS_Shape& S = ex.Current(); | |
854 | Standard_Boolean added = M.Add(S); | |
855 | if (added) { | |
856 | nbElem++; | |
857 | } | |
858 | } | |
859 | di << " WIRE : " << nbElem << "\n"; | |
860 | nbElem = 0; | |
861 | ||
862 | for (ex.Init (Sh,TopAbs_FACE); ex.More(); ex.Next()) { | |
863 | const TopoDS_Shape& S = ex.Current(); | |
864 | Standard_Boolean added = M.Add(S); | |
865 | if (added) { | |
866 | nbElem++; | |
867 | } | |
868 | } | |
869 | di << " FACE : " << nbElem << "\n"; | |
870 | nbElem = 0; | |
871 | ||
872 | for (ex.Init (Sh,TopAbs_SHELL); ex.More(); ex.Next()) { | |
873 | const TopoDS_Shape& S = ex.Current(); | |
874 | Standard_Boolean added = M.Add(S); | |
875 | if (added) { | |
876 | nbElem++; | |
877 | } | |
878 | } | |
879 | di << " SHELL : " << nbElem << "\n"; | |
880 | nbElem = 0; | |
881 | ||
882 | for (ex.Init (Sh,TopAbs_SOLID); ex.More(); ex.Next()) { | |
883 | const TopoDS_Shape& S = ex.Current(); | |
884 | Standard_Boolean added = M.Add(S); | |
885 | if (added) { | |
886 | nbElem++; | |
887 | } | |
888 | } | |
889 | di << " SOLID : " << nbElem << "\n"; | |
890 | nbElem = 0; | |
891 | ||
892 | for (ex.Init (Sh,TopAbs_COMPSOLID); ex.More(); ex.Next()) { | |
893 | const TopoDS_Shape& S = ex.Current(); | |
894 | Standard_Boolean added = M.Add(S); | |
895 | if (added) { | |
896 | nbElem++; | |
897 | } | |
898 | } | |
899 | di << " COMPSOLID : " << nbElem << "\n"; | |
900 | nbElem = 0; | |
901 | ||
902 | for (ex.Init (Sh,TopAbs_COMPOUND); ex.More(); ex.Next()) { | |
903 | const TopoDS_Shape& S = ex.Current(); | |
904 | Standard_Boolean added = M.Add(S); | |
905 | if (added) { | |
906 | nbElem++; | |
907 | } | |
908 | } | |
909 | di << " COMPOUND : " << nbElem << "\n"; | |
910 | nbElem = 0; | |
911 | ||
912 | di << " SHAPE : " << M.Extent() << "\n"; | |
913 | di << "\n" ; | |
914 | } | |
915 | } | |
916 | ||
917 | return 0; | |
918 | } | |
919 | ||
920 | //======================================================================= | |
921 | //memory management | |
922 | //======================================================================= | |
923 | static Standard_Integer purgemmgt(Draw_Interpretor&, Standard_Integer , const char**) { | |
924 | Standard::Purge(); | |
925 | return 0; | |
926 | } | |
927 | //======================================================================= | |
928 | ||
929 | //======================================================================= | |
930 | // check | |
931 | //======================================================================= | |
932 | ||
933 | static Standard_Integer check(Draw_Interpretor& , | |
934 | Standard_Integer n, const char** a) | |
935 | { | |
936 | if (n < 2) return 1; | |
937 | ||
938 | Standard_Integer i; | |
939 | TopExp_Explorer ex; | |
940 | for (i = 1; i < n; i++) { | |
941 | TopoDS_Shape S = DBRep::Get(a[i]); | |
942 | TopoDS_Shape C; | |
943 | if (S.IsNull()) continue; | |
944 | for (ex.Init(S,TopAbs_FACE);ex.More();ex.Next()) { | |
945 | C = ex.Current(); | |
946 | C.Checked(Standard_False); | |
947 | BRepTools::Update(C); | |
948 | } | |
949 | } | |
950 | ||
951 | return 0; | |
952 | } | |
953 | ||
954 | //======================================================================= | |
955 | // normals | |
956 | //======================================================================= | |
957 | ||
958 | static Standard_Integer normals(Draw_Interpretor& di, | |
959 | Standard_Integer n, const char** a) | |
960 | { | |
961 | if (n <= 1) return 1; | |
962 | Standard_Real l = 1.; | |
963 | if (n > 2) | |
964 | l = atof(a[2]); | |
965 | ||
966 | TopoDS_Shape S = DBRep::Get(a[1]); | |
967 | if (S.IsNull()) return 1; | |
968 | ||
969 | DBRep_WriteColorOrientation(); | |
970 | ||
971 | gp_Pnt P1,P2; | |
972 | gp_Vec V,V1,V2; | |
973 | Draw_Color col; | |
974 | ||
975 | TopExp_Explorer ex(S,TopAbs_FACE); | |
976 | while (ex.More()) { | |
977 | ||
978 | const TopoDS_Face& F = TopoDS::Face(ex.Current()); | |
979 | ||
980 | // find the center of the minmax | |
981 | BRepAdaptor_Surface SF(F); | |
982 | ||
983 | Standard_Real u, v, x; | |
984 | ||
985 | u = SF.FirstUParameter(); | |
986 | x = SF.LastUParameter(); | |
987 | if (Precision::IsInfinite(u)) | |
988 | u = (Precision::IsInfinite(x)) ? 0. : x; | |
989 | else if (!Precision::IsInfinite(x)) | |
990 | u = (u+x) / 2.; | |
991 | ||
992 | v = SF.FirstVParameter(); | |
993 | x = SF.LastVParameter(); | |
994 | if (Precision::IsInfinite(v)) | |
995 | v = (Precision::IsInfinite(x)) ? 0. : x; | |
996 | else if (!Precision::IsInfinite(x)) | |
997 | v = (v+x) / 2.; | |
998 | ||
999 | SF.D1(u,v,P1,V1,V2); | |
1000 | V = V1.Crossed(V2); | |
1001 | x = V.Magnitude(); | |
1002 | if (x > 1.e-10) | |
1003 | V.Multiply(l/x); | |
1004 | else { | |
1005 | V.SetCoord(l/2.,0,0); | |
1006 | di << "Null normal"<< "\n"; | |
1007 | } | |
1008 | ||
1009 | P2 = P1; | |
1010 | P2.Translate(V); | |
1011 | ||
1012 | col = DBRep_ColorOrientation(F.Orientation()); | |
1013 | ||
1014 | Handle(Draw_Segment3D) seg = new Draw_Segment3D(P1,P2,col); | |
1015 | dout << seg; | |
1016 | ||
1017 | ||
1018 | ex.Next(); | |
1019 | } | |
1020 | return 0; | |
1021 | } | |
1022 | ||
1023 | ||
1024 | //======================================================================= | |
1025 | //function : Set | |
1026 | //purpose : | |
1027 | //======================================================================= | |
1028 | void DBRep::Set(const Standard_CString Name, const TopoDS_Shape& S) | |
1029 | { | |
1030 | Handle(DBRep_DrawableShape) D = | |
1031 | new DBRep_DrawableShape(S, | |
1032 | Draw_vert, | |
1033 | Draw_jaune, | |
1034 | Draw_rouge, | |
1035 | Draw_bleu, | |
1036 | size, | |
1037 | nbIsos, | |
1038 | discret); | |
1039 | D->DisplayTriangulation(disptriangles); | |
1040 | D->DisplayPolygons(disppolygons); | |
1041 | D->DisplayHLR(withHLR,withRg1,withRgN,withHid,anglHLR); | |
1042 | Draw::Set(Name,D); | |
1043 | } | |
1044 | //======================================================================= | |
1045 | //function : Get | |
1046 | //purpose : | |
1047 | //======================================================================= | |
1048 | TopoDS_Shape DBRep::Get(Standard_CString& name, | |
1049 | const TopAbs_ShapeEnum typ, | |
1050 | const Standard_Boolean complain) | |
1051 | { | |
1052 | Standard_Boolean pick = name[0] == '.'; | |
1053 | TopoDS_Shape S; | |
1054 | Handle(DBRep_DrawableShape) D; | |
1055 | Handle(Draw_Drawable3D) DD = Draw::Get(name,complain); | |
1056 | if (!DD.IsNull()) | |
1057 | D = Handle(DBRep_DrawableShape)::DownCast(DD); | |
1058 | if (!D.IsNull()) { | |
1059 | S = D->Shape(); | |
1060 | if (typ != TopAbs_SHAPE) { | |
1061 | if (typ != S.ShapeType()) { | |
1062 | // try to find prom pick | |
1063 | if (pick) { | |
1064 | Standard_Real u,v; | |
1065 | DBRep_DrawableShape::LastPick(S,u,v); | |
1066 | } | |
1067 | } | |
1068 | if (typ != S.ShapeType()) { | |
1069 | if (complain) { | |
1070 | cout << name << " is not a "; | |
1071 | TopAbs::Print(typ,cout); | |
1072 | cout << " but a "; | |
1073 | TopAbs::Print(S.ShapeType(),cout); | |
1074 | cout << endl; | |
1075 | } | |
1076 | S = TopoDS_Shape(); | |
1077 | } | |
1078 | } | |
1079 | } | |
1080 | return S; | |
1081 | } | |
1082 | ||
1083 | static Standard_Integer XProgress (Draw_Interpretor& di, Standard_Integer argc, const char **argv) | |
1084 | { | |
1085 | for ( Standard_Integer i=1; i < argc; i++ ) { | |
1086 | Standard_Boolean turn = Standard_True; | |
1087 | if ( argv[i][0] == '-' ) turn = Standard_False; | |
1088 | else if ( argv[i][0] != '+' ) continue; | |
1089 | if ( argv[i][1] == 't' ) Draw_ProgressIndicator::DefaultTextMode() = turn; | |
1090 | else if ( argv[i][1] == 'g' ) Draw_ProgressIndicator::DefaultGraphMode() = turn; | |
1091 | else if ( ! strcmp ( argv[i], "-stop" ) && i+1 < argc ) { | |
1092 | Draw_ProgressIndicator::StopIndicator() = atol(argv[++i]); | |
1093 | return 0; | |
1094 | } | |
1095 | } | |
1096 | di << "Progress Indicator defaults: text mode is "; | |
1097 | if ( Draw_ProgressIndicator::DefaultTextMode() ) { | |
1098 | di<<"ON"; | |
1099 | } else { | |
1100 | di<<"OFF"; | |
1101 | } | |
1102 | di<<", graphical mode is "; | |
1103 | if ( Draw_ProgressIndicator::DefaultGraphMode() ) { | |
1104 | di<<"ON"; | |
1105 | } else { | |
1106 | di<<"OFF"; | |
1107 | } | |
1108 | di<< "\n"; | |
1109 | return 0; | |
1110 | } | |
1111 | ||
1112 | //======================================================================= | |
1113 | //function : BasicCommands | |
1114 | //purpose : | |
1115 | //======================================================================= | |
1116 | ||
1117 | static Standard_Boolean done = Standard_False; | |
1118 | void DBRep::BasicCommands(Draw_Interpretor& theCommands) | |
1119 | { | |
1120 | if (done) return; | |
1121 | done = Standard_True; | |
1122 | Draw::Commands(theCommands); | |
1123 | ||
1124 | const char* g = "Basic shape commands"; | |
1125 | ||
1126 | theCommands.Add("isos","isos [name1 ...] [nbisos]",__FILE__,isos,g); | |
1127 | theCommands.Add("hlr" ,"[no]hlr, rg1, rgn, hid, ang",__FILE__,hlr ,g); | |
1128 | theCommands.Add("vori","vori [name1 ...], edges are colored by orientation (see vconn)",__FILE__,dispor,g); | |
1129 | theCommands.Add("triangles", "triangles [name1]..., display triangles of shapes if exists",__FILE__, triangles, g); | |
1130 | theCommands.Add("tclean", "tclean [name1]..., erase triangulations and polygons on triangulations from shapes",__FILE__, tclean, g); | |
1131 | theCommands.Add("polygons", "polygons [name1]..., display polygons of shapes if exists",__FILE__, polygons, g); | |
1132 | theCommands.Add("vconn","vconn [name1 ...] , edges are colored by number of faces (see vori)",__FILE__,dispor,g); | |
1133 | theCommands.Add("discretisation","discretisation [nbpoints]",__FILE__,discretisation,g); | |
1134 | theCommands.Add("compound","compound [name1 name2 ..] compound",__FILE__,compound,g); | |
1135 | theCommands.Add("add","add name1 name2",__FILE__,add,g); | |
1136 | theCommands.Add("explode","explode name [Cd/C/So/Sh/F/W/E/V]",__FILE__,explode,g); | |
1137 | theCommands.Add("nexplode","stable numbered explode for edge and face: nexplode name [F/E]",__FILE__,nexplode,g); | |
1138 | theCommands.Add("exwire","exwire wirename",__FILE__,exwire,g); | |
1139 | theCommands.Add("emptycopy","emptycopy [copyshape] originalshape",__FILE__,emptycopy,g); | |
1140 | theCommands.Add("check","check shape1 shape2 ...",__FILE__,check,g); | |
1141 | ||
1142 | theCommands.Add("orientation","orientation name1 name2.. F/R/E/I",__FILE__,orientation,g); | |
1143 | theCommands.Add("treverse","treverse name1 name2 ...",__FILE__,orientation,g); | |
1144 | theCommands.Add("complement","complement name1 name2 ...",__FILE__,orientation,g); | |
1145 | theCommands.Add("invert","invert name, reverse subshapes",__FILE__,invert,g); | |
1146 | theCommands.Add("normals","normals s (length = 10), disp normals",__FILE__,normals,g); | |
1147 | theCommands.Add("nbshapes","nbshapes s; size of shape",__FILE__,nbshapes,g); | |
1148 | theCommands.Add("numshapes","numshapes s; size of shape",__FILE__,numshapes,g); | |
1149 | theCommands.Add("countshapes","countshapes s; count of shape",__FILE__,countshapes,g); | |
1150 | ||
1151 | // theCommands.Add("dumpmmgt", | |
1152 | // "dump le contenu du gestionnaire de memoire",__FILE__,dumpmmgt,g); | |
1153 | theCommands.Add("purgemmgt", | |
0d969553 | 1154 | "returns the free memory from the system to the memory manager", |
7fd59977 | 1155 | __FILE__,purgemmgt,g); |
1156 | ||
1157 | // Add command for DRAW-specific ProgressIndicator | |
1158 | theCommands.Add ( "XProgress","XProgress [+|-t] [+|-g]: switch on/off textual and graphical mode of Progress Indicator",XProgress,"DE: General"); | |
1159 | } | |
1160 | ||
1161 | //======================================================================= | |
1162 | //function : HLRMode | |
1163 | //purpose : | |
1164 | //======================================================================= | |
1165 | ||
1166 | Standard_Boolean DBRep::HLRMode() | |
1167 | { return withHLR; } | |
1168 | ||
1169 | //======================================================================= | |
1170 | //function : Rg1Mode | |
1171 | //purpose : | |
1172 | //======================================================================= | |
1173 | ||
1174 | Standard_Boolean DBRep::Rg1Mode() | |
1175 | { return withRg1; } | |
1176 | ||
1177 | //======================================================================= | |
1178 | //function : RgNMode | |
1179 | //purpose : | |
1180 | //======================================================================= | |
1181 | ||
1182 | Standard_Boolean DBRep::RgNMode() | |
1183 | { return withRgN; } | |
1184 | ||
1185 | //======================================================================= | |
1186 | //function : HidMode | |
1187 | //purpose : | |
1188 | //======================================================================= | |
1189 | ||
1190 | Standard_Boolean DBRep::HidMode() | |
1191 | { return withHid; } | |
1192 | ||
1193 | //======================================================================= | |
1194 | //function : HLRAngle | |
1195 | //purpose : | |
1196 | //======================================================================= | |
1197 | ||
1198 | Standard_Real DBRep::HLRAngle() | |
1199 | { return anglHLR; } | |
1200 | ||
1201 | //======================================================================= | |
1202 | //function : | |
1203 | //purpose : save and restore shapes | |
1204 | //======================================================================= | |
1205 | ||
1206 | static Standard_Boolean stest(const Handle(Draw_Drawable3D)& d) | |
1207 | { | |
1208 | return d->IsInstance(STANDARD_TYPE(DBRep_DrawableShape)); | |
1209 | } | |
1210 | ||
1211 | static void ssave(const Handle(Draw_Drawable3D)&d, ostream& OS) | |
1212 | { | |
1213 | Handle(DBRep_DrawableShape) | |
1214 | N = Handle(DBRep_DrawableShape)::DownCast(d); | |
1215 | BRep_Builder B; | |
1216 | BRepTools_ShapeSet S(B); | |
1217 | if(!Draw::GetProgressBar().IsNull()) | |
1218 | S.SetProgress(Draw::GetProgressBar()); | |
1219 | S.Add(N->Shape()); | |
1220 | S.Write(OS); | |
1221 | if(!Draw::GetProgressBar().IsNull() && Draw::GetProgressBar()->UserBreak()) | |
1222 | return; | |
1223 | S.Write(N->Shape(),OS); | |
1224 | } | |
1225 | ||
1226 | static Handle(Draw_Drawable3D) srestore (istream& IS) | |
1227 | { | |
1228 | BRep_Builder B; | |
1229 | BRepTools_ShapeSet S(B); | |
1230 | if(!Draw::GetProgressBar().IsNull()) | |
1231 | S.SetProgress(Draw::GetProgressBar()); | |
1232 | S.Read(IS); | |
1233 | Handle(DBRep_DrawableShape) N; | |
1234 | if(!Draw::GetProgressBar().IsNull() && Draw::GetProgressBar()->UserBreak()) | |
1235 | return N; | |
1236 | TopoDS_Shape theShape; | |
1237 | S.Read(theShape,IS ); | |
1238 | N = new DBRep_DrawableShape(theShape, | |
1239 | Draw_vert, | |
1240 | Draw_jaune, | |
1241 | Draw_rouge, | |
1242 | Draw_bleu, | |
1243 | size, | |
1244 | nbIsos, | |
1245 | discret); | |
1246 | N->DisplayTriangulation(disptriangles); | |
1247 | N->DisplayPolygons(disppolygons); | |
1248 | N->DisplayHLR(withHLR,withRg1,withRgN,withHid,anglHLR); | |
1249 | ||
1250 | return N; | |
1251 | } | |
1252 | ||
1253 | ||
1254 | static Draw_SaveAndRestore ssr("DBRep_DrawableShape", | |
1255 | stest,ssave,srestore); | |
1256 | ||
1257 | ||
1258 | void dumps (const TopoDS_Shape& S) | |
1259 | { | |
1260 | BRepTools::Dump(S,cout); | |
1261 | } | |
1262 | ||
1263 | //======================================================================= | |
1264 | //function : NbIsos | |
1265 | //purpose : | |
1266 | //======================================================================= | |
1267 | ||
1268 | Standard_Integer DBRep::NbIsos() | |
1269 | { return nbIsos; } | |
1270 | ||
1271 | ||
1272 | //======================================================================= | |
1273 | //function : Discretisation | |
1274 | //purpose : | |
1275 | //======================================================================= | |
1276 | ||
1277 | Standard_Integer DBRep::Discretisation() | |
1278 | { return discret; } |