Files
EgtInterface/API_Nesting.cpp
T
Dario Sassi e538b3067d EgtInterface 1.6l8 :
- aggiornamento interfaccia per nesting.
2016-01-14 17:36:55 +00:00

273 lines
8.9 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 EgtCreateFlatParts( int nType)
{
return ( ExeCreateFlatParts( nType) ? 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 EgtVerifyPartCluster( int nId[], int nCount, BOOL bReducedCut,
double dXmin, double dYmin, double dXmax, double dYmax)
{
// 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), dXmin, dYmin,dXmax, dYmax))
return FALSE ;
return TRUE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtPackPartCluster( int nId[], int nCount, BOOL bReducedCut,
double dXmin, double dYmin, double dXmax, double dYmax, 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), dXmin, dYmin,dXmax, dYmax, ( bBottomUp != FALSE)))
return FALSE ;
return TRUE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtMovePartCluster( int nId[], int nCount, BOOL bReducedCut, double vtMove[3],
double dXmin, double dYmin, double dXmax, double dYmax)
{
// 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, dXmin, dYmin, dXmax, dYmax))
return FALSE ;
VEC_FROM_3D( vtMove, vtM)
return TRUE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtRotatePartCluster( int nId[], int nCount, BOOL bReducedCut, const double ptCen[3], double* pdRotAngDeg,
double dXmin, double dYmin, double dXmax, double dYmax)
{
// 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, dXmin, dYmin, dXmax, dYmax))
return FALSE ;
return TRUE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtTgMovePartClusterOnCollision( int nId[], int nCount, BOOL bReducedCut, double vtMove[3],
double dXmin, double dYmin, double dXmax, double dYmax)
{
// 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, dXmin, dYmin, dXmax, dYmax))
return FALSE ;
VEC_FROM_3D( vtMove, vtM)
return TRUE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtAlignPartClusterOnCollision( int nId[], int nCount, BOOL bReducedCut,
double dXmin, double dYmin, double dXmax, double dYmax, 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), dXmin, dYmin, dXmax, dYmax, bMoved))
return FALSE ;
if ( pbMoved != nullptr)
*pbMoved = bMoved ;
return TRUE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtMoveToSnapPointOnCollision( int nId[], int nCount, BOOL bReducedCut, double dMaxMove,
double dXmin, double dYmin, double dXmax, double dYmax, 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, dXmin, dYmin, dXmax, dYmax, bMoved))
return FALSE ;
if ( pbMoved != nullptr)
*pbMoved = bMoved ;
return TRUE ;
}
//-----------------------------------------------------------------------------
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 ;
}
//-----------------------------------------------------------------------------
void
__stdcall EgtSaveCollInfo( void)
{
ExeSaveCollInfo() ;
}
//-----------------------------------------------------------------------------
void
__stdcall EgtRestoreCollInfo( void)
{
ExeRestoreCollInfo() ;
}