mirror of https://github.com/CGAL/cgal
Deal with write_VTU()
This commit is contained in:
parent
e7c0c9d57e
commit
5b6b521ca8
|
|
@ -17,4 +17,27 @@ template <class CDT>
|
|||
void write_VTU(std::ostream& os,
|
||||
const CDT& tr,
|
||||
IO::Mode mode = IO::BINARY);
|
||||
|
||||
|
||||
//!\ingroup PkgMesh2IO
|
||||
//! \brief writes the faces of a domain and its constrained edges embedded in
|
||||
//! a 2D constrained Delaunay triangulation using the `PolyData` XML
|
||||
//! format.
|
||||
//! The faces output are those for which `get(ipm, f)` returns
|
||||
//! `true` where `f`is a `CDT::Face_handle`,
|
||||
//! the edges are those for which `ConstrainedTriangulationFaceBase_2::is_constrained()` returns `true`.
|
||||
//! \tparam CDT a `Constrained_Delaunay_triangulation_2` with face type model of `DelaunayMeshFaceBase_2`.
|
||||
//!
|
||||
//! \param os the stream used for writing.
|
||||
//! \param tr the triangulated domain to be written.
|
||||
//! \param mode decides if the data should be written in binary (`BINARY`)
|
||||
//! or in \ascii (`ASCII`).
|
||||
//!
|
||||
template <class CDT, typename InDomainPmap>
|
||||
void write_VTU(std::ostream& os,
|
||||
const CDT& tr,
|
||||
InDomainPmap ipm,
|
||||
IO::Mode mode = IO::BINARY);
|
||||
|
||||
|
||||
} }
|
||||
|
|
|
|||
|
|
@ -35,10 +35,11 @@ namespace internal {
|
|||
|
||||
// writes the cells tags before binary data is appended
|
||||
|
||||
template <class CDT>
|
||||
template <class CDT, class InDomainPmap>
|
||||
void
|
||||
write_cells_tag_2(std::ostream& os,
|
||||
const CDT & tr,
|
||||
InDomainPmap in_domain,
|
||||
std::size_t number_of_triangles,
|
||||
std::map<typename CDT::Vertex_handle, std::size_t> & V,
|
||||
bool binary,
|
||||
|
|
@ -74,12 +75,12 @@ write_cells_tag_2(std::ostream& os,
|
|||
end = tr.finite_faces_end();
|
||||
fit != end; ++fit)
|
||||
{
|
||||
if(fit->is_in_domain())
|
||||
{
|
||||
os << V[fit->vertex(0)] << " ";
|
||||
os << V[fit->vertex(2)] << " ";
|
||||
os << V[fit->vertex(1)] << " ";
|
||||
}
|
||||
if(get(in_domain, fit))
|
||||
{
|
||||
os << V[fit->vertex(0)] << " ";
|
||||
os << V[fit->vertex(2)] << " ";
|
||||
os << V[fit->vertex(1)] << " ";
|
||||
}
|
||||
}
|
||||
for(typename CDT::Constrained_edges_iterator
|
||||
cei = tr.constrained_edges_begin(),
|
||||
|
|
@ -114,7 +115,7 @@ write_cells_tag_2(std::ostream& os,
|
|||
fit != tr.finite_faces_end() ;
|
||||
++fit )
|
||||
{
|
||||
if(fit->is_in_domain())
|
||||
if(get(in_domain, fit))
|
||||
{
|
||||
cells_offset += 3;
|
||||
os << cells_offset << " ";
|
||||
|
|
@ -149,7 +150,7 @@ write_cells_tag_2(std::ostream& os,
|
|||
fit != tr.finite_faces_end() ;
|
||||
++fit )
|
||||
{
|
||||
if(fit->is_in_domain())
|
||||
if(get(in_domain, fit))
|
||||
{
|
||||
os << "5 ";
|
||||
}
|
||||
|
|
@ -166,10 +167,11 @@ write_cells_tag_2(std::ostream& os,
|
|||
}
|
||||
|
||||
// writes the cells appended data at the end of the .vtu file
|
||||
template <class CDT>
|
||||
template <class CDT, class InDomainPmap>
|
||||
void
|
||||
write_cells_2(std::ostream& os,
|
||||
const CDT & tr,
|
||||
InDomainPmap in_domain,
|
||||
std::size_t number_of_triangles,
|
||||
std::map<typename CDT::Vertex_handle, std::size_t> & V)
|
||||
{
|
||||
|
|
@ -185,7 +187,7 @@ write_cells_2(std::ostream& os,
|
|||
end = tr.finite_faces_end();
|
||||
fit != end; ++fit)
|
||||
{
|
||||
if(fit->is_in_domain())
|
||||
if(get(in_domain, fit))
|
||||
{
|
||||
off += 3;
|
||||
offsets.push_back(off);
|
||||
|
|
@ -324,11 +326,12 @@ write_attributes_2(std::ostream& os,
|
|||
write_vector(os,att);
|
||||
}
|
||||
|
||||
template <class CDT>
|
||||
template <class CDT, class InDomainPmap>
|
||||
void write_VTU_with_attributes(std::ostream& os,
|
||||
const CDT& tr,
|
||||
std::vector<std::pair<const char*, const std::vector<double>*> >& attributes,
|
||||
Mode mode = BINARY)
|
||||
const CDT& tr,
|
||||
InDomainPmap in_domain,
|
||||
std::vector<std::pair<const char*, const std::vector<double>*> >& attributes,
|
||||
Mode mode = BINARY)
|
||||
{
|
||||
typedef typename CDT::Vertex_handle Vertex_handle;
|
||||
std::map<Vertex_handle, std::size_t> V;
|
||||
|
|
@ -355,14 +358,14 @@ void write_VTU_with_attributes(std::ostream& os,
|
|||
end = tr.finite_faces_end();
|
||||
fit != end; ++fit)
|
||||
{
|
||||
if(fit->is_in_domain()) ++number_of_triangles;
|
||||
if(get(in_domain, fit)) ++number_of_triangles;
|
||||
}
|
||||
os << " <Piece NumberOfPoints=\"" << tr.number_of_vertices()
|
||||
<< "\" NumberOfCells=\"" << number_of_triangles + std::distance(tr.constrained_edges_begin(), tr.constrained_edges_end()) << "\">\n";
|
||||
std::size_t offset = 0;
|
||||
const bool binary = (mode == BINARY);
|
||||
write_cdt_points_tag(os,tr,V,binary,offset);
|
||||
write_cells_tag_2(os,tr,number_of_triangles, V,binary,offset);
|
||||
write_cells_tag_2(os,tr, in_domain, number_of_triangles, V,binary,offset);
|
||||
if(attributes.empty())
|
||||
os << " <CellData >\n";
|
||||
else
|
||||
|
|
@ -377,7 +380,7 @@ void write_VTU_with_attributes(std::ostream& os,
|
|||
if (binary) {
|
||||
os << "<AppendedData encoding=\"raw\">\n_";
|
||||
write_cdt_points(os,tr,V); // write points before cells to fill the std::map V
|
||||
write_cells_2(os,tr, number_of_triangles, V);
|
||||
write_cells_2(os, tr, in_domain, number_of_triangles, V);
|
||||
for(std::size_t i = 0; i< attributes.size(); ++i)
|
||||
write_attributes_2(os, *attributes[i].second);
|
||||
}
|
||||
|
|
@ -386,15 +389,26 @@ void write_VTU_with_attributes(std::ostream& os,
|
|||
|
||||
} // namespace internal
|
||||
|
||||
template <class CDT>
|
||||
template <class CDT, class InDomainPmap>
|
||||
void write_VTU(std::ostream& os,
|
||||
const CDT& tr,
|
||||
InDomainPmap ipm,
|
||||
Mode mode = BINARY)
|
||||
{
|
||||
std::vector<std::pair<const char*, const std::vector<double>*> > dummy_atts;
|
||||
internal::write_VTU_with_attributes(os, tr, ipm, dummy_atts, mode);
|
||||
}
|
||||
|
||||
template <class CDT, class InDomainPmap>
|
||||
void write_VTU(std::ostream& os,
|
||||
const CDT& tr,
|
||||
Mode mode = BINARY)
|
||||
{
|
||||
std::vector<std::pair<const char*, const std::vector<double>*> > dummy_atts;
|
||||
internal::write_VTU_with_attributes(os, tr, dummy_atts, mode);
|
||||
internal::In_domain<CDT> in_domain;
|
||||
write_VTU(os, tr, in_domain, mode);
|
||||
}
|
||||
|
||||
|
||||
} // namespace IO
|
||||
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
|
|
|
|||
Loading…
Reference in New Issue