Files
EgtExecutor/GeoTools.cpp
T
Dario Sassi 966885645e EgtExecutor 1.6e2 :
- primo rilascio (esecutore e lua da EgtInterface).
2015-05-05 22:14:04 +00:00

90 lines
2.8 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : GeoTools.cpp Data : 01.02.15 Versione : 1.6b1
// Contenuto : Funzioni geometriche ausiliarie.
//
//
//
// Modifiche : 01.02.15 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#include "stdafx.h"
#include "GeoTools.h"
#include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EXeConst.h"
//----------------------------------------------------------------------------
Vector3d
GetVectorLocal( IGeomDB* pGeomDB, const Vector3d& vtV, int nRefType, const Frame3d& frLoc)
{
Vector3d vtVL( vtV) ;
if ( nRefType == RTY_GLOB)
vtVL.ToLoc( frLoc) ;
else if ( nRefType == RTY_GRID)
vtVL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
return vtVL ;
}
//----------------------------------------------------------------------------
Point3d
GetPointLocal( IGeomDB* pGeomDB, const Point3d& ptP, int nRefType, const Frame3d& frLoc)
{
Point3d ptPL( ptP) ;
if ( nRefType == RTY_GLOB)
ptPL.ToLoc( frLoc) ;
else if ( nRefType == RTY_GRID)
ptPL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
return ptPL ;
}
//----------------------------------------------------------------------------
bool
VerifySameFrame( IGeomDB* pGeomDB, const INTVECTOR& vIds)
{
// verifico puntatore a GeomDB
if ( pGeomDB == nullptr)
return false ;
// ciclo sul vettore degli identificativi
bool bFirst = true ;
Frame3d frFirst ;
for ( size_t i = 0 ; i < vIds.size() ; ++ i) {
// se si deve agire su un singolo oggetto ( gruppo o entità)
if ( vIds[i] != GDB_ID_SEL) {
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( vIds[i], frLoc) &&
! pGeomDB->GetGlobFrame( vIds[i], frLoc))
return false ;
if ( bFirst) {
frFirst = frLoc ;
bFirst = false ;
}
else {
if ( ! AreSameFrame( frFirst, frLoc))
return false ;
}
}
// altrimenti si deve agire sugli oggetti selezionati
else {
int nI = pGeomDB->GetFirstSelectedObj() ;
while ( nI != GDB_ID_NULL) {
Frame3d frLoc ;
if ( ! pGeomDB->GetGlobFrame( nI, frLoc))
return false ;
if ( bFirst) {
frFirst = frLoc ;
bFirst = false ;
}
else {
if ( ! AreSameFrame( frFirst, frLoc))
return false ;
}
// passo alla successiva
nI = pGeomDB->GetNextSelectedObj() ;
}
}
}
return true ;
}