1 // Created on: 2014-12-25
2 // Created by: KULIKOVA Galina
3 // Copyright (c) 2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and / or modify it
8 // under the terms of the GNU Lesser General Public version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <BRepAlgoAPI.ixx>
19 #include <TCollection_AsciiString.hxx>
20 #include <BRepTools.hxx>
21 #include <OSD_File.hxx>
23 //=======================================================================
26 //=======================================================================
27 void BRepAlgoAPI::DumpOper(const Standard_CString theFilePath,
28 const TopoDS_Shape& theShape1,
29 const TopoDS_Shape& theShape2,
30 const TopoDS_Shape& theResult,
31 BOPAlgo_Operation theOperation,
32 Standard_Boolean isNonValidArgs)
34 TCollection_AsciiString aPath(theFilePath);
36 Standard_Integer aNumOper = 1;
37 Standard_Boolean isExist = Standard_True;
38 TCollection_AsciiString aFileName;
42 aFileName = aPath + "BO_" + TCollection_AsciiString(aNumOper) +".tcl";
43 OSD_File aScript(aFileName);
44 isExist = aScript.Exists();
49 FILE* afile = fopen(aFileName.ToCString(), "w+");
53 fprintf(afile,"%s\n","# Arguments are invalid");
55 TCollection_AsciiString aName1;
56 TCollection_AsciiString aName2;
57 TCollection_AsciiString aNameRes;
58 if(!theShape1.IsNull())
61 "Arg1_" + TCollection_AsciiString(aNumOper) + ".brep";
62 BRepTools::Write(theShape1, aName1.ToCString());
65 fprintf(afile,"%s\n","# First argument is Null ");
67 if(!theShape2.IsNull())
70 "Arg2_"+ TCollection_AsciiString(aNumOper) + ".brep";
72 BRepTools::Write(theShape2, aName2.ToCString());
75 fprintf(afile,"%s\n","# Second argument is Null ");
77 if(!theResult.IsNull())
80 "Result_"+ TCollection_AsciiString(aNumOper) + ".brep";
82 BRepTools::Write(theResult, aNameRes.ToCString());
85 fprintf(afile,"%s\n","# Result is Null ");
87 fprintf(afile, "%s %s %s\n","restore", aName1.ToCString(), "arg1");
88 fprintf(afile, "%s %s %s\n","restore", aName2.ToCString(), "arg2");;
89 TCollection_AsciiString aBopString;
92 case BOPAlgo_COMMON : aBopString += "bcommon Res "; break;
93 case BOPAlgo_FUSE : aBopString += "bfuse Res "; break;
95 case BOPAlgo_CUT21 : aBopString += "bcut Res "; break;
96 case BOPAlgo_SECTION : aBopString += "bsection Res "; break;
99 aBopString += ("arg1 arg2");
100 if(theOperation == BOPAlgo_CUT21)
103 fprintf(afile, "%s\n",aBopString.ToCString());