8#include <boost/shared_ptr.hpp>
9#include <boost/tuple/tuple.hpp>
10#include <boost/tuple/tuple_comparison.hpp>
11#include <boost/timer/progress_display.hpp>
13#include <OpenVolumeMesh/Mesh/PolyhedralMesh.hh>
14#include <OpenVolumeMesh/Geometry/VectorT.hh>
26 typedef boost::tuple<VertexHandle, VertexHandle, VertexHandle> FaceTuple;
36 v_component_(_cpy.v_component_),
37 vertex_(0.0, 0.0, 0.0),
43 void add_vertex_component(
double _comp) {
45 if(v_component_ > 2) {
46 std::cerr <<
"Vertices of dimension higher than three not supported!" << std::endl;
49 vertex_[v_component_] = _comp;
51 if(v_component_ == 3) {
63 void add_cell_vertex(
unsigned int _idx) {
68 if(c_vertices_.size() == 4) {
70 add_tetrahedral_cell();
77 void set_num_cells(
unsigned int _n) {
79 if(progress_.get() == NULL) {
80 progress_.reset(
new boost::timer::progress_display(_n));
84 void add_tetrahedral_cell() {
86 if(c_vertices_.size() != 4) {
87 std::cerr <<
"The specified cell is not incident to four vertices!" << std::endl;
92 Vec3d midP(0.0, 0.0, 0.0);
94 for(std::vector<OpenVolumeMesh::VertexHandle>::const_iterator it = c_vertices_.begin();
95 it != c_vertices_.end(); ++it) {
102 std::sort(c_vertices_.begin(), c_vertices_.end());
104 std::vector<FaceTuple> tuples;
107 tuples.push_back(FaceTuple(c_vertices_[0], c_vertices_[1], c_vertices_[2]));
108 tuples.push_back(FaceTuple(c_vertices_[1], c_vertices_[2], c_vertices_[3]));
109 tuples.push_back(FaceTuple(c_vertices_[0], c_vertices_[2], c_vertices_[3]));
110 tuples.push_back(FaceTuple(c_vertices_[0], c_vertices_[1], c_vertices_[3]));
113 std::vector<HalfFaceHandle> cell_halffaces;
115 for(std::vector<FaceTuple>::const_iterator it = tuples.begin();
116 it != tuples.end(); ++it) {
119 FaceMap::iterator f = faceMap_.find(*it);
120 if(f == faceMap_.end()) {
130 Vec3d n = (e1 % e2).normalize();
132 std::vector<VertexHandle> v_vec;
133 v_vec.push_back(it->get<0>());
134 v_vec.push_back(it->get<1>());
135 v_vec.push_back(it->get<2>());
142 if(((midP - mesh_.
vertex(it->get<0>())) | n) > 0.0) {
160 std::vector<HalfEdgeHandle> hes = mesh_.
face(fh).halfedges();
162 assert(hes.size() == 3);
169 Vec3d n = (e1 % e2).normalize();
171 if(((midP - mesh_.
vertex(mesh_.
halfedge(hes[0]).from_vertex())) | n) > 0.0) {
182 assert(cell_halffaces.size() == 4);
186 mesh_.
add_cell(cell_halffaces,
true);
188 mesh_.
add_cell(cell_halffaces,
false);
192 if((progress_.get() != NULL) && (progress_->expected_count() != 0))
198 typedef std::map<FaceTuple, OpenVolumeMesh::FaceHandle> FaceMap;
200 unsigned int v_component_;
203 std::vector<VertexHandle> c_vertices_;
209 boost::shared_ptr<boost::timer::progress_display> progress_;
VertexHandle add_vertex(const VecT &_p)
Add a geometric point to the mesh.
const VecT & vertex(VertexHandle _vh) const
Get point _vh's coordinates.
virtual FaceHandle add_face(std::vector< HalfEdgeHandle > _halfedges, bool _topologyCheck=false)
Add face via incident edges.
static HalfFaceHandle halfface_handle(FaceHandle _h, const unsigned char _subIdx)
Conversion function.
virtual CellHandle add_cell(std::vector< HalfFaceHandle > _halffaces, bool _topologyCheck=false)
Add cell via incident halffaces.
Edge halfedge(HalfEdgeHandle _halfEdgeHandle) const
Get edge that corresponds to halfedge with handle _halfEdgeHandle.
const Face & face(FaceHandle _faceHandle) const
Get face with handle _faceHandle.