2 // Created: Wed Jul 21 16:11:15 1993
3 // Author: Remi LEQUETTE
11 #include <DBRep_DrawableShape.hxx>
12 #include <Draw_Appli.hxx>
14 #include <Draw_Segment3D.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>
31 #include <TopTools_Array1OfShape.hxx>
32 #include <TColStd_Array1OfInteger.hxx>
34 #include <GProp_GProps.hxx>
35 #include <BRepGProp.hxx>
36 #include <TColStd_Array1OfReal.hxx>
37 #include <Draw_ProgressIndicator.hxx>
40 #include <Standard.hxx>
44 extern Draw_Viewer dout;
50 #define Characters(IArg) (strspn (Arg[IArg], "0123456789.+-eE") != strlen (Arg[IArg]))
51 #define Float(IArg) (strspn (Arg[IArg], "0123456789+-") != strlen (Arg[IArg]))
54 //==========================================
56 //==========================================
58 Standard_EXPORT void DBRep_WriteColorOrientation ()
60 cout << "\nrouge FORWARD";
61 cout << "\nbleu REVERSED";
62 cout << "\nrose EXTERNAL";
63 cout << "\norange INTERNAL"<<endl;
66 Standard_EXPORT Draw_Color DBRep_ColorOrientation (const TopAbs_Orientation Or)
75 case TopAbs_REVERSED :
79 case TopAbs_EXTERNAL :
83 case TopAbs_INTERNAL :
91 //==========================================
93 //==========================================
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;
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;
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;
108 //=======================================================================
110 //=======================================================================
112 static Standard_Integer isos (Draw_Interpretor& di,
113 Standard_Integer NbArg, const char **Arg)
118 di << "Current number of isos : " << nbIsos << "\n" ;
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]) ;
128 Change = Standard_True ;
133 di << "New current number of isos : " << nbIsos << "\n" ;
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()) {
142 Shape2->ChangeNbIsos (NbIsos) ;
144 di << "Number of isos for " << Arg[IArg] << " : " << Shape2->NbIsos() << "\n";
149 if (Change) dout.RepaintAll() ;
155 //=======================================================================
157 //=======================================================================
159 static Standard_Integer hlr (Draw_Interpretor& di,
160 Standard_Integer n, const char **a)
165 if (withRgN) di << " RgNLines";
167 if (withRg1) di << " Rg1Lines";
168 else di << " no RegLines";
170 if (withHid) di << " HiddenLines";
171 else di << " no HiddenLines";
174 di << "Angle of discretization : ";
175 di << anglHLR * 180 / M_PI << " degrees" << "\n";
178 else di << " wireframe";
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;
191 else if (!strcasecmp(a[1],"norg1")) {
192 withRg1 = Standard_False;
193 withRgN = Standard_False;
195 else if (!strcasecmp(a[1],"rg1" )) {
196 withHLR = Standard_True;
197 withRg1 = Standard_True;
198 withRgN = Standard_False;
200 else if (!strcasecmp(a[1],"norgn")) {
201 withRgN = Standard_False;
203 else if (!strcasecmp(a[1],"rgn" )) {
204 withHLR = Standard_True;
205 withRg1 = Standard_True;
206 withRgN = Standard_True;
208 else if (!strcasecmp(a[1],"ang" )) {
209 di << "Angle de discretisation : ";
210 di << anglHLR * 180 / M_PI << " degres" << "\n";
215 Standard_Integer nFirst = 2;
217 if (n >= 3 && !strcasecmp(a[1],"ang" )) {
220 Standard_Real ang = atof(a[2]);
221 anglHLR = ang * M_PI / 180;
222 if (anglHLR < HAngMin) anglHLR = HAngMin;
223 if (anglHLR > HAngMax) anglHLR = HAngMax;
225 di << "Angle of discretization : ";
226 di << anglHLR * 180 / M_PI << " degrees" << "\n";
229 if (n >= nFirst + 1) {
231 for (Standard_Integer i = nFirst ; i < n; i++) {
232 Handle (Draw_Drawable3D) D = Draw::Get (a[i]) ;
234 Handle (DBRep_DrawableShape) S =
235 Handle (DBRep_DrawableShape)::DownCast (D) ;
237 Standard_Boolean localHLR, localRg1, localRgN, localHid;
238 Standard_Real localAng;
239 S->GetDisplayHLR(localHLR, localRg1, localRgN, localHid,
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;
248 else if (!strcasecmp(a[1],"norg1")) {
249 localRg1 = Standard_False;
250 localRgN = Standard_False;
252 else if (!strcasecmp(a[1],"rg1" )) {
253 localHLR = Standard_True;
254 localRg1 = Standard_True;
255 localRgN = Standard_False;
257 else if (!strcasecmp(a[1],"norgn")) {
258 localRgN = Standard_False;
260 else if (!strcasecmp(a[1],"rgn" )) {
261 localHLR = Standard_True;
262 localRg1 = Standard_True;
263 localRgN = Standard_True;
265 else if (!strcasecmp(a[1],"ang" )) {
266 Standard_Real ang = atof(a[2]);
267 localAng = ang * M_PI / 180;
270 S->DisplayHLR(localHLR, localRg1, localRgN, localHid,
282 //=======================================================================
284 //=======================================================================
286 static Standard_Integer dispor (Draw_Interpretor& ,
287 Standard_Integer n, const char** a)
289 Standard_Boolean d = !strcasecmp(a[0],"vori");
292 DBRep_WriteColorOrientation();
295 for (i = 1; i < n; i++) {
296 Handle(Draw_Drawable3D) d1 = Draw::Get(a[i]);
298 Handle(DBRep_DrawableShape) d2 =
299 Handle(DBRep_DrawableShape)::DownCast(d1);
301 d2->DisplayOrientation(d);
309 //=======================================================================
311 //=======================================================================
313 static Standard_Integer discretisation(Draw_Interpretor& di,
314 Standard_Integer n, const char** a)
317 di << "Current number of points : "<<discret<<"\n";
319 discret = atoi(a[1]);
325 //=======================================================================
327 //=======================================================================
329 static Standard_Integer triangles(Draw_Interpretor& ,
330 Standard_Integer n, const char** a)
335 disptriangles = !disptriangles;
337 if (disptriangles) cout <<"Triangulations are always displayed"<<endl;
338 else cout <<"Triangulations are displayed only if there is no geometric representation"<<endl;
343 for (i = 1; i <= n-1; i++) {
344 Handle(Draw_Drawable3D) d1 = Draw::Get(a[i]);
346 Handle(DBRep_DrawableShape) d2 =
347 Handle(DBRep_DrawableShape)::DownCast(d1);
349 d2->DisplayTriangulation(!(d2->DisplayTriangulation()));
359 //=======================================================================
361 //=======================================================================
363 static Standard_Integer tclean(Draw_Interpretor& ,
364 Standard_Integer n, const char** a)
368 for (Standard_Integer i = 1; i < n; i++) {
369 TopoDS_Shape S = DBRep::Get(a[i]);
375 //=======================================================================
377 //=======================================================================
379 static Standard_Integer polygons(Draw_Interpretor& ,
380 Standard_Integer n, const char** a)
385 disppolygons = !disppolygons;
387 if (disppolygons) cout <<"Polygons are always displayed"<<endl;
388 else cout <<"Polygons are displayed only if there is no geometric representation"<<endl;
393 for (i = 1; i <= n-1; i++) {
394 Handle(Draw_Drawable3D) d1 = Draw::Get(a[i]);
396 Handle(DBRep_DrawableShape) d2 =
397 Handle(DBRep_DrawableShape)::DownCast(d1);
399 d2->DisplayPolygons(!(d2->DisplayPolygons()));
410 //=======================================================================
412 //=======================================================================
414 static Standard_Integer compound(Draw_Interpretor& ,
415 Standard_Integer n, const char** a)
417 if (n <= 1) return 1;
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);
425 DBRep::Set(a[n-1],C);
429 //=======================================================================
431 //=======================================================================
433 static Standard_Integer emptycopy(Draw_Interpretor& ,
434 Standard_Integer n, const char** a)
436 if (n <= 1) return 1;
437 TopoDS_Shape S = DBRep::Get(a[(n == 2) ? 1 : 2]);
438 if (S.IsNull()) return 1;
444 //=======================================================================
446 //=======================================================================
448 static Standard_Integer add(Draw_Interpretor& ,
449 Standard_Integer n, const char** a)
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;
462 //=======================================================================
464 //=======================================================================
466 static Standard_Integer explode(Draw_Interpretor& di,
467 Standard_Integer n, const char** a)
469 if (n <= 1) return 1;
470 TopoDS_Shape S = DBRep::Get(a[1]);
471 if (S.IsNull()) return 0;
473 strcpy(newname,a[1]);
475 while (*p != '\0') p++;
478 Standard_Integer i = 0;
480 TopoDS_Iterator itr(S);
484 DBRep::Set(newname,itr.Value());
485 di.AppendElement(newname);
491 TopAbs_ShapeEnum typ;
496 if ((a[2][1] == 'd')||(a[2][1] == 'D'))
497 typ = TopAbs_COMPOUND;
499 typ = TopAbs_COMPSOLID;
504 if ((a[2][1] == 'O')||(a[2][1] == 'o'))
506 else if ((a[2][1] == 'H')||(a[2][1] == 'h'))
536 TopTools_MapOfShape M;
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);
545 DBRep::Set(newname,Sx);
546 di.AppendElement(newname);
553 //=======================================================================
554 // nexplode : stable numbered explode (from Serguey Nizhny)
555 //=======================================================================
557 static Standard_Integer nexplode(Draw_Interpretor& di,
558 Standard_Integer n, const char** a)
560 if (n <= 2) return 1;
561 TopoDS_Shape S = DBRep::Get(a[1]);
562 if (S.IsNull()) return 0;
564 strcpy(newname,a[1]);
566 while (*p != '\0') p++;
569 TopAbs_ShapeEnum typ;
585 TopTools_IndexedMapOfShape IMOStmp;
586 TopTools_MapOfShape MShape;
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);
596 if (MShape.Add(Exp.Current())) {
598 aShapes.SetValue(Index,Exp.Current());
603 TColStd_Array1OfInteger OrderInd(1,MaxShapes);
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;
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 +
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;
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";
637 for (Index=1 ;Index <= MaxShapes; Index++) {
638 sprintf(p,"%d",Index);
639 DBRep::Set(newname,aShapes(OrderInd(Index)));
640 di.AppendElement(newname);
646 //=======================================================================
648 //=======================================================================
650 static Standard_Integer exwire(Draw_Interpretor& ,
651 Standard_Integer n, const char** a)
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;
658 strcpy(newname,a[1]);
660 while (*p != '\0') p++;
663 Standard_Integer i = 0;
664 BRepTools_WireExplorer ex(TopoDS::Wire(S));
668 DBRep::Set(newname,ex.Current());
674 //=======================================================================
676 //=======================================================================
678 static Standard_Integer invert(Draw_Interpretor& ,
679 Standard_Integer n, const char** a)
681 if (n <= 1) return 1;
682 TopoDS_Shape S = DBRep::Get(a[1]);
683 if (S.IsNull()) return 0;
686 TopoDS_Shape NS = S.EmptyCopied();
687 TopoDS_Iterator itr(S);
690 B.Add(NS,itr.Value().Reversed());
698 //=======================================================================
699 // orientation, reverse, complement
700 //=======================================================================
702 static Standard_Integer orientation(Draw_Interpretor& ,
703 Standard_Integer n, const char** a)
705 if (n <= 1) return 1;
706 Standard_Integer cas = 0;
708 TopAbs_Orientation ori;
710 TopAbs_Orientation ori=TopAbs_FORWARD;
712 Standard_Integer last = n;
713 if (!strcasecmp(a[0],"orientation")) {
714 if (n <= 2) return 1;
719 ori = TopAbs_FORWARD;
723 ori = TopAbs_REVERSED;
727 ori = TopAbs_INTERNAL;
731 ori = TopAbs_EXTERNAL;
736 else if (!strcasecmp(a[0],"treverse")) {
740 else if (!strcasecmp(a[0],"complement")) {
744 for (Standard_Integer i = 1; i < last; i++) {
745 TopoDS_Shape S = DBRep::Get(a[i]);
759 #include <TCollection_AsciiString.hxx>
761 //=======================================================================
762 // numshapes same as nbshapes but the output is cout
763 //=======================================================================
765 static Standard_Integer numshapes(Draw_Interpretor& di,
766 Standard_Integer n, const char** a)
772 for (i = 1; i < n; i++) {
773 TopoDS_Shape S = DBRep::Get(a[i]);
775 BRepTools_ShapeSet BS;
777 di <<"Number of shapes in "<<a[i]<<"\n";
778 TCollection_AsciiString Astr;
780 di <<Astr.ToCString();
788 //=======================================================================
790 //=======================================================================
792 static Standard_Integer nbshapes(Draw_Interpretor& di,
793 Standard_Integer n, const char** a)
799 for (i = 1; i < n; i++) {
800 TopoDS_Shape S = DBRep::Get(a[i]);
802 BRepTools_ShapeSet BS;
804 di<<"Number of shapes in "<<a[i]<<"\n";
805 TCollection_AsciiString Astr;
807 di<<Astr.ToCString();
814 //=======================================================================
816 //=======================================================================
818 static Standard_Integer countshapes(Draw_Interpretor& di,
819 Standard_Integer n, const char** a)
825 for (i = 1; i < n; i++) {
826 TopoDS_Shape Sh = DBRep::Get(a[i]);
827 Standard_Integer nbElem = 0;
829 di <<"Number of shapes in "<<a[i]<<"\n";
830 TopTools_MapOfShape M;
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);
839 di << " VERTEX : " << nbElem << "\n";
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);
849 di << " EDGE : " << nbElem << "\n";
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);
859 di << " WIRE : " << nbElem << "\n";
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);
869 di << " FACE : " << nbElem << "\n";
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);
879 di << " SHELL : " << nbElem << "\n";
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);
889 di << " SOLID : " << nbElem << "\n";
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);
899 di << " COMPSOLID : " << nbElem << "\n";
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);
909 di << " COMPOUND : " << nbElem << "\n";
912 di << " SHAPE : " << M.Extent() << "\n";
920 //=======================================================================
922 //=======================================================================
923 static Standard_Integer purgemmgt(Draw_Interpretor&, Standard_Integer , const char**) {
927 //=======================================================================
929 //=======================================================================
931 //=======================================================================
933 static Standard_Integer check(Draw_Interpretor& ,
934 Standard_Integer n, const char** a)
940 for (i = 1; i < n; i++) {
941 TopoDS_Shape S = DBRep::Get(a[i]);
943 if (S.IsNull()) continue;
944 for (ex.Init(S,TopAbs_FACE);ex.More();ex.Next()) {
946 C.Checked(Standard_False);
947 BRepTools::Update(C);
954 //=======================================================================
956 //=======================================================================
958 static Standard_Integer normals(Draw_Interpretor& di,
959 Standard_Integer n, const char** a)
961 if (n <= 1) return 1;
962 Standard_Real l = 1.;
966 TopoDS_Shape S = DBRep::Get(a[1]);
967 if (S.IsNull()) return 1;
969 DBRep_WriteColorOrientation();
975 TopExp_Explorer ex(S,TopAbs_FACE);
978 const TopoDS_Face& F = TopoDS::Face(ex.Current());
980 // find the center of the minmax
981 BRepAdaptor_Surface SF(F);
983 Standard_Real u, v, x;
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))
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))
1005 V.SetCoord(l/2.,0,0);
1006 di << "Null normal"<< "\n";
1012 col = DBRep_ColorOrientation(F.Orientation());
1014 Handle(Draw_Segment3D) seg = new Draw_Segment3D(P1,P2,col);
1024 //=======================================================================
1027 //=======================================================================
1028 void DBRep::Set(const Standard_CString Name, const TopoDS_Shape& S)
1030 Handle(DBRep_DrawableShape) D =
1031 new DBRep_DrawableShape(S,
1039 D->DisplayTriangulation(disptriangles);
1040 D->DisplayPolygons(disppolygons);
1041 D->DisplayHLR(withHLR,withRg1,withRgN,withHid,anglHLR);
1044 //=======================================================================
1047 //=======================================================================
1048 TopoDS_Shape DBRep::Get(Standard_CString& name,
1049 const TopAbs_ShapeEnum typ,
1050 const Standard_Boolean complain)
1052 Standard_Boolean pick = name[0] == '.';
1054 Handle(DBRep_DrawableShape) D;
1055 Handle(Draw_Drawable3D) DD = Draw::Get(name,complain);
1057 D = Handle(DBRep_DrawableShape)::DownCast(DD);
1060 if (typ != TopAbs_SHAPE) {
1061 if (typ != S.ShapeType()) {
1062 // try to find prom pick
1065 DBRep_DrawableShape::LastPick(S,u,v);
1068 if (typ != S.ShapeType()) {
1070 cout << name << " is not a ";
1071 TopAbs::Print(typ,cout);
1073 TopAbs::Print(S.ShapeType(),cout);
1083 static Standard_Integer XProgress (Draw_Interpretor& di, Standard_Integer argc, const char **argv)
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]);
1096 di << "Progress Indicator defaults: text mode is ";
1097 if ( Draw_ProgressIndicator::DefaultTextMode() ) {
1102 di<<", graphical mode is ";
1103 if ( Draw_ProgressIndicator::DefaultGraphMode() ) {
1112 //=======================================================================
1113 //function : BasicCommands
1115 //=======================================================================
1117 static Standard_Boolean done = Standard_False;
1118 void DBRep::BasicCommands(Draw_Interpretor& theCommands)
1121 done = Standard_True;
1122 Draw::Commands(theCommands);
1124 const char* g = "Basic shape commands";
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);
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);
1151 // theCommands.Add("dumpmmgt",
1152 // "dump le contenu du gestionnaire de memoire",__FILE__,dumpmmgt,g);
1153 theCommands.Add("purgemmgt",
1154 "returns the free memory from the system to the memory manager",
1155 __FILE__,purgemmgt,g);
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");
1161 //=======================================================================
1162 //function : HLRMode
1164 //=======================================================================
1166 Standard_Boolean DBRep::HLRMode()
1169 //=======================================================================
1170 //function : Rg1Mode
1172 //=======================================================================
1174 Standard_Boolean DBRep::Rg1Mode()
1177 //=======================================================================
1178 //function : RgNMode
1180 //=======================================================================
1182 Standard_Boolean DBRep::RgNMode()
1185 //=======================================================================
1186 //function : HidMode
1188 //=======================================================================
1190 Standard_Boolean DBRep::HidMode()
1193 //=======================================================================
1194 //function : HLRAngle
1196 //=======================================================================
1198 Standard_Real DBRep::HLRAngle()
1201 //=======================================================================
1203 //purpose : save and restore shapes
1204 //=======================================================================
1206 static Standard_Boolean stest(const Handle(Draw_Drawable3D)& d)
1208 return d->IsInstance(STANDARD_TYPE(DBRep_DrawableShape));
1211 static void ssave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1213 Handle(DBRep_DrawableShape)
1214 N = Handle(DBRep_DrawableShape)::DownCast(d);
1216 BRepTools_ShapeSet S(B);
1217 if(!Draw::GetProgressBar().IsNull())
1218 S.SetProgress(Draw::GetProgressBar());
1221 if(!Draw::GetProgressBar().IsNull() && Draw::GetProgressBar()->UserBreak())
1223 S.Write(N->Shape(),OS);
1226 static Handle(Draw_Drawable3D) srestore (istream& IS)
1229 BRepTools_ShapeSet S(B);
1230 if(!Draw::GetProgressBar().IsNull())
1231 S.SetProgress(Draw::GetProgressBar());
1233 Handle(DBRep_DrawableShape) N;
1234 if(!Draw::GetProgressBar().IsNull() && Draw::GetProgressBar()->UserBreak())
1236 TopoDS_Shape theShape;
1237 S.Read(theShape,IS );
1238 N = new DBRep_DrawableShape(theShape,
1246 N->DisplayTriangulation(disptriangles);
1247 N->DisplayPolygons(disppolygons);
1248 N->DisplayHLR(withHLR,withRg1,withRgN,withHid,anglHLR);
1254 static Draw_SaveAndRestore ssr("DBRep_DrawableShape",
1255 stest,ssave,srestore);
1258 void dumps (const TopoDS_Shape& S)
1260 BRepTools::Dump(S,cout);
1263 //=======================================================================
1266 //=======================================================================
1268 Standard_Integer DBRep::NbIsos()
1272 //=======================================================================
1273 //function : Discretisation
1275 //=======================================================================
1277 Standard_Integer DBRep::Discretisation()