EgtInterface 1.5l2 :

- migliorie e modifiche in generale, specie su Lua.
This commit is contained in:
Dario Sassi
2014-12-30 17:36:43 +00:00
parent 517a36a009
commit bebcf1ecfe
23 changed files with 1528 additions and 402 deletions
+35 -26
View File
@@ -27,53 +27,62 @@ bool __stdcall EgtGetVersionInfo( std::string& sVer, const char* szNewLine) ;
//--------------------------- GeomDB -----------------------------------------
bool __stdcall EgtSetGridFrame( const Frame3d& frFrame) ;
bool __stdcall EgtGetGridFrame( Frame3d& frFrame) ;
bool __stdcall EgtGetGridVersZ( int nRefId, Vector3d& vtVersZ) ;
bool __stdcall EgtOpenFile( const std::string& sFilePath) ;
bool __stdcall EgtSaveFile( const std::string& sFilePath, int nFlag) ;
//--------------------------- GeomDB Create ----------------------------------
int __stdcall EgtCreateCurveBezier( int nParentId, int nDegree, const PNTVECTOR& vPnt) ;
int __stdcall EgtCreateCurveBezierRational( int nParentId, int nDegree, const PNTUVECTOR& vPntW) ;
int __stdcall EgtCreateCurveCompo( int nParentId, const INTVECTOR& vIds, bool bErase) ;
int __stdcall EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, const Point3d& ptNear, bool bErase) ;
int __stdcall EgtCreateCurveCompoFromPoints( int nParentId, const PolyLine& PL) ;
int __stdcall EgtCreateCurveCompoFromPointBulges( int nParentId, const PolyArc& PA) ;
//--------------------------- GeomDBCreate -----------------------------------
int __stdcall EgtCreateText( int nParentId, const std::string& sText,
const Point3d& ptP, double dAngRotDeg, double dH) ;
int __stdcall EgtCreateTextEx( int nParentId, const std::string& sText,
const Point3d& ptP, double dAngRotDeg, const std::string& sFont,
int nW, bool bItalic, double dH, double dRat, double dAddAdv, int nInsPos) ;
//--------------------------- GeomDBCreateCurve ------------------------------
int __stdcall EgtCreateCurveBezier( int nParentId, int nDegree, const PNTVECTOR& vPnt) ;
int __stdcall EgtCreateCurveBezierRational( int nParentId, int nDegree, const PNTUVECTOR& vPntW) ;
int __stdcall EgtCreateCurveCompo( int nParentId, const INTVECTOR& vIds, bool bErase) ;
int __stdcall EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, const Point3d& ptNear, bool bErase) ;
int __stdcall EgtCreateCurveCompoFromPoints( int nParentId, const PolyLine& PL) ;
int __stdcall EgtCreateCurveCompoFromPointBulges( int nParentId, const PolyArc& PA) ;
bool __stdcall GetPolyLineFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyLine& PL) ;
bool __stdcall GetPolyArcFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyArc& PA) ;
//--------------------------- GdbModify --------------------------------------
BOOL __stdcall EgtModifyText( int nId, const std::string& sNewText) ;
BOOL __stdcall EgtChangeTextFont( int nId, const std::string& sNewFont) ;
//--------------------------- GdbObjects -------------------------------------
int __stdcall EgtGetFirstNameInGroup( int nGroupId, const std::string& sName) ;
int __stdcall EgtGetNextName( int nId, const std::string& sName) ;
//--------------------------- GdbObjAttribs ----------------------------------
BOOL __stdcall EgtStdColor( const std::string& sName, Color& StdCol) ;
BOOL __stdcall EgtSetName( int nId, const std::string& sName) ;
BOOL __stdcall EgtGetName( int nId, std::string& sName) ;
bool __stdcall EgtSetName( int nId, const std::string& sName) ;
bool __stdcall EgtGetName( int nId, std::string& sName) ;
bool __stdcall EgtSetInfo( int nId, const std::string& sKey, const std::string& sInfo) ;
bool __stdcall EgtSetInfo( int nId, const std::string& sKey, int nInfo) ;
bool __stdcall EgtGetInfo( int nId, const std::string& sKey, std::string& sInfo) ;
bool __stdcall EgtGetInfo( int nId, const std::string& sKey, int& nInfo) ;
BOOL __stdcall EgtExistsInfo( int nId, const std::string& sKey) ;
BOOL __stdcall EgtRemoveInfo( int nId, const std::string& sKey) ;
bool __stdcall EgtExistsInfo( int nId, const std::string& sKey) ;
bool __stdcall EgtRemoveInfo( int nId, const std::string& sKey) ;
//--------------------------- GeoSnap ----------------------------------------
bool __stdcall EgtStartPoint( int nId, Point3d& ptP) ;
bool __stdcall EgtEndPoint( int nId, Point3d& ptP) ;
bool __stdcall EgtMidPoint( int nId, Point3d& ptP) ;
bool __stdcall EgtCenterPoint( int nId, Point3d& ptP) ;
bool __stdcall EgtAtParamPoint( int nId, double dU, Point3d& ptP) ;
bool __stdcall EgtIntersectionPoint( int nId1, int nId2, const Point3d& ptNear, Point3d& ptP) ;
bool __stdcall EgtStartVector( int nId, Vector3d& vtV) ;
bool __stdcall EgtEndVector( int nId, Vector3d& vtV) ;
bool __stdcall EgtMidVector( int nId, Vector3d& vtV) ;
bool __stdcall EgtAtParamVector( int nId, double dU, int nSide, Vector3d& vtV) ;
bool __stdcall EgtFrame( int nId, Frame3d& frFrame) ;
bool __stdcall EgtCurveExtrusion( int nId, Vector3d& vtExtr) ;
bool __stdcall EgtStartPoint( int nId, int nRefId, Point3d& ptP) ;
bool __stdcall EgtEndPoint( int nId, int nRefId, Point3d& ptP) ;
bool __stdcall EgtMidPoint( int nId, int nRefId, Point3d& ptP) ;
bool __stdcall EgtCenterPoint( int nId, int nRefId, Point3d& ptP) ;
bool __stdcall EgtAtParamPoint( int nId, double dU, int nRefId, Point3d& ptP) ;
bool __stdcall EgtNearPoint( int nId, const Point3d& ptNear, int nRefId, Point3d& ptP) ;
bool __stdcall EgtIntersectionPoint( int nId1, int nId2, const Point3d& ptNear, int nRefId, Point3d& ptP) ;
bool __stdcall EgtStartVector( int nId, int nRefId, Vector3d& vtV) ;
bool __stdcall EgtEndVector( int nId, int nRefId, Vector3d& vtV) ;
bool __stdcall EgtMidVector( int nId, int nRefId, Vector3d& vtV) ;
bool __stdcall EgtAtParamVector( int nId, double dU, int nSide, int nRefId, Vector3d& vtV) ;
bool __stdcall EgtFrame( int nId, int nRefId, Frame3d& frFrame) ;
bool __stdcall EgtCurveExtrusion( int nId, int nRefId, Vector3d& vtExtr) ;
// EgtCurveThickness vedi EinAPI.h
bool __stdcall EgtCurveArcNormVersor( int nId, Vector3d& vtNorm) ;
bool __stdcall EgtExtTextNormVersor( int nId, Vector3d& vtNorm) ;
bool __stdcall EgtCurveArcNormVersor( int nId, int nRefId, Vector3d& vtNorm) ;
bool __stdcall EgtExtTextNormVersor( int nId, int nRefId, Vector3d& vtNorm) ;
bool __stdcall EgtPointToIdGlob( Point3d& ptP, int nId) ;
bool __stdcall EgtPointToIdLoc( Point3d& ptP, int nId) ;
bool __stdcall EgtVectorToIdGlob( Vector3d& vtV, int nId) ;
+104
View File
@@ -1081,6 +1081,36 @@ __stdcall EgtCreateCurveCompoFromPointBulges( int nParentId, const PolyArc& PA)
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoFromCurveApprox( int nParentId, int nSouId, BOOL bArcsVsLines, double dLinTol)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero il riferimento di inserimento
Frame3d frEnt ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frEnt))
return GDB_ID_NULL ;
// eseguo l'approssimazione
PtrOwner<ICurveComposite> pCC( CreateCurveComposite()) ;
if ( IsNull( pCC))
return false ;
if ( ! bArcsVsLines) { // con linee
PolyLine PL ;
if ( ! GetPolyLineFromCurve( nSouId, frEnt, dLinTol, PL) ||
! pCC->FromPolyLine( PL))
return false ;
}
else { // con bi-archi
PolyArc PA ;
if ( ! GetPolyArcFromCurve( nSouId, frEnt, dLinTol, PA) ||
! pCC->FromPolyArc( PA))
return false ;
}
// inserisco la curva composita nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCC)) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoFromRectangle( int nParentId,
@@ -1147,3 +1177,77 @@ __stdcall SetExtrusionFromGridVersZ( IGeomDB* pGeomDB, int nParentId, ICurve* pC
vtExtr.ToLoc( frEnt) ;
return pCurve->SetExtrusion( vtExtr) ;
}
//----------------------------------------------------------------------------
bool
__stdcall GetPolyLineFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyLine& PL)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCrv == nullptr)
return false ;
// recupero il riferimento della curva
Frame3d frCrv ;
if ( ! pGeomDB->GetGlobFrame( nId, frCrv))
return false ;
// calcolo la polilinea che approssima la curva
const double ANG_TOL_STD_DEG = 15 ;
// se i riferimenti sono uguali
if ( AreSameFrame( frCrv, frDest)) {
// ricavo l'approssimazione
if ( ! pCrv->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL))
return false ;
}
// altrimenti devo prima trasformare la curva
else {
// creo una copia della curva (da buttare alla fine)
PtrOwner<ICurve> pModCrv( pCrv->Clone()) ;
if ( IsNull( pModCrv))
return false ;
// eseguo la trasformazione
pModCrv->LocToLoc( frCrv, frDest) ;
// ricavo l'approssimazione
if ( ! pModCrv->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL))
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
__stdcall GetPolyArcFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyArc& PA)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCrv == nullptr)
return false ;
// recupero il riferimento della curva
Frame3d frCrv ;
if ( ! pGeomDB->GetGlobFrame( nId, frCrv))
return false ;
// calcolo la polilinea che approssima la curva
const double ANG_TOL_STD_DEG = 15 ;
// se i riferimenti sono uguali
if ( AreSameFrame( frCrv, frDest)) {
// ricavo l'approssimazione
if ( ! pCrv->ApproxWithArcs( dLinTol, ANG_TOL_STD_DEG, PA))
return false ;
}
// altrimenti devo prima trasformare la curva
else {
// creo una copia della curva (da buttare alla fine)
PtrOwner<ICurve> pModCrv( pCrv->Clone()) ;
if ( IsNull( pModCrv))
return false ;
// eseguo la trasformazione
pModCrv->LocToLoc( frCrv, frDest) ;
// ricavo l'approssimazione
if ( ! pModCrv->ApproxWithArcs( dLinTol, ANG_TOL_STD_DEG, PA))
return false ;
}
return true ;
}
+5 -45
View File
@@ -22,10 +22,6 @@
using namespace std ;
//-------------------------------------------------------------------------------
static bool GetPolyLineFromCurve( IGeomDB* pGeomDB, int nId, const Frame3d& frDest, double dLinTol, PolyLine& PL) ;
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateSurfTriMeshByContour( int nParentId, int nCrvId, double dLinTol)
@@ -38,7 +34,7 @@ __stdcall EgtCreateSurfTriMeshByContour( int nParentId, int nCrvId, double dLinT
return GDB_ID_NULL ;
// calcolo la polilinea che approssima la curva
PolyLine PL ;
if ( ! GetPolyLineFromCurve( pGeomDB, nCrvId, frDest, dLinTol, PL))
if ( ! GetPolyLineFromCurve( nCrvId, frDest, dLinTol, PL))
return GDB_ID_NULL ;
// creo la superficie trimesh
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
@@ -63,7 +59,7 @@ __stdcall EgtCreateSurfTriMeshByExtrusion( int nParentId, int nCrvId, const doub
return GDB_ID_NULL ;
// calcolo la polilinea che approssima la curva
PolyLine PL ;
if ( ! GetPolyLineFromCurve( pGeomDB, nCrvId, frDest, dLinTol, PL))
if ( ! GetPolyLineFromCurve( nCrvId, frDest, dLinTol, PL))
return GDB_ID_NULL ;
// creo la superficie trimesh
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
@@ -90,7 +86,7 @@ __stdcall EgtCreateSurfTriMeshByScrewing( int nParentId, int nCrvId,
return GDB_ID_NULL ;
// calcolo la polilinea che approssima la curva
PolyLine PL ;
if ( ! GetPolyLineFromCurve( pGeomDB, nCrvId, frDest, dLinTol, PL))
if ( ! GetPolyLineFromCurve( nCrvId, frDest, dLinTol, PL))
return GDB_ID_NULL ;
// calcolo lo step di rotazione
double dMaxRad = 0 ;
@@ -121,11 +117,11 @@ __stdcall EgtCreateSurfTriMeshRuled( int nParentId, int nCrvId1, int nCrvId2, do
return GDB_ID_NULL ;
// calcolo la polilinea che approssima la prima curva
PolyLine PL1 ;
if ( ! GetPolyLineFromCurve( pGeomDB, nCrvId1, frDest, dLinTol, PL1))
if ( ! GetPolyLineFromCurve( nCrvId1, frDest, dLinTol, PL1))
return GDB_ID_NULL ;
// calcolo la polilinea che approssima la seconda curva
PolyLine PL2 ;
if ( ! GetPolyLineFromCurve( pGeomDB, nCrvId2, frDest, dLinTol, PL2))
if ( ! GetPolyLineFromCurve( nCrvId2, frDest, dLinTol, PL2))
return GDB_ID_NULL ;
// creo la superficie trimesh
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
@@ -137,39 +133,3 @@ __stdcall EgtCreateSurfTriMeshRuled( int nParentId, int nCrvId1, int nCrvId2, do
// inserisco la superficie trimesh nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) ;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
static bool
GetPolyLineFromCurve( IGeomDB* pGeomDB, int nId, const Frame3d& frDest, double dLinTol, PolyLine& PL)
{
const double ANG_TOL_STD_DEG = 15 ;
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCrv == nullptr)
return false ;
// recupero il riferimento della curva
Frame3d frCrv ;
if ( ! pGeomDB->GetGlobFrame( nId, frCrv))
return false ;
// calcolo la polilinea che approssima la curva
// se i riferimenti sono uguali
if ( AreSameFrame( frCrv, frDest)) {
// ricavo l'approssimazione
if ( ! pCrv->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL))
return false ;
}
// altrimenti devo prima trasformare la curva
else {
// creo una copia della curva (da buttare alla fine)
PtrOwner<ICurve> pModCrv( pCrv->Clone()) ;
if ( IsNull( pModCrv))
return false ;
// eseguo la trasformazione
pModCrv->LocToLoc( frCrv, frDest) ;
// ricavo l'approssimazione
if ( ! pModCrv->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL))
return false ;
}
return true ;
}
+58 -18
View File
@@ -16,12 +16,13 @@
#include "API.h"
#include "API_Macro.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EgkCurve.h"
#include "/EgtDev/Include/EgkCurveArc.h"
#include "/EgtDev/Include/EgkCurveBezier.h"
#include "/EgtDev/Include/EgkCurveComposite.h"
#include "/EgtDev/Include/EgkDistPointCurve.h"
#include "/EgtDev/Include/EgkExtTExt.h"
#include "/EgtDev/Include/EGkCurve.h"
#include "/EgtDev/Include/EGkCurveArc.h"
#include "/EgtDev/Include/EGkCurveBezier.h"
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkExtTExt.h"
#include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
@@ -73,12 +74,32 @@ __stdcall EgtModifyCurveExtrusion( int nId, const double vtExtr[3])
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCurve == nullptr)
return FALSE ;
// ne modifico il vettore estrusione
return ( pCurve->SetExtrusion( Vector3d( vtExtr)) ? TRUE : FALSE) ;
// se gruppo, agisco sulle sole curve componenti
if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) {
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( pGeomDB)) ;
if ( IsNull( pIter))
return FALSE ;
bool bOk = true ;
Vector3d vtVE( vtExtr) ;
for ( bool bFound = pIter->GoToFirstInGroup( nId) ;
bFound ;
bFound = pIter->GoToNext()) {
// recupero la curva e ne modifico il vettore estrusione
ICurve* pCurve = GetCurve( pIter->GetGeoObj()) ;
if ( pCurve != nullptr && ! pCurve->SetExtrusion( vtVE))
bOk = false ;
}
return ( bOk ? TRUE : FALSE) ;
}
// se oggetto geometrico
else {
// recupero la curva
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCurve == nullptr)
return FALSE ;
// ne modifico il vettore estrusione
return ( pCurve->SetExtrusion( Vector3d( vtExtr)) ? TRUE : FALSE) ;
}
}
//----------------------------------------------------------------------------
@@ -87,12 +108,31 @@ __stdcall EgtModifyCurveThickness( int nId, double dThick)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCurve == nullptr)
return FALSE ;
// ne modifico lo spessore
return ( pCurve->SetThickness( dThick) ? TRUE : FALSE) ;
// se gruppo, agisco sulle sole curve componenti
if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) {
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( pGeomDB)) ;
if ( IsNull( pIter))
return FALSE ;
bool bOk = true ;
for ( bool bFound = pIter->GoToFirstInGroup( nId) ;
bFound ;
bFound = pIter->GoToNext()) {
// recupero la curva e ne modifico lo spessore
ICurve* pCurve = GetCurve( pIter->GetGeoObj()) ;
if ( pCurve != nullptr && ! pCurve->SetThickness( dThick))
bOk = false ;
}
return ( bOk ? TRUE : FALSE) ;
}
// se oggetto geometrico
else {
// recupero la curva
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCurve == nullptr)
return FALSE ;
// ne modifico lo spessore
return ( pCurve->SetThickness( dThick) ? TRUE : FALSE) ;
}
}
//----------------------------------------------------------------------------
+13 -21
View File
@@ -212,7 +212,7 @@ BOOL
__stdcall EgtStdColor( const wchar_t* wsName, int StdCol[4])
{
Color ColStd ;
if ( EgtStdColor( wstrztoA( wsName), ColStd) != FALSE) {
if ( GetStdColor( wstrztoA( wsName), ColStd)) {
StdCol[0] = ColStd.GetIntRed() ;
StdCol[1] = ColStd.GetIntGreen() ;
StdCol[2] = ColStd.GetIntBlue() ;
@@ -222,14 +222,6 @@ __stdcall EgtStdColor( const wchar_t* wsName, int StdCol[4])
return FALSE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtStdColor( const string& sName, Color& StdCol)
{
// recupero il colore standard
return ( GetStdColor( sName, StdCol) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtSetColor( int nId, const int ObjCol[4])
@@ -320,17 +312,17 @@ __stdcall EgtGetCalcColor( int nId, int ObjCol[4])
BOOL
__stdcall EgtSetName( int nId, const wchar_t* wsName)
{
return EgtSetName( nId, wstrztoA( wsName)) ;
return ( EgtSetName( nId, wstrztoA( wsName)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
bool
__stdcall EgtSetName( int nId, const string& sName)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
VERIFY_GEOMDB( pGeomDB, false)
// assegno il nome
return ( pGeomDB->SetName( nId, sName) ? TRUE : FALSE) ;
return pGeomDB->SetName( nId, sName) ;
}
//-----------------------------------------------------------------------------
@@ -345,11 +337,11 @@ __stdcall EgtGetName( int nId, wchar_t*& wsName)
}
//-----------------------------------------------------------------------------
BOOL
bool
__stdcall EgtGetName( int nId, string& sName)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
VERIFY_GEOMDB( pGeomDB, false)
// recupero il nome
return pGeomDB->GetName( nId, sName) ;
}
@@ -454,32 +446,32 @@ __stdcall EgtGetInfo( int nId, const string& sKey, int& nInfo)
BOOL
__stdcall EgtExistsInfo( int nId, const wchar_t* wsKey)
{
return EgtExistsInfo( nId, wstrztoA( wsKey)) ;
return ( EgtExistsInfo( nId, wstrztoA( wsKey)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
bool
__stdcall EgtExistsInfo( int nId, const string& sKey)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
// verifico esistenza info
return ( pGeomDB->ExistsInfo( nId, sKey) ? TRUE : FALSE) ;
return pGeomDB->ExistsInfo( nId, sKey) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtRemoveInfo( int nId, const wchar_t* wsKey)
{
return EgtRemoveInfo( nId, wstrztoA( wsKey)) ;
return ( EgtRemoveInfo( nId, wstrztoA( wsKey)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
bool
__stdcall EgtRemoveInfo( int nId, const string& sKey)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
// rimuovo la info
return ( pGeomDB->RemoveInfo( nId, sKey) ? TRUE : FALSE) ;
return pGeomDB->RemoveInfo( nId, sKey) ;
}
+30
View File
@@ -151,6 +151,36 @@ __stdcall EgtGetPrevGroup( int nId)
return pGeomDB->GetPrevGroup( nId) ;
}
//-----------------------------------------------------------------------------
int
__stdcall EgtGetFirstNameInGroup( int nGroupId, const string& sName)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero il primo oggetto nel gruppo
int nFirstId = pGeomDB->GetFirstInGroup( nGroupId) ;
string sObjName ;
if ( pGeomDB->GetName( nFirstId, sObjName) && sObjName == sName)
return nFirstId ;
return EgtGetNextName( nFirstId, sName) ;
}
//-----------------------------------------------------------------------------
int
__stdcall EgtGetNextName( int nId, const string& sName)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero il prossimo oggetto nello stesso gruppo con il nome voluto
int nNextId = nId ;
while ( ( nNextId = pGeomDB->GetNext( nNextId)) != GDB_ID_NULL) {
string sObjName ;
if ( pGeomDB->GetName( nNextId, sObjName) && sObjName == sName)
return nNextId ;
}
return GDB_ID_NULL ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtGetBBox( int nId, int nFlag, double ptMin[3], double ptMax[3])
+238 -71
View File
@@ -26,13 +26,97 @@
#include "/EgtDev/Include/EgtPointerOwner.h"
//----------------------------------------------------------------------------
static bool
TrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP)
{
// se non va trasformato, esco
if ( nRefId == nId)
return true ;
// recupero il riferimento in cui è espresso il punto (quello dell'entità da cui deriva)
Frame3d frSou ;
if ( ! pGeomDB->GetGlobFrame( nId, frSou))
return false ;
// se va portato in globale, trasformo ed esco
if ( nRefId == GDB_ID_ROOT)
return ptP.ToGlob( frSou) ;
// recupero il riferimento destinazione
Frame3d frDest ;
if ( nRefId == GDB_ID_GRID)
frDest = pGeomDB->GetGridFrame() ;
else {
// nRefId può essere un gruppo o una entità
if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) &&
! pGeomDB->GetGlobFrame( nRefId, frDest))
return false ;
}
// eseguo la trasformazione
return ptP.LocToLoc( frSou, frDest) ;
}
//----------------------------------------------------------------------------
static bool
TrasformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV)
{
// se non va trasformato, esco
if ( nRefId == nId)
return true ;
// recupero il riferimento in cui è espresso il punto (quello dell'entità da cui deriva)
Frame3d frSou ;
if ( ! pGeomDB->GetGlobFrame( nId, frSou))
return false ;
// se va portato in globale, trasformo ed esco
if ( nRefId == GDB_ID_ROOT)
return vtV.ToGlob( frSou) ;
// recupero il riferimento destinazione
Frame3d frDest ;
if ( nRefId == GDB_ID_GRID)
frDest = pGeomDB->GetGridFrame() ;
else {
// nRefId può essere un gruppo o una entità
if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) &&
! pGeomDB->GetGlobFrame( nRefId, frDest))
return false ;
}
// eseguo la trasformazione
return vtV.LocToLoc( frSou, frDest) ;
}
//----------------------------------------------------------------------------
static bool
TrasformFrame( IGeomDB* pGeomDB, int nId, int nRefId, Frame3d& frF)
{
// se non va trasformato, esco
if ( nRefId == nId)
return true ;
// recupero il riferimento in cui è espresso il punto (quello dell'entità da cui deriva)
Frame3d frSou ;
if ( ! pGeomDB->GetGlobFrame( nId, frSou))
return false ;
// se va portato in globale, trasformo ed esco
if ( nRefId == GDB_ID_ROOT)
return frF.ToGlob( frSou) ;
// recupero il riferimento destinazione
Frame3d frDest ;
if ( nRefId == GDB_ID_GRID)
frDest = pGeomDB->GetGridFrame() ;
else {
// nRefId può essere un gruppo o una entità
if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) &&
! pGeomDB->GetGlobFrame( nRefId, frDest))
return false ;
}
// eseguo la trasformazione
return frF.LocToLoc( frSou, frDest) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtStartPoint( int nId, double ptP[3])
{
// recupero il punto
Point3d ptStart ;
if ( ! EgtStartPoint( nId, ptStart))
if ( ! EgtStartPoint( nId, nId, ptStart))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptStart)
@@ -41,7 +125,7 @@ __stdcall EgtStartPoint( int nId, double ptP[3])
//----------------------------------------------------------------------------
bool
__stdcall EgtStartPoint( int nId, Point3d& ptP)
__stdcall EgtStartPoint( int nId, int nRefId, Point3d& ptP)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
@@ -55,7 +139,6 @@ __stdcall EgtStartPoint( int nId, Point3d& ptP)
const IGeoPoint3d* pGP = GetGeoPoint3d( pGObj) ;
// assegno il punto
ptP = pGP->GetPoint() ;
return true ;
}
// se vettore
else if ( pGObj->GetType() == GEO_VECT3D) {
@@ -63,7 +146,6 @@ __stdcall EgtStartPoint( int nId, Point3d& ptP)
const IGeoVector3d* pGV = GetGeoVector3d( pGObj) ;
// assegno il punto
ptP = pGV->GetBase() ;
return true ;
}
// se frame
else if ( pGObj->GetType() == GEO_FRAME3D) {
@@ -71,23 +153,27 @@ __stdcall EgtStartPoint( int nId, Point3d& ptP)
const IGeoFrame3d* pGF = GetGeoFrame3d( pGObj) ;
// assegno il punto
ptP = pGF->GetFrame().Orig() ;
return true ;
}
// se curva
else if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
// recupero la curva
const ICurve* pCrv = GetCurve( pGObj) ;
// assegno il punto
return pCrv->GetStartPoint( ptP) ;
if ( pCrv == nullptr || ! pCrv->GetStartPoint( ptP))
return false ;
}
// se testo
else if ( pGObj->GetType() == EXT_TEXT) {
// recupero il testo
const IExtText* pTxt = GetExtText( pGObj) ;
// assegno il punto
return pTxt->GetStartPoint( ptP) ;
if ( pTxt == nullptr || ! pTxt->GetStartPoint( ptP))
return false ;
}
return false ;
else
return false ;
// gestione trasformazione ( eventuale)
return TrasformPoint( pGeomDB, nId, nRefId, ptP) ;
}
//----------------------------------------------------------------------------
@@ -96,7 +182,7 @@ __stdcall EgtEndPoint( int nId, double ptP[3])
{
// recupero il punto
Point3d ptEnd ;
if ( ! EgtEndPoint( nId, ptEnd))
if ( ! EgtEndPoint( nId, nId, ptEnd))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptEnd)
@@ -105,7 +191,7 @@ __stdcall EgtEndPoint( int nId, double ptP[3])
//----------------------------------------------------------------------------
bool
__stdcall EgtEndPoint( int nId, Point3d& ptP)
__stdcall EgtEndPoint( int nId, int nRefId, Point3d& ptP)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
@@ -117,15 +203,20 @@ __stdcall EgtEndPoint( int nId, Point3d& ptP)
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
// recupero la curva
const ICurve* pCrv = GetCurve( pGObj) ;
return pCrv->GetEndPoint( ptP) ;
if ( pCrv == nullptr || ! pCrv->GetEndPoint( ptP))
return false ;
}
// se testo
else if ( pGObj->GetType() == EXT_TEXT) {
// recupero il testo
const IExtText* pTxt = GetExtText( pGObj) ;
return pTxt->GetEndPoint( ptP) ;
if ( pTxt == nullptr || ! pTxt->GetEndPoint( ptP))
return false ;
}
return false ;
else
return false ;
// gestione trasformazione ( eventuale)
return TrasformPoint( pGeomDB, nId, nRefId, ptP) ;
}
//----------------------------------------------------------------------------
@@ -134,7 +225,7 @@ __stdcall EgtMidPoint( int nId, double ptP[3])
{
// recupero il punto
Point3d ptMid ;
if ( ! EgtMidPoint( nId, ptMid))
if ( ! EgtMidPoint( nId, nId, ptMid))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptMid)
@@ -143,7 +234,7 @@ __stdcall EgtMidPoint( int nId, double ptP[3])
//----------------------------------------------------------------------------
bool
__stdcall EgtMidPoint( int nId, Point3d& ptP)
__stdcall EgtMidPoint( int nId, int nRefId, Point3d& ptP)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
@@ -156,16 +247,21 @@ __stdcall EgtMidPoint( int nId, Point3d& ptP)
// recupero la curva
const ICurve* pCrv = GetCurve( pGObj) ;
// assegno il punto
return pCrv->GetMidPoint( ptP) ;
if ( pCrv == nullptr || ! pCrv->GetMidPoint( ptP))
return false ;
}
// se testo
else if ( pGObj->GetType() == EXT_TEXT) {
// recupero il testo
const IExtText* pTxt = GetExtText( pGObj) ;
// assegno il punto
return pTxt->GetMidPoint( ptP) ;
if ( pTxt == nullptr || ! pTxt->GetMidPoint( ptP))
return false ;
}
return false ;
else
return false ;
// gestione trasformazione ( eventuale)
return TrasformPoint( pGeomDB, nId, nRefId, ptP) ;
}
//----------------------------------------------------------------------------
@@ -174,7 +270,7 @@ __stdcall EgtCenterPoint( int nId, double ptP[3])
{
// recupero il punto
Point3d ptCent ;
if ( ! EgtCenterPoint( nId, ptCent))
if ( ! EgtCenterPoint( nId, nId, ptCent))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptCent)
@@ -183,7 +279,7 @@ __stdcall EgtCenterPoint( int nId, double ptP[3])
//----------------------------------------------------------------------------
bool
__stdcall EgtCenterPoint( int nId, Point3d& ptP)
__stdcall EgtCenterPoint( int nId, int nRefId, Point3d& ptP)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
@@ -196,16 +292,21 @@ __stdcall EgtCenterPoint( int nId, Point3d& ptP)
// recupero la curva
const ICurve* pCrv = GetCurve( pGObj) ;
// assegno il punto
return pCrv->GetCenterPoint( ptP) ;
if ( pCrv == nullptr || ! pCrv->GetCenterPoint( ptP))
return false ;
}
// se testo
else if ( pGObj->GetType() == EXT_TEXT) {
// recupero il testo
const IExtText* pTxt = GetExtText( pGObj) ;
// assegno il punto
return pTxt->GetCenterPoint( ptP) ;
if ( pTxt == nullptr || ! pTxt->GetCenterPoint( ptP))
return false ;
}
return false ;
else
return false ;
// gestione trasformazione ( eventuale)
return TrasformPoint( pGeomDB, nId, nRefId, ptP) ;
}
//----------------------------------------------------------------------------
@@ -214,7 +315,7 @@ __stdcall EgtAtParamPoint( int nId, double dU, double ptP[3])
{
// recupero il punto
Point3d ptAtPar ;
if ( ! EgtAtParamPoint( nId, dU, ptAtPar))
if ( ! EgtAtParamPoint( nId, dU, nId, ptAtPar))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptAtPar)
@@ -223,7 +324,7 @@ __stdcall EgtAtParamPoint( int nId, double dU, double ptP[3])
//----------------------------------------------------------------------------
bool
__stdcall EgtAtParamPoint( int nId, double dU, Point3d& ptP)
__stdcall EgtAtParamPoint( int nId, double dU, int nRefId, Point3d& ptP)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
@@ -235,18 +336,22 @@ __stdcall EgtAtParamPoint( int nId, double dU, Point3d& ptP)
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
// recupero la curva
const ICurve* pCrv = GetCurve( pGObj) ;
return pCrv->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP) ;
if ( pCrv == nullptr || ! pCrv->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP))
return false ;
}
return false ;
else
return false ;
// gestione trasformazione ( eventuale)
return TrasformPoint( pGeomDB, nId, nRefId, ptP) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtIntersectionPoint( int nId1, int nId2, const double ptNear[3], double ptP[3])
__stdcall EgtNearPoint( int nId, const double ptNear[3], double ptP[3])
{
// recupero il punto
Point3d ptInt ;
if ( ! EgtIntersectionPoint( nId1, nId2, ptNear, ptInt))
if ( ! EgtNearPoint( nId, ptNear, nId, ptInt))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptInt)
@@ -255,7 +360,46 @@ __stdcall EgtIntersectionPoint( int nId1, int nId2, const double ptNear[3], doub
//----------------------------------------------------------------------------
bool
__stdcall EgtIntersectionPoint( int nId1, int nId2, const Point3d& ptNear, Point3d& ptP)
__stdcall EgtNearPoint( int nId, const Point3d& ptNear, int nRefId, Point3d& ptP)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// se non è entità geometrica
const IGeoObj* pGObj = pGeomDB->GetGeoObj( nId) ;
if ( pGObj == nullptr)
return false ;
// se curva
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
// recupero la curva
const ICurve* pCrv = GetCurve( pGObj) ;
// calcolo il punto della curva più vicino al punto di riferimento
DistPointCurve dstPC( ptNear, *pCrv) ;
int nFlag ;
if ( ! dstPC.GetMinDistPoint( 0, ptP, nFlag))
return false ;
}
else
return false ;
// gestione trasformazione ( eventuale)
return TrasformPoint( pGeomDB, nId, nRefId, ptP) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtIntersectionPoint( int nId1, int nId2, const double ptNear[3], double ptP[3])
{
// recupero il punto
Point3d ptInt ;
if ( ! EgtIntersectionPoint( nId1, nId2, ptNear, nId1, ptInt))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptInt)
return TRUE ;
}
//----------------------------------------------------------------------------
bool
__stdcall EgtIntersectionPoint( int nId1, int nId2, const Point3d& ptNear, int nRefId, Point3d& ptP)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
@@ -292,9 +436,13 @@ __stdcall EgtIntersectionPoint( int nId1, int nId2, const Point3d& ptNear, Point
ptNearLoc.ToLoc( frEnt1) ;
// calcolo il punto di intersezione sulla prima curva più vicino al punto di riferimento
IntersCurveCurve intCC( *pCrv1, *pCrv2, true) ;
return intCC.GetIntersPointNearTo( 0, ptNearLoc, ptP) ;
if ( ! intCC.GetIntersPointNearTo( 0, ptNearLoc, ptP))
return false ;
}
return false ;
else
return false ;
// gestione trasformazione ( eventuale)
return TrasformPoint( pGeomDB, nId1, nRefId, ptP) ;
}
//----------------------------------------------------------------------------
@@ -303,7 +451,7 @@ __stdcall EgtStartVector( int nId, double vtV[3])
{
// recupero il vettore
Vector3d vtStart ;
if ( ! EgtStartVector( nId, vtStart))
if ( ! EgtStartVector( nId, nId, vtStart))
return FALSE ;
// ritorno il vettore
VEC_FROM_3D( vtV, vtStart)
@@ -312,13 +460,13 @@ __stdcall EgtStartVector( int nId, double vtV[3])
//----------------------------------------------------------------------------
bool
__stdcall EgtStartVector( int nId, Vector3d& vtV)
__stdcall EgtStartVector( int nId, int nRefId, Vector3d& vtV)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// se non è entità geometrica
const IGeoObj* pGObj ;
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
const IGeoObj* pGObj = pGeomDB->GetGeoObj( nId) ;
if ( pGObj == nullptr)
return false ;
// se vettore
if ( pGObj->GetType() == GEO_VECT3D) {
@@ -326,14 +474,14 @@ __stdcall EgtStartVector( int nId, Vector3d& vtV)
const IGeoVector3d* pGV = GetGeoVector3d( pGObj) ;
// assegno il vettore
vtV = pGV->GetVector() ;
return true ;
}
// se curva
else if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
// recupero la curva
const ICurve* pCrv = GetCurve( pGObj) ;
// assegno il vettore
return pCrv->GetStartDir( vtV) ;
if ( ! pCrv->GetStartDir( vtV))
return false ;
}
// se testo
else if ( pGObj->GetType() == EXT_TEXT) {
@@ -341,9 +489,11 @@ __stdcall EgtStartVector( int nId, Vector3d& vtV)
const IExtText* pTxt = GetExtText( pGObj) ;
// assegno il vettore
vtV = pTxt->GetDirVersor() ;
return true ;
}
return false ;
else
return false ;
// gestione trasformazione ( eventuale)
return TrasformVector( pGeomDB, nId, nRefId, vtV) ;
}
//----------------------------------------------------------------------------
@@ -352,7 +502,7 @@ __stdcall EgtEndVector( int nId, double vtV[3])
{
// recupero il vettore
Vector3d vtEnd ;
if ( ! EgtEndVector( nId, vtEnd))
if ( ! EgtEndVector( nId, nId, vtEnd))
return FALSE ;
// ritorno il vettore
VEC_FROM_3D( vtV, vtEnd)
@@ -361,22 +511,26 @@ __stdcall EgtEndVector( int nId, double vtV[3])
//----------------------------------------------------------------------------
bool
__stdcall EgtEndVector( int nId, Vector3d& vtV)
__stdcall EgtEndVector( int nId, int nRefId, Vector3d& vtV)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// se non è entità geometrica
const IGeoObj* pGObj ;
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
const IGeoObj* pGObj = pGeomDB->GetGeoObj( nId) ;
if ( pGObj == nullptr)
return false ;
// se curva
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
// recupero la curva
const ICurve* pCrv = GetCurve( pGObj) ;
// assegno il vettore
return pCrv->GetEndDir( vtV) ;
if ( ! pCrv->GetEndDir( vtV))
return false ;
}
return false ;
else
return false ;
// gestione trasformazione ( eventuale)
return TrasformVector( pGeomDB, nId, nRefId, vtV) ;
}
//----------------------------------------------------------------------------
@@ -385,7 +539,7 @@ __stdcall EgtMidVector( int nId, double vtV[3])
{
// recupero il vettore
Vector3d vtMid ;
if ( ! EgtMidVector( nId, vtMid))
if ( ! EgtMidVector( nId, nId, vtMid))
return FALSE ;
// ritorno il vettore
VEC_FROM_3D( vtV, vtMid)
@@ -394,7 +548,7 @@ __stdcall EgtMidVector( int nId, double vtV[3])
//----------------------------------------------------------------------------
bool
__stdcall EgtMidVector( int nId, Vector3d& vtV)
__stdcall EgtMidVector( int nId, int nRefId, Vector3d& vtV)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
@@ -407,9 +561,13 @@ __stdcall EgtMidVector( int nId, Vector3d& vtV)
// recupero la curva
const ICurve* pCrv = GetCurve( pGObj) ;
// assegno il vettore
return pCrv->GetMidDir( vtV) ;
if ( ! pCrv->GetMidDir( vtV))
return false ;
}
return false ;
else
return false ;
// gestione trasformazione ( eventuale)
return TrasformVector( pGeomDB, nId, nRefId, vtV) ;
}
//----------------------------------------------------------------------------
@@ -418,7 +576,7 @@ __stdcall EgtAtParamVector( int nId, double dU, int nSide, double vtV[3])
{
// recupero il vettore
Vector3d vtAtPar ;
if ( ! EgtAtParamVector( nId, dU, nSide, vtAtPar))
if ( ! EgtAtParamVector( nId, dU, nSide, nId, vtAtPar))
return FALSE ;
// ritorno il vettore
VEC_FROM_3D( vtV, vtAtPar)
@@ -427,7 +585,7 @@ __stdcall EgtAtParamVector( int nId, double dU, int nSide, double vtV[3])
//----------------------------------------------------------------------------
bool
__stdcall EgtAtParamVector( int nId, double dU, int nSide, Vector3d& vtV)
__stdcall EgtAtParamVector( int nId, double dU, int nSide, int nRefId, Vector3d& vtV)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
@@ -445,9 +603,13 @@ __stdcall EgtAtParamVector( int nId, double dU, int nSide, Vector3d& vtV)
nSide = ICurve::FROM_PLUS ;
// recupero la direzione
Point3d ptP ;
return pCrv->GetPointTang( dU, nSide, ptP, vtV) ;
if ( ! pCrv->GetPointTang( dU, nSide, ptP, vtV))
return false ;
}
return false ;
else
return false ;
// gestione trasformazione ( eventuale)
return TrasformVector( pGeomDB, nId, nRefId, vtV) ;
}
//----------------------------------------------------------------------------
@@ -456,7 +618,7 @@ __stdcall EgtFrame( int nId, double ptOrig[3], double vtX[3], double vtY[3], dou
{
// recupero il frame
Frame3d frFrame ;
if ( ! EgtFrame( nId, frFrame))
if ( ! EgtFrame( nId, nId, frFrame))
return FALSE ;
// assegno l'origine
VEC_FROM_3D( ptOrig, frFrame.Orig())
@@ -471,21 +633,23 @@ __stdcall EgtFrame( int nId, double ptOrig[3], double vtX[3], double vtY[3], dou
//----------------------------------------------------------------------------
bool
__stdcall EgtFrame( int nId, Frame3d& frFrame)
__stdcall EgtFrame( int nId, int nRefId, Frame3d& frFrame)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// se gruppo
if ( pGeomDB->GetGroupFrame( nId, frFrame))
return true ;
// gestione trasformazione ( eventuale)
return TrasformFrame( pGeomDB, nId, nRefId, frFrame) ;
// se geo frame
const IGeoObj* pGObj ;
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) != nullptr &&
pGObj->GetType() == GEO_FRAME3D) {
pGObj->GetType() == GEO_FRAME3D) {
frFrame = GetGeoFrame3d( pGObj)->GetFrame() ;
return true ;
// gestione trasformazione ( eventuale)
return TrasformFrame( pGeomDB, nId, nRefId, frFrame) ;
}
// altrimenti errore
// errore
return false ;
}
@@ -534,7 +698,7 @@ __stdcall EgtCurveExtrusion( int nId, double vtExtr[3])
{
// recupero il vettore estrusione
Vector3d vtTmp ;
if ( ! EgtCurveExtrusion( nId, vtTmp))
if ( ! EgtCurveExtrusion( nId, nId, vtTmp))
return FALSE ;
// lo assegno
VEC_FROM_3D( vtExtr, vtTmp)
@@ -543,16 +707,17 @@ __stdcall EgtCurveExtrusion( int nId, double vtExtr[3])
//----------------------------------------------------------------------------
bool
__stdcall EgtCurveExtrusion( int nId, Vector3d& vtExtr)
__stdcall EgtCurveExtrusion( int nId, int nRefId, Vector3d& vtExtr)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero la curva
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCurve == nullptr)
return false ;
// ne ricavo il vettore estrusione
return pCurve->GetExtrusion( vtExtr) ;
if ( pCurve == nullptr || ! pCurve->GetExtrusion( vtExtr))
return false ;
// gestione trasformazione ( eventuale)
return TrasformVector( pGeomDB, nId, nRefId, vtExtr) ;
}
//----------------------------------------------------------------------------
@@ -625,7 +790,7 @@ __stdcall EgtCurveArcNormVersor( int nId, double vtNorm[3])
{
// recupero il vettore normale
Vector3d vtTmp ;
if ( ! EgtCurveArcNormVersor( nId, vtTmp))
if ( ! EgtCurveArcNormVersor( nId, nId, vtTmp))
return FALSE ;
// lo assegno
VEC_FROM_3D( vtNorm, vtTmp)
@@ -634,7 +799,7 @@ __stdcall EgtCurveArcNormVersor( int nId, double vtNorm[3])
//----------------------------------------------------------------------------
bool
__stdcall EgtCurveArcNormVersor( int nId, Vector3d& vtNorm)
__stdcall EgtCurveArcNormVersor( int nId, int nRefId, Vector3d& vtNorm)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
@@ -644,7 +809,8 @@ __stdcall EgtCurveArcNormVersor( int nId, Vector3d& vtNorm)
return false ;
// recupero la normale
vtNorm = pArc->GetNormVersor() ;
return true ;
// gestione trasformazione ( eventuale)
return TrasformVector( pGeomDB, nId, nRefId, vtNorm) ;
}
//----------------------------------------------------------------------------
@@ -653,7 +819,7 @@ __stdcall EgtExtTextNormVersor( int nId, double vtNorm[3])
{
// recupero il vettore normale
Vector3d vtTmp ;
if ( ! EgtExtTextNormVersor( nId, vtTmp))
if ( ! EgtExtTextNormVersor( nId, nId, vtTmp))
return FALSE ;
// lo assegno
VEC_FROM_3D( vtNorm, vtTmp)
@@ -662,7 +828,7 @@ __stdcall EgtExtTextNormVersor( int nId, double vtNorm[3])
//----------------------------------------------------------------------------
bool
__stdcall EgtExtTextNormVersor( int nId, Vector3d& vtNorm)
__stdcall EgtExtTextNormVersor( int nId, int nRefId, Vector3d& vtNorm)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
@@ -672,7 +838,8 @@ __stdcall EgtExtTextNormVersor( int nId, Vector3d& vtNorm)
return false ;
// recupero la normale
vtNorm = pTxt->GetNormVersor() ;
return true ;
// gestione trasformazione ( eventuale)
return TrasformVector( pGeomDB, nId, nRefId, vtNorm) ;
}
+20
View File
@@ -134,6 +134,26 @@ __stdcall EgtGetGridFrame( Frame3d& frFrame)
return true ;
}
//-----------------------------------------------------------------------------
bool
__stdcall EgtGetGridVersZ( int nRefId, Vector3d& vtVersZ)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero il versore Z della griglia
vtVersZ = pGeomDB->GetGridFrame().VersZ() ;
// se richiesto nel riferimento globale, esco subito
if ( nRefId == GDB_ID_ROOT)
return true ;
// recupero il riferimento destinazione (nRefId può essere un gruppo o una entità)
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) &&
! pGeomDB->GetGlobFrame( nRefId, frDest))
return false ;
// eseguo la trasformazione
return vtVersZ.ToLoc( frDest) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtNewFile( void)
BIN
View File
Binary file not shown.
+2 -1
View File
@@ -230,13 +230,14 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="EInDllMain.cpp" />
<ClCompile Include="GseContext.cpp" />
<ClCompile Include="LUA_Aux.cpp" />
<ClCompile Include="LUA_CurveModif.cpp" />
<ClCompile Include="LUA_GdbModifyCurve.cpp" />
<ClCompile Include="LUA_Exchange.cpp" />
<ClCompile Include="LUA_GdbModify.cpp" />
<ClCompile Include="LUA_GdbObjAttribs.cpp" />
<ClCompile Include="LUA_GdbObjects.cpp" />
<ClCompile Include="LUA_General.cpp" />
<ClCompile Include="LUA_GdbCreate.cpp" />
<ClCompile Include="LUA_GeoBase.cpp" />
<ClCompile Include="LUA_GeomDB.cpp" />
<ClCompile Include="LUA_GeoSnap.cpp" />
<ClCompile Include="LUA_GeoTransform.cpp" />
+100 -88
View File
@@ -13,6 +13,15 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="File di origine\API">
<UniqueIdentifier>{77e59e94-e3d5-4510-8bcb-d1360cf74848}</UniqueIdentifier>
</Filter>
<Filter Include="File di origine\LUA">
<UniqueIdentifier>{8d45f54c-e32b-4568-a8c6-6d9074ed565f}</UniqueIdentifier>
</Filter>
<Filter Include="File di origine\General">
<UniqueIdentifier>{58650c7e-f303-498a-b85b-7bee0f52fa88}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
@@ -44,101 +53,104 @@
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="EInDllMain.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="API_General.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="GseContext.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="API_GeomDB.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="API_Scene.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="API_TscExec.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="API_GdbObjects.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="API_GdbObjAttribs.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="API_Exchange.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="LUA_General.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="API_LUA.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="LUA_GeomDB.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="LUA_Aux.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="LUA_Exchange.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="LUA_Scene.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="LUA_GeoTransform.cpp">
<Filter>File di origine</Filter>
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="API_GdbCreate.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="LUA_GdbCreate.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="API_GeoTransform.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="LUA_GdbObjAttribs.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="LUA_GdbObjects.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="API_GeoSnap.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="LUA_GeoSnap.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="LUA_CurveModif.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="API_GdbModify.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="LUA_GdbModify.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="API_GdbObjSelection.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="API_GeoBase.cpp">
<Filter>File di origine</Filter>
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="API_GdbCreateCurve.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="API_GdbModifyCurve.cpp">
<Filter>File di origine</Filter>
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="API_GdbCreateSurf.cpp">
<Filter>File di origine</Filter>
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="API_GdbModify.cpp">
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="API_GdbModifyCurve.cpp">
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="API_GdbObjAttribs.cpp">
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="API_GdbObjects.cpp">
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="API_GdbObjSelection.cpp">
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="API_General.cpp">
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="API_GeoBase.cpp">
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="API_GeomDB.cpp">
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="API_GeoSnap.cpp">
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="API_GeoTransform.cpp">
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="API_Lua.cpp">
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="API_Scene.cpp">
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="API_TscExec.cpp">
<Filter>File di origine\API</Filter>
</ClCompile>
<ClCompile Include="LUA_Aux.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
<ClCompile Include="LUA_Exchange.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
<ClCompile Include="LUA_GdbCreate.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
<ClCompile Include="LUA_GdbModify.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
<ClCompile Include="LUA_GdbObjAttribs.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
<ClCompile Include="LUA_GdbObjects.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
<ClCompile Include="LUA_General.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
<ClCompile Include="LUA_GeoBase.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
<ClCompile Include="LUA_GeomDB.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
<ClCompile Include="LUA_GeoSnap.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
<ClCompile Include="LUA_GeoTransform.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
<ClCompile Include="LUA_Scene.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
<ClCompile Include="EInDllMain.cpp">
<Filter>File di origine\General</Filter>
</ClCompile>
<ClCompile Include="GseContext.cpp">
<Filter>File di origine\General</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>File di origine\General</Filter>
</ClCompile>
<ClCompile Include="LUA_GdbModifyCurve.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
+6 -3
View File
@@ -57,6 +57,9 @@ bool LuaSetReturn( lua_State* L, const Point3d& ptPar) ;
bool LuaSetReturn( lua_State* L, const Frame3d& frPar) ;
bool LuaSetReturn( lua_State* L, const Color& colPar) ;
//-------------------------- GeoBase -----------------------------------------
bool LuaInstallGeoBase( lua_State* L) ;
//-------------------------- GeomDB ------------------------------------------
bool LuaInstallGeomDB( lua_State* L) ;
@@ -66,15 +69,15 @@ bool LuaInstallGdbCreate( lua_State* L) ;
//-------------------------- GdbModify ---------------------------------------
bool LuaInstallGdbModify( lua_State* L) ;
//-------------------------- GdbModifyCurve ----------------------------------
bool LuaInstallGdbModifyCurve( lua_State* L) ;
//-------------------------- GdbObjects --------------------------------------
bool LuaInstallGdbObjects( lua_State* L) ;
//-------------------------- GdbObjAttribs -----------------------------------
bool LuaInstallGdbObjAttribs( lua_State* L) ;
//-------------------------- CurveModif --------------------------------------
bool LuaInstallCurveModif( lua_State* L) ;
//-------------------------- GeoSnap -----------------------------------------
bool LuaInstallGeoSnap( lua_State* L) ;
+43 -7
View File
@@ -31,7 +31,8 @@ LuaCreateGroup( lua_State* L)
int nParentId ;
LuaCheckParam( L, 1, nParentId)
Frame3d frFrame ;
LuaGetParam( L, 2, frFrame) ;
if ( lua_gettop( L) >= 2)
LuaCheckParam( L, 2, frFrame) ;
LuaClearStack( L) ;
// creo il gruppo
int nId = EgtCreateGroup( nParentId, frFrame.Orig().v,
@@ -74,9 +75,11 @@ LuaCreateGeoVector( lua_State* L)
Vector3d vtV ;
LuaCheckParam( L, 2, vtV)
Point3d ptB ;
LuaGetParam( L, 3, ptB) ;
if ( lua_gettop( L) >= 3)
LuaCheckParam( L, 3, ptB) ;
double dScale = 1 ;
LuaGetParam( L, 4, dScale) ;
if ( lua_gettop( L) >= 4)
LuaCheckParam( L, 4, dScale) ;
LuaClearStack( L) ;
// creo il segmento di retta
vtV *= dScale ;
@@ -144,7 +147,8 @@ LuaCreateCurveLineMinPointCurve( lua_State* L)
int nCrvId ;
LuaCheckParam( L, 3, nCrvId)
double dNearPar = 0 ;
LuaGetParam( L, 4, dNearPar) ;
if ( lua_gettop( L) >= 4)
LuaCheckParam( L, 4, dNearPar) ;
LuaClearStack( L) ;
// creo il segmento di retta
int nId = EgtCreateCurveLineMinPointCurve( nParentId, ptIni.v, nCrvId, dNearPar) ;
@@ -368,7 +372,8 @@ LuaCreateCurveBezierFromArc( lua_State* L)
int nArcId ;
LuaCheckParam( L, 2, nArcId)
bool bErase = true ;
LuaGetParam( L, 3, bErase) ;
if ( lua_gettop( L) >= 3)
LuaCheckParam( L, 3, bErase) ;
LuaClearStack( L) ;
// creo la curva
int nId = EgtCreateCurveBezierFromArc( nParentId, nArcId, bErase) ;
@@ -390,7 +395,8 @@ LuaCreateCurveCompo( lua_State* L)
INTVECTOR vIds ;
LuaCheckParam( L, 2, vIds)
bool bErase = true ;
LuaGetParam( L, 3, bErase) ;
if ( lua_gettop( L) >= 3)
LuaCheckParam( L, 3, bErase) ;
LuaClearStack( L) ;
// creo la curva composita
int nId = EgtCreateCurveCompo( nParentId, vIds, ( bErase ? TRUE : FALSE)) ;
@@ -448,6 +454,34 @@ LuaCreateCurveCompoFromPointBulges( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateCurveCompoFromCurveApprox( lua_State* L)
{
// 4 parametri : ParentId, nSouId, sType, dLinTol
int nParentId ;
LuaCheckParam( L, 1, nParentId)
int nSouId ;
LuaCheckParam( L, 2, nSouId)
bool bArcsVsLines = true ;
string sTemp ;
LuaCheckParam( L, 3, sTemp)
ToUpper( sTemp) ;
if ( sTemp == "LINES")
bArcsVsLines = false ;
double dLinTol ;
LuaCheckParam( L, 4, dLinTol)
LuaClearStack( L) ;
// creo la curva composita
int nId = EgtCreateCurveCompoFromCurveApprox( nParentId, nSouId, bArcsVsLines, dLinTol) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateCurveCompoFromPolygonSide( lua_State* L)
@@ -482,7 +516,8 @@ LuaCreateSurfTriMeshByContour( lua_State* L)
int nCrvId ;
LuaCheckParam( L, 2, nCrvId)
double dLinTol = 0.1 ;
LuaGetParam( L, 3, dLinTol) ;
if ( lua_gettop( L) >= 3)
LuaCheckParam( L, 3, dLinTol) ;
LuaClearStack( L) ;
// creo STM riempiendo un contorno piano
int nId = EgtCreateSurfTriMeshByContour( nParentId, nCrvId, dLinTol) ;
@@ -604,6 +639,7 @@ LuaInstallGdbCreate( lua_State* L)
lua_register( L, "EgtCurveCompo", LuaCreateCurveCompo) ;
lua_register( L, "EgtCurveCompoFromPoints", LuaCreateCurveCompoFromPoints) ;
lua_register( L, "EgtCurveCompoFromPointBulges", LuaCreateCurveCompoFromPointBulges) ;
lua_register( L, "EgtCurveCompoFromCurveApprox", LuaCreateCurveCompoFromCurveApprox) ;
lua_register( L, "EgtCurveCompoFromPolygonSide", LuaCreateCurveCompoFromPolygonSide) ;
lua_register( L, "EgtSurfTmByContour", LuaCreateSurfTriMeshByContour) ;
lua_register( L, "EgtText", LuaCreateText) ;
+10 -28
View File
@@ -33,25 +33,7 @@ LuaChangeVectorBase( lua_State* L)
LuaCheckParam( L, 2, ptBase)
LuaClearStack( L) ;
// modifica del testo
bool bOk = ( EgtChangeVectorBase( nId, ptBase.v) ? true : false) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaOffsetCurve( lua_State* L)
{
// 4 parametri : Id, dDist, nType
int nId ;
LuaCheckParam( L, 1, nId)
double dDist ;
LuaCheckParam( L, 2, dDist)
int nType ;
LuaCheckParam( L, 3, nType)
LuaClearStack( L) ;
// offset della curva
bool bOk = ( EgtOffsetCurve( nId, dDist, nType) ? true : false) ;
bool bOk = ( EgtChangeVectorBase( nId, ptBase.v) != FALSE) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
@@ -67,7 +49,7 @@ LuaModifyText( lua_State* L)
LuaCheckParam( L, 2, sNewText)
LuaClearStack( L) ;
// modifica del testo
bool bOk = ( EgtModifyText( nId, sNewText) ? true : false) ;
bool bOk = ( EgtModifyText( nId, sNewText) != FALSE) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
@@ -83,7 +65,7 @@ LuaChangeTextFont( lua_State* L)
LuaCheckParam( L, 2, sNewFont)
LuaClearStack( L) ;
// modifica del testo
bool bOk = ( EgtChangeTextFont( nId, sNewFont) ? true : false) ;
bool bOk = ( EgtChangeTextFont( nId, sNewFont) != FALSE) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
@@ -97,7 +79,7 @@ LuaFlipText( lua_State* L)
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// flip del testo
bool bOk = ( EgtFlipText( nId) ? true : false) ;
bool bOk = ( EgtFlipText( nId) != FALSE) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
@@ -110,15 +92,16 @@ LuaMirrorText( lua_State* L)
int nId ;
LuaCheckParam( L, 1, nId)
bool bOnL = true ;
string sLorH ;
if ( LuaGetParam( L, 2, sLorH)) {
if ( lua_gettop( L) >= 2) {
string sLorH ;
LuaCheckParam( L, 2, sLorH) ;
ToUpper( sLorH) ;
if ( sLorH == "H")
bOnL = false ;
}
LuaClearStack( L) ;
// flip del testo
bool bOk = ( EgtMirrorText( nId, bOnL) ? true : false) ;
bool bOk = ( EgtMirrorText( nId, bOnL) != FALSE) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
@@ -134,7 +117,7 @@ LuaTextToOutline( lua_State* L)
LuaCheckParam( L, 2, nIdGroupDest)
LuaClearStack( L) ;
// esplosione del testo in outline
bool bOk = ( EgtTextToOutline( nId, nIdGroupDest) ? true : false) ;
bool bOk = ( EgtTextToOutline( nId, nIdGroupDest) != FALSE) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
@@ -150,7 +133,7 @@ LuaSplitText( lua_State* L)
LuaCheckParam( L, 2, nIdGroupDest)
LuaClearStack( L) ;
// esplosione del testo in più testi, uno per riga
bool bOk = ( EgtSplitText( nId, nIdGroupDest) ? true : false) ;
bool bOk = ( EgtSplitText( nId, nIdGroupDest) != FALSE) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
@@ -162,7 +145,6 @@ LuaInstallGdbModify( lua_State* L)
{
try {
lua_register( L, "EgtChangeVectorBase", LuaChangeVectorBase) ;
lua_register( L, "EgtOffsetCurve", LuaOffsetCurve) ;
lua_register( L, "EgtModifyText", LuaModifyText) ;
lua_register( L, "EgtChangeTextFont", LuaChangeTextFont) ;
lua_register( L, "EgtFlipText", LuaFlipText) ;
+46 -2
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : LUA_CurveModif.cpp Data : 03.10.14 Versione : 1.5i5
// File : LUA_GdbModifyCurve.cpp Data : 28.12.14 Versione : 1.5l2
// Contenuto : Funzioni di modifica delle curve per LUA.
//
//
@@ -16,6 +16,7 @@
#include "LUA.h"
#include "API.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EGkCurve.h"
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
using namespace std ;
@@ -35,6 +36,31 @@ LuaInvertCurve( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaOffsetCurve( lua_State* L)
{
// 3 parametri : Id, dDist, nType
int nId ;
LuaCheckParam( L, 1, nId)
double dDist ;
LuaCheckParam( L, 2, dDist)
int nType = ICurve::OFF_FILLET ;
if ( lua_gettop( L) >= 3) {
string sType ;
LuaCheckParam( L, 3, sType)
if ( sType == "CHAMFER")
nType = ICurve::OFF_CHAMFER ;
else if ( sType == "EXTEND")
nType = ICurve::OFF_EXTEND ;
}
LuaClearStack( L) ;
// offset della curva
bool bOk = ( EgtOffsetCurve( nId, dDist, nType) != FALSE) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaModifyCurveStartPoint( lua_State* L)
@@ -191,12 +217,29 @@ LuaTrimCurveStartEndAtParam( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaModifyCurveArcRadius( lua_State* L)
{
// 2 parametri : Id, dNewRad
int nId ;
LuaCheckParam( L, 1, nId)
double dNewRad ;
LuaCheckParam( L, 2, dNewRad)
LuaClearStack( L) ;
// modifica del raggio
bool bOk = ( EgtModifyCurveArcRadius( nId, dNewRad) != FALSE) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallCurveModif( lua_State* L)
LuaInstallGdbModifyCurve( lua_State* L)
{
try {
lua_register( L, "EgtInvertCurve", LuaInvertCurve) ;
lua_register( L, "EgtOffsetCurve", LuaOffsetCurve) ;
lua_register( L, "EgtModifyCurveStartPoint", LuaModifyCurveStartPoint) ;
lua_register( L, "EgtModifyCurveEndPoint", LuaModifyCurveEndPoint) ;
lua_register( L, "EgtModifyCurveExtrusion", LuaModifyCurveExtrusion) ;
@@ -206,6 +249,7 @@ LuaInstallCurveModif( lua_State* L)
lua_register( L, "EgtTrimCurveStartAtParam", LuaTrimCurveStartAtParam) ;
lua_register( L, "EgtTrimCurveEndAtParam", LuaTrimCurveEndAtParam) ;
lua_register( L, "EgtTrimCurveStartEndAtParam", LuaTrimCurveStartEndAtParam) ;
lua_register( L, "EgtModifyCurveArcRadius", LuaModifyCurveArcRadius) ;
}
catch ( ...) {
return false ;
+26 -26
View File
@@ -38,7 +38,7 @@ LuaSetLevel( lua_State* L)
nLevel = GDB_LV_TEMP ;
LuaClearStack( L) ;
// imposto lo stato
bool bOk = ( EgtSetLevel( nId, nLevel) ? true : false) ;
bool bOk = ( EgtSetLevel( nId, nLevel) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
@@ -53,7 +53,7 @@ LuaRevertLevel( lua_State* L)
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// porto il livello al valore precedente
bool bOk = ( EgtRevertLevel( nId) ? true : false) ;
bool bOk = ( EgtRevertLevel( nId) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
@@ -69,7 +69,7 @@ LuaGetLevel( lua_State* L)
LuaClearStack( L) ;
// recupero il livello
int nLevel ;
if ( EgtGetLevel( nId, &nLevel))
if ( EgtGetLevel( nId, &nLevel) != FALSE)
// restituisco il risultato
LuaSetReturn( L, nLevel) ;
else
@@ -87,7 +87,7 @@ LuaGetCalcLevel( lua_State* L)
LuaClearStack( L) ;
// recupero il livello
int nLevel ;
if ( EgtGetCalcLevel( nId, &nLevel))
if ( EgtGetCalcLevel( nId, &nLevel) != FALSE)
// restituisco il risultato
LuaSetReturn( L, nLevel) ;
else
@@ -112,7 +112,7 @@ LuaSetMode( lua_State* L)
nMode = GDB_MD_HIDDEN ;
LuaClearStack( L) ;
// imposto il modo
bool bOk = ( EgtSetMode( nId, nMode) ? true : false) ;
bool bOk = ( EgtSetMode( nId, nMode) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
@@ -127,7 +127,7 @@ LuaRevertMode( lua_State* L)
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// porto il modo al valore precedente
bool bOk = ( EgtRevertMode( nId) ? true : false) ;
bool bOk = ( EgtRevertMode( nId) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
@@ -143,7 +143,7 @@ LuaGetMode( lua_State* L)
LuaClearStack( L) ;
// recupero il modo
int nMode ;
if ( EgtGetMode( nId, &nMode))
if ( EgtGetMode( nId, &nMode) != FALSE)
// restituisco il risultato
LuaSetReturn( L, nMode) ;
else
@@ -161,7 +161,7 @@ LuaGetCalcMode( lua_State* L)
LuaClearStack( L) ;
// recupero il modo calcolato (ovvero proprio ed ereditato)
int nMode ;
if ( EgtGetCalcMode( nId, &nMode))
if ( EgtGetCalcMode( nId, &nMode) != FALSE)
// restituisco il risultato
LuaSetReturn( L, nMode) ;
else
@@ -186,7 +186,7 @@ LuaSetStatus( lua_State* L)
nStatus = GDB_ST_SEL ;
LuaClearStack( L) ;
// imposto lo stato
bool bOk = ( EgtSetStatus( nId, nStatus) ? true : false) ;
bool bOk = ( EgtSetStatus( nId, nStatus) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
@@ -201,7 +201,7 @@ LuaRevertStatus( lua_State* L)
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// porto lo stato al valore precedente
bool bOk = ( EgtRevertStatus( nId) ? true : false) ;
bool bOk = ( EgtRevertStatus( nId) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
@@ -217,7 +217,7 @@ LuaGetStatus( lua_State* L)
LuaClearStack( L) ;
// recupero lo stato
int nStatus ;
if ( EgtGetStatus( nId, &nStatus))
if ( EgtGetStatus( nId, &nStatus) != FALSE)
// restituisco il risultato
LuaSetReturn( L, nStatus) ;
else
@@ -235,7 +235,7 @@ LuaGetCalcStatus( lua_State* L)
LuaClearStack( L) ;
// recupero lo stato
int nStatus ;
if ( EgtGetCalcStatus( nId, &nStatus))
if ( EgtGetCalcStatus( nId, &nStatus) != FALSE)
// restituisco il risultato
LuaSetReturn( L, nStatus) ;
else
@@ -252,7 +252,7 @@ LuaSetMark( lua_State* L)
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// imposto l'evidenziazione
bool bOk = ( EgtSetMark( nId) ? true : false) ;
bool bOk = ( EgtSetMark( nId) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
@@ -267,7 +267,7 @@ LuaResetMark( lua_State* L)
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// cancello l'evidenziazione
bool bOk = ( EgtResetMark( nId) ? true : false) ;
bool bOk = ( EgtResetMark( nId) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
@@ -283,7 +283,7 @@ LuaGetMark( lua_State* L)
LuaClearStack( L) ;
// recupero lo stato di evidenziazione
BOOL nMark ;
if ( EgtGetMark( nId, &nMark))
if ( EgtGetMark( nId, &nMark) != FALSE)
// restituisco il risultato
LuaSetReturn( L, ( nMark != FALSE)) ;
else
@@ -301,7 +301,7 @@ LuaGetCalcMark( lua_State* L)
LuaClearStack( L) ;
// recupero lo stato calcolato di evidenziazione
BOOL nMark ;
if ( EgtGetCalcMark( nId, &nMark))
if ( EgtGetCalcMark( nId, &nMark) != FALSE)
// restituisco il risultato
LuaSetReturn( L, ( nMark != FALSE)) ;
else
@@ -319,7 +319,7 @@ LuaStdColor( lua_State* L)
LuaClearStack( L) ;
// recupero il colore con il nome indicato
Color cCol ;
if ( EgtStdColor( sName, cCol)) {
if ( GetStdColor( sName, cCol)) {
// restituisco il risultato
LuaSetReturn( L, cCol) ;
}
@@ -343,7 +343,7 @@ LuaSetColor( lua_State* L)
cCol.GetInt( vCol) ;
bool bOk = true ;
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
if ( ! EgtSetColor( vId[i], vCol))
if ( EgtSetColor( vId[i], vCol) == FALSE)
bOk = false ;
}
// restituisco il risultato
@@ -361,7 +361,7 @@ LuaGetColor( lua_State* L)
LuaClearStack( L) ;
// recupero il colore
int vCol[4] ;
if ( EgtGetColor( nId, vCol)) {
if ( EgtGetColor( nId, vCol) != FALSE) {
Color cCol( vCol) ;
// restituisco il risultato
LuaSetReturn( L, cCol) ;
@@ -381,7 +381,7 @@ LuaGetCalcColor( lua_State* L)
LuaClearStack( L) ;
// recupero il colore
int vCol[4] ;
if ( EgtGetCalcColor( nId, vCol)) {
if ( EgtGetCalcColor( nId, vCol) != FALSE) {
Color cCol( vCol) ;
// restituisco il risultato
LuaSetReturn( L, cCol) ;
@@ -402,7 +402,7 @@ LuaSetName( lua_State* L)
LuaCheckParam( L, 2, sName)
LuaClearStack( L) ;
// assegno il nome
bool bOk = ( EgtSetName( nId, sName) ? true : false) ;
bool bOk = EgtSetName( nId, sName) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
@@ -418,7 +418,7 @@ LuaGetName( lua_State* L)
LuaClearStack( L) ;
// recupero il nome
string sName ;
bool bOk = ( EgtGetName( nId, sName) ? true : false) ;
bool bOk = EgtGetName( nId, sName) ;
// restituisco il risultato
if ( bOk)
LuaSetReturn( L, sName) ;
@@ -436,7 +436,7 @@ LuaExistsName( lua_State* L)
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// verifico esistenza nome
bool bOk = ( EgtExistsName( nId) ? true : false) ;
bool bOk = ( EgtExistsName( nId) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
@@ -451,7 +451,7 @@ LuaRemoveName( lua_State* L)
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// verifico esistenza nome
bool bOk = ( EgtRemoveName( nId) ? true : false) ;
bool bOk = ( EgtRemoveName( nId) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
@@ -508,7 +508,7 @@ LuaExistsInfo( lua_State* L)
LuaCheckParam( L, 2, sKey)
LuaClearStack( L) ;
// verifico esistenza info
bool bOk = ( EgtExistsInfo( nId, sKey) ? true : false) ;
bool bOk = EgtExistsInfo( nId, sKey) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
@@ -525,7 +525,7 @@ LuaRemoveInfo( lua_State* L)
LuaCheckParam( L, 2, sKey)
LuaClearStack( L) ;
// rimuovo info
bool bOk = ( EgtRemoveInfo( nId, sKey) ? true : false) ;
bool bOk = EgtRemoveInfo( nId, sKey) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
+59 -13
View File
@@ -31,7 +31,7 @@ LuaExistsObj( lua_State* L)
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// verifico esistenza oggetto
bool bOk = ( EgtExistsObj( nId) ? true : false) ;
bool bOk = ( EgtExistsObj( nId) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
@@ -45,7 +45,7 @@ LuaGetGroupObjs( lua_State* L)
int nGroupId ;
LuaCheckParam( L, 1, nGroupId)
LuaClearStack( L) ;
// verifico esistenza oggetto
// determino il numero di oggetti nel gruppo
int nObjs = EgtGetGroupObjs( nGroupId) ;
// restituisco il risultato
LuaSetReturn( L, nObjs) ;
@@ -124,6 +124,46 @@ LuaGetPrev( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetFirstNameInGroup( lua_State* L)
{
// 2 parametri : GroupId, sName
int nGroupId ;
LuaCheckParam( L, 1, nGroupId)
string sName ;
LuaCheckParam( L, 2, sName)
LuaClearStack( L) ;
// recupero il primo oggetto del gruppo
int nId = EgtGetFirstNameInGroup( nGroupId, sName) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetNextName( lua_State* L)
{
// 2 parametri : Id, sName
int nId ;
LuaCheckParam( L, 1, nId)
string sName ;
LuaCheckParam( L, 2, sName)
LuaClearStack( L) ;
// recupero il prossimo oggetto nello stesso gruppo
int nNextId = EgtGetNextName( nId, sName) ;
// restituisco il risultato
if ( nNextId != GDB_ID_NULL)
LuaSetReturn( L, nNextId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCopy( lua_State* L)
@@ -134,8 +174,9 @@ LuaCopy( lua_State* L)
int nRefId ;
LuaCheckParam( L, 2, nRefId)
int nSonBeforeAfter = GDB_SON ;
string sSonBeforeAfter ;
if ( LuaGetParam( L, 3, sSonBeforeAfter)) {
if ( lua_gettop( L) >= 3) {
string sSonBeforeAfter ;
LuaCheckParam( L, 3, sSonBeforeAfter) ;
ToUpper( sSonBeforeAfter) ;
if ( sSonBeforeAfter == "BEFORE")
nSonBeforeAfter = GDB_BEFORE ;
@@ -163,8 +204,9 @@ LuaCopyGlob( lua_State* L)
int nRefId ;
LuaCheckParam( L, 2, nRefId)
int nSonBeforeAfter = GDB_SON ;
string sSonBeforeAfter ;
if ( LuaGetParam( L, 3, sSonBeforeAfter)) {
if ( lua_gettop( L) >= 3) {
string sSonBeforeAfter ;
LuaCheckParam( L, 3, sSonBeforeAfter) ;
ToUpper( sSonBeforeAfter) ;
if ( sSonBeforeAfter == "BEFORE")
nSonBeforeAfter = GDB_BEFORE ;
@@ -192,8 +234,9 @@ LuaRelocate( lua_State* L)
int nRefId ;
LuaCheckParam( L, 2, nRefId)
int nSonBeforeAfter = GDB_SON ;
string sSonBeforeAfter ;
if ( LuaGetParam( L, 3, sSonBeforeAfter)) {
if ( lua_gettop( L) >= 3) {
string sSonBeforeAfter ;
LuaCheckParam( L, 3, sSonBeforeAfter) ;
ToUpper( sSonBeforeAfter) ;
if ( sSonBeforeAfter == "BEFORE")
nSonBeforeAfter = GDB_BEFORE ;
@@ -202,7 +245,7 @@ LuaRelocate( lua_State* L)
}
LuaClearStack( L) ;
// eseguo la rilocazione
bool bOk = ( EgtRelocate( nSouId, nRefId, nSonBeforeAfter) ? true : false) ;
bool bOk = ( EgtRelocate( nSouId, nRefId, nSonBeforeAfter) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
@@ -218,8 +261,9 @@ LuaRelocateGlob( lua_State* L)
int nRefId ;
LuaCheckParam( L, 2, nRefId)
int nSonBeforeAfter = GDB_SON ;
string sSonBeforeAfter ;
if ( LuaGetParam( L, 3, sSonBeforeAfter)) {
if ( lua_gettop( L) >= 3) {
string sSonBeforeAfter ;
LuaCheckParam( L, 3, sSonBeforeAfter) ;
ToUpper( sSonBeforeAfter) ;
if ( sSonBeforeAfter == "BEFORE")
nSonBeforeAfter = GDB_BEFORE ;
@@ -228,7 +272,7 @@ LuaRelocateGlob( lua_State* L)
}
LuaClearStack( L) ;
// eseguo la rilocazione
bool bOk = ( EgtRelocateGlob( nSouId, nRefId, nSonBeforeAfter) ? true : false) ;
bool bOk = ( EgtRelocateGlob( nSouId, nRefId, nSonBeforeAfter) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
@@ -244,7 +288,7 @@ LuaErase( lua_State* L)
// eseguo la cancellazione
bool bOk = true ;
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
if ( ! EgtErase( vId[i]))
if ( EgtErase( vId[i]) == FALSE)
bOk = false ;
}
// restituisco il risultato
@@ -263,6 +307,8 @@ LuaInstallGdbObjects( lua_State* L)
lua_register( L, "EgtGetNext", LuaGetNext) ;
lua_register( L, "EgtGetLastInGroup", LuaGetLastInGroup) ;
lua_register( L, "EgtGetPrev", LuaGetPrev) ;
lua_register( L, "EgtGetFirstNameInGroup", LuaGetFirstNameInGroup) ;
lua_register( L, "EgtGetNextName", LuaGetNextName) ;
lua_register( L, "EgtCopy", LuaCopy) ;
lua_register( L, "EgtCopyGlob", LuaCopyGlob) ;
lua_register( L, "EgtRelocate", LuaRelocate) ;
+43 -4
View File
@@ -16,6 +16,7 @@
#include "LUA.h"
#include "API.h"
#include "API_Macro.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/EGnFileCompare.h"
#include "/EgtDev/Include/EgtPerfCounter.h"
@@ -50,6 +51,10 @@ LuaInit( void)
LOG_ERROR( GetLogger(), "Error in LuaInstallGeneral (" __FUNCTION__ ")")
return false ;
}
if ( ! LuaInstallGeoBase( s_L)) {
LOG_ERROR( GetLogger(), "Error in LuaInstallGeoBase (" __FUNCTION__ ")")
return false ;
}
if ( ! LuaInstallGeomDB( s_L)) {
LOG_ERROR( GetLogger(), "Error in LuaInstallGeomDB (" __FUNCTION__ ")")
return false ;
@@ -62,6 +67,10 @@ LuaInit( void)
LOG_ERROR( GetLogger(), "Error in LuaInstallGdbModify (" __FUNCTION__ ")")
return false ;
}
if ( ! LuaInstallGdbModifyCurve( s_L)) {
LOG_ERROR( GetLogger(), "Error in LuaInstallGdbModifyCurve (" __FUNCTION__ ")")
return false ;
}
if ( ! LuaInstallGdbObjects( s_L)) {
LOG_ERROR( GetLogger(), "Error in LuaInstallGdbObjects (" __FUNCTION__ ")")
return false ;
@@ -70,10 +79,6 @@ LuaInit( void)
LOG_ERROR( GetLogger(), "Error in LuaInstallGdbObjAttribs (" __FUNCTION__ ")")
return false ;
}
if ( ! LuaInstallCurveModif( s_L)) {
LOG_ERROR( GetLogger(), "Error in LuaInstallCurveModif (" __FUNCTION__ ")")
return false ;
}
if ( ! LuaInstallGeoSnap( s_L)) {
LOG_ERROR( GetLogger(), "Error in LuaInstallGeoSnap (" __FUNCTION__ ")")
return false ;
@@ -285,6 +290,23 @@ LuaStopCounter( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaNumToString( lua_State* L)
{
// 2 parametri : dVal, nDec
double dVal ;
LuaCheckParam( L, 1, dVal)
int nDec ;
LuaCheckParam( L, 2, nDec)
LuaClearStack( L) ;
// costruisco la stringa
string sVal = ToString( dVal, nDec) ;
// ritorno il risultato
LuaSetReturn( L, sVal) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaExecTsc( lua_State* L)
@@ -396,6 +418,21 @@ LuaGetVersion( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaIs64bit( lua_State* L)
{
// nessun parametro
// restituisco il risultato
#if defined( _WIN64)
bool bRes = true ;
#elif defined( _WIN32)
bool bRes = false ;
#endif
LuaSetReturn( L, bRes) ;
return 1 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallGeneral( lua_State* L)
@@ -407,6 +444,7 @@ LuaInstallGeneral( lua_State* L)
lua_register( L, "EgtPause", LuaPause) ;
lua_register( L, "EgtStartCounter", LuaStartCounter) ;
lua_register( L, "EgtStopCounter", LuaStopCounter) ;
lua_register( L, "EgtNumToString", LuaNumToString) ;
lua_register( L, "EgtExecTsc", LuaExecTsc) ;
lua_register( L, "EgtOutLog", LuaOutLog) ;
lua_register( L, "EgtEraseFile", LuaEraseFile) ;
@@ -414,6 +452,7 @@ LuaInstallGeneral( lua_State* L)
lua_register( L, "EgtTextFileCompare", LuaTextFileCompare) ;
lua_register( L, "EgtBinaryFileCompare", LuaBinaryFileCompare) ;
lua_register( L, "EgtGetVersion", LuaGetVersion) ;
lua_register( L, "EgtIs64bit", LuaIs64bit) ;
}
catch ( ...) {
return false ;
+376
View File
@@ -0,0 +1,376 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : LUA_GeoBasel.cpp Data : 20.12.14 Versione : 1.5l2
// Contenuto : Funzioni generali per LUA.
//
//
//
// Modifiche : 27.09.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "LUA.h"
#include "API.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EgnStringUtils.h"
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
using namespace std ;
//-------------------------------------------------------------------------------
static int
LuaVectorRotate( lua_State* L)
{
// 3 parametri : Vector, VtAsse, AngRot in gradi
Vector3d vtV ;
LuaCheckParam( L, 1, vtV)
Vector3d vtAx ;
LuaCheckParam( L, 2, vtAx)
double dAngRotDeg ;
LuaCheckParam( L, 3, dAngRotDeg)
LuaClearStack( L) ;
// eseguo la rotazione
if ( vtV.Rotate( vtAx, dAngRotDeg)) {
LuaSetReturn( L, true) ;
LuaSetReturn( L, vtV) ;
return 2 ;
}
else {
LuaSetReturn( L, false) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaVectorToGlob( lua_State* L)
{
// 2 parametri : Vector, frame di trasformazione
Vector3d vtV ;
LuaCheckParam( L, 1, vtV)
Frame3d frTool ;
LuaCheckParam( L, 2, frTool)
LuaClearStack( L) ;
// eseguo la trasformazione
if ( vtV.ToGlob( frTool)) {
LuaSetReturn( L, true) ;
LuaSetReturn( L, vtV) ;
return 2 ;
}
else {
LuaSetReturn( L, false) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaVectorToLoc( lua_State* L)
{
// 2 parametri : Vector, frame di trasformazione
Vector3d vtV ;
LuaCheckParam( L, 1, vtV)
Frame3d frTool ;
LuaCheckParam( L, 2, frTool)
LuaClearStack( L) ;
// eseguo la trasformazione
if ( vtV.ToLoc( frTool)) {
LuaSetReturn( L, true) ;
LuaSetReturn( L, vtV) ;
return 2 ;
}
else {
LuaSetReturn( L, false) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaVectorLocToLoc( lua_State* L)
{
// 3 parametri : Vector, frame origine, frame destinazione
Vector3d vtV ;
LuaCheckParam( L, 1, vtV)
Frame3d frOri ;
LuaCheckParam( L, 2, frOri)
Frame3d frDest ;
LuaCheckParam( L, 3, frDest)
LuaClearStack( L) ;
// eseguo la trasformazione
if ( vtV.LocToLoc( frOri, frDest)) {
LuaSetReturn( L, true) ;
LuaSetReturn( L, vtV) ;
return 2 ;
}
else {
LuaSetReturn( L, false) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaPointRotate( lua_State* L)
{
// 4 parametri : Point, PtAsse, VtAsse, AngRot in gradi
Point3d ptP ;
LuaCheckParam( L, 1, ptP)
Point3d ptAx ;
LuaCheckParam( L, 2, ptAx)
Vector3d vtAx ;
LuaCheckParam( L, 3, vtAx)
double dAngRotDeg ;
LuaCheckParam( L, 4, dAngRotDeg)
LuaClearStack( L) ;
// eseguo la rotazione
if ( ptP.Rotate( ptAx, vtAx, dAngRotDeg)) {
LuaSetReturn( L, true) ;
LuaSetReturn( L, ptP) ;
return 2 ;
}
else {
LuaSetReturn( L, false) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaPointToGlob( lua_State* L)
{
// 2 parametri : Point, frame di trasformazione
Point3d ptP ;
LuaCheckParam( L, 1, ptP)
Frame3d frTool ;
LuaCheckParam( L, 2, frTool)
LuaClearStack( L) ;
// eseguo la trasformazione
if ( ptP.ToGlob( frTool)) {
LuaSetReturn( L, true) ;
LuaSetReturn( L, ptP) ;
return 2 ;
}
else {
LuaSetReturn( L, false) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaPointToLoc( lua_State* L)
{
// 2 parametri : Point, frame di trasformazione
Point3d ptP ;
LuaCheckParam( L, 1, ptP)
Frame3d frTool ;
LuaCheckParam( L, 2, frTool)
LuaClearStack( L) ;
// eseguo la trasformazione
if ( ptP.ToLoc( frTool)) {
LuaSetReturn( L, true) ;
LuaSetReturn( L, ptP) ;
return 2 ;
}
else {
LuaSetReturn( L, false) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaPointLocToLoc( lua_State* L)
{
// 3 parametri : Point, frame origine, frame destinazione
Point3d ptP ;
LuaCheckParam( L, 1, ptP)
Frame3d frOri ;
LuaCheckParam( L, 2, frOri)
Frame3d frDest ;
LuaCheckParam( L, 3, frDest)
LuaClearStack( L) ;
// eseguo la trasformazione
if ( ptP.LocToLoc( frOri, frDest)) {
LuaSetReturn( L, true) ;
LuaSetReturn( L, ptP) ;
return 2 ;
}
else {
LuaSetReturn( L, false) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaFrameFrom3Points( lua_State* L)
{
// 3 parametri : origine, punto su X, punto vicino a Y
Point3d ptOrig ;
LuaCheckParam( L, 1, ptOrig)
Point3d ptOnX ;
LuaCheckParam( L, 2, ptOnX)
Point3d ptNearY ;
LuaCheckParam( L, 3, ptNearY)
// calcolo il riferimento e restituisco il risultato : bOk, Frame
Frame3d frTemp ;
if ( frTemp.Set( ptOrig, ptOnX, ptNearY)) {
LuaSetReturn( L, true) ;
LuaSetReturn( L, frTemp) ;
return 2 ;
}
else {
LuaSetReturn( L, false) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaFrameOCS( lua_State* L)
{
// 2 parametri : origine, asse Z
Point3d ptOrig ;
LuaCheckParam( L, 1, ptOrig)
Vector3d vtDirZ ;
LuaCheckParam( L, 2, vtDirZ)
LuaClearStack( L) ;
// calcolo il riferimento e restituisco il risultato : bOk, Frame
Frame3d frTemp ;
if ( frTemp.Set( ptOrig, vtDirZ)) {
LuaSetReturn( L, true) ;
LuaSetReturn( L, frTemp) ;
return 2 ;
}
else {
LuaSetReturn( L, false) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaFrameRotate( lua_State* L)
{
// 4 parametri : Frame, PtAsse, VtAsse, AngRot in gradi
Frame3d frFrame ;
LuaCheckParam( L, 1, frFrame)
Point3d ptAx ;
LuaCheckParam( L, 2, ptAx)
Vector3d vtAx ;
LuaCheckParam( L, 3, vtAx)
double dAngRotDeg ;
LuaCheckParam( L, 4, dAngRotDeg)
LuaClearStack( L) ;
// eseguo la rotazione
if ( frFrame.Rotate( ptAx, vtAx, dAngRotDeg)) {
LuaSetReturn( L, true) ;
LuaSetReturn( L, frFrame) ;
return 2 ;
}
else {
LuaSetReturn( L, false) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaFrameToGlob( lua_State* L)
{
// 2 parametri : frame, frame di trasformazione
Frame3d frFrame ;
LuaCheckParam( L, 1, frFrame)
Frame3d frTool ;
LuaCheckParam( L, 2, frTool)
LuaClearStack( L) ;
// eseguo la trasformazione
if ( frFrame.ToGlob( frTool)) {
LuaSetReturn( L, true) ;
LuaSetReturn( L, frFrame) ;
return 2 ;
}
else {
LuaSetReturn( L, false) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaFrameToLoc( lua_State* L)
{
// 2 parametri : frame, frame di trasformazione
Frame3d frFrame ;
LuaCheckParam( L, 1, frFrame)
Frame3d frTool ;
LuaCheckParam( L, 2, frTool)
LuaClearStack( L) ;
// eseguo la trasformazione
if ( frFrame.ToLoc( frTool)) {
LuaSetReturn( L, true) ;
LuaSetReturn( L, frFrame) ;
return 2 ;
}
else {
LuaSetReturn( L, false) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaFrameLocToLoc( lua_State* L)
{
// 3 parametri : frame, frame origine, frame destinazione
Frame3d frFrame ;
LuaCheckParam( L, 1, frFrame)
Frame3d frOri ;
LuaCheckParam( L, 2, frOri)
Frame3d frDest ;
LuaCheckParam( L, 3, frDest)
LuaClearStack( L) ;
// eseguo la trasformazione
if ( frFrame.LocToLoc( frOri, frDest)) {
LuaSetReturn( L, true) ;
LuaSetReturn( L, frFrame) ;
return 2 ;
}
else {
LuaSetReturn( L, false) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
bool
LuaInstallGeoBase( lua_State* L)
{
try {
lua_register( L, "EgtVectorRotate", LuaVectorRotate) ;
lua_register( L, "EgtVectorToGlob", LuaVectorToGlob) ;
lua_register( L, "EgtVectorToLoc", LuaVectorToLoc) ;
lua_register( L, "EgtVectorLocToLoc", LuaVectorLocToLoc) ;
lua_register( L, "EgtPointRotate", LuaPointRotate) ;
lua_register( L, "EgtPointToGlob", LuaPointToGlob) ;
lua_register( L, "EgtPointToLoc", LuaPointToLoc) ;
lua_register( L, "EgtPointLocToLoc", LuaPointLocToLoc) ;
lua_register( L, "EgtFrameFrom3Points", LuaFrameFrom3Points) ;
lua_register( L, "EgtFrameOCS", LuaFrameOCS) ;
lua_register( L, "EgtFrameRotate", LuaFrameRotate) ;
lua_register( L, "EgtFrameToGlob", LuaFrameToGlob) ;
lua_register( L, "EgtFrameToLoc", LuaFrameToLoc) ;
lua_register( L, "EgtFrameLocToLoc", LuaFrameLocToLoc) ;
}
catch ( ...) {
return false ;
}
return true ;
}
+273 -21
View File
@@ -16,6 +16,7 @@
#include "LUA.h"
#include "API.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EgnStringUtils.h"
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
using namespace std ;
@@ -25,13 +26,22 @@ using namespace std ;
static int
LuaStartPoint( lua_State* L)
{
// 1 parametro : Id
// 1 o 2 parametri : Id [, nRefIf]
int nId ;
LuaCheckParam( L, 1, nId)
int nRefId = nId ;
if ( lua_gettop( L) >= 2) {
if ( ! LuaGetParam( L, 2, nRefId)) {
string sFlag ;
LuaCheckParam( L, 2, sFlag)
ToUpper( sFlag) ;
nRefId = (( sFlag == "GRID") ? GDB_ID_GRID : GDB_ID_ROOT) ;
}
}
LuaClearStack( L) ;
// recupero il punto iniziale dell'entità
Point3d ptP ;
if ( EgtStartPoint( nId, ptP))
if ( EgtStartPoint( nId, nRefId, ptP))
LuaSetReturn( L, ptP) ;
else
LuaSetReturn( L) ;
@@ -42,13 +52,22 @@ LuaStartPoint( lua_State* L)
static int
LuaEndPoint( lua_State* L)
{
// 1 parametro : Id
// 1 o 2 parametri : Id [, nRefIf]
int nId ;
LuaCheckParam( L, 1, nId)
int nRefId = nId ;
if ( lua_gettop( L) >= 2) {
if ( ! LuaGetParam( L, 2, nRefId)) {
string sFlag ;
LuaCheckParam( L, 2, sFlag)
ToUpper( sFlag) ;
nRefId = (( sFlag == "GRID") ? GDB_ID_GRID : GDB_ID_ROOT) ;
}
}
LuaClearStack( L) ;
// recupero il punto finale dell'entità
Point3d ptP ;
if ( EgtEndPoint( nId, ptP))
if ( EgtEndPoint( nId, nRefId, ptP))
LuaSetReturn( L, ptP) ;
else
LuaSetReturn( L) ;
@@ -59,13 +78,22 @@ LuaEndPoint( lua_State* L)
static int
LuaMidPoint( lua_State* L)
{
// 1 parametro : Id
// 1 o 2 parametri : Id [, nRefIf]
int nId ;
LuaCheckParam( L, 1, nId)
int nRefId = nId ;
if ( lua_gettop( L) >= 2) {
if ( ! LuaGetParam( L, 2, nRefId)) {
string sFlag ;
LuaCheckParam( L, 2, sFlag)
ToUpper( sFlag) ;
nRefId = (( sFlag == "GRID") ? GDB_ID_GRID : GDB_ID_ROOT) ;
}
}
LuaClearStack( L) ;
// recupero il punto centrale dell'entità
Point3d ptP ;
if ( EgtMidPoint( nId, ptP))
if ( EgtMidPoint( nId, nRefId, ptP))
LuaSetReturn( L, ptP) ;
else
LuaSetReturn( L) ;
@@ -76,13 +104,22 @@ LuaMidPoint( lua_State* L)
static int
LuaCenterPoint( lua_State* L)
{
// 1 parametro : Id
// 1 o 2 parametri : Id [, nRefIf]
int nId ;
LuaCheckParam( L, 1, nId)
int nRefId = nId ;
if ( lua_gettop( L) >= 2) {
if ( ! LuaGetParam( L, 2, nRefId)) {
string sFlag ;
LuaCheckParam( L, 2, sFlag)
ToUpper( sFlag) ;
nRefId = (( sFlag == "GRID") ? GDB_ID_GRID : GDB_ID_ROOT) ;
}
}
LuaClearStack( L) ;
// recupero il punto centrale dell'entità
Point3d ptP ;
if ( EgtCenterPoint( nId, ptP))
if ( EgtCenterPoint( nId, nRefId, ptP))
LuaSetReturn( L, ptP) ;
else
LuaSetReturn( L) ;
@@ -93,15 +130,82 @@ LuaCenterPoint( lua_State* L)
static int
LuaAtParamPoint( lua_State* L)
{
// 2 parametri : Id, U
// 2 o 3 parametri : Id, U [, nRefIf]
int nId ;
LuaCheckParam( L, 1, nId)
double dU ;
LuaCheckParam( L, 2, dU)
int nRefId = nId ;
if ( lua_gettop( L) >= 3) {
if ( ! LuaGetParam( L, 3, nRefId)) {
string sFlag ;
LuaCheckParam( L, 3, sFlag)
ToUpper( sFlag) ;
nRefId = (( sFlag == "GRID") ? GDB_ID_GRID : GDB_ID_ROOT) ;
}
}
LuaClearStack( L) ;
// recupero il punto in posizione parametrica U della curva
Point3d ptP ;
if ( EgtAtParamPoint( nId, dU, ptP))
if ( EgtAtParamPoint( nId, dU, nRefId, ptP))
LuaSetReturn( L, ptP) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaNearPoint( lua_State* L)
{
// 2 o 3 parametri : Id, ptNear [, nRefIf]
int nId ;
LuaCheckParam( L, 1, nId)
Point3d ptNear ;
LuaCheckParam( L, 2, ptNear)
int nRefId = nId ;
if ( lua_gettop( L) >= 3) {
if ( ! LuaGetParam( L, 3, nRefId)) {
string sFlag ;
LuaCheckParam( L, 3, sFlag)
ToUpper( sFlag) ;
nRefId = (( sFlag == "GRID") ? GDB_ID_GRID : GDB_ID_ROOT) ;
}
}
LuaClearStack( L) ;
// recupero il punto di intersezione tra le curve più vicino al punto passato
Point3d ptP ;
if ( EgtNearPoint( nId, ptNear, nRefId, ptP))
LuaSetReturn( L, ptP) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaIntersectionPoint( lua_State* L)
{
// 3 o 4 parametri : Id1, Id2, ptNear [, nRefIf]
int nId1 ;
LuaCheckParam( L, 1, nId1)
int nId2 ;
LuaCheckParam( L, 2, nId2)
Point3d ptNear ;
LuaCheckParam( L, 3, ptNear)
int nRefId = nId1 ;
if ( lua_gettop( L) >= 4) {
if ( ! LuaGetParam( L, 4, nRefId)) {
string sFlag ;
LuaCheckParam( L, 4, sFlag)
ToUpper( sFlag) ;
nRefId = (( sFlag == "GRID") ? GDB_ID_GRID : GDB_ID_ROOT) ;
}
}
LuaClearStack( L) ;
// recupero il punto di intersezione tra le curve più vicino al punto passato
Point3d ptP ;
if ( EgtIntersectionPoint( nId1, nId2, ptNear, nRefId, ptP))
LuaSetReturn( L, ptP) ;
else
LuaSetReturn( L) ;
@@ -112,13 +216,22 @@ LuaAtParamPoint( lua_State* L)
static int
LuaStartVector( lua_State* L)
{
// 1 parametro : Id
// 1 o 2 parametri : Id [, nRefIf]
int nId ;
LuaCheckParam( L, 1, nId)
int nRefId = nId ;
if ( lua_gettop( L) >= 2) {
if ( ! LuaGetParam( L, 2, nRefId)) {
string sFlag ;
LuaCheckParam( L, 2, sFlag)
ToUpper( sFlag) ;
nRefId = (( sFlag == "GRID") ? GDB_ID_GRID : GDB_ID_ROOT) ;
}
}
LuaClearStack( L) ;
// recupero il vettore tangente all'inizio della curva
Vector3d vtV ;
if ( EgtStartVector( nId, vtV))
if ( EgtStartVector( nId, nRefId, vtV))
LuaSetReturn( L, vtV) ;
else
LuaSetReturn( L) ;
@@ -129,13 +242,22 @@ LuaStartVector( lua_State* L)
static int
LuaEndVector( lua_State* L)
{
// 1 parametro : Id
// 1 o 2 parametri : Id [, nRefIf]
int nId ;
LuaCheckParam( L, 1, nId)
int nRefId = nId ;
if ( lua_gettop( L) >= 2) {
if ( ! LuaGetParam( L, 2, nRefId)) {
string sFlag ;
LuaCheckParam( L, 2, sFlag)
ToUpper( sFlag) ;
nRefId = (( sFlag == "GRID") ? GDB_ID_GRID : GDB_ID_ROOT) ;
}
}
LuaClearStack( L) ;
// recupero il vettore tangente alla fine della curva
Vector3d vtV ;
if ( EgtEndVector( nId, vtV))
if ( EgtEndVector( nId, nRefId, vtV))
LuaSetReturn( L, vtV) ;
else
LuaSetReturn( L) ;
@@ -146,13 +268,22 @@ LuaEndVector( lua_State* L)
static int
LuaMidVector( lua_State* L)
{
// 1 parametro : Id
// 1 o 2 parametri : Id [, nRefIf]
int nId ;
LuaCheckParam( L, 1, nId)
int nRefId = nId ;
if ( lua_gettop( L) >= 2) {
if ( ! LuaGetParam( L, 2, nRefId)) {
string sFlag ;
LuaCheckParam( L, 2, sFlag)
ToUpper( sFlag) ;
nRefId = (( sFlag == "GRID") ? GDB_ID_GRID : GDB_ID_ROOT) ;
}
}
LuaClearStack( L) ;
// recupero il vettore tangente nel punto medio della curva
Vector3d vtV ;
if ( EgtMidVector( nId, vtV))
if ( EgtMidVector( nId, nRefId, vtV))
LuaSetReturn( L, vtV) ;
else
LuaSetReturn( L) ;
@@ -163,19 +294,29 @@ LuaMidVector( lua_State* L)
static int
LuaAtParamVector( lua_State* L)
{
// 2 o 3 parametri : Id, U [, sSide]
// 2, 3 o 4 parametri : Id, U, sSide [, nRefIf]
int nId ;
LuaCheckParam( L, 1, nId)
double dU ;
LuaCheckParam( L, 2, dU)
int nSide = + 1 ;
string sSide ;
if ( LuaGetParam( L, 3, sSide) && sSide == "-")
LuaCheckParam( L, 3, sSide) ;
if ( sSide == "-")
nSide = - 1 ;
int nRefId = nId ;
if ( lua_gettop( L) >= 4) {
if ( ! LuaGetParam( L, 4, nRefId)) {
string sFlag ;
LuaCheckParam( L, 4, sFlag)
ToUpper( sFlag) ;
nRefId = (( sFlag == "GRID") ? GDB_ID_GRID : GDB_ID_ROOT) ;
}
}
LuaClearStack( L) ;
// recupero il punto in posizione parametrica U della curva
Vector3d vtV ;
if ( EgtAtParamVector( nId, dU, nSide, vtV))
if ( EgtAtParamVector( nId, dU, nSide, nRefId, vtV))
LuaSetReturn( L, vtV) ;
else
LuaSetReturn( L) ;
@@ -186,19 +327,124 @@ LuaAtParamVector( lua_State* L)
static int
LuaFrame( lua_State* L)
{
// 1 parametro : Id
// 1 o 2 parametri : Id [, nRefIf]
int nId ;
LuaCheckParam( L, 1, nId)
int nRefId = nId ;
if ( lua_gettop( L) >= 2) {
if ( ! LuaGetParam( L, 2, nRefId)) {
string sFlag ;
LuaCheckParam( L, 2, sFlag)
ToUpper( sFlag) ;
nRefId = (( sFlag == "GRID") ? GDB_ID_GRID : GDB_ID_ROOT) ;
}
}
LuaClearStack( L) ;
// recupero il frame
Frame3d frFrame ;
if ( EgtFrame( nId, frFrame))
if ( EgtFrame( nId, nRefId, frFrame))
LuaSetReturn( L, frFrame) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaCurveExtrusion( lua_State* L)
{
// 1 o 2 parametri : Id [, nRefIf]
int nId ;
LuaCheckParam( L, 1, nId)
int nRefId = nId ;
if ( lua_gettop( L) >= 2) {
if ( ! LuaGetParam( L, 2, nRefId)) {
string sFlag ;
LuaCheckParam( L, 2, sFlag)
ToUpper( sFlag) ;
nRefId = (( sFlag == "GRID") ? GDB_ID_GRID : GDB_ID_ROOT) ;
}
}
LuaClearStack( L) ;
// recupero il versore
Vector3d vtExtr ;
if ( EgtCurveExtrusion( nId, nRefId, vtExtr))
LuaSetReturn( L, vtExtr) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaCurveThickness( lua_State* L)
{
// 1 parametro : Id
int nId ;
LuaCheckParam( L, 1, nId)
int nRefId = nId ;
LuaClearStack( L) ;
// recupero lo spessore
double dThick ;
if ( EgtCurveThickness( nId, &dThick) != FALSE)
LuaSetReturn( L, dThick) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaCurveArcNormVersor( lua_State* L)
{
// 1 o 2 parametri : Id [, nRefIf]
int nId ;
LuaCheckParam( L, 1, nId)
int nRefId = nId ;
if ( lua_gettop( L) >= 2) {
if ( ! LuaGetParam( L, 2, nRefId)) {
string sFlag ;
LuaCheckParam( L, 2, sFlag)
ToUpper( sFlag) ;
nRefId = (( sFlag == "GRID") ? GDB_ID_GRID : GDB_ID_ROOT) ;
}
}
LuaClearStack( L) ;
// recupero il versore
Vector3d vtNorm ;
if ( EgtCurveArcNormVersor( nId, nRefId, vtNorm))
LuaSetReturn( L, vtNorm) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaExtTextNormVersor( lua_State* L)
{
// 1 o 2 parametri : Id [, nRefIf]
int nId ;
LuaCheckParam( L, 1, nId)
int nRefId = nId ;
if ( lua_gettop( L) >= 2) {
if ( ! LuaGetParam( L, 2, nRefId)) {
string sFlag ;
LuaCheckParam( L, 2, sFlag)
ToUpper( sFlag) ;
nRefId = (( sFlag == "GRID") ? GDB_ID_GRID : GDB_ID_ROOT) ;
}
}
LuaClearStack( L) ;
// recupero il versore
Vector3d vtNorm ;
if ( EgtExtTextNormVersor( nId, nRefId, vtNorm))
LuaSetReturn( L, vtNorm) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallGeoSnap( lua_State* L)
@@ -209,11 +455,17 @@ LuaInstallGeoSnap( lua_State* L)
lua_register( L, "EgtMP", LuaMidPoint) ;
lua_register( L, "EgtCP", LuaCenterPoint) ;
lua_register( L, "EgtUP", LuaAtParamPoint) ;
lua_register( L, "EgtNP", LuaNearPoint) ;
lua_register( L, "EgtIP", LuaIntersectionPoint) ;
lua_register( L, "EgtSV", LuaStartVector) ;
lua_register( L, "EgtEV", LuaEndVector) ;
lua_register( L, "EgtMV", LuaMidVector) ;
lua_register( L, "EgtUV", LuaAtParamVector) ;
lua_register( L, "EgtFR", LuaFrame) ;
lua_register( L, "EgtCurveExtrusion", LuaCurveExtrusion) ;
lua_register( L, "EgtCurveThickness", LuaCurveThickness) ;
lua_register( L, "EgtCurveArcNormVersor", LuaCurveArcNormVersor) ;
lua_register( L, "EgtExtTextNormVersor", LuaExtTextNormVersor) ;
}
catch ( ...) {
return false ;
+14 -8
View File
@@ -72,12 +72,17 @@ LuaGetGridFrame( lua_State* L)
static int
LuaGetGridVersZ( lua_State* L)
{
// nessun parametro
// recupero il riferimento della griglia
Frame3d frFrame ;
EgtGetGridFrame( frFrame) ;
// restituisco il risultato
LuaSetReturn( L, frFrame.VersZ()) ;
// 1 o nessun parametro : [nRefId]
int nRefId = GDB_ID_ROOT ;
if ( lua_gettop( L) >= 1)
LuaCheckParam( L, 1, nRefId)
LuaClearStack( L) ;
// recupero il versore Z della griglia e lo restituisco
Vector3d vtVersZ ;
if ( EgtGetGridVersZ( nRefId, vtVersZ))
LuaSetReturn( L, vtVersZ) ;
else
LuaSetReturn( L) ;
return 1 ;
}
@@ -117,8 +122,9 @@ LuaSaveFile( lua_State* L)
string sFilePath ;
LuaCheckParam( L, 1, sFilePath)
int nFlag = GDB_SV_CMPTXT ;
string sFlag ;
if ( LuaGetParam( L, 2, sFlag)) {
if ( lua_gettop( L) >= 2) {
string sFlag ;
LuaCheckParam( L, 2, sFlag) ;
ToUpper( sFlag) ;
if ( sFlag == "T")
nFlag = GDB_SV_TXT ;
+27 -20
View File
@@ -26,13 +26,14 @@ using namespace std ;
static int
LuaSetBackground( lua_State* L)
{
// 3 parametri : colore top, colore bottom, flag ridisegna
// 2 o 3 parametri : colore top, colore bottom [, flag ridisegna]
Color colTop ;
LuaCheckParam( L, 1, colTop)
Color colBot ;
LuaCheckParam( L, 2, colBot)
bool bRedraw ;
LuaCheckParam( L, 3, bRedraw)
if ( lua_gettop( L) >= 3)
LuaCheckParam( L, 3, bRedraw)
LuaClearStack( L) ;
// imposto lo sfondo
bool bOk = ( EgtSetBackground( colTop, colBot, bRedraw) != FALSE) ;
@@ -58,7 +59,7 @@ LuaDraw( lua_State* L)
static int
LuaSetShowMode( lua_State* L)
{
// 2 parametri : ShowMode ("WF","HL","SH"), flag ridisegna
// 1 o 2 parametri : ShowMode ("WF","HL","SH") [, flag ridisegna]
string sShowMode ;
LuaCheckParam( L, 1, sShowMode)
int nShowMode = SM_SHADING ;
@@ -67,8 +68,9 @@ LuaSetShowMode( lua_State* L)
nShowMode = SM_WIREFRAME ;
else if ( sShowMode == "HL")
nShowMode = SM_HIDDENLINE ;
bool bRedraw ;
LuaCheckParam( L, 2, bRedraw)
bool bRedraw = true ;
if ( lua_gettop( L) >= 2)
LuaCheckParam( L, 2, bRedraw)
LuaClearStack( L) ;
// imposto il modo di visualizzazione
bool bOk = ( EgtSetShowMode( nShowMode, bRedraw) != FALSE) ;
@@ -81,11 +83,12 @@ LuaSetShowMode( lua_State* L)
static int
LuaSetShowCurveDirection( lua_State* L)
{
// 2 parametri : flag ShowCrvDir, flag ridisegna
// 1 o 2 parametri : flag ShowCrvDir [, flag ridisegna]
bool bShowCrvDir ;
LuaCheckParam( L, 1, bShowCrvDir)
bool bRedraw ;
LuaCheckParam( L, 2, bRedraw)
bool bRedraw = true ;
if ( lua_gettop( L) >= 2)
LuaCheckParam( L, 2, bRedraw)
LuaClearStack( L) ;
// imposto visualizzazione direzione curve
bool bOk = ( EgtSetShowCurveDirection( bShowCrvDir, bRedraw) != FALSE) ;
@@ -98,7 +101,7 @@ LuaSetShowCurveDirection( lua_State* L)
static int
LuaZoom( lua_State* L)
{
// 2 parametri : ZoomType ("ALL","IN","OUT"), flag ridisegna
// 1 o 2 parametri : ZoomType ("ALL","IN","OUT") [, flag ridisegna]
string sZoomType ;
LuaCheckParam( L, 1, sZoomType)
int nZoomType = 1 ;
@@ -107,8 +110,9 @@ LuaZoom( lua_State* L)
nZoomType = 2 ;
else if ( sZoomType == "OUT")
nZoomType = 3 ;
bool bRedraw ;
LuaCheckParam( L, 2, bRedraw)
bool bRedraw = true ;
if ( lua_gettop( L) >= 2)
LuaCheckParam( L, 2, bRedraw)
LuaClearStack( L) ;
// imposto zoom
bool bOk = ( EgtZoom( nZoomType, bRedraw) != FALSE) ;
@@ -121,7 +125,7 @@ LuaZoom( lua_State* L)
static int
LuaSetView( lua_State* L)
{
// 2 parametri : ViewDir ("T","F","R","B","L","BO","SWI","SEI","NEI","NWI","CPL"), flag ridisegna
// 1 o 2 parametri : ViewDir ("T","F","R","B","L","BO","SWI","SEI","NEI","NWI","CPL") [, flag ridisegna]
string sViewDir ;
LuaCheckParam( L, 1, sViewDir)
int nViewDir = CT_TOP ;
@@ -144,8 +148,9 @@ LuaSetView( lua_State* L)
nViewDir = CT_ISO_NW ;
else if ( sViewDir == "CPL")
nViewDir = CT_CPLANE ;
bool bRedraw ;
LuaCheckParam( L, 2, bRedraw)
bool bRedraw = true ;
if ( lua_gettop( L) >= 2)
LuaCheckParam( L, 2, bRedraw)
LuaClearStack( L) ;
// imposto direzione di vista
bool bOk = ( EgtSetView( nViewDir, bRedraw) != FALSE) ;
@@ -158,13 +163,14 @@ LuaSetView( lua_State* L)
static int
LuaSetGenericView( lua_State* L)
{
// 3 parametri : dAngVertDeg, dAngHorizDeg, flag ridisegna
// 2 o 3 parametri : dAngVertDeg, dAngHorizDeg [, flag ridisegna]
double dAngVertDeg ;
LuaCheckParam( L, 1, dAngVertDeg)
double dAngHorizDeg ;
LuaCheckParam( L, 2, dAngHorizDeg)
bool bRedraw ;
LuaCheckParam( L, 3, bRedraw)
bool bRedraw = true ;
if ( lua_gettop( L) >= 3)
LuaCheckParam( L, 3, bRedraw)
LuaClearStack( L) ;
// imposto direzione di vista
bool bOk = ( EgtSetGenericView( dAngVertDeg, dAngHorizDeg, bRedraw) != FALSE) ;
@@ -177,11 +183,12 @@ LuaSetGenericView( lua_State* L)
static int
LuaSetViewCenter( lua_State* L)
{
// 2 parametri : ptCen, flag ridisegna
// 1 o 2 parametri : ptCen [, flag ridisegna]
Point3d ptCen ;
LuaCheckParam( L, 1, ptCen)
bool bRedraw ;
LuaCheckParam( L, 2, bRedraw)
bool bRedraw = true ;
if ( lua_gettop( L) >= 2)
LuaCheckParam( L, 2, bRedraw)
LuaClearStack( L) ;
// imposto centro di vista
bool bOk = ( EgtSetViewCenter( ptCen.v, bRedraw) != FALSE) ;
BIN
View File
Binary file not shown.