1 // Created by: Peter KURNEV
2 // Copyright (c) 2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
16 #include <BOPTest.hxx>
17 #include <BOPTest_Objects.hxx>
20 #include <BOPAlgo_GlueEnum.hxx>
24 static Standard_Integer boptions (Draw_Interpretor&, Standard_Integer, const char**);
25 static Standard_Integer brunparallel (Draw_Interpretor&, Standard_Integer, const char**);
26 static Standard_Integer bnondestructive(Draw_Interpretor&, Standard_Integer, const char**);
27 static Standard_Integer bfuzzyvalue(Draw_Interpretor&, Standard_Integer, const char**);
28 static Standard_Integer bGlue(Draw_Interpretor&, Standard_Integer, const char**);
29 static Standard_Integer bdrawwarnshapes(Draw_Interpretor&, Standard_Integer, const char**);
30 static Standard_Integer bcheckinverted(Draw_Interpretor&, Standard_Integer, const char**);
31 static Standard_Integer buseobb(Draw_Interpretor&, Standard_Integer, const char**);
32 static Standard_Integer bsimplify(Draw_Interpretor&, Standard_Integer, const char**);
34 //=======================================================================
35 //function : OptionCommands
37 //=======================================================================
38 void BOPTest::OptionCommands(Draw_Interpretor& theCommands)
40 static Standard_Boolean done = Standard_False;
44 const char* g = "BOPTest commands";
46 theCommands.Add("boptions", "Usage: boptions [-default]\n"
47 "\t\tw/o arguments shows current value of BOP options\n"
48 "\t\t-default - allows setting all options to default values",
49 __FILE__, boptions, g);
51 theCommands.Add("brunparallel", "Enables/Disables parallel processing mode.\n"
52 "\t\tUsage: brunparallel 0/1",
53 __FILE__, brunparallel, g);
55 theCommands.Add("bnondestructive", "Enables/Disables the safe processing mode.\n"
56 "\t\tUsage: bnondestructive 0/1",
57 __FILE__, bnondestructive, g);
59 theCommands.Add("bfuzzyvalue", "Sets the additional tolerance for BOP algorithms.\n"
60 "\t\tUsage: bfuzzyvalue value",
61 __FILE__, bfuzzyvalue, g);
63 theCommands.Add("bglue", "Sets the gluing mode for the BOP algorithms.\n"
64 "\t\tUsage: bglue [0 (off) / 1 (shift) / 2 (full)]",
67 theCommands.Add("bdrawwarnshapes", "Enables/Disables drawing of waring shapes of BOP algorithms.\n"
68 "\t\tUsage: bdrawwarnshapes 0 (do not draw) / 1 (draw warning shapes)",
69 __FILE__, bdrawwarnshapes, g);
71 theCommands.Add("bcheckinverted", "Enables/Disables the check of the input solids on inverted status in BOP algorithms\n"
72 "\t\tUsage: bcheckinverted 0 (off) / 1 (on)",
73 __FILE__, bcheckinverted, g);
75 theCommands.Add("buseobb", "Enables/disables the usage of OBB in BOP algorithms\n"
76 "\t\tUsage: buseobb 0 (off) / 1 (on)",
77 __FILE__, buseobb, g);
79 theCommands.Add("bsimplify", "Enables/Disables the result simplification after BOP\n"
80 "\t\tUsage: bsimplify [-e 0/1] [-f 0/1] [-a tol]\n"
81 "\t\t-e 0/1 - enables/disables edges unification\n"
82 "\t\t-f 0/1 - enables/disables faces unification\n"
83 "\t\t-a tol - changes default angular tolerance of unification algo (accepts value in degrees).",
84 __FILE__, bsimplify, g);
86 //=======================================================================
89 //=======================================================================
90 Standard_Integer boptions(Draw_Interpretor& di,
102 if (strcmp(a[1], "-default"))
108 // Set all options to default values
109 BOPTest_Objects::SetDefaultOptions();
114 BOPAlgo_GlueEnum aGlue = BOPTest_Objects::Glue();
116 Sprintf(buf, " RunParallel: %s \t\t(%s)\n", BOPTest_Objects::RunParallel() ? "Yes" : "No",
117 "use \"brunparallel\" command to change");
119 Sprintf(buf, " NonDestructive: %s \t\t(%s)\n", BOPTest_Objects::NonDestructive() ? "Yes" : "No",
120 "use \"bnondestructive\" command to change");
122 Sprintf(buf, " FuzzyValue: %g \t\t(%s)\n", BOPTest_Objects::FuzzyValue(),
123 "use \"bfuzzyvalue\" command to change");
125 Sprintf(buf, " GlueOption: %s \t\t(%s)\n", ((aGlue == BOPAlgo_GlueOff) ? "Off" :
126 ((aGlue == BOPAlgo_GlueFull) ? "Full" : "Shift")),
127 "use \"bglue\" command to change");
129 Sprintf(buf, " Draw Warning Shapes: %s \t(%s)\n", BOPTest_Objects::DrawWarnShapes() ? "Yes" : "No",
130 "use \"bdrawwarnshapes\" command to change");
132 Sprintf(buf, " Check for invert solids: %s \t(%s)\n", BOPTest_Objects::CheckInverted() ? "Yes" : "No",
133 "use \"bcheckinverted\" command to change");
135 Sprintf(buf, " Use OBB: %s \t\t\t(%s)\n", BOPTest_Objects::UseOBB() ? "Yes" : "No",
136 "use \"buseobb\" command to change");
138 Sprintf(buf, " Unify Edges: %s \t\t(%s)\n", BOPTest_Objects::UnifyEdges() ? "Yes" : "No",
139 "use \"bsimplify -e\" command to change");
141 Sprintf(buf, " Unify Faces: %s \t\t(%s)\n", BOPTest_Objects::UnifyFaces() ? "Yes" : "No",
142 "use \"bsimplify -f\" command to change");
144 Sprintf(buf, " Angular: %g \t\t(%s)\n", BOPTest_Objects::Angular(),
145 "use \"bsimplify -a\" command to change");
150 //=======================================================================
151 //function : bfuzzyvalue
153 //=======================================================================
154 Standard_Integer bfuzzyvalue(Draw_Interpretor& di,
164 Standard_Real aFuzzyValue = Draw::Atof(a[1]);
165 BOPTest_Objects::SetFuzzyValue(aFuzzyValue);
168 //=======================================================================
169 //function : brunparallel
171 //=======================================================================
172 Standard_Integer brunparallel(Draw_Interpretor& di,
182 Standard_Integer iRunParallel = Draw::Atoi(a[1]);
183 BOPTest_Objects::SetRunParallel(iRunParallel != 0);
186 //=======================================================================
187 //function : bnondestructive
189 //=======================================================================
190 Standard_Integer bnondestructive(Draw_Interpretor& di,
200 Standard_Integer iNonDestructive = Draw::Atoi(a[1]);
201 BOPTest_Objects::SetNonDestructive(iNonDestructive != 0);
205 //=======================================================================
208 //=======================================================================
209 Standard_Integer bGlue(Draw_Interpretor& di,
219 Standard_Integer iGlue = Draw::Atoi(a[1]);
220 if (iGlue < 0 || iGlue > 2)
222 di << "Wrong value.\n";
227 BOPAlgo_GlueEnum aGlue = BOPAlgo_GlueEnum(iGlue);
228 BOPTest_Objects::SetGlue(aGlue);
232 //=======================================================================
233 //function : bdrawwarnshapes
235 //=======================================================================
236 Standard_Integer bdrawwarnshapes(Draw_Interpretor& di,
246 Standard_Integer iDraw = Draw::Atoi(a[1]);
247 BOPTest_Objects::SetDrawWarnShapes(iDraw != 0);
251 //=======================================================================
252 //function : bcheckinverted
254 //=======================================================================
255 Standard_Integer bcheckinverted(Draw_Interpretor& di,
265 Standard_Integer iCheck = Draw::Atoi(a[1]);
266 BOPTest_Objects::SetCheckInverted(iCheck != 0);
270 //=======================================================================
273 //=======================================================================
274 Standard_Integer buseobb(Draw_Interpretor& di,
284 Standard_Integer iUse = Draw::Atoi(a[1]);
285 BOPTest_Objects::SetUseOBB(iUse != 0);
289 //=======================================================================
290 //function : bsimplify
292 //=======================================================================
293 Standard_Integer bsimplify(Draw_Interpretor& di,
297 if (n == 1 || n%2 == 0)
303 for (Standard_Integer i = 1; i < n - 1; ++i)
305 if (!strcmp(a[i], "-e"))
307 Standard_Integer iUnifyEdges = Draw::Atoi(a[++i]);
308 BOPTest_Objects::SetUnifyEdges(iUnifyEdges != 0);
310 else if (!strcmp(a[i], "-f"))
312 Standard_Integer iUnifyFaces = Draw::Atoi(a[++i]);
313 BOPTest_Objects::SetUnifyFaces(iUnifyFaces != 0);
315 else if (!strcmp(a[i], "-a"))
317 Standard_Real anAngTol = Draw::Atof(a[++i]) * (M_PI / 180.0);
318 BOPTest_Objects::SetAngular(anAngTol);
322 di << "Wrong key option.\n";