00001
00002
00003
00004
00005 #include "Vrml.h"
00006 #include "gui/DisplayRep.h"
00007
00008
00009 namespace gui {
00010
00011 static GraphicsVector currentPoint;
00012
00013 static const char * setup_string =
00014 "#VRML V1.0 ascii\n"
00015 "DEF BackgroundColor Info { string \"0.8 0.8 0.8\" }\n"
00016 "FontStyle { size 3}\n"
00017 "Material { emissiveColor 0.5 0.5 0.5 ambientColor 0 0 0 }\n";
00018
00019
00020
00021 Vrml::Vrml(std::ostream& c)
00022 : _out(c)
00023 , _ncoord(0)
00024 {
00025 _out << setup_string;
00026 ViewPort::detail(0);
00027 }
00028 Vrml::~Vrml(){_out.flush();}
00029
00030
00031
00032
00033 void Vrml::set_quad(int , int )
00034 {
00035
00036 }
00037 void Vrml::beginSeparator(){ _out << "Separator {\n";}
00038 void Vrml::endSeparator() { _out << "}\n"; _ncoord=0; }
00039
00040 void Vrml::coordinate3(const GraphicsVector* v,int n)
00041 {
00042 _out << "Coordinate3 { point [ \n " ;
00043 for( int i=0; i<n; i++){
00044 _out << v[i].x()<< ' ' << v[i].y()<< ' '<< v[i].z() ;
00045 if( i< n-1 ) _out <<",\n" ;
00046 }
00047 _out << "] }\n";
00048 _ncoord=n;
00049 currentPoint = v[n-1];
00050 }
00051 void Vrml::indexedLineSet(const int ia[], int n)
00052 {
00053 _out << "IndexedLineSet{ coordIndex[\n";
00054 for(int i=0; i<n; i++){
00055 _out << ia[i] ;
00056 if( i< n-1 ) _out << ",";
00057 }
00058 _out << "] }\n";
00059 }
00060
00061 void Vrml::indexedFaceSet(const int *ia,int n)
00062 {
00063 _out << "IndexedFaceSet{ coordIndex[\n";
00064 for(int i=0; i<n; i++){
00065 _out << ia[i] ;
00066 if( i< n-1 ) _out << ",";
00067 }
00068 _out << "] }\n";
00069 }
00070 void Vrml::lineSet( int n)
00071 {
00072 _out << "IndexedLineSet{ coordIndex[\n";
00073 for(int i=0; i<n; i++)
00074 _out << i << ',';
00075 _out << -1 << "] }\n";
00076 }
00077
00078 void Vrml::drawPL(const GraphicsVector* v,int n)
00079 {
00080 coordinate3(v,n);
00081 lineSet(n);
00082 }
00083
00084 void Vrml::drawText(const char *text, const GraphicsVector& pnt, int )
00085 {
00086 beginSeparator();
00087 _out << "Transform { translation "
00088 << pnt.x() << ' '<< pnt.y() << ' ' << pnt.z() << "}\n";
00089 _out << "AsciiText { string \"" << text << "\"} \n";
00090 endSeparator();
00091 }
00092 void Vrml::drawText(const char* text)
00093 {
00094 drawText(text, currentPoint);
00095
00096 }
00097
00098
00099 void Vrml::draw_markers(const GraphicsVector* v,int n)
00100 {
00101 coordinate3(v,n);
00102 _out << "PointSet { startIndex 0 numPoints " << n << "}\n";
00103
00104 }
00105
00106
00107 void Vrml::flush(){
00108 _out.flush();
00109 }
00110
00111
00112
00113
00114
00115
00116 void Vrml::set_rgb( float r, float g, float b )
00117 {
00118 _out << "Material { emissiveColor "<< r << ' '<< g <<' '<< b << "}\n";
00119 }
00120 void Vrml::set_col_index(int index)
00121 {
00122 DisplayRep::ColorInfo& cinfo = DisplayRep::pallete[index];
00123 set_rgb(cinfo.r/255., cinfo.g/255., cinfo.b/255.);
00124 }
00125
00126 void Vrml::set_marker_size(float ){}
00127 void Vrml::set_line_width( float ){}
00128
00129 void Vrml::set_line_style( int ){}
00130
00131 void Vrml::set_cap_style(int ){}
00132 void Vrml::setJoinStyle(int ){}
00133
00134 void Vrml::setBkColIndex(int ){}
00135 void Vrml::set_enhanced(int){}
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 }
00159
00160
00161
00162