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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <DrawTrSurf.hxx>
18 #include <GeomTools.hxx>
19 #include <GeomTools_SurfaceSet.hxx>
20 #include <GeomTools_CurveSet.hxx>
21 #include <GeomTools_Curve2dSet.hxx>
23 #include <gp_Pnt2d.hxx>
24 #include <Geom_Geometry.hxx>
25 #include <Geom2d_Curve.hxx>
27 // This file defines global functions not declared in any public header,
28 // intended for use from debugger prompt (Command Window in Visual Studio)
30 //! Save geometric object identified by pointer to handle
31 const char* DrawTrSurf_Set (const char* theNameStr, void* theHandlePtr)
33 if (theNameStr == 0 || theHandlePtr == 0)
35 return "Error: argument is null";
38 const Handle(Standard_Transient)& aHandle = *(Handle(Standard_Transient)*)theHandlePtr;
39 Handle(Geom_Geometry) aGeom3d = Handle(Geom_Geometry)::DownCast(aHandle);
40 if (!aGeom3d.IsNull())
42 DrawTrSurf::Set (theNameStr, aGeom3d);
45 Handle(Geom2d_Curve) aGeom2d = Handle(Geom2d_Curve)::DownCast(aHandle);
46 if (!aGeom2d.IsNull())
48 DrawTrSurf::Set (theNameStr, aGeom2d);
52 return "Error: Not a geometric object";
54 catch (Standard_Failure const& anException)
56 return anException.GetMessageString();
60 //! Set point to DRAW variable
61 const char* DrawTrSurf_SetPnt (const char* theNameStr, void* thePntPtr)
63 if (theNameStr == 0 || thePntPtr == 0)
65 return "Error: argument is null";
68 const gp_Pnt& aP = *(gp_Pnt*)thePntPtr;
69 static char buff[256];
70 sprintf (buff, "Point (%.16g, %.16g, %.16g) set to DRAW variable %.80s", aP.X(), aP.Y(), aP.Z(), theNameStr);
71 DrawTrSurf::Set (theNameStr, aP);
74 catch (Standard_Failure const& anException)
76 return anException.GetMessageString();
80 //! Set 2d point to DRAW variable
81 const char* DrawTrSurf_SetPnt2d (const char* theNameStr, void* thePnt2dPtr)
83 if (theNameStr == 0 || thePnt2dPtr == 0)
85 return "Error: argument is null";
88 const gp_Pnt2d& aP = *(gp_Pnt2d*)thePnt2dPtr;
89 static char buff[256];
90 sprintf (buff, "Point (%.16g, %.16g) set to DRAW variable %.80s", aP.X(), aP.Y(), theNameStr);
91 DrawTrSurf::Set (theNameStr, aP);
94 catch (Standard_Failure const& anException)
96 return anException.GetMessageString();
100 // MSVC debugger cannot deal correctly with functions whose argunments
101 // have non-standard types. Here we define alternative to the above functions
102 // with good types with the hope that GDB on Linux or other debugger could
103 // work with them (DBX could, on SUN Solaris).
106 const char* DrawTrSurf_Set (const char* name, const Handle(Standard_Transient)& G)
108 return DrawTrSurf_Set (name, (void*)&G);
111 const char* DrawTrSurf_Set (const char* theName, const gp_Pnt& thePnt)
113 return DrawTrSurf_SetPnt (theName, (void*)&thePnt);
116 const char* DrawTrSurf_Set (const char* theName, const gp_Pnt2d& thePnt2d)
118 return DrawTrSurf_SetPnt2d (theName, (void*)&thePnt2d);
121 #endif /* _MSC_VER */
123 // old function, looks too dangerous to be used
125 void DrawTrSurf_Get(const char* name, Handle(Standard_Transient)& G)
127 Handle(Geom_Geometry) GG = DrawTrSurf::Get(name);
128 cout << "Nom : " << name << endl;
134 Handle(Geom2d_Curve) GC = DrawTrSurf::GetCurve2d(name);
140 cout << "*** Not a geometric object ***" << endl;