68b003ec39
- a EgtAutomaticPackParts aggiunto parametro bGuillotineMode.
391 lines
12 KiB
C++
391 lines
12 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : API_Nesting.cpp Data : 31.07.15 Versione : 1.6g9
|
|
// Contenuto : Funzioni nesting per API.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 31.07.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "API.h"
|
|
#include "/EgtDev/Include/EInAPI.h"
|
|
#include "/EgtDev/Include/EXeExecutor.h"
|
|
|
|
using namespace std ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtCreateAdjustFlatParts( int nType, double dToler)
|
|
{
|
|
return ( ExeCreateAdjustFlatParts( nType, dToler) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtCreateFlatParts( int nType, double dToler)
|
|
{
|
|
return ( ExeCreateFlatParts( nType, dToler) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtAdjustFlatParts( void)
|
|
{
|
|
return ( ExeAdjustFlatParts() ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtAdjustFlatPart( int nPartId)
|
|
{
|
|
return ( ExeAdjustFlatPart( nPartId) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtAdjustFlatPartLayer( int nLayerId)
|
|
{
|
|
return ( ExeAdjustFlatPartLayer( nLayerId) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtCalcFlatPartUpRegion( int nPartId, BOOL bCalc)
|
|
{
|
|
return ( ExeCalcFlatPartUpRegion( nPartId, ( bCalc != FALSE)) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtCalcFlatPartDownRegion( int nPartId, double dH)
|
|
{
|
|
return ( ExeCalcFlatPartDownRegion( nPartId, dH) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtPackBox( int nId, double dXmin, double dYmin,
|
|
double dXmax, double dYmax, double dOffs, BOOL bBottomUp)
|
|
{
|
|
return ( ExePackBox( nId, dXmin, dYmin, dXmax, dYmax, dOffs, ( bBottomUp != FALSE)) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtPackBoxCluster( int nId[], int nCount, double dXmin, double dYmin,
|
|
double dXmax, double dYmax, double dOffs, BOOL bBottomUp)
|
|
{
|
|
// verifico
|
|
if ( nId == nullptr || nCount <= 0)
|
|
return FALSE ;
|
|
// riempio il vettore
|
|
INTVECTOR vIds ;
|
|
vIds.reserve( nCount) ;
|
|
for ( int i = 0 ; i < nCount ; ++ i)
|
|
vIds.push_back( nId[i]) ;
|
|
// eseguo
|
|
return ( ExePackBoxCluster( vIds, dXmin, dYmin, dXmax, dYmax, dOffs, bBottomUp != FALSE) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetClusterBBoxGlob( int nId[], int nCount, double ptMin[3], double ptMax[3])
|
|
{
|
|
// verifico
|
|
if ( nId == nullptr || nCount <= 0)
|
|
return FALSE ;
|
|
// riempio il vettore
|
|
INTVECTOR vIds ;
|
|
vIds.reserve( nCount) ;
|
|
for ( int i = 0 ; i < nCount ; ++ i)
|
|
vIds.push_back( nId[i]) ;
|
|
// recupero il bounding box dell'oggetto in globale
|
|
BBox3d b3Box ;
|
|
if ( ! ExeGetClusterBBoxGlob( vIds, b3Box))
|
|
return FALSE ;
|
|
// converto il risultato
|
|
VEC_FROM_3D( ptMin, b3Box.GetMin())
|
|
VEC_FROM_3D( ptMax, b3Box.GetMax())
|
|
return TRUE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtMoveBoxCluster( int nId[], int nCount, double vtMove[3],
|
|
double dXmin, double dYmin, double dXmax, double dYmax, double dOffs)
|
|
{
|
|
// verifico
|
|
if ( nId == nullptr || nCount <= 0)
|
|
return FALSE ;
|
|
// riempio il vettore
|
|
INTVECTOR vIds ;
|
|
vIds.reserve( nCount) ;
|
|
for ( int i = 0 ; i < nCount ; ++ i)
|
|
vIds.push_back( nId[i]) ;
|
|
// eseguo
|
|
Vector3d vtM = vtMove ;
|
|
if ( ! ExeMoveBoxCluster( vIds, vtM, dXmin, dYmin, dXmax, dYmax, dOffs))
|
|
return FALSE ;
|
|
VEC_FROM_3D( vtMove, vtM)
|
|
return TRUE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtCreateOutRegionRectangle( int nParentId,
|
|
double dXmin, double dYmin, double dXmax, double dYmax, double dZ)
|
|
{
|
|
return ( ExeCreateOutRegion( nParentId, dXmin, dYmin, dXmax, dYmax, dZ) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtCreateOutRegion( int nParentId, int nOutCrvId)
|
|
{
|
|
return ( ExeCreateOutRegion( nParentId, nOutCrvId) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtCreateReferenceRegion( int nParentId, int nOutCrvId, BOOL bBottomUp)
|
|
{
|
|
return ( ExeCreateReferenceRegion( nParentId, nOutCrvId, ( bBottomUp != FALSE)) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtCreateDamagedRegion( int nParentId, int nDmgCrvId)
|
|
{
|
|
return ( ExeCreateDamagedRegion( nParentId, nDmgCrvId) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtVerifyPartCluster( int nId[], int nCount, BOOL bReducedCut)
|
|
{
|
|
// verifico
|
|
if ( nId == nullptr || nCount <= 0)
|
|
return FALSE ;
|
|
// riempio il vettore
|
|
INTVECTOR vIds ;
|
|
vIds.reserve( nCount) ;
|
|
for ( int i = 0 ; i < nCount ; ++ i)
|
|
vIds.push_back( nId[i]) ;
|
|
// eseguo
|
|
if ( ! ExeVerifyPartCluster( vIds, ( bReducedCut != FALSE)))
|
|
return FALSE ;
|
|
return TRUE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtPackPartClusterInRectangle( int nId[], int nCount, BOOL bReducedCut, BOOL bBottomUp)
|
|
{
|
|
// verifico
|
|
if ( nId == nullptr || nCount <= 0)
|
|
return FALSE ;
|
|
// riempio il vettore
|
|
INTVECTOR vIds ;
|
|
vIds.reserve( nCount) ;
|
|
for ( int i = 0 ; i < nCount ; ++ i)
|
|
vIds.push_back( nId[i]) ;
|
|
// eseguo
|
|
if ( ! ExePackPartClusterInRectangle( vIds, ( bReducedCut != FALSE), ( bBottomUp != FALSE)))
|
|
return FALSE ;
|
|
return TRUE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtPackPartCluster( int nId[], int nCount, BOOL bReducedCut, BOOL bBottomUp)
|
|
{
|
|
// verifico
|
|
if ( nId == nullptr || nCount <= 0)
|
|
return FALSE ;
|
|
// riempio il vettore
|
|
INTVECTOR vIds ;
|
|
vIds.reserve( nCount) ;
|
|
for ( int i = 0 ; i < nCount ; ++ i)
|
|
vIds.push_back( nId[i]) ;
|
|
// eseguo
|
|
if ( ! ExePackPartCluster( vIds, ( bReducedCut != FALSE), ( bBottomUp != FALSE)))
|
|
return FALSE ;
|
|
return TRUE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtMovePartCluster( int nId[], int nCount, BOOL bReducedCut, double vtMove[3])
|
|
{
|
|
// verifico
|
|
if ( nId == nullptr || nCount <= 0)
|
|
return FALSE ;
|
|
// riempio il vettore
|
|
INTVECTOR vIds ;
|
|
vIds.reserve( nCount) ;
|
|
for ( int i = 0 ; i < nCount ; ++ i)
|
|
vIds.push_back( nId[i]) ;
|
|
// eseguo
|
|
Vector3d vtM = vtMove ;
|
|
if ( ! ExeMovePartCluster( vIds, ( bReducedCut != FALSE), vtM))
|
|
return FALSE ;
|
|
VEC_FROM_3D( vtMove, vtM)
|
|
return TRUE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtRotatePartCluster( int nId[], int nCount, BOOL bReducedCut, const double ptCen[3], double* pdRotAngDeg)
|
|
{
|
|
// verifico
|
|
if ( nId == nullptr || nCount <= 0 || pdRotAngDeg == nullptr)
|
|
return FALSE ;
|
|
// riempio il vettore
|
|
INTVECTOR vIds ;
|
|
vIds.reserve( nCount) ;
|
|
for ( int i = 0 ; i < nCount ; ++ i)
|
|
vIds.push_back( nId[i]) ;
|
|
// eseguo
|
|
if ( ! ExeRotatePartCluster( vIds, ( bReducedCut != FALSE), ptCen, *pdRotAngDeg))
|
|
return FALSE ;
|
|
return TRUE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtTgMovePartClusterOnCollision( int nId[], int nCount, BOOL bReducedCut, double vtMove[3])
|
|
{
|
|
// verifico
|
|
if ( nId == nullptr || nCount <= 0)
|
|
return FALSE ;
|
|
// riempio il vettore
|
|
INTVECTOR vIds ;
|
|
vIds.reserve( nCount) ;
|
|
for ( int i = 0 ; i < nCount ; ++ i)
|
|
vIds.push_back( nId[i]) ;
|
|
// eseguo
|
|
Vector3d vtM = vtMove ;
|
|
if ( ! ExeTgMovePartClusterOnCollision( vIds, ( bReducedCut != FALSE), vtM))
|
|
return FALSE ;
|
|
VEC_FROM_3D( vtMove, vtM)
|
|
return TRUE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtAlignPartClusterOnCollision( int nId[], int nCount, BOOL bReducedCut, BOOL* pbMoved)
|
|
{
|
|
// verifico
|
|
if ( nId == nullptr || nCount <= 0)
|
|
return FALSE ;
|
|
// riempio il vettore
|
|
INTVECTOR vIds ;
|
|
vIds.reserve( nCount) ;
|
|
for ( int i = 0 ; i < nCount ; ++ i)
|
|
vIds.push_back( nId[i]) ;
|
|
// eseguo
|
|
bool bMoved ;
|
|
if ( ! ExeAlignPartClusterOnCollision( vIds, ( bReducedCut != FALSE), bMoved))
|
|
return FALSE ;
|
|
if ( pbMoved != nullptr)
|
|
*pbMoved = bMoved ;
|
|
return TRUE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtMoveToSnapPointOnCollision( int nId[], int nCount, BOOL bReducedCut, double dMaxMove, BOOL* pbMoved)
|
|
{
|
|
// verifico
|
|
if ( nId == nullptr || nCount <= 0)
|
|
return FALSE ;
|
|
// riempio il vettore
|
|
INTVECTOR vIds ;
|
|
vIds.reserve( nCount) ;
|
|
for ( int i = 0 ; i < nCount ; ++ i)
|
|
vIds.push_back( nId[i]) ;
|
|
// eseguo
|
|
bool bMoved ;
|
|
if ( ! ExeMoveToSnapPointOnCollision( vIds, ( bReducedCut != FALSE), dMaxMove, bMoved))
|
|
return FALSE ;
|
|
if ( pbMoved != nullptr)
|
|
*pbMoved = ( bMoved ? TRUE : FALSE) ;
|
|
return TRUE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
__stdcall EgtSaveCollInfo( void)
|
|
{
|
|
ExeSaveCollInfo() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
__stdcall EgtRestoreCollInfo( void)
|
|
{
|
|
ExeRestoreCollInfo() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetPartClusterCenterGlob( int nId[], int nCount, double ptCen[3])
|
|
{
|
|
// verifico
|
|
if ( nId == nullptr || nCount <= 0 || ptCen == nullptr)
|
|
return FALSE ;
|
|
// riempio il vettore
|
|
INTVECTOR vIds ;
|
|
vIds.reserve( nCount) ;
|
|
for ( int i = 0 ; i < nCount ; ++ i)
|
|
vIds.push_back( nId[i]) ;
|
|
// eseguo
|
|
Point3d ptC ;
|
|
if ( ! ExeGetPartClusterCenterGlob( vIds, ptC))
|
|
return FALSE ;
|
|
VEC_FROM_3D( ptCen, ptC)
|
|
return TRUE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtAutomaticPackParts( int nId[], int nCount, BOOL bMinimizeOnXvsY, BOOL bReducedCut, BOOL bGuillotineMode, int nMaxTime)
|
|
{
|
|
// verifico
|
|
if ( nId == nullptr || nCount <= 0)
|
|
return FALSE ;
|
|
// riempio il vettore
|
|
INTVECTOR vIds ;
|
|
vIds.resize( nCount) ;
|
|
for ( int i = 0 ; i < nCount ; ++ i)
|
|
vIds[i] = nId[i] ;
|
|
// eseguo
|
|
bool bOk = ExeAutomaticPackParts( vIds, ( bMinimizeOnXvsY != FALSE), ( bReducedCut != FALSE), ( bGuillotineMode != FALSE), nMaxTime) ;
|
|
// aggiorno il vettore
|
|
for ( int i = 0 ; i < nCount ; ++ i)
|
|
nId[i] = vIds[i] ;
|
|
return ( bOk ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtVerifyMachining( int nMchId, int* pnResult)
|
|
{
|
|
if ( pnResult == nullptr)
|
|
return FALSE ;
|
|
return ( ExeVerifyMachining( nMchId, *pnResult) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
__stdcall EgtVerifyCutAsSplitting( int nMchId)
|
|
{
|
|
return ExeVerifyCutAsSplitting( nMchId) ;
|
|
}
|