some cleanups
This commit is contained in:
parent
c8149ca991
commit
ade2c49443
|
|
@ -25,6 +25,8 @@
|
||||||
#define __VCG_COMPLEX_BASE
|
#define __VCG_COMPLEX_BASE
|
||||||
|
|
||||||
#include <typeindex>
|
#include <typeindex>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include <vcg/container/simple_temporary_data.h>
|
#include <vcg/container/simple_temporary_data.h>
|
||||||
|
|
||||||
#include "used_types.h"
|
#include "used_types.h"
|
||||||
|
|
@ -599,7 +601,7 @@ template <class MeshType> inline bool IsMarked(const MeshType & m,typename MeshT
|
||||||
@param m the mesh containing the element
|
@param m the mesh containing the element
|
||||||
@param t tetra pointer */
|
@param t tetra pointer */
|
||||||
template <class MeshType>
|
template <class MeshType>
|
||||||
inline bool IsMarked(MeshType &m, typename MeshType::ConstTetraPointer t) { return t->cIMark() == m.imark; }
|
inline bool IsMarked(const MeshType &m, typename MeshType::ConstTetraPointer t) { return t->cIMark() == m.imark; }
|
||||||
|
|
||||||
/** \brief Set the vertex incremental mark of the vertex to the one of the mesh.
|
/** \brief Set the vertex incremental mark of the vertex to the one of the mesh.
|
||||||
@param m the mesh containing the element
|
@param m the mesh containing the element
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ First working release.
|
||||||
#ifndef __VCGLIB_BOX
|
#ifndef __VCGLIB_BOX
|
||||||
#define __VCGLIB_BOX
|
#define __VCGLIB_BOX
|
||||||
|
|
||||||
#include <vcg/space/point.h>
|
#include <vcg/space/point3.h>
|
||||||
#include <vcg/space/space.h>
|
#include <vcg/space/space.h>
|
||||||
#include <vcg/math/linear.h>
|
#include <vcg/math/linear.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
* VCGLib o o *
|
* VCGLib o o *
|
||||||
* Visual and Computer Graphics Library o o *
|
* Visual and Computer Graphics Library o o *
|
||||||
* _ O _ *
|
* _ O _ *
|
||||||
* Copyright(C) 2004-2016 \/)\/ *
|
* Copyright(C) 2004-2021 \/)\/ *
|
||||||
* Visual Computing Lab /\/| *
|
* Visual Computing Lab /\/| *
|
||||||
* ISTI - Italian National Research Council | *
|
* ISTI - Italian National Research Council | *
|
||||||
* \ *
|
* \ *
|
||||||
|
|
@ -53,18 +53,15 @@ public:
|
||||||
PointType max;
|
PointType max;
|
||||||
/// Standard constructor
|
/// Standard constructor
|
||||||
inline Box2() { min.X()= 1; max.X()= -1; min.Y()= 1; max.Y()= -1; }
|
inline Box2() { min.X()= 1; max.X()= -1; min.Y()= 1; max.Y()= -1; }
|
||||||
/// Copy constructor
|
|
||||||
inline Box2( const Box2 & b ) { min=b.min; max=b.max; }
|
|
||||||
/// Min Max constructor
|
/// Min Max constructor
|
||||||
inline Box2(const Point2<BoxScalarType> & mi, const Point2<BoxScalarType> & ma ) { min = mi; max = ma; }
|
inline Box2(const Point2<BoxScalarType> & mi, const Point2<BoxScalarType> & ma ) { min = mi; max = ma; }
|
||||||
|
|
||||||
inline Box2(const Point2<BoxScalarType> & center, const BoxScalarType & radius) {
|
inline Box2(const Point2<BoxScalarType> & center, const BoxScalarType & radius)
|
||||||
|
{
|
||||||
min = center-Point2<BoxScalarType>(radius,radius);
|
min = center-Point2<BoxScalarType>(radius,radius);
|
||||||
max = center+Point2<BoxScalarType>(radius,radius);
|
max = center+Point2<BoxScalarType>(radius,radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Distructor
|
|
||||||
inline ~Box2() { }
|
|
||||||
/// Operator to compare two bounding box
|
/// Operator to compare two bounding box
|
||||||
inline bool operator == ( Box2 const & p ) const
|
inline bool operator == ( Box2 const & p ) const
|
||||||
{
|
{
|
||||||
|
|
@ -76,7 +73,7 @@ public:
|
||||||
min = max = p;
|
min = max = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
Point2<BoxScalarType> P(const int & i) const
|
Point2<BoxScalarType> P(int i) const
|
||||||
{
|
{
|
||||||
return Point2<BoxScalarType>(
|
return Point2<BoxScalarType>(
|
||||||
min[0]+ (i%2) * DimX(),
|
min[0]+ (i%2) * DimX(),
|
||||||
|
|
@ -96,9 +93,9 @@ public:
|
||||||
{
|
{
|
||||||
min.X()= 1; max.X()= -1; min.Y()= 1; max.Y()= -1;
|
min.X()= 1; max.X()= -1; min.Y()= 1; max.Y()= -1;
|
||||||
}
|
}
|
||||||
/** Function to add two bounding box
|
/** @brief Function to add two bounding box
|
||||||
the bounding box expand to include the other bounding box (if necessary)
|
* the bounding box expand to include the other bounding box (if necessary)
|
||||||
@param b The bounding box to be added
|
* @param b The bounding box to be added
|
||||||
*/
|
*/
|
||||||
void Add( Box2 const & b )
|
void Add( Box2 const & b )
|
||||||
{
|
{
|
||||||
|
|
@ -116,9 +113,10 @@ public:
|
||||||
if(max.Y() < b.max.Y()) max.Y() = b.max.Y();
|
if(max.Y() < b.max.Y()) max.Y() = b.max.Y();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** Adds a point to the bouning box.
|
/**
|
||||||
the bounding box expand to include the new point (if necessary)
|
* @brief Adds a point to the bouning box.
|
||||||
@param p The point 2D
|
* the bounding box expand to include the new point (if necessary)
|
||||||
|
* @param p The point 2D
|
||||||
*/
|
*/
|
||||||
void Add( const PointType & p )
|
void Add( const PointType & p )
|
||||||
{
|
{
|
||||||
|
|
@ -133,16 +131,18 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Varies the dimension of the bounding box.
|
/**
|
||||||
@param delta The size delta (if positive, box is enlarged)
|
* @brief Varies the dimension of the bounding box.
|
||||||
|
* @param delta The size delta (if positive, box is enlarged)
|
||||||
*/
|
*/
|
||||||
void Offset(const ScalarType s)
|
void Offset(ScalarType s)
|
||||||
{
|
{
|
||||||
Offset(PointType(s, s));
|
Offset(PointType(s, s));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Varies the dimension of the bounding box.
|
/**
|
||||||
@param delta The size delta per dimension (if positive, box is enlarged)
|
* @brief Varies the dimension of the bounding box.
|
||||||
|
* @param delta The size delta per dimension (if positive, box is enlarged)
|
||||||
*/
|
*/
|
||||||
void Offset(const PointType & delta)
|
void Offset(const PointType & delta)
|
||||||
{
|
{
|
||||||
|
|
@ -150,8 +150,9 @@ public:
|
||||||
max += delta;
|
max += delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Computes intersection between this and another bounding box
|
/**
|
||||||
@param b The other bounding box
|
* @brief Computes intersection between this and another bounding box
|
||||||
|
* @param b The other bounding box
|
||||||
*/
|
*/
|
||||||
void Intersect( const Box2 & b )
|
void Intersect( const Box2 & b )
|
||||||
{
|
{
|
||||||
|
|
@ -164,54 +165,58 @@ public:
|
||||||
if(min.X()>max.X() || min.Y()>max.Y()) SetNull();
|
if(min.X()>max.X() || min.Y()>max.Y()) SetNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Translate the bounding box by a vector
|
/**
|
||||||
@param p The translation vector
|
* @brief Translate the bounding box by a vector
|
||||||
|
* @param p The translation vector
|
||||||
*/
|
*/
|
||||||
void Translate( const PointType & p )
|
void Translate( const PointType & p )
|
||||||
{
|
{
|
||||||
min += p;
|
min += p;
|
||||||
max += p;
|
max += p;
|
||||||
}
|
}
|
||||||
/** Checks whether a 2D point p is inside the box
|
/**
|
||||||
@param p The point 2D
|
* @brief Checks whether a 2D point p is inside the box
|
||||||
@return True iff p inside
|
* @param p The point 2D
|
||||||
|
* @return True iff p inside
|
||||||
*/
|
*/
|
||||||
bool IsIn( PointType const & p ) const
|
bool IsIn( const PointType & p ) const
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
min.X() <= p.X() && p.X() <= max.X() &&
|
min.X() <= p.X() && p.X() <= max.X() &&
|
||||||
min.Y() <= p.Y() && p.Y() <= max.Y()
|
min.Y() <= p.Y() && p.Y() <= max.Y());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
/** Checks whether a 2D point p is inside the box, closed at min but open at max
|
/**
|
||||||
@param p The point in 2D
|
* @brief Checks whether a 2D point p is inside the box, closed at min but open at max
|
||||||
@return True iff p inside
|
* @param p The point in 2D
|
||||||
|
* @return True iff p inside
|
||||||
*/
|
*/
|
||||||
bool IsInEx( PointType const & p ) const
|
bool IsInEx( const PointType & p ) const
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
min.X() <= p.X() && p.X() < max.X() &&
|
min.X() <= p.X() && p.X() < max.X() &&
|
||||||
min.Y() <= p.Y() && p.Y() < max.Y()
|
min.Y() <= p.Y() && p.Y() < max.Y());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
/** Check bbox collision.
|
/**
|
||||||
Note: just adjiacent bbox won't collide
|
* @brief Check bbox collision.
|
||||||
@param b A bounding box
|
* Note: just adjiacent bbox won't collide
|
||||||
@return True iff collision
|
* @param b A bounding box
|
||||||
|
* @return True iff collision
|
||||||
*/
|
*/
|
||||||
bool Collide( Box2 const &b )
|
bool Collide( const Box2 &b ) const
|
||||||
{
|
{
|
||||||
Box2 bb=*this;
|
Box2 bb=*this;
|
||||||
bb.Intersect(b);
|
bb.Intersect(b);
|
||||||
return bb.IsValid();
|
return bb.IsValid();
|
||||||
}
|
}
|
||||||
/** Check if empty.
|
/**
|
||||||
@return True iff empty
|
* Check if empty.
|
||||||
|
* @return True iff empty
|
||||||
*/
|
*/
|
||||||
inline bool IsNull() const { return min.X()>max.X() || min.Y()>max.Y(); }
|
inline bool IsNull() const { return min.X()>max.X() || min.Y()>max.Y(); }
|
||||||
|
|
||||||
/** Check consistency.
|
/**
|
||||||
@return True iff consistent
|
* Check consistency.
|
||||||
|
* @return True iff consistent
|
||||||
*/
|
*/
|
||||||
inline bool IsValid() const { return min.X()<max.X() && min.Y()<max.Y(); }
|
inline bool IsValid() const { return min.X()<max.X() && min.Y()<max.Y(); }
|
||||||
|
|
||||||
|
|
@ -252,13 +257,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns global coords of a local point expressed in [0..1]^2
|
/// Returns global coords of a local point expressed in [0..1]^2
|
||||||
PointType LocalToGlobal(PointType const & p) const{
|
PointType LocalToGlobal(const PointType & p) const{
|
||||||
return PointType(
|
return PointType(
|
||||||
min[0] + p[0]*(max[0]-min[0]),
|
min[0] + p[0]*(max[0]-min[0]),
|
||||||
min[1] + p[1]*(max[1]-min[1]));
|
min[1] + p[1]*(max[1]-min[1]));
|
||||||
}
|
}
|
||||||
/// Returns local coords expressed in [0..1]^2 of a point in R^2
|
/// Returns local coords expressed in [0..1]^2 of a point in R^2
|
||||||
PointType GlobalToLocal(PointType const & p) const{
|
PointType GlobalToLocal(const PointType & p) const{
|
||||||
return PointType(
|
return PointType(
|
||||||
(p[0]-min[0])/(max[0]-min[0]),
|
(p[0]-min[0])/(max[0]-min[0]),
|
||||||
(p[1]-min[1])/(max[1]-min[1])
|
(p[1]-min[1])/(max[1]-min[1])
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,6 @@ public:
|
||||||
Point3<BoxScalarType> max;
|
Point3<BoxScalarType> max;
|
||||||
/// The bounding box constructor
|
/// The bounding box constructor
|
||||||
inline Box3() { this->SetNull(); }
|
inline Box3() { this->SetNull(); }
|
||||||
/// Copy constructor
|
|
||||||
//inline Box3( const Box3 & b ) { min=b.min; max=b.max; }
|
|
||||||
/// Min Max constructor
|
/// Min Max constructor
|
||||||
inline Box3( const Point3<BoxScalarType> & mi, const Point3<BoxScalarType> & ma ) { min = mi; max = ma; }
|
inline Box3( const Point3<BoxScalarType> & mi, const Point3<BoxScalarType> & ma ) { min = mi; max = ma; }
|
||||||
/// Point Radius Constructor
|
/// Point Radius Constructor
|
||||||
|
|
@ -63,12 +61,12 @@ public:
|
||||||
/// The bounding box distructor
|
/// The bounding box distructor
|
||||||
inline ~Box3() { }
|
inline ~Box3() { }
|
||||||
/// Operator to compare two bounding box
|
/// Operator to compare two bounding box
|
||||||
inline bool operator == ( Box3<BoxScalarType> const & p ) const
|
inline bool operator == ( const Box3<BoxScalarType> & p ) const
|
||||||
{
|
{
|
||||||
return min==p.min && max==p.max;
|
return min==p.min && max==p.max;
|
||||||
}
|
}
|
||||||
/// Operator to dispare two bounding box
|
/// Operator to dispare two bounding box
|
||||||
inline bool operator != ( Box3<BoxScalarType> const & p ) const
|
inline bool operator != ( const Box3<BoxScalarType> & p ) const
|
||||||
{
|
{
|
||||||
return min!=p.min || max!=p.max;
|
return min!=p.min || max!=p.max;
|
||||||
}
|
}
|
||||||
|
|
@ -103,7 +101,7 @@ public:
|
||||||
/** Modify the current bbox to contain also the passed box.
|
/** Modify the current bbox to contain also the passed box.
|
||||||
* Adding a null bounding box does nothing
|
* Adding a null bounding box does nothing
|
||||||
*/
|
*/
|
||||||
void Add( Box3<BoxScalarType> const & b )
|
void Add( const Box3<BoxScalarType> & b )
|
||||||
{
|
{
|
||||||
if(b.IsNull()) return; // Adding a null bbox should do nothing
|
if(b.IsNull()) return; // Adding a null bbox should do nothing
|
||||||
if(IsNull()) *this=b;
|
if(IsNull()) *this=b;
|
||||||
|
|
@ -193,7 +191,7 @@ void Add( const Point3<BoxScalarType> & p, const BoxScalarType radius )
|
||||||
}
|
}
|
||||||
/** true if the point belong to the closed box
|
/** true if the point belong to the closed box
|
||||||
*/
|
*/
|
||||||
bool IsIn( Point3<BoxScalarType> const & p ) const
|
bool IsIn( const Point3<BoxScalarType> & p ) const
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
min.X() <= p.X() && p.X() <= max.X() &&
|
min.X() <= p.X() && p.X() <= max.X() &&
|
||||||
|
|
@ -204,7 +202,7 @@ void Add( const Point3<BoxScalarType> & p, const BoxScalarType radius )
|
||||||
/** true if the point belong to the open box (open on the max side)
|
/** true if the point belong to the open box (open on the max side)
|
||||||
* e.g. if p in [min,max)
|
* e.g. if p in [min,max)
|
||||||
*/
|
*/
|
||||||
bool IsInEx( Point3<BoxScalarType> const & p ) const
|
bool IsInEx( const Point3<BoxScalarType> & p ) const
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
min.X() <= p.X() && p.X() < max.X() &&
|
min.X() <= p.X() && p.X() < max.X() &&
|
||||||
|
|
@ -225,7 +223,7 @@ void Add( const Point3<BoxScalarType> & p, const BoxScalarType radius )
|
||||||
return bb.IsValid();
|
return bb.IsValid();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
bool Collide(Box3<BoxScalarType> const &b) const
|
bool Collide( const Box3<BoxScalarType> &b) const
|
||||||
{
|
{
|
||||||
return b.min.X()<max.X() && b.max.X()>min.X() &&
|
return b.min.X()<max.X() && b.max.X()>min.X() &&
|
||||||
b.min.Y()<max.Y() && b.max.Y()>min.Y() &&
|
b.min.Y()<max.Y() && b.max.Y()>min.Y() &&
|
||||||
|
|
@ -259,14 +257,14 @@ void Add( const Point3<BoxScalarType> & p, const BoxScalarType radius )
|
||||||
return (max-min);
|
return (max-min);
|
||||||
}
|
}
|
||||||
/// Returns global coords of a local point expressed in [0..1]^3
|
/// Returns global coords of a local point expressed in [0..1]^3
|
||||||
Point3<BoxScalarType> LocalToGlobal(Point3<BoxScalarType> const & p) const{
|
Point3<BoxScalarType> LocalToGlobal(const Point3<BoxScalarType> & p) const{
|
||||||
return Point3<BoxScalarType>(
|
return Point3<BoxScalarType>(
|
||||||
min[0] + p[0]*(max[0]-min[0]),
|
min[0] + p[0]*(max[0]-min[0]),
|
||||||
min[1] + p[1]*(max[1]-min[1]),
|
min[1] + p[1]*(max[1]-min[1]),
|
||||||
min[2] + p[2]*(max[2]-min[2]));
|
min[2] + p[2]*(max[2]-min[2]));
|
||||||
}
|
}
|
||||||
/// Returns local coords expressed in [0..1]^3 of a point in 3D
|
/// Returns local coords expressed in [0..1]^3 of a point in 3D
|
||||||
Point3<BoxScalarType> GlobalToLocal(Point3<BoxScalarType> const & p) const{
|
Point3<BoxScalarType> GlobalToLocal(const Point3<BoxScalarType> & p) const{
|
||||||
return Point3<BoxScalarType>(
|
return Point3<BoxScalarType>(
|
||||||
(p[0]-min[0])/(max[0]-min[0]),
|
(p[0]-min[0])/(max[0]-min[0]),
|
||||||
(p[1]-min[1])/(max[1]-min[1]),
|
(p[1]-min[1])/(max[1]-min[1]),
|
||||||
|
|
@ -313,7 +311,7 @@ void Add( const Point3<BoxScalarType> & p, const BoxScalarType radius )
|
||||||
}
|
}
|
||||||
|
|
||||||
/// gives the ith box vertex in order: (x,y,z),(X,y,z),(x,Y,z),(X,Y,z),(x,y,Z),(X,y,Z),(x,Y,Z),(X,Y,Z)
|
/// gives the ith box vertex in order: (x,y,z),(X,y,z),(x,Y,z),(X,Y,z),(x,y,Z),(X,y,Z),(x,Y,Z),(X,Y,Z)
|
||||||
Point3<BoxScalarType> P(const int & i) const {
|
Point3<BoxScalarType> P(int i) const {
|
||||||
return Point3<BoxScalarType>(
|
return Point3<BoxScalarType>(
|
||||||
min[0]+ (i%2) * DimX(),
|
min[0]+ (i%2) * DimX(),
|
||||||
min[1]+ ((i / 2)%2) * DimY(),
|
min[1]+ ((i / 2)%2) * DimY(),
|
||||||
|
|
|
||||||
|
|
@ -97,10 +97,8 @@ public:
|
||||||
{
|
{
|
||||||
_v[0] = p[0]; _v[1]= p[1]; _v[2] = p[2]; _v[3]= p[3];
|
_v[0] = p[0]; _v[1]= p[1]; _v[2] = p[2]; _v[3]= p[3];
|
||||||
}
|
}
|
||||||
inline Point4 ( const Point4 & p )
|
inline Point4 ( const Point4 & p ) = default;
|
||||||
{
|
|
||||||
_v[0]= p._v[0]; _v[1]= p._v[1]; _v[2]= p._v[2]; _v[3]= p._v[3];
|
|
||||||
}
|
|
||||||
inline void SetZero()
|
inline void SetZero()
|
||||||
{
|
{
|
||||||
_v[0] = _v[1] = _v[2] = _v[3]= 0;
|
_v[0] = _v[1] = _v[2] = _v[3]= 0;
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ public:
|
||||||
Line2 (const Line2<ScalarType,!NORM > &r)
|
Line2 (const Line2<ScalarType,!NORM > &r)
|
||||||
{ Import(r); };
|
{ Import(r); };
|
||||||
/// assignment
|
/// assignment
|
||||||
inline LineType & operator = ( Line2<ScalarType,!NORM> const &r)
|
inline LineType & operator = ( const Line2<ScalarType,!NORM> &r)
|
||||||
{ Import(r); return *this; };
|
{ Import(r); return *this; };
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue