45#include "HoleInfoT.hh"
52template<
class MeshT >
54 : mesh_(_mesh), filler_(0)
59template<
class MeshT >
67template<
class MeshT >
75 mesh_->add_property( boundary_search,
"Boundary search" );
78 for (
auto e_it : mesh_->edges()) {
79 mesh_->property( boundary_search , e_it ) =
false;
84 for (
auto e_it : mesh_->edges()) {
87 if ( mesh_->property( boundary_search , e_it ) )
91 if ( !e_it.is_boundary())
100 typename MeshT::Point center(0,0,0);
107 currentHole.push_back( ch.
edge() );
109 center += mesh_->point( ch.
from() );
111 mesh_->property( boundary_search , ch.
edge() ) =
true;
118 if ( voh_it.is_boundary() )
122 typename MeshT::HalfedgeHandle op = ch.
opp();
123 typename MeshT::VertexOHalfedgeIter voh_it(*mesh_,op);
130 }
while ( ch != hh );
133 center /= currentHole.size();
139 for (
unsigned int i=0; i < currentHole.size(); i++){
140 typename MeshT::HalfedgeHandle hh = currentHole[i].h0();
142 if ( ! mesh_->is_boundary( hh ) )
143 hh = mesh_->opposite_halfedge_handle( hh );
145 typename MeshT::VertexHandle vh = mesh_->from_vertex_handle(hh);
147 typename MeshT::Normal n = mesh_->normal( vh );
149 typename MeshT::Point p = mesh_->point( vh );
151 if ( (p - center).norm() < (p + n - center).
norm() ){
160 holes_.push_back(currentHole);
163 mesh_->remove_property( boundary_search);
168template<
class MeshT >
172 if ( (uint) _index > holes_.size()){
173 std::cerr <<
"Cannot fill hole. Index invalid." << std::endl;
180 filler_->fill_hole( holes_[_index][0], _stages );
182 mesh_->garbage_collection();
184 MeshSelection::clearEdgeSelection(mesh_);
190template<
class MeshT >
196 filler_->fill_hole( _eh, _stages );
198 mesh_->garbage_collection();
200 MeshSelection::clearEdgeSelection(mesh_);
206template<
class MeshT >
213 filler_->fill_all_holes( _stages );
218template<
class MeshT >
222 if ( (uint) _index > holes_.size()){
223 std::cerr <<
"Cannot select hole. Index invalid." << std::endl;
227 for ( uint i = 0 ; i < (holes_[_index]).size() ; ++i ) {
228 mesh_->status( (holes_[_index])[i] ).set_selected(
true);
233template<
class MeshT >
237 _holeCenter =
typename MeshT::Point(0.0,0.0,0.0);
238 _holeNormal =
typename MeshT::Normal(0.0,0.0,0.0);
241 for (
size_t i = 0 ; i < holes_[_index].size() ; ++i ) {
242 const typename MeshT::HalfedgeHandle he = mesh_->halfedge_handle(holes_[_index][i],0);
243 const typename MeshT::VertexHandle vh_to = mesh_->to_vertex_handle(he);
245 _holeCenter += mesh_->point(vh_to);
246 _holeNormal += mesh_->normal(vh_to);
249 _holeCenter /=
typename MeshT::Scalar(holes_[_index].size());
250 _holeNormal /=
typename MeshT::Scalar(holes_[_index].size());
251 _holeNormal.normalize();
255template<
class MeshT >
259 if ( _index >= holes_.size() ) {
260 std::cerr <<
"Invalid hole index " << _index << std::endl;
264 _boundaryLength = 0.0;
266 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());
267 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());
269 for (
size_t i = 0 ; i < holes_[_index].size() ; ++i) {
272 typename MeshT::Point pos = mesh_->point(mesh_->from_vertex_handle(mesh_->halfedge_handle(holes_[_index][i],0)));
273 minCoord[0] = std::min(minCoord[0],pos[0]);
274 minCoord[1] = std::min(minCoord[1],pos[1]);
275 minCoord[2] = std::min(minCoord[2],pos[2]);
277 maxCoord[0] = std::max(maxCoord[0],pos[0]);
278 maxCoord[1] = std::max(maxCoord[1],pos[1]);
279 maxCoord[2] = std::max(maxCoord[2],pos[2]);
282 _edges = holes_[_index].size();
283 _diagonal = (maxCoord - minCoord).length();
289template<
class MeshT >
Functions for selection on a mesh.
void getHoleInfo(const unsigned int _index, size_t &_edges, typename MeshT::Scalar &_diagonal, typename MeshT::Scalar &_boundaryLength) const
void fillAllHoles(int _stages=3)
fill all holes
void getHolePostitionInfo(const int _index, typename MeshT::Normal &_holeNormal, typename MeshT::Point &_holeCenter) const
Collect information to fly to a hole.
void getHoles()
get all holes and store them internally
void selectHole(int _index)
select a hole with given index
std::vector< std::vector< typename OpenMesh::SmartEdgeHandle > > * holes()
get the holes vector
HoleInfo(MeshT *_mesh)
Konstruktor.
void fillHole(int _index, int _stages=3)
fill hole with given index
void update_normals()
Compute normals for all primitives.
Scalar calc_edge_length(EdgeHandle _eh) const
Compute normals for all primitives.
bool is_boundary() const
Returns true iff the handle is boundary.
Scalar norm(const VectorT< Scalar, DIM > &_v)
SmartVertexHandle from() const
Returns vertex at start of halfedge.
SmartHalfedgeHandle next() const
Returns next halfedge handle.
SmartEdgeHandle edge() const
Returns incident edge of halfedge.
SmartHalfedgeHandle opp() const
Returns opposite halfedge handle.
SmartVertexHandle to() const
Returns vertex pointed to by halfedge.
Smart version of VertexHandle contains a pointer to the corresponding mesh and allows easier access t...
PolyConnectivity::ConstVertexOHalfedgeRange outgoing_halfedges() const
Returns a range of incoming halfedges incident to the vertex (PolyConnectivity::voh_range())