0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / SWDRAW / SWDRAW_ShapeProcess.cxx
CommitLineData
b311480e 1// Created on: 1999-06-19
2// Created by: Andrey BETENEV
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
7fd59977 17
18#include <DBRep.hxx>
19#include <Draw_Interpretor.hxx>
7fd59977 20#include <ShapeProcess.hxx>
7fd59977 21#include <ShapeProcess_OperLibrary.hxx>
42cf5bc1 22#include <ShapeProcess_ShapeContext.hxx>
23#include <SWDRAW.hxx>
24#include <SWDRAW_ShapeProcess.hxx>
25#include <TopoDS_Shape.hxx>
7fd59977 26
27//=======================================================================
28//function : ApplySequence
29//purpose :
30//=======================================================================
7fd59977 31static Standard_Integer ApplySequence(Draw_Interpretor& di,
32 Standard_Integer argc, const char** argv)
33{
586db386 34 if (argc < 4) { di<<"Specify result, shape, resource name and prefix (optional)\n"; return 1 /* Error */; }
7fd59977 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() ) {
586db386 50 di << "No result\n";
7fd59977 51 }
52 else if ( result == Shape ) {
586db386 53 di << "Shape not modified\n";
7fd59977 54 }
55 DBRep::Set (arg1,result);
56 return 0;
57}
58
59//=======================================================================
60//function : InitCommands
61//purpose :
62//=======================================================================
63
64void SWDRAW_ShapeProcess::InitCommands(Draw_Interpretor& theCommands)
65{
66 static Standard_Boolean initactor = 0;
c48e2889 67 if (initactor)
68 {
69 return;
70 }
71 initactor = 1;
7fd59977 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}