0024837: Visualization - revise design and implementation of connected Interactive...
[occt.git] / src / QABugs / QABugs_11.cxx
old mode 100755 (executable)
new mode 100644 (file)
index d0aebf4..a7099d5
@@ -1,21 +1,17 @@
 // Created on: 2002-03-20
 // Created by: QA Admin
-// Copyright (c) 2002-2012 OPEN CASCADE SAS
+// Copyright (c) 2002-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 #include <stdio.h>
 
@@ -92,8 +88,6 @@
 #include <BRepFeat_SplitShape.hxx>
 #include <BRepAlgoAPI_Section.hxx>
 
-#include <tcl.h>
-
 #if ! defined(WNT)
 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
 #else
@@ -280,53 +274,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
@@ -828,17 +775,32 @@ static Standard_Integer OCC381_Save (Draw_Interpretor& di, Standard_Integer nb,
   PCDM_StoreStatus theStatus = A->Save(D, theStatusMessage);
   if (theStatus != PCDM_SS_OK ) {
     switch ( theStatus ) {
-    case PCDM_SS_DriverFailure: {
-      di << " Could not store , no driver found to make it " <<"\n" ;
-      break ;
-    }
-    case PCDM_SS_WriteFailure: {
-      di << " Write access failure " << "\n" ;
-      break;
-    }
-    case PCDM_SS_Failure: {
-      di << " Write failure " << "\n" ;
-    }
+      case PCDM_SS_DriverFailure: {
+        di << "Error saving document: Could not store , no driver found to make it" << "\n";
+        break ;
+      }
+      case PCDM_SS_WriteFailure: {
+        di << "Error saving document: Write access failure" << "\n";
+        break;
+      }
+      case PCDM_SS_Failure: {
+        di << "Error saving document: Write failure" << "\n" ;
+        break;
+      }
+      case PCDM_SS_Doc_IsNull: {
+        di << "Error saving document: No document to save" << "\n";
+        break ;
+      }
+      case PCDM_SS_No_Obj: {
+        di << "Error saving document: No objects written" << "\n";
+        break;
+      }
+      case PCDM_SS_Info_Section_Error: {
+        di << "Error saving document: Write info section failure" << "\n" ;
+        break;
+      }
+      default:
+          break;
     }
     return 1;
   }
@@ -863,17 +825,32 @@ static Standard_Integer OCC381_SaveAs (Draw_Interpretor& di, Standard_Integer nb
   PCDM_StoreStatus theStatus = A->SaveAs(D,path, theStatusMessage);
   if (theStatus != PCDM_SS_OK ) {
     switch ( theStatus ) {
-    case PCDM_SS_DriverFailure: {
-      di << " Could not store , no driver found to make it " <<"\n" ;
-      break ;
-    }
-    case PCDM_SS_WriteFailure: {
-      di << " Write access failure " << "\n" ;
-      break;
-    }
-    case PCDM_SS_Failure: {
-      di << " Write failure " << "\n" ;
-    }
+      case PCDM_SS_DriverFailure: {
+        di << "Error saving document: Could not store , no driver found to make it" << "\n";
+        break ;
+      }
+      case PCDM_SS_WriteFailure: {
+        di << "Error saving document: Write access failure" << "\n";
+        break;
+      }
+      case PCDM_SS_Failure: {
+        di << "Error saving document: Write failure" << "\n" ;
+        break;
+      }
+      case PCDM_SS_Doc_IsNull: {
+        di << "Error saving document: No document to save" << "\n";
+        break ;
+      }
+      case PCDM_SS_No_Obj: {
+        di << "Error saving document: No objects written" << "\n";
+        break;
+      }
+      case PCDM_SS_Info_Section_Error: {
+        di << "Error saving document: Write info section failure" << "\n" ;
+        break;
+      }
+      default:
+          break;
     }
     return 1;
   }
@@ -1371,7 +1348,7 @@ static Standard_Integer OCC369(Draw_Interpretor& di, Standard_Integer argc, cons
     if(aShape.IsNull()) {di << "OCC369 FAULTY. Entry shape is NULL \n"; return 0;}
 
     // 3. Build mesh
-    BRepMesh_IncrementalMesh aMesh(aShape, 0.2, Standard_True, M_PI/6);
+    BRepMesh_IncrementalMesh aMesh(aShape, 0.2, Standard_True, M_PI / 6);
 
   }
   catch (Standard_Failure) {di << "OCC369 Exception \n" ;return 0;}
@@ -1682,7 +1659,7 @@ static Standard_Integer OCC708 (Draw_Interpretor& di, Standard_Integer argc, con
     return 1;
   }
   
-  Standard_Boolean updateviewer = Standard_True, PutInCollector = Standard_True;
+  Standard_Boolean updateviewer = Standard_True;
 
   ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
   
@@ -1698,11 +1675,11 @@ static Standard_Integer OCC708 (Draw_Interpretor& di, Standard_Integer argc, con
       di << argv[1] << " : No interactive object" << "\n";
       return 1;
     } 
-    AISObj->UnsetTransformation();
+    AISObj->ResetTransformation();
     if (!aContext->HasOpenedContext()) {
       aContext->OpenLocalContext();
     }
-    aContext->Erase(AISObj, updateviewer, PutInCollector);
+    aContext->Erase(AISObj, updateviewer);
     aContext->UpdateCurrentViewer();
     aContext->Display(AISObj, updateviewer);
     aContext->UpdateCurrentViewer();
@@ -2159,7 +2136,7 @@ TopoDS_Shape OCC1077_boolbl(BRepAlgoAPI_BooleanOperation& aBoolenaOperation,cons
   TopoDS_Shape ShapeCut = aBoolenaOperation.Shape();
 
 //#ifdef OCC40 
-//  Handle_TopOpeBRepBuild_HBuilder build = aBoolenaOperation.Builder();
+//  Handle(TopOpeBRepBuild_HBuilder) build = aBoolenaOperation.Builder();
 //#endif 
   TopTools_ListIteratorOfListOfShape its;
 
@@ -2225,7 +2202,7 @@ TopoDS_Shape OCC1077_Bug()
   TopoDS_Shape theCylinder3 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, - 10, 0),
                                                              gp_Dir(0, 1, 0)), 3, 20).Shape();
   TopoDS_Shape theTmp1 = OCC1077_cut_blend(theCommon,theCylinder1,0.7);
