Files
EgtInterface/GeoTools.cpp
T
Dario Sassi d63fa552c6 EgtInterface 1.6d4 :
- in selezione tutto si considerano solo i pezzi (non le parti per le lavorazioni)
- aggiunte EgtIsPart e EgtIsLayer a API e LUA
- migliorati controlli per riconoscimento pezzi e layer
- corretto errore in VerifySameFrame per GeoTransforms
- ImportDxf e Stl ora accettano anche fattore di scala API e LUA.
2015-04-25 20:39:16 +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/EInConst.h"
#include "/EgtDev/Include/EGkGeomDB.h"
//----------------------------------------------------------------------------
Vector3d
GetVectorLocal( IGeomDB* pGeomDB, const double vtV[3], 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 double ptP[3], 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 ;
}