EgtInterface 1.6e2 :

- esecutore e lua scorporato in EgtExecutor.
This commit is contained in:
Dario Sassi
2015-05-05 22:14:56 +00:00
parent e7ee6d9255
commit 8bc0e986b2
60 changed files with 454 additions and 16260 deletions
+14 -342
View File
@@ -14,12 +14,8 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "API.h"
#include "API_Macro.h"
#include "AuxTools.h"
#include "GeoTools.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EInConst.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EXeExecutor.h"
using namespace std ;
@@ -29,61 +25,7 @@ __stdcall EgtMove( int nId, double vVtMove[3], int nRefType)
{
INTVECTOR vIds ;
vIds.push_back( nId) ;
return ( EgtMove( vIds, vVtMove, nRefType) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
bool
EgtMove( INTVECTOR& vIds, const Vector3d& vtMove, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
bool bOk = true ;
// se traslazione espressa in locale
if ( nRefType == RTY_LOC) {
// verifico che tutti gli oggetti siano nello stesso riferimento
bOk = bOk && VerifySameFrame( pGeomDB, vIds) ;
// ciclo sul vettore degli identificativi
for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) {
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
while ( nId != GDB_ID_NULL) {
// eseguo traslazione
if ( ! pGeomDB->Translate( nId, vtMove))
bOk = false ;
// passo alla successiva
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
}
}
}
// altrimenti in globale o in griglia
else {
Vector3d vtMoveG = vtMove ;
// se griglia, porto il vettore in globale
if ( nRefType == RTY_GRID)
vtMoveG.ToGlob( pGeomDB->GetGridFrame()) ;
// ciclo sul vettore degli identificativi
for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) {
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
while ( nId != GDB_ID_NULL) {
// eseguo traslazione
if ( ! pGeomDB->TranslateGlob( nId, vtMoveG))
bOk = false ;
// passo alla successiva
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
}
}
}
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtMove({" + IdListToString( vIds) + "},{" +
ToString( vtMove) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return bOk ;
return ( ExeMove( vIds, vVtMove, nRefType) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
@@ -92,66 +34,7 @@ __stdcall EgtRotate( int nId, double vPtAx[3], double vVtAx[3], double dAngRotDe
{
INTVECTOR vIds ;
vIds.push_back( nId) ;
return ( EgtRotate( vIds, vPtAx, vVtAx, dAngRotDeg, nRefType) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
bool
EgtRotate( INTVECTOR& vIds, const Point3d& ptAx, const Vector3d& vtAx, double dAngRotDeg, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
bool bOk = true ;
// se rotazione espressa in locale
if ( nRefType == RTY_LOC) {
// verifico che tutti gli oggetti siano nello stesso riferimento
bOk = bOk && VerifySameFrame( pGeomDB, vIds) ;
// ciclo sul vettore degli identificativi
for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) {
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
while ( nId != GDB_ID_NULL) {
// eseguo rotazione
if ( ! pGeomDB->Rotate( nId, ptAx, vtAx, dAngRotDeg))
bOk = false ;
// passo alla successiva
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
}
}
}
// altrimenti in globale o in griglia
else {
Point3d ptAxG = ptAx ;
Vector3d vtAxG = vtAx ;
// se griglia, porto punto e vettore in globale
if ( nRefType == RTY_GRID) {
ptAxG.ToGlob( pGeomDB->GetGridFrame()) ;
vtAxG.ToGlob( pGeomDB->GetGridFrame()) ;
}
// ciclo sul vettore degli identificativi
for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) {
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
while ( nId != GDB_ID_NULL) {
// eseguo rotazione
if ( ! pGeomDB->RotateGlob( nId, ptAxG, vtAxG, dAngRotDeg))
bOk = false ;
// passo alla successiva
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
}
}
}
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtRotate({" + IdListToString( vIds) + "},{" +
ToString( ptAx) + "},{" +
ToString( vtAx) + "}," +
ToString( dAngRotDeg) + "," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return bOk ;
return ( ExeRotate( vIds, vPtAx, vVtAx, dAngRotDeg, nRefType) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
@@ -167,68 +50,7 @@ __stdcall EgtScale( int nId, const double vOrig[3],
if ( ! frFrame.Set( vOrig, vX, vY, vZ))
return FALSE ;
// eseguo
return ( EgtScale( vIds, frFrame, dCoeffX, dCoeffY, dCoeffZ, nRefType) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
bool
EgtScale( INTVECTOR& vIds, const Frame3d& frRef,
double dCoeffX, double dCoeffY, double dCoeffZ, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
bool bOk = true ;
// se scalatura espressa in locale
if ( nRefType == RTY_LOC) {
// verifico che tutti gli oggetti siano nello stesso riferimento
bOk = bOk && VerifySameFrame( pGeomDB, vIds) ;
// ciclo sul vettore degli identificativi
for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) {
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
while ( nId != GDB_ID_NULL) {
// eseguo scalature
if ( ! pGeomDB->Scale( nId, frRef, dCoeffX, dCoeffY, dCoeffZ))
bOk = false ;
// passo alla successiva
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
}
}
}
// altrimenti in globale o in griglia
else {
Frame3d frRefG = frRef ;
// se griglia, porto riferimento in globale
if ( nRefType == RTY_GRID)
frRefG.ToGlob( pGeomDB->GetGridFrame()) ;
// ciclo sul vettore degli identificativi
for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) {
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
while ( nId != GDB_ID_NULL) {
// eseguo scalature
if ( ! pGeomDB->ScaleGlob( nId, frRefG, dCoeffX, dCoeffY, dCoeffZ))
bOk = false ;
// passo alla successiva
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
}
}
}
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtScale({" + IdListToString( vIds) + "},{{" +
ToString( frRef.Orig()) + "},{" +
ToString( frRef.VersX()) + "},{" +
ToString( frRef.VersY()) + "},{" +
ToString( frRef.VersZ()) + "}}," +
ToString( dCoeffX) + "," +
ToString( dCoeffY) + "," +
ToString( dCoeffZ) + "," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return bOk ;
return ( ExeScale( vIds, frFrame, dCoeffX, dCoeffY, dCoeffZ, nRefType) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
@@ -237,65 +59,7 @@ __stdcall EgtMirror( int nId, const double vPnt[3], const double vN[3], int nRef
{
INTVECTOR vIds ;
vIds.push_back( nId) ;
return ( EgtMirror( vIds, vPnt, vN, nRefType) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
bool
EgtMirror( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
bool bOk = true ;
// se specularità espressa in locale
if ( nRefType == RTY_LOC) {
// verifico che tutti gli oggetti siano nello stesso riferimento
bOk = bOk && VerifySameFrame( pGeomDB, vIds) ;
// ciclo sul vettore degli identificativi
for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) {
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
while ( nId != GDB_ID_NULL) {
// eseguo riflessione
if ( ! pGeomDB->Mirror( nId, ptP, vtN))
bOk = false ;
// passo alla successiva
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
}
}
}
// altrimenti in globale o in griglia
else {
Point3d ptPG = ptP ;
Vector3d vtNG = vtN ;
// se griglia, porto riferimento in globale
if ( nRefType == RTY_GRID) {
ptPG.ToGlob( pGeomDB->GetGridFrame()) ;
vtNG.ToGlob( pGeomDB->GetGridFrame()) ;
}
// ciclo sul vettore degli identificativi
for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) {
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
while ( nId != GDB_ID_NULL) {
// eseguo riflessione
if ( ! pGeomDB->MirrorGlob( nId, ptPG, vtNG))
bOk = false ;
// passo alla successiva
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
}
}
}
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtMirror({" + IdListToString( vIds) + "},{" +
ToString( ptP) + "},{" +
ToString( vtN) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return bOk ;
return ( ExeMirror( vIds, vPnt, vN, nRefType) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
@@ -305,96 +69,21 @@ __stdcall EgtShear( int nId, const double vPnt[3], const double vN[3],
{
INTVECTOR vIds ;
vIds.push_back( nId) ;
return ( EgtShear( vIds, vPnt, vN, vDir, dCoeff, nRefType) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
bool
EgtShear( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN,
const Vector3d& vtDir, double dCoeff, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
bool bOk = true ;
// se stiramento espresso in locale
if ( nRefType == RTY_LOC) {
// verifico che tutti gli oggetti siano nello stesso riferimento
bOk = bOk && VerifySameFrame( pGeomDB, vIds) ;
// ciclo sul vettore degli identificativi
for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) {
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
while ( nId != GDB_ID_NULL) {
// eseguo stiramento
if ( ! pGeomDB->Shear( nId, ptP, vtN, vtDir, dCoeff))
bOk = false ;
// passo alla successiva
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
}
}
}
// altrimenti in globale o in griglia
else {
Point3d ptPG = ptP ;
Vector3d vtNG = vtN ;
Vector3d vtDirG = vtDir ;
// se griglia, porto riferimento in globale
if ( nRefType == RTY_GRID) {
ptPG.ToGlob( pGeomDB->GetGridFrame()) ;
vtNG.ToGlob( pGeomDB->GetGridFrame()) ;
vtDirG.ToGlob( pGeomDB->GetGridFrame()) ;
}
// ciclo sul vettore degli identificativi
for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) {
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
while ( nId != GDB_ID_NULL) {
// eseguo stiramento
if ( ! pGeomDB->ShearGlob( nId, ptPG, vtNG, vtDirG, dCoeff))
bOk = false ;
// passo alla successiva
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
}
}
}
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtShear({" + IdListToString( vIds) + "},{" +
ToString( ptP) + "},{" +
ToString( vtN) + "},{" +
ToString( vtDir) + "}," +
ToString( dCoeff) + "," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return ( bOk ? TRUE : FALSE) ;
return ( ExeShear( vIds, vPnt, vN, vDir, dCoeff, nRefType) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
BOOL
__stdcall EgtMoveGroup( int nId, double vVtMove[3])
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
// eseguo traslazione ( solo singola)
bool bOk = pGeomDB->TranslateGroup( nId, vVtMove) ;
EgtSetModified() ;
// restituisco risultato
return ( bOk ? TRUE : FALSE) ;
return ( ExeMoveGroup( nId, vVtMove) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
BOOL
__stdcall EgtRotateGroup( int nId, double vPtAx[3], double vVtAx[3], double dAngRotDeg)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
// eseguo rotazione ( solo singola)
bool bOk = pGeomDB->RotateGroup( nId, vPtAx, vVtAx, dAngRotDeg) ;
EgtSetModified() ;
// restituisco risultato
return ( bOk ? TRUE : FALSE) ;
return ( ExeRotateGroup( nId, vPtAx, vVtAx, dAngRotDeg) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
@@ -403,43 +92,26 @@ __stdcall EgtScaleGroup( int nId, const double vOrig[3],
const double vX[3], const double vY[3], const double vZ[3],
double dCoeffX, double dCoeffY, double dCoeffZ)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
bool bOk = true ;
// costruisco il riferimento di scalatura
Frame3d frFrame ;
if ( ! frFrame.Set( vOrig, vX, vY, vZ))
bOk = false ;
// eseguo scalatura ( solo singola)
bOk = bOk && pGeomDB->ScaleGroup( nId, frFrame, dCoeffX, dCoeffY, dCoeffZ) ;
EgtSetModified() ;
// restituisco risultato
return ( bOk ? TRUE : FALSE) ;
return FALSE ;
// eseguo
return ( ExeScaleGroup( nId, frFrame, dCoeffX, dCoeffY, dCoeffZ) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
BOOL
__stdcall EgtMirrorGroup( int nId, const double vPnt[3], const double vN[3])
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
// eseguo riflessione ( solo singola)
bool bOk = pGeomDB->MirrorGroup( nId, vPnt, vN) ;
EgtSetModified() ;
// restituisco risultato
return ( bOk ? TRUE : FALSE) ;
return ( ExeMirrorGroup( nId, vPnt, vN) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
BOOL
__stdcall EgtShearGroup( int nId, const double vPnt[3], const double vN[3],
const double vDir[3], double dCoeff)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
// eseguo stiramento ( solo singolo)
bool bOk = pGeomDB->ShearGroup( nId, vPnt, vN, vDir, dCoeff) ;
EgtSetModified() ;
// restituisco risultato
return ( bOk ? TRUE : FALSE) ;
return ( ExeShearGroup( nId, vPnt, vN, vDir, dCoeff) ? TRUE : FALSE) ;
}