diff --git a/Post/PViewX3D.cpp b/Post/PViewX3D.cpp index e34ec8b939cf12deeb8ce8d120e41eff2941ad4d..fea1430c6e6047b593fc7eaad197509fa335d80b 100644 --- a/Post/PViewX3D.cpp +++ b/Post/PViewX3D.cpp @@ -21,7 +21,7 @@ #include "OS.h" #include <ctime> #include "SBoundingBox3d.h" -#include <math.h> +#include <math.h> #include "PViewX3D.h" #include <iostream> @@ -38,18 +38,18 @@ bool compare_zmax_triangle (const TriangleToSort* first, const TriangleToSort* s bool PView::writeX3D(const std::string &fileName ) { - + // tags duplicated triangles --------------------- int _size=1; - if ( PView::getInnerBorder() ) { + if ( PView::getInnerBorder() ) { for(unsigned int i = 0; i < PView::list.size(); i++){ VertexArray *va =PView::list[i]->va_triangles; _size += va->getNumVertices()/3; } } int _count=0; - std::vector<bool> visible(_size, false) ; - if ( PView::getInnerBorder() ) { + bool visible[_size] ; + if ( PView::getInnerBorder() ) { // evaluate bbox of each triangle std::list< TriangleToSort* > tlist ; tlist.clear(); @@ -61,7 +61,7 @@ bool PView::writeX3D(const std::string &fileName ) float *p2 = va->getVertexArray(3 * (ipt + 2)); TriangleToSort *_current = new TriangleToSort ; _current->_index = ipt; - _current->_globalIndex=_count; visible[_count]=true; _count++; + _current->_globalIndex=_count; visible[_count]=true; _count++; _current->_ppv = PView::list[ivp] ; _current->xmin = min(p0[0], min(p1[0],p2[0]) ); _current->ymin = min(p0[1], min(p1[1],p2[1]) ); @@ -94,40 +94,15 @@ bool PView::writeX3D(const std::string &fileName ) int gip=(*pt)->_globalIndex; while ( nt != tlist.end() && !found ) { int gin=(*nt)->_globalIndex; - if ( ( ( ( abs( (*pt)->xmin - (*nt)->xmin ) < 1.e-9 ) && ( abs( (*pt)->ymin - (*nt)->ymin ) < 1.e-9) ) && ( abs( (*pt)->zmin - (*nt)->zmin ) < 1.e-9 ) ) + if ( ( ( ( abs( (*pt)->xmin - (*nt)->xmin ) < 1.e-9 ) && ( abs( (*pt)->ymin - (*nt)->ymin ) < 1.e-9) ) && ( abs( (*pt)->zmin - (*nt)->zmin ) < 1.e-9 ) ) && ( ( ( abs( (*pt)->xmax - (*nt)->xmax ) < 1.e-9 ) && ( abs( (*pt)->ymax - (*nt)->ymax ) < 1.e-9) ) && ( abs( (*pt)->zmax - (*nt)->zmax ) < 1.e-9 ) ) ) { VertexArray *van = ( (*nt)->_ppv)->va_triangles; - int in=(*nt)->_index; + int in=(*nt)->_index; float *n0 = van->getVertexArray( 3* in ); float *n1 = van->getVertexArray( 3* (in+1) ); float *n2 = van->getVertexArray( 3* (in+2) ); - // bool cas00 = (p0[0]==n0[0] && p0[1]==n0[1] && p0[2]==n0[2]); - // bool cas01 = (p0[0]==n1[0] && p0[1]==n1[1] && p0[2]==n1[2]); - // bool cas02 = (p0[0]==n2[0] && p0[1]==n2[1] && p0[2]==n2[2]); - // bool cas10 = (p1[0]==n0[0] && p1[1]==n0[1] && p1[2]==n0[2]); - // bool cas11 = (p1[0]==n1[0] && p1[1]==n1[1] && p1[2]==n1[2]); - // bool cas12 = (p1[0]==n2[0] && p1[1]==n2[1] && p1[2]==n2[2]); - // bool cas20 = (p2[0]==n0[0] && p2[1]==n0[1] && p2[2]==n0[2]); - // bool cas21 = (p2[0]==n1[0] && p2[1]==n1[1] && p2[2]==n1[2]); - // bool cas22 = (p2[0]==n2[0] && p2[1]==n2[1] && p2[2]==n2[2]); - /* - if ( p0[0]==n0[0] && p0[1]==n0[1] && p0[2]==n0[2] ){ - if ( p1[0]==n1[0] && p1[1]==n1[1] && p1[2]==n1[2] ){ - if ( p2[0]==n2[0] && p2[1]==n2[1] && p2[2]==n2[2] ) { found=true; } } - else if ( p1[0]==n2[0] && p1[1]==n2[1] && p1[2]==n2[2] ) { - if ( p2[0]==n1[0] && p2[1]==n1[1] && p2[2]==n1[2] ) { found=true; } } } - else if ( p0[0]==n1[0] && p0[1]==n1[1] && p0[2]==n1[2] ) { - if ( p1[0]==n0[0] && p1[1]==n0[1] && p1[2]==n0[2] ){ - if ( p2[0]==n2[0] && p2[1]==n2[1] && p2[2]==n2[2] ) { found=true; } } - else if ( p1[0]==n2[0] && p1[1]==n2[1] && p1[2]==n2[2] ) { - if ( p2[0]==n0[0] && p2[1]==n0[1] && p2[2]==n0[2] ) { found=true; } } } - else if ( p0[0]==n2[0] && p0[1]==n2[1] && p0[2]==n2[2] ) { - if ( p1[0]==n0[0] && p1[1]==n0[1] && p1[2]==n0[2] ){ - if ( p2[0]==n1[0] && p2[1]==n1[1] && p2[2]==n1[2] ) { found=true; } } - else if ( p1[0]==n1[0] && p1[1]==n1[1] && p1[2]==n1[2] ) { - if ( p2[0]==n0[0] && p2[1]==n0[1] && p2[2]==n0[2] ) { found=true; } } } - */ - if ( almostEqual(p0[0],n0[0]) && almostEqual(p0[1],n0[1]) && almostEqual(p0[2],n0[2]) ){ + + if ( almostEqual(p0[0],n0[0]) && almostEqual(p0[1],n0[1]) && almostEqual(p0[2],n0[2]) ){ if ( almostEqual(p1[0],n1[0]) && almostEqual(p1[1],n1[1]) && almostEqual(p1[2],n1[2]) ){ if ( almostEqual(p2[0],n2[0]) && almostEqual(p2[1],n2[1]) && almostEqual(p2[2],n2[2]) ) { found=true; } } else if ( almostEqual(p1[0],n2[0]) && almostEqual(p1[1],n2[1]) && almostEqual(p1[2],n2[2]) ) { @@ -137,13 +112,12 @@ bool PView::writeX3D(const std::string &fileName ) if ( almostEqual(p2[0],n2[0]) && almostEqual(p2[1],n2[1]) && almostEqual(p2[2],n2[2]) ) { found=true; } } else if ( almostEqual(p1[0],n2[0]) && almostEqual(p1[1],n2[1]) && almostEqual(p1[2],n2[2]) ) { if ( almostEqual(p2[0],n0[0]) && almostEqual(p2[1],n0[1]) && almostEqual(p2[2],n0[2]) ) { found=true; } } } - else if ( almostEqual(p0[0],n2[0]) && almostEqual(p0[1],n2[1]) && almostEqual(p0[2],n2[2]) ) { + else if ( almostEqual(p0[0],n2[0]) && almostEqual(p0[1],n2[1]) && almostEqual(p0[2],n2[2]) ) { if ( almostEqual(p1[0],n0[0]) && almostEqual(p1[1],n0[1]) && almostEqual(p1[2],n0[2]) ){ if ( almostEqual(p2[0],n1[0]) && almostEqual(p2[1],n1[1]) && almostEqual(p2[2],n1[2]) ) { found=true; } } - else if ( almostEqual(p1[0],n1[0]) && almostEqual(p1[1],n1[1]) && almostEqual(p1[2],n1[2]) ) { + else if ( almostEqual(p1[0],n1[0]) && almostEqual(p1[1],n1[1]) && almostEqual(p1[2],n1[2]) ) { if ( almostEqual(p2[0],n0[0]) && almostEqual(p2[1],n0[1]) && almostEqual(p2[2],n0[2]) ) { found=true; } } } - if (found){ visible[gip]=false; visible[gin]=false; @@ -178,7 +152,7 @@ bool PView::writeX3D(const std::string &fileName ) // x3 Header --------------------------------------------------------------------------- fprintf(fp,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); fprintf(fp,"<!DOCTYPE X3D PUBLIC \"ISO//Web3D//DTD X3D 3.3//EN\" \"http://www.web3d.org/specifications/x3d-3.3.dtd\">\n"); - fprintf(fp,"<X3D profile='Interchange' version='3.3' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' >\n"); + fprintf(fp,"<X3D profile='Interchange' version='3.3' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' >\n"); fprintf(fp,"<head>\n"); fprintf(fp," <meta name='title' content='PView'/> \n"); fprintf(fp," <meta name='description' content='%s'/>\n", fileName.c_str()); @@ -204,7 +178,7 @@ bool PView::writeX3D(const std::string &fileName ) // HUD : Head Up Display fprintf(fp,"<ProtoDeclare appinfo='Heads-up display (HUD)' name='HeadsUpDisplay'> \n"); fprintf(fp," <ProtoInterface> \n"); - fprintf(fp," <field accessType='inputOutput' appinfo='offset position for HUD' name='screenOffset' type='SFVec3f' value='%g %g %g'/> \n", _center.x(), _center.y() , 5*_center.z()+_diagonal*1.2 ); + fprintf(fp," <field accessType='inputOutput' appinfo='offset position for HUD' name='screenOffset' type='SFVec3f' value='%g %g %g'/> \n", _center.x(), _center.y() , 5*_center.z()+_diagonal*1.2 ); fprintf(fp," <field accessType='inputOutput' appinfo='X3D content positioned at HUD offset' name='children' type='MFNode'> \n"); fprintf(fp," </field> \n"); fprintf(fp," <field accessType='outputOnly' appinfo='HUD position update (in world coordinates) relative to original location' name='position_changed' type='SFVec3f'/> \n"); @@ -236,22 +210,13 @@ bool PView::writeX3D(const std::string &fileName ) fprintf(fp," </ProtoBody> \n"); fprintf(fp," </ProtoDeclare> \n"); fprintf(fp," <Background skyColor='.7 .7 1'/> \n"); - fprintf(fp," <Viewpoint description='Book View' orientation='0 0. 1. 0.' position='%g %g %g'/> \n", _center.x(), _center.y() , _center.z()+_diagonal*1.2 ); + fprintf(fp," <Viewpoint description='Book View' orientation='0 0. 1. 0.' position='%g %g %g'/> \n", _center.x(), _center.y() , _center.z()+_diagonal*1.2 ); fprintf(fp," <!-- ProtoDeclare is the \"cookie cutter\" template, ProtoInstance creates an actual occurrence --> \n"); fprintf(fp," <ProtoInstance DEF='HeadsUpDisplay' name='HeadsUpDisplay'> \n"); fprintf(fp," <!-- example: upper left-hand corner of screen (x=-2, y=1) and set back z=-5 from user view --> \n"); fprintf(fp," <fieldValue name='screenOffset' value='%g %g %g'/> \n", _center.x(), _center.y() , _center.z()-.2*_diagonal ); fprintf(fp," <fieldValue name='children'> \n"); - /*--------------------------------------------------------- - fprintf(fp," <Shape> \n"); - fprintf(fp," <Text string='\"HUD : place for legend\" \"stay fixed while user navigates\"'> \n"); - fprintf(fp," <FontStyle justify='\"MIDDLE\" \"MIDDLE\"' size='0.02'/> \n"); - fprintf(fp," </Text> \n"); - fprintf(fp," <Appearance> \n"); - fprintf(fp," <Material diffuseColor='0. 0. 0.'/> \n"); - fprintf(fp," </Appearance> \n"); - fprintf(fp," </Shape> \n"); - ------------------------------------------------------------*/ + // here contour/scalebar legends in frame (-.45,-.28, 0.) and (.45, .28,0.) : viewport .9 x .56 double viewportWidth =.9 ; @@ -261,9 +226,9 @@ bool PView::writeX3D(const std::string &fileName ) for(unsigned int i = 0; i < PView::list.size(); i++){ PViewData *data = PView::list[i]->getData(); PViewOptions *opt = PView::list[i]->getOptions(); - if(!data->getDirty() - && opt->visible && opt->showScale - && opt->type == PViewOptions::Plot3D && data->getNumElements() + if(!data->getDirty() + && opt->visible && opt->showScale + && opt->type == PViewOptions::Plot3D && data->getNumElements() ) scales.push_back(PView::list[i]); } @@ -278,7 +243,7 @@ bool PView::writeX3D(const std::string &fileName ) PView *p = scales[i]; PViewData *data = p->getData(); PViewOptions *opt = p->getOptions(); - + if(!opt->autoPosition) { double w= viewportWidth/3; double h= viewportHeight/11; @@ -339,32 +304,20 @@ bool PView::writeX3D(const std::string &fileName ) } } - // end of contour legend - // frame to visualize HUD if necessary---------------------------------------- - /* - fprintf(fp," <Shape>\n"); - fprintf(fp," <IndexedFaceSet solid=\"false\" colorPerVertex=\"true\" coordIndex=\"0 1 2 3 -1\">\n"); - fprintf(fp," <Coordinate point= \" -.45 -.28 0. .45 -.28 0. .45 .28 0. -.45 .28 0. \" />\n"); - fprintf(fp," <Color color= \"0 0 0, 0 0 0, 1 1 1, 1 1 1\" /> \n"); - fprintf(fp," </IndexedFaceSet>\n"); - fprintf(fp," <Appearance> \n"); - fprintf(fp," <Material transparency='0.75' /> \n"); - fprintf(fp," </Appearance> \n"); - fprintf(fp," </Shape>"); - */ - //----------------------------------------------------------------------------- fprintf(fp," </fieldValue> \n"); fprintf(fp," </ProtoInstance> \n"); + - //count all visible triangles of previous visited PView - _count=0; // geometrical objects + VertexArray *va; + PViewData *data; + PViewOptions *opt; + // points ------------------------NOT TREATED YET------------------------------- + /* for(unsigned int ipv = 0; ipv < PView::list.size(); ipv++){ - PViewData *data = PView::list[ipv]->getData(true); - PViewOptions *opt = PView::list[ipv]->getOptions(); + data = PView::list[ipv]->getData(true); + opt = PView::list[ipv]->getOptions(); if( !data->getDirty() && opt->visible ) { - VertexArray *va; - // points ------------------------NOT TREATED YET------------------------------- va=PView::list[ipv]->va_points; for(int ipt = 0; ipt < va->getNumVertices(); ipt++){ float *p = va->getVertexArray(3 * ipt); @@ -382,50 +335,74 @@ bool PView::writeX3D(const std::string &fileName ) else fprintf(fp,"sphere : %g %g %g \n", p[0], p[1], p[2] ); } + } // enf if dirty + + }// end loop on PView::list + */ - // lines ----------------------------------------------------------------------- + + // lines ----------------------------------------------------------------------- + int _ind=0; + fprintf(fp,"<Shape> \n"); + fprintf(fp," <IndexedLineSet coordIndex=' "); + for(unsigned int ipv = 0; ipv < PView::list.size(); ipv++){ + PViewData *data = PView::list[ipv]->getData(true); + PViewOptions *opt = PView::list[ipv]->getOptions(); + if( !data->getDirty() && opt->visible ) { va=PView::list[ipv]->va_lines; - fprintf(fp,"<Shape> \n"); - fprintf(fp," <IndexedLineSet coordIndex=' "); for(int ipt = 0; ipt < va->getNumVertices(); ipt += 2){ - if(opt->lineType != 2 && opt->lineType != 1) { - fprintf(fp,"%i %i %i ",ipt,ipt+1,-1); + if(opt->lineType != 2 && opt->lineType != 1) { + fprintf(fp,"%i %i %i ",_ind,_ind+1,-1); } + _ind += 2; } - fprintf(fp,"'> \n"); - fprintf(fp," <Coordinate DEF='TurnPoints' point=' "); - for(int ipt = 0; ipt < va->getNumVertices(); ipt += 2){ - if(opt->lineType != 2 && opt->lineType != 1) { + } // end if dirty + }// end for loop on PView::list + fprintf(fp,"'>\n"); + fprintf(fp," <Coordinate DEF='TurnPoints' point=' "); + for(unsigned int ipv = 0; ipv < PView::list.size(); ipv++){ + PViewData *data = PView::list[ipv]->getData(true); + PViewOptions *opt = PView::list[ipv]->getOptions(); + if( !data->getDirty() && opt->visible ) { + va=PView::list[ipv]->va_lines; + for(int ipt = 0; ipt < va->getNumVertices(); ipt += 2){ + if(opt->lineType != 2 && opt->lineType != 1) { float *p0 = va->getVertexArray(3 * ipt); float *p1 = va->getVertexArray(3 * (ipt + 1)); - fprintf(fp,"%g %g %g %g %g %g ", p0[0], p0[1], p0[2], p1[0], p1[1], p1[2]); + fprintf(fp,"%g %g %g %g %g %g ", p0[0], p0[1], p0[2], p1[0], p1[1], p1[2]); } - } - fprintf(fp,"'/>\n"); - fprintf(fp," </IndexedLineSet> \n"); - fprintf(fp," <Appearance> \n"); - fprintf(fp," <Material emissiveColor='0 0 0'/>\n"); - fprintf(fp," <LineProperties containerField='lineProperties'> \n"); - fprintf(fp," </LineProperties> \n"); - fprintf(fp," </Appearance> \n"); - fprintf(fp,"</Shape>\n"); + } // end for + } // end if dirty + }// end for loop on PView::list + fprintf(fp,"'/> \n"); + fprintf(fp," </IndexedLineSet> \n"); + fprintf(fp," <Appearance> \n"); + fprintf(fp," <Material emissiveColor='0 0 0'/>\n"); + fprintf(fp," <LineProperties containerField='lineProperties'> \n"); + fprintf(fp," </LineProperties> \n"); + fprintf(fp," </Appearance> \n"); + fprintf(fp,"</Shape>\n"); - //vectors --------------------colored arrow replaced by colored cones------------------- - va=PView::list[ipv]->va_vectors; + //vectors --------------------colored arrow replaced by colored cones------------------- + for(unsigned int ipv = 0; ipv < PView::list.size(); ipv++){ + data = PView::list[ipv]->getData(true); + opt = PView::list[ipv]->getOptions(); + if( !data->getDirty() && opt->visible ) { + va=PView::list[ipv]->va_vectors; for(int iv = 0; iv < va->getNumVertices(); iv += 2){ float *s = va->getVertexArray(3 * iv); float *v = va->getVertexArray(3 * (iv + 1)); unsigned char *c = va->getColorArray(4 * iv); double rgba[4]; - UnsignedChar2rgba(c,rgba) ; + UnsignedChar2rgba(c,rgba) ; double l = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); double lmax = opt->tmpMax; if((l || opt->vectorType == 6) && lmax){ double scale=.5/_diagonal; - double theta=acos(v[1]/l); + double theta=acos(v[1]/l); fprintf(fp,"<Transform rotation='%g %g %g %g' translation='%e %e %e' >\n" ,v[2],0.,-v[0],theta ,s[0]+.5*scale*v[0],s[1]+.5*scale*v[1],s[2]+.5*scale*v[2]); @@ -438,76 +415,98 @@ bool PView::writeX3D(const std::string &fileName ) fprintf(fp," </Appearance>\n"); fprintf(fp,"</Shape>\n"); fprintf(fp,"</Transform>\n"); + } // end if l + } // end for iv + } // end if dirty + }// end for loop on PView::list + + + //triangles --------------------------colored triangles ------------------------------- + //count all visible triangles of previous visited PView + _count=0; + _ind=0.; + fprintf(fp,"<Transform> \n"); + fprintf(fp,"<Shape> \n"); + fprintf(fp," <Appearance> \n"); + fprintf(fp," <Material transparency='%g' ", PView::getTransparencyValue() ); + fprintf(fp," ambientIntensity='0.15' diffuseColor='.5 .5 .5' emissiveColor='0 0 0' "); + fprintf(fp," shininess='0.1' specularColor='.1 .1 .1' /> \n"); + fprintf(fp," </Appearance> \n"); + fprintf(fp," <IndexedTriangleSet solid='true' ccw='true' colorPerVertex='true' \n "); + fprintf(fp," normalPerVertex='true' containerField='geometry' index=' "); + for(unsigned int ipv = 0; ipv < PView::list.size(); ipv++){ + data = PView::list[ipv]->getData(true); + opt = PView::list[ipv]->getOptions(); + if( !data->getDirty() && opt->visible ) { + va=PView::list[ipv]->va_triangles; + for(int ipt = 0; ipt < va->getNumVertices(); ipt += 3){ + if ( (PView::getInnerBorder() && visible[_count] ) || !PView::getInnerBorder() ) { + fprintf(fp,"%i %i %i ",_ind,_ind+1,_ind+2); + _ind += 3; } + _count++; } - - //triangles --------------------------colored triangles ------------------------------- + } // enf if dirty + }// end loop on PView::list + + fprintf(fp," ' > \n"); + fprintf(fp," <Coordinate point='"); + _count=0; + for(unsigned int ipv = 0; ipv < PView::list.size(); ipv++){ + data = PView::list[ipv]->getData(true); + opt = PView::list[ipv]->getOptions(); + if( !data->getDirty() && opt->visible ) { va=PView::list[ipv]->va_triangles; - - fprintf(fp,"<Transform> \n"); - fprintf(fp,"<Shape> \n"); - fprintf(fp," <IndexedTriangleSet index=' "); - // index of point of the visible tirangle - int ind=0; for(int ipt = 0; ipt < va->getNumVertices(); ipt += 3){ - if ( (PView::getInnerBorder() && visible[_count+ipt/3] ) || !PView::getInnerBorder() ) { - fprintf(fp,"%i %i %i ",ind,ind+1,ind+2); - ind+=3; + if ( ( PView::getInnerBorder() && visible[_count] ) || !PView::getInnerBorder()) { + float *p0 = va->getVertexArray(3 * ipt); + float *p1 = va->getVertexArray(3 * (ipt + 1)); + float *p2 = va->getVertexArray(3 * (ipt + 2)); + + fprintf(fp,"%e %e %e %e %e %e %e %e %e " + , p0[0], p0[1], p0[2] + , p1[0], p1[1], p1[2] + , p2[0], p2[1], p2[2]); } + _count++; } - fprintf(fp," ' solid='false' ccw='true' colorPerVertex='true' normalPerVertex='true' containerField='geometry'> \n"); - fprintf(fp," <Coordinate point='"); - + } // enf if dirty + }// end loop on PView::list + fprintf(fp," '/> \n"); + + fprintf(fp," <Color color='"); + _count=0; + for(unsigned int ipv = 0; ipv < PView::list.size(); ipv++){ + data = PView::list[ipv]->getData(true); + opt = PView::list[ipv]->getOptions(); + if( !data->getDirty() && opt->visible ) { + va=PView::list[ipv]->va_triangles; for(int ipt = 0; ipt < va->getNumVertices(); ipt += 3){ - if ( ( PView::getInnerBorder() && visible[_count+ipt/3] ) || !PView::getInnerBorder()) { - float *p0 = va->getVertexArray(3 * ipt); - float *p1 = va->getVertexArray(3 * (ipt + 1)); - float *p2 = va->getVertexArray(3 * (ipt + 2)); - /* - std::cout<<" PV" << ipv<<" ipt "<<ipt<<" coord "<<p0[0]<<"," - <<p0[1]<<","<<p0[2]<<"|"<<p1[0]<<","<<p1[1]<<","<<p1[2] - <<"|"<<p2[0]<<","<<p2[1]<<","<<p2[2]<<std::endl; - */ - fprintf(fp,"%e %e %e %e %e %e %e %e %e " - , p0[0], p0[1], p0[2] - , p1[0], p1[1], p1[2] - , p2[0], p2[1], p2[2]); - - } - } - fprintf(fp," '/> \n"); - fprintf(fp," <Color color='"); - for(int ipt = 0; ipt < va->getNumVertices(); ipt += 3){ - if ( ( PView::getInnerBorder() && visible[_count+ipt/3] ) || !PView::getInnerBorder() ) { - unsigned char *c0 = va->getColorArray(4 * ipt); - unsigned char *c1 = va->getColorArray(4 * (ipt+1)); - unsigned char *c2 = va->getColorArray(4 * (ipt+2)); - double rgba0[4] , rgba1[4] ,rgba2[4]; - UnsignedChar2rgba(c0,rgba0) ; - UnsignedChar2rgba(c1,rgba1) ; - UnsignedChar2rgba(c2,rgba2) ; - fprintf(fp,"%g %g %g %g %g %g %g %g %g " - , rgba0[0],rgba0[1],rgba0[2] - , rgba1[0],rgba1[1],rgba1[2] - , rgba2[0],rgba2[1],rgba2[2]); - } + if ( ( PView::getInnerBorder() && visible[_count] ) || !PView::getInnerBorder() ) { + unsigned char *c0 = va->getColorArray(4 * ipt); + unsigned char *c1 = va->getColorArray(4 * (ipt+1)); + unsigned char *c2 = va->getColorArray(4 * (ipt+2)); + double rgba0[4] , rgba1[4] ,rgba2[4]; + UnsignedChar2rgba(c0,rgba0) ; + UnsignedChar2rgba(c1,rgba1) ; + UnsignedChar2rgba(c2,rgba2) ; + /* + fprintf(fp,"%g %g %g %g %g %g %g %g %g " + , rgba0[0],rgba0[1],rgba0[2] + , rgba1[0],rgba1[1],rgba1[2] + , rgba2[0],rgba2[1],rgba2[2]); + */ + fprintf(fp,"%g %g %g %g %g %g %g %g %g " + , .5,.5,.5,.5,.5,.5,.5,.5,.5); + } + _count++; } - fprintf(fp," '/>\n"); - fprintf(fp," </IndexedTriangleSet> \n"); - fprintf(fp," <Appearance> \n"); - fprintf(fp," <Material transparency='%g' \n", PView::getTransparencyValue() ); - fprintf(fp," ambientIntensity=\"0.5\""); - fprintf(fp," diffuseColor=\".5 .5 .5\""); - fprintf(fp," emissiveColor=\"0.0 0.0 0.0\""); - fprintf(fp," shininess=\"0.25\""); - fprintf(fp," specularColor=\".1 .1 .1\" /> "); - fprintf(fp," </Appearance> \n"); - fprintf(fp,"</Shape> \n"); - fprintf(fp,"</Transform> \n"); - - _count += va->getNumVertices()/3; } // enf if dirty }// end loop on PView::list + fprintf(fp," '/>\n"); + fprintf(fp," </IndexedTriangleSet> \n"); + fprintf(fp,"</Shape> \n"); + fprintf(fp,"</Transform> \n"); fprintf(fp,"</Scene>\n"); fprintf(fp,"</X3D>\n"); @@ -555,29 +554,29 @@ static void writeX3DScaleBar(FILE *fp, PView *p, double xmin, double ymin, doubl double box = (horizontal ? width : height) / (opt->nbIso ? opt->nbIso : 1); for(int i = 0; i < opt->nbIso; i++) { - if(opt->intervalsType == PViewOptions::Continuous - || opt->intervalsType == PViewOptions::Discrete + if(opt->intervalsType == PViewOptions::Continuous + || opt->intervalsType == PViewOptions::Discrete || opt->intervalsType == PViewOptions::Numeric){ fprintf(fp," <Shape> \n"); fprintf(fp," <IndexedFaceSet colorPerVertex='true' normalPerVertex='true' coordIndex='0 1 2 3 -1' solid='false' ccw='true' > \n"); fprintf(fp," <Coordinate point='"); if(horizontal){ - fprintf(fp,"%e %e %e %e %e %e %e %e %e %e %e %e " + fprintf(fp,"%e %e %e %e %e %e %e %e %e %e %e %e " ,xmin + i * box , ymin, 0. ,xmin + (i + 1) * box, ymin, 0. ,xmin + (i + 1) * box, ymin + height, 0. ,xmin + i * box , ymin + height, 0.); } else{ - fprintf(fp,"%e %e %e %e %e %e %e %e %e %e %e %e " + fprintf(fp,"%e %e %e %e %e %e %e %e %e %e %e %e " ,xmin, ymin + i * box, 0. ,xmin + width, ymin + i * box, 0. ,xmin + width, ymin + (i + 1) * box, 0. ,xmin, ymin + (i + 1) * box, 0.); } fprintf(fp," '/> \n"); - - if(opt->intervalsType == PViewOptions::Discrete + + if(opt->intervalsType == PViewOptions::Discrete || opt->intervalsType == PViewOptions::Numeric){ double rgba[4]= { .5,.5,.5,1. }; unsigned int col = opt->getColor(i, opt->nbIso); @@ -737,3 +736,4 @@ static void writeX3DStringCenter( FILE *fp,char *label,double x, double y, doubl fprintf(fp," </Transform> \n"); } +