1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-08 14:17:06 +03:00

0024599: Tools for interacting with DRAW from Visual Studio debugger

Global functions are added to allow a user performing DRAW commands from VS Command Window when DRAW is interrupted on a breakpoint.
Previously existing functions are adapted to work with Visual Studio debugger (Command Window).
A manual describing use of these functions and other debugging facilities and some hints is added to Developer Guides.
Minor corrections and refinement of debug.md.
This commit is contained in:
abv
2014-02-27 18:22:52 +04:00
committed by apn
parent c5face6f3a
commit d4faf9e945
12 changed files with 610 additions and 87 deletions

View File

@@ -624,18 +624,6 @@ void BRepTools::Dump(const TopoDS_Shape& Sh, Standard_OStream& S)
SS.Dump(S);
}
#ifdef DEB
//=======================================================================
//function : BRepTools_Write
//purpose :
//=======================================================================
void BRepTools_Write (const TopoDS_Shape& S,
const Standard_CString File)
{
BRepTools::Write (S,File);
}
#endif
//=======================================================================
//function : Write
//purpose :

View File

@@ -0,0 +1,112 @@
// Created on: 1994-07-25
// Created by: Remi LEQUETTE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and / or modify it
// under the terms of the GNU Lesser General Public 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.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepTools.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <TopTools_LocationSet.hxx>
// This file defines global functions not declared in any public header,
// intended for use from debugger prompt (Command Window in Visual Studio)
//! Save shape to file
const char* BRepTools_Write (const char* theFileStr, void* theShapePtr)
{
if (theFileStr == 0 || theShapePtr == 0)
{
return "Error: name or shape is null";
}
try {
OCC_CATCH_SIGNALS
if (BRepTools::Write (*(TopoDS_Shape*)theShapePtr, theFileStr))
return theFileStr;
else
return "Error: write failed";
}
catch (Standard_Failure)
{
return Standard_Failure::Caught()->GetMessageString();
}
}
//! Dump shape to cout
const char* BRepTools_Dump (void* theShapePtr)
{
if (theShapePtr == 0)
{
return "Error: name or shape is null";
}
try {
OCC_CATCH_SIGNALS
cout <<"\n\n";
BRepTools::Dump (*(TopoDS_Shape*)theShapePtr, cout);
cout << endl;
return "Shape dumped to cout";
}
catch (Standard_Failure)
{
return Standard_Failure::Caught()->GetMessageString();
}
}
//! Dump shape location to cout
const char* BRepTools_DumpLoc (void* theLocationPtr)
{
if (theLocationPtr == 0)
{
return "Error: name or shape is null";
}
try {
OCC_CATCH_SIGNALS
cout <<"\n\n";
TopTools_LocationSet LS;
LS.Add(*(TopLoc_Location*)theLocationPtr);
LS.Dump(cout);
cout <<endl;
return "Location dumped to cout";
}
catch (Standard_Failure)
{
return Standard_Failure::Caught()->GetMessageString();
}
}
// MSVC debugger cannot deal correctly with functions whose argunments
// have non-standard types. Here we define alternative to the above functions
// with good types with the hope that GDB on Linux or other debugger could
// work with them (DBX could, on SUN Solaris).
#ifndef _MSC_VER
const char* BRepTools_Write (const char* theFileNameStr, const TopoDS_Shape& theShape)
{
return BRepTools_Write (theFileNameStr, (void*)&theShape);
}
const char* BRepTools_Dump (const TopoDS_Shape& theShape)
{
return BRepTools_Dump ((void*)&theShape);
}
const char* BRepTools_DumpLoc (const TopoDS_Shape& theShape)
{
return BRepTools_DumpLoc ((void*)&theShape);
}
#endif

1
src/BRepTools/FILES Normal file
View File

@@ -0,0 +1 @@
BRepTools_Debug.cxx

View File

@@ -14,19 +14,45 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// command that can be called within the debugger
#include <DBRep.hxx>
#include <BRepTools.hxx>
#include <TopTools_LocationSet.hxx>
#include <TopoDS_Shape.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
// This file defines global functions not declared in any public header,
// intended for use from debugger prompt (Command Window in Visual Studio)
void DBRep_Set(char* name, const TopoDS_Shape& S)
//! Save shape identified by pointer
Standard_EXPORT const char* DBRep_Set (const char* theNameStr, void* theShapePtr)
{
DBRep::Set(name,S);
if (theNameStr == 0 || theShapePtr == 0)
{
return "Error: name or shape is null";
}
try {
DBRep::Set (theNameStr, *(TopoDS_Shape*)theShapePtr);
return theNameStr;
}
catch (Standard_Failure)
{
return Standard_Failure::Caught()->GetMessageString();
}
}
// MSVC debugger cannot deal correctly with functions whose argunments
// have non-standard types. Here we define alternative to the above functions
// with good types with the hope that GDB on Linux or other debugger could
// work with them (DBX could, on SUN Solaris).
#ifndef _MSC_VER
const char* DBRep_Set (char* theName, const TopoDS_Shape& theShape)
{
return DBRep_Set (theName, (void*)&theShape);
}
#endif /* _MSC_VER */
// old function, perhaps too dangerous to be used
/*
void DBRep_Get(char* name, TopoDS_Shape& S)
{
char n[255];
@@ -36,21 +62,4 @@ void DBRep_Get(char* name, TopoDS_Shape& S)
if (*name == '.')
cout << "Name : " << n << endl;
}
void DBRep_Dump(const TopoDS_Shape& S)
{
cout <<"\n\n";
BRepTools::Dump(S,cout);
cout <<endl;
}
void DBRep_DumpLoc(const TopLoc_Location& L)
{
cout <<"\n\n";
TopTools_LocationSet LS;
LS.Add(L);
LS.Dump(cout);
cout <<endl;
}
*/

