0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / SWDRAW / SWDRAW_ShapeProcess.cxx
1 // Created on: 1999-06-19
2 // Created by: Andrey BETENEV
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <DBRep.hxx>
19 #include <Draw_Interpretor.hxx>
20 #include <ShapeProcess.hxx>
21 #include <ShapeProcess_OperLibrary.hxx>
22 #include <ShapeProcess_ShapeContext.hxx>
23 #include <SWDRAW.hxx>
24 #include <SWDRAW_ShapeProcess.hxx>
25 #include <TopoDS_Shape.hxx>
26
27 //=======================================================================
28 //function : ApplySequence
29 //purpose  : 
30 //=======================================================================
31 static Standard_Integer ApplySequence(Draw_Interpretor& di,
32                                       Standard_Integer argc, const char** argv)
33 {
34   if (argc < 4) { di<<"Specify result, shape, resource name and prefix (optional)\n"; return 1 /* Error */; }
35   Standard_CString arg1 = argv[1];
36   Standard_CString arg2 = argv[2];
37   Standard_CString arg3 = argv[3];
38   Standard_CString arg4 = "";
39   if (argc > 4) arg4 = argv[4];
40   TopoDS_Shape Shape = DBRep::Get(arg2);
41   if (Shape.IsNull()) { di<<"Shape unknown : "<<arg2<<"\n"; return 1 /* Error */; }
42
43   Handle(ShapeProcess_ShapeContext) context = new ShapeProcess_ShapeContext (Shape, arg3);
44   ShapeProcess::Perform ( context, arg4 );
45   context->PrintStatistics();
46   
47   TopoDS_Shape result = context->Result();
48 //  seq.PrintPreparationResult ();
49   if ( result.IsNull() ) {
50     di << "No result\n";
51   }
52   else if ( result == Shape ) {
53     di << "Shape not modified\n";
54   }
55   DBRep::Set (arg1,result);
56   return 0;
57 }
58   
59 //=======================================================================
60 //function : InitCommands
61 //purpose  : 
62 //=======================================================================
63
64 void SWDRAW_ShapeProcess::InitCommands(Draw_Interpretor& theCommands) 
65 {
66   static Standard_Boolean initactor = 0;
67   if (initactor)
68   {
69     return;
70   }
71   initactor = 1;
72   
73   ShapeProcess_OperLibrary::Init();
74   
75   Standard_CString g = SWDRAW::GroupName(); // "Tests of DivideTool";
76  
77   theCommands.Add ("SPApply","SPApply result shape rscfilename [sequence]",
78                    __FILE__,ApplySequence,g);
79 }