some cleanups
This commit is contained in:
parent
c8149ca991
commit
ade2c49443
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
285
vcg/space/box2.h
285
vcg/space/box2.h
|
@ -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 | *
|
||||
* \ *
|
||||
|
@ -36,54 +36,51 @@ template <class SegScalarType> class Segment2;
|
|||
/** \addtogroup space */
|
||||
/*@{*/
|
||||
/**
|
||||
Templated class for a 2D bounding box. It is stored just as two Point2
|
||||
Templated class for a 2D bounding box. It is stored just as two Point2
|
||||
@param BoxScalarType (Template Parameter) Specifies the scalar field.
|
||||
*/
|
||||
template <class BoxScalarType>
|
||||
class Box2
|
||||
{
|
||||
public:
|
||||
/// The scalar type
|
||||
/// The scalar type
|
||||
typedef BoxScalarType ScalarType;
|
||||
typedef Point2<BoxScalarType> PointType ;
|
||||
typedef Point2<BoxScalarType> PointType;
|
||||
|
||||
/// min coordinate point
|
||||
PointType min;
|
||||
/// max coordinate point
|
||||
PointType max;
|
||||
/// Standard constructor
|
||||
/// min coordinate point
|
||||
PointType min;
|
||||
/// max coordinate point
|
||||
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; }
|
||||
/// 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) {
|
||||
min = center-Point2<BoxScalarType>(radius,radius);
|
||||
max = center+Point2<BoxScalarType>(radius,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
|
||||
/// Operator to compare two bounding box
|
||||
inline bool operator == ( Box2 const & p ) const
|
||||
{
|
||||
return min==p.min && max==p.max;
|
||||
}
|
||||
/// Initializing the bounding box with a point
|
||||
/// Initializing the bounding box with a point
|
||||
void Set( const PointType & p )
|
||||
{
|
||||
min = max = p;
|
||||
}
|
||||
|
||||
Point2<BoxScalarType> P(const int & i) const
|
||||
Point2<BoxScalarType> P(int i) const
|
||||
{
|
||||
return Point2<BoxScalarType>(
|
||||
min[0]+ (i%2) * DimX(),
|
||||
return Point2<BoxScalarType>(
|
||||
min[0]+ (i%2) * DimX(),
|
||||
min[1]+ ((i / 2)%2) * DimY());
|
||||
}
|
||||
|
||||
// Initializing with the values
|
||||
// Initializing with the values
|
||||
inline void Set( ScalarType minx, ScalarType miny, ScalarType maxx, ScalarType maxy )
|
||||
{
|
||||
min[0] = minx;
|
||||
|
@ -91,15 +88,15 @@ public:
|
|||
max[0] = maxx;
|
||||
max[1] = maxy;
|
||||
}
|
||||
/// Set the bounding box to a null value
|
||||
/// Set the bounding box to a null value
|
||||
void SetNull()
|
||||
{
|
||||
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
|
||||
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 )
|
||||
{
|
||||
if(IsNull())
|
||||
|
@ -116,14 +113,15 @@ 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 )
|
||||
{
|
||||
if(IsNull()) Set(p);
|
||||
else
|
||||
else
|
||||
{
|
||||
if(min.X() > p.X()) min.X() = p.X();
|
||||
if(min.Y() > p.Y()) min.Y() = p.Y();
|
||||
|
@ -133,26 +131,29 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
/** Varies the dimension of the bounding box.
|
||||
@param delta The size delta (if positive, box is enlarged)
|
||||
*/
|
||||
void Offset(const ScalarType s)
|
||||
/**
|
||||
* @brief Varies the dimension of the bounding box.
|
||||
* @param delta The size delta (if positive, box is enlarged)
|
||||
*/
|
||||
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)
|
||||
{
|
||||
min -= 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 )
|
||||
{
|
||||
if(min.X() < b.min.X()) min.X() = b.min.X();
|
||||
|
@ -164,114 +165,118 @@ 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
|
||||
*/
|
||||
bool IsIn( PointType const & p ) const
|
||||
/**
|
||||
* @brief Checks whether a 2D point p is inside the box
|
||||
* @param p The point 2D
|
||||
* @return True iff p inside
|
||||
*/
|
||||
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
|
||||
*/
|
||||
bool IsInEx( PointType const & p ) const
|
||||
/**
|
||||
* @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( const PointType & p ) const
|
||||
{
|
||||
return (
|
||||
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
|
||||
*/
|
||||
bool Collide( Box2 const &b )
|
||||
/**
|
||||
* @brief Check bbox collision.
|
||||
* Note: just adjiacent bbox won't collide
|
||||
* @param b A bounding box
|
||||
* @return True iff collision
|
||||
*/
|
||||
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(); }
|
||||
|
||||
/** Check if empty.
|
||||
@return True iff empty
|
||||
/** Check if empty.
|
||||
@return True iff empty
|
||||
*/
|
||||
inline bool IsEmpty() const { return min==max; }
|
||||
|
||||
/// Computes length of diagonal
|
||||
|
||||
/// Computes length of diagonal
|
||||
ScalarType Diag() const
|
||||
{
|
||||
return Distance(min,max);
|
||||
}
|
||||
/// Computes box center
|
||||
/// Computes box center
|
||||
PointType Center() const
|
||||
{
|
||||
return (min+max)/2;
|
||||
}
|
||||
/// Computes area
|
||||
/// Computes area
|
||||
inline ScalarType Area() const
|
||||
{
|
||||
return (max[0]-min[0])*(max[1]-min[1]);
|
||||
}
|
||||
/// computes dimension on X axis.
|
||||
/// computes dimension on X axis.
|
||||
inline ScalarType DimX() const { return max.X()-min.X(); }
|
||||
/// computes dimension on Y axis.
|
||||
/// computes dimension on Y axis.
|
||||
inline ScalarType DimY() const { return max.Y()-min.Y(); }
|
||||
|
||||
/// Computes sizes (as a vector)
|
||||
/// Computes sizes (as a vector)
|
||||
inline PointType Dim() const { return max-min; }
|
||||
|
||||
/// Deprecated: use GlobalToLocal
|
||||
/// Deprecated: use GlobalToLocal
|
||||
inline void Normalize( PointType & p )
|
||||
{
|
||||
p -= min;
|
||||
p[0] /= max[0]-min[0];
|
||||
p[1] /= max[1]-min[1];
|
||||
}
|
||||
|
||||
/// Returns global coords of a local point expressed in [0..1]^2
|
||||
PointType LocalToGlobal(PointType const & p) const{
|
||||
return PointType(
|
||||
min[0] + p[0]*(max[0]-min[0]),
|
||||
min[1] + p[1]*(max[1]-min[1]));
|
||||
|
||||
/// Returns global coords of a local point expressed in [0..1]^2
|
||||
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{
|
||||
return PointType(
|
||||
(p[0]-min[0])/(max[0]-min[0]),
|
||||
(p[1]-min[1])/(max[1]-min[1])
|
||||
);
|
||||
/// Returns local coords expressed in [0..1]^2 of a point in R^2
|
||||
PointType GlobalToLocal(const PointType & p) const{
|
||||
return PointType(
|
||||
(p[0]-min[0])/(max[0]-min[0]),
|
||||
(p[1]-min[1])/(max[1]-min[1])
|
||||
);
|
||||
}
|
||||
|
||||
/// Turns the bounding box into a square (conservatively)
|
||||
|
||||
/// Turns the bounding box into a square (conservatively)
|
||||
void MakeSquare(){
|
||||
ScalarType radius = max( DimX(), DimY() ) / 2;
|
||||
PointType c = Center();
|
||||
max = c + PointType(radius, radius);
|
||||
min = c - PointType(radius, radius);
|
||||
}
|
||||
ScalarType radius = max( DimX(), DimY() ) / 2;
|
||||
PointType c = Center();
|
||||
max = c + PointType(radius, radius);
|
||||
min = c - PointType(radius, radius);
|
||||
}
|
||||
|
||||
inline unsigned char MaxDim() const {
|
||||
int i=1;
|
||||
|
@ -288,7 +293,7 @@ public:
|
|||
i=0;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
}; // end class definition
|
||||
|
||||
template <class ScalarType>
|
||||
|
@ -300,36 +305,36 @@ ScalarType DistancePoint2Box2(const Point2<ScalarType> &test,
|
|||
if ((test.X()<=bbox.min.X())&&(test.Y()<=bbox.min.Y()))
|
||||
return ((test-bbox.min).Norm());
|
||||
else
|
||||
if ((test.X()>=bbox.min.X())&&
|
||||
(test.X()<=bbox.max.X())&&
|
||||
(test.Y()<=bbox.min.Y()))
|
||||
return (bbox.min.Y()-test.Y());
|
||||
else
|
||||
if ((test.X()>=bbox.max.X())&&
|
||||
(test.Y()<=bbox.min.Y()))
|
||||
return ((test-vcg::Point2<ScalarType>(bbox.max.X(),bbox.min.Y())).Norm());
|
||||
else
|
||||
if ((test.Y()>=bbox.min.Y())&&
|
||||
(test.Y()<=bbox.max.Y())&&
|
||||
(test.X()>=bbox.max.X()))
|
||||
return (test.X()-bbox.max.X());
|
||||
else
|
||||
if ((test.X()>=bbox.max.X())&&(test.Y()>=bbox.max.Y()))
|
||||
return ((test-bbox.max).Norm());
|
||||
else
|
||||
if ((test.X()>=bbox.min.X())&&
|
||||
(test.X()<=bbox.max.X())&&
|
||||
(test.Y()>=bbox.max.Y()))
|
||||
return (test.Y()-bbox.max.Y());
|
||||
else
|
||||
if ((test.X()<=bbox.min.X())&&
|
||||
(test.Y()>=bbox.max.Y()))
|
||||
return ((test-vcg::Point2<ScalarType>(bbox.min.X(),bbox.max.Y())).Norm());
|
||||
else
|
||||
if ((test.X()<=bbox.min.X())&&
|
||||
(test.Y()<=bbox.max.Y())&&
|
||||
(test.Y()>=bbox.min.Y()))
|
||||
return (bbox.min.X()-test.X());
|
||||
if ((test.X()>=bbox.min.X())&&
|
||||
(test.X()<=bbox.max.X())&&
|
||||
(test.Y()<=bbox.min.Y()))
|
||||
return (bbox.min.Y()-test.Y());
|
||||
else
|
||||
if ((test.X()>=bbox.max.X())&&
|
||||
(test.Y()<=bbox.min.Y()))
|
||||
return ((test-vcg::Point2<ScalarType>(bbox.max.X(),bbox.min.Y())).Norm());
|
||||
else
|
||||
if ((test.Y()>=bbox.min.Y())&&
|
||||
(test.Y()<=bbox.max.Y())&&
|
||||
(test.X()>=bbox.max.X()))
|
||||
return (test.X()-bbox.max.X());
|
||||
else
|
||||
if ((test.X()>=bbox.max.X())&&(test.Y()>=bbox.max.Y()))
|
||||
return ((test-bbox.max).Norm());
|
||||
else
|
||||
if ((test.X()>=bbox.min.X())&&
|
||||
(test.X()<=bbox.max.X())&&
|
||||
(test.Y()>=bbox.max.Y()))
|
||||
return (test.Y()-bbox.max.Y());
|
||||
else
|
||||
if ((test.X()<=bbox.min.X())&&
|
||||
(test.Y()>=bbox.max.Y()))
|
||||
return ((test-vcg::Point2<ScalarType>(bbox.min.X(),bbox.max.Y())).Norm());
|
||||
else
|
||||
if ((test.X()<=bbox.min.X())&&
|
||||
(test.Y()<=bbox.max.Y())&&
|
||||
(test.Y()>=bbox.min.Y()))
|
||||
return (bbox.min.X()-test.X());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -372,13 +377,13 @@ Point2<ScalarType> ClosestPoint2Box2(const Point2<ScalarType> &test,
|
|||
return closest;
|
||||
}
|
||||
|
||||
/// Specificazione di box of short
|
||||
/// Specificazione di box of short
|
||||
typedef Box2<short> Box2s;
|
||||
/// Specificazione di box of int
|
||||
/// Specificazione di box of int
|
||||
typedef Box2<int> Box2i;
|
||||
/// Specificazione di box of float
|
||||
/// Specificazione di box of float
|
||||
typedef Box2<float> Box2f;
|
||||
/// Specificazione di box of double
|
||||
/// Specificazione di box of double
|
||||
typedef Box2<double> Box2d;
|
||||
|
||||
/*@}*/
|
||||
|
|
|
@ -46,29 +46,27 @@ public:
|
|||
typedef BoxScalarType ScalarType;
|
||||
|
||||
/// min coordinate point
|
||||
Point3<BoxScalarType> min;
|
||||
Point3<BoxScalarType> min;
|
||||
/// max coordinate point
|
||||
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
|
||||
inline Box3(const Point3<BoxScalarType> & center, const BoxScalarType & radius) {
|
||||
min = center-Point3<BoxScalarType>(radius,radius,radius);
|
||||
max = center+Point3<BoxScalarType>(radius,radius,radius);
|
||||
}
|
||||
inline Box3(const Point3<BoxScalarType> & center, const BoxScalarType & radius) {
|
||||
min = center-Point3<BoxScalarType>(radius,radius,radius);
|
||||
max = center+Point3<BoxScalarType>(radius,radius,radius);
|
||||
}
|
||||
/// 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;
|
||||
|
@ -137,20 +135,20 @@ public:
|
|||
|
||||
/** Modify the current bbox to contain also the passed sphere
|
||||
*/
|
||||
void Add( const Point3<BoxScalarType> & p, const BoxScalarType radius )
|
||||
{
|
||||
if(IsNull()) Set(p);
|
||||
else
|
||||
void Add( const Point3<BoxScalarType> & p, const BoxScalarType radius )
|
||||
{
|
||||
min.X() = std::min(min.X(),p.X()-radius);
|
||||
min.Y() = std::min(min.Y(),p.Y()-radius);
|
||||
min.Z() = std::min(min.Z(),p.Z()-radius);
|
||||
if(IsNull()) Set(p);
|
||||
else
|
||||
{
|
||||
min.X() = std::min(min.X(),p.X()-radius);
|
||||
min.Y() = std::min(min.Y(),p.Y()-radius);
|
||||
min.Z() = std::min(min.Z(),p.Z()-radius);
|
||||
|
||||
max.X() = std::max(max.X(),p.X()+radius);
|
||||
max.Y() = std::max(max.Y(),p.Y()+radius);
|
||||
max.Z() = std::max(max.Z(),p.Z()+radius);
|
||||
max.X() = std::max(max.X(),p.X()+radius);
|
||||
max.Y() = std::max(max.Y(),p.Y()+radius);
|
||||
max.Z() = std::max(max.Z(),p.Z()+radius);
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Modify the current bbox to contain also the box b transformed according to the matrix m
|
||||
*/
|
||||
void Add( const Matrix44<BoxScalarType> &m, const Box3<BoxScalarType> & 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(),
|
||||
|
|
|
@ -253,7 +253,7 @@ public:
|
|||
assert(i>=0 && i<3);
|
||||
return _v[i];
|
||||
}
|
||||
inline const P3ScalarType &X() const { return _v[0]; }
|
||||
inline const P3ScalarType &X() const { return _v[0]; }
|
||||
inline const P3ScalarType &Y() const { return _v[1]; }
|
||||
inline const P3ScalarType &Z() const { return _v[2]; }
|
||||
inline P3ScalarType &X() { return _v[0]; }
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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; };
|
||||
//@}
|
||||
|
||||
|
|
Loading…
Reference in New Issue