42
src/Draw/Draw_Debug.cxx Normal file
View File

@@ -0,0 +1,42 @@
// Created on: 2010-06-02
// Created by: Peter KURNEV
// Copyright (c) 2010-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// 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.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <DBRep.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
extern Draw_Interpretor theCommands;
// This file defines global functions not declared in any public header,
// intended for use from debugger prompt (Command Window in Visual Studio)
//! Execute given DRAW command
Standard_EXPORT const char* Draw_Eval (const char *theCommandStr)
{
if (theCommandStr == 0)
{
return "Error: null command string";
}
try {
OCC_CATCH_SIGNALS
theCommands.Eval (theCommandStr);
return theCommands.Result();
}
catch (Standard_Failure)
{
return Standard_Failure::Caught()->GetMessageString();
}
}

View File

@@ -27,3 +27,4 @@ Draw_Main.cxx
Draw_PluginMacro.hxx
Draw_PloadCommands.cxx
Draw_Window_1.mm
Draw_Debug.cxx

View File

@@ -22,25 +22,104 @@
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
// method to call with dbx
// This file defines global functions not declared in any public header,
// intended for use from debugger prompt (Command Window in Visual Studio)
void DrawTrSurf_Set(char* name, const Handle(Standard_Transient)& G)
//! Save geometric object identified by pointer to handle
const char* DrawTrSurf_Set (const char* theNameStr, void* theHandlePtr)
{
Handle(Geom_Geometry) GG = Handle(Geom_Geometry)::DownCast(G);
if (!GG.IsNull()) {
DrawTrSurf::Set(name,GG);
return;
if (theNameStr == 0 || theHandlePtr == 0)
{
return "Error: argument is null";
}
try {
const Handle(Standard_Transient)& aHandle = *(Handle(Standard_Transient)*)theHandlePtr;
Handle(Geom_Geometry) aGeom3d = Handle(Geom_Geometry)::DownCast(aHandle);
if (!aGeom3d.IsNull())
{
DrawTrSurf::Set (theNameStr, aGeom3d);
return theNameStr;
}
Handle(Geom2d_Curve) GC = Handle(Geom2d_Curve)::DownCast(G);
if (!GC.IsNull()) {
DrawTrSurf::Set(name,GC);
return;
Handle(Geom2d_Curve) aGeom2d = Handle(Geom2d_Curve)::DownCast(aHandle);
if (!aGeom2d.IsNull())
{
DrawTrSurf::Set (theNameStr, aGeom2d);
return theNameStr;
}
cout << "*** Not a geometric object ***" << endl;
return "Error: Not a geometric object";
}
catch (Standard_Failure)
{
return Standard_Failure::Caught()->GetMessageString();
}
}
//! Set point to DRAW variable
const char* DrawTrSurf_SetPnt (const char* theNameStr, void* thePntPtr)
{
if (theNameStr == 0 || thePntPtr == 0)
{
return "Error: argument is null";
}
try {
const gp_Pnt& aP = *(gp_Pnt*)thePntPtr;
static char buff[256];
sprintf (buff, "Point (%.16g, %.16g, %.16g) set to DRAW variable %.80s", aP.X(), aP.Y(), aP.Z(), theNameStr);
DrawTrSurf::Set (theNameStr, aP);
return buff;
}
catch (Standard_Failure)
{
return Standard_Failure::Caught()->GetMessageString();
}
}
//! Set 2d point to DRAW variable
const char* DrawTrSurf_SetPnt2d (const char* theNameStr, void* thePnt2dPtr)
{
if (theNameStr == 0 || thePnt2dPtr == 0)
{
return "Error: argument is null";
}
try {
const gp_Pnt2d& aP = *(gp_Pnt2d*)thePnt2dPtr;
static char buff[256];
sprintf (buff, "Point (%.16g, %.16g) set to DRAW variable %.80s", aP.X(), aP.Y(), theNameStr);
DrawTrSurf::Set (theNameStr, aP);
return buff;
}
catch (Standard_Failure)
{
return Standard_Failure::Caught()->GetMessageString();
}
}
// MSVC debugger cannot deal correctly with functions whose argunments
// have non-standard types. Here we define alternative to the above functions
// with good types with the hope that GDB on Linux or other debugger could
// work with them (DBX could, on SUN Solaris).
#ifndef _MSC_VER
const char* DrawTrSurf_Set (const char* name, const Handle(Standard_Transient)& G)
{
return DrawTrSurf_Set (name, (void*)&G);
}
const char* DrawTrSurf_Set (const char* theName, const gp_Pnt& thePnt)
{
return DrawTrSurf_SetPnt (theName, (void*)&thePnt);
}
const char* DrawTrSurf_Set (const char* theName, const gp_Pnt2d& thePnt2d)
{
return DrawTrSurf_SetPnt2d (theName, (void*)&thePnt2d);
}
#endif /* _MSC_VER */
// old function, looks too dangerous to be used
/*
void DrawTrSurf_Get(const char* name, Handle(Standard_Transient)& G)
{
Handle(Geom_Geometry) GG = DrawTrSurf::Get(name);
@@ -58,41 +137,4 @@ void DrawTrSurf_Get(const char* name, Handle(Standard_Transient)& G)
cout << "*** Not a geometric object ***" << endl;
}
void DrawTrSurf_Dump(const Handle(Standard_Transient)& G)
{
cout << "\n\n";
Handle(Geom_Surface) GS = Handle(Geom_Surface)::DownCast(G);
if (!GS.IsNull()) {
GeomTools_SurfaceSet::PrintSurface(GS,cout);
cout << endl;
return;
}
Handle(Geom_Curve) GC = Handle(Geom_Curve)::DownCast(G);
if (!GC.IsNull()) {
GeomTools_CurveSet::PrintCurve(GC,cout);
cout << endl;
return;
}
Handle(Geom2d_Curve) GC2d = Handle(Geom2d_Curve)::DownCast(G);
if (!GC2d.IsNull()) {
GeomTools_Curve2dSet::PrintCurve2d(GC2d,cout);
cout << endl;
return;
}
}
void DrawTrSurf_Set(char* name, const gp_Pnt& P)
{
cout<<"point "<<name<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<endl;
DrawTrSurf::Set(name,P);
}
void DrawTrSurf_Set(char* name, const gp_Pnt2d& P)
{
cout<<"point "<<name<<" "<<P.X()<<" "<<P.Y()<<endl;
DrawTrSurf::Set(name,P);
}
*/

1
src/GeomTools/FILES Normal file
View File

@@ -0,0 +1 @@
GeomTools_Debug.cxx

View File

@@ -0,0 +1,81 @@
// Created on: 1994-07-25
// Created by: Remi LEQUETTE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and / or modify it
// under the terms of the GNU Lesser General Public 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.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <GeomTools.hxx>
#include <GeomTools_SurfaceSet.hxx>
#include <GeomTools_CurveSet.hxx>
#include <GeomTools_Curve2dSet.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
// This file defines global functions not declared in any public header,
// intended for use from debugger prompt (Command Window in Visual Studio)
//! Dump content of the geometric object to cout
const char* GeomTools_Dump (void* theHandlePtr)
{
if (theHandlePtr == 0)
{
return "Error: argument is null";
}
try {
OCC_CATCH_SIGNALS
const Handle(Standard_Transient)& aHandle = *(Handle(Standard_Transient)*)theHandlePtr;
Handle(Geom_Surface) GS = Handle(Geom_Surface)::DownCast(aHandle);
if (!GS.IsNull()) {
cout << "\n\n";
GeomTools_SurfaceSet::PrintSurface (GS,cout);
cout << endl;
return "Found Geom_Surface, see dump in cout";
}
Handle(Geom_Curve) GC = Handle(Geom_Curve)::DownCast(aHandle);
if (!GC.IsNull()) {
cout << "\n\n";
GeomTools_CurveSet::PrintCurve(GC,cout);
cout << endl;
return "Found Geom_Curve, see dump in cout";
}
Handle(Geom2d_Curve) GC2d = Handle(Geom2d_Curve)::DownCast(aHandle);
if (!GC2d.IsNull()) {
cout << "\n\n";
GeomTools_Curve2dSet::PrintCurve2d(GC2d,cout);
cout << endl;
return "Found Geom2d_Curve, see dump in cout";
}
return "Error: Not a geometric object";
}
catch (Standard_Failure)
{
return Standard_Failure::Caught()->GetMessageString();
}
}
// MSVC debugger cannot deal correctly with functions whose argunments
// have non-standard types. Here we define alternative to the above functions
// with good types with the hope that GDB on Linux or other debugger could
// work with them (DBX could, on SUN Solaris).
#ifndef _MSC_VER
const char* GeomTools_Dump (const Handle(Standard_Transient)& theGeom)
{
return GeomTools_Dump ((void*)&theGeom);
}
#endif