EgtInterface 1.6a2 :

- numerose modifiche e correzioni
- aggiunta registrazione comandi in formato lua
- aggiunto valutatore di espressioni.
This commit is contained in:
Dario Sassi
2015-01-14 21:56:57 +00:00
parent bebcf1ecfe
commit e23999b6a3
32 changed files with 3080 additions and 989 deletions
+265 -63
View File
@@ -15,6 +15,7 @@
#include "stdafx.h"
#include "API.h"
#include "API_Macro.h"
#include "AuxTools.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EInConst.h"
#include "/EgtDev/Include/EgkCurveLine.h"
@@ -30,6 +31,7 @@
#include "/EgtDev/Include/EgkChainCurves.h"
#include "/EgtDev/Include/EgkSurfTriMesh.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
@@ -66,7 +68,17 @@ __stdcall EgtCreateCurveLine( int nParentId, const double ptIni[3], const double
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvLine)))
return GDB_ID_NULL ;
// inserisco la linea nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtLine(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptIni)) + "},{" +
ToString( Point3d( ptFin)) + "})" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
@@ -161,7 +173,28 @@ __stdcall EgtCreateCurveLineEx( int nParentId, const double ptIni[3], int nSepI,
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvLine)))
return GDB_ID_NULL ;
// inserisco la linea nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua ;
if ( nSepI == SEP_STD && nSepF == SEP_STD)
sLua = "EgtLine(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptIni)) + "},{" +
ToString( Point3d( ptFin)) + "})" +
" -- Id=" + ToString( nId) ;
else
sLua = "EgtLineEx(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptIni)) + "}," +
SepToString( nSepI) + "," +
ToString( nIdI) + ",{" +
ToString( Point3d( ptFin)) + "}," +
SepToString( nSepF) + "," +
ToString( nIdF) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
@@ -442,7 +475,18 @@ __stdcall EgtCreateCurveLinePVL( int nParentId, const double ptIni[3], const dou
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvLine)))
return GDB_ID_NULL ;
// inserisco la linea nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtLinePVL(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptIni)) + "},{" +
ToString( Vector3d( vtDir)) + "}," +
ToString( dLen) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
@@ -486,7 +530,18 @@ __stdcall EgtCreateCurveLineMinPointCurve( int nParentId,
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvLine)))
return GDB_ID_NULL ;
// inserisco la linea nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtLineMinPointCurve(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptStart)) + "}," +
ToString( nCrvId) + "," +
ToString( dNearPar) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
@@ -507,7 +562,25 @@ __stdcall EgtCreateCurveCircle( int nParentId,
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
// inserisco l'arco nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua ;
if ( Vector3d( vtN).IsZplus())
sLua = "EgtCircleXY(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "}," +
ToString( dRad) + ")" +
" -- Id=" + ToString( nId) ;
else
sLua = "EgtCircle(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "},{" +
ToString( Vector3d( vtN)) + "}," +
ToString( dRad) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
@@ -528,7 +601,17 @@ __stdcall EgtCreateCurveCircleXY( int nParentId,
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
// inserisco l'arco nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtCircleXY(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "}," +
ToString( dRad) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
@@ -551,7 +634,18 @@ __stdcall EgtCreateCurveCircleCPN( int nParentId,
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
// inserisco l'arco nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtCircleCPN(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "},{" +
ToString( Point3d( ptOn)) + "},{" +
ToString( Vector3d( vtN)) + "})" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
@@ -572,7 +666,18 @@ __stdcall EgtCreateCurveCircle3P( int nParentId,
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
// inserisco l'arco nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtCircle3P(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptP1)) + "},{" +
ToString( Point3d( ptP2)) + "},{" +
ToString( Point3d( ptP3)) + "})" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
@@ -594,7 +699,21 @@ __stdcall EgtCreateCurveArc( int nParentId,
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
// inserisco l'arco nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtArc(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "},{" +
ToString( Vector3d( vtN)) + "}," +
ToString( dRad) + ",{" +
ToString( Vector3d( vtS)) + "}," +
ToString( dAngCenDeg) + "," +
ToString( dDeltaN) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
@@ -616,33 +735,20 @@ __stdcall EgtCreateCurveArcXY( int nParentId,
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
// inserisco l'arco nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveArc3P( int nParentId,
const double ptP1[3], const double ptP2[3], const double ptP3[3])
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo l'arco
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( IsNull( pCrvArc))
return GDB_ID_NULL ;
// setto l'arco
if ( pCrvArc->Set3P( ptP1, ptP2, ptP3, false)) {
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
// inserisco l'arco nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtArc(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "}," +
ToString( dRad) + "," +
ToString( dAngStartDeg) + "," +
ToString( dAngCenDeg) + "," +
ToString( dDeltaZ) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// se risulta essere una retta
if ( ( Point3d( ptP2) - Point3d( ptP1)) * ( Point3d( ptP3) - Point3d( ptP2)) > EPS_ZERO)
return EgtCreateCurveLine( nParentId, ptP1, ptP3) ;
// errore
return GDB_ID_NULL ;
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
@@ -663,7 +769,60 @@ __stdcall EgtCreateCurveArcC2PN( int nParentId,
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
// inserisco l'arco nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtArcC2PN(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "},{" +
ToString( Point3d( ptStart)) + "},{" +
ToString( Point3d( ptNearEnd)) + "},{" +
ToString( Vector3d( vtNorm)) + "})" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveArc3P( int nParentId,
const double ptP1[3], const double ptP2[3], const double ptP3[3])
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo l'arco
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( IsNull( pCrvArc))
return GDB_ID_NULL ;
int nId = GDB_ID_NULL ;
// setto l'arco
if ( pCrvArc->Set3P( ptP1, ptP2, ptP3, false)) {
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
// inserisco l'arco nel DB
nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
}
// se risulta essere una retta
else if ( ( Point3d( ptP2) - Point3d( ptP1)) * ( Point3d( ptP3) - Point3d( ptP2)) > EPS_ZERO) {
bool bOldCmdLog = IsCmdLog() ;
EgtDisableCommandLogger() ;
nId = EgtCreateCurveLine( nParentId, ptP1, ptP3) ;
if ( bOldCmdLog)
EgtEnableCommandLogger() ;
}
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtArc3P(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptP1)) + "},{" +
ToString( Point3d( ptP2)) + "},{" +
ToString( Point3d( ptP3)) + "})" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
@@ -677,19 +836,35 @@ __stdcall EgtCreateCurveArc2PVN( int nParentId,
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( IsNull( pCrvArc))
return GDB_ID_NULL ;
int nId = GDB_ID_NULL ;
// setto l'arco
if ( pCrvArc->Set2PVN( ptStart, ptEnd, vtDirS, vtNorm)) {
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
// inserisco l'arco nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
}
// se risulta essere una retta
if ( ( Point3d( ptEnd) - Point3d( ptStart)) * Vector3d( vtDirS) > EPS_ZERO)
return EgtCreateCurveLine( nParentId, ptStart, ptEnd) ;
// errore
return GDB_ID_NULL ;
else if ( ( Point3d( ptEnd) - Point3d( ptStart)) * Vector3d( vtDirS) > EPS_ZERO) {
bool bOldCmdLog = IsCmdLog() ;
EgtDisableCommandLogger() ;
nId = EgtCreateCurveLine( nParentId, ptStart, ptEnd) ;
if ( bOldCmdLog)
EgtEnableCommandLogger() ;
}
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtArc2PVN(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptStart)) + "},{" +
ToString( Point3d( ptEnd)) + "},{" +
ToString( Vector3d( vtDirS)) + "},{" +
ToString( Vector3d( vtNorm)) + "})" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
@@ -1016,6 +1191,22 @@ __stdcall EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, cons
return GDB_ID_NULL ;
}
}
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sIds ;
for ( size_t i = 0 ; i < vIds.size() ; ++ i) {
if ( i > 0)
sIds += "," ;
sIds += ToString( vIds[i]) ;
}
string sLua = "EgtCurveCompoByChain(" + ToString( nParentId) + ",{" +
sIds + "},{" +
ToString( Point3d( ptNear)) + "}," +
( bErase ? "true" : "false") + ")" +
" -- Id=" + ToString( nFirstId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della prima nuova entità
return nFirstId ;
}
@@ -1083,7 +1274,7 @@ __stdcall EgtCreateCurveCompoFromPointBulges( int nParentId, const PolyArc& PA)
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoFromCurveApprox( int nParentId, int nSouId, BOOL bArcsVsLines, double dLinTol)
__stdcall EgtCreateCurveCompoByApprox( int nParentId, int nSouId, BOOL bArcsVsLines, double dLinTol)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
@@ -1113,38 +1304,49 @@ __stdcall EgtCreateCurveCompoFromCurveApprox( int nParentId, int nSouId, BOOL bA
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoFromRectangle( int nParentId,
const double ptIni[3], const double ptFin[3])
__stdcall EgtCreateRectangle3P( int nParentId,
const double ptIni[3], const double ptCross[3], const double ptDir[3])
{
// --- Il rettangolo ha i lati paralleli agli assi della griglia corrente ---
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// recupero il riferimento di inserimento
Frame3d frEnt ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frEnt))
return GDB_ID_NULL ;
// recupero il riferimento di griglia
Frame3d frGrid = pGeomDB->GetGridFrame() ;
// calcolo il vettore del lato parallelo a Y
Vector3d vtDiag = (Point3d( ptFin) - Point3d( ptIni)) ;
vtDiag.LocToLoc( frEnt, frGrid) ;
Vector3d vtLatoY( 0, vtDiag.y, 0) ;
vtLatoY.LocToLoc( frGrid, frEnt) ;
bOk = false ;
// calcolo il lato X
Vector3d vtDirX = Point3d( ptDir) - Point3d( ptIni) ;
bOk = vtDirX.Normalize() ;
Vector3d vtLatoX = bOk ? (( Point3d( ptCross) - Point3d( ptIni)) * vtDirX) * vtDirX : V_NULL ;
// creo la polilinea con i punti
PolyLine PL ;
PL.AddUPoint( 0, ptIni) ;
PL.AddUPoint( 1, Point3d( ptFin) - vtLatoY) ;
PL.AddUPoint( 2, ptFin) ;
PL.AddUPoint( 3, Point3d( ptIni) + vtLatoY) ;
PL.AddUPoint( 4, ptIni) ;
// creo la curva e la inserisco nel GDB
return EgtCreateCurveCompoFromPoints( nParentId, PL) ;
int nId = GDB_ID_NULL ;
if ( bOk) {
PolyLine PL ;
PL.AddUPoint( 0, ptIni) ;
PL.AddUPoint( 1, Point3d( ptIni) + vtLatoX) ;
PL.AddUPoint( 2, ptCross) ;
PL.AddUPoint( 3, Point3d( ptCross) - vtLatoX) ;
PL.AddUPoint( 4, ptIni) ;
// creo la curva e la inserisco nel GDB
nId = EgtCreateCurveCompoFromPoints( nParentId, PL) ;
}
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtRectangle3P(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptIni)) + "},{" +
ToString( Point3d( ptCross)) + "},{" +
ToString( Point3d( ptDir)) + "})" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoFromPolygonSide( int nParentId, int nNumSides,
const double ptIni[3], const double ptFin[3])
__stdcall EgtCreatePolygonFromSide( int nParentId, int nNumSides,
const double ptIni[3], const double ptFin[3])
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)