0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / DrawTrSurf / DrawTrSurf_Debug.cxx
CommitLineData
b311480e 1// Created on: 1994-07-25
2// Created by: Remi LEQUETTE
3// Copyright (c) 1994-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <DrawTrSurf.hxx>
18#include <GeomTools.hxx>
19#include <GeomTools_SurfaceSet.hxx>
20#include <GeomTools_CurveSet.hxx>
21#include <GeomTools_Curve2dSet.hxx>
22#include <gp_Pnt.hxx>
23#include <gp_Pnt2d.hxx>
ec357c5c 24#include <Geom_Geometry.hxx>
25#include <Geom2d_Curve.hxx>
7fd59977 26
d4faf9e9 27// This file defines global functions not declared in any public header,
28// intended for use from debugger prompt (Command Window in Visual Studio)
7fd59977 29
d4faf9e9 30//! Save geometric object identified by pointer to handle
31const char* DrawTrSurf_Set (const char* theNameStr, void* theHandlePtr)
7fd59977 32{
d4faf9e9 33 if (theNameStr == 0 || theHandlePtr == 0)
34 {
35 return "Error: argument is null";
36 }
37 try {
38 const Handle(Standard_Transient)& aHandle = *(Handle(Standard_Transient)*)theHandlePtr;
39 Handle(Geom_Geometry) aGeom3d = Handle(Geom_Geometry)::DownCast(aHandle);
40 if (!aGeom3d.IsNull())
41 {
42 DrawTrSurf::Set (theNameStr, aGeom3d);
43 return theNameStr;
7fd59977 44 }
d4faf9e9 45 Handle(Geom2d_Curve) aGeom2d = Handle(Geom2d_Curve)::DownCast(aHandle);
46 if (!aGeom2d.IsNull())
47 {
48 DrawTrSurf::Set (theNameStr, aGeom2d);
49 return theNameStr;
7fd59977 50 }
51
d4faf9e9 52 return "Error: Not a geometric object";
53 }
9775fa61 54 catch (Standard_Failure const& anException)
d4faf9e9 55 {
9775fa61 56 return anException.GetMessageString();
d4faf9e9 57 }
58}
59
60//! Set point to DRAW variable
61const char* DrawTrSurf_SetPnt (const char* theNameStr, void* thePntPtr)
62{
63 if (theNameStr == 0 || thePntPtr == 0)
64 {
65 return "Error: argument is null";
66 }
67 try {
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);
72 return buff;
73 }
9775fa61 74 catch (Standard_Failure const& anException)
d4faf9e9 75 {
9775fa61 76 return anException.GetMessageString();
d4faf9e9 77 }
78}
79
80//! Set 2d point to DRAW variable
81const char* DrawTrSurf_SetPnt2d (const char* theNameStr, void* thePnt2dPtr)
82{
83 if (theNameStr == 0 || thePnt2dPtr == 0)
84 {
85 return "Error: argument is null";
86 }
87 try {
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);
92 return buff;
93 }
9775fa61 94 catch (Standard_Failure const& anException)
d4faf9e9 95 {
9775fa61 96 return anException.GetMessageString();
d4faf9e9 97 }
98}
99
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).
104#ifndef _MSC_VER
105
106const char* DrawTrSurf_Set (const char* name, const Handle(Standard_Transient)& G)
107{
108 return DrawTrSurf_Set (name, (void*)&G);
7fd59977 109}
110
d4faf9e9 111const char* DrawTrSurf_Set (const char* theName, const gp_Pnt& thePnt)
112{
113 return DrawTrSurf_SetPnt (theName, (void*)&thePnt);
114}
115
116const char* DrawTrSurf_Set (const char* theName, const gp_Pnt2d& thePnt2d)
117{
118 return DrawTrSurf_SetPnt2d (theName, (void*)&thePnt2d);
119}
120
121#endif /* _MSC_VER */
122
123// old function, looks too dangerous to be used
124/*
7fd59977 125void DrawTrSurf_Get(const char* name, Handle(Standard_Transient)& G)
126{
127 Handle(Geom_Geometry) GG = DrawTrSurf::Get(name);
04232180 128 std::cout << "Nom : " << name << std::endl;
7fd59977 129 if (!GG.IsNull()) {
130 G = GG;
131 return;
132 }
133
134 Handle(Geom2d_Curve) GC = DrawTrSurf::GetCurve2d(name);
135 if (!GC.IsNull()) {
136 G = GC;
137 return;
138 }
139
04232180 140 std::cout << "*** Not a geometric object ***" << std::endl;
7fd59977 141}
d4faf9e9 142*/