0032806: Coding - get rid of unused headers [Contap to Extrema]
[occt.git] / src / DrawTrSurf / DrawTrSurf_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 <DrawTrSurf.hxx>
18 #include <GeomTools.hxx>
19 #include <GeomTools_SurfaceSet.hxx>
20 #include <GeomTools_CurveSet.hxx>
21 #include <gp_Pnt.hxx>
22 #include <gp_Pnt2d.hxx>
23 #include <Geom_Geometry.hxx>
24 #include <Geom2d_Curve.hxx>
25
26 // This file defines global functions not declared in any public header,
27 // intended for use from debugger prompt (Command Window in Visual Studio)
28
29 //! Save geometric object identified by pointer to handle
30 const char* DrawTrSurf_Set (const char* theNameStr, void* theHandlePtr)
31 {
32   if (theNameStr == 0 || theHandlePtr == 0)
33   {
34     return "Error: argument is null";
35   }
36   try {
37     const Handle(Standard_Transient)& aHandle = *(Handle(Standard_Transient)*)theHandlePtr;
38     Handle(Geom_Geometry) aGeom3d = Handle(Geom_Geometry)::DownCast(aHandle);
39     if (!aGeom3d.IsNull())
40     {
41       DrawTrSurf::Set (theNameStr, aGeom3d);
42       return theNameStr;
43     }
44     Handle(Geom2d_Curve) aGeom2d = Handle(Geom2d_Curve)::DownCast(aHandle);
45     if (!aGeom2d.IsNull())
46     {
47       DrawTrSurf::Set (theNameStr, aGeom2d);
48       return theNameStr;
49     }
50
51     return "Error: Not a geometric object";
52   }
53   catch (Standard_Failure const& anException)
54   {
55     return anException.GetMessageString();
56   }
57 }
58
59 //! Set point to DRAW variable
60 const char* DrawTrSurf_SetPnt (const char* theNameStr, void* thePntPtr)
61 {
62   if (theNameStr == 0 || thePntPtr == 0)
63   {
64     return "Error: argument is null";
65   }
66   try {
67     const gp_Pnt& aP = *(gp_Pnt*)thePntPtr;
68     static char buff[256];
69     sprintf (buff, "Point (%.16g, %.16g, %.16g) set to DRAW variable %.80s", aP.X(), aP.Y(), aP.Z(), theNameStr);
70     DrawTrSurf::Set (theNameStr, aP);
71     return buff;
72   }
73   catch (Standard_Failure const& anException)
74   {
75     return anException.GetMessageString();
76   }
77 }
78
79 //! Set 2d point to DRAW variable
80 const char* DrawTrSurf_SetPnt2d (const char* theNameStr, void* thePnt2dPtr)
81 {
82   if (theNameStr == 0 || thePnt2dPtr == 0)
83   {
84     return "Error: argument is null";
85   }
86   try {
87     const gp_Pnt2d& aP = *(gp_Pnt2d*)thePnt2dPtr;
88     static char buff[256];
89     sprintf (buff, "Point (%.16g, %.16g) set to DRAW variable %.80s", aP.X(), aP.Y(), theNameStr);
90     DrawTrSurf::Set (theNameStr, aP);
91     return buff;
92   }
93   catch (Standard_Failure const& anException)
94   {
95     return anException.GetMessageString();
96   }
97 }
98
99 // MSVC debugger cannot deal correctly with functions whose argunments 
100 // have non-standard types. Here we define alternative to the above functions
101 // with good types with the hope that GDB on Linux or other debugger could
102 // work with them (DBX could, on SUN Solaris).
103 #ifndef _MSC_VER
104
105 const char* DrawTrSurf_Set (const char* name, const Handle(Standard_Transient)& G)
106 {
107   return DrawTrSurf_Set (name, (void*)&G);
108 }
109
110 const char* DrawTrSurf_Set (const char* theName, const gp_Pnt& thePnt)
111 {
112   return DrawTrSurf_SetPnt (theName, (void*)&thePnt);
113 }
114
115 const char* DrawTrSurf_Set (const char* theName, const gp_Pnt2d& thePnt2d)
116 {
117   return DrawTrSurf_SetPnt2d (theName, (void*)&thePnt2d);
118 }
119
120 #endif /* _MSC_VER */
121
122 // old function, looks too dangerous to be used
123 /*
124 void DrawTrSurf_Get(const char* name, Handle(Standard_Transient)& G)
125 {
126   Handle(Geom_Geometry) GG = DrawTrSurf::Get(name);
127   std::cout << "Nom : " << name << std::endl;
128   if (!GG.IsNull()) {
129     G = GG;
130     return;
131   }
132
133   Handle(Geom2d_Curve) GC = DrawTrSurf::GetCurve2d(name);
134   if (!GC.IsNull()) {
135     G = GC;
136     return;
137   }
138
139   std::cout << "*** Not a geometric object ***" << std::endl;
140 }
141 */