b14c634bc3
- in creazione curve eliminata la normale (si deduce dal riferimento indicato) - in creazione gruppo di inserimento è layer corrente da costante - gestino carattere ' nelle stringhe per lua.
108 lines
3.3 KiB
C++
108 lines
3.3 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 "EXE.h"
|
|
#include "EXE_Macro.h"
|
|
#include "GeoTools.h"
|
|
#include "/EgtDev/Include/EGkGeomDB.h"
|
|
#include "/EgtDev/Include/EXeConst.h"
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
AdjustId( int nId)
|
|
{
|
|
GseContext* pCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX( pCtx, GDB_ID_NULL)
|
|
if ( nId == GDB_ID_CURRPART)
|
|
return pCtx->m_nCurrPart ;
|
|
else if ( nId == GDB_ID_CURRLAYER)
|
|
return pCtx->m_nCurrLayer ;
|
|
else if ( nId <= GDB_ID_NULL)
|
|
return GDB_ID_NULL ;
|
|
else
|
|
return nId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
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 ;
|
|
} |