-  Handle_ShapeFix_Shape fixer = new ShapeFix_Shape(theTmp1);
+  Handle(ShapeFix_Shape) fixer = new ShapeFix_Shape(theTmp1);
   fixer->Perform();
   theTmp1 = fixer->Shape();
   TopoDS_Shape theTmp2 = OCC1077_cut_blend(theTmp1,theCylinder2,0.7);
@@ -2380,28 +2357,16 @@ static Standard_Integer OCC5698 (Draw_Interpretor& di, Standard_Integer argc, co
   return 0;
 }
 
-static char sarr[2000];
-static int si=1;
-static int StackOverflow(int i = -1)
+#ifdef WNT
+static int StackOverflow (int i = -1)
 {
   char arr[2000];
-  if (si == 1) {
-    si = 0;
-    memcpy(arr,sarr,2000);
-    arr[1999]=0;
-    int n = strlen(arr), s=0;
-    while (n--)
-      s += StackOverflow(i-1);
-    return i + s + StackOverflow(i-1);
-  }
-  else if (i != 0) {
-    return i + StackOverflow(i-1);
-  }
-  si = 1;
+  memset (arr, 0, sizeof(arr));
+  if (i < 0)
+    StackOverflow(i-1);
   return i;
 }
 
-#ifdef WNT
 // this code does not work with optimize mode on Windows
 #pragma optimize( "", off )
 #endif
@@ -2409,7 +2374,7 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
 {
   if (argc != 1)
     {
-      di << "Usage : " << argv[0] << "\n";
+      cout << "Usage : " << argv[0] << "\n";
       return 1;
     }
   Standard_Boolean Succes;
@@ -2420,6 +2385,7 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
   {//==== Test Divide ByZero (Integer) ========================================
     try{
       OCC_CATCH_SIGNALS
+      cout << "(Integer) Divide By Zero..." << endl;
       di << "(Integer) Divide By Zero...";
       //cout.flush();
       di << "\n";
@@ -2455,6 +2421,7 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
   {//==== Test Divide ByZero (Real) ===========================================
     try{
       OCC_CATCH_SIGNALS
+      cout << "(Real) Divide By Zero..." << endl;
       di << "(Real) Divide By Zero...";
       //cout.flush();
       di << "\n";
@@ -2463,13 +2430,13 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       di << " 4.0 / 0.0 = " << res << "  Does not Caught... KO"<< "\n";
       Succes = Standard_False;
     }
-#if defined(SOLARIS) || defined(WNT)
-    catch(Standard_DivideByZero)
-#else
-    catch(Standard_NumericError)
-#endif
+    catch(Standard_DivideByZero) // Solaris, Windows w/o SSE2
     {
-      di << " Ok"<< "\n";
+      di << " Ok" << "\n";
+    }
+    catch(Standard_NumericError) // Linux, Windows with SSE2
+    {
+      di << " Ok" << "\n";
     }
     catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
@@ -2483,6 +2450,7 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
   {//==== Test Overflow (Integer) =============================================
     try{
       OCC_CATCH_SIGNALS
+      cout << "(Integer) Overflow..." << endl;
       di << "(Integer) Overflow...";
       //cout.flush();
       di << "\n";
@@ -2507,24 +2475,25 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
   {//==== Test Overflow (Real) ================================================ 
     try{
       OCC_CATCH_SIGNALS
+      cout << "(Real) Overflow..." << endl;
       di << "(Real) Overflow...";
       //cout.flush();
       di << "\n";
       Standard_Real res, r=RealLast();
       res = r * r;
       
-      sin(1.); //this function tests FPU flags and raises signal (tested on LINUX).
+      (void)sin(1.); //this function tests FPU flags and raises signal (tested on LINUX).
 
       di << "-- "<<res<<"="<<r<<"*"<<r<<"   Does not Caught... KO"<< "\n";
       Succes = Standard_False;
     }
-#if defined(SOLARIS) || defined(WNT)
-    catch(Standard_Overflow)
-#else
-    catch(Standard_NumericError)
-#endif
+    catch(Standard_Overflow) // Solaris, Windows w/o SSE2
     {
-      di << " Ok"<< "\n";
+      di << " Ok" << "\n";
+    }
+    catch(Standard_NumericError) // Linux, Windows with SSE2
+    {
+      di << " Ok" << "\n";
     }
     catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
@@ -2538,6 +2507,7 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
   {//==== Test Underflow (Real) ===============================================
     try{
       OCC_CATCH_SIGNALS
+      cout << "(Real) Underflow" << endl; // to have message in log even if process crashed
       di << "(Real) Underflow";
       //cout.flush();
       di << "\n";
@@ -2548,13 +2518,13 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       //++++ Succes = Standard_False;
       di<<" -- "<<res<<"="<<r<<"*"<<r<<"   Does not Caught... (But) Ok"<<"\n";
     }
-#if defined(SOLARIS) || defined(WNT)
-    catch(Standard_Underflow)
-#else
-    catch(Standard_NumericError)
-#endif
+    catch(Standard_Underflow) // could be on Solaris, Windows w/o SSE2
     {
-      di << " Ok"<< "\n";
+      di << " Ok" << "\n";
+    }
+    catch(Standard_NumericError) // could be on Linux, Windows with SSE2
+    {
+      di << " Ok" << "\n";
     }
     catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
@@ -2568,6 +2538,7 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
   {//==== Test Invalid Operation (Real) ===============================================
     try{
       OCC_CATCH_SIGNALS
+      cout << "(Real) Invalid Operation..." << endl;
       di << "(Real) Invalid Operation...";
       //cout.flush();
       di << "\n";
@@ -2591,6 +2562,7 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
   {//==== Test Access Violation ===============================================
     try {
       OCC_CATCH_SIGNALS
+      cout << "Segmentation Fault..." << endl;
       di << "Segmentation Fault...";
       //cout.flush();
       di << "\n";
@@ -2619,6 +2591,7 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
   {//==== Test Stack Overflow ===============================================
     try {
       OCC_CATCH_SIGNALS
+      cout << "Stack Overflow..." << endl;
       di << "Stack Overflow...";
       //cout.flush();
       di << "\n";
@@ -2684,9 +2657,9 @@ static Standard_Integer OCC7141 (Draw_Interpretor& di, Standard_Integer argc, co
     nCount = Draw::Atoi(argv[1]);
     TCollection_AsciiString aFilePath = argv[2];
   STEPCAFControl_Writer writer;
-  Handle_TDocStd_Document document;
+  Handle(TDocStd_Document) document;
   document = new TDocStd_Document("Pace Test-StepExporter-");
-  Handle_XCAFDoc_ShapeTool shapeTool;
+  Handle(XCAFDoc_ShapeTool) shapeTool;
   shapeTool = XCAFDoc_DocumentTool::ShapeTool(document->Main());
   shapeTool->AddShape(AddTestStructure(nCount), Standard_True);
   STEPControl_StepModelType mode = STEPControl_AsIs;
@@ -3157,18 +3130,6 @@ static Standard_Integer OCC7068 (Draw_Interpretor& di, Standard_Integer argc, co
     }
   }
 
-  // ObjectsInCollector
-  AIS_ListOfInteractive ListOfIO_2;
-  AISContext->ObjectsInCollector(ListOfIO_2);
-  di<< "ObjectsInCollector = " << ListOfIO_2.Extent() <<"\n";
-  if (!ListOfIO_2.IsEmpty() ) {
-    AIS_ListIteratorOfListOfInteractive iter;
-    for (iter.Initialize(ListOfIO_2); iter.More() ; iter.Next() ) {
-      Handle(AIS_InteractiveObject) aIO=iter.Value();
-      di<< GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
-    }
-  }
-
   return 0;
 }
 
@@ -3233,7 +3194,7 @@ Standard_Integer OCC14376(Draw_Interpretor& di, Standard_Integer argc, const cha
   }
   di<<"deflection="<< aDeflection << "\n";
 
-  BRepMesh_IncrementalMesh aIMesh(aShape, aDeflection, Standard_False, M_PI/9.);
+  BRepMesh_IncrementalMesh aIMesh(aShape, aDeflection, Standard_False, M_PI / 9.);
   TopLoc_Location aLocation;
   Handle(Poly_Triangulation) aTriang = BRep_Tool::Triangulation(TopoDS::Face(aShape), aLocation);
 
@@ -5281,9 +5242,9 @@ Standard_Integer CR23234 (Draw_Interpretor& di, Standard_Integer argc, const cha
   {
     aisContext->CloseAllContexts();
     aisContext->RemoveAll(false);
-    aisContext->EraseSelected(false, false);
+    aisContext->EraseSelected(false);
   }
-  aisContext->EraseAll(false,false);
+  aisContext->EraseAll(false);
   Handle(Geom_Axis2Placement) trihedronAxis = new Geom_Axis2Placement(gp::XOY());
   Handle(AIS_Trihedron) trihedron = new AIS_Trihedron(trihedronAxis);
   if (aMode)
@@ -5317,7 +5278,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);
 
 //====================================================
 //