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>
22 #include <gp_Pnt2d.hxx>
23 #include <Geom_Geometry.hxx>
24 #include <Geom2d_Curve.hxx>
26 // This file defines global functions not declared in any public header,
27 // intended for use from debugger prompt (Command Window in Visual Studio)
29 //! Save geometric object identified by pointer to handle
30 const char* DrawTrSurf_Set (const char* theNameStr, void* theHandlePtr)
32 if (theNameStr == 0 || theHandlePtr == 0)
34 return "Error: argument is null";
37 const Handle(Standard_Transient)& aHandle = *(Handle(Standard_Transient)*)theHandlePtr;
38 Handle(Geom_Geometry) aGeom3d = Handle(Geom_Geometry)::DownCast(aHandle);
39 if (!aGeom3d.IsNull())
41 DrawTrSurf::Set (theNameStr, aGeom3d);
44 Handle(Geom2d_Curve) aGeom2d = Handle(Geom2d_Curve)::DownCast(aHandle);
45 if (!aGeom2d.IsNull())
47 DrawTrSurf::Set (theNameStr, aGeom2d);
51 return "Error: Not a geometric object";
53 catch (Standard_Failure const& anException)
55 return anException.GetMessageString();
59 //! Set point to DRAW variable
60 const char* DrawTrSurf_SetPnt (const char* theNameStr, void* thePntPtr)
62 if (theNameStr == 0 || thePntPtr == 0)
64 return "Error: argument is null";
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);
73 catch (Standard_Failure const& anException)
75 return anException.GetMessageString();
79 //! Set 2d point to DRAW variable
80 const char* DrawTrSurf_SetPnt2d (const char* theNameStr, void* thePnt2dPtr)
82 if (theNameStr == 0 || thePnt2dPtr == 0)
84 return "Error: argument is null";
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);
93 catch (Standard_Failure const& anException)
95 return anException.GetMessageString();
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).
105 const char* DrawTrSurf_Set (const char* name, const Handle(Standard_Transient)& G)
107 return DrawTrSurf_Set (name, (void*)&G);
110 const char* DrawTrSurf_Set (const char* theName, const gp_Pnt& thePnt)
112 return DrawTrSurf_SetPnt (theName, (void*)&thePnt);
115 const char* DrawTrSurf_Set (const char* theName, const gp_Pnt2d& thePnt2d)
117 return DrawTrSurf_SetPnt2d (theName, (void*)&thePnt2d);
120 #endif /* _MSC_VER */
122 // old function, looks too dangerous to be used
124 void DrawTrSurf_Get(const char* name, Handle(Standard_Transient)& G)
126 Handle(Geom_Geometry) GG = DrawTrSurf::Get(name);
127 std::cout << "Nom : " << name << std::endl;
133 Handle(Geom2d_Curve) GC = DrawTrSurf::GetCurve2d(name);
139 std::cout << "*** Not a geometric object ***" << std::endl;