0026619: Tolerances of operands are modified using bop
[occt.git] / src / BOPTest / BOPTest_OptionCommands.cxx
CommitLineData
49b0c452 1// Created by: Peter KURNEV
2// Copyright (c) 2014 OPEN CASCADE SAS
3//
4// This file is part of Open CASCADE Technology software library.
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
11//
12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
14
49b0c452 15
42cf5bc1 16#include <BOPTest.hxx>
17#include <BOPTest_Objects.hxx>
49b0c452 18#include <DBRep.hxx>
19#include <Draw.hxx>
20
42cf5bc1 21#include <stdio.h>
22#include <string.h>
49b0c452 23static Standard_Integer boptions (Draw_Interpretor&, Standard_Integer, const char**);
24static Standard_Integer brunparallel (Draw_Interpretor&, Standard_Integer, const char**);
3510db62 25static Standard_Integer bnondestructive(Draw_Interpretor&, Standard_Integer, const char**);
26static Standard_Integer bfuzzyvalue(Draw_Interpretor&, Standard_Integer, const char**);
49b0c452 27
28//=======================================================================
29//function : OptionCommands
30//purpose :
31//=======================================================================
32void BOPTest::OptionCommands(Draw_Interpretor& theCommands)
33{
34 static Standard_Boolean done = Standard_False;
35 if (done) return;
36 done = Standard_True;
37 // Chapter's name
43cb0011 38 const char* g = "BOPTest commands";
49b0c452 39 // Commands
3510db62 40 theCommands.Add("boptions", "use boptions, shows current value of BOP options" , __FILE__, boptions, g);
49b0c452 41 theCommands.Add("brunparallel", "use brunparallel [0/1]" , __FILE__, brunparallel, g);
3510db62 42 theCommands.Add("bnondestructive", "use bnondestructive [0/1]", __FILE__, bnondestructive, g);
43 theCommands.Add("bfuzzyvalue", "use bfuzzyvalue value", __FILE__, bfuzzyvalue, g);
49b0c452 44}
45//=======================================================================
46//function : boptions
47//purpose :
48//=======================================================================
49Standard_Integer boptions(Draw_Interpretor& di,
50 Standard_Integer n,
51 const char** )
52{
53 if (n!=1) {
54 di << " use boptions\n";
55 return 0;
56 }
57 //
58 char buf[128];
3510db62 59 Standard_Boolean bRunParallel, bNonDestructive;
49b0c452 60 Standard_Real aFuzzyValue;
61 //
62 bRunParallel=BOPTest_Objects::RunParallel();
3510db62 63 bNonDestructive = BOPTest_Objects::NonDestructive();
64 aFuzzyValue = BOPTest_Objects::FuzzyValue();
49b0c452 65
66 Sprintf(buf, " RunParallel: %d\n", bRunParallel);
67 di << buf;
3510db62 68 Sprintf(buf, " NonDestructive: %d\n", bNonDestructive);
69 di << buf;
49b0c452 70 Sprintf(buf, " FuzzyValue : %lf\n", aFuzzyValue);
71 di << buf;
72 //
73 return 0;
74}
75//=======================================================================
76//function : bfuzzyvalue
77//purpose :
78//=======================================================================
79Standard_Integer bfuzzyvalue(Draw_Interpretor& di,
80 Standard_Integer n,
81 const char** a)
82{
83 if (n!=2) {
84 di << " use bfuzzyvalue value\n";
85 return 0;
86 }
87 //
88 Standard_Real aFuzzyValue;
89 //
90 aFuzzyValue=Draw::Atof(a[1]);
91 if (aFuzzyValue<0.) {
92 di << " Wrong value.\n";
93 return 0;
94 }
95 //
96 BOPTest_Objects::SetFuzzyValue(aFuzzyValue);
97 //
98 return 0;
99}
100//=======================================================================
101//function : brunparallel
102//purpose :
103//=======================================================================
104Standard_Integer brunparallel(Draw_Interpretor& di,
105 Standard_Integer n,
106 const char** a)
107{
108 if (n!=2) {
109 di << " use brunparallel [0/1]\n";
110 return 0;
111 }
112 //
113 Standard_Integer iX;
114 Standard_Boolean bRunParallel;
115 //
116 iX=Draw::Atoi(a[1]);
117 if (iX<0 || iX>1) {
118 di << " Wrong value.\n";
119 return 0;
120 }
121 //
122 bRunParallel=(Standard_Boolean)(iX);
123 BOPTest_Objects::SetRunParallel(bRunParallel);
124 //
125 return 0;
126}
43cb0011 127//=======================================================================
3510db62 128//function : bnondestructive
43cb0011 129//purpose :
130//=======================================================================
3510db62 131Standard_Integer bnondestructive(Draw_Interpretor& di,
132 Standard_Integer n,
133 const char** a)
43cb0011 134{
3510db62 135 if (n != 2) {
136 di << " use bnondestructive [0/1]\n";
137 return 0;
43cb0011 138 }
3510db62 139 //
140 Standard_Integer iX;
141 Standard_Boolean bNonDestructive;
142 //
143 iX = Draw::Atoi(a[1]);
144 if (iX<0 || iX>1) {
145 di << " Wrong value.\n";
146 return 0;
43cb0011 147 }
3510db62 148 //
149 bNonDestructive = (Standard_Boolean)(iX);
150 BOPTest_Objects::SetNonDestructive(bNonDestructive);
151 //
43cb0011 152 return 0;
153}