#ifndef MY_PLANE_SHAPE_H
#define MY_PLANE_SHAPE_H
#include <CGAL/number_utils.h>
template <class Traits>
public:
typedef typename Traits::FT
FT;
typedef typename Traits::Point_3 Point;
typedef typename Traits::Vector_3 Vector;
public:
My_Plane()
{}
const FT sd = (this->constr_vec(m_point_on_primitive, p)) * m_normal;
return sd * sd;
}
Vector plane_normal() const {
return m_normal;
}
FT d() const {
return m_d;
}
virtual std::string
info()
const {
std::stringstream sstr;
sstr << "Type: plane (" << this->get_x(m_normal) << ", "
<< this->get_y(m_normal) << ", " << this->get_z(m_normal) << ")x - " <<
m_d << " = 0" << " #Pts: " << this->m_indices.size();
return sstr.str();
}
protected:
virtual void create_shape(
const std::vector<std::size_t> &indices) {
const Point p1 = this->
point(indices[0]);
const Point p2 = this->
point(indices[1]);
const Point p3 = this->
point(indices[2]);
m_normal = this->cross_pdct(p1 - p2, p1 - p3);
m_normal = m_normal * (1.0 / sqrt(this->sqlen(m_normal)));
m_d = -(p1[0] * m_normal[0] + p1[1] * m_normal[1] + p1[2] * m_normal[2]);
m_point_on_primitive = p1;
this->m_is_valid = true;
}
std::vector<FT> &dists) const {
for (std::size_t i = 0; i < indices.size(); i++) {
const FT sd = (this->
point(indices[i])
- m_point_on_primitive) * m_normal;
dists[i] = sd * sd;
}
}
virtual void cos_to_normal(
const std::vector<std::size_t> &indices,
std::vector<FT> &angles) const {
for (std::size_t i = 0; i < indices.size(); i++)
angles[i] = CGAL::abs(this->
normal(indices[i]) * m_normal);
}
return 3;
}
private:
Point m_point_on_primitive;
Vector m_normal;
FT m_d;
};
#endif