Updating the changelog in the VERSION file, and version_sync.
[shapes.git] / source / constructorrepresentation.cc
blobc467b3b703853c99776d63aaf0937bdaa36aeaae
1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * any later version.
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008 Henrik Tidefelt
19 #include "constructorrepresentation.h"
21 #include <sstream>
23 using namespace Shapes;
26 std::string
27 Helpers::shapesFormat( double scalar )
29 std::ostringstream oss;
31 if( scalar < 0 )
33 oss << "~" ;
35 static char buf[25];
36 sprintf( buf, "%.5f", fabs( scalar ) );
37 oss << buf ;
38 return oss.str( );
41 std::string
42 Helpers::shapesFormat( Concrete::Length length )
44 std::ostringstream oss;
46 double val = Concrete::Length::offtype( length );
48 if( val < 0 )
50 oss << "~" ;
52 static char buf[25];
53 sprintf( buf, "%.5fbp", fabs( val ) );
54 oss << buf ;
55 return oss.str( );
58 std::string
59 Helpers::shapesFormat( Concrete::Coords2D coords )
61 std::ostringstream oss;
63 oss << "(" << Helpers::shapesFormat( coords.x_ ) << "," << Helpers::shapesFormat( coords.y_ ) << ")" ;
65 return oss.str( );
68 std::string
69 Helpers::shapesFormat( Concrete::Coords3D coords )
71 std::ostringstream oss;
73 oss << "(" << Helpers::shapesFormat( coords.x_ ) << "," << Helpers::shapesFormat( coords.y_ ) << "," << Helpers::shapesFormat( coords.z_ ) << ")" ;
75 return oss.str( );
78 std::string
79 Helpers::shapesFormat( Concrete::UnitFloatPair coords )
81 std::ostringstream oss;
83 oss << "(" << Helpers::shapesFormat( coords.x_ ) << "," << Helpers::shapesFormat( coords.y_ ) << ")" ;
85 return oss.str( );
88 std::string
89 Helpers::shapesFormat( Concrete::UnitFloatTriple coords )
91 std::ostringstream oss;
93 oss << "(" << Helpers::shapesFormat( coords.x_ ) << "," << Helpers::shapesFormat( coords.y_ ) << "," << Helpers::shapesFormat( coords.z_ ) << ")" ;
95 return oss.str( );