//---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- // File : LUA_GdbCreateCurve.cpp Data : 07.01.15 Versione : 1.6a1 // Contenuto : Funzioni di creazione curve per LUA. // // // // Modifiche : 07.01.15 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "LUA.h" #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EXeConst.h" #include "/EgtDev/Include/EGkGdbConst.h" #include "/EgtDev/Include/EGkLuaAux.h" using namespace std ; //------------------------------------------------------------------------------- static int LuaCreateLine( lua_State* L) { // 3 o 4 parametri : ParentId, PtIni, PtFin [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; LuaCheckParam( L, 2, ptIni) Point3d ptFin ; LuaCheckParam( L, 3, ptFin) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // creo il segmento di retta int nId = ExeCreateLine( nParentId, ptIni, ptFin, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateLineEx( lua_State* L) { // 7 o 8 parametri : ParentId, PtIni, nSepI, nIdI, PtFin, nSepF, nIdF [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; LuaCheckParam( L, 2, ptIni) int nSepI ; LuaCheckParam( L, 3, nSepI) int nIdI ; LuaCheckParam( L, 4, nIdI) Point3d ptFin ; LuaCheckParam( L, 5, ptFin) int nSepF ; LuaCheckParam( L, 6, nSepF) int nIdF ; LuaCheckParam( L, 7, nIdF) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 8, nRefType) ; LuaClearStack( L) ; // creo il segmento di retta int nId = ExeCreateLineEx( nParentId, ptIni, nSepI, nIdI, ptFin, nSepF, nIdF, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateLinePDL( lua_State* L) { // 4 o 5 parametri : ParentId, PtIni, dDirDeg, dLen [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; LuaCheckParam( L, 2, ptIni) double dDirDeg ; LuaCheckParam( L, 3, dDirDeg) double dLen ; LuaCheckParam( L, 4, dLen) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo il segmento di retta int nId = ExeCreateLinePDL( nParentId, ptIni, dDirDeg, dLen, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateLinePVL( lua_State* L) { // 4 o 5 parametri : ParentId, PtIni, VtDir, dLen [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; LuaCheckParam( L, 2, ptIni) Vector3d vtDir ; LuaCheckParam( L, 3, vtDir) double dLen ; LuaCheckParam( L, 4, dLen) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo il segmento di retta int nId = ExeCreateLinePVL( nParentId, ptIni, vtDir, dLen, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateLineMinPointCurve( lua_State* L) { // 3 o 4 o 5 parametri : ParentId, PtIni, CrvId [, NearPar] [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; LuaCheckParam( L, 2, ptIni) int nCrvId ; LuaCheckParam( L, 3, nCrvId) double dNearPar = 0 ; int nRefType = RTY_DEFAULT ; if ( LuaGetParam( L, 4, dNearPar)) LuaGetParam( L, 5, nRefType) ; else LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // creo il segmento di retta int nId = ExeCreateLineMinPointCurve( nParentId, ptIni, nCrvId, dNearPar, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCircle( lua_State* L) { // 3 o 4 parametri : ParentId, PtCen, Rad [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; LuaCheckParam( L, 2, ptCen) double dRad ; LuaCheckParam( L, 3, dRad) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = ExeCreateCircle( nParentId, ptCen, dRad, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCircleCP( lua_State* L) { // 3 o 4 parametri : ParentId, PtCen, PtOn [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; LuaCheckParam( L, 2, ptCen) Point3d ptOn ; LuaCheckParam( L, 3, ptOn) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = ExeCreateCircleCP( nParentId, ptCen, ptOn, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCircleCPEx( lua_State* L) { // 5 o 6 parametri : ParentId, PtCen, PtOn, nSepO, nIdO [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; LuaCheckParam( L, 2, ptCen) Point3d ptOn ; LuaCheckParam( L, 3, ptOn) int nSepO ; LuaCheckParam( L, 4, nSepO) int nIdO ; LuaCheckParam( L, 5, nIdO) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = ExeCreateCircleCPEx( nParentId, ptCen, ptOn, nSepO, nIdO, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCircle2P( lua_State* L) { // 3 o 4 parametri : ParentId, PtP1, PtP2 [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptP1 ; LuaCheckParam( L, 2, ptP1) Point3d ptP2 ; LuaCheckParam( L, 3, ptP2) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = ExeCreateCircle2P( nParentId, ptP1, ptP2, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCircle3P( lua_State* L) { // 4 o 5 parametri : ParentId, PtP1, PtP2, PtP3 [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptP1 ; LuaCheckParam( L, 2, ptP1) Point3d ptP2 ; LuaCheckParam( L, 3, ptP2) Point3d ptP3 ; LuaCheckParam( L, 4, ptP3) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = ExeCreateCircle3P( nParentId, ptP1, ptP2, ptP3, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateArc( lua_State* L) { // 6 o 7 parametri : ParentId, PtCen, Rad, AngIniDeg, AngCenDeg, DeltaN [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; LuaCheckParam( L, 2, ptCen) double dRad ; LuaCheckParam( L, 3, dRad) double dAngIniDeg ; LuaCheckParam( L, 4, dAngIniDeg) double dAngCenDeg ; LuaCheckParam( L, 5, dAngCenDeg) double dDeltaN ; LuaCheckParam( L, 6, dDeltaN) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 7, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = ExeCreateArc( nParentId, ptCen, dRad, dAngIniDeg, dAngCenDeg, dDeltaN, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateArcCPA( lua_State* L) { // 5 o 6 parametri : ParentId, PtCen, PtStart, AngCenDeg, DeltaN [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; LuaCheckParam( L, 2, ptCen) Point3d ptStart ; LuaCheckParam( L, 3, ptStart) double dAngCenDeg ; LuaCheckParam( L, 4, dAngCenDeg) double dDeltaN ; LuaCheckParam( L, 5, dDeltaN) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = ExeCreateArcCPA( nParentId, ptCen, ptStart, dAngCenDeg, dDeltaN, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateArcC2P( lua_State* L) { // 4 o 5 parametri : ParentId, PtCen, PtStart, PtNearEnd [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; LuaCheckParam( L, 2, ptCen) Point3d ptStart ; LuaCheckParam( L, 3, ptStart) Point3d ptNearEnd ; LuaCheckParam( L, 4, ptNearEnd) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = ExeCreateArcC2P( nParentId, ptCen, ptStart, ptNearEnd, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateArcC2PEx( lua_State* L) { // 6 o 7 parametri : ParentId, PtCen, PtStart, nSepS, nIdS, PtNearEnd [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; LuaCheckParam( L, 2, ptCen) Point3d ptStart ; LuaCheckParam( L, 3, ptStart) int nSepS ; LuaCheckParam( L, 4, nSepS) int nIdS ; LuaCheckParam( L, 5, nIdS) Point3d ptNearEnd ; LuaCheckParam( L, 6, ptNearEnd) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 7, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = ExeCreateArcC2PEx( nParentId, ptCen, ptStart, nSepS, nIdS, ptNearEnd, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateArc3P( lua_State* L) { // 4 o 5 parametri : ParentId, PtP1, PtP2, PtP3 [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptP1 ; LuaCheckParam( L, 2, ptP1) Point3d ptP2 ; LuaCheckParam( L, 3, ptP2) Point3d ptP3 ; LuaCheckParam( L, 4, ptP3) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = ExeCreateArc3P( nParentId, ptP1, ptP2, ptP3, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateArc2PR( lua_State* L) { // 5 o 6 parametri : ParentId, PtStart, PtEnd, dRad, bCCW [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptStart ; LuaCheckParam( L, 2, ptStart) Point3d ptEnd ; LuaCheckParam( L, 3, ptEnd) double dRad ; LuaCheckParam( L, 4, dRad) bool bCCW ; LuaCheckParam( L, 5, bCCW) ; int nRefType = RTY_DEFAULT ; LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = ExeCreateArc2PR( nParentId, ptStart, ptEnd, dRad, bCCW, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateArc2PB( lua_State* L) { // 4 o 5 parametri : ParentId, PtStart, PtEnd, dBulge [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptStart ; LuaCheckParam( L, 2, ptStart) Point3d ptEnd ; LuaCheckParam( L, 3, ptEnd) double dBulge ; LuaCheckParam( L, 4, dBulge) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = ExeCreateArc2PB( nParentId, ptStart, ptEnd, dBulge, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateArc2PD( lua_State* L) { // 4 o 5 parametri : ParentId, PtStart, PtEnd, dDirSDeg [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptStart ; LuaCheckParam( L, 2, ptStart) Point3d ptEnd ; LuaCheckParam( L, 3, ptEnd) double dDirSDeg ; LuaCheckParam( L, 4, dDirSDeg) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = ExeCreateArc2PD( nParentId, ptStart, ptEnd, dDirSDeg, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateArc2PDEx( lua_State* L) { // 6 o 7 parametri : ParentId, PtStart, PtEnd, nSepE, nIdE, dDirSDeg [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptStart ; LuaCheckParam( L, 2, ptStart) Point3d ptEnd ; LuaCheckParam( L, 3, ptEnd) int nSepE ; LuaCheckParam( L, 4, nSepE) int nIdE ; LuaCheckParam( L, 5, nIdE) double dDirSDeg ; LuaCheckParam( L, 6, dDirSDeg) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 7, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = ExeCreateArc2PDEx( nParentId, ptStart, ptEnd, nSepE, nIdE, dDirSDeg, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateArc2PV( lua_State* L) { // 4 o 5 parametri : ParentId, PtStart, PtEnd, VtDirS [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptStart ; LuaCheckParam( L, 2, ptStart) Point3d ptEnd ; LuaCheckParam( L, 3, ptEnd) Vector3d vtDirS ; LuaCheckParam( L, 4, vtDirS) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = ExeCreateArc2PV( nParentId, ptStart, ptEnd, vtDirS, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateBiArc( lua_State* L) { // 6 o 7 parametri : ParentId, ptStart, ptEnd, dDirSDeg, dDirEDeg, dPar [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptStart ; LuaCheckParam( L, 2, ptStart) Point3d ptEnd ; LuaCheckParam( L, 3, ptEnd) double dDirSDeg ; LuaCheckParam( L, 4, dDirSDeg) double dDirEDeg ; LuaCheckParam( L, 5, dDirEDeg) double dPar ; LuaCheckParam( L, 6, dPar) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 7, nRefType) ; LuaClearStack( L) ; // creo l'arco di fillet int nId = ExeCreateBiArc( nParentId, ptStart, ptEnd, dDirSDeg, dDirEDeg, dPar, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCurveFillet( lua_State* L) { // 7 o 8 parametri : ParentId, nCrv1, PtNear1, nCrv2, PtNear2, dRad, bTrim [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrv1 ; LuaCheckParam( L, 2, nCrv1) Point3d ptNear1 ; LuaCheckParam( L, 3, ptNear1) int nCrv2 ; LuaCheckParam( L, 4, nCrv2) Point3d ptNear2 ; LuaCheckParam( L, 5, ptNear2) double dRad ; LuaCheckParam( L, 6, dRad) bool bTrim ; LuaCheckParam( L, 7, bTrim) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 8, nRefType) ; LuaClearStack( L) ; // creo l'arco di fillet int nId = ExeCreateCurveFillet( nParentId, nCrv1, ptNear1, nCrv2, ptNear2, dRad, bTrim, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCurveChamfer( lua_State* L) { // 7 o 8 parametri : ParentId, nCrv1, PtNear1, nCrv2, PtNear2, dDist, bTrim [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrv1 ; LuaCheckParam( L, 2, nCrv1) Point3d ptNear1 ; LuaCheckParam( L, 3, ptNear1) int nCrv2 ; LuaCheckParam( L, 4, nCrv2) Point3d ptNear2 ; LuaCheckParam( L, 5, ptNear2) double dDist ; LuaCheckParam( L, 6, dDist) bool bTrim ; LuaCheckParam( L, 7, bTrim) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 8, nRefType) ; LuaClearStack( L) ; // creo l'arco di fillet int nId = ExeCreateCurveChamfer( nParentId, nCrv1, ptNear1, nCrv2, ptNear2, dDist, bTrim, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCurveBezier( lua_State* L) { // 3 o 4 parametri : ParentId, Degree, CtrlPnts [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nDegree ; LuaCheckParam( L, 2, nDegree) PNTVECTOR vPnt ; LuaCheckParam( L, 3, vPnt) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // creo la curva int nId = ExeCreateCurveBezier( nParentId, nDegree, vPnt, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCurveBezierRational( lua_State* L) { // 3 o 4 parametri : ParentId, Degree, CtrlPntWs [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nDegree ; LuaCheckParam( L, 2, nDegree) PNTUVECTOR vPntW ; LuaCheckParam( L, 3, vPntW) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // creo la curva int nId = ExeCreateCurveBezierRational( nParentId, nDegree, vPntW, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCurveBezierFromArc( lua_State* L) { // 2 o 3 parametri : ParentId, ArcId[ , Erase] int nParentId ; LuaCheckParam( L, 1, nParentId) int nArcId ; LuaCheckParam( L, 2, nArcId) bool bErase = true ; LuaGetParam( L, 3, bErase) ; LuaClearStack( L) ; // creo la curva int nId = ExeCreateCurveBezierFromArc( nParentId, nArcId, bErase) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCurveBezierFromCurve( lua_State* L) { // 2 o 3 parametri : ParentId, nCrvId [, bRat] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId ; LuaCheckParam( L, 2, nCrvId) bool bRat = true ; LuaGetParam( L, 3, bRat) ; // creo la versione bezier della curva int nId = ExeCreateCurveBezierFromCurve( nParentId, nCrvId, bRat) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCurveCompo( lua_State* L) { // 2 o 3 parametri : ParentId, nIds [, Erase] int nParentId ; LuaCheckParam( L, 1, nParentId) INTVECTOR vIds ; LuaCheckParam( L, 2, vIds) bool bErase = true ; LuaGetParam( L, 3, bErase) ; LuaClearStack( L) ; // creo la curva composita int nId = ExeCreateCurveCompo( nParentId, vIds, bErase) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCurveCompoByChain( lua_State* L) { // 3 o 4 o 5 o 6 parametri : ParentId, nIds, PtNear [, Erase] [, nRefType] [, dToler] int nParentId ; LuaCheckParam( L, 1, nParentId) INTVECTOR vIds ; LuaCheckParam( L, 2, vIds) Point3d ptNear ; LuaCheckParam( L, 3, ptNear) bool bErase = true ; int nRefType = RTY_DEFAULT ; double dToler = 10 * EPS_SMALL ; if ( LuaGetParam( L, 4, bErase)) { LuaGetParam( L, 5, nRefType) ; LuaGetParam( L, 6, dToler) ; } else if ( LuaGetParam( L, 4, nRefType)) LuaGetParam( L, 5, dToler) ; else LuaGetParam( L, 4, dToler) ; LuaClearStack( L) ; // creo la curva composita int nCount = 0 ; int nId = ExeCreateCurveCompoByChainEx( nParentId, vIds, ptNear, bErase, nRefType, dToler, &nCount) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; LuaSetParam( L, nCount) ; return 2 ; } //------------------------------------------------------------------------------- static int LuaCreateCurveCompoByReorder( lua_State* L) { // 3 o 4 o 5 o 6 parametri : ParentId, nIds, PtNear [, Erase] [, nRefType] [, dToler] int nParentId ; LuaCheckParam( L, 1, nParentId) INTVECTOR vIds ; LuaCheckParam( L, 2, vIds) Point3d ptNear ; LuaCheckParam( L, 3, ptNear) bool bErase = true ; int nRefType = RTY_DEFAULT ; double dToler = 10 * EPS_SMALL ; if ( LuaGetParam( L, 4, bErase)) { LuaGetParam( L, 5, nRefType) ; LuaGetParam( L, 6, dToler) ; } else if ( LuaGetParam( L, 4, nRefType)) LuaGetParam( L, 5, dToler) ; else LuaGetParam( L, 4, dToler) ; LuaClearStack( L) ; // creo la curva composita int nCount = 0 ; int nId = ExeCreateCurveCompoByReorderEx( nParentId, vIds, ptNear, bErase, nRefType, dToler, &nCount) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; LuaSetParam( L, nCount) ; return 2 ; } //------------------------------------------------------------------------------- static int LuaCreateCurveCompoByInterpolation( lua_State* L) { // 3 o 4 parametri : ParentId, ptPs, nType [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) PNTVECTOR vPnt ; LuaCheckParam( L, 2, vPnt) int nType ; LuaGetParam( L, 3, nType) ; int nRefType = RTY_DEFAULT ; LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; PolyLine PL ; // creo una polilinea a partire dai punti for ( size_t i = 0 ; i < vPnt.size() ; ++ i) PL.AddUPoint( 0, vPnt[i]) ; // creo la curva composita int nId = ExeCreateCurveCompoByInterpolation( nParentId, PL, nType, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCurveCompoByApproximation( lua_State* L) { // 4 o 5 parametri : ParentId, ptPs, nType, dLinTol [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) PNTVECTOR vPnt ; LuaCheckParam( L, 2, vPnt) int nType ; LuaCheckParam( L, 3, nType) double dLinTol ; LuaCheckParam( L, 4, dLinTol) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; PolyLine PL ; // creo una polilinea a partire dai punti for ( size_t i = 0 ; i < vPnt.size() ; ++ i) PL.AddUPoint( 0, vPnt[i]) ; // creo la curva composita int nId = ExeCreateCurveCompoByApproximation( nParentId, PL, nType, dLinTol, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCurveCompoFromPoints( lua_State* L) { // 2 o 3 parametri : ParentId, ptPs [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) PNTVECTOR vPnt ; LuaCheckParam( L, 2, vPnt) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; PolyLine PL ; // creo una polilinea a partire dai punti for ( size_t i = 0 ; i < vPnt.size() ; ++ i) PL.AddUPoint( double( i), vPnt[i]) ; // creo la curva composita int nId = ExeCreateCurveCompoFromPoints( nParentId, PL, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCurveCompoFromPointBulges( lua_State* L) { // 2 o 3 parametri : ParentId, ptPBs [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) PNTUVECTOR vPntB ; LuaCheckParam( L, 2, vPntB) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; // creo un poliarco a partire dai punti con bulge PolyArc PA ; for ( size_t i = 0 ; i < vPntB.size() ; ++ i) PA.AddUPoint( double( i), vPntB[i].first, vPntB[i].second) ; // creo la curva composita int nId = ExeCreateCurveCompoFromPointBulges( nParentId, PA, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateRectangle2P( lua_State* L) { // 3 o 4 parametri : ParentId, PtIni, PtCross [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; LuaCheckParam( L, 2, ptIni) Point3d ptCross ; LuaCheckParam( L, 3, ptCross) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // creo il poligono int nId = ExeCreateRectangle2P( nParentId, ptIni, ptCross, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateRectangle3P( lua_State* L) { // 4 o 5 parametri : ParentId, PtIni, PtCross, PtDir [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; LuaCheckParam( L, 2, ptIni) Point3d ptCross ; LuaCheckParam( L, 3, ptCross) Point3d ptDir ; LuaCheckParam( L, 4, ptDir) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo il poligono int nId = ExeCreateRectangle3P( nParentId, ptIni, ptCross, ptDir, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreatePolygonFromRadius( lua_State* L) { // 4 o 5 parametri : ParentId, nNumSides, PtCen, PtCorn [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nNumSides ; LuaCheckParam( L, 2, nNumSides) Point3d PtCen ; LuaCheckParam( L, 3, PtCen) Point3d PtCorn ; LuaCheckParam( L, 4, PtCorn) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo il poligono int nId = ExeCreatePolygonFromRadius( nParentId, nNumSides, PtCen, PtCorn, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreatePolygonFromApothem( lua_State* L) { // 4 o 5 parametri : ParentId, nNumSides, PtCen, PtMid [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nNumSides ; LuaCheckParam( L, 2, nNumSides) Point3d PtCen ; LuaCheckParam( L, 3, PtCen) Point3d PtMid ; LuaCheckParam( L, 4, PtMid) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo il poligono int nId = ExeCreatePolygonFromApothem( nParentId, nNumSides, PtCen, PtMid, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreatePolygonFromSide( lua_State* L) { // 4 o 5 parametri : ParentId, nNumSides, PtIni, PtFin [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nNumSides ; LuaCheckParam( L, 2, nNumSides) Point3d ptIni ; LuaCheckParam( L, 3, ptIni) Point3d ptFin ; LuaCheckParam( L, 4, ptFin) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo il poligono int nId = ExeCreatePolygonFromSide( nParentId, nNumSides, ptIni, ptFin, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateCirclesAlongCurve( lua_State* L) { // 7 parametri : ParentId, nCrvId, dOffset, dOverlap, dStartAdd, dEndAdd, dDiam int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId ; LuaCheckParam( L, 2, nCrvId) double dOffset ; LuaCheckParam( L, 3, dOffset) double dOverlap ; LuaCheckParam( L, 4, dOverlap) double dStartAdd ; LuaCheckParam( L, 5, dStartAdd) double dEndAdd ; LuaCheckParam( L, 6, dEndAdd) double dDiam ; LuaCheckParam( L, 7, dDiam) LuaClearStack( L) ; // creo la curva composita int nCount = 0 ; int nId = ExeCreateCirclesAlongCurve( nParentId, nCrvId, dOffset, dOverlap, dStartAdd, dEndAdd, dDiam, &nCount) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; LuaSetParam( L, nCount) ; return 2 ; } //------------------------------------------------------------------------------- bool LuaInstallGdbCreateCurve( LuaMgr& luaMgr) { bool bOk = ( &luaMgr != nullptr) ; bOk = bOk && luaMgr.RegisterFunction( "EgtLine", LuaCreateLine) ; bOk = bOk && luaMgr.RegisterFunction( "EgtLineEx", LuaCreateLineEx) ; bOk = bOk && luaMgr.RegisterFunction( "EgtLinePDL", LuaCreateLinePDL) ; bOk = bOk && luaMgr.RegisterFunction( "EgtLinePVL", LuaCreateLinePVL) ; bOk = bOk && luaMgr.RegisterFunction( "EgtLineMinPointCurve", LuaCreateLineMinPointCurve) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCircle", LuaCreateCircle) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCircleCP", LuaCreateCircleCP) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCircleCPEx", LuaCreateCircleCPEx) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCircle2P", LuaCreateCircle2P) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCircle3P", LuaCreateCircle3P) ; bOk = bOk && luaMgr.RegisterFunction( "EgtArc", LuaCreateArc) ; bOk = bOk && luaMgr.RegisterFunction( "EgtArcCPA", LuaCreateArcCPA) ; bOk = bOk && luaMgr.RegisterFunction( "EgtArcC2P", LuaCreateArcC2P) ; bOk = bOk && luaMgr.RegisterFunction( "EgtArcC2PEx", LuaCreateArcC2PEx) ; bOk = bOk && luaMgr.RegisterFunction( "EgtArc3P", LuaCreateArc3P) ; bOk = bOk && luaMgr.RegisterFunction( "EgtArc2PR", LuaCreateArc2PR) ; bOk = bOk && luaMgr.RegisterFunction( "EgtArc2PB", LuaCreateArc2PB) ; bOk = bOk && luaMgr.RegisterFunction( "EgtArc2PD", LuaCreateArc2PD) ; bOk = bOk && luaMgr.RegisterFunction( "EgtArc2PDEx", LuaCreateArc2PDEx) ; bOk = bOk && luaMgr.RegisterFunction( "EgtArc2PV", LuaCreateArc2PV) ; bOk = bOk && luaMgr.RegisterFunction( "EgtBiArc", LuaCreateBiArc) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveFillet", LuaCreateCurveFillet) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveChamfer", LuaCreateCurveChamfer) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveBezier", LuaCreateCurveBezier) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveBezierRat", LuaCreateCurveBezierRational) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveBezierFromArc", LuaCreateCurveBezierFromArc) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveBezierFromCurve", LuaCreateCurveBezierFromCurve) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompo", LuaCreateCurveCompo) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoByChain", LuaCreateCurveCompoByChain) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoByReorder", LuaCreateCurveCompoByReorder) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoByInterpolation", LuaCreateCurveCompoByInterpolation) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoByApproximation", LuaCreateCurveCompoByApproximation) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoFromPoints", LuaCreateCurveCompoFromPoints) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoFromPointBulges", LuaCreateCurveCompoFromPointBulges) ; bOk = bOk && luaMgr.RegisterFunction( "EgtRectangle2P", LuaCreateRectangle2P) ; bOk = bOk && luaMgr.RegisterFunction( "EgtRectangle3P", LuaCreateRectangle3P) ; bOk = bOk && luaMgr.RegisterFunction( "EgtPolygonFromRadius", LuaCreatePolygonFromRadius) ; bOk = bOk && luaMgr.RegisterFunction( "EgtPolygonFromApothem", LuaCreatePolygonFromApothem) ; bOk = bOk && luaMgr.RegisterFunction( "EgtPolygonFromSide", LuaCreatePolygonFromSide) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCirclesAlongCurve", LuaCreateCirclesAlongCurve) ; return bOk ; }