From: nauber Date: Fri, 21 May 1999 12:04:28 +0000 (+0000) Subject: Some corrections, renamed eps_output_data to EpsOutputData X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14099a7abcc4736b7f8d8018f9d51e44917e57a5;p=dealii-svn.git Some corrections, renamed eps_output_data to EpsOutputData git-svn-id: https://svn.dealii.org/trunk@1346 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/numerics/data_io.h b/deal.II/deal.II/include/numerics/data_io.h index bd6de39843..ca38f0dfd5 100644 --- a/deal.II/deal.II/include/numerics/data_io.h +++ b/deal.II/deal.II/include/numerics/data_io.h @@ -305,10 +305,10 @@ class DataIn { * (EPS) without the need for another graphics tool. * #write_epsgrid# writes just the 2d grid - This is obsolete and * should be removed. The functionality is provided through #write_eps# - * and #eps_output_data# now. + * and #EpsOutputData# now. * #write_eps# can use one data vector for height information and one * cell vector for shading information. Control is done through an - * object of class #eps_output_data# as follows. + * object of class #EpsOutputData# as follows. * * Vectors are added as usual by #add_data_vector#. Then one has to * decide, wether to produce a 2D or 3D plot. This is done by setting @@ -453,7 +453,7 @@ class DataOut { * default constructed object is used. */ void write_eps (ostream &out, - const eps_output_data &EOD = eps_output_data()) const; + const EpsOutputData &eod = EpsOutputData()) const; /** * Write grid in Encapsulated @@ -665,7 +665,7 @@ class DataOut { * Class of data for vertices * for eps output. */ - class eps_vertex_data{ + class EpsVertexData{ public: /** * Coordinates @@ -678,14 +678,14 @@ class DataOut { * Default Constructor; * needed for STL. */ - eps_vertex_data() + EpsVertexData() {}; /** * Constructor that takes three * coordinate values as argument. */ - eps_vertex_data(double a, double b, double c):x(a),y(b),z(c) + EpsVertexData(double a, double b, double c):x(a),y(b),z(c) {}; /** @@ -701,13 +701,13 @@ class DataOut { * projection and output. Because of this all * output data is put into a STL multiset. */ - class eps_cell_data{ + class EpsCellData{ public: /** * STL-vector of vertices */ - vector vertices; + EpsVertexData vertices[4]; /** * Color values @@ -725,7 +725,7 @@ class DataOut { * Comparison operator for * sorting */ - bool operator < (const eps_cell_data &) const; + bool operator < (const EpsCellData &) const; }; }; @@ -735,26 +735,26 @@ class DataOut { * documentation of class DataOut for * description. */ -class eps_output_data{ +class EpsOutputData{ public: /** * Different types of * colorization */ - typedef enum {None,Vector,Shaded,Black,White} color_type; + typedef enum {None,Vector,Shaded,Black,White} ColorType; /** * Type of height information */ - color_type height_type; + ColorType height_type; /** * Cell shading */ - color_type cell_type; + ColorType cell_type; /** * Boundary color */ - color_type cell_boundary_type; + ColorType cell_boundary_type; /** * Vector with height information @@ -782,7 +782,7 @@ class eps_output_data{ /** * Default constructor */ - eps_output_data(); + EpsOutputData(); /** * Color scaling diff --git a/deal.II/deal.II/source/numerics/data_io.cc b/deal.II/deal.II/source/numerics/data_io.cc index 2a06502e5e..301c56e580 100644 --- a/deal.II/deal.II/source/numerics/data_io.cc +++ b/deal.II/deal.II/source/numerics/data_io.cc @@ -1107,7 +1107,7 @@ void DataOut<2>::write_epsgrid (ostream &out) const { template <> -void DataOut<2>::write_eps (ostream &out, const eps_output_data &EOD) const { +void DataOut<2>::write_eps (ostream &out, const EpsOutputData &eod) const { Assert (dofs != 0, ExcNoDoFHandlerSelected()); { @@ -1135,27 +1135,28 @@ void DataOut<2>::write_eps (ostream &out, const eps_output_data &EOD) const { // copying them to a multiset. // Perform the necessary turn. DoFHandler<2>::active_cell_iterator endc = dofs->end(); - unsigned cell_index=0; - multiset::eps_cell_data> cells; - multiset::eps_cell_data> cells2; + multiset::EpsCellData> cells; + multiset::EpsCellData> cells2; - bool cell_data_p = ((cell_data.size())>0) && (EOD.cell_type == EOD.Vector); + bool cell_data_p = ((cell_data.size())>0) && (eod.cell_type == EpsOutputData::Vector); - for(DoFHandler<2>::active_cell_iterator cell=dofs->begin_active(); - cell!=endc; ++cell, ++cell_index) + unsigned cell_index; + DoFHandler<2>::active_cell_iterator cell; + for(cell_index=0, cell=dofs->begin_active(); + cell!=endc; + ++cell, ++cell_index) { - eps_cell_data cd; - cd.vertices.resize(4); - for (unsigned int i=0; i<4; i++) + EpsCellData cd; + for (unsigned int i=0; i<4; ++i) { (cd.vertices[i]).x=cell->vertex(i)(0); (cd.vertices[i]).y=cell->vertex(i)(1); - switch (EOD.height_type) + switch (eod.height_type) { - case EOD.Vector: - (cd.vertices[i]).z=(*dof_data[EOD.height_vector].data)(cell->vertex_dof_index(i,0)); + case EpsOutputData::Vector: + (cd.vertices[i]).z=(*dof_data[eod.height_vector].data)(cell->vertex_dof_index(i,0)); break; - case EOD.None: + case EpsOutputData::None: (cd.vertices[i]).z=0; break; default: @@ -1163,11 +1164,11 @@ void DataOut<2>::write_eps (ostream &out, const eps_output_data &EOD) const { }; }; - if (EOD.height_type==EOD.Vector) - cd.turn(EOD.azimuth,EOD.elevation); + if (eod.height_type==EpsOutputData::Vector) + cd.turn(eod.azimuth,eod.elevation); if (cell_data_p) - cd.red=(*cell_data[EOD.cell_vector].data)(cell_index); + cd.red=(*cell_data[eod.cell_vector].data)(cell_index); cells.insert(cd); }; @@ -1175,8 +1176,6 @@ void DataOut<2>::write_eps (ostream &out, const eps_output_data &EOD) const { // multiset cells. First we look // for extrema. - - double xvv,yvv,cvv; double xmin=cells.begin()->vertices[0].x; double xmax=xmin; double ymin=cells.begin()->vertices[0].y; @@ -1184,11 +1183,12 @@ void DataOut<2>::write_eps (ostream &out, const eps_output_data &EOD) const { float cell_vector_min=cells.begin()->red; float cell_vector_max=cell_vector_min; - for(typename multiset::eps_cell_data>::iterator c=cells.begin(); + for(typename multiset::EpsCellData>::iterator c=cells.begin(); c!=cells.end(); ++c, ++cell_index) { - for (unsigned int i=0; i<4; i++) + for (unsigned int i=0; i<4; ++i) { + double xvv,yvv; xvv=c->vertices[i].x; xmin=(xmin < xvv ? xmin : xvv); xmax=(xmax > xvv ? xmax : xvv); @@ -1199,6 +1199,7 @@ void DataOut<2>::write_eps (ostream &out, const eps_output_data &EOD) const { } if (cell_data_p) { + double cvv; cvv = c->red; cell_vector_max = (cell_vector_max > cvv ? cell_vector_max : cvv); cell_vector_min = (cell_vector_min < cvv ? cell_vector_min : cvv); @@ -1209,15 +1210,15 @@ void DataOut<2>::write_eps (ostream &out, const eps_output_data &EOD) const { // If we want shaded output we can // do the shading now. - if (EOD.cell_type==EOD.Shaded) + if (eod.cell_type==EpsOutputData::Shaded) { double spann1[3], spann2[3], normal[3]; double light_norm, normal_norm; float color; - for (typename multiset::eps_cell_data>::iterator c=cells.begin();c!=cells.end();c++) + for (typename multiset::EpsCellData>::iterator c=cells.begin();c!=cells.end();++c) { - eps_cell_data cd(*c); + EpsCellData cd(*c); spann1[0]=spann2[0]=cd.vertices[0].x; spann1[1]=spann2[1]=cd.vertices[0].y; @@ -1236,9 +1237,9 @@ void DataOut<2>::write_eps (ostream &out, const eps_output_data &EOD) const { normal[2] = spann1[0]*spann2[1]-spann1[1]*spann2[0]; normal_norm = sqrt(normal[0]*normal[0]+normal[1]*normal[1]+normal[2]*normal[2]); - light_norm = sqrt(EOD.light[0]*EOD.light[0]+EOD.light[1]*EOD.light[1]+EOD.light[2]*EOD.light[2]); + light_norm = sqrt(eod.light[0]*eod.light[0]+eod.light[1]*eod.light[1]+eod.light[2]*eod.light[2]); - color = EOD.light[0]*normal[0]+EOD.light[1]*normal[1]+EOD.light[2]*normal[2]; + color = eod.light[0]*normal[0]+eod.light[1]*normal[1]+eod.light[2]*normal[2]; color /= light_norm * normal_norm; cd.red=color; @@ -1260,34 +1261,31 @@ void DataOut<2>::write_eps (ostream &out, const eps_output_data &EOD) const { // this so that it is in the range // between 0 and 1. - double xscale = 300 / (xmax-xmin); - double yscale = 300 / (ymax-ymin); - double scale = (xscale < yscale ? xscale : yscale); + const double scale = 300 / (xmax-xmin > ymax-ymin ? xmax-xmin : ymax-ymin); cells.clear(); - - for (typename multiset::eps_cell_data>::iterator c=cells2.begin(); + for (typename multiset::EpsCellData>::iterator c=cells2.begin(); c!=cells2.end(); ++c) { - eps_cell_data cd (*c); - for (unsigned int i=0; i<4; i++) + EpsCellData cd (*c); + for (unsigned int i=0; i<4; ++i) { cd.vertices[i].x=(cd.vertices[i].x-xmin)*scale; cd.vertices[i].y=(cd.vertices[i].y-ymin)*scale; }; if (cell_data_p) - EOD.color(cd.red,cell_vector_max,cell_vector_min,cd.red,cd.green,cd.blue); + eod.color(cd.red,cell_vector_max,cell_vector_min,cd.red,cd.green,cd.blue); cells.insert(cd); }; // Now we are ready to output... - cell_data_p = cell_data_p || (EOD.cell_type==EOD.Shaded); + cell_data_p = cell_data_p || (eod.cell_type==EpsOutputData::Shaded); - for (typename multiset::eps_cell_data>::iterator c=cells.begin(); + for (typename multiset::EpsCellData>::iterator c=cells.begin(); c!=cells.end(); ++c) { if (cell_data_p) @@ -1300,15 +1298,15 @@ void DataOut<2>::write_eps (ostream &out, const eps_output_data &EOD) const { << " closepath fill" << endl; }; - if (EOD.cell_boundary_type == EOD.Black || - EOD.cell_boundary_type == EOD.White) + if (eod.cell_boundary_type == EpsOutputData::Black || + eod.cell_boundary_type == EpsOutputData::White) { - switch (EOD.cell_boundary_type) + switch (eod.cell_boundary_type) { - case EOD.Black: + case EpsOutputData::Black: out << "0"; break; - case EOD.White: + case EpsOutputData::White: out << "1"; break; default: @@ -1338,8 +1336,8 @@ void DataOut::write_epsgrid (ostream &/*out*/) const { template -void DataOut::write_eps (ostream &/*out*/, - const eps_output_data &/*EOD*/) const { +void DataOut::write_eps (ostream &, + const EpsOutputData &) const{ // this is for all other dimensions that // are not explicitely specialized Assert (false, ExcNotImplemented()); @@ -1438,13 +1436,13 @@ string DataOut::get_output_format_names () { template -bool DataOut::eps_cell_data::operator < (const eps_cell_data &other) const +bool DataOut::EpsCellData::operator < (const EpsCellData &other) const { double maxz = vertices[0].z, othermaxz = other.vertices[0].z; unsigned i; - for (i=1; i<4; i++) + for (i=1; i<4; ++i) { maxz = (maxz > vertices[i].z ? maxz : vertices[i].z); othermaxz = (othermaxz > other.vertices[i].z ? othermaxz : other.vertices[i].z); @@ -1456,7 +1454,7 @@ bool DataOut::eps_cell_data::operator < (const eps_cell_data &other) const template -void DataOut::eps_vertex_data::turn(double azi, double ele) +void DataOut::EpsVertexData::turn(double azi, double ele) { double nx,ny,nz; @@ -1488,14 +1486,14 @@ void DataOut::eps_vertex_data::turn(double azi, double ele) template -void DataOut::eps_cell_data::turn(double azi, double ele) +void DataOut::EpsCellData::turn(double azi, double ele) { - for (unsigned i=0; i<4; i++) + for (unsigned i=0; i<4; ++i) vertices[i].turn(azi,ele); }; -eps_output_data::eps_output_data() +EpsOutputData::EpsOutputData() : height_type(None), cell_type(None), cell_boundary_type (Black), @@ -1536,7 +1534,7 @@ eps_output_data::eps_output_data() // { 0 (3) - (4) // { ( 4*x- xmin-3*xmax)/(xmax-xmin) (4) - (5) -void eps_output_data::color(const float x, const float xmax, const float xmin, +void EpsOutputData::color(const float x, const float xmax, const float xmin, float &r, float &g, float &b) const { float sum = xmax+ xmin;