1 // Created by: Eugeny MALTCHIKOV
2 // Copyright (c) 2018 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.
15 #include <BOPTest.hxx>
17 #include <BOPTest_DrawableShape.hxx>
18 #include <BOPTest_Objects.hxx>
20 #include <BRep_Builder.hxx>
22 #include <BRepAlgoAPI_Defeaturing.hxx>
24 #include <BRepTest_Objects.hxx>
30 #include <TopoDS_Compound.hxx>
32 static Standard_Integer RemoveFeatures (Draw_Interpretor&, Standard_Integer, const char**);
34 //=======================================================================
35 //function : RemoveFeaturesCommands
37 //=======================================================================
38 void BOPTest::RemoveFeaturesCommands(Draw_Interpretor& theCommands)
40 static Standard_Boolean done = Standard_False;
44 const char* group = "BOPTest commands";
46 theCommands.Add("removefeatures", "removefeatures result shape f1 f2 ... [-parallel]\n"
47 "\t\tRemoves user-defined features (faces) from the shape.\n"
48 "\t\tresult - result of the operation;\n"
49 "\t\tshape - the shape to remove the features from;\n"
50 "\t\tf1, f2 - features to remove from the shape;\n"
51 "\t\tparallel - enables the parallel processing mode.",
52 __FILE__, RemoveFeatures, group);
55 //=======================================================================
56 //function : RemoveFeatures
58 //=======================================================================
59 Standard_Integer RemoveFeatures(Draw_Interpretor& theDI,
60 Standard_Integer theArgc,
61 const char ** theArgv)
65 theDI.PrintHelp(theArgv[0]);
69 // Get the shape to remove the features from
70 TopoDS_Shape aShape = DBRep::Get(theArgv[2]);
73 theDI << "Error: " << theArgv[2] << " is a null shape.\n";
77 BRepAlgoAPI_Defeaturing aRF;
80 // Add faces to remove
81 for (Standard_Integer i = 3; i < theArgc; ++i)
83 TopoDS_Shape aF = DBRep::Get(theArgv[i]);
86 if (!strcmp(theArgv[i], "-parallel"))
88 // enable the parallel processing mode
89 aRF.SetRunParallel(Standard_True);
92 theDI << "Warning: " << theArgv[i] << " is a null shape. Skip it.\n";
97 aRF.AddFaceToRemove(aF);
100 aRF.SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
102 // Perform the removal
105 // Check for the errors/warnings
106 BOPTest::ReportAlerts(aRF.GetReport());
108 if (BRepTest_Objects::IsHistoryNeeded())
109 BRepTest_Objects::SetHistory(aRF.History());
114 const TopoDS_Shape& aResult = aRF.Shape();
115 DBRep::Set(theArgv[1], aResult);