45 #include "HoleInfoT.hh" 52 template<
class MeshT >
54 : mesh_(_mesh), filler_(0)
59 template<
class MeshT >
67 template<
class MeshT >
75 mesh_->add_property( boundary_search,
"Boundary search" );
78 typename MeshT::EdgeIter e_it, e_end=mesh_->edges_end();
79 for (e_it=mesh_->edges_begin(); e_it!=e_end; ++e_it) {
80 mesh_->property( boundary_search , *e_it ) =
false;
85 for (e_it=mesh_->edges_begin(); e_it!=e_end; ++e_it) {
88 if ( mesh_->property( boundary_search , *e_it ) )
92 if ( !mesh_->is_boundary(*e_it))
96 typename MeshT::HalfedgeHandle hh = mesh_->halfedge_handle( *e_it, 0 );
97 if ( ! mesh_->is_boundary( hh ) )
98 hh = mesh_->opposite_halfedge_handle( hh );
101 typename MeshT::Point center(0,0,0);
106 typename MeshT::HalfedgeHandle ch = hh;
108 currentHole.push_back( mesh_->edge_handle(ch) );
110 center += mesh_->point( mesh_->from_vertex_handle(ch) );
112 mesh_->property( boundary_search , mesh_->edge_handle(ch) ) =
true;
116 typename MeshT::VertexHandle vh = mesh_->to_vertex_handle(ch);
118 for (
typename MeshT::VertexOHalfedgeIter voh_it(*mesh_,vh); voh_it.is_valid(); ++voh_it)
119 if ( mesh_->is_boundary( *voh_it ) )
123 typename MeshT::HalfedgeHandle op = mesh_->opposite_halfedge_handle( ch );
124 typename MeshT::VertexOHalfedgeIter voh_it(*mesh_,op);
129 ch = mesh_->next_halfedge_handle( ch );
131 }
while ( ch != hh );
134 center /= currentHole.size();
140 for (
unsigned int i=0; i < currentHole.size(); i++){
141 typename MeshT::HalfedgeHandle hh = mesh_->halfedge_handle( currentHole[i], 0 );
143 if ( ! mesh_->is_boundary( hh ) )
144 hh = mesh_->opposite_halfedge_handle( hh );
146 typename MeshT::VertexHandle vh = mesh_->from_vertex_handle(hh);
148 typename MeshT::Normal n = mesh_->normal( vh );
150 typename MeshT::Point p = mesh_->point( vh );
152 if ( (p - center).norm() < (p + n - center).norm() ){
161 holes_.push_back(currentHole);
164 mesh_->remove_property( boundary_search);
169 template<
class MeshT >
173 if ( (uint) _index > holes_.size()){
174 std::cerr <<
"Cannot fill hole. Index invalid." << std::endl;
181 filler_->fill_hole( holes_[_index][0], _stages );
183 mesh_->garbage_collection();
185 MeshSelection::clearEdgeSelection(mesh_);
187 mesh_->update_normals();
191 template<
class MeshT >
197 filler_->fill_hole( _eh, _stages );
199 mesh_->garbage_collection();
201 MeshSelection::clearEdgeSelection(mesh_);
203 mesh_->update_normals();
207 template<
class MeshT >
214 filler_->fill_all_holes( _stages );
219 template<
class MeshT >
223 if ( (uint) _index > holes_.size()){
224 std::cerr <<
"Cannot select hole. Index invalid." << std::endl;
228 for ( uint i = 0 ; i < (holes_[_index]).size() ; ++i ) {
229 mesh_->status( (holes_[_index])[i] ).set_selected(
true);
234 template<
class MeshT >
238 _holeCenter =
typename MeshT::Point(0.0,0.0,0.0);
239 _holeNormal =
typename MeshT::Normal(0.0,0.0,0.0);
242 for (
size_t i = 0 ; i < holes_[_index].size() ; ++i ) {
243 const typename MeshT::HalfedgeHandle he = mesh_->halfedge_handle(holes_[_index][i],0);
244 const typename MeshT::VertexHandle vh_to = mesh_->to_vertex_handle(he);
246 _holeCenter += mesh_->point(vh_to);
247 _holeNormal += mesh_->normal(vh_to);
250 _holeCenter /=
typename MeshT::Scalar(holes_[_index].size());
251 _holeNormal /=
typename MeshT::Scalar(holes_[_index].size());
252 _holeNormal.normalize();
256 template<
class MeshT >
260 if ( _index >= holes_.size() ) {
261 std::cerr <<
"Invalid hole index " << _index << std::endl;
265 _boundaryLength = 0.0;
267 typename MeshT::Point minCoord =
typename MeshT::Point(std::numeric_limits<typename MeshT::Scalar>::max(),std::numeric_limits<typename MeshT::Scalar>::max(),std::numeric_limits<typename MeshT::Scalar>::max());
268 typename MeshT::Point maxCoord =
typename MeshT::Point(-std::numeric_limits<typename MeshT::Scalar>::max(),-std::numeric_limits<typename MeshT::Scalar>::max(),-std::numeric_limits<typename MeshT::Scalar>::max());
270 for (
size_t i = 0 ; i < holes_[_index].size() ; ++i) {
271 _boundaryLength += mesh_->calc_edge_length(holes_[_index][i]);
273 typename MeshT::Point pos = mesh_->point(mesh_->from_vertex_handle(mesh_->halfedge_handle(holes_[_index][i],0)));
274 minCoord[0] = std::min(minCoord[0],pos[0]);
275 minCoord[1] = std::min(minCoord[1],pos[1]);
276 minCoord[2] = std::min(minCoord[2],pos[2]);
278 maxCoord[0] = std::max(maxCoord[0],pos[0]);
279 maxCoord[1] = std::max(maxCoord[1],pos[1]);
280 maxCoord[2] = std::max(maxCoord[2],pos[2]);
283 _edges = holes_[_index].size();
284 _diagonal = (maxCoord - minCoord).length();
290 template<
class MeshT >
void getHoleInfo(const unsigned int _index, size_t &_edges, typename MeshT::Scalar &_diagonal, typename MeshT::Scalar &_boundaryLength) const
void selectHole(int _index)
select a hole with given index
void fillAllHoles(int _stages=3)
fill all holes
Functions for selection on a mesh.
void fillHole(int _index, int _stages=3)
fill hole with given index
void getHoles()
get all holes and store them internally
void getHolePostitionInfo(const int _index, typename MeshT::Normal &_holeNormal, typename MeshT::Point &_holeCenter) const
Collect information to fly to a hole.
std::vector< std::vector< typename MeshT::EdgeHandle > > * holes()
get the holes vector
HoleInfo(MeshT *_mesh)
Konstruktor.