#ifndef slic3r_NormalUtils_hpp_
#define slic3r_NormalUtils_hpp_
#include "Point.hpp"
#include "Model.hpp"
namespace Slic3r {
///
/// Collection of static function
/// to create normals
///
class NormalUtils
{
public:
using Normal = Vec3f;
using Normals = std::vector;
NormalUtils() = delete; // only static functions
enum class VertexNormalType {
AverageNeighbor,
AngleWeighted,
NelsonMaxWeighted
};
///
/// Create normal for triangle defined by indices from vertices
///
/// index into vertices
/// vector of vertices
/// normal to triangle(normalized to size 1)
static Normal create_triangle_normal(
const stl_triangle_vertex_indices &indices,
const std::vector & vertices);
///
/// Create normals for each vertices
///
/// indices and vertices
/// Vector of normals
static Normals create_triangle_normals(const indexed_triangle_set &its);
///
/// Create normals for each vertex by averaging neighbor triangles normal
///
/// Triangle indices and vertices
/// Type of calculation normals
/// Normal for each vertex
static Normals create_normals(
const indexed_triangle_set &its,
VertexNormalType type = VertexNormalType::NelsonMaxWeighted);
static Normals create_normals_average_neighbor(const indexed_triangle_set &its);
static Normals create_normals_angle_weighted(const indexed_triangle_set &its);
static Normals create_normals_nelson_weighted(const indexed_triangle_set &its);
///
/// Calculate angle of trinagle side.
///
/// index to indices, define angle point
/// address to vertices
/// vertices data
/// Angle [in radian]
static float indice_angle(int i,
const Vec3crd & indice,
const std::vector &vertices);
};
} // namespace Slic3r
#endif // slic3r_NormalUtils_hpp_