Smoother Update, added function to respect feature vertices/lines/edges on the Mesh
Function skip_features() Defaults to false git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@86 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -58,7 +58,8 @@ namespace Smoother {
|
||||
template <class Mesh>
|
||||
SmootherT<Mesh>::
|
||||
SmootherT(Mesh& _mesh)
|
||||
: mesh_(_mesh)
|
||||
: mesh_(_mesh),
|
||||
skip_features_(false)
|
||||
{
|
||||
// request properties
|
||||
mesh_.request_vertex_status();
|
||||
@@ -154,6 +155,30 @@ set_active_vertices()
|
||||
active = ((nothing_selected || mesh_.status(v_it).selected())
|
||||
&& !mesh_.is_boundary(v_it)
|
||||
&& !mesh_.status(v_it).locked());
|
||||
|
||||
if ( skip_features_ ) {
|
||||
|
||||
active = active && !mesh_.status(v_it).feature();
|
||||
|
||||
typename Mesh::VertexOHalfedgeIter voh_it(mesh_,v_it);
|
||||
for ( ; voh_it ; ++voh_it ) {
|
||||
|
||||
// If the edge is a feature edge, skip the current vertex while smoothing
|
||||
if ( mesh_.status(mesh_.edge_handle(voh_it.handle())).feature() )
|
||||
active = false;
|
||||
|
||||
typename Mesh::FaceHandle fh1 = mesh_.face_handle(voh_it.handle() );
|
||||
typename Mesh::FaceHandle fh2 = mesh_.face_handle(mesh_.opposite_halfedge_handle(voh_it.handle() ) );
|
||||
|
||||
// If one of the faces is a feature, lock current vertex
|
||||
if ( fh1.is_valid() && mesh_.status( fh1 ).feature() )
|
||||
active = false;
|
||||
if ( fh2.is_valid() && mesh_.status( fh2 ).feature() )
|
||||
active = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
mesh_.property(is_active_, v_it) = active;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,16 +85,20 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
// constructor & destructor
|
||||
/** \brief constructor & destructor
|
||||
*
|
||||
* @param _mesh Reference to the mesh
|
||||
*/
|
||||
SmootherT( Mesh& _mesh );
|
||||
virtual ~SmootherT();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/// Initialize smoother
|
||||
/// \param _comp Determine component to smooth
|
||||
/// \param _cont
|
||||
/** Initialize smoother
|
||||
* \param _comp Determine component to smooth
|
||||
* \param _cont Determine Continuity
|
||||
*/
|
||||
void initialize(Component _comp, Continuity _cont);
|
||||
|
||||
|
||||
@@ -105,6 +109,12 @@ public:
|
||||
void disable_local_error_check();
|
||||
//@}
|
||||
|
||||
/** \brief enable or disable feature handling
|
||||
*
|
||||
* @param _state true : If features are selected on the mesh, they will be left unmodified\n
|
||||
* false : Features will be ignored
|
||||
*/
|
||||
void skip_features( bool _state ){ skip_features_ = _state; };
|
||||
|
||||
/// Do _n smoothing iterations
|
||||
virtual void smooth(unsigned int _n);
|
||||
@@ -158,6 +168,7 @@ protected:
|
||||
protected:
|
||||
|
||||
Mesh& mesh_;
|
||||
bool skip_features_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user