From: Wolfgang Bangerth Date: Mon, 19 Mar 2001 10:59:00 +0000 (+0000) Subject: Fix various bugs in VTK output. X-Git-Tag: v8.0.0~19529 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fca70840bf894dd85c03ef2ce0da779c1f6de520;p=dealii.git Fix various bugs in VTK output. git-svn-id: https://svn.dealii.org/trunk@4243 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/source/data_out_base.cc b/deal.II/base/source/data_out_base.cc index 796b2c6d1f..e4f67d0a91 100644 --- a/deal.II/base/source/data_out_base.cc +++ b/deal.II/base/source/data_out_base.cc @@ -1878,101 +1878,79 @@ void DataOutBase::write_vtk (const typename std::vector > &p // note that we have to print // d=1..3 dimensions out << "POINTS " << n_nodes << " double" << std::endl; - for (unsigned int d=1; d<=3; ++d) + for (typename std::vector >::const_iterator patch=patches.begin(); + patch!=patches.end(); ++patch) { - for (typename std::vector >::const_iterator patch=patches.begin(); - patch!=patches.end(); ++patch) + const unsigned int n_subdivisions = patch->n_subdivisions; + + switch (dim) { - const unsigned int n_subdivisions = patch->n_subdivisions; - - // if we have nonzero values for - // this coordinate - if (d<=spacedim) - { - switch (dim) - { - case 1: - { - for (unsigned int i=0; ivertices[1](0) * i / n_subdivisions) + - (patch->vertices[0](0) * (n_subdivisions-i) / n_subdivisions)) - << ' '; - break; - }; - - case 2: - { - for (unsigned int i=0; ivertices[1](d-1) * x_frac) + - (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) + - ((patch->vertices[2](d-1) * x_frac) + - (patch->vertices[3](d-1) * (1-x_frac))) * y_frac) - << ' '; - }; - break; - }; + case 1: + { + for (unsigned int i=0; ivertices[1](0) * i / n_subdivisions) + + (patch->vertices[0](0) * (n_subdivisions-i) / n_subdivisions)) + << " 0 0\n"; + break; + }; - case 3: + case 2: + { + for (unsigned int i=0; ivertices[1] * x_frac) + + (patch->vertices[0] * (1-x_frac))) * (1-y_frac) + + ((patch->vertices[2] * x_frac) + + (patch->vertices[3] * (1-x_frac))) * y_frac) + << " 0\n"; + }; + break; + }; + + case 3: + { + for (unsigned int i=0; ivertices[1](d-1) * x_frac) + - (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) + - ((patch->vertices[2](d-1) * x_frac) + - (patch->vertices[3](d-1) * (1-x_frac))) * y_frac) * (1-z_frac) + - (((patch->vertices[5](d-1) * x_frac) + - (patch->vertices[4](d-1) * (1-x_frac))) * (1-y_frac) + - ((patch->vertices[6](d-1) * x_frac) + - (patch->vertices[7](d-1) * (1-x_frac))) * y_frac) * z_frac) - << ' '; - }; - - break; + // note the broken + // design of hexahedra + // in deal.II, where + // first the z-component + // is counted up, before + // increasing the y- + // coordinate + const double x_frac = i * 1./n_subdivisions, + y_frac = k * 1./n_subdivisions, + z_frac = j * 1./n_subdivisions; + + // compute coordinates for + // this patch point + out << ((((patch->vertices[1] * x_frac) + + (patch->vertices[0] * (1-x_frac))) * (1-y_frac) + + ((patch->vertices[2] * x_frac) + + (patch->vertices[3] * (1-x_frac))) * y_frac) * (1-z_frac) + + (((patch->vertices[5] * x_frac) + + (patch->vertices[4] * (1-x_frac))) * (1-y_frac) + + ((patch->vertices[6] * x_frac) + + (patch->vertices[7] * (1-x_frac))) * y_frac) * z_frac) + << std::endl; }; - - default: - Assert (false, ExcNotImplemented()); - }; - } - else - // d>spacedim. write zeros instead - { - const unsigned int n_points - = static_cast(pow (static_cast(n_subdivisions+1), dim)); - for (unsigned int i=0; i > &p { for (unsigned int i=0; i > &p for (unsigned int i=0; i > &p { out << "8 " // note: vertex indices start with 1! - << first_vertex_of_patch+(i*(n_subdivisions+1)+j )*(n_subdivisions+1)+k +1 << ' ' - << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j )*(n_subdivisions+1)+k +1 << ' ' - << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j+1)*(n_subdivisions+1)+k +1 << ' ' - << first_vertex_of_patch+(i*(n_subdivisions+1)+j+1 )*(n_subdivisions+1)+k +1 << ' ' - << first_vertex_of_patch+(i*(n_subdivisions+1)+j )*(n_subdivisions+1)+k+1+1 << ' ' - << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j )*(n_subdivisions+1)+k+1+1 << ' ' - << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j+1)*(n_subdivisions+1)+k+1+1 << ' ' - << first_vertex_of_patch+(i*(n_subdivisions+1)+j+1 )*(n_subdivisions+1)+k+1+1 << ' ' + << first_vertex_of_patch+(i*(n_subdivisions+1)+j )*(n_subdivisions+1)+k << ' ' + << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j )*(n_subdivisions+1)+k << ' ' + << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j+1)*(n_subdivisions+1)+k << ' ' + << first_vertex_of_patch+(i*(n_subdivisions+1)+j+1 )*(n_subdivisions+1)+k << ' ' + << first_vertex_of_patch+(i*(n_subdivisions+1)+j )*(n_subdivisions+1)+k+1 << ' ' + << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j )*(n_subdivisions+1)+k+1 << ' ' + << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j+1)*(n_subdivisions+1)+k+1 << ' ' + << first_vertex_of_patch+(i*(n_subdivisions+1)+j+1 )*(n_subdivisions+1)+k+1 << ' ' << std::endl; }; break; @@ -2059,11 +2037,11 @@ void DataOutBase::write_vtk (const typename std::vector > &p Assert (false, ExcNotImplemented()); }; }; - out << std::endl; // next output the types of the // cells. since all cells are // the same, this is simple + out << "CELL_TYPES " << n_cells << std::endl; for (unsigned int i=0; i > &p copy(data_vectors[data_set].begin(), data_vectors[data_set].end(), std::ostream_iterator(out, " ")); - out << std::endl - << std::endl; + out << std::endl; }; // assert the stream is still ok