diff --git a/include/Algo/MC/marchingcube.h b/include/Algo/MC/marchingcube.h index 5caa7e1b50e83b7f3c82b01340ccc01f3a5fd8c0..8c16d897590de0e548c773ce9237b3b74558a71e 100644 --- a/include/Algo/MC/marchingcube.h +++ b/include/Algo/MC/marchingcube.h @@ -37,7 +37,9 @@ namespace CGoGN namespace Algo { -namespace MC { +namespace MC +{ + /** * Marching Cube * @@ -257,10 +259,11 @@ public: void recalPoints(const Geom::Vec3f& origin); }; +} // namespace MC + +} // namespace Algo -} // end namespace -} // end namespace -} // end namespace +} // namespace CGoGN #include "Algo/MC/marchingcube.hpp" #endif diff --git a/include/Geometry/bounding_box.h b/include/Geometry/bounding_box.h index 5b03055a490b5fbd203b2514566014f063bad766..3242503912c32b8f6e625df1c2ff5eafefcb0975 100644 --- a/include/Geometry/bounding_box.h +++ b/include/Geometry/bounding_box.h @@ -89,23 +89,22 @@ class BoundingBox // fusion with the given bounding box void fusion(const BoundingBox& bb) ; - //return true if the vector belongs strictly to a bounding box + // return true if the vector belongs strictly to a bounding box bool contains(const VEC& p); - //return true if the bounding box belongs strictly to a bounding box + // return true if the bounding box belongs strictly to a bounding box bool contains(const BoundingBox & bb); - //resize a bounding box - void scale(float size); + // scale the bounding box + void scale(typename VEC::DATA_TYPE size); + + // 0-centered scale of the bounding box + void centeredScale(typename VEC::DATA_TYPE size); /**********************************************/ /* STREAM OPERATORS */ /**********************************************/ -// friend std::ostream& operator<<(std::ostream& out, const BoundingBox& bb); -// -// friend std::istream& operator>>(std::istream& in, BoundingBox& bb); - friend std::ostream& operator<<(std::ostream& out, const BoundingBox& bb) { out << bb.min() << " " << bb.max() ; diff --git a/include/Geometry/bounding_box.hpp b/include/Geometry/bounding_box.hpp index f3d97259d535c5ae6161a466c132abffc8074487..2b03aeebe1564900cdeeb7ba9c8ede78788d88a2 100644 --- a/include/Geometry/bounding_box.hpp +++ b/include/Geometry/bounding_box.hpp @@ -142,7 +142,7 @@ bool BoundingBox::isInitialized() const template void BoundingBox::reset() { - m_initialized=false; + m_initialized = false; } template @@ -197,7 +197,6 @@ void BoundingBox::fusion(const BoundingBox& bb) } } - template bool BoundingBox::contains(const VEC& p) { @@ -221,28 +220,20 @@ bool BoundingBox::contains(const BoundingBox& bb) } template -void BoundingBox::scale(float size) +void BoundingBox::scale(typename VEC::DATA_TYPE size) { assert(m_initialized || !"Bounding box not initialized"); - m_pMin *= size; - m_pMax *= size; + m_pMin *= size ; + m_pMax *= size ; } - - -//template -//friend std::ostream& BoundingBox::operator<<(std::ostream& out, const BoundingBox& bb) -//{ -// out << bb.min() << " " << bb.max() ; -// return out ; -//} -// -//template -//friend std::istream& BoundingBox::operator>>(std::istream& in, BoundingBox& bb) -//{ -// in >> bb.min() >> bb.max() ; -// return in ; -//} +template +void BoundingBox::centeredScale(typename VEC::DATA_TYPE size) +{ + VEC center = (m_pMin + m_pMax) / typename VEC::DATA_TYPE(2) ; + m_pMin = ((m_pMin - center) * size) + center ; + m_pMax = ((m_pMax - center) * size) + center ; +} } // namespace Geom diff --git a/include/Geometry/plane_3d.h b/include/Geometry/plane_3d.h index 6e921195b8f045387bc373882fbd655299390cc0..a496ce52bb5083a4a8ac13dc2df46497b45b293d 100644 --- a/include/Geometry/plane_3d.h +++ b/include/Geometry/plane_3d.h @@ -109,6 +109,6 @@ class Plane3D } // namespace CGoGN -#include "plane_3d.hpp" +#include "Geometry/plane_3d.hpp" #endif diff --git a/include/Geometry/plane_3d.hpp b/include/Geometry/plane_3d.hpp index 44572f9779188af4bb0a1c9b8e9bbe2fd88ee122..fb8eccdb3ba0b7fe54f8ed680da9477ea3444bc9 100644 --- a/include/Geometry/plane_3d.hpp +++ b/include/Geometry/plane_3d.hpp @@ -44,8 +44,7 @@ std::string Plane3D::CGoGNnameOfType() /**********************************************/ template -Plane3D::Plane3D(int d) : -m_normal(0), m_d(d) +Plane3D::Plane3D(int d) : m_normal(0), m_d(d) { } template @@ -56,15 +55,13 @@ Plane3D::Plane3D(const Plane3D& p) } template -Plane3D::Plane3D(const Vector<3,T>& n, T d) : -m_normal(n), m_d(d) +Plane3D::Plane3D(const Vector<3,T>& n, T d) : m_normal(n), m_d(d) { m_normal.normalize(); } template -Plane3D::Plane3D(const Vector<3,T>& n, const Vector<3,T>& p) : -m_normal(n), m_d(-(p*n)) +Plane3D::Plane3D(const Vector<3,T>& n, const Vector<3,T>& p) : m_normal(n), m_d(-(p*n)) { m_normal.normalize(); } @@ -118,7 +115,7 @@ T Plane3D::distance(const Vector<3,T>& p) const template void Plane3D::project(Vector<3,T>& p) const { -#define PRECISION 1e-5 +#define PRECISION 1e-10 T d = -distance(p) ; if(abs(d) > PRECISION) { @@ -131,7 +128,7 @@ void Plane3D::project(Vector<3,T>& p) const template Orientation3D Plane3D::orient(const Vector<3,T>& p) const { -#define PRECISION 1e-5 +#define PRECISION 1e-10 T dist = distance(p) ; if(dist < -PRECISION) return UNDER ;