Include : modifiche per BoundingBox.

This commit is contained in:
Dario Sassi
2014-01-16 22:03:21 +00:00
parent 46b18392f3
commit 8527b5c7bd
7 changed files with 105 additions and 4 deletions
+63
View File
@@ -0,0 +1,63 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : EGkBBox3d.h Data : 14.01.14 Versione : 1.5a4
// Contenuto : Dichiarazione della classe axis aligned bounding box BBox3d.
//
//
//
// Modifiche : 14.01.13 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "/EgtDev/Include/EGKPoint3d.h"
//----------------------- Macro per import/export ----------------------------
#undef EGK_EXPORT
#if defined( I_AM_EGK) // da definirsi solo nella DLL
#define EGK_EXPORT __declspec( dllexport)
#else
#define EGK_EXPORT __declspec( dllimport)
#endif
//----------------------------------------------------------------------------
class EGK_EXPORT BBox3d
{
public :
BBox3d( void) // Box vuoto (min > MAX)
: m_ptMin( +INFINITO, +INFINITO, +INFINITO),
m_ptMax( -INFINITO, -INFINITO, -INFINITO) {}
BBox3d( const Point3d ptP)
: m_ptMin( ptP), m_ptMax( ptP) {}
BBox3d( const Point3d ptP1, const Point3d ptP2) ;
void Reset( void)
{ m_ptMin = Point3d( +INFINITO, +INFINITO, +INFINITO) ;
m_ptMax = Point3d( -INFINITO, -INFINITO, -INFINITO) ; }
void Set( const Point3d ptP)
{ m_ptMin = ptP ; m_ptMax = ptP ; }
void Set( const Point3d ptP1, const Point3d ptP2) ;
public :
void Add( const Point3d& ptP) ;
void Add( const BBox3d& b3B) ;
void Expand( double dDelta) ;
void Expand( double dDeltaX, double dDeltaY, double dDeltaZ) ;
bool GetMinMax( Point3d& ptMin, Point3d& ptMax) const ;
bool GetCenterExtent( Point3d& ptCenter, Vector3d& vtExtent) const ;
bool ToGlob( const Frame3d& frRef) ;
bool ToLoc( const Frame3d& frRef) ;
bool Encloses( const Point3d& ptP) const ;
bool Overlaps( const BBox3d& b3B) const ;
bool FindIntersection( const BBox3d& b3B, BBox3d& b3Int) const ;
double SqDistFromPoint( const Point3d& ptP) const ;
private :
bool IsValid( void) const ;
private :
Point3d m_ptMin ;
Point3d m_ptMax ;
} ;
+5 -3
View File
@@ -6,7 +6,7 @@
//
//
//
// Modifiche : 04.01.12 DS Creazione modulo.
// Modifiche : 04.01.13 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
@@ -30,7 +30,9 @@ class EGK_EXPORT Frame3d
enum Type { ERR = 0, TOP = 1, BOTTOM = 2, FRONT = 3,
BACK = 4, LEFT = 5, RIGHT = 6, GEN = 7} ;
public :
Frame3d( void) ;
Frame3d( void)
: m_nType( TOP), m_nZType( TOP), m_ptOrig( ORIG),
m_vtVersX( X_AX), m_vtVersY( Y_AX), m_vtVersZ( Z_AX) {}
bool Set( const Point3d& ptOrig, const Vector3d& vtDirX,
const Vector3d& vtDirY, const Vector3d& vtDirZ) ;
bool Set( const Point3d& ptOrig, const Point3d& ptOnX, const Point3d& ptNearY) ;
@@ -41,6 +43,7 @@ class EGK_EXPORT Frame3d
bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad) ;
// Scale non possibile (non previsti fattori di scala)
// Mirror non possibile (cambia il senso destrorso in sinistrorso)
bool Invert( void) ;
bool ToGlob( const Frame3d& frRef) ;
bool ToLoc( const Frame3d& frRef) ;
const Frame3d& operator*=( const Frame3d& frRef) { this->ToGlob( frRef) ; return *this ;}
@@ -63,7 +66,6 @@ class EGK_EXPORT Frame3d
Vector3d m_vtVersX ;
Vector3d m_vtVersY ;
Vector3d m_vtVersZ ;
} ;
//----------------------------------------------------------------------------
+4 -1
View File
@@ -41,6 +41,9 @@ const double COS_ORTO_ANG_ZERO = SIN_EPS_ANG_ZERO ;
// tolleranza lineare minima in approssimazioni lineari
const double LIN_TOL_MIN = 0.01 ;
// deviazione angolare minima (in gradi) in approssimazioni lineari
const double ANG_TOL_MIN_DEG = 0.1 ;
// tolleranza lineare standard in approssimazioni lineari
static const double LIN_TOL_APPROX = 1 ;
// deviazione angolare standard (in gradi) in approssimazioni lineari
static const double ANG_TOL_APPROX_DEG = 45 ;
+3
View File
@@ -16,6 +16,7 @@
#include "/EgtDev/Include/EGnScan.h"
#include "/EgtDev/Include/EGkPoint3d.h"
#include "/EgtDev/Include/EGkFrame3d.h"
#include "/EgtDev/Include/EGkBBox3d.h"
#include "/EgtDev/Include/EGkGeoObjType.h"
#include <string>
@@ -38,6 +39,8 @@ class __declspec( novtable) IGeoObj
virtual bool IsValid( void) const = 0 ;
virtual bool Save( std::ostream& osOut) const = 0 ;
virtual bool Load( Scanner& TheScanner) = 0 ;
virtual bool GetLocalBBox( BBox3d& b3Loc) const = 0 ;
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const = 0 ;
virtual bool Translate( const Vector3d& vtMove) = 0 ;
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) = 0 ;
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad) = 0 ;
+2
View File
@@ -44,6 +44,8 @@ class __declspec( novtable) IGeomDB
virtual bool GetGroupGlobFrame( int nId, Frame3d& frGlob) = 0 ;
virtual int GetParentId( int nId) = 0 ;
virtual bool GetGlobFrame( int nId, Frame3d& frGlob) = 0 ;
virtual bool GetLocalBBox( int nId, BBox3d& b3Loc) const = 0 ;
virtual bool GetBBox( int nId, const Frame3d& frRef, BBox3d& b3Ref) const = 0 ;
virtual int Copy( int nIdSou, int nIdDest, int nParentIdDest) = 0 ;
virtual bool Erase( int nId) = 0 ;
virtual bool Translate( int nId, const Vector3d& vtMove) = 0 ;
+2
View File
@@ -42,6 +42,8 @@ class EGK_EXPORT Point3d
public :
const Point3d& operator +=( const Vector3d& vtV)
{ this->x += vtV.x ; this->y += vtV.y ; this->z += vtV.z ; return *this ; }
const Point3d& operator -=( const Vector3d& vtV)
{ this->x -= vtV.x ; this->y -= vtV.y ; this->z -= vtV.z ; return *this ; }
// questa somma è valida solo se equivalente ad una combinazione baricentrica
const Point3d& operator +=( const Point3d& ptP)
{ this->x += ptP.x ; this->y += ptP.y ; this->z += ptP.z ; return *this ; }
+26
View File
@@ -50,6 +50,14 @@ class EGK_EXPORT Vector3d
{ return ( ( x * x + y * y + z * z) < ( EPS_ZERO * EPS_ZERO)) ; }
bool IsNormalized( void) const
{ return ( fabs( 1.0 - (x * x + y * y + z * z)) < ( 2 * EPS_ZERO)) ; }
bool IsXplus( void) const
{ return ( x > EPS_ZERO && fabs( y) < EPS_ZERO && fabs( z) < EPS_ZERO) ; }
bool IsXminus( void) const
{ return ( x < - EPS_ZERO && fabs( y) < EPS_ZERO && fabs( z) < EPS_ZERO) ; }
bool IsYplus( void) const
{ return ( fabs( x) < EPS_ZERO && y > EPS_ZERO && fabs( z) < EPS_ZERO) ; }
bool IsYminus( void) const
{ return ( fabs( x) < EPS_ZERO && y < - EPS_ZERO && fabs( z) < EPS_ZERO) ; }
bool IsZplus( void) const
{ return ( fabs( x) < EPS_ZERO && fabs( y) < EPS_ZERO && z > EPS_ZERO) ; }
bool IsZminus( void) const
@@ -192,6 +200,24 @@ AreSameVectorExact( const Vector3d& vtV1, const Vector3d& vtV2)
return ( ( vtV1 - vtV2).IsZero()) ;
}
//----------------------------------------------------------------------------
// Verifica che due vettori sono quasi opposti (Small error -> Near)
//----------------------------------------------------------------------------
inline bool
AreOppositeVectorNear( const Vector3d& vtV1, const Vector3d& vtV2)
{
return ( ( vtV1 + vtV2).IsSmall()) ;
}
//----------------------------------------------------------------------------
// Verifica che due vettori sono esattamente coincidenti (Zero error -> Exact)
//----------------------------------------------------------------------------
inline bool
AreOppositeVectorExact( const Vector3d& vtV1, const Vector3d& vtV2)
{
return ( ( vtV1 + vtV2).IsZero()) ;
}
//----------------------------------------------------------------------------
// Verifica che due versori sono ortogonali (Small error -> Near)
//----------------------------------------------------------------------------