some cleanups

This commit is contained in:
alemuntoni 2021-03-25 18:13:41 +01:00
parent c8149ca991
commit ade2c49443
7 changed files with 178 additions and 175 deletions

View File

@ -25,6 +25,8 @@
#define __VCG_COMPLEX_BASE
#include <typeindex>
#include <set>
#include <vcg/container/simple_temporary_data.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 t tetra pointer */
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.
@param m the mesh containing the element

View File

@ -49,7 +49,7 @@ First working release.
#ifndef __VCGLIB_BOX
#define __VCGLIB_BOX
#include <vcg/space/point.h>
#include <vcg/space/point3.h>
#include <vcg/space/space.h>
#include <vcg/math/linear.h>

View File

@ -2,7 +2,7 @@
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2016 \/)\/ *
* Copyright(C) 2004-2021 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
@ -53,18 +53,15 @@ public:
PointType max;
/// Standard constructor
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
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);
max = center+Point2<BoxScalarType>(radius,radius);
}
/// Distructor
inline ~Box2() { }
/// Operator to compare two bounding box
inline bool operator == ( Box2 const & p ) const
{
@ -76,7 +73,7 @@ public:
min = max = p;
}
Point2<BoxScalarType> P(const int & i) const
Point2<BoxScalarType> P(int i) const
{
return Point2<BoxScalarType>(
min[0]+ (i%2) * DimX(),
@ -96,9 +93,9 @@ public:
{
min.X()= 1; max.X()= -1; min.Y()= 1; max.Y()= -1;
}
/** Function to add two bounding box
the bounding box expand to include the other bounding box (if necessary)
@param b The bounding box to be added
/** @brief Function to add two bounding box
* the bounding box expand to include the other bounding box (if necessary)
* @param b The bounding box to be added
*/
void Add( Box2 const & b )
{
@ -116,9 +113,10 @@ public:
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)
@param p The point 2D
/**
* @brief Adds a point to the bouning box.
* the bounding box expand to include the new point (if necessary)
* @param p The point 2D
*/
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));
}
/** 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)
{
@ -150,8 +150,9 @@ public:
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 )
{
@ -164,54 +165,58 @@ public:
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 )
{
min += p;
max += p;
}
/** Checks whether a 2D point p is inside the box
@param p The point 2D
@return True iff p inside
/**
* @brief Checks whether a 2D point p is inside the box
* @param p The point 2D
* @return True iff p inside
*/
bool IsIn( PointType const & p ) const
bool IsIn( const PointType & p ) const
{
return (
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
@return True iff p inside
/**
* @brief Checks whether a 2D point p is inside the box, closed at min but open at max
* @param p The point in 2D
* @return True iff p inside
*/
bool IsInEx( PointType const & p ) const
bool IsInEx( const PointType & p ) const
{
return (
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
@param b A bounding box
@return True iff collision
/**
* @brief Check bbox collision.
* Note: just adjiacent bbox won't collide
* @param b A bounding box
* @return True iff collision
*/
bool Collide( Box2 const &b )
bool Collide( const Box2 &b ) const
{
Box2 bb=*this;
bb.Intersect(b);
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(); }
/** 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(); }
@ -252,13 +257,13 @@ public:
}
/// 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(
min[0] + p[0]*(max[0]-min[0]),
min[1] + p[1]*(max[1]-min[1]));
}
/// 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(
(p[0]-min[0])/(max[0]-min[0]),
(p[1]-min[1])/(max[1]-min[1])

View File

@ -51,8 +51,6 @@ public:
Point3<BoxScalarType> max;
/// The bounding box constructor
inline Box3() { this->SetNull(); }
/// Copy constructor
//inline Box3( const Box3 & b ) { min=b.min; max=b.max; }
/// Min Max constructor
inline Box3( const Point3<BoxScalarType> & mi, const Point3<BoxScalarType> & ma ) { min = mi; max = ma; }
/// Point Radius Constructor
@ -63,12 +61,12 @@ public:
/// The bounding box distructor
inline ~Box3() { }
/// 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;
}
/// 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;
}
@ -103,7 +101,7 @@ public:
/** Modify the current bbox to contain also the passed box.
* 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(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
*/
bool IsIn( Point3<BoxScalarType> const & p ) const
bool IsIn( const Point3<BoxScalarType> & p ) const
{
return (
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)
* e.g. if p in [min,max)
*/
bool IsInEx( Point3<BoxScalarType> const & p ) const
bool IsInEx( const Point3<BoxScalarType> & p ) const
{
return (
min.X() <= p.X() && p.X() < max.X() &&
@ -225,7 +223,7 @@ void Add( const Point3<BoxScalarType> & p, const BoxScalarType radius )
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() &&
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);
}
/// 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>(
min[0] + p[0]*(max[0]-min[0]),
min[1] + p[1]*(max[1]-min[1]),
min[2] + p[2]*(max[2]-min[2]));
}
/// 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>(
(p[0]-min[0])/(max[0]-min[0]),
(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)
Point3<BoxScalarType> P(const int & i) const {
Point3<BoxScalarType> P(int i) const {
return Point3<BoxScalarType>(
min[0]+ (i%2) * DimX(),
min[1]+ ((i / 2)%2) * DimY(),

View File

@ -97,10 +97,8 @@ public:
{
_v[0] = p[0]; _v[1]= p[1]; _v[2] = p[2]; _v[3]= p[3];
}
inline Point4 ( const Point4 & p )
{
_v[0]= p._v[0]; _v[1]= p._v[1]; _v[2]= p._v[2]; _v[3]= p._v[3];
}
inline Point4 ( const Point4 & p ) = default;
inline void SetZero()
{
_v[0] = _v[1] = _v[2] = _v[3]= 0;

View File

@ -167,7 +167,7 @@ public:
Line2 (const Line2<ScalarType,!NORM > &r)
{ Import(r); };
/// assignment
inline LineType & operator = ( Line2<ScalarType,!NORM> const &r)
inline LineType & operator = ( const Line2<ScalarType,!NORM> &r)
{ Import(r); return *this; };
//@}