0024599: Tools for interacting with DRAW from Visual Studio debugger
[occt.git] / src / GeomTools / GeomTools_Debug.cxx
CommitLineData
d4faf9e9 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
9// under the terms of the GNU Lesser General Public 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
24// This file defines global functions not declared in any public header,
25// intended for use from debugger prompt (Command Window in Visual Studio)
26
27//! Dump content of the geometric object to cout
28const char* GeomTools_Dump (void* theHandlePtr)
29{
30 if (theHandlePtr == 0)
31 {
32 return "Error: argument is null";
33 }
34 try {
35 OCC_CATCH_SIGNALS
36 const Handle(Standard_Transient)& aHandle = *(Handle(Standard_Transient)*)theHandlePtr;
37
38 Handle(Geom_Surface) GS = Handle(Geom_Surface)::DownCast(aHandle);
39 if (!GS.IsNull()) {
40 cout << "\n\n";
41 GeomTools_SurfaceSet::PrintSurface (GS,cout);
42 cout << endl;
43 return "Found Geom_Surface, see dump in cout";
44 }
45
46 Handle(Geom_Curve) GC = Handle(Geom_Curve)::DownCast(aHandle);
47 if (!GC.IsNull()) {
48 cout << "\n\n";
49 GeomTools_CurveSet::PrintCurve(GC,cout);
50 cout << endl;
51 return "Found Geom_Curve, see dump in cout";
52 }
53
54 Handle(Geom2d_Curve) GC2d = Handle(Geom2d_Curve)::DownCast(aHandle);
55 if (!GC2d.IsNull()) {
56 cout << "\n\n";
57 GeomTools_Curve2dSet::PrintCurve2d(GC2d,cout);
58 cout << endl;
59 return "Found Geom2d_Curve, see dump in cout";
60 }
61
62 return "Error: Not a geometric object";
63 }
64 catch (Standard_Failure)
65 {
66 return Standard_Failure::Caught()->GetMessageString();
67 }
68}
69
70// MSVC debugger cannot deal correctly with functions whose argunments
71// have non-standard types. Here we define alternative to the above functions
72// with good types with the hope that GDB on Linux or other debugger could
73// work with them (DBX could, on SUN Solaris).
74#ifndef _MSC_VER
75
76const char* GeomTools_Dump (const Handle(Standard_Transient)& theGeom)
77{
78 return GeomTools_Dump ((void*)&theGeom);
79}
80
81#endif