From 6a0964c23e489dd3ba69065ad2fdfa0e98ca3c04 Mon Sep 17 00:00:00 2001 From: abv Date: Tue, 5 Nov 2013 09:48:27 +0400 Subject: [PATCH] 0024316: Make building with different versions of Tcl easier On Windows with MSVC Tcl library is linked using #pragma statement instead of using project properties, to allow easy switch between Tcl versions. In gendoc.bat, tclsh.exe is called instead of tclsh86.exe, to avoid dependency on hard-coded Tcl version. Tcl-dependent code (unused functions) removed from QABugs package. --- gendoc.bat | 2 +- src/Draw/Draw.cxx | 16 +- src/QABugs/QABugs_11.cxx | 50 ------ src/QABugs/QABugs_13.cxx | 21 +-- src/QABugs/QABugs_3.cxx | 333 --------------------------------------- src/QABugs/QABugs_4.cxx | 2 - src/QADraw/QADraw.cxx | 2 - src/TKQADraw/EXTERNLIB | 2 - tests/bugs/vis/buc60661 | 2 +- 9 files changed, 29 insertions(+), 401 deletions(-) diff --git a/gendoc.bat b/gendoc.bat index b117413e42..8f6ffa5625 100644 --- a/gendoc.bat +++ b/gendoc.bat @@ -9,7 +9,7 @@ if exist "%~dp0env.bat" ( ) if not ["%1"] == ["-h"] ( - tclsh86.exe %~dp0dox/start.tcl %* + tclsh.exe %~dp0dox/start.tcl %* ) else ( echo. echo gen.bat options: diff --git a/src/Draw/Draw.cxx b/src/Draw/Draw.cxx index 7780a1357c..7054f69133 100755 --- a/src/Draw/Draw.cxx +++ b/src/Draw/Draw.cxx @@ -60,7 +60,6 @@ #include #include #include -#include #include #include @@ -68,6 +67,21 @@ #include #include #include + +#include + +// on MSVC, use #pragma to define name of the Tcl library to link with, +// depending on Tcl version number +#ifdef _MSC_VER +// two helper macros are needed to convert version number macro to string literal +#define STRINGIZE1(a) #a +#define STRINGIZE2(a) STRINGIZE1(a) +#pragma comment (lib, "tcl" STRINGIZE2(TCL_MAJOR_VERSION) STRINGIZE2(TCL_MINOR_VERSION) ".lib") +#pragma comment (lib, "tk" STRINGIZE2(TCL_MAJOR_VERSION) STRINGIZE2(TCL_MINOR_VERSION) ".lib") +#undef STRINGIZE2 +#undef STRINGIZE1 +#endif + extern Standard_Boolean Draw_ParseFailed; Standard_EXPORT Draw_Viewer dout; diff --git a/src/QABugs/QABugs_11.cxx b/src/QABugs/QABugs_11.cxx index a3ddc90980..c3c0a644b7 100755 --- a/src/QABugs/QABugs_11.cxx +++ b/src/QABugs/QABugs_11.cxx @@ -92,8 +92,6 @@ #include #include -#include - #if ! defined(WNT) extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(); #else @@ -280,53 +278,6 @@ static int BUC60610(Draw_Interpretor& di, Standard_Integer argc, const char ** a return (1); } -static Standard_Integer BUC60661(Draw_Interpretor& di, Standard_Integer argc, const char ** a) -{ - if(argc!=2) - { - di << "Usage : " << a[0] << " file.igs" << "\n"; - return -1; - } - - Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext(); - - if(myContext.IsNull()) { - di << "use 'vinit' command before " << a[0] << "\n"; - return -1; - } - - // MKV 30.03.05 -#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST) - const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY); -#else - Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY); -#endif - - Standard_Character *file1 = new Standard_Character [strlen(DD)+strlen(a[1])+2]; - Sprintf(file1,"%s/%s",DD,a[1]); - - IGESToBRep_Reader reader; - Standard_Integer status = reader.LoadFile(file1); - if( !status ) { - IGESToBRep::Init(); - reader.TransferRoots(); - TopoDS_Shape shape = reader.OneShape(); - - Handle(AIS_Shape) importedShape = new AIS_Shape(shape); - - Handle(V3d_Viewer) myPView = myContext->CurrentViewer(); - - if( ! myPView.IsNull() && (myPView->DefaultVisualization() == V3d_WIREFRAME) ) - importedShape->SetDisplayMode(AIS_WireFrame); - else importedShape->SetDisplayMode(AIS_Shaded); - myContext->Display(importedShape); - } - - printf("\n End of my IGES to 3D-viewer *****************>\n"); - return 0; -} - - //==================================================== // // Following code is inserted from @@ -5301,7 +5252,6 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) { theCommands.Add("OCC136", "OCC136", __FILE__, OCC136, group); theCommands.Add("BUC60610","BUC60610 iges_input [name]",__FILE__,BUC60610,group); - theCommands.Add("BUC60661","BUC60661 file.igs",__FILE__,BUC60661, group); //==================================================== // diff --git a/src/QABugs/QABugs_13.cxx b/src/QABugs/QABugs_13.cxx index 209111b68e..edb1d742d4 100755 --- a/src/QABugs/QABugs_13.cxx +++ b/src/QABugs/QABugs_13.cxx @@ -28,8 +28,6 @@ #include #include -#include - #include #include #include @@ -82,7 +80,7 @@ static Standard_Integer OCC332bug (Draw_Interpretor& di, Standard_Integer argc, //if ((bend_angle >= M_PI)) { if ((bend_angle >= M_PI)) { di << "The arguments are invalid." << "\n"; - return(TCL_ERROR); + return 1; } di << "creating the shape for a bent tube" << "\n"; @@ -447,7 +445,7 @@ static Standard_Integer OCC544 (Draw_Interpretor& di, Standard_Integer argc, con // mkv 15.07.03 if ((bend_angle >= 2.0*M_PI)) { if ((bend_angle >= 2.0*M_PI)) { di << "The arguments are invalid." << "\n"; - return(TCL_ERROR); + return 1; } di << "creating the shape for a bent tube" << "\n"; @@ -531,7 +529,8 @@ static Standard_Integer OCC544 (Draw_Interpretor& di, Standard_Integer argc, con BRepBuilderAPI_MakeEdge mkEdge; mkEdge.Init(SpineCurve); - if (!mkEdge.IsDone()) return TCL_ERROR; + if (!mkEdge.IsDone()) + return 1; TopoDS_Wire SpineWire = BRepBuilderAPI_MakeWire(mkEdge.Edge()).Wire(); Sprintf (name,"SpineWire"); @@ -568,7 +567,8 @@ static Standard_Integer OCC544 (Draw_Interpretor& di, Standard_Integer argc, con mkPipe1.SetMode(Standard_False); mkPipe1.SetLaw(Wire1_, myLaw, Location1, Standard_False, Standard_False); mkPipe1.Build(); - if (!mkPipe1.IsDone()) return TCL_ERROR; + if (!mkPipe1.IsDone()) + return 1; // Make outer pipe shell BRepOffsetAPI_MakePipeShell mkPipe2(SpineWire); @@ -577,7 +577,8 @@ static Standard_Integer OCC544 (Draw_Interpretor& di, Standard_Integer argc, con mkPipe2.SetMode(Standard_False); mkPipe2.SetLaw(outerWire1_, myLaw2, Location1, Standard_False, Standard_False); mkPipe2.Build(); - if (!mkPipe2.IsDone()) return TCL_ERROR; + if (!mkPipe2.IsDone()) + return 1; // Sprintf(name,"w1-first"); // DBRep::Set(name,mkPipe1.FirstShape()); @@ -608,7 +609,8 @@ static Standard_Integer OCC544 (Draw_Interpretor& di, Standard_Integer argc, con mkFace.Init(Plane1,Standard_False,Precision::Confusion()); mkFace.Add(TopoDS::Wire(outerWire1_)); mkFace.Add(TopoDS::Wire(Wire1_.Reversed())); - if (!mkFace.IsDone()) return TCL_ERROR; + if (!mkFace.IsDone()) + return 1; TopoDS_Face Face1 = mkFace.Face(); // Make face for second opening @@ -616,7 +618,8 @@ static Standard_Integer OCC544 (Draw_Interpretor& di, Standard_Integer argc, con mkFace.Init(Plane2,Standard_False,Precision::Confusion()); mkFace.Add(TopoDS::Wire(outerWire2_)); mkFace.Add(TopoDS::Wire(Wire2_.Reversed())); - if (!mkFace.IsDone()) return TCL_ERROR; + if (!mkFace.IsDone()) + return 1; TopoDS_Face Face2 = mkFace.Face(); // Grab the gas solid now that we've extracted the faces. diff --git a/src/QABugs/QABugs_3.cxx b/src/QABugs/QABugs_3.cxx index c75cad750e..c1802606f9 100644 --- a/src/QABugs/QABugs_3.cxx +++ b/src/QABugs/QABugs_3.cxx @@ -33,7 +33,6 @@ #include #include #include -#include #include @@ -233,333 +232,6 @@ static int BUC60609(Draw_Interpretor& di, Standard_Integer argc, const char ** a return 0; } - -#if ! defined(WNT) -void stringerror(int state) -{ - printf("%s",((state&ios::eofbit) !=0)? " [eof]": ""); - printf("%s",((state&ios::failbit)!=0)? " [fail]":""); - printf("%s",((state&ios::badbit) !=0)? " [bad]": ""); - printf("%s\n",(state==ios::goodbit)? " [ok]": ""); -} - - -//#if defined(LIN) -//#include -//#else -//#include -//#endif -#ifdef HAVE_IOSTREAM -#include -#include -using namespace std; -#elif defined (HAVE_IOSTREAM_H) -#include -#include -#else -#error "check config.h file or compilation options: either HAVE_IOSTREAM or HAVE_IOSTREAM_H should be defined" -#endif -static int UKI61075(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** /*argv*/) { - double da,db; - char buffer1[128]; -#ifndef USE_STL_STREAM - ostrstream stringout1(buffer1,sizeof(buffer1)); - istrstream stringin1(buffer1,sizeof(buffer1)); -#else - ostringstream stringout1(buffer1); - istringstream stringin1(buffer1); -#endif - char buffer2[128]; -#ifndef USE_STL_STREAM - ostrstream stringout2(buffer2,sizeof(buffer2)); - istrstream stringin2(buffer2,sizeof(buffer2)); -#else - ostringstream stringout2(buffer1); - istringstream stringin2(buffer1); -#endif - - stringout1.precision(17); - stringout2.precision(17); - - da=-(DBL_MAX); - db=DBL_MAX; - printf("Valeurs originales :\n\t%.17lg %.17lg\n",da,db); - - stringout1<>da>>db; - printf("Valeurs relues :\n\t%.17lg %.17lg",da,db); - stringerror(stringin1.rdstate()); - - stringout2<>da>>db; - printf("Valeurs relues a nouveau :\n\t%.17lg %.17lg",da,db); - stringerror(stringin2.rdstate()); - - return(0); -} -#endif - -#include -#include - -#include -#include - -//static Standard_CString St = " \"trimsphere\"/\"sphere\" [result] [name] [plane]"; -static Standard_CString St = " \"trimsphere\"/\"sphere\" [result] [name] [plane] [BRepAlgoAPI/BRepAlgo = 1/0]"; - -static int BUC60585(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { - - //if(argc<2) { - // cerr << "Usage : " << argv[0] << St << endl; - // return -1; - //} - if(argc < 2 || argc > 6) { - di << "Usage : " << argv[0] << " shape1 shape2 shape3 shape4 shape5 shape6 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n"; - return 1; - } - Standard_Boolean IsBRepAlgoAPI = Standard_True; - if (argc == 6) { - Standard_Integer IsB = Draw::Atoi(argv[5]); - if (IsB != 1) { - IsBRepAlgoAPI = Standard_False; -#if ! defined(BRepAlgo_def04) -// di << "Error: There is not BRepAlgo_Section class" << "\n"; -// return 1; -#endif - } - } - - - gp_Dir N; - if(!strcmp(argv[1],"trimsphere")) { -////////////////////////////////////////// -// Uncomment for trimmed sphere bug: -// filename = "trimsphere.topo"; - N=gp_Dir( 0.0, -1.0, 0.0 ); -////////////////////////////////////////// - } else if(!strcmp(argv[1],"sphere")) { - -////////////////////////////////////////// -// Uncomment for untrimmed sphere bug: - -// filename="sphere.topo"; - N=gp_Dir( 0.0, -0.75103523489975432, -0.66026212668838646 ); - -////////////////////////////////////////// - } else { - di << "Usage : " << argv[0] << St << "\n"; - return -1; - } - - // MKV 30.03.05 -#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST) - const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY); -#else - Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY); -#endif - - Standard_Character *filename = new Standard_Character [strlen(DD)+17]; - Sprintf(filename,"%s/%s.topo",DD,argv[1]); - - filebuf fic; - istream in(&fic); - if (!fic.open(filename,ios::in)) { - di << "Cannot open file for reading : " << filename << "\n"; - delete [] filename; - return -1; - } - - // Read in the shape - - BRep_Builder B; - BRepTools_ShapeSet S(B); - S.Read(in); - TopoDS_Shape theShape; - S.Read(theShape,in); - - // Create the plane - - gp_Pnt O( 2036.25, -97.5, -1460.499755859375 ); - gp_Dir A( 1.0, 0.0, 0.0 ); - - gp_Ax3 PLA( O, N, A ); - gp_Pln Pl(PLA); - - // Perform the section - -//#if ! defined(BRepAlgoAPI_def01) -// BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False); -//#else -// BRepAlgo_Section Sec( theShape, Pl, Standard_False); -//#endif - - TopoDS_Shape res; - - try{ - OCC_CATCH_SIGNALS -// Sec.Approximation(Standard_True); - - //Sec.Build(); - //if(!Sec.IsDone()){ - // cout << "Error performing intersection: not done." << endl; - // delete filename; - // return -1; - //} - //res = Sec.Shape(); - - if (IsBRepAlgoAPI) { - di << "BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False)" <<"\n"; - BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False); - Sec.Build(); - if(!Sec.IsDone()){ - di << "Error performing intersection: not done." << "\n"; - delete [] filename; - return -1; - } - res = Sec.Shape(); - } else { - di << "BRepAlgo_Section Sec( theShape, Pl, Standard_False)" <<"\n"; - BRepAlgo_Section Sec( theShape, Pl, Standard_False); - Sec.Build(); - if(!Sec.IsDone()){ - di << "Error performing intersection: not done." << "\n"; - delete [] filename; - return -1; - } - res = Sec.Shape(); - } - - }catch(Standard_Failure){ - Handle(Standard_Failure) error = Standard_Failure::Caught(); - di << "Error performing intersection: not done." << "\n"; - delete [] filename; - return -1; - } - - if(argc>3) DBRep::Set(argv[3],theShape); - - if(argc>2) DBRep::Set(argv[2],res); - - if(argc>4) { - Handle(Geom_Geometry) result; - Handle(Geom_Plane) C = new Geom_Plane(Pl); - result=C; - DrawTrSurf::Set(argv[4],result); - } - - di << "Done" << "\n"; - - delete [] filename; - - return 0; -} - -#include - -static int BUC60547(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { - if(argc!=2) { - di << "Usage : " << argv[0] << " name" << "\n"; - return -1; - } - - Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); - if(myAISContext.IsNull()) { - di << "use 'vinit' command before " << argv[0] << "\n"; - return -1; - } - - // MKV 30.03.05 -#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST) - const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY); -#else - Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY); -#endif - - Standard_Character *Ch = new Standard_Character[strlen(argv[1])+3]; - - Standard_Character *FileName = new Standard_Character[strlen(DD)+13]; - - TopoDS_Shape free_1,free_2,free_3,free_4; - BRep_Builder B; - Sprintf(FileName,"%s/%s",DD,"buc60547a.brep"); - BRepTools::Read(free_1,FileName,B); - Sprintf(FileName,"%s/%s",DD,"buc60547b.brep"); - BRepTools::Read(free_2,FileName,B); - Sprintf(FileName,"%s/%s",DD,"buc60547c.brep"); - BRepTools::Read(free_3,FileName,B); - Sprintf(FileName,"%s/%s",DD,"buc60547d.brep"); - BRepTools::Read(free_4,FileName,B); - Sprintf(Ch,"%s_%i",argv[1],1); - DBRep::Set(Ch,free_1); - di << Ch << " "; - Sprintf(Ch,"%s_%i",argv[1],2); - DBRep::Set(Ch,free_2); - di << Ch << " "; - Sprintf(Ch,"%s_%i",argv[1],3); - DBRep::Set(Ch,free_3); - di << Ch << " "; - Sprintf(Ch,"%s_%i",argv[1],4); - DBRep::Set(Ch,free_4); - di << Ch << " "; - -// Handle(AIS_Shape) S1 = new AIS_Shape(free_1); -// Handle(AIS_Shape) S2 = new AIS_Shape(free_2); -// Handle(AIS_Shape) S3 = new AIS_Shape(free_3); -// Handle(AIS_Shape) S4 = new AIS_Shape(free_4); - -// Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); - -// myAISContext->Display(S1); -// myAISContext->Display(S2); -// myAISContext->Display(S3); -// myAISContext->Display(S4); - -// di.Eval("vfit"); - - TopoDS_Compound Com; - BRep_Builder bui; - bui.MakeCompound(Com); - bui.Add(Com,free_1); - bui.Add(Com,free_2); - bui.Add(Com,free_3); - bui.Add(Com,free_4); - - Sprintf(Ch,"%s_%c",argv[1],'c'); - DBRep::Set(Ch,Com); - di << Ch << " "; - - Handle(AIS_Shape) SC = new AIS_Shape(Com); - myAISContext->Display(SC); // nothing on the screen If I save the compound : - - Sprintf(FileName,"%s/%s",DD,"free.brep"); - - BRepTools::Write(Com,FileName); - - delete [] Ch; - delete [] FileName; - - return 0; -} - #include #include #include @@ -2148,11 +1820,6 @@ void QABugs::Commands_3(Draw_Interpretor& theCommands) { theCommands.Add("BUC60569","BUC60569 shape",__FILE__,BUC60569,group); theCommands.Add("BUC60614","BUC60614 shape",__FILE__,BUC60614,group); theCommands.Add("BUC60609","BUC60609 shape name [U V]",__FILE__,BUC60609,group); -#if ! defined(WNT) - theCommands.Add("UKI61075","UKI61075",__FILE__,UKI61075,group); -#endif - theCommands.Add("BUC60585",St,__FILE__,BUC60585,group); - theCommands.Add("BUC60547","BUC60547 name",__FILE__,BUC60547,group); theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group); theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group); theCommands.Add("ksection","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group); diff --git a/src/QABugs/QABugs_4.cxx b/src/QABugs/QABugs_4.cxx index 11bed9742c..1abaf9220b 100755 --- a/src/QABugs/QABugs_4.cxx +++ b/src/QABugs/QABugs_4.cxx @@ -37,8 +37,6 @@ //#include #include -#include - static Standard_Integer BUC60738 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv) { diff --git a/src/QADraw/QADraw.cxx b/src/QADraw/QADraw.cxx index 2cd4a27ab1..22dba731c6 100755 --- a/src/QADraw/QADraw.cxx +++ b/src/QADraw/QADraw.cxx @@ -44,8 +44,6 @@ # include #endif -#include - #include Handle(TColStd_HSequenceOfReal) GetColorOfPixel (const Image_PixMap& theImage, diff --git a/src/TKQADraw/EXTERNLIB b/src/TKQADraw/EXTERNLIB index 65ff8720aa..63ae4ad248 100755 --- a/src/TKQADraw/EXTERNLIB +++ b/src/TKQADraw/EXTERNLIB @@ -34,8 +34,6 @@ TKXSDRAW TKSTL TKAdvTools TKVoxel -CSF_TclLibs -CSF_TclTkLibs CSF_gdi32 CSF_advapi32 CSF_user32 diff --git a/tests/bugs/vis/buc60661 b/tests/bugs/vis/buc60661 index 942153655e..db37102183 100755 --- a/tests/bugs/vis/buc60661 +++ b/tests/bugs/vis/buc60661 @@ -22,7 +22,7 @@ brepiges buc60661 ${imagedir}/buc60661.igs dall -if [catch { igesbrep ${imagedir}//buc60661.igs a * } res] { +if [catch { igesbrep ${imagedir}/buc60661.igs a * } res] { puts "Faulty BUC60661: here is reading problem of iges file" } else { puts "Reading of iges in BUC60661 is OK"