EgtExecutor 1.9b1 :

- aggiunta funzione Exe e Lua VolZmapAvoidSphere
- aggiunta funzione Lua EgtSetCurrFilePath
- modifiche per pezzi piani nesting con bordi con due tagli sovrapposti a diversa inclinazione.
This commit is contained in:
Dario Sassi
2018-02-05 07:16:03 +00:00
parent f3f16af29f
commit b64ac4314d
8 changed files with 206 additions and 10 deletions
+5
View File
@@ -28,6 +28,7 @@ const std::string CRV_ORIG = "ORIG" ;
// Per FlatParts (Nesting)
const std::string NST_PARTREG_LAYER = "Region" ;
const std::string NST_PARTUPREG_LAYER = "UpReg" ;
const std::string NST_PARTDOWNREG_LAYER = "DwnReg" ;
const std::string NST_EXT_LAYER = "OutLoop" ;
const std::string NST_EXT_ORIG_LAYER = "OutLoop.orig" ;
@@ -35,6 +36,10 @@ const std::string NST_IN_LAYER = "InLoop" ;
const std::string NST_ON_LAYER = "OnPath" ;
const std::string NST_KEY_SIDEANG = "SideAng" ;
const std::string NST_KEY_OFFSET = "Offset" ;
const std::string NST_KEY_DEPTH = "Depth" ;
const std::string NST_KEY_SIDEANG2 = "SideAng2" ;
const std::string NST_KEY_OFFSET2 = "Offset2" ;
const std::string NST_KEY_DEPTH2 = "Depth2" ;
// Per Sheets (Nesting)
const std::string NST_SHEET_OUTREG = "SheetOut" ;
+28 -2
View File
@@ -476,7 +476,6 @@ ExeVolZmapAvoidBox( int nId, const Frame3d& frBox, const Vector3d& vtDiag, int n
// recupero lo Zmap e calcolo collisione
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
bOk = bOk && ( pVZM != nullptr && pVZM->AvoidBox( frBoxL, vtDiag)) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtVolZmapAvoidBox(" + IdToString( nId) + ",{" +
@@ -491,4 +490,31 @@ ExeVolZmapAvoidBox( int nId, const Frame3d& frBox, const Vector3d& vtDiag, int n
}
// restituisco risultato
return bOk ;
}
}
//----------------------------------------------------------------------------
bool
ExeVolZmapAvoidSphere( int nId, const Point3d& ptCen, double dRad, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero il riferimento locale
Frame3d frLoc ;
bool bOk = pGeomDB->GetGlobFrame( nId, frLoc) ;
// porto in locale il centro della sfera
Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frLoc) ;
// recupero lo Zmap e calcolo collisione
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
bOk = bOk && ( pVZM != nullptr && pVZM->AvoidSphere( ptCenL, dRad)) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtVolZmapAvoidSphere(" + IdToString( nId) + ",{" +
ToString( ptCen) + "}," +
ToString( dRad) + "," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return bOk ;
}
+1
View File
@@ -17,6 +17,7 @@ class IGeomDB ;
//----------------------------------------------------------------------------
int GetFlatPartRegion( IGeomDB* pGeomDB, int nId) ;
int GetFlatPartUpRegion( IGeomDB* pGeomDB, int nId) ;
int GetFlatPartDownRegion( IGeomDB* pGeomDB, int nId) ;
bool GetFlatPartCutRegions( IGeomDB* pGeomDB, int nId, bool bReduced, INTVECTOR& vCrId) ;
bool GetFlatPartDownCutRegions( IGeomDB* pGeomDB, int nId, bool bReduced, INTVECTOR& vCrId) ;
+128 -4
View File
@@ -818,6 +818,113 @@ AdjustCurves( ICurve* pCrv1, ICurve* pCrv2)
return ( pCrv1->ModifyEnd( ptNew) && pCrv2->ModifyStart( ptNew)) ;
}
//----------------------------------------------------------------------------
bool
ExeCalcFlatPartUpRegion( int nPartId, bool bCalc)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// ripristino lo stato originale
pGeomDB->Erase( pGeomDB->GetFirstNameInGroup( nPartId, NST_PARTUPREG_LAYER)) ;
// se non richiesto calcolo, non devo fare altro
if ( ! bCalc)
return true ;
// recupero il layer esterno
int nOlId = pGeomDB->GetFirstNameInGroup( nPartId, NST_EXT_LAYER) ;
if ( nOlId == GDB_ID_NULL)
return false ;
// se il pezzo non ha lati esterni con offset negativo non devo fare alcunchè
bool bAllFixSides = true ;
int nCrvId = pGeomDB->GetFirstInGroup( nOlId) ;
while ( nCrvId != GDB_ID_NULL) {
double dOffset, dOffset2 ;
if ( ( pGeomDB->GetInfo( nCrvId, NST_KEY_OFFSET, dOffset) && dOffset < - EPS_SMALL) ||
( pGeomDB->GetInfo( nCrvId, NST_KEY_OFFSET2, dOffset2) && dOffset2 < - EPS_SMALL)) {
bAllFixSides = false ;
break ;
}
nCrvId = pGeomDB->GetNext( nCrvId) ;
}
if ( bAllFixSides)
return true ;
// creo il layer per la regione sopra (con il medesimo riferimento del layer esterno)
Frame3d frOl ;
pGeomDB->GetGroupFrame( nOlId, frOl) ;
int nUpRegId = pGeomDB->AddGroup( GDB_ID_NULL, nPartId, frOl) ;
if ( nUpRegId == GDB_ID_NULL)
return false ;
pGeomDB->SetName( nUpRegId, NST_PARTUPREG_LAYER) ;
// copio le entità del contorno esterno e le offsetto opportunamente
nCrvId = pGeomDB->GetFirstInGroup( nOlId) ;
while ( nCrvId != GDB_ID_NULL) {
// copio la curva nel gruppo temporaneo
int nNewId = pGeomDB->CopyGlob( nCrvId, GDB_ID_NULL, nUpRegId) ;
if ( nNewId == GDB_ID_NULL)
return false ;
// determino ed eseguo offset
double dOffset, dOffset2 ;
if ( ( pGeomDB->GetInfo( nCrvId, NST_KEY_OFFSET, dOffset) && dOffset < - EPS_SMALL) ||
( pGeomDB->GetInfo( nCrvId, NST_KEY_OFFSET2, dOffset2) && dOffset2 < - EPS_SMALL)) {
double dCalcOffset = min( dOffset, dOffset2) ;
ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nNewId)) ;
if ( pCrv == nullptr)
return false ;
pCrv->SimpleOffset( dCalcOffset) ;
}
// passo alla successiva
nCrvId = pGeomDB->GetNext( nCrvId) ;
}
// aggiusto tra loro le entità offsettate
int nFirstCrvId = pGeomDB->GetFirstInGroup( nUpRegId) ;
ICurve* pCrv1 = GetCurve( pGeomDB->GetGeoObj( nFirstCrvId)) ;
int nNextCrvId = pGeomDB->GetNext( nFirstCrvId) ;
ICurve* pCrv2 = GetCurve( pGeomDB->GetGeoObj( nNextCrvId)) ;
while ( nNextCrvId != GDB_ID_NULL) {
// sistemo le curve
pCrv2 = GetCurve( pGeomDB->GetGeoObj( nNextCrvId)) ;
if ( pCrv1 == nullptr || pCrv2 == nullptr || ! AdjustCurves( pCrv1, pCrv2))
return false ;
// passo alla successiva
pCrv1 = pCrv2 ;
nNextCrvId = pGeomDB->GetNext( nNextCrvId) ;
}
// anche prima e ultima
pCrv2 = GetCurve( pGeomDB->GetGeoObj( nFirstCrvId)) ;
if ( pCrv1 == nullptr || pCrv2 == nullptr || ! AdjustCurves( pCrv1, pCrv2))
return false ;
// creo la regione
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
if ( IsNull( pCompo))
return false ;
for ( int nCrvId = pGeomDB->GetFirstInGroup( nUpRegId) ;
nCrvId != GDB_ID_NULL ;
nCrvId = pGeomDB->GetFirstInGroup( nUpRegId)) {
ICurve* pCrv = GetCurve( pGeomDB->RemoveGeoObjAndErase( nCrvId)) ;
if ( pCrv != nullptr) {
pCompo->AddCurve( pCrv) ;
pGeomDB->RemoveGeoObjAndErase( nCrvId) ;
}
else
pGeomDB->Erase( nCrvId) ;
}
SurfFlatRegionByContours SfrCntr( false) ;
SfrCntr.AddCurve( Release( pCompo)) ;
int nSfrId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nUpRegId, GDB_FIRST_SON, SfrCntr.GetSurf()) ;
if ( nSfrId == GDB_ID_NULL)
return false ;
// assegno il colore
Color cCol = AQUA ;
cCol.SetAlpha( 0.25) ;
pGeomDB->SetMaterial( nSfrId, cCol) ;
return true ;
}
//----------------------------------------------------------------------------
bool
ExeCalcFlatPartDownRegion( int nPartId, double dH)
@@ -831,9 +938,9 @@ ExeCalcFlatPartDownRegion( int nPartId, double dH)
if ( nOlOrigId != GDB_ID_NULL) {
pGeomDB->Erase( pGeomDB->GetFirstNameInGroup( nPartId, NST_EXT_LAYER)) ;
pGeomDB->SetName( nOlOrigId, NST_EXT_LAYER) ;
pGeomDB->SetStatus( nOlOrigId, GDB_ST_ON) ;
pGeomDB->SetStatus( nOlOrigId, GDB_ST_ON) ;
}
// se spessore nullo, non devo fare alcunché
// se spessore nullo, non devo fare altro
if ( dH < EPS_SMALL)
return true ;
// recupero il layer esterno
@@ -1000,7 +1107,7 @@ GetFlatPartRegion( IGeomDB* pGeomDB, int nId)
{
if ( pGeomDB == nullptr)
return GDB_ID_NULL ;
// recupero regione del pezzo (è la prima del sottogruppo di nome Region)
// recupero regione totale del pezzo (è la prima del sottogruppo di nome Region)
int nRegGrp = pGeomDB->GetFirstNameInGroup( nId, NST_PARTREG_LAYER) ;
int nRegId = pGeomDB->GetFirstInGroup( nRegGrp) ;
while ( nRegId != GDB_ID_NULL) {
@@ -1011,13 +1118,30 @@ GetFlatPartRegion( IGeomDB* pGeomDB, int nId)
return nRegId ;
}
//----------------------------------------------------------------------------
int
GetFlatPartUpRegion( IGeomDB* pGeomDB, int nId)
{
if ( pGeomDB == nullptr)
return GDB_ID_NULL ;
// recupero regione sopra del pezzo (è la prima del sottogruppo di nome UpReg)
int nRegGrp = pGeomDB->GetFirstNameInGroup( nId, NST_PARTUPREG_LAYER) ;
int nRegId = pGeomDB->GetFirstInGroup( nRegGrp) ;
while ( nRegId != GDB_ID_NULL) {
if ( pGeomDB->GetGeoType( nRegId) == SRF_FLATRGN)
break ;
nRegId = pGeomDB->GetNext( nRegId) ;
}
return nRegId ;
}
//----------------------------------------------------------------------------
int
GetFlatPartDownRegion( IGeomDB* pGeomDB, int nId)
{
if ( pGeomDB == nullptr)
return GDB_ID_NULL ;
// recupero regione del pezzo (è la prima del sottogruppo di nome DwnReg)
// recupero regione sotto del pezzo (è la prima del sottogruppo di nome DwnReg)
int nRegGrp = pGeomDB->GetFirstNameInGroup( nId, NST_PARTDOWNREG_LAYER) ;
int nRegId = pGeomDB->GetFirstInGroup( nRegGrp) ;
while ( nRegId != GDB_ID_NULL) {
+4 -2
View File
@@ -118,8 +118,10 @@ ExeVerifyMachining( int nMchId, int& nResult)
BBox3d b3Part ;
if ( pGeomDB->GetGlobalBBox( nId, b3Part, BBF_PART_MY_FLAG) &&
b3Mch.OverlapsXY( b3Part)) {
// recupero regione del pezzo
int nRegId = GetFlatPartRegion( pGeomDB, nId) ;
// recupero eventuale regione sopra del pezzo oppure regione del pezzo
int nRegId = GetFlatPartUpRegion( pGeomDB, nId) ;
if ( nRegId == GDB_ID_NULL)
nRegId = GetFlatPartRegion( pGeomDB, nId) ;
if ( nRegId != GDB_ID_NULL)
vOthReg.emplace_back( nRegId) ;
else
BIN
View File
Binary file not shown.
+23 -1
View File
@@ -337,13 +337,34 @@ LuaVolZmapAvoidBox( lua_State* L)
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 4, nRefType) ;
LuaClearStack( L) ;
// eseguo calcolo profondità dal punto lungo la direzione
// verifico non interferenza
bool bOk = ExeVolZmapAvoidBox( nId, frBox, vtDiag, nRefType) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaVolZmapAvoidSphere( lua_State* L)
{
// 3 o 4 parametri : nId, ptCen, dRad [, nRefType]
int nId ;
LuaCheckParam( L, 1, nId)
Point3d ptCen ;
LuaCheckParam( L, 2, ptCen)
double dRad ;
LuaCheckParam( L, 3, dRad)
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 4, nRefType) ;
LuaClearStack( L) ;
// verifico non interferenza
bool bOk = ExeVolZmapAvoidSphere( nId, ptCen, dRad, nRefType) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallGdbModifyVol( LuaMgr& luaMgr)
@@ -361,6 +382,7 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetDepth", LuaVolZmapGetDepth) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapIntersPlane", LuaVolZmapIntersPlane) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapAvoidBox", LuaVolZmapAvoidBox) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapAvoidSphere", LuaVolZmapAvoidSphere) ;
return bOk ;
}
+17 -1
View File
@@ -114,7 +114,7 @@ LuaSetGridFrame( lua_State* L)
LuaCheckParam( L, 1, frFrame) ;
LuaClearStack( L) ;
// imposto il riferimento della Griglia (o CPlane)
bool bOk = ( ExeSetGridFrame( frFrame)) ;
bool bOk = ExeSetGridFrame( frFrame) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
@@ -155,6 +155,21 @@ LuaGetGridVersZ( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSetCurrFilePath( lua_State* L)
{
// 1 parametro : sFilePath
string sFilePath ;
LuaCheckParam( L, 1, sFilePath)
LuaClearStack( L) ;
// imposto la path del file corrente
bool bOk = ExeSetCurrFilePath( sFilePath) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetCurrFilePath( lua_State* L)
@@ -319,6 +334,7 @@ LuaInstallGeomDB( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtSetGridFrame", LuaSetGridFrame) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetGridFrame", LuaGetGridFrame) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetGridVersZ", LuaGetGridVersZ) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetCurrFilePath", LuaSetCurrFilePath) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetCurrFilePath", LuaGetCurrFilePath) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtEnableModified", LuaEnableModified) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtDisableModified", LuaDisableModified) ;