1 // Created on: 1999-03-09
2 // Created by: data exchange team
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
19 #include <ShapeExtend_Explorer.hxx>
21 #include <SWDRAW_ShapeExtend.hxx>
22 #include <TopoDS_Shape.hxx>
23 #include <TopTools_HSequenceOfShape.hxx>
25 static Standard_Integer sortcompound (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
27 Standard_CString arg1 = argv[1];
29 di<<"Give shape name. As is, just displays shape type\n";
30 di<<" or add result_name type [mode]\n";
31 di<<" Type : v (vertex) e (edge) w (wire) f (face) s (shell) so (solid)\n";
32 di<<" Mode : n (normal, by default) e (explore) c (compound) x (explore+comp)\n";
35 TopoDS_Shape Shape = DBRep::Get(arg1);
36 if (Shape.IsNull()) { di<<"Shape unknown : "<<arg1<<"\n"; return 1 /* Error */; }
39 ShapeExtend_Explorer sbx;
40 for (int i = 0; i < 2; i ++) {
41 Standard_Boolean viaCompound = (i != 0);
42 TopAbs_ShapeEnum ts = sbx.ShapeType(Shape, viaCompound);
43 //std::cout<<" Type "<<(i ? " (via Compound) : " : "(True) : ");
45 di<<" Type (True) : ";
47 di<<" Type (via Compound) : ";
50 case TopAbs_SHAPE : di<<"SHAPE (empty)"; break;
51 case TopAbs_VERTEX : di<<"VERTEX"; break;
52 case TopAbs_EDGE : di<<"EDGE"; break;
53 case TopAbs_WIRE : di<<"WIRE"; break;
54 case TopAbs_FACE : di<<"FACE"; break;
55 case TopAbs_SHELL : di<<"SHELL"; break;
56 case TopAbs_SOLID : di<<"SOLID"; break;
57 case TopAbs_COMPSOLID : di<<"COMPSOLID"; break;
58 case TopAbs_COMPOUND : di<<"COMPOUND"; if (i>0) di<<" (heterogeneous)"; break;
65 TopAbs_ShapeEnum tse = TopAbs_COMPOUND;
66 char tsc = argv[3][0];
68 case 'v' : tse = TopAbs_VERTEX; break;
69 case 'e' : tse = TopAbs_EDGE; break;
70 case 'w' : tse = TopAbs_WIRE; break;
71 case 'f' : tse = TopAbs_FACE; break;
72 case 's' : tse = (argv[3][1] == 'o' ? TopAbs_SOLID : TopAbs_SHELL);
76 Standard_Boolean modexp = Standard_False;
77 Standard_Boolean modcom = Standard_False;
80 case 'e' : modexp = Standard_True; break;
81 case 'c' : modcom = Standard_True; break;
82 case 'x' : modexp = modcom = Standard_True; break;
85 ShapeExtend_Explorer sbx;
86 Shape = sbx.SortedCompound (Shape,tse,modexp,modcom);
87 if ( Shape.IsNull()) { di<<"Empty result\n"; return 0; }
88 DBRep::Set(argv[2],Shape);
93 //=======================================================================
94 //function : InitCommands
96 //=======================================================================
98 void SWDRAW_ShapeExtend::InitCommands(Draw_Interpretor& theCommands)
100 static Standard_Integer initactor = 0;
107 Standard_CString g = SWDRAW::GroupName();
108 theCommands.Add ("sortcompound","shape_entree shape_result type=v-e-w-f-s-so [mode=n-e-c-x]",
109 __FILE__,sortcompound,g);