0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / GeomTools / GeomTools_Debug.cxx
1 // Created on: 1994-07-25
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <GeomTools.hxx>
18 #include <GeomTools_SurfaceSet.hxx>
19 #include <GeomTools_CurveSet.hxx>
20 #include <GeomTools_Curve2dSet.hxx>
21 #include <Standard_ErrorHandler.hxx>
22 #include <Standard_Failure.hxx>
23 #include <Geom_Surface.hxx>
24 #include <Geom_Curve.hxx>
25 #include <Geom2d_Curve.hxx>
26
27 // This file defines global functions not declared in any public header,
28 // intended for use from debugger prompt (Command Window in Visual Studio)
29
30 //! Dump content of the geometric object to cout
31 const char* GeomTools_Dump (void* theHandlePtr)
32 {
33   if (theHandlePtr == 0)
34   {
35     return "Error: argument is null";
36   }
37   try {
38     OCC_CATCH_SIGNALS
39     const Handle(Standard_Transient)& aHandle = *(Handle(Standard_Transient)*)theHandlePtr;
40
41     Handle(Geom_Surface) GS = Handle(Geom_Surface)::DownCast(aHandle);
42     if (!GS.IsNull()) {
43       cout << "\n\n";
44       GeomTools_SurfaceSet::PrintSurface (GS,cout);
45       cout << endl;
46       return "Found Geom_Surface, see dump in cout";
47     }
48
49     Handle(Geom_Curve) GC = Handle(Geom_Curve)::DownCast(aHandle);
50     if (!GC.IsNull()) {
51       cout << "\n\n";
52       GeomTools_CurveSet::PrintCurve(GC,cout);
53       cout << endl;
54       return "Found Geom_Curve, see dump in cout";
55     }
56
57     Handle(Geom2d_Curve) GC2d = Handle(Geom2d_Curve)::DownCast(aHandle);
58     if (!GC2d.IsNull()) {
59       cout << "\n\n";
60       GeomTools_Curve2dSet::PrintCurve2d(GC2d,cout);
61       cout << endl;
62       return "Found Geom2d_Curve, see dump in cout";
63     }
64
65     return "Error: Not a geometric object";
66   }
67   catch (Standard_Failure const& anException)
68   {
69     return anException.GetMessageString();
70   }
71 }
72
73 // MSVC debugger cannot deal correctly with functions whose argunments 
74 // have non-standard types. Here we define alternative to the above functions
75 // with good types with the hope that GDB on Linux or other debugger could
76 // work with them (DBX could, on SUN Solaris).
77 #ifndef _MSC_VER
78
79 const char* GeomTools_Dump (const Handle(Standard_Transient)& theGeom)
80 {
81   return GeomTools_Dump ((void*)&theGeom);
82 }
83
84 #endif