0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / TopOpeBRepTool / TopOpeBRepTool_STATE.cxx
1 // Created on: 1997-10-22
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1997-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 #ifdef OCCT_DEBUG
18
19 #include <TopOpeBRepTool_STATE.hxx>
20
21 TopOpeBRepTool_STATE::TopOpeBRepTool_STATE
22   (const char* name, const Standard_Boolean b) :
23   myin(Standard_False),myout(Standard_False),
24   myon(Standard_False),myunknown(Standard_False),
25   myonetrue(Standard_False)
26
27   strcpy(myname,name);
28   Set(b);
29 }
30
31 void TopOpeBRepTool_STATE::Set(const Standard_Boolean b)
32 {
33   Set(TopAbs_IN,b); 
34   Set(TopAbs_OUT,b);
35   Set(TopAbs_ON,b); 
36   Set(TopAbs_UNKNOWN,b);
37 }
38
39 void TopOpeBRepTool_STATE::Set
40   (const TopAbs_State S,const Standard_Boolean b)
41 {
42   switch(S) {
43   case TopAbs_IN : myin = b; break;
44   case TopAbs_OUT : myout = b; break;
45   case TopAbs_ON : myon = b; break;
46   case TopAbs_UNKNOWN : myunknown = b; break;
47   }
48   myonetrue = myin || myout || myon || myunknown;
49 }
50
51 void TopOpeBRepTool_STATE::Set(const Standard_Boolean b,
52                                Standard_Integer n, char** a)
53
54   if (!n) Set(b);
55   else {
56     Set(Standard_False);
57     for (Standard_Integer i=0; i < n; i++) {
58       const char *p = a[i];
59       if      ( !strcmp(p,"IN") )      Set(TopAbs_IN,b);
60       else if ( !strcmp(p,"OUT") )     Set(TopAbs_OUT,b);
61       else if ( !strcmp(p,"ON") )      Set(TopAbs_ON,b);
62       else if ( !strcmp(p,"UNKNOWN") ) Set(TopAbs_UNKNOWN,b);
63     }
64     Print();
65   }
66 }
67
68 Standard_Boolean TopOpeBRepTool_STATE::Get(const TopAbs_State S)
69 {
70   Standard_Boolean b = Standard_False;
71   switch(S) {
72   case TopAbs_IN : b = myin; break;
73   case TopAbs_OUT : b = myout; break;
74   case TopAbs_ON : b = myon; break;
75   case TopAbs_UNKNOWN : b = myunknown; break;
76   }
77   return b;
78 }
79
80 void TopOpeBRepTool_STATE::Print()
81 {
82   std::cout<<myname<<" : ";
83   std::cout<<"IN/OUT/ON/UNKNOWN = ";
84   std::cout<<Get(TopAbs_IN)<<Get(TopAbs_OUT)<<Get(TopAbs_ON)<<Get(TopAbs_UNKNOWN);
85   std::cout<<std::endl;
86 }
87
88 #endif