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