Loading...
Searching...
No Matches
SmootherT.hh
Go to the documentation of this file.
/* ========================================================================= *
* *
* OpenMesh *
* Copyright (c) 2001-2022, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openmesh.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenMesh. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
* ========================================================================= */
//=============================================================================
//
// CLASS SmootherT
//
//=============================================================================
#ifndef OPENMESH_SMOOTHER_SMOOTHERT_HH
#define OPENMESH_SMOOTHER_SMOOTHERT_HH
//== INCLUDES =================================================================
#include <OpenMesh/Core/System/config.hh>
#include <OpenMesh/Core/Utils/Property.hh>
#include <OpenMesh/Core/Utils/Noncopyable.hh>
//== FORWARDDECLARATIONS ======================================================
//== NAMESPACES ===============================================================
namespace OpenMesh {
namespace Smoother {
//== CLASS DEFINITION =========================================================
template <class Mesh>
class SmootherT : private Utils::Noncopyable
{
public:
typedef typename Mesh::Scalar Scalar;
typedef typename Mesh::Point Point;
typedef typename Mesh::Normal NormalType;
typedef typename Mesh::VertexHandle VertexHandle;
typedef typename Mesh::EdgeHandle EdgeHandle;
// initialize smoother
enum Component {
Tangential,
Normal,
Tangential_and_Normal
};
enum Continuity {
C0,
C1,
C2
};
public:
SmootherT( Mesh& _mesh );
virtual ~SmootherT();
public:
//===========================================================================
//===========================================================================
void initialize(Component _comp, Continuity _cont);
virtual void smooth(unsigned int _n);
//===========================================================================
//===========================================================================
void set_relative_local_error(Scalar _err);
void set_absolute_local_error(Scalar _err);
void disable_local_error_check();
void skip_features( bool _state ){ skip_features_ = _state; };
private:
void set_active_vertices();
// single steps of smoothing
void compute_new_positions();
void project_to_tangent_plane();
void local_error_check();
void move_points();
protected:
// override these
virtual void compute_new_positions_C0() = 0;
virtual void compute_new_positions_C1() = 0;
protected:
// misc helpers
const Point& orig_position(VertexHandle _vh) const
{ return mesh_.property(original_positions_, _vh); }
const NormalType& orig_normal(VertexHandle _vh) const
{ return mesh_.property(original_normals_, _vh); }
const Point& new_position(VertexHandle _vh) const
{ return mesh_.property(new_positions_, _vh); }
void set_new_position(VertexHandle _vh, const Point& _p)
{ mesh_.property(new_positions_, _vh) = _p; }
bool is_active(VertexHandle _vh) const
{ return mesh_.property(is_active_, _vh); }
Component component() const { return component_; }
Continuity continuity() const { return continuity_; }
protected:
Mesh& mesh_;
bool skip_features_;
private:
Scalar tolerance_;
Scalar normal_deviation_;
Component component_;
Continuity continuity_;
OpenMesh::VPropHandleT<Point> original_positions_;
OpenMesh::VPropHandleT<NormalType> original_normals_;
OpenMesh::VPropHandleT<Point> new_positions_;
OpenMesh::VPropHandleT<bool> is_active_;
};
//=============================================================================
} // namespace Smoother
} // namespace OpenMesh
//=============================================================================
#if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SMOOTHERT_C)
#define OPENMESH_SMOOTHERT_TEMPLATES
#include "SmootherT_impl.hh"
#endif
//=============================================================================
#endif // OPENMESH_SMOOTHER_SMOOTHERT_HH defined
//=============================================================================
SmootherT_impl.hh
OpenMesh
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition MeshItems.hh:59
OpenMesh::VertexHandle
Handle for a vertex entity.
Definition Handles.hh:121
OpenMesh::PolyMesh_ArrayKernelT
Polygonal mesh based on the ArrayKernel.
Definition PolyMesh_ArrayKernelT.hh:96
OpenMesh::PolyMeshT::VertexHandle
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition PolyMeshT.hh:136
OpenMesh::PolyMeshT::Scalar
Kernel::Scalar Scalar
Scalar type.
Definition PolyMeshT.hh:110
OpenMesh::PolyMeshT::EdgeHandle
Kernel::EdgeHandle EdgeHandle
Scalar type.
Definition PolyMeshT.hh:138
OpenMesh::PolyMeshT::Normal
Kernel::Normal Normal
Normal type.
Definition PolyMeshT.hh:114
OpenMesh::PolyMeshT::Point
Kernel::Point Point
Coordinate type.
Definition PolyMeshT.hh:112
OpenMesh::Utils::Noncopyable
This class demonstrates the non copyable idiom.
Definition Noncopyable.hh:72
OpenMesh::VPropHandleT
Handle representing a vertex property.
Definition Property.hh:417
OpenMesh::Smoother::SmootherT
Base class for smoothing algorithms.
Definition SmootherT.hh:77
OpenMesh::Smoother::SmootherT::smooth
virtual void smooth(unsigned int _n)
Do _n smoothing iterations.
Definition SmootherT_impl.hh:302
OpenMesh::Smoother::SmootherT::Component
Component
Definition SmootherT.hh:87
OpenMesh::Smoother::SmootherT::Tangential_and_Normal
@ Tangential_and_Normal
Smooth tangential and normal direction.
Definition SmootherT.hh:90
OpenMesh::Smoother::SmootherT::Tangential
@ Tangential
Smooth tangential direction.
Definition SmootherT.hh:88
OpenMesh::Smoother::SmootherT::Normal
@ Normal
Smooth normal direction.
Definition SmootherT.hh:89
OpenMesh::Smoother::SmootherT::initialize
void initialize(Component _comp, Continuity _cont)
Initialize smoother.
Definition SmootherT_impl.hh:122
OpenMesh::Smoother::SmootherT::set_absolute_local_error
void set_absolute_local_error(Scalar _err)
Set local error as an absolute value.
Definition SmootherT_impl.hh:278
OpenMesh::Smoother::SmootherT::disable_local_error_check
void disable_local_error_check()
Disable error control of the smoother.
Definition SmootherT_impl.hh:290
OpenMesh::Smoother::SmootherT::set_relative_local_error
void set_relative_local_error(Scalar _err)
Set local error relative to bounding box.
Definition SmootherT_impl.hh:248
OpenMesh::Smoother::SmootherT::skip_features
void skip_features(bool _state)
enable or disable feature handling
Definition SmootherT.hh:167