0026922: Huge performance issue writing data to the output stream
[occt.git] / src / Vrml / Vrml_LOD.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <gp_Vec.hxx>
16 #include <Standard_Type.hxx>
17 #include <Vrml_LOD.hxx>
18
19 Vrml_LOD::Vrml_LOD()
20 {
21   myRange = new TColStd_HArray1OfReal(1,1);
22   gp_Vec tmpVec(0,0,0);
23   myCenter = tmpVec;
24   myRangeFlag = Standard_False;
25 }
26
27 Vrml_LOD::Vrml_LOD(const Handle(TColStd_HArray1OfReal)& aRange,
28                    const gp_Vec& aCenter)
29 {
30   myRange = aRange;
31   myCenter = aCenter;
32   myRangeFlag = Standard_True;
33 }
34
35  void Vrml_LOD::SetRange(const Handle(TColStd_HArray1OfReal)& aRange) 
36 {
37   myRange = aRange;
38   myRangeFlag = Standard_True;
39 }
40
41  Handle(TColStd_HArray1OfReal) Vrml_LOD::Range() const
42 {
43   return myRange;
44 }
45
46  void Vrml_LOD::SetCenter(const gp_Vec& aCenter) 
47 {
48   myCenter = aCenter;
49 }
50
51  gp_Vec Vrml_LOD::Center() const
52 {
53   return myCenter;
54 }
55
56  Standard_OStream& Vrml_LOD::Print(Standard_OStream& anOStream) const
57 {
58   Standard_Integer i;
59   anOStream  << "LOD {\n";
60   
61   if ( myRangeFlag == Standard_True )
62     { 
63       anOStream  << "    range [\n\t";
64       for ( i = myRange->Lower(); i <= myRange->Upper(); i++ )
65         {
66           anOStream << myRange->Value(i);
67           if ( i < myRange->Length() )
68             anOStream  << ",";
69         }
70       anOStream  << " ]\n";
71     }
72
73   if ( Abs(myCenter.X() - 0) > 0.0001 || 
74       Abs(myCenter.Y() - 0) > 0.0001 || 
75       Abs(myCenter.Z() - 0) > 0.0001 ) 
76     {
77       anOStream  << "    center\t";
78       anOStream << myCenter.X() << " " << myCenter.Y() << " " << myCenter.Z() << "\n";
79     }
80   
81   anOStream  << "}\n";
82   return anOStream;
83 }