0026940: Visualization, TKOpenGl - capping plane should be applied to connected struc...
[occt.git] / src / SWDRAW / SWDRAW_ShapeExtend.cxx
CommitLineData
b311480e 1// Created on: 1999-03-09
2// Created by: data exchange team
3// Copyright (c) 1999-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
42cf5bc1 17
7fd59977 18#include <DBRep.hxx>
7fd59977 19#include <ShapeExtend_Explorer.hxx>
42cf5bc1 20#include <SWDRAW.hxx>
21#include <SWDRAW_ShapeExtend.hxx>
7fd59977 22#include <TopoDS_Shape.hxx>
42cf5bc1 23#include <TopTools_HSequenceOfShape.hxx>
7fd59977 24
25static Standard_Integer sortcompound (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
26{
27 Standard_CString arg1 = argv[1];
28 if (argc < 2) {
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";
33 return 0;
34 }
35 TopoDS_Shape Shape = DBRep::Get(arg1);
36 if (Shape.IsNull()) { di<<"Shape unknown : "<<arg1<<"\n"; return 1 /* Error */; }
37
38 if (argc < 4) {
39 ShapeExtend_Explorer sbx;
40 for (int i = 0; i < 2; i ++) {
41 TopAbs_ShapeEnum ts = sbx.ShapeType(Shape,i);
42 //cout<<" Type "<<(i ? " (via Compound) : " : "(True) : ");
43 if (i == 0) {
44 di<<" Type "<<"(True) : ";
45 } else {
46 di<<" Type "<<" (via Compound) : ";
47 }
48 switch (ts) {
49 case TopAbs_SHAPE : di<<"SHAPE (empty)"; break;
50 case TopAbs_VERTEX : di<<"VERTEX"; break;
51 case TopAbs_EDGE : di<<"EDGE"; break;
52 case TopAbs_WIRE : di<<"WIRE"; break;
53 case TopAbs_FACE : di<<"FACE"; break;
54 case TopAbs_SHELL : di<<"SHELL"; break;
55 case TopAbs_SOLID : di<<"SOLID"; break;
56 case TopAbs_COMPSOLID : di<<"COMPSOLID"; break;
57 case TopAbs_COMPOUND : di<<"COMPOUND"; if (i>0) di<<" (heterogeneous)"; break;
58 }
59 }
60 di<<"\n";
61 return 0;
62 }
63
64 TopAbs_ShapeEnum tse = TopAbs_COMPOUND;
65 char tsc = argv[3][0];
66 switch (tsc) {
67 case 'v' : tse = TopAbs_VERTEX; break;
68 case 'e' : tse = TopAbs_EDGE; break;
69 case 'w' : tse = TopAbs_WIRE; break;
70 case 'f' : tse = TopAbs_FACE; break;
71 case 's' : tse = TopAbs_SHELL;
72 if (argv[3][1] == 'o') tse = TopAbs_SOLID; break;
73 default : break;
74 }
75 Standard_Boolean modexp = Standard_False;
76 Standard_Boolean modcom = Standard_False;
77 if (argc > 4) {
78 switch (argv[4][0]) {
79 case 'e' : modexp = Standard_True; break;
80 case 'c' : modcom = Standard_True; break;
81 case 'x' : modexp = modcom = Standard_True; break;
82 default : break;
83 }
84 ShapeExtend_Explorer sbx;
85 Shape = sbx.SortedCompound (Shape,tse,modexp,modcom);
86 if ( Shape.IsNull()) { di<<"Empty result"<<"\n"; return 0; }
87 DBRep::Set(argv[2],Shape);
88 }
89 return 0; // Done
90}
91
92//=======================================================================
93//function : InitCommands
94//purpose :
95//=======================================================================
96
97 void SWDRAW_ShapeExtend::InitCommands(Draw_Interpretor& theCommands)
98{
99 static Standard_Integer initactor = 0;
100 if (initactor) return; initactor = 1;
101
102 Standard_CString g = SWDRAW::GroupName();
103 theCommands.Add ("sortcompound","shape_entree shape_result type=v-e-w-f-s-so [mode=n-e-c-x]",
104 __FILE__,sortcompound,g);
105}