0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / GeomTools / GeomTools.cxx
CommitLineData
b311480e 1// Created on: 1993-01-21
2// Created by: Remi LEQUETTE
3// Copyright (c) 1993-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
7fd59977 17
42cf5bc1 18#include <Geom2d_Curve.hxx>
19#include <Geom_Curve.hxx>
20#include <Geom_Surface.hxx>
21#include <GeomTools.hxx>
7fd59977 22#include <GeomTools_Curve2dSet.hxx>
42cf5bc1 23#include <GeomTools_CurveSet.hxx>
24#include <GeomTools_SurfaceSet.hxx>
7fd59977 25#include <GeomTools_UndefinedTypeHandler.hxx>
26
27static Handle(GeomTools_UndefinedTypeHandler) theActiveHandler = new GeomTools_UndefinedTypeHandler;
28
29void GeomTools::Dump(const Handle(Geom_Surface)& S, Standard_OStream& OS)
30{
31 GeomTools_SurfaceSet::PrintSurface(S,OS);
32}
33
34void GeomTools::Write(const Handle(Geom_Surface)& S, Standard_OStream& OS)
35{
36 GeomTools_SurfaceSet::PrintSurface(S,OS,Standard_True);
37}
38
39void GeomTools::Read(Handle(Geom_Surface)& S, Standard_IStream& IS)
40{
aa00364d 41 S = GeomTools_SurfaceSet::ReadSurface(IS);
7fd59977 42}
43
44void GeomTools::Dump(const Handle(Geom_Curve)& C, Standard_OStream& OS)
45{
46 GeomTools_CurveSet::PrintCurve(C,OS);
47}
48
49void GeomTools::Write(const Handle(Geom_Curve)& C, Standard_OStream& OS)
50{
51 GeomTools_CurveSet::PrintCurve(C,OS,Standard_True);
52}
53
54void GeomTools::Read(Handle(Geom_Curve)& C, Standard_IStream& IS)
55{
aa00364d 56 C = GeomTools_CurveSet::ReadCurve(IS);
7fd59977 57}
58
59void GeomTools::Dump(const Handle(Geom2d_Curve)& C, Standard_OStream& OS)
60{
61 GeomTools_Curve2dSet::PrintCurve2d(C,OS);
62}
63
64void GeomTools::Write(const Handle(Geom2d_Curve)& C, Standard_OStream& OS)
65{
66 GeomTools_Curve2dSet::PrintCurve2d(C,OS,Standard_True);
67}
68
69void GeomTools::Read(Handle(Geom2d_Curve)& C, Standard_IStream& IS)
70{
aa00364d 71 C = GeomTools_Curve2dSet::ReadCurve2d(IS);
7fd59977 72}
73
74//=======================================================================
75//function : SetUndefinedTypeHandler
76//purpose :
77//=======================================================================
78
79void GeomTools::SetUndefinedTypeHandler(const Handle(GeomTools_UndefinedTypeHandler)& aHandler)
80{
81 if(!aHandler.IsNull())
82 theActiveHandler = aHandler;
83}
84
85//=======================================================================
86//function : GetUndefinedTypeHandler
87//purpose :
88//=======================================================================
89
90Handle(GeomTools_UndefinedTypeHandler) GeomTools::GetUndefinedTypeHandler()
91{
92 return theActiveHandler;
93}
71598a83 94
95//=======================================================================
96//function : GetReal
97//purpose :
98//=======================================================================
99
100void GeomTools::GetReal(Standard_IStream& IS,Standard_Real& theValue)
101{
102 theValue = 0.;
103 if (IS.eof())
104 return;
105
106 char buffer[256];
107 buffer[0] = '\0';
108 std::streamsize anOldWide = IS.width(256);
109 IS >> buffer;
110 IS.width(anOldWide);
111 theValue = Strtod(buffer, NULL);
112}