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_;