EgtInterface 1.6d1 :
- aggiunte funzioni API e lua per creazione solidi standard - aggiunta funzione API e lua per grezzo - modificata creazione superficie rigata per gestire caso punto con curva.
This commit is contained in:
@@ -140,6 +140,7 @@ bool EgtInsertMachMgr( int nInsGrp) ;
|
||||
int EgtAddMachGroup( const std::string& sName, const std::string& sMachineName) ;
|
||||
bool EgtGetMachGroupName( int nMGroupInd, std::string& sName) ;
|
||||
bool EgtGetMachGroupInd( const std::string& sName, int& nInd) ;
|
||||
int EgtAddRawPart( Point3d ptOrig, double dWidth, double dLength, double dHeight, Color cCol) ;
|
||||
|
||||
//--------------------------- Scene ------------------------------------------
|
||||
bool EgtSetBackground( Color TopCol, Color BottomCol, bool bRedraw) ;
|
||||
|
||||
+271
-11
@@ -19,14 +19,233 @@
|
||||
#include "GeoTools.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EInConst.h"
|
||||
#include "/EgtDev/Include/EGkStmStandard.h"
|
||||
#include "/EgtDev/Include/EGkStmFromCurves.h"
|
||||
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
|
||||
#include "/EgtDev/Include/EgkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EgkCurveLocal.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTmBox( int nParentId, const double ptIni[3], const double ptCross[3],
|
||||
const double ptDir[3], double dHeight, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
|
||||
return GDB_ID_NULL ;
|
||||
// porto in locale i punti, i versori e il versore estrusione
|
||||
Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ;
|
||||
Point3d ptCrossL = GetPointLocal( pGeomDB, ptCross, nRefType, frLoc) ;
|
||||
Point3d ptDirL = GetPointLocal( pGeomDB, ptDir, nRefType, frLoc) ;
|
||||
// ne ricavo un riferimento intrinseco
|
||||
Frame3d frBox ;
|
||||
bOk = bOk && frBox.Set( ptIniL, ptDirL, ptCrossL) ;
|
||||
// ricavo le dimensioni della base
|
||||
Point3d ptCrossI = ptCrossL ;
|
||||
ptCrossI.ToLoc( frBox) ;
|
||||
double dWidth = ptCrossI.x ;
|
||||
double dLen = ptCrossI.y ;
|
||||
// creo il box nel suo riferimento intrinseco
|
||||
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshBox( fabs( dWidth), dLen, dHeight)) ;
|
||||
bOk = bOk && ! IsNull( pSTM) ;
|
||||
// eventuale traslazione per larghezza negativa
|
||||
if ( dWidth < 0)
|
||||
pSTM->Translate( Vector3d( dWidth, 0, 0)) ;
|
||||
// porto il box nel riferimento locale
|
||||
bOk = bOk && pSTM->ToGlob( frBox) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfTmBox(" + ToString( nParentId) + ",{" +
|
||||
ToString( Point3d( ptIni)) + "},{" +
|
||||
ToString( Point3d( ptCross)) + "},{" +
|
||||
ToString( Point3d( ptDir)) + "}," +
|
||||
ToString( dHeight) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTmPyramid( int nParentId, const double ptIni[3], const double ptCross[3],
|
||||
const double ptDir[3], double dHeight, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
|
||||
return GDB_ID_NULL ;
|
||||
// porto in locale i punti, i versori e il versore estrusione
|
||||
Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ;
|
||||
Point3d ptCrossL = GetPointLocal( pGeomDB, ptCross, nRefType, frLoc) ;
|
||||
Point3d ptDirL = GetPointLocal( pGeomDB, ptDir, nRefType, frLoc) ;
|
||||
// ne ricavo un riferimento intrinseco
|
||||
Frame3d frBox ;
|
||||
bOk = bOk && frBox.Set( ptIniL, ptDirL, ptCrossL) ;
|
||||
// ricavo le dimensioni della base
|
||||
Point3d ptCrossI = ptCrossL ;
|
||||
ptCrossI.ToLoc( frBox) ;
|
||||
double dWidth = ptCrossI.x ;
|
||||
double dLen = ptCrossI.y ;
|
||||
// creo la piramide nel suo riferimento intrinseco
|
||||
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshPyramid( fabs( dWidth), dLen, dHeight)) ;
|
||||
bOk = bOk && ! IsNull( pSTM) ;
|
||||
// eventuale traslazione per larghezza negativa
|
||||
if ( dWidth < 0)
|
||||
pSTM->Translate( Vector3d( dWidth, 0, 0)) ;
|
||||
// porto la piramide nel riferimento locale
|
||||
bOk = bOk && pSTM->ToGlob( frBox) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfTmPyramid(" + ToString( nParentId) + ",{" +
|
||||
ToString( Point3d( ptIni)) + "},{" +
|
||||
ToString( Point3d( ptCross)) + "},{" +
|
||||
ToString( Point3d( ptDir)) + "}," +
|
||||
ToString( dHeight) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTmCylinder( int nParentId, const double ptOrig[3], const double vtN[3],
|
||||
double dRad, double dHeight, double dLinTol, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// porto in locale il punto e il versore
|
||||
Point3d ptOrigL = GetPointLocal( pGeomDB, ptOrig, nRefType, frLoc) ;
|
||||
Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ;
|
||||
// calcolo riferimento OCS a partire da questo punto e versore
|
||||
Frame3d frCyl ;
|
||||
bOk = bOk && frCyl.Set( ptOrigL, vtNL) ;
|
||||
// creo il cilindro nel suo riferimento intrinseco
|
||||
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshCylinder( dRad, dHeight, dLinTol)) ;
|
||||
bOk = bOk && ! IsNull( pSTM) ;
|
||||
// porto il cilindro nel riferimento locale
|
||||
bOk = bOk && pSTM->ToGlob( frCyl) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfTmCylinder(" + ToString( nParentId) + ",{" +
|
||||
ToString( Point3d( ptOrig)) + "},{" +
|
||||
ToString( Vector3d( vtN)) + "}," +
|
||||
ToString( dRad) + "," +
|
||||
ToString( dHeight) + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTmCone( int nParentId, const double ptOrig[3], const double vtN[3],
|
||||
double dRad, double dHeight, double dLinTol, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// porto in locale il punto e il versore
|
||||
Point3d ptOrigL = GetPointLocal( pGeomDB, ptOrig, nRefType, frLoc) ;
|
||||
Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ;
|
||||
// calcolo riferimento OCS a partire da questo punto e versore
|
||||
Frame3d frCyl ;
|
||||
bOk = bOk && frCyl.Set( ptOrigL, vtNL) ;
|
||||
// creo il cono nel suo riferimento intrinseco
|
||||
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshCone( dRad, dHeight, dLinTol)) ;
|
||||
bOk = bOk && ! IsNull( pSTM) ;
|
||||
// porto il cono nel riferimento locale
|
||||
bOk = bOk && pSTM->ToGlob( frCyl) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfTmCone(" + ToString( nParentId) + ",{" +
|
||||
ToString( Point3d( ptOrig)) + "},{" +
|
||||
ToString( Vector3d( vtN)) + "}," +
|
||||
ToString( dRad) + "," +
|
||||
ToString( dHeight) + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTmSphere( int nParentId, const double ptOrig[3],
|
||||
double dRad, double dLinTol, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// porto in locale il punto
|
||||
Point3d ptOrigL = GetPointLocal( pGeomDB, ptOrig, nRefType, frLoc) ;
|
||||
// creo la sfera
|
||||
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshSphere( dRad, dLinTol)) ;
|
||||
bOk = bOk && ! IsNull( pSTM) ;
|
||||
// porto la sfera nella sua origine
|
||||
bOk = bOk && pSTM->Translate( ptOrig - ORIG) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfTmSphere(" + ToString( nParentId) + ",{" +
|
||||
ToString( Point3d( ptOrig)) + "}," +
|
||||
ToString( dRad) + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTmByFlatContour( int nParentId, int nCrvId, double dLinTol)
|
||||
@@ -320,7 +539,7 @@ __stdcall EgtCreateSurfTmByScrewing( int nParentId, int nCrvId,
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTmRuled( int nParentId, int nCrvId1, int nCrvId2, double dLinTol)
|
||||
__stdcall EgtCreateSurfTmRuled( int nParentId, int nPtOrCrvId1, int nPtOrCrvId2, double dLinTol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
@@ -328,22 +547,63 @@ __stdcall EgtCreateSurfTmRuled( int nParentId, int nCrvId1, int nCrvId2, double
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// recupero la prima curva in locale
|
||||
CurveLocal CrvLoc1( pGeomDB, nCrvId1, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc1.Get() != nullptr) ;
|
||||
// recupero la seconda curva in locale
|
||||
CurveLocal CrvLoc2( pGeomDB, nCrvId2, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc2.Get() != nullptr) ;
|
||||
// calcolo la superficie
|
||||
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshRuled( CrvLoc1.Get(), CrvLoc2.Get(), dLinTol) : nullptr) ;
|
||||
// creo la superficie trimesh
|
||||
ISurfTriMesh* pSTM = nullptr ;
|
||||
// se la prima entità è un punto e la seconda una curva
|
||||
if ( pGeomDB->GetGeoType( nPtOrCrvId1) == GEO_PNT3D &&
|
||||
( pGeomDB->GetGeoType( nPtOrCrvId2) & GEO_CURVE) != 0) {
|
||||
// recupero il punto in locale
|
||||
// recupero riferimento del punto
|
||||
Frame3d frPnt ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nPtOrCrvId1, frPnt) ;
|
||||
// porto il punto in locale
|
||||
Point3d ptP = GetGeoPoint3d( pGeomDB->GetGeoObj( nPtOrCrvId1))->GetPoint() ;
|
||||
bOk = bOk && ptP.LocToLoc( frPnt, frLoc) ;
|
||||
// recupero la curva in locale
|
||||
CurveLocal CrvLoc( pGeomDB, nPtOrCrvId2, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
|
||||
// calcolo la superficie
|
||||
pSTM = ( bOk ? GetSurfTriMeshRuled( ptP, CrvLoc.Get(), dLinTol) : nullptr) ;
|
||||
}
|
||||
// se la prima entità è una curva e la seconda un punto
|
||||
else if ( ( pGeomDB->GetGeoType( nPtOrCrvId1) & GEO_CURVE) != 0 &&
|
||||
pGeomDB->GetGeoType( nPtOrCrvId2) == GEO_PNT3D) {
|
||||
// recupero la curva in locale
|
||||
CurveLocal CrvLoc( pGeomDB, nPtOrCrvId1, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
|
||||
// recupero il punto in locale
|
||||
// recupero riferimento del punto
|
||||
Frame3d frPnt ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nPtOrCrvId2, frPnt) ;
|
||||
// porto il punto in locale
|
||||
Point3d ptP = GetGeoPoint3d( pGeomDB->GetGeoObj( nPtOrCrvId2))->GetPoint() ;
|
||||
bOk = bOk && ptP.LocToLoc( frPnt, frLoc) ;
|
||||
// calcolo la superficie
|
||||
pSTM = ( bOk ? GetSurfTriMeshRuled( ptP, CrvLoc.Get(), dLinTol) : nullptr) ;
|
||||
}
|
||||
// se entrambe curve
|
||||
else if ( ( pGeomDB->GetGeoType( nPtOrCrvId1) & GEO_CURVE) != 0 &&
|
||||
( pGeomDB->GetGeoType( nPtOrCrvId2) & GEO_CURVE) != 0) {
|
||||
// recupero la prima curva in locale
|
||||
CurveLocal CrvLoc1( pGeomDB, nPtOrCrvId1, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc1.Get() != nullptr) ;
|
||||
// recupero la seconda curva in locale
|
||||
CurveLocal CrvLoc2( pGeomDB, nPtOrCrvId2, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc2.Get() != nullptr) ;
|
||||
// calcolo la superficie
|
||||
pSTM = ( bOk ? GetSurfTriMeshRuled( CrvLoc1.Get(), CrvLoc2.Get(), dLinTol) : nullptr) ;
|
||||
}
|
||||
// altrimenti errore
|
||||
else
|
||||
bOk = false ;
|
||||
// inserisco la superficie trimesh nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ;
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfTmRuled(" + ToString( nParentId) + "," +
|
||||
ToString( nCrvId1) + "," +
|
||||
ToString( nCrvId2) + "," +
|
||||
ToString( nPtOrCrvId1) + "," +
|
||||
ToString( nPtOrCrvId2) + "," +
|
||||
ToString( dLinTol) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
|
||||
@@ -166,3 +166,13 @@ __stdcall EgtGetCurrMachGroup( int* pnInd)
|
||||
// reset macchinata corrente
|
||||
return ( pMachMgr->GetCurrMachGroup( *pnInd) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
EgtAddRawPart( Point3d ptOrig, double dWidth, double dLength, double dHeight, Color cCol)
|
||||
{
|
||||
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
||||
VERIFY_MACHMGR( pMachMgr, false)
|
||||
// inserisco grezzo nella macchinata corrente
|
||||
return pMachMgr->AddRawPart( ptOrig, dWidth, dLength, dHeight, cCol) ;
|
||||
}
|
||||
|
||||
Binary file not shown.
+159
-6
@@ -27,6 +27,154 @@ using namespace std ;
|
||||
//-------------------------------------------------------------------------------
|
||||
static const double LIN_TOL_DEF = 0.05 ;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfTmBox( lua_State* L)
|
||||
{
|
||||
// 5 o 6 parametri : ParentId, PtIni, PtCross, PtDir, dHeight [, sRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptIni ;
|
||||
LuaCheckParam( L, 2, ptIni)
|
||||
Point3d ptCross ;
|
||||
LuaCheckParam( L, 3, ptCross)
|
||||
Point3d ptDir ;
|
||||
LuaCheckParam( L, 4, ptDir)
|
||||
double dHeight ;
|
||||
LuaCheckParam( L, 5, dHeight)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetRefType( L, 6, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM cilindro
|
||||
int nId = EgtCreateSurfTmBox( nParentId, ptIni.v, ptCross.v, ptDir.v, dHeight, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfTmPyramid( lua_State* L)
|
||||
{
|
||||
// 5 o 6 parametri : ParentId, PtIni, PtCross, PtDir, dHeight [, sRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptIni ;
|
||||
LuaCheckParam( L, 2, ptIni)
|
||||
Point3d ptCross ;
|
||||
LuaCheckParam( L, 3, ptCross)
|
||||
Point3d ptDir ;
|
||||
LuaCheckParam( L, 4, ptDir)
|
||||
double dHeight ;
|
||||
LuaCheckParam( L, 5, dHeight)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetRefType( L, 6, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM cilindro
|
||||
int nId = EgtCreateSurfTmPyramid( nParentId, ptIni.v, ptCross.v, ptDir.v, dHeight, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfTmCylinder( lua_State* L)
|
||||
{
|
||||
// 5 o 6 o 7 parametri : ParentId, PtOrig, vtN, dRad, dHeight [, dTol] [, sRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptOrig ;
|
||||
LuaCheckParam( L, 2, ptOrig)
|
||||
Vector3d vtN ;
|
||||
LuaCheckParam( L, 3, vtN)
|
||||
double dRad ;
|
||||
LuaCheckParam( L, 4, dRad)
|
||||
double dHeight ;
|
||||
LuaCheckParam( L, 5, dHeight)
|
||||
double dLinTol = LIN_TOL_DEF ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
if ( LuaGetParam( L, 6, dLinTol))
|
||||
LuaGetRefType( L, 7, nRefType) ;
|
||||
else
|
||||
LuaGetRefType( L, 6, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM cilindro
|
||||
int nId = EgtCreateSurfTmCylinder( nParentId, ptOrig.v, vtN.v, dRad, dHeight, dLinTol, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfTmCone( lua_State* L)
|
||||
{
|
||||
// 5 o 6 o 7 parametri : ParentId, PtOrig, vtN, dRad, dHeight [, dTol] [, sRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptOrig ;
|
||||
LuaCheckParam( L, 2, ptOrig)
|
||||
Vector3d vtN ;
|
||||
LuaCheckParam( L, 3, vtN)
|
||||
double dRad ;
|
||||
LuaCheckParam( L, 4, dRad)
|
||||
double dHeight ;
|
||||
LuaCheckParam( L, 5, dHeight)
|
||||
double dLinTol = LIN_TOL_DEF ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
if ( LuaGetParam( L, 6, dLinTol))
|
||||
LuaGetRefType( L, 7, nRefType) ;
|
||||
else
|
||||
LuaGetRefType( L, 6, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM cilindro
|
||||
int nId = EgtCreateSurfTmCone( nParentId, ptOrig.v, vtN.v, dRad, dHeight, dLinTol, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfTmSphere( lua_State* L)
|
||||
{
|
||||
// 3 o 4 o 5 parametri : ParentId, PtOrig, dRad [, dTol] [, sRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptOrig ;
|
||||
LuaCheckParam( L, 2, ptOrig)
|
||||
double dRad ;
|
||||
LuaCheckParam( L, 3, dRad)
|
||||
double dLinTol = LIN_TOL_DEF ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
if ( LuaGetParam( L, 4, dLinTol))
|
||||
LuaGetRefType( L, 5, nRefType) ;
|
||||
else
|
||||
LuaGetRefType( L, 4, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM cilindro
|
||||
int nId = EgtCreateSurfTmSphere( nParentId, ptOrig.v, dRad, dLinTol, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfTmByFlatContour( lua_State* L)
|
||||
@@ -200,19 +348,19 @@ LuaCreateSurfTmByScrewing( lua_State* L)
|
||||
static int
|
||||
LuaCreateSurfTmRuled( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : ParentId, CrvId1, CrvId2, [, dTol]
|
||||
// 3 o 4 parametri : ParentId, PtOrCrvId1, PtOrCrvId2, [, dTol]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nCrvId1 ;
|
||||
LuaCheckParam( L, 2, nCrvId1)
|
||||
int nCrvId2 ;
|
||||
LuaCheckParam( L, 3, nCrvId2)
|
||||
int nPtOrCrvId1 ;
|
||||
LuaCheckParam( L, 2, nPtOrCrvId1)
|
||||
int nPtOrCrvId2 ;
|
||||
LuaCheckParam( L, 3, nPtOrCrvId2)
|
||||
double dLinTol = LIN_TOL_DEF ;
|
||||
if ( lua_gettop( L) >= 4)
|
||||
LuaCheckParam( L, 4, dLinTol) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM riempiendo un contorno piano
|
||||
int nId = EgtCreateSurfTmRuled( nParentId, nCrvId1, nCrvId2, dLinTol) ;
|
||||
int nId = EgtCreateSurfTmRuled( nParentId, nPtOrCrvId1, nPtOrCrvId2, dLinTol) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
@@ -272,6 +420,11 @@ bool
|
||||
LuaInstallGdbCreateSurf( void)
|
||||
{
|
||||
bool bOk = true ;
|
||||
bOk = bOk && LuaRegisterFunction( "EgtSurfTmBox", LuaCreateSurfTmBox) ;
|
||||
bOk = bOk && LuaRegisterFunction( "EgtSurfTmPyramid", LuaCreateSurfTmPyramid) ;
|
||||
bOk = bOk && LuaRegisterFunction( "EgtSurfTmCylinder", LuaCreateSurfTmCylinder) ;
|
||||
bOk = bOk && LuaRegisterFunction( "EgtSurfTmCone", LuaCreateSurfTmCone) ;
|
||||
bOk = bOk && LuaRegisterFunction( "EgtSurfTmSphere", LuaCreateSurfTmSphere) ;
|
||||
bOk = bOk && LuaRegisterFunction( "EgtSurfTmByFlatContour", LuaCreateSurfTmByFlatContour) ;
|
||||
bOk = bOk && LuaRegisterFunction( "EgtSurfTmByRegion", LuaCreateSurfTmByRegion) ;
|
||||
bOk = bOk && LuaRegisterFunction( "EgtSurfTmByExtrusion", LuaCreateSurfTmByExtrusion) ;
|
||||
|
||||
@@ -150,6 +150,32 @@ LuaGetCurrMachGroup( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaAddRawPart( lua_State* L)
|
||||
{
|
||||
// 5 parametri : Pto origine, dWidth, dLen, dH, Color
|
||||
Point3d ptOrig ;
|
||||
LuaCheckParam( L, 1, ptOrig)
|
||||
double dWidth ;
|
||||
LuaCheckParam( L, 2, dWidth)
|
||||
double dLength ;
|
||||
LuaCheckParam( L, 3, dLength)
|
||||
double dHeight ;
|
||||
LuaCheckParam( L, 4, dHeight)
|
||||
Color cCol ;
|
||||
LuaCheckParam( L, 5, cCol)
|
||||
LuaClearStack( L) ;
|
||||
// inserisco il grezzo nella macchinata corrente
|
||||
int nInd = EgtAddRawPart( ptOrig, dWidth, dLength, dHeight, cCol) ;
|
||||
// restituisco il risultato
|
||||
if ( nInd != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nInd) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallMachMgr( void)
|
||||
@@ -163,5 +189,6 @@ LuaInstallMachMgr( void)
|
||||
bOk = bOk && LuaRegisterFunction( "EgtSetCurrMachGroup", LuaSetCurrMachGroup) ;
|
||||
bOk = bOk && LuaRegisterFunction( "EgtResetCurrMachGroup", LuaResetCurrMachGroup) ;
|
||||
bOk = bOk && LuaRegisterFunction( "EgtGetCurrMachGroup", LuaGetCurrMachGroup) ;
|
||||
bOk = bOk && LuaRegisterFunction( "EgtAddRawPart", LuaAddRawPart) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user