Merge branch 'master' into Trimming
This commit is contained in:
+23
-10
@@ -2038,7 +2038,7 @@ ExeCreateSurfBezierRational( int nParentId, int nDegU, int nDegV, int nSpanU, in
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBezierLeaves( int nParentId, int nSurfBzId, int nTextHeight, bool bShowTrim, int* pnCount)
|
||||
ExeCreateSurfBezierLeaves( int nParentId, int nSurfBzId, int nTextHeight, bool bShowTrim, bool bRefined, int* pnCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
@@ -2049,7 +2049,7 @@ ExeCreateSurfBezierLeaves( int nParentId, int nSurfBzId, int nTextHeight, bool b
|
||||
return GDB_ID_NULL ;
|
||||
// disegno le foglie
|
||||
vector<tuple<int,Point3d,Point3d>> vLeaves ;
|
||||
pSurfBez->GetLeaves( vLeaves) ;
|
||||
pSurfBez->GetLeaves( vLeaves, bRefined) ;
|
||||
double dFactor = 1 ;
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
int nCount = 0 ;
|
||||
@@ -2770,7 +2770,7 @@ ExeCreateSurfBzRuled( int nParentId, int nCrvId1, int nCrvId2, int nRuledType, b
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBzRuledGuided( int nParentId, int nCrvId1, int nCrvId2, int nLayGuides, bool bCapEnds, double dLinTol)
|
||||
ExeCreateSurfBzRuledGuided( int nParentId, int nCrvId1, int nCrvId2, const BIPNTVECTOR& vGuidesCrv, bool bCapEnds, double dLinTol, int nLayGuides)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
@@ -2784,14 +2784,27 @@ ExeCreateSurfBzRuledGuided( int nParentId, int nCrvId1, int nCrvId2, int nLayGui
|
||||
bOk = bOk && ( CrvLoc1.Get() != nullptr) ;
|
||||
CurveLocal CrvLoc2( pGeomDB, nCrvId2, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc2.Get() != nullptr) ;
|
||||
ICURVEPOVECTOR vCrv ;
|
||||
int nId = pGeomDB->GetFirstInGroup( nLayGuides) ;
|
||||
while( nId != GDB_ID_NULL && bOk) {
|
||||
CurveLocal CrvLocGuide( pGeomDB, nId, frLoc) ;
|
||||
bOk = bOk && ( CrvLocGuide.Get() != nullptr) ;
|
||||
vCrv.emplace_back( CrvLocGuide.Get()->Clone()) ;
|
||||
nId = pGeomDB->GetNext( nId) ;
|
||||
BIPNTVECTOR vCrv ;
|
||||
if( nLayGuides != -1 && vGuidesCrv.empty()) {
|
||||
int nId = pGeomDB->GetFirstInGroup( nLayGuides) ;
|
||||
while( nId != GDB_ID_NULL && bOk) {
|
||||
CurveLocal CrvLocGuide( pGeomDB, nId, frLoc) ;
|
||||
bOk = bOk && ( CrvLocGuide.Get() != nullptr) ;
|
||||
const ICurve* pCrv = CrvLocGuide.Get() ;
|
||||
Point3d ptStart ; pCrv->GetStartPoint( ptStart) ;
|
||||
ptStart.ToLoc( frLoc) ;
|
||||
Point3d ptEnd ; pCrv->GetEndPoint( ptEnd) ;
|
||||
ptEnd.ToLoc( frLoc) ;
|
||||
vCrv.emplace_back( ptStart, ptEnd) ;
|
||||
nId = pGeomDB->GetNext( nId) ;
|
||||
}
|
||||
}
|
||||
else if( ! vGuidesCrv.empty()) {
|
||||
for( int i = 0 ; i < ssize( vGuidesCrv) ; ++i)
|
||||
vCrv.emplace_back( GetToLoc( vGuidesCrv[i].first, frLoc), GetToLoc( vGuidesCrv[i].second, frLoc)) ;
|
||||
}
|
||||
else
|
||||
return GDB_ID_NULL ;
|
||||
|
||||
// calcolo la superficie
|
||||
PtrOwner<ISurfBezier> pSbz( bOk ? GetSurfBezierRuledGuided( CrvLoc1, CrvLoc2, vCrv, dLinTol) : nullptr) ;
|
||||
|
||||
+40
-60
@@ -45,7 +45,16 @@ ExeCreateVolZmap( int nParentId, const Point3d& ptIni, double dDimX, double dDim
|
||||
// creo lo Zmap nel suo riferimento intrinseco
|
||||
PtrOwner<IVolZmap> pVZM( CreateVolZmap()) ;
|
||||
bOk = bOk && ! IsNull( pVZM) ;
|
||||
bOk = bOk && pVZM->Create( ORIG, dDimX, dDimY, dDimZ, dPrec, bTriDex) ;
|
||||
if ( bOk) {
|
||||
int nError = 0 ;
|
||||
bOk = pVZM->Create( ORIG, dDimX, dDimY, dDimZ, dPrec, bTriDex, &nError) ;
|
||||
if ( ! bOk) {
|
||||
if ( nError == 1)
|
||||
ExeOutLog( "EgtVolZmapBox too big for a 32-bit system") ;
|
||||
else
|
||||
ExeOutLog( "EgtVolZmapBox error number : " + ToString( nError)) ;
|
||||
}
|
||||
}
|
||||
// lo porto nel riferimento locale
|
||||
bOk = bOk && pVZM->ToGlob( frBox) ;
|
||||
// inserisco lo Zmap nel DB
|
||||
@@ -88,7 +97,16 @@ int ExeCreateVolZmapEmpty( int nParentId, const Point3d& ptIni, double dDimX, do
|
||||
// creo lo Zmap nel suo riferimento intrinseco
|
||||
PtrOwner<IVolZmap> pVZM( CreateVolZmap()) ;
|
||||
bOk = bOk && ! IsNull( pVZM) ;
|
||||
bOk = bOk && pVZM->CreateEmpty( ORIG, dDimX, dDimY, dDimZ, dPrec, bTriDex) ;
|
||||
if ( bOk) {
|
||||
int nError = 0 ;
|
||||
bOk = pVZM->CreateEmpty( ORIG, dDimX, dDimY, dDimZ, dPrec, bTriDex, &nError) ;
|
||||
if ( ! bOk) {
|
||||
if ( nError == 1)
|
||||
ExeOutLog( "EgtVolZmapEmpty too big for a 32-bit system") ;
|
||||
else
|
||||
ExeOutLog( "EgtVolZmapEmpty error number : " + ToString( nError)) ;
|
||||
}
|
||||
}
|
||||
// lo porto nel riferimento locale
|
||||
bOk = bOk && pVZM->ToGlob( frBox) ;
|
||||
// inserisco lo Zmap nel DB
|
||||
@@ -130,7 +148,16 @@ ExeCreateVolZmapByRegionExtrusion( int nParentId, int nSfrId, double dDimZ, doub
|
||||
// creo lo Zmap nel suo riferimento intrinseco
|
||||
PtrOwner<IVolZmap> pVZM( CreateVolZmap()) ;
|
||||
bOk = bOk && ! IsNull( pVZM) ;
|
||||
bOk = bOk && pVZM->CreateFromFlatRegion( *pSfr, dDimZ, dPrec, bTriDex) ;
|
||||
if ( bOk) {
|
||||
int nError = 0 ;
|
||||
bOk = pVZM->CreateFromFlatRegion( *pSfr, dDimZ, dPrec, bTriDex, &nError) ;
|
||||
if ( ! bOk) {
|
||||
if ( nError == 1)
|
||||
ExeOutLog( "EgtVolZmapByRegionExtrusion too big for a 32-bit system") ;
|
||||
else
|
||||
ExeOutLog( "EgtVolZmapByRegionExtrusion error number : " + ToString( nError)) ;
|
||||
}
|
||||
}
|
||||
// lo porto nel riferimento di destinazione
|
||||
bOk = bOk && pVZM->LocToLoc( frSfr, frDest) ;
|
||||
// inserisco lo Zmap nel DB
|
||||
@@ -169,7 +196,16 @@ ExeCreateVolZmapFromSurfTm( int nParentId, int nStmId, double dPrec, bool bTriDe
|
||||
// creo lo Zmap nel suo riferimento intrinseco
|
||||
PtrOwner<IVolZmap> pVZM( CreateVolZmap()) ;
|
||||
bOk = bOk && ! IsNull( pVZM) ;
|
||||
bOk = bOk && pVZM->CreateFromTriMesh( *pStm, dPrec, bTriDex, dExtraBox) ;
|
||||
if ( bOk) {
|
||||
int nError = 0 ;
|
||||
bOk = pVZM->CreateFromTriMesh( *pStm, dPrec, bTriDex, dExtraBox, &nError) ;
|
||||
if ( ! bOk) {
|
||||
if ( nError == 1)
|
||||
ExeOutLog( "EgtVolZmapFromSurfTm too big for a 32-bit system") ;
|
||||
else
|
||||
ExeOutLog( "EgtVolZmapFromSurfTm error number : " + ToString( nError)) ;
|
||||
}
|
||||
}
|
||||
// lo porto nel riferimento di destinazione
|
||||
bOk = bOk && pVZM->LocToLoc( frStm, frDest) ;
|
||||
// inserisco lo Zmap nel DB
|
||||
@@ -188,59 +224,3 @@ ExeCreateVolZmapFromSurfTm( int nParentId, int nStmId, double dPrec, bool bTriDe
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeUpdateVolZmapByAddingSurfTm( int nVolZmapId, int nStmId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero lo Zmap
|
||||
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nVolZmapId)) ;
|
||||
bool bOk = ( pVZM != nullptr) ;
|
||||
// recupero la trimesh
|
||||
PtrOwner<ISurfTriMesh> pStm( CloneSurfTriMesh( pGeomDB->GetGeoObj( nStmId))) ;
|
||||
bOk = bOk && !IsNull( pStm) ;
|
||||
// recupero il frame dello Zmap e della Trimesh
|
||||
Frame3d frZmap, frStm ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nVolZmapId, frZmap) &&
|
||||
pGeomDB->GetGlobFrame( nStmId, frStm) ;
|
||||
// porto la Stm nel frame dello Zmap
|
||||
bOk = bOk && pStm->LocToLoc( frStm, frZmap) ;
|
||||
// aggiorno lo Zmap con la nuova superficie
|
||||
bOk = bOk && pVZM->AddSurfTm( pStm) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtUpdateVolZmapByAddingSurfTm(" + ToString( nVolZmapId) + "," +
|
||||
ToString( nStmId) + ")"
|
||||
" -- bOk =" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeUniformVolZmap( int nVolZmapId, double dToler, bool bExtensionFirst, int nToolNum)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero lo Zmap
|
||||
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nVolZmapId)) ;
|
||||
bool bOk = ( pVZM != nullptr) ;
|
||||
// aggiorno lo Zmap
|
||||
dToler = max( dToler, EPS_SMALL) ;
|
||||
bOk = bOk && pVZM->MakeUniform( dToler, bExtensionFirst, nToolNum) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtUniformVolZmap(" + ToString( nVolZmapId) + "," +
|
||||
ToString( dToler) + "," +
|
||||
( bExtensionFirst ? "true" : "false") +
|
||||
ToString( nToolNum) + ")"
|
||||
" -- bOk =" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
+1
-1
@@ -760,7 +760,7 @@ ExeShowCurveBezierControlPoints( int nCrvId, int nDestGrpId, int* pnCount)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la curva di Bezier
|
||||
IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nCrvId) ;
|
||||
if ( pGeoObj->GetType() != CRV_BEZIER && pGeoObj->GetType() != CRV_COMPO)
|
||||
if ( pGeoObj == nullptr || ( pGeoObj->GetType() != CRV_BEZIER && pGeoObj->GetType() != CRV_COMPO))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento della curva
|
||||
Frame3d frCrv ;
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExePocketing( const int nId, double dRad, double dStep, double dAngle, int nType, bool bSmooth, int nDestGrpId,
|
||||
ExePocketing( int nId, double dRad, double dStep, double dAngle, int nType, bool bSmooth, int nDestGrpId,
|
||||
int& nFirstId, int& nCrvCount)
|
||||
{
|
||||
// database geometrico
|
||||
@@ -59,7 +59,8 @@ ExePocketing( const int nId, double dRad, double dStep, double dAngle, int nType
|
||||
|
||||
// eseguo Pocketing
|
||||
ICRVCOMPOPOVECTOR vCrvCompoRes ;
|
||||
bool bOk = CalcPocketing( pSfr, dRad, 0, dStep, dAngle, 5., nType, bSmooth, true, false, false, false, true, P_INVALID, nullptr, false, dStep, INFINITO, 0, vCrvCompoRes) ;
|
||||
bool bOk = CalcPocketing( pSfr, dRad, 0, dStep, dAngle, 5., nType, bSmooth, true, false, false, false, true, P_INVALID, nullptr, false,
|
||||
dStep, 0, INFINITO, 0, 0, INFINITO, false, 0., 0., vCrvCompoRes) ;
|
||||
nFirstId = GDB_ID_NULL ;
|
||||
nCrvCount = int( vCrvCompoRes.size()) ;
|
||||
if ( bOk && nCrvCount > 0) {
|
||||
|
||||
+84
-17
@@ -21,6 +21,7 @@
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkGeoVector3d.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
@@ -47,9 +48,6 @@ ExeSurfArea( int nId, double& dArea)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( &dArea == nullptr)
|
||||
return false ;
|
||||
// recupero la superficie
|
||||
ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nId)) ;
|
||||
// ne restituisco l'area
|
||||
@@ -74,9 +72,6 @@ ExeSurfVolume( int nId, double& dVol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( &dVol == nullptr)
|
||||
return false ;
|
||||
// recupero la superficie
|
||||
ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nId)) ;
|
||||
// ne restituisco l'eventuale volume (se è chiusa)
|
||||
@@ -105,9 +100,6 @@ ExeSurfFrGrossArea( int nId, double& dArea)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( &dArea == nullptr)
|
||||
return false ;
|
||||
// recupero la Regione
|
||||
const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId)) ;
|
||||
// ne restituisco l'area senza eventuali buchi
|
||||
@@ -219,9 +211,6 @@ ExeSurfFrChunkMaxOffset( int nId, int nChunk, double& dMaxOffset)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( &dMaxOffset == nullptr)
|
||||
return false ;
|
||||
// recupero la Regione
|
||||
const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId)) ;
|
||||
return ( pSfr != nullptr && pSfr->GetChunkMaxOffset( nChunk, dMaxOffset)) ;
|
||||
@@ -260,6 +249,46 @@ ExeSurfFrChunkSimpleClassify( int nId1, int nChunk1, int nId2, int nChunk2, doub
|
||||
return nRes ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Resultati restituiti : REGC_NULL ( errore), REGC_OUT ( Chunks esterni), REGC_INTERS ( Chunk che si intersecano)
|
||||
int
|
||||
ExeSurfFlatRegionInterference( int nId1, int nChunk1, int nId2, int nChunk2, double dToler)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la prima superficie FlatRegion
|
||||
ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ;
|
||||
bool bOk = ( pSfr1 != nullptr) ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf1 ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nId1, frSurf1) ;
|
||||
// recupero la seconda superficie FlatRegion
|
||||
const ISurfFlatRegion* pSfr2 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId2)) ;
|
||||
bOk = bOk && ( pSfr2 != nullptr) ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf2 ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nId2, frSurf2) ;
|
||||
// se riferimenti diversi, porto una copia della seconda nel riferimento della prima
|
||||
const ISurfFlatRegion* pSfr2L = pSfr2 ;
|
||||
PtrOwner<ISurfFlatRegion> pTmp ;
|
||||
if ( bOk && ( abs( dToler) > EPS_SMALL || ! AreSameFrame( frSurf1, frSurf2))) {
|
||||
pTmp.Set( pSfr2->Clone()) ;
|
||||
bOk = ( ! IsNull( pTmp)) ;
|
||||
bOk = bOk && pTmp->LocToLoc( frSurf2, frSurf1) ;
|
||||
pTmp->Offset( - abs( dToler), ICurve::OFF_FILLET) ;
|
||||
pSfr2L = pTmp ;
|
||||
}
|
||||
// verifico interferenza del Chunk della prima regione rispetto a quello della seconda
|
||||
int nRes = REGC_NULL ;
|
||||
if ( bOk) {
|
||||
bool bInterference = false ;
|
||||
bOk = pSfr1->CheckChunkInterference( nChunk1, *pSfr2L, nChunk2, bInterference) ;
|
||||
if ( bOk)
|
||||
nRes = ( bInterference ? REGC_INTERS : REGC_OUT) ;
|
||||
}
|
||||
return nRes ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfFrChunkCenter( int nId, int nChunk, int nRefId, Point3d& ptCen, Vector3d& vtN)
|
||||
@@ -373,6 +402,20 @@ ExeSurfTmPartCount( int nId)
|
||||
return pStm->GetPartCount() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmGetPartAndShellFromFacet( int nIdSurfTm, int nIdFacet, int& nPart, int& nShell)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nIdSurfTm)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// recupero la parte e la shell a cui appartiene la faccia passata
|
||||
return pStm->GetPartAndShellFromFacet( nIdFacet, nPart, nShell) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmGetVertex( int nId, int nVert, int nRefId, Point3d& ptVert)
|
||||
@@ -1572,7 +1615,7 @@ ExeSurfBezierGetPointNrmD1( int nSurfId, double dU, double dV, int nUsd, int nVs
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
static int
|
||||
MySurfBezierGetCurveUV( int nSurfId, bool bIsU, double dPar, int nDestGrpId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
@@ -1657,6 +1700,30 @@ ExeSurfBezierGetCurveV( int nSurfId, double dU, int nDestGrpId)
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfBezierParamsFromPoint( int nSurfId, const Point3d& ptOnSurf, int nRefId, double& dU, double& dV)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie di Bezier
|
||||
const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nSurfId)) ;
|
||||
if ( pSbz == nullptr)
|
||||
return false ;
|
||||
// porto il punto Near nel riferimento dell'entità
|
||||
Point3d ptOnSurfL = ptOnSurf ;
|
||||
if ( ! InvTransformPoint( pGeomDB, nSurfId, nRefId, ptOnSurfL))
|
||||
return false ;
|
||||
// determino i parametri corrispondenti al punto
|
||||
Point3d ptParam ;
|
||||
if ( ! pSbz->UnprojectPoint( ptOnSurfL, ptParam, P_INVALID))
|
||||
return false ;
|
||||
dU = ptParam.x ;
|
||||
dV = ptParam.y ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfBezierGetInfo( int nSurfId, int& nDegU, int& nDegV, int& nSpanU, int& nSpanV, bool& bIsRat, bool& bTrimmed)
|
||||
@@ -1786,7 +1853,7 @@ ExeExtractSurfBezierLoops( int nId, int nDestGrpId, int* pnCount)
|
||||
// recupero la superficie di Bezier
|
||||
const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pSbz != nullptr) ;
|
||||
if( ! bOk)
|
||||
if ( ! bOk)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf ;
|
||||
@@ -1836,10 +1903,10 @@ int
|
||||
ExeShowSurfBezierControlPoints( int nSrfId, int nDestGrpId, int* pnCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la superficie di bezier
|
||||
IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nSrfId) ;
|
||||
if ( pGeoObj->GetType() != SRF_BEZIER)
|
||||
if ( pGeoObj == nullptr || pGeoObj->GetType() != SRF_BEZIER)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf ;
|
||||
@@ -1870,4 +1937,4 @@ ExeShowSurfBezierControlPoints( int nSrfId, int nDestGrpId, int* pnCount)
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
}
|
||||
|
||||
+21
-12
@@ -208,7 +208,7 @@ ExeApproxCurve( int nId, int nApprType, double dLinTol, double dMaxSegmLen)
|
||||
// eliminazione di small Z
|
||||
bOk = bOk && pCC->RemoveSmallDefects( 0.5 * dLinTol, ANG_TOL_STD_DEG) ;
|
||||
}
|
||||
else { // con bi-archi
|
||||
else if ( nApprType == APP_ARCS) { // con bi-archi
|
||||
PolyArc PA ;
|
||||
double dLinFea = LIN_FEA_STD ;
|
||||
double dAngTol = ANG_TOL_STD_DEG ;
|
||||
@@ -223,6 +223,11 @@ ExeApproxCurve( int nId, int nApprType, double dLinTol, double dMaxSegmLen)
|
||||
// merge di archi identici di biarchi
|
||||
bOk = bOk && pCC->MergeCurves( 0.5 * dLinTol, ANG_TOL_STD_DEG) ;
|
||||
}
|
||||
else if ( nApprType == APP_CUBIC_BEZIER) {
|
||||
PtrOwner<ICurve> pCrv( ApproxCurveWithBezier( pCurve, dLinTol)) ;
|
||||
bOk = bOk && ! IsNull( pCrv) ;
|
||||
bOk = bOk && pCC->AddCurve( Release( pCrv)) ;
|
||||
}
|
||||
// copio estrusione e spessore
|
||||
Vector3d vtExtr ;
|
||||
if ( bOk && pCurve->GetExtrusion( vtExtr))
|
||||
@@ -2510,6 +2515,8 @@ MyProjectCurveOnSurf( int nCurveId, const INTVECTOR& vnSurfId, int nDestGrpId,
|
||||
pGeomDB->SetInfo( nNewId, "Ind", nInd ++) ;
|
||||
pGeomDB->SetInfo( nNewId, "Par", Pt5ax.dPar) ;
|
||||
pGeomDB->SetInfo( nNewId, "Flag", Pt5ax.nFlag) ;
|
||||
pGeomDB->SetInfo( nNewId, "DirU", Pt5ax.vtDirU) ;
|
||||
pGeomDB->SetInfo( nNewId, "DirV", Pt5ax.vtDirV) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -2538,7 +2545,7 @@ ExeProjectCurveOnSurf( int nCurveId, const INTVECTOR& vnSurfId, int nDestGrpId,
|
||||
//-------------------------------------------------------------------------------
|
||||
static bool
|
||||
MyProjectCurveOnSurfDir( int nCurveId, const INTVECTOR& vnSurfId, const Vector3d& vtProj, int nDestGrpId,
|
||||
double dLinTol, double dMaxSegmLen, bool bDirFromProj, int nRefType)
|
||||
double dLinTol, double dMaxSegmLen, bool bDirFromProj, bool bFromVsTo, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
@@ -2580,7 +2587,7 @@ MyProjectCurveOnSurfDir( int nCurveId, const INTVECTOR& vnSurfId, const Vector3d
|
||||
bool bSharpEdges = ( ! bDirFromProj) ;
|
||||
// eseguo la proiezione
|
||||
PNT5AXVECTOR vPt5ax ;
|
||||
if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, vtProjL, dLinTol, dMaxSegmLen, bSharpEdges, vPt5ax))
|
||||
if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, vtProjL, dLinTol, dMaxSegmLen, bSharpEdges, bFromVsTo, vPt5ax))
|
||||
return false ;
|
||||
// inserisco la composita nel gruppo destinazione
|
||||
PtrOwner<ICurveComposite> pCompo ;
|
||||
@@ -2619,9 +2626,9 @@ MyProjectCurveOnSurfDir( int nCurveId, const INTVECTOR& vnSurfId, const Vector3d
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeProjectCurveOnSurfDir( int nCurveId, const INTVECTOR& vnSurfId, const Vector3d& vtProj, int nDestGrpId,
|
||||
double dLinTol, double dMaxSegmLen, bool bDirFromProj, int nRefType)
|
||||
double dLinTol, double dMaxSegmLen, bool bDirFromProj, bool bFromVsTo, int nRefType)
|
||||
{
|
||||
bool bOk = MyProjectCurveOnSurfDir( nCurveId, vnSurfId, vtProj, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromProj, nRefType) ;
|
||||
bool bOk = MyProjectCurveOnSurfDir( nCurveId, vnSurfId, vtProj, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromProj, bFromVsTo, nRefType) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
@@ -2632,6 +2639,7 @@ ExeProjectCurveOnSurfDir( int nCurveId, const INTVECTOR& vnSurfId, const Vector3
|
||||
ToString( dLinTol) + "," +
|
||||
ToString( dMaxSegmLen) + "," +
|
||||
( bDirFromProj ? "true" : "false") + "," +
|
||||
( bFromVsTo ? "true" : "false") + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
@@ -2642,7 +2650,7 @@ ExeProjectCurveOnSurfDir( int nCurveId, const INTVECTOR& vnSurfId, const Vector3
|
||||
//-------------------------------------------------------------------------------
|
||||
static bool
|
||||
MyProjectCurveOnSurfExt( int nCurveId, const INTVECTOR& vnSurfId, int nGuideId, int nDestGrpId,
|
||||
double dLinTol, double dMaxSegmLen, bool bDirFromGuide)
|
||||
double dLinTol, double dMaxSegmLen, bool bDirFromGuide, bool bFromVsTo)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
@@ -2703,14 +2711,14 @@ MyProjectCurveOnSurfExt( int nCurveId, const INTVECTOR& vnSurfId, int nGuideId,
|
||||
if ( pGdeLoc == nullptr)
|
||||
return false ;
|
||||
pGdeLoc->LocToLoc( frGde, frSurf) ;
|
||||
if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, *pGdeLoc, dLinTol, dMaxSegmLen, bSharpEdges, vPt5ax))
|
||||
if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, *pGdeLoc, dLinTol, dMaxSegmLen, bSharpEdges, bFromVsTo, vPt5ax))
|
||||
return false ;
|
||||
}
|
||||
else if ( pGdeCrv != nullptr) {
|
||||
CurveLocal GdeLoc( pGdeCrv, frGde, frSurf) ;
|
||||
if ( GdeLoc.Get() == nullptr)
|
||||
return false ;
|
||||
if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, *GdeLoc.Get(), dLinTol, dMaxSegmLen, bSharpEdges, vPt5ax))
|
||||
if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, *GdeLoc.Get(), dLinTol, dMaxSegmLen, bSharpEdges, bFromVsTo, vPt5ax))
|
||||
return false ;
|
||||
}
|
||||
else { // pGdeStm != nullptr
|
||||
@@ -2718,7 +2726,7 @@ MyProjectCurveOnSurfExt( int nCurveId, const INTVECTOR& vnSurfId, int nGuideId,
|
||||
const ISurf* pGdeLoc = GetSurf( GdeLoc.Get()) ;
|
||||
if ( pGdeLoc == nullptr)
|
||||
return false ;
|
||||
if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, *pGdeLoc, dLinTol, dMaxSegmLen, bSharpEdges, vPt5ax))
|
||||
if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, *pGdeLoc, dLinTol, dMaxSegmLen, bSharpEdges, bFromVsTo, vPt5ax))
|
||||
return false ;
|
||||
}
|
||||
// inserisco la composita nel gruppo destinazione
|
||||
@@ -2758,9 +2766,9 @@ MyProjectCurveOnSurfExt( int nCurveId, const INTVECTOR& vnSurfId, int nGuideId,
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeProjectCurveOnSurfExt( int nCurveId, const INTVECTOR& vnSurfId, int nGuideId, int nDestGrpId,
|
||||
double dLinTol, double dMaxSegmLen, bool bDirFromGuide)
|
||||
double dLinTol, double dMaxSegmLen, bool bDirFromGuide, bool bFromVsTo)
|
||||
{
|
||||
bool bOk = MyProjectCurveOnSurfExt( nCurveId, vnSurfId, nGuideId, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromGuide) ;
|
||||
bool bOk = MyProjectCurveOnSurfExt( nCurveId, vnSurfId, nGuideId, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromGuide, bFromVsTo) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
@@ -2770,7 +2778,8 @@ ExeProjectCurveOnSurfExt( int nCurveId, const INTVECTOR& vnSurfId, int nGuideId,
|
||||
ToString( nDestGrpId) + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
ToString( dMaxSegmLen) + "," +
|
||||
( bDirFromGuide ? "true" : "false") + ")" +
|
||||
( bDirFromGuide ? "true" : "false") + "," +
|
||||
( bFromVsTo ? "true" : "false") + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
|
||||
+22
-1
@@ -1185,7 +1185,10 @@ ExeSurfTmGetShowEdges( int nId, bool& bShow)
|
||||
ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pStm != nullptr) ;
|
||||
// recupero lo stato di visualizzazione degli spigoli vivi
|
||||
bShow = ( bOk && pStm->GetShowEdges()) ;
|
||||
if ( bOk)
|
||||
bShow = pStm->GetShowEdges() ;
|
||||
else
|
||||
bShow = false ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -1199,6 +1202,7 @@ ExeSurfTmSetSmoothAng( int nId, double dAngDeg)
|
||||
ISurfTriMesh* pSrfTm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pSrfTm == nullptr)
|
||||
return false ;
|
||||
// imposto l'angolo discriminante degli spigoli vivi
|
||||
pSrfTm->SetSmoothAngle( dAngDeg) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
@@ -1210,6 +1214,23 @@ ExeSurfTmSetSmoothAng( int nId, double dAngDeg)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmGetSmoothAng( int nId, double& dAngDeg)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie trimesh
|
||||
ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pStm != nullptr) ;
|
||||
// recupero l'angolo discriminante degli spigoli vivi
|
||||
if ( bOk)
|
||||
dAngDeg = pStm->GetSmoothAngle() ;
|
||||
else
|
||||
dAngDeg = 0 ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static double
|
||||
GetStmOffsPrec( double dOffs, double dLinTol)
|
||||
|
||||
@@ -142,6 +142,23 @@ ExeVolZmapSetShowEdges( int nId, bool bShow)
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeVolZmapGetShowEdges( int nId, bool& bShow)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero lo Zmap
|
||||
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pVZM != nullptr) ;
|
||||
// leggo lo stato di visualizzazione degli spigoli vivi
|
||||
if ( bOk)
|
||||
bShow = pVZM->GetShowEdges() ;
|
||||
else
|
||||
bShow = false ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeRemoveVolZmapPart( int nId, int nPart)
|
||||
@@ -561,3 +578,87 @@ ExeVolZMapOffset( int nId, double dDist, int nType)
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeUpdateVolZmapByAddingSurfTm( int nVolZmapId, int nStmId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero lo Zmap
|
||||
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nVolZmapId)) ;
|
||||
bool bOk = ( pVZM != nullptr) ;
|
||||
// recupero la trimesh
|
||||
PtrOwner<ISurfTriMesh> pStm( CloneSurfTriMesh( pGeomDB->GetGeoObj( nStmId))) ;
|
||||
bOk = bOk && !IsNull( pStm) ;
|
||||
// recupero il frame dello Zmap e della Trimesh
|
||||
Frame3d frZmap, frStm ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nVolZmapId, frZmap) &&
|
||||
pGeomDB->GetGlobFrame( nStmId, frStm) ;
|
||||
// porto la Stm nel frame dello Zmap
|
||||
bOk = bOk && pStm->LocToLoc( frStm, frZmap) ;
|
||||
// aggiorno lo Zmap con la nuova superficie
|
||||
bOk = bOk && pVZM->AddSurfTm( pStm) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtUpdateVolZmapByAddingSurfTm(" + ToString( nVolZmapId) + "," +
|
||||
ToString( nStmId) + ")"
|
||||
" -- bOk =" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeVolZmapMakeUniform( int nVolZmapId, double dToler, bool bExtensionFirst, int nToolNum)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero lo Zmap
|
||||
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nVolZmapId)) ;
|
||||
bool bOk = ( pVZM != nullptr) ;
|
||||
// aggiorno lo Zmap
|
||||
dToler = max( dToler, EPS_SMALL) ;
|
||||
bOk = bOk && pVZM->MakeUniform( dToler, bExtensionFirst, nToolNum) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtVolZmapMakeUniform(" + ToString( nVolZmapId) + "," +
|
||||
ToString( dToler) + "," +
|
||||
( bExtensionFirst ? "true" : "false") +
|
||||
ToString( nToolNum) + ")"
|
||||
" -- bOk =" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeVolZMapRemoveFins( int nVolZMapId, const Vector3d& vtDir, double dThick, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false) ;
|
||||
// Recupero lo ZMap
|
||||
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nVolZMapId)) ;
|
||||
bool bOk = ( pVZM != nullptr) ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nVolZMapId, frLoc) ;
|
||||
// porto in locale la normale al piano
|
||||
Vector3d vtDirL = GetVectorLocal( pGeomDB, vtDir, nRefType, frLoc) ;
|
||||
// Aggiorno lo ZMap mediante rimozione delle alette
|
||||
bOk = bOk && pVZM->RemoveFins( vtDirL, dThick) ;
|
||||
// Se richiesto salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtVolZMapRemoveFins(" + ToString( nVolZMapId) + "," +
|
||||
ToString( vtDir) + "," +
|
||||
ToString( dThick) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- bOk =" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -393,6 +393,29 @@ ExeCopyGlobEx( int nSouCtx, int nSouId, int nDestCtx, int nRefId, int nSonBefore
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeDuplicateGeomDB( int nSouCtx, int nDestCtx, bool bSkipTemp)
|
||||
{
|
||||
// recupero i due GeomDB
|
||||
IGeomDB* pSouGeomDB = GetGeomDB( nSouCtx) ;
|
||||
VERIFY_GEOMDB( pSouGeomDB, GDB_ID_NULL)
|
||||
IGeomDB* pDstGeomDB = GetGeomDB( nDestCtx) ;
|
||||
VERIFY_GEOMDB( pDstGeomDB, GDB_ID_NULL)
|
||||
// eseguo la duplicazione del primo GeomDB nel secondo
|
||||
bool bOk = DuplicateGeomDB( pSouGeomDB, pDstGeomDB, bSkipTemp) ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtDuplicateGeomDB(" + ToString( nSouCtx) + "," +
|
||||
ToString( nDestCtx) + "," +
|
||||
( bSkipTemp ? "true" : "false") + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeRelocate( int nSouId, int nRefId, int nSonBeforeAfter)
|
||||
|
||||
+52
-28
@@ -47,8 +47,8 @@
|
||||
using namespace std ;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
MyLineCurveInters( const Point3d& ptP, const Vector3d& vtDir, const int nId, const int nRefType,
|
||||
static bool
|
||||
MyLineCurveInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRefType,
|
||||
INTDBLVECTOR& vInters)
|
||||
{
|
||||
vInters.clear() ;
|
||||
@@ -71,7 +71,7 @@ MyLineCurveInters( const Point3d& ptP, const Vector3d& vtDir, const int nId, con
|
||||
if ( ! CrvLoc->GetLocalBBox( b3Crv))
|
||||
return false ;
|
||||
b3Crv.Expand( 100 * EPS_SMALL) ;
|
||||
// definisco la linea (punto e direzione sono gi� nel riferimento di calcolo)
|
||||
// definisco la linea (punto e direzione sono già nel riferimento di calcolo)
|
||||
double dLen = 2 * floor( b3Crv.MaxDistFromPoint( ptP)) ;
|
||||
double dOffs = -dLen / 2 ;
|
||||
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
|
||||
@@ -127,7 +127,7 @@ MyLineCurveInters( const Point3d& ptP, const Vector3d& vtDir, const int nId, con
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeLineCurveInters( const Point3d& ptP, const Vector3d& vtDir, const int nId, const int nRefType,
|
||||
ExeLineCurveInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRefType,
|
||||
INTDBLVECTOR& vInters)
|
||||
{
|
||||
// eseguo
|
||||
@@ -161,7 +161,7 @@ ExeLineBoxInters( const Point3d& ptP, const Vector3d& vtDir, const BBox3d& b3Box
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della prima nuova entit�
|
||||
// restituisco l'identificativo della prima nuova entità
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ ExeLineSurfTmInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRe
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della prima nuova entit�
|
||||
// restituisco l'identificativo della prima nuova entità
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ ExeLineSurfBzInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRe
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della prima nuova entit�
|
||||
// restituisco l'identificativo della prima nuova entità
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -359,15 +359,27 @@ MyAddPlaneIntersResultToGeomDB( IGeomDB* pGeomDB, const PNTVECTOR& vPnt, const B
|
||||
}
|
||||
// Inserisco le curve nel DB (dopo averle concatenate)
|
||||
ChainCurves chainC ;
|
||||
chainC.Init( false, dToler, int( vBpt.size())) ;
|
||||
chainC.Init( false, dToler, int( vBpt.size())) ;
|
||||
DBLVECTOR vdLen ; vdLen.reserve( vBpt.size()) ;
|
||||
for ( int i = 0 ; i < int( vBpt.size()) ; ++ i) {
|
||||
Vector3d vtDir = vBpt[i].second - vBpt[i].first ;
|
||||
vdLen.emplace_back( vtDir.Len()) ;
|
||||
vtDir.Normalize() ;
|
||||
if ( ! chainC.AddCurve( i + 1, vBpt[i].first, vtDir, vBpt[i].second, vtDir))
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
|
||||
// recupero i percorsi concatenati
|
||||
// il punto di inizio viene scelto come lo start di un tratto più lungo della tolleranza in modo da evitare casi problematici
|
||||
// del chain in cui percorsi formati da tratti di lunghezza inferiore alla tolleranza vengono individuati erroneamente come chiusi
|
||||
// interrompendo il loro concatenamento con le altre curve
|
||||
Point3d ptNear = ( vBpt.empty() ? ORIG : vBpt[0].first) ;
|
||||
for ( int i = 0 ; i < int( vdLen.size()) ; ++ i) {
|
||||
if ( vdLen[i] > 2 * dToler) {
|
||||
ptNear = vBpt[i].first ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
INTVECTOR vId ;
|
||||
while ( chainC.GetChainFromNear( ptNear, false, vId)) {
|
||||
// creo una curva composita
|
||||
@@ -390,6 +402,8 @@ MyAddPlaneIntersResultToGeomDB( IGeomDB* pGeomDB, const PNTVECTOR& vPnt, const B
|
||||
pLine->Set( ptStart, ptEnd) &&
|
||||
pCrvCompo->AddCurve( Release( pLine), true, dToler)) ;
|
||||
ptNear = ( bAdded ? ptEnd : ptStart) ;
|
||||
// rendo invalida la sua lunghezza per non ritrovarlo come tratto iniziale del percorso successivo
|
||||
vdLen[nInd] = -1 ;
|
||||
}
|
||||
// se lunghezza curva inferiore a 5 volte la tolleranza, la ignoro
|
||||
double dCrvLen ;
|
||||
@@ -421,6 +435,13 @@ MyAddPlaneIntersResultToGeomDB( IGeomDB* pGeomDB, const PNTVECTOR& vPnt, const B
|
||||
if ( nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nNewId ;
|
||||
++ nCrvCount ;
|
||||
// scelgo il nuovo punto di inizio
|
||||
for ( int i = 0 ; i < int( vdLen.size()) ; ++ i) {
|
||||
if ( vdLen[i] > 2 * dToler) {
|
||||
ptNear = vBpt[i].first ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Inserisco i triangoli nel DB (dopo averli uniti in una superficie trimesh)
|
||||
StmFromTriangleSoup StmFts ;
|
||||
@@ -454,8 +475,8 @@ MyAddPlaneIntersResultToGeomDB( IGeomDB* pGeomDB, const PNTVECTOR& vPnt, const B
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
MyPlaneCurveInters( const Point3d& ptOn, const Vector3d& vtN, const int nId, const int nDestGrpId, const int nRefType, int& nCount)
|
||||
static int
|
||||
MyPlaneCurveInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDestGrpId, int nRefType, int& nCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
@@ -546,13 +567,13 @@ MyPlaneCurveInters( const Point3d& ptOn, const Vector3d& vtN, const int nId, con
|
||||
EPS_SMALL, nPntCount, nCrvCount, nTmp) ;
|
||||
nCount = nPntCount + nCrvCount ;
|
||||
|
||||
// restituisco l'identificativo della prima entit� creata
|
||||
// restituisco l'identificativo della prima entità creata
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExePlaneCurveInters( const Point3d& ptOn, const Vector3d& vtN, const int nId, const int nDestGrpId, const int nRefType, int* pnCount)
|
||||
ExePlaneCurveInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDestGrpId, int nRefType, int* pnCount)
|
||||
{
|
||||
// eseguo
|
||||
int nCount{ 0} ;
|
||||
@@ -575,7 +596,7 @@ ExePlaneCurveInters( const Point3d& ptOn, const Vector3d& vtN, const int nId, co
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
|
||||
// restituisco l'identificativo della prima nuova entit�
|
||||
// restituisco l'identificativo della prima nuova entità
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
@@ -746,7 +767,7 @@ MyPlaneBoxInters( const Point3d& ptOn, const Vector3d& vtN, const BBox3d& b3Box,
|
||||
nFirstId = nNewId ;
|
||||
++ nSrfCount ;
|
||||
}
|
||||
// restituisco l'identificativo della prima nuova entit�
|
||||
// restituisco l'identificativo della prima nuova entità
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
@@ -779,7 +800,7 @@ ExePlaneBoxInters( const Point3d& ptOn, const Vector3d& vtN, const BBox3d& b3Box
|
||||
", CrvNbr=" + ToString( nCrvCount) + ", SrfNbr=" + ToString( nSrfCount) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della prima nuova entit�
|
||||
// restituisco l'identificativo della prima nuova entità
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
@@ -818,7 +839,7 @@ MyPlaneSurfTmInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDes
|
||||
// inserisco il risultato dell'intersezione nel DB
|
||||
int nFirstId = MyAddPlaneIntersResultToGeomDB( pGeomDB, vPnt, vBpt, vTria, frSurf, frDest, nId, nDestGrpId, plPlane.GetVersN(), dToler,
|
||||
nPntCount, nCrvCount, nSrfCount) ;
|
||||
// restituisco l'identificativo della prima nuova entit�
|
||||
// restituisco l'identificativo della prima nuova entità
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
@@ -852,7 +873,7 @@ ExePlaneSurfTmInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDe
|
||||
", CrvNbr=" + ToString( nCrvCount) + ", SrfNbr=" + ToString( nSrfCount) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della prima nuova entit�
|
||||
// restituisco l'identificativo della prima nuova entità
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
@@ -941,7 +962,7 @@ ExeParPlanesSurfTmInters( const Point3d& ptOn, const Vector3d& vtN, const DBLVEC
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
|
||||
// restituisco l'identificativo della prima nuova entit�
|
||||
// restituisco l'identificativo della prima nuova entità
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
@@ -1010,13 +1031,13 @@ ExePlaneVolZmapInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nD
|
||||
" -- Id=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della prima nuova entit�
|
||||
// restituisco l'identificativo della prima nuova entità
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
MyCurveCurveInters( const int nId1, const int nId2, const int nDestGrpId, int& nPntCount, int& nCrvCount, bool bOnly3D)
|
||||
static int
|
||||
MyCurveCurveInters( int nId1, int nId2, int nDestGrpId, int& nPntCount, int& nCrvCount, bool bOnly3D)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
@@ -1032,6 +1053,9 @@ MyCurveCurveInters( const int nId1, const int nId2, const int nDestGrpId, int& n
|
||||
CurveLocal Crv1Loc( pGeomDB, nId1, frDest) ;
|
||||
CurveLocal Crv2Loc( pGeomDB, nId2, frDest) ;
|
||||
|
||||
if( Crv1Loc.Get() == nullptr || Crv2Loc.Get() == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
|
||||
// intersezione fra le curve nel piano XY locale
|
||||
IntersCurveCurve intCC( *Crv1Loc, *Crv2Loc, true) ;
|
||||
int nInters = 0 ;
|
||||
@@ -1092,7 +1116,7 @@ MyCurveCurveInters( const int nId1, const int nId2, const int nDestGrpId, int& n
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCurveCurveInters( const int nId1, const int nId2, const int nDestGrpId, int* pnPntCount, int* pnCrvCount, bool bOnly3D)
|
||||
ExeCurveCurveInters( int nId1, int nId2, int nDestGrpId, int* pnPntCount, int* pnCrvCount, bool bOnly3D)
|
||||
{
|
||||
// eseguo
|
||||
int nPntCount{ 0}, nCrvCount{ 0} ;
|
||||
@@ -1114,7 +1138,7 @@ ExeCurveCurveInters( const int nId1, const int nId2, const int nDestGrpId, int*
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
|
||||
// restituisco l'identificativo della prima nuova entit�
|
||||
// restituisco l'identificativo della prima nuova entità
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
@@ -1137,7 +1161,7 @@ GetCurveSurfTmIntersType( int nFlag)
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
MyCurveSurfTmInters( const int nCrvId, const int nId2, const int nDestGrpId, int& nPntCount, int& nCrvCount)
|
||||
MyCurveSurfTmInters( int nCrvId, int nId2, int nDestGrpId, int& nPntCount, int& nCrvCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
@@ -1219,7 +1243,7 @@ MyCurveSurfTmInters( const int nCrvId, const int nId2, const int nDestGrpId, int
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCurveSurfTmInters( const int nCrvId, const int nStmId, const int nDestGrpId, int* pnPntCount, int* pnCrvCount)
|
||||
ExeCurveSurfTmInters( int nCrvId, int nStmId, int nDestGrpId, int* pnPntCount, int* pnCrvCount)
|
||||
{
|
||||
// eseguo
|
||||
int nPntCount{ 0}, nCrvCount{ 0} ;
|
||||
@@ -1374,7 +1398,7 @@ MySurfTmSurfTmInters( int nId1, int nId2, int nDestGrpId, double dToler,
|
||||
const ISurfTriMesh* pStm2L = GetSurfTriMesh( Surf2Loc) ;
|
||||
if ( pStm2L == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// eseguo l'intersezione (gi� espressa nel riferimento destinazione)
|
||||
// eseguo l'intersezione (già espressa nel riferimento destinazione)
|
||||
PNTVECTOR vPnt ;
|
||||
BIPNTVECTOR vBpt ;
|
||||
TRIA3DVECTOR vTria ;
|
||||
@@ -1430,7 +1454,7 @@ MySurfTmSurfTmInters( int nId1, int nId2, int nDestGrpId, double dToler,
|
||||
nFirstId = nNewId ;
|
||||
++ nSrfCount ;
|
||||
}
|
||||
// restituisco l'identificativo della prima nuova entit�
|
||||
// restituisco l'identificativo della prima nuova entità
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
@@ -1462,7 +1486,7 @@ ExeSurfTmSurfTmInters( int nId1, int nId2, int nDestGrpId, double dToler,
|
||||
", CrvNbr=" + ToString( nCrvCount) + ", SrfNbr=" + ToString( nSrfCount) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della prima nuova entit�
|
||||
// restituisco l'identificativo della prima nuova entità
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
|
||||
+68
-4
@@ -2748,6 +2748,16 @@ ExeUpdateMachining( bool bPostApply)
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeChangePreviewMachiningToolShow( int nLookFlag)
|
||||
{
|
||||
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
||||
VERIFY_MACHMGR( pMachMgr, false)
|
||||
// impostazione tipo visualizzazione anteprima utensile su lavorazione
|
||||
return pMachMgr->ChangePreviewMachiningToolShow( nLookFlag) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExePreparePreviewMachiningTool( void)
|
||||
@@ -3090,6 +3100,16 @@ ExeGetClEntIndex( int nEntId, int& nIndex)
|
||||
return pMachMgr->GetClEntIndex( nEntId, nIndex) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeGetClEntFeed( int nEntId, double& dFeed)
|
||||
{
|
||||
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
||||
VERIFY_MACHMGR( pMachMgr, false)
|
||||
// recupero la feed
|
||||
return pMachMgr->GetClEntFeed( nEntId, dFeed) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeGetClEntAxesStatus( int nEntId, int& nStatus)
|
||||
@@ -3120,6 +3140,36 @@ ExeGetClEntAxesVal( int nEntId, DBLVECTOR& vAxes)
|
||||
return pMachMgr->GetClEntAxesVal( nEntId, vAxes) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeGetClEntTDir( int nEntId, Vector3d& vTDir)
|
||||
{
|
||||
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
||||
VERIFY_MACHMGR( pMachMgr, false) ;
|
||||
// recupero vTDir
|
||||
return pMachMgr->GetClEntTDir( nEntId, vTDir) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeGetClEntCDir( int nEntId, Vector3d& vtCDir)
|
||||
{
|
||||
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
||||
VERIFY_MACHMGR( pMachMgr, false) ;
|
||||
// recupero CDir
|
||||
return pMachMgr->GetClEntCDir( nEntId, vtCDir) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeGetClEntADir( int nEntId, Vector3d& vADir)
|
||||
{
|
||||
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
||||
VERIFY_MACHMGR( pMachMgr, false) ;
|
||||
// recupero ADir
|
||||
return pMachMgr->GetClEntADir( nEntId, vADir) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Simulazione
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -3262,12 +3312,14 @@ ExeGenerate( const string& sCncFile, const string& sInfo)
|
||||
ReplaceString( sDir, "/", "\\") ;
|
||||
// recupero il nome
|
||||
string sNcName ;
|
||||
if ( ! ExeGetInfo( ExeGetCurrMachGroup(), GDL_NC_NAME, sNcName)) {
|
||||
if ( ExeGetInfo( ExeGetCurrMachGroup(), GDL_NC_NAME, sNcName))
|
||||
sNcName = GetFileName( sNcName) ;
|
||||
else {
|
||||
string sCurrMachDir ; pMachMgr->GetCurrMachineDir( sCurrMachDir) ;
|
||||
string sCurrMachName ; pMachMgr->GetCurrMachineName( sCurrMachName) ;
|
||||
string sCurrMachIni = sCurrMachDir + "\\" + sCurrMachName + ".ini" ;
|
||||
string sExt = GetPrivateProfileStringUtf8( "PartProgram", "Extension", ".cnc", sCurrMachIni.c_str()) ;
|
||||
sNcName = ChangeFileExtension( GetFileTitleEgt( sProjPath), sExt) ;
|
||||
sNcName = ChangeFileExtension( GetFileName( sProjPath), sExt) ;
|
||||
}
|
||||
// creo la path completa
|
||||
sMyCncFile = sDir + "\\" + sNcName ;
|
||||
@@ -3294,8 +3346,10 @@ ExeEstimate( const string& sEstFile, const string& sInfo)
|
||||
ReplaceString( sDir, "/", "\\") ;
|
||||
// recupero il nome
|
||||
string sEstName ;
|
||||
if ( ! ExeGetInfo( ExeGetCurrMachGroup(), GDL_NC_NAME, sEstName))
|
||||
sEstName = GetFileTitleEgt( sProjPath) ;
|
||||
if ( ExeGetInfo( ExeGetCurrMachGroup(), GDL_NC_NAME, sEstName))
|
||||
sEstName = GetFileName( sEstName) ;
|
||||
else
|
||||
sEstName = GetFileName( sProjPath) ;
|
||||
sEstName = ChangeFileExtension( sEstName, ".html") ;
|
||||
// creo la path completa
|
||||
sMyEstFile = sDir + "\\" + sEstName ;
|
||||
@@ -3593,6 +3647,16 @@ ExeVerifyOutstroke( double dX, double dY, double dZ, double dAngA, double dAngB,
|
||||
return pMachMgr->VerifyOutstroke( dX, dY, dZ, dAngA, dAngB, nStat) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeVerifyOutstroke( double dX, double dY, double dZ, const DBLVECTOR& vAng, int& nStat)
|
||||
{
|
||||
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
||||
VERIFY_MACHMGR( pMachMgr, false)
|
||||
// verifica l'extracorsa degli assi
|
||||
return pMachMgr->VerifyOutstroke( dX, dY, dZ, vAng, true, nStat) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeGetOutstrokeInfo( string& sInfo)
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
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) ;
|
||||
bool GetFlatPartInterpartGap(IGeomDB* pGeomDB, int nId, double& dGap);
|
||||
int GetFlatPartFromRegion( IGeomDB* pGeomDB, int nId) ;
|
||||
int GetFlatPartFromCut( IGeomDB* pGeomDB, int nId) ;
|
||||
int GetGeometryFromCut( IGeomDB* pGeomDB, IMachMgr* pMachMgr, int nId) ;
|
||||
bool GetFlatPartApproxContour( IGeomDB* pGeomDB, int nId, PolyLine& PL) ;
|
||||
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) ;
|
||||
bool GetFlatPartInterpartGap(IGeomDB* pGeomDB, int nId, double& dGap);
|
||||
int GetFlatPartFromRegion( IGeomDB* pGeomDB, int nId) ;
|
||||
int GetFlatPartFromCut( IGeomDB* pGeomDB, int nId) ;
|
||||
INTVECTOR GetGeometryFromCut( IGeomDB* pGeomDB, IMachMgr* pMachMgr, int nId) ;
|
||||
bool GetFlatPartApproxContour( IGeomDB* pGeomDB, int nId, PolyLine& PL) ;
|
||||
|
||||
+11
-10
@@ -2184,24 +2184,25 @@ GetFlatPartFromCut( IGeomDB* pGeomDB, int nId)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
INTVECTOR
|
||||
GetGeometryFromCut( IGeomDB* pGeomDB, IMachMgr* pMachMgr, int nId)
|
||||
{
|
||||
INTVECTOR vnIds ;
|
||||
if ( pGeomDB == nullptr || pMachMgr == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
return vnIds ;
|
||||
// verifico appartenga ad una lavorazione
|
||||
int nMchId ;
|
||||
if ( ! pGeomDB->GetInfo( pGeomDB->GetParentId( pGeomDB->GetParentId( nId)), "MId", nMchId))
|
||||
return GDB_ID_NULL ;
|
||||
return vnIds ;
|
||||
// recupero la geometria di applicazione della lavorazione (deve essere una sola)
|
||||
if ( ! pMachMgr->SetCurrMachining( nMchId))
|
||||
return GDB_ID_NULL ;
|
||||
SELVECTOR vIds ;
|
||||
pMachMgr->GetMachiningGeometry( vIds) ;
|
||||
if ( vIds.size() == 1)
|
||||
return vIds[0].nId ;
|
||||
else
|
||||
return GDB_ID_NULL ;
|
||||
return vnIds ;
|
||||
SELVECTOR vSelIds ;
|
||||
pMachMgr->GetMachiningGeometry( vSelIds) ;
|
||||
vnIds.reserve( vSelIds.size()) ;
|
||||
for ( const SelData& mySelData : vSelIds)
|
||||
vnIds.emplace_back( mySelData.nId) ;
|
||||
return vnIds ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -143,7 +143,7 @@ ExeVerifyMachining( int nMchId, int& nResult)
|
||||
// confronto la regione di attacco della lavorazione con le regioni degli altri pezzi
|
||||
for ( int nMchRegId : vMchLiReg) {
|
||||
for ( int nOthRegId : vOthReg) {
|
||||
if ( ExeSurfFrChunkSimpleClassify( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT)
|
||||
if ( ExeSurfFlatRegionInterference( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT)
|
||||
nResult |= FMI_LI ;
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@ ExeVerifyMachining( int nMchId, int& nResult)
|
||||
if ( vMchDwnLiReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) {
|
||||
int nMchRegId = ( ( vMchDwnLiReg[i] != GDB_ID_NULL) ? vMchDwnLiReg[i] : vMchLiReg[i]) ;
|
||||
int nOthRegId = ( ( vOthDwnReg[j] != GDB_ID_NULL) ? vOthDwnReg[j] : vOthReg[j]) ;
|
||||
if ( ExeSurfFrChunkSimpleClassify( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT)
|
||||
if ( ExeSurfFlatRegionInterference( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT)
|
||||
nResult |= FMI_LI ;
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ ExeVerifyMachining( int nMchId, int& nResult)
|
||||
// confronto la regione ridotta della lavorazione con le regioni degli altri pezzi
|
||||
for ( int nMchRegId : vMchRReg) {
|
||||
for ( int nOthRegId : vOthReg) {
|
||||
if ( ExeSurfFrChunkSimpleClassify( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT)
|
||||
if ( ExeSurfFlatRegionInterference( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT)
|
||||
nResult |= FMI_RM ;
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ ExeVerifyMachining( int nMchId, int& nResult)
|
||||
if ( vMchDwnRReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) {
|
||||
int nMchRegId = ( ( vMchDwnRReg[i] != GDB_ID_NULL) ? vMchDwnRReg[i] : vMchRReg[i]) ;
|
||||
int nOthRegId = ( ( vOthDwnReg[j] != GDB_ID_NULL) ? vOthDwnReg[j] : vOthReg[j]) ;
|
||||
if ( ExeSurfFrChunkSimpleClassify( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT)
|
||||
if ( ExeSurfFlatRegionInterference( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT)
|
||||
nResult |= FMI_RM ;
|
||||
}
|
||||
}
|
||||
@@ -177,7 +177,7 @@ ExeVerifyMachining( int nMchId, int& nResult)
|
||||
// confronto la regione di uscita della lavorazione con le regioni degli altri pezzi
|
||||
for ( int nMchRegId : vMchLoReg) {
|
||||
for ( int nOthRegId : vOthReg) {
|
||||
if ( ExeSurfFrChunkSimpleClassify( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT)
|
||||
if ( ExeSurfFlatRegionInterference( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT)
|
||||
nResult |= FMI_LO ;
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ ExeVerifyMachining( int nMchId, int& nResult)
|
||||
if ( vMchDwnLoReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) {
|
||||
int nMchRegId = ( ( vMchDwnLoReg[i] != GDB_ID_NULL) ? vMchDwnLoReg[i] : vMchLoReg[i]) ;
|
||||
int nOthRegId = ( ( vOthDwnReg[j] != GDB_ID_NULL) ? vOthDwnReg[j] : vOthReg[j]) ;
|
||||
if ( ExeSurfFrChunkSimpleClassify( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT)
|
||||
if ( ExeSurfFlatRegionInterference( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT)
|
||||
nResult |= FMI_LO ;
|
||||
}
|
||||
}
|
||||
|
||||
+331
-132
@@ -22,8 +22,10 @@
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EGkCAvSimpleSurfFrMove.h"
|
||||
#include "/EgtDev/Include/EGkCAvSurfFrMove.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EMkMachiningGeoConst.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
@@ -32,6 +34,7 @@
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// collisioni semplici
|
||||
struct SCollInfoEx : public SCollInfo
|
||||
{
|
||||
int nIdM ; // identificativo della regione mobile
|
||||
@@ -43,7 +46,7 @@ struct SCollInfoEx : public SCollInfo
|
||||
nIdF( GDB_ID_NULL), bIsCutF( false) {}
|
||||
SCollInfoEx( const SCollInfo& Sou) : SCollInfo( Sou), nIdM( GDB_ID_NULL), bIsCutM( false),
|
||||
nIdF( GDB_ID_NULL), bIsCutF( false) {}
|
||||
} ;
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static const double SPESS = 100 ;
|
||||
@@ -92,7 +95,7 @@ ExeCreateOutRegion( int nParentId, double dXmin, double dYmin, double dXmax, dou
|
||||
dYmax < dYmin + GAP + 2 * EPS_SMALL)
|
||||
return false ;
|
||||
|
||||
// se già esiste, posso uscire
|
||||
// se già esiste, posso uscire
|
||||
int nBoxId = pGeomDB->GetFirstNameInGroup( nParentId, NST_SHEET_OUTREG) ;
|
||||
if ( nBoxId != GDB_ID_NULL)
|
||||
return true ;
|
||||
@@ -149,7 +152,7 @@ ExeCreateOutRegion( int nParentId, int nOutCrvId)
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
|
||||
// se già esiste, posso uscire
|
||||
// se già esiste, posso uscire
|
||||
int nBoxId = pGeomDB->GetFirstNameInGroup( nParentId, NST_SHEET_OUTREG) ;
|
||||
if ( nBoxId != GDB_ID_NULL)
|
||||
return true ;
|
||||
@@ -187,7 +190,7 @@ ExeCreateOutRegion( int nParentId, int nOutCrvId)
|
||||
BBox3d b3Box ;
|
||||
pCompo->GetLocalBBox( b3Box) ;
|
||||
b3Box.Expand( SPESS, SPESS, 0) ;
|
||||
// determino il punto più vicino al massimo del box e lo faccio diventare il nuovo inizio
|
||||
// determino il punto più vicino al massimo del box e lo faccio diventare il nuovo inizio
|
||||
int nFlag ;
|
||||
double dU ;
|
||||
DistPointCurve distPC( b3Box.GetMax(), *pCompo) ;
|
||||
@@ -250,7 +253,7 @@ ExeCreateReferenceRegion( int nParentId, int nOutCrvId, bool bBottomUp)
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
|
||||
// se già esiste, posso uscire
|
||||
// se già esiste, posso uscire
|
||||
int nRegId = pGeomDB->GetFirstNameInGroup( nParentId, NST_REFERENCE_REG) ;
|
||||
if ( nRegId != GDB_ID_NULL)
|
||||
return true ;
|
||||
@@ -283,7 +286,7 @@ ExeCreateReferenceRegion( int nParentId, int nOutCrvId, bool bBottomUp)
|
||||
// ne ricavo il bbox
|
||||
BBox3d b3Box ;
|
||||
PL.GetLocalBBox( b3Box) ;
|
||||
// cerco i punti più vicini ai quattro vertici (0=BL, 1=BR, 2=TR, 3=TL)
|
||||
// cerco i punti più vicini ai quattro vertici (0=BL, 1=BR, 2=TR, 3=TL)
|
||||
double dU[4] = { -1, -1, -1, -1} ;
|
||||
double dMinSqDist[4] = { SQ_INFINITO, SQ_INFINITO, SQ_INFINITO, SQ_INFINITO} ;
|
||||
Point3d ptVert[4] ;
|
||||
@@ -391,7 +394,7 @@ ExeCreateDamagedRegion( int nParentId, int nDmgCrvId)
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
|
||||
// verifico se esiste già la regione associata
|
||||
// verifico se esiste già la regione associata
|
||||
int nRegId = pGeomDB->GetFirstNameInGroup( nParentId, NST_DAMAGED_REG) ;
|
||||
while ( nRegId != GDB_ID_NULL) {
|
||||
// recupero l'indice della curva di origine
|
||||
@@ -710,7 +713,7 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d&
|
||||
// box delle regioni dei pezzi rispetto al box dell'esterno
|
||||
if ( ! b3Region.EnclosesXY( b3RegCluster))
|
||||
return false ;
|
||||
// regioni dei pezzi rispetto alla regione dell'esterno
|
||||
// regioni dei pezzi rispetto alla regione dell'esterno (controllo semplice)
|
||||
for ( int nRegId : vReg) {
|
||||
if ( ExeSurfFrChunkSimpleClassify( nRegId, 0, nBoxId, 0) != REGC_OUT)
|
||||
return false ;
|
||||
@@ -721,7 +724,7 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d&
|
||||
return false ;
|
||||
}
|
||||
|
||||
// Verifico con l'eventuale regione di riferimento
|
||||
// Verifico con l'eventuale regione di riferimento (controllo semplice)
|
||||
// recupero la regione
|
||||
int nRefReg = pGeomDB->GetFirstNameInGroup( nGroupId, NST_REFERENCE_REG) ;
|
||||
if ( pGeomDB->ExistsInfo( nRefReg, KEY_NST_OFF))
|
||||
@@ -749,17 +752,17 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d&
|
||||
vDmgReg.emplace_back( nId) ;
|
||||
nId = pGeomDB->GetNextName( nId, NST_DAMAGED_REG) ;
|
||||
}
|
||||
// regioni dei pezzi rispetto alle regioni delle aree danneggiate
|
||||
// regioni dei pezzi rispetto alle regioni delle aree danneggiate (controllo completo)
|
||||
for ( int nRegId : vReg) {
|
||||
for ( int nDmgRegId : vDmgReg) {
|
||||
if ( ExeSurfFrChunkSimpleClassify( nRegId, 0, nDmgRegId, 0) != REGC_OUT)
|
||||
if ( ExeSurfFlatRegionInterference( nRegId, 0, nDmgRegId, 0) != REGC_OUT)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
for ( int nDwnRegId : vDwnReg) {
|
||||
if ( nDwnRegId != GDB_ID_NULL) {
|
||||
for ( int nDmgRegId : vDmgReg) {
|
||||
if ( ExeSurfFrChunkSimpleClassify( nDwnRegId, 0, nDmgRegId, 0) != REGC_OUT)
|
||||
if ( ExeSurfFlatRegionInterference( nDwnRegId, 0, nDmgRegId, 0) != REGC_OUT)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -800,59 +803,62 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d&
|
||||
nId2 = ( bInRoot ? ExeGetNextPart( nId2, true) : ExeGetNextGroup( nId2)) ;
|
||||
}
|
||||
|
||||
// Eseguo verifiche
|
||||
// Eseguo verifiche (controllo completo)
|
||||
// regioni dei pezzi
|
||||
for ( size_t i = 0 ; i < vReg.size() ; ++ i) {
|
||||
// verifico con le regioni degli altri pezzi (sempre regioni standard)
|
||||
for ( int i = 0 ; i < ssize( vReg) ; ++ i) {
|
||||
// verifico con le regioni degli altri pezzi
|
||||
for ( int nOthRegId : vOthReg) {
|
||||
if ( ExeSurfFrChunkSimpleClassify( vReg[i], 0, nOthRegId, 0) != REGC_OUT)
|
||||
if ( ExeSurfFlatRegionInterference( vReg[i], 0, nOthRegId, 0) != REGC_OUT)
|
||||
return false ;
|
||||
}
|
||||
// e con le regioni dei tagli degli altri pezzi (se esistono le regioni up devo usarle)
|
||||
int nRegUpId = ((vUpReg[i] == GDB_ID_NULL) ? vReg[i] : vUpReg[i]) ;
|
||||
int nRegUpId = ( ( vUpReg[i] == GDB_ID_NULL) ? vReg[i] : vUpReg[i]) ;
|
||||
for ( int nOthCutRegId : vOthCutReg) {
|
||||
if ( ExeSurfFrChunkSimpleClassify( nRegUpId, 0, nOthCutRegId, 0) != REGC_OUT)
|
||||
if ( ExeSurfFlatRegionInterference( nRegUpId, 0, nOthCutRegId, 0) != REGC_OUT)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// regioni sotto dei pezzi
|
||||
for ( size_t i = 0 ; i < vDwnReg.size() ; ++ i) {
|
||||
|
||||
// regioni sotto dei pezzi (controllo completo)
|
||||
for ( int i = 0 ; i < ssize( vDwnReg) ; ++ i) {
|
||||
// verifico con le regioni sotto degli altri pezzi
|
||||
for ( size_t j = 0 ; j < vOthDwnReg.size() ; ++ j) {
|
||||
for ( int j = 0 ; j < ssize( vOthDwnReg) ; ++ j) {
|
||||
if ( vDwnReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) {
|
||||
int nDwnRegId = ( vDwnReg[i] != GDB_ID_NULL ? vDwnReg[i] : vReg[i]) ;
|
||||
int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ;
|
||||
if ( ExeSurfFrChunkSimpleClassify( nDwnRegId, 0, nOthDwnRegId, 0) != REGC_OUT)
|
||||
if ( ExeSurfFlatRegionInterference( nDwnRegId, 0, nOthDwnRegId, 0) != REGC_OUT)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// e con le regioni sotto dei tagli degli altri pezzi
|
||||
for ( size_t j = 0 ; j < vOthDwnCutReg.size() ; ++ j) {
|
||||
for ( int j = 0 ; j < ssize( vOthDwnCutReg) ; ++ j) {
|
||||
if ( vDwnReg[i] != GDB_ID_NULL || vOthDwnCutReg[j] != GDB_ID_NULL) {
|
||||
int nDwnRegId = ( vDwnReg[i] != GDB_ID_NULL ? vDwnReg[i] : vReg[i]) ;
|
||||
int nOthDwnCutRegId = ( vOthDwnCutReg[j] != GDB_ID_NULL ? vOthDwnCutReg[j] : vOthCutReg[j]) ;
|
||||
if ( ExeSurfFrChunkSimpleClassify( nDwnRegId, 0, nOthDwnCutRegId, 0) != REGC_OUT)
|
||||
if ( ExeSurfFlatRegionInterference( nDwnRegId, 0, nOthDwnCutRegId, 0) != REGC_OUT)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// regioni delle lavorazioni dei pezzi
|
||||
for ( int nCutRegId : vCutReg) {
|
||||
// le confronto con le regioni degli altri pezzi
|
||||
for ( size_t j = 0 ; j < vOthReg.size() ; ++ j) {
|
||||
int nOthUpRegId = (( vOthUpReg[j] == GDB_ID_NULL) ? vOthReg[j] : vOthUpReg[j]) ;
|
||||
if ( ExeSurfFrChunkSimpleClassify( nCutRegId, 0, nOthUpRegId, 0) != REGC_OUT)
|
||||
// le confronto con le regioni degli altri pezzi (controllo completo)
|
||||
for ( int j = 0 ; j < ssize( vOthReg) ; ++ j) {
|
||||
int nOthUpRegId = ( ( vOthUpReg[j] == GDB_ID_NULL) ? vOthReg[j] : vOthUpReg[j]) ;
|
||||
if ( ExeSurfFlatRegionInterference( nCutRegId, 0, nOthUpRegId, 0) != REGC_OUT)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
// regioni sotto delle lavorazioni dei pezzi
|
||||
for ( size_t i = 0 ; i < vDwnCutReg.size() ; ++ i) {
|
||||
// le confronto con le regioni sotto degli altri pezzi
|
||||
for ( size_t j = 0 ; j < vOthDwnReg.size() ; ++ j) {
|
||||
for ( int i = 0 ; i < ssize( vDwnCutReg) ; ++ i) {
|
||||
// le confronto con le regioni sotto degli altri pezzi (controllo completo)
|
||||
for ( int j = 0 ; j < ssize( vOthDwnReg) ; ++ j) {
|
||||
if ( vDwnCutReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) {
|
||||
int nDwnCutRegId = ( vDwnCutReg[i] != GDB_ID_NULL ? vDwnCutReg[i] : vCutReg[i]) ;
|
||||
int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ;
|
||||
if ( ExeSurfFrChunkSimpleClassify( nDwnCutRegId, 0, nOthDwnRegId, 0) != REGC_OUT)
|
||||
if ( ExeSurfFlatRegionInterference( nDwnCutRegId, 0, nOthDwnRegId, 0) != REGC_OUT)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -1031,14 +1037,14 @@ ExePackPartCluster( const INTVECTOR& vIds, bool bReducedCut, bool bBottomUp)
|
||||
double dRegClDimY = b3RegCluster.GetMax().y - b3RegCluster.GetMin().y ;
|
||||
Point3d ptOrig = b3RegCluster.GetMin() ;
|
||||
|
||||
// Determino punto più in basso a sinistra del cluster
|
||||
// Determino punto più in basso a sinistra del cluster
|
||||
Point3d ptBL = b3RegCluster.GetMax() ;
|
||||
double dDimBottom = 0 ;
|
||||
for ( int nId : vTrueIds) {
|
||||
// recupero l'approssimazione lineare del contorno del pezzo ( in globale)
|
||||
PolyLine PL ;
|
||||
if ( GetFlatPartApproxContour( pGeomDB, nId, PL)) {
|
||||
// cerco il punto più in basso a sinistra
|
||||
// cerco il punto più in basso a sinistra
|
||||
Point3d ptP ;
|
||||
bool bFound = PL.GetFirstPoint( ptP) ;
|
||||
while ( bFound) {
|
||||
@@ -1163,6 +1169,7 @@ UpdateCollId( double dLen, double dPrevLen, int nId1, int nId2, bool bIsCut1, bo
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Collisione semplice
|
||||
static bool
|
||||
MySurfFrMoveSimpleNoCollision( int nId1, int nId2, const Vector3d& vtDir, double& dLen, SCollInfo& scInfo)
|
||||
{
|
||||
@@ -1170,23 +1177,27 @@ MySurfFrMoveSimpleNoCollision( int nId1, int nId2, const Vector3d& vtDir, double
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la prima superficie FlatRegion
|
||||
ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ;
|
||||
bool bOk = ( pSfr1 != nullptr) ;
|
||||
if ( pSfr1 == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf1 ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nId1, frSurf1) ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId1, frSurf1))
|
||||
return false ;
|
||||
// recupero la seconda superficie FlatRegion
|
||||
const ISurfFlatRegion* pSfr2 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId2)) ;
|
||||
bOk = bOk && ( pSfr2 != nullptr) ;
|
||||
if ( pSfr2 == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf2 ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nId2, frSurf2) ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId2, frSurf2))
|
||||
return false ;
|
||||
// se riferimenti diversi, porto una copia della seconda nel riferimento della prima
|
||||
const ISurfFlatRegion* pSfr2L = pSfr2 ;
|
||||
PtrOwner<ISurfFlatRegion> pTmp ;
|
||||
if ( ! AreSameFrame( frSurf1, frSurf2)) {
|
||||
pTmp.Set( pSfr2->Clone()) ;
|
||||
bOk = bOk && ! IsNull( pTmp) ;
|
||||
bOk = bOk && pTmp->LocToLoc( frSurf2, frSurf1) ;
|
||||
if ( IsNull( pTmp) || ! pTmp->LocToLoc( frSurf2, frSurf1))
|
||||
return false ;
|
||||
pSfr2L = pTmp ;
|
||||
}
|
||||
// porto in locale alla prima superficie il versore di movimento
|
||||
@@ -1194,21 +1205,71 @@ MySurfFrMoveSimpleNoCollision( int nId1, int nId2, const Vector3d& vtDir, double
|
||||
vtDirL.ToLoc( frSurf1) ;
|
||||
// calcolo massima lunghezza di traslazione della prima regione senza semplice collisione con la seconda
|
||||
CAvSimpleSurfFrMove ScdSfrMove( *pSfr1, *pSfr2L) ;
|
||||
bOk = bOk && ScdSfrMove.Translate( vtDirL, dLen) ;
|
||||
if ( bOk) {
|
||||
scInfo = ScdSfrMove.GetSCollInfo() ;
|
||||
if ( scInfo.nType != SCI_NONE) {
|
||||
scInfo.ptP1.ToGlob( frSurf1) ;
|
||||
scInfo.vtDirM.ToGlob( frSurf1) ;
|
||||
scInfo.vtDirF.ToGlob( frSurf1) ;
|
||||
}
|
||||
if ( scInfo.nType == SCI_LINE_LINE)
|
||||
scInfo.ptP2.ToGlob( frSurf1) ;
|
||||
if ( ! ScdSfrMove.Translate( vtDirL, dLen))
|
||||
return false ;
|
||||
scInfo = ScdSfrMove.GetSCollInfo() ;
|
||||
if ( scInfo.nType != SCI_NONE) {
|
||||
scInfo.ptP1.ToGlob( frSurf1) ;
|
||||
scInfo.vtDirM.ToGlob( frSurf1) ;
|
||||
scInfo.vtDirF.ToGlob( frSurf1) ;
|
||||
}
|
||||
return bOk ;
|
||||
if ( scInfo.nType == SCI_LINE_LINE)
|
||||
scInfo.ptP2.ToGlob( frSurf1) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Collisione completa
|
||||
static bool
|
||||
MySurfFrMoveNoCollision( int nId1, int nId2, const Vector3d& vtDir, double& dLen, SCollInfo& cInfo)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la prima superficie FlatRegion
|
||||
ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ;
|
||||
if ( pSfr1 == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf1 ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId1, frSurf1))
|
||||
return false ;
|
||||
// recupero la seconda superficie FlatRegion
|
||||
const ISurfFlatRegion* pSfr2 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId2)) ;
|
||||
if ( pSfr2 == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf2 ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId2, frSurf2))
|
||||
return false ;
|
||||
// se riferimenti diversi, porto una copia della seconda nel riferimento della prima
|
||||
const ISurfFlatRegion* pSfr2L = pSfr2 ;
|
||||
PtrOwner<ISurfFlatRegion> pTmp ;
|
||||
if ( ! AreSameFrame( frSurf1, frSurf2)) {
|
||||
pTmp.Set( pSfr2->Clone()) ;
|
||||
if ( IsNull( pTmp) || ! pTmp->LocToLoc( frSurf2, frSurf1))
|
||||
return false ;
|
||||
pSfr2L = pTmp ;
|
||||
}
|
||||
// porto in locale alla prima superficie il versore di movimento
|
||||
Vector3d vtDirL = vtDir ;
|
||||
vtDirL.ToLoc( frSurf1) ;
|
||||
// calcolo massima lunghezza di traslazione della prima regione senza collisione con la seconda
|
||||
CAvSurfFrMove cdSfrMove( *pSfr1, *pSfr2L) ;
|
||||
if ( ! cdSfrMove.Translate( vtDirL, dLen))
|
||||
return false ;
|
||||
cInfo = cdSfrMove.GetCollInfo() ;
|
||||
if ( cInfo.nType != SCI_NONE) {
|
||||
cInfo.ptP1.ToGlob( frSurf1) ;
|
||||
cInfo.vtDirM.ToGlob( frSurf1) ;
|
||||
cInfo.vtDirF.ToGlob( frSurf1) ;
|
||||
}
|
||||
if ( cInfo.nType == SCI_LINE_LINE)
|
||||
cInfo.ptP2.ToGlob( frSurf1) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Traslazione con CAvSurfFr
|
||||
static bool
|
||||
MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster, bool bReducedCut, Vector3d& vtMove)
|
||||
{
|
||||
@@ -1293,67 +1354,67 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster
|
||||
bOk = false ;
|
||||
break ;
|
||||
}
|
||||
// la confronto con il box
|
||||
// la confronto con il box (collisione semplice)
|
||||
MySurfFrMoveSimpleNoCollision( nRegId, nBoxId, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nBoxId, false, false, scInfoCurr) ;
|
||||
// la confronto con la regione di riferimento
|
||||
// la confronto con la regione di riferimento (collisione semplice)
|
||||
if ( nRefReg != GDB_ID_NULL) {
|
||||
MySurfFrMoveSimpleNoCollision( nRegId, nRefReg, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nRefReg, false, false, scInfoCurr) ;
|
||||
}
|
||||
// la confronto con le aree danneggiate
|
||||
// la confronto con le aree danneggiate (collisione completa)
|
||||
for ( int nDmgRegId : vDmgReg) {
|
||||
MySurfFrMoveSimpleNoCollision( nRegId, nDmgRegId, vtDir, dLen, scInfoCurr) ;
|
||||
MySurfFrMoveNoCollision( nRegId, nDmgRegId, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nDmgRegId, false, false, scInfoCurr) ;
|
||||
}
|
||||
// la confronto con le regioni degli altri pezzi
|
||||
// la confronto con le regioni degli altri pezzi (collisione completa)
|
||||
for ( int nOthRegId : vOthReg) {
|
||||
MySurfFrMoveSimpleNoCollision( nRegId, nOthRegId, vtDir, dLen, scInfoCurr) ;
|
||||
MySurfFrMoveNoCollision( nRegId, nOthRegId, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nOthRegId, false, false, scInfoCurr) ;
|
||||
}
|
||||
// e con le regioni dei tagli degli altri pezzi
|
||||
// recupero regione in alto del pezzo
|
||||
// recupero regione in alto del pezzo (collisione completa)
|
||||
int nUpRegId = GetFlatPartUpRegion( pGeomDB, nTrueId) ;
|
||||
int nTestRegId = (( nUpRegId == GDB_ID_NULL) ? nRegId : nUpRegId) ;
|
||||
for ( int nOthCutRegId : vOthCutReg) {
|
||||
MySurfFrMoveSimpleNoCollision( nTestRegId, nOthCutRegId, vtDir, dLen, scInfoCurr) ;
|
||||
MySurfFrMoveNoCollision( nTestRegId, nOthCutRegId, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nTestRegId, nOthCutRegId, false, true, scInfoCurr) ;
|
||||
}
|
||||
// -----------------------------------------
|
||||
// recupero regione in basso del pezzo
|
||||
int nDwnRegId = GetFlatPartDownRegion( pGeomDB, nTrueId) ;
|
||||
// la confronto con il box
|
||||
// la confronto con il box (collisone semplice)
|
||||
if ( nDwnRegId != GDB_ID_NULL) {
|
||||
MySurfFrMoveSimpleNoCollision( nDwnRegId, nBoxId, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nDwnRegId, nBoxId, false, false, scInfoCurr) ;
|
||||
}
|
||||
// la confronto con la regione di riferimento
|
||||
// la confronto con la regione di riferimento (collisione completa)
|
||||
if ( nDwnRegId != GDB_ID_NULL && nRefReg != GDB_ID_NULL) {
|
||||
MySurfFrMoveSimpleNoCollision( nDwnRegId, nRefReg, vtDir, dLen, scInfoCurr) ;
|
||||
MySurfFrMoveNoCollision( nDwnRegId, nRefReg, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nDwnRegId, nRefReg, false, false, scInfoCurr) ;
|
||||
}
|
||||
// la confronto con le aree danneggiate
|
||||
// la confronto con le aree danneggiate (collisione completa)
|
||||
if ( nDwnRegId != GDB_ID_NULL) {
|
||||
for ( int nDmgRegId : vDmgReg) {
|
||||
MySurfFrMoveSimpleNoCollision( nDwnRegId, nDmgRegId, vtDir, dLen, scInfoCurr) ;
|
||||
MySurfFrMoveNoCollision( nDwnRegId, nDmgRegId, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nDwnRegId, nDmgRegId, false, false, scInfoCurr) ;
|
||||
}
|
||||
}
|
||||
// la confronto con le regioni in basso degli altri pezzi
|
||||
for ( size_t j = 0 ; j < vOthDwnReg.size() ; ++ j) {
|
||||
// la confronto con le regioni in basso degli altri pezzi (collisione completa)
|
||||
for ( int j = 0 ; j < ssize( vOthDwnReg) ; ++ j) {
|
||||
if ( nDwnRegId != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) {
|
||||
int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ;
|
||||
int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ;
|
||||
MySurfFrMoveSimpleNoCollision( nTmpDwnRegId, nOthDwnRegId, vtDir, dLen, scInfoCurr) ;
|
||||
MySurfFrMoveNoCollision( nTmpDwnRegId, nOthDwnRegId, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnRegId, nOthDwnRegId, false, false, scInfoCurr) ;
|
||||
}
|
||||
}
|
||||
// e con le regioni in basso dei tagli degli altri pezzi
|
||||
for ( size_t j = 0 ; j < vOthDwnCutReg.size() ; ++ j) {
|
||||
// e con le regioni in basso dei tagli degli altri pezzi (collisione completa)
|
||||
for ( int j = 0 ; j < ssize( vOthDwnCutReg) ; ++ j) {
|
||||
if ( nDwnRegId != GDB_ID_NULL || vOthDwnCutReg[j] != GDB_ID_NULL) {
|
||||
int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ;
|
||||
int nOthDwnCutRegId = ( vOthDwnCutReg[j] != GDB_ID_NULL ? vOthDwnCutReg[j] : vOthCutReg[j]) ;
|
||||
MySurfFrMoveSimpleNoCollision( nTmpDwnRegId, nOthDwnCutRegId, vtDir, dLen, scInfoCurr) ;
|
||||
MySurfFrMoveNoCollision( nTmpDwnRegId, nOthDwnCutRegId, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnRegId, nOthDwnCutRegId, false, true, scInfoCurr) ;
|
||||
}
|
||||
}
|
||||
@@ -1364,11 +1425,11 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster
|
||||
bOk = false ;
|
||||
break ;
|
||||
}
|
||||
// le confronto con le regioni degli altri pezzi
|
||||
// le confronto con le regioni degli altri pezzi (collisione completa)
|
||||
for ( int nCrId : vCrId) {
|
||||
for ( size_t k = 0 ; k < vOthReg.size() ; ++ k) {
|
||||
for ( int k = 0 ; k < ssize( vOthReg) ; ++ k) {
|
||||
int nOthRegId = ( vOthUpReg[k] == GDB_ID_NULL ? vOthReg[k] : vOthUpReg[k]) ;
|
||||
MySurfFrMoveSimpleNoCollision( nCrId, nOthRegId, vtDir, dLen, scInfoCurr) ;
|
||||
MySurfFrMoveNoCollision( nCrId, nOthRegId, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nCrId, nOthRegId, true, false, scInfoCurr) ;
|
||||
}
|
||||
}
|
||||
@@ -1379,13 +1440,13 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster
|
||||
bOk = false ;
|
||||
break ;
|
||||
}
|
||||
// le confronto con le regioni in basso degli altri pezzi
|
||||
for ( size_t j = 0 ; j < vDwnCrId.size() ; ++ j) {
|
||||
for ( size_t k = 0 ; k < vOthDwnReg.size() ; ++ k) {
|
||||
// le confronto con le regioni in basso degli altri pezzi (collisione completa)
|
||||
for ( int j = 0 ; j < ssize( vDwnCrId) ; ++ j) {
|
||||
for ( int k = 0 ; k < ssize( vOthDwnReg) ; ++ k) {
|
||||
if ( vDwnCrId[j] != GDB_ID_NULL || vOthDwnReg[k] != GDB_ID_NULL) {
|
||||
int nTmpDwnCrId = ( vDwnCrId[j] != GDB_ID_NULL ? vDwnCrId[j] : vCrId[j]) ;
|
||||
int nOthDwnRegId = ( vOthDwnReg[k] != GDB_ID_NULL ? vOthDwnReg[k] : vOthReg[k]) ;
|
||||
MySurfFrMoveSimpleNoCollision( nTmpDwnCrId, nOthDwnRegId, vtDir, dLen, scInfoCurr) ;
|
||||
MySurfFrMoveNoCollision( nTmpDwnCrId, nOthDwnRegId, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnCrId, nOthDwnRegId, true, false, scInfoCurr) ;
|
||||
}
|
||||
}
|
||||
@@ -1419,7 +1480,7 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster
|
||||
}
|
||||
}
|
||||
|
||||
// Se movimento risultante nullo, non faccio alcunché
|
||||
// Se movimento risultante nullo, non faccio alcunché
|
||||
vtMoveXY = vtDir * dLen ;
|
||||
if ( vtMoveXY.IsSmall())
|
||||
return true ;
|
||||
@@ -1464,7 +1525,7 @@ ExeMovePartCluster( const INTVECTOR& vIds, bool bReducedCut, Vector3d& vtMove)
|
||||
vtMove = vtM ;
|
||||
return true ;
|
||||
}
|
||||
// altrimenti, riprovo con tagli standard
|
||||
// altrimenti, riprovo con tagli standard
|
||||
else {
|
||||
// annullo il movimento
|
||||
for ( int nId : vTrueIds)
|
||||
@@ -1475,7 +1536,50 @@ ExeMovePartCluster( const INTVECTOR& vIds, bool bReducedCut, Vector3d& vtMove)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
MySurfFrRotateNoCollision( int nId1, int nId2, const Point3d& ptCen, double& dAngDeg, SCollInfo& cInfo)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la prima superficie FlatRegion
|
||||
ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ;
|
||||
if ( pSfr1 == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf1 ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId1, frSurf1))
|
||||
return false ;
|
||||
// recupero la seconda superficie FlatRegion
|
||||
const ISurfFlatRegion* pSfr2 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId2)) ;
|
||||
if ( pSfr2 == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf2 ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId2, frSurf2))
|
||||
return false ;
|
||||
// se riferimenti diversi, porto una copia della seconda nel riferimento della prima
|
||||
const ISurfFlatRegion* pSfr2L = pSfr2 ;
|
||||
PtrOwner<ISurfFlatRegion> pTmp ;
|
||||
if ( ! AreSameFrame( frSurf1, frSurf2)) {
|
||||
pTmp.Set( pSfr2->Clone()) ;
|
||||
if ( IsNull( pTmp) || ! pTmp->LocToLoc( frSurf2, frSurf1))
|
||||
return false ;
|
||||
pSfr2L = pTmp ;
|
||||
}
|
||||
// porto in locale alla prima superficie il punto di rotazione
|
||||
Point3d ptCenL = ptCen ;
|
||||
ptCenL.ToLoc( frSurf1) ;
|
||||
// calcolo massima lunghezza di traslazione della prima regione senza collisione con la seconda
|
||||
CAvSurfFrMove cdSfrMove( *pSfr1, *pSfr2L) ;
|
||||
if ( ! cdSfrMove.Rotate( ptCenL, dAngDeg))
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Rotazione con CAvSurfFr
|
||||
bool
|
||||
MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Cluster, bool bReducedCut,
|
||||
const Point3d& ptCen, double& dRotAngDeg)
|
||||
@@ -1553,21 +1657,21 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus
|
||||
bOk = false ;
|
||||
break ;
|
||||
}
|
||||
// la confronto con il box
|
||||
// la confronto con il box (collisione semplice)
|
||||
ExeSurfFrRotateSimpleNoCollision( nRegId, nBoxId, ptCen, dAng, RTY_GLOB) ;
|
||||
// la confronto con la regione di riferimento
|
||||
// la confronto con la regione di riferimento (collisione semplice)
|
||||
if ( nRefReg != GDB_ID_NULL) {
|
||||
ExeSurfFrRotateSimpleNoCollision( nRegId, nRefReg, ptCen, dAng, RTY_GLOB) ;
|
||||
}
|
||||
// la confronto con le aree danneggiate
|
||||
// la confronto con le aree danneggiate (collisione completa)
|
||||
for ( int nDmgRegId : vDmgReg) {
|
||||
ExeSurfFrRotateSimpleNoCollision( nRegId, nDmgRegId, ptCen, dAng, RTY_GLOB) ;
|
||||
MySurfFrRotateNoCollision( nRegId, nDmgRegId, ptCen, dAng, s_scInfo) ;
|
||||
}
|
||||
// la confronto con le regioni degli altri pezzi
|
||||
// la confronto con le regioni degli altri pezzi (collisione completa)
|
||||
for ( int nOthRegId : vOthReg) {
|
||||
ExeSurfFrRotateSimpleNoCollision( nRegId, nOthRegId, ptCen, dAng, RTY_GLOB) ;
|
||||
MySurfFrRotateNoCollision( nRegId, nOthRegId, ptCen, dAng, s_scInfo) ;
|
||||
}
|
||||
// e con le regioni dei tagli degli altri pezzi
|
||||
// e con le regioni dei tagli degli altri pezzi (collisione completa)
|
||||
// recupero regione in alto del pezzo
|
||||
int nUpRegId = GetFlatPartUpRegion( pGeomDB, nTrueId) ;
|
||||
int nTestRegId = (( nUpRegId == GDB_ID_NULL) ? nRegId : nUpRegId) ;
|
||||
@@ -1577,33 +1681,33 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus
|
||||
// -----------------------------------------
|
||||
// recupero regione in basso del pezzo
|
||||
int nDwnRegId = GetFlatPartDownRegion( pGeomDB, nTrueId) ;
|
||||
// la confronto con il box
|
||||
// la confronto con il box (collisione semplice)
|
||||
if ( nDwnRegId != GDB_ID_NULL)
|
||||
ExeSurfFrRotateSimpleNoCollision( nDwnRegId, nBoxId, ptCen, dAng, RTY_GLOB) ;
|
||||
// la confronto con la regione di riferimento
|
||||
// la confronto con la regione di riferimento (collisione semplice)
|
||||
if ( nRefReg != GDB_ID_NULL) {
|
||||
ExeSurfFrRotateSimpleNoCollision( nDwnRegId, nRefReg, ptCen, dAng, RTY_GLOB) ;
|
||||
}
|
||||
// la confronto con le aree danneggiate
|
||||
// la confronto con le aree danneggiate (collisione completa)
|
||||
if ( nDwnRegId != GDB_ID_NULL) {
|
||||
for ( int nDmgRegId : vDmgReg) {
|
||||
ExeSurfFrRotateSimpleNoCollision( nDwnRegId, nDmgRegId, ptCen, dAng, RTY_GLOB) ;
|
||||
MySurfFrRotateNoCollision( nDwnRegId, nDmgRegId, ptCen, dAng, s_scInfo) ;
|
||||
}
|
||||
}
|
||||
// la confronto con le regioni in basso degli altri pezzi
|
||||
for ( size_t j = 0 ; j < vOthDwnReg.size() ; ++ j) {
|
||||
// la confronto con le regioni in basso degli altri pezzi (collisione completa)
|
||||
for ( int j = 0 ; j < ssize( vOthDwnReg) ; ++ j) {
|
||||
if ( nDwnRegId != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) {
|
||||
int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ;
|
||||
int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ;
|
||||
ExeSurfFrRotateSimpleNoCollision( nTmpDwnRegId, nOthDwnRegId, ptCen, dAng, RTY_GLOB) ;
|
||||
MySurfFrRotateNoCollision( nTmpDwnRegId, nOthDwnRegId, ptCen, dAng, s_scInfo) ;
|
||||
}
|
||||
}
|
||||
// e con le regioni in basso dei tagli degli altri pezzi
|
||||
for ( size_t j = 0 ; j < vOthDwnCutReg.size() ; ++ j) {
|
||||
// e con le regioni in basso dei tagli degli altri pezzi (collisione completa)
|
||||
for ( int j = 0 ; j < ssize( vOthDwnCutReg) ; ++ j) {
|
||||
if ( nDwnRegId != GDB_ID_NULL || vOthDwnCutReg[j] != GDB_ID_NULL) {
|
||||
int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ;
|
||||
int nOthDwnCutRegId = ( vOthDwnCutReg[j] != GDB_ID_NULL ? vOthDwnCutReg[j] : vOthCutReg[j]) ;
|
||||
ExeSurfFrRotateSimpleNoCollision( nTmpDwnRegId, nOthDwnCutRegId, ptCen, dAng, RTY_GLOB) ;
|
||||
MySurfFrRotateNoCollision( nTmpDwnRegId, nOthDwnCutRegId, ptCen, dAng, s_scInfo) ;
|
||||
}
|
||||
}
|
||||
// -----------------------------------------
|
||||
@@ -1613,11 +1717,11 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus
|
||||
bOk = false ;
|
||||
break ;
|
||||
}
|
||||
// le confronto con le regioni degli altri pezzi
|
||||
// le confronto con le regioni degli altri pezzi (collisione completa)
|
||||
for ( int nCrId : vCrId) {
|
||||
for ( size_t k = 0 ; k < vOthReg.size() ; ++ k) {
|
||||
for ( int k = 0 ; k < ssize( vOthReg) ; ++ k) {
|
||||
int nOthRegId = ( vOthUpReg[k] == GDB_ID_NULL ? vOthReg[k] : vOthUpReg[k]) ;
|
||||
ExeSurfFrRotateSimpleNoCollision( nCrId, nOthRegId, ptCen, dAng, RTY_GLOB) ;
|
||||
MySurfFrRotateNoCollision( nCrId, nOthRegId, ptCen, dAng, s_scInfo) ;
|
||||
}
|
||||
}
|
||||
// -----------------------------------------
|
||||
@@ -1627,13 +1731,13 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus
|
||||
bOk = false ;
|
||||
break ;
|
||||
}
|
||||
// le confronto con le regioni in basso degli altri pezzi
|
||||
for ( size_t j = 0 ; j < vDwnCrId.size() ; ++ j) {
|
||||
for ( size_t k = 0 ; k < vOthDwnReg.size() ; ++ k) {
|
||||
// le confronto con le regioni in basso degli altri pezzi (collisione completa)
|
||||
for ( int j = 0 ; j < ssize( vDwnCrId) ; ++ j) {
|
||||
for ( int k = 0 ; k < ssize( vOthDwnReg) ; ++ k) {
|
||||
if ( vDwnCrId[j] != GDB_ID_NULL || vOthDwnReg[k] != GDB_ID_NULL) {
|
||||
int nTmpDwnCrId = ( vDwnCrId[j] != GDB_ID_NULL ? vDwnCrId[j] : vCrId[j]) ;
|
||||
int nOthDwnRegId = ( vOthDwnReg[k] != GDB_ID_NULL ? vOthDwnReg[k] : vOthReg[k]) ;
|
||||
ExeSurfFrRotateSimpleNoCollision( nTmpDwnCrId, nOthDwnRegId, ptCen, dAng, RTY_GLOB) ;
|
||||
MySurfFrRotateNoCollision( nTmpDwnCrId, nOthDwnRegId, ptCen, dAng, s_scInfo) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1643,7 +1747,7 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus
|
||||
if ( ! bOk)
|
||||
return false ;
|
||||
|
||||
// Se movimento risultante nullo, non faccio alcunché
|
||||
// Se movimento risultante nullo, non faccio alcunché
|
||||
dRotAngDeg = dAng ;
|
||||
if ( abs( dAng) < EPS_ANG_SMALL)
|
||||
return true ;
|
||||
@@ -1686,7 +1790,7 @@ GetObstacleTangent( Vector3d& vtTang)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
GetMovingTangent( Vector3d& vtTang)
|
||||
GetMovingTangent( Vector3d& vtTang)
|
||||
{
|
||||
if ( s_scInfo.nType != SCI_LINE_PNT && s_scInfo.nType != SCI_LINE_LINE)
|
||||
return false ;
|
||||
@@ -1733,7 +1837,7 @@ ExeAlignPartClusterOnCollision( const INTVECTOR& vIds, bool bReducedCut, bool& b
|
||||
Point3d ptCntL = s_scInfo.ptP1 ;
|
||||
ptCntL.ToLoc( frSfr) ;
|
||||
// cerco le direzioni tangenti prima e dopo il punto di contatto sulle parti mobili
|
||||
PtrOwner<ICurve> pCrv( pSfr->GetLoop( s_scInfo.nChunkM, 0)) ;
|
||||
PtrOwner<ICurve> pCrv( pSfr->GetLoop( s_scInfo.nChunkM, s_scInfo.nLoopM)) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
double dU ;
|
||||
@@ -1760,7 +1864,7 @@ ExeAlignPartClusterOnCollision( const INTVECTOR& vIds, bool bReducedCut, bool& b
|
||||
string sOut = "vtTp=(" + ToString( vtTp) + ") vtTn=(" + ToString( vtTn) + ")" ;
|
||||
LOG_INFO( GetLogger(), sOut.c_str()) ;
|
||||
}
|
||||
// ruoto dalla parte dell'angolo più piccolo (componente più grande)
|
||||
// ruoto dalla parte dell'angolo più piccolo (componente più grande)
|
||||
double dRotAngDeg = ( abs( vtTp * s_scInfo.vtDirF) > abs( vtTn * s_scInfo.vtDirF)) ? 90 : - 90 ;
|
||||
// provo a ruotare sul punto di collisione in senso orario
|
||||
Point3d ptCen = s_scInfo.ptP1 ;
|
||||
@@ -1784,6 +1888,7 @@ ExeMoveToSnapPointOnCollision( const INTVECTOR& vIds, bool bReducedCut, double d
|
||||
// cerco i due tagli in collisione
|
||||
int nCutM = GDB_ID_NULL ;
|
||||
int nGeoM = GDB_ID_NULL ;
|
||||
INTVECTOR vnGeoM, vnGeoF ;
|
||||
Point3d ptStartM, ptEndM ;
|
||||
Vector3d vtDirM ;
|
||||
Frame3d frGeoM ;
|
||||
@@ -1792,13 +1897,38 @@ ExeMoveToSnapPointOnCollision( const INTVECTOR& vIds, bool bReducedCut, double d
|
||||
Point3d ptStartF, ptEndF ;
|
||||
Vector3d vtDirF ;
|
||||
Frame3d frGeoF ;
|
||||
// se mobile è già un taglio, ne ricavo i dati
|
||||
// se mobile è già un taglio, ne ricavo i dati
|
||||
if ( s_scInfo.bIsCutM) {
|
||||
if ( s_scInfo.nIdM == GDB_ID_NULL)
|
||||
return false ;
|
||||
nCutM = s_scInfo.nIdM ;
|
||||
nGeoM = GetGeometryFromCut( pGeomDB, pMachMgr, nCutM) ;
|
||||
ICurveLine* pLineM = GetCurveLine( pGeomDB->GetGeoObj( nGeoM)) ;
|
||||
if ( nCutM == GDB_ID_NULL || nGeoM == GDB_ID_NULL ||
|
||||
pLineM == nullptr || ! pGeomDB->GetGlobFrame( nGeoM, frGeoM))
|
||||
vnGeoM = GetGeometryFromCut( pGeomDB, pMachMgr, nCutM) ;
|
||||
if ( vnGeoM.empty())
|
||||
return false ;
|
||||
ICurveLine* pLineM = nullptr ;
|
||||
// se ho un solo taglio, allora è quello
|
||||
if ( ssize( vnGeoM) == 1) {
|
||||
pLineM = GetCurveLine( pGeomDB->GetGeoObj( vnGeoM[0])) ;
|
||||
nGeoM = vnGeoM[0] ;
|
||||
}
|
||||
// se più tagli, cerco quello più vicino alla linea corrente
|
||||
else {
|
||||
double dMinSqDist = INFINITO ;
|
||||
for ( int i = 0 ; i < ssize( vnGeoM) ; ++ i) {
|
||||
Frame3d frCurrGeoM ;
|
||||
ICurveLine* pCurrLineM = GetCurveLine( pGeomDB->GetGeoObj( vnGeoM[i])) ;
|
||||
if ( pCurrLineM == nullptr || ! pGeomDB->GetGlobFrame( vnGeoM[i], frCurrGeoM))
|
||||
return false ;
|
||||
double dCurrSqDist ;
|
||||
DistPointLine( GetToLoc( s_scInfo.ptP1, frCurrGeoM), *pCurrLineM).GetSqDist( dCurrSqDist) ;
|
||||
if ( dCurrSqDist < dMinSqDist) {
|
||||
dMinSqDist = dCurrSqDist ;
|
||||
pLineM = pCurrLineM ;
|
||||
nGeoM = vnGeoM[i] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( pLineM == nullptr || ! pGeomDB->GetGlobFrame( nGeoM, frGeoM))
|
||||
return false ;
|
||||
ptStartM = pLineM->GetStart() ;
|
||||
ptStartM.ToGlob( frGeoM) ;
|
||||
@@ -1807,13 +1937,36 @@ ExeMoveToSnapPointOnCollision( const INTVECTOR& vIds, bool bReducedCut, double d
|
||||
vtDirM = ptEndM - ptStartM ;
|
||||
vtDirM.Normalize() ;
|
||||
}
|
||||
// se fisso è già un taglio, ne ricavo i dati
|
||||
// se fisso è già un taglio, ne ricavo i dati
|
||||
if ( s_scInfo.bIsCutF) {
|
||||
if ( s_scInfo.nChunkF == GDB_ID_NULL)
|
||||
return false ;
|
||||
nCutF = s_scInfo.nIdF ;
|
||||
nGeoF = GetGeometryFromCut( pGeomDB, pMachMgr, nCutF) ;
|
||||
vnGeoF = GetGeometryFromCut( pGeomDB, pMachMgr, nCutF) ;
|
||||
ICurveLine* pLineF = GetCurveLine( pGeomDB->GetGeoObj( nGeoF)) ;
|
||||
if ( nCutF == GDB_ID_NULL || nGeoF == GDB_ID_NULL ||
|
||||
pLineF == nullptr || ! pGeomDB->GetGlobFrame( nGeoF, frGeoF))
|
||||
// se ho un solo taglio, allora è quello
|
||||
if ( ssize( vnGeoF) == 1) {
|
||||
pLineF = GetCurveLine( pGeomDB->GetGeoObj( vnGeoF[0])) ;
|
||||
nGeoF = vnGeoF[0] ;
|
||||
}
|
||||
// se più tagli, cerco quello più vicino alla linea corrente
|
||||
else {
|
||||
double dMinSqDist = INFINITO ;
|
||||
for ( int i = 0 ; i < ssize( vnGeoF) ; ++ i) {
|
||||
Frame3d frCurrGeoF ;
|
||||
ICurveLine* pCurrLineF = GetCurveLine( pGeomDB->GetGeoObj( vnGeoF[i])) ;
|
||||
if ( pCurrLineF == nullptr || ! pGeomDB->GetGlobFrame( vnGeoF[i], frCurrGeoF))
|
||||
return false ;
|
||||
double dCurrSqDist ;
|
||||
DistPointLine( GetToLoc( s_scInfo.ptP1, frCurrGeoF), *pCurrLineF).GetSqDist( dCurrSqDist) ;
|
||||
if ( dCurrSqDist < dMinSqDist) {
|
||||
dMinSqDist = dCurrSqDist ;
|
||||
pLineF = pCurrLineF ;
|
||||
nGeoF = vnGeoF[i] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( pLineF == nullptr || ! pGeomDB->GetGlobFrame( nGeoF, frGeoF))
|
||||
return false ;
|
||||
ptStartF = pLineF->GetStart() ;
|
||||
ptStartF.ToGlob( frGeoF) ;
|
||||
@@ -1838,8 +1991,31 @@ ExeMoveToSnapPointOnCollision( const INTVECTOR& vIds, bool bReducedCut, double d
|
||||
BBox3d b3Temp ;
|
||||
pGeomDB->GetGlobalBBox( nId, b3Temp) ;
|
||||
if ( b3Temp.OverlapsXY( b3CutM)) {
|
||||
int nGeom = GetGeometryFromCut( pGeomDB, pMachMgr, nId) ;
|
||||
ICurveLine* pLine = GetCurveLine( pGeomDB->GetGeoObj( nGeom)) ;
|
||||
int nGeom = GDB_ID_NULL ;
|
||||
INTVECTOR vnGeom = GetGeometryFromCut( pGeomDB, pMachMgr, nId) ;
|
||||
ICurveLine* pLine = nullptr ;
|
||||
// se ho un solo taglio, allora è quello
|
||||
if ( ssize( vnGeom) == 1) {
|
||||
pLine = GetCurveLine( pGeomDB->GetGeoObj( vnGeom[0])) ;
|
||||
nGeom = vnGeom[0] ;
|
||||
}
|
||||
// se ho più tagli, cerco quello più vicino alla linea corrente
|
||||
else {
|
||||
double dMinSqDist = INFINITO ;
|
||||
for ( int i = 0 ; i < ssize( vnGeom) ; ++ i) {
|
||||
Frame3d frCurrGeo ;
|
||||
ICurveLine* pCurrLine = GetCurveLine( pGeomDB->GetGeoObj( vnGeom[i])) ;
|
||||
if ( pCurrLine == nullptr || ! pGeomDB->GetGlobFrame( vnGeom[i], frCurrGeo))
|
||||
return false ;
|
||||
double dCurrSqDist ;
|
||||
DistPointLine( GetToLoc( s_scInfo.ptP1, frCurrGeo), *pCurrLine).GetSqDist( dCurrSqDist) ;
|
||||
if ( dCurrSqDist < dMinSqDist) {
|
||||
dMinSqDist = dCurrSqDist ;
|
||||
pLine = pCurrLine ;
|
||||
nGeom = vnGeom[i] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( nGeom == GDB_ID_NULL || pLine == nullptr || ! pGeomDB->GetGlobFrame( nGeom, frGeoF))
|
||||
continue ;
|
||||
ptStartF = pLine->GetStart() ;
|
||||
@@ -1872,8 +2048,31 @@ ExeMoveToSnapPointOnCollision( const INTVECTOR& vIds, bool bReducedCut, double d
|
||||
BBox3d b3Temp ;
|
||||
pGeomDB->GetGlobalBBox( nId, b3Temp) ;
|
||||
if ( b3Temp.OverlapsXY( b3CutF)) {
|
||||
int nGeom = GetGeometryFromCut( pGeomDB, pMachMgr, nId) ;
|
||||
ICurveLine* pLine = GetCurveLine( pGeomDB->GetGeoObj( nGeom)) ;
|
||||
int nGeom = GDB_ID_NULL ;
|
||||
INTVECTOR vnGeom = GetGeometryFromCut( pGeomDB, pMachMgr, nId) ;
|
||||
ICurveLine* pLine = nullptr ;
|
||||
// se ho un solo taglio, allora è quello
|
||||
if ( ssize( vnGeom) == 1) {
|
||||
pLine = GetCurveLine( pGeomDB->GetGeoObj( vnGeom[0])) ;
|
||||
nGeom = vnGeom[0] ;
|
||||
}
|
||||
// se ho più tagli, cerco quello più vicino alla linea corrente
|
||||
else {
|
||||
double dMinSqDist = INFINITO ;
|
||||
for ( int i = 0 ; i < ssize( vnGeom) ; ++ i) {
|
||||
Frame3d frCurrGeo ;
|
||||
ICurveLine* pCurrLine = GetCurveLine( pGeomDB->GetGeoObj( vnGeom[0])) ;
|
||||
if ( pCurrLine == nullptr || ! pGeomDB->GetGlobFrame( vnGeom[i], frCurrGeo))
|
||||
return false ;
|
||||
double dCurrSqDist ;
|
||||
DistPointLine( GetToLoc( s_scInfo.ptP1, frCurrGeo), *pCurrLine).GetSqDist( dCurrSqDist) ;
|
||||
if ( dCurrSqDist < dMinSqDist) {
|
||||
dMinSqDist = dCurrSqDist ;
|
||||
pLine = pCurrLine ;
|
||||
nGeom = vnGeom[i] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( nGeom == GDB_ID_NULL || pLine == nullptr || ! pGeomDB->GetGlobFrame( nGeom, frGeoM))
|
||||
continue ;
|
||||
ptStartM = pLine->GetStart() ;
|
||||
@@ -1950,9 +2149,9 @@ ExeMoveToSnapPointOnCollision( const INTVECTOR& vIds, bool bReducedCut, double d
|
||||
dMoveMn = CrossXY( ptStartF - ptEndM, vtDirFp) / dDenom ;
|
||||
}
|
||||
}
|
||||
// pareggio la parte più vicina, se almeno una sotto soglia
|
||||
// pareggio la parte più vicina, se almeno una sotto soglia
|
||||
if ( abs( dMoveMp) < dMaxMove || abs( dMoveMn) < dMaxMove) {
|
||||
// calcolo movimento necessario, se nullo già a posto
|
||||
// calcolo movimento necessario, se nullo già a posto
|
||||
Vector3d vtMove = (( abs( dMoveMp) < abs( dMoveMn)) ? dMoveMp : dMoveMn) * vtDirF ;
|
||||
if ( vtMove.IsSmall()) {
|
||||
bMoved = false ;
|
||||
@@ -1977,7 +2176,7 @@ ExeMoveToSnapPointOnCollision( const INTVECTOR& vIds, bool bReducedCut, double d
|
||||
pGeomDB->GetRefBBox( nCutM, frCutF, b3CutM) ;
|
||||
double dStartDelta = b3CutF.GetMin().x - b3CutM.GetMin().x ;
|
||||
double dEndDelta = b3CutF.GetMax().x - b3CutM.GetMax().x ;
|
||||
// pareggio la parte più vicina, se sotto soglia
|
||||
// pareggio la parte più vicina, se sotto soglia
|
||||
if ( abs( dStartDelta) > dMaxMove && abs( dEndDelta) > dMaxMove)
|
||||
return false ;
|
||||
Vector3d vtMove = (( abs( dStartDelta) < abs( dEndDelta)) ? dStartDelta : dEndDelta) * vtDirF ;
|
||||
@@ -2079,7 +2278,7 @@ ExeAutomaticPackParts( INTVECTOR& vIds, bool bMinimizeOnXvsY, bool bReducedCut,
|
||||
// Avvio nesting automatico
|
||||
ExeAutoNestStart() ;
|
||||
|
||||
// Modalità ghigliottina incompatibile con tagli completi
|
||||
// Modalità ghigliottina incompatibile con tagli completi
|
||||
if ( ! bReducedCut)
|
||||
bGuillotineMode = false ;
|
||||
|
||||
@@ -2102,11 +2301,11 @@ ExeAutomaticPackParts( INTVECTOR& vIds, bool bMinimizeOnXvsY, bool bReducedCut,
|
||||
nDamId = pGeomDB->GetNextName( nDamId, NST_DAMAGED_REG) ;
|
||||
}
|
||||
|
||||
// Modalità ghigliottina incompatibile con pannelli non rettangolari
|
||||
// Modalità ghigliottina incompatibile con pannelli non rettangolari
|
||||
if ( ! bIsRect)
|
||||
bGuillotineMode = false ;
|
||||
|
||||
// Assegno le aree occupate dai pezzi già nestati
|
||||
// Assegno le aree occupate dai pezzi già nestati
|
||||
bool bPartAlreadyNested = false ;
|
||||
BBox3d b3Sheet ;
|
||||
pGeomDB->GetGlobalBBox( nRefReg, b3Sheet) ;
|
||||
@@ -2132,18 +2331,18 @@ ExeAutomaticPackParts( INTVECTOR& vIds, bool bMinimizeOnXvsY, bool bReducedCut,
|
||||
GetFlatPartDownCutRegions( pGeomDB, nId, bReducedCut, vCutReg) ;
|
||||
for ( int nRegId : vCutReg)
|
||||
ExeAutoNestAddDefectToSheet( nSheetId, nRegId) ;
|
||||
// dichiaro ci sono pezzi già nestati
|
||||
// dichiaro ci sono pezzi già nestati
|
||||
bPartAlreadyNested = true ;
|
||||
}
|
||||
}
|
||||
nId = ( bInRoot ? ExeGetNextPart( nId, true) : ExeGetNextGroup( nId)) ;
|
||||
}
|
||||
|
||||
// Pezzi già nestati incompatibili con ghigliottina
|
||||
// Pezzi già nestati incompatibili con ghigliottina
|
||||
if ( bPartAlreadyNested)
|
||||
bGuillotineMode = false ;
|
||||
|
||||
// Se richiesta modalità ghigliottina
|
||||
// Se richiesta modalità ghigliottina
|
||||
if ( bGuillotineMode) {
|
||||
// cerco il gap necessario tra le parti
|
||||
double dGap = 0 ;
|
||||
@@ -2153,7 +2352,7 @@ ExeAutomaticPackParts( INTVECTOR& vIds, bool bMinimizeOnXvsY, bool bReducedCut,
|
||||
if ( GetFlatPartInterpartGap( pGeomDB, nPartId, dCurrGap) && dCurrGap > dGap)
|
||||
dGap = dCurrGap ;
|
||||
}
|
||||
// se non trovato disabilito richiesta modalità ghigliottina
|
||||
// se non trovato disabilito richiesta modalità ghigliottina
|
||||
if ( dGap < EPS_SMALL)
|
||||
bGuillotineMode = false ;
|
||||
// altrimenti lo imposto
|
||||
@@ -2161,7 +2360,7 @@ ExeAutomaticPackParts( INTVECTOR& vIds, bool bMinimizeOnXvsY, bool bReducedCut,
|
||||
ExeAutoNestSetInterpartGap( dGap) ;
|
||||
}
|
||||
|
||||
// Se richiesto e abilitato, imposto modalità ghigliottina
|
||||
// Se richiesto e abilitato, imposto modalità ghigliottina
|
||||
if ( bGuillotineMode)
|
||||
ExeAutoNestSetGuillotineMode() ;
|
||||
|
||||
@@ -2177,7 +2376,7 @@ ExeAutomaticPackParts( INTVECTOR& vIds, bool bMinimizeOnXvsY, bool bReducedCut,
|
||||
int nDwnRegId = GetFlatPartDownRegion( pGeomDB, nPartId) ;
|
||||
if ( nDwnRegId != GDB_ID_NULL)
|
||||
ExeAutoNestAddAnotherOutlineToPart( nPartId, nDwnRegId) ;
|
||||
// se non è ghigliottina imposto le regioni dei tagli (con ghigliottina si usa il gap)
|
||||
// se non è ghigliottina imposto le regioni dei tagli (con ghigliottina si usa il gap)
|
||||
if ( ! bGuillotineMode) {
|
||||
// recupero regioni dei tagli del pezzo
|
||||
INTVECTOR vCutReg ;
|
||||
|
||||
@@ -267,6 +267,21 @@ ExeDraw( void)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeRedraw( void)
|
||||
{
|
||||
// se interfaccia disabilitata, esco subito
|
||||
if ( ! ExeGetEnableUI())
|
||||
return true ;
|
||||
|
||||
IEGrScene* pScene = GetCurrScene() ;
|
||||
VERIFY_SCENE( pScene, false)
|
||||
// forzo ridisegno
|
||||
pScene->RedrawWindow() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSelect( int nWinX, int nWinY, int nSelW, int nSelH, int* pnSel)
|
||||
|
||||
@@ -242,7 +242,7 @@ MyTestSpheSurfTm( const Point3d& ptCen, double dR, int nSurfTmId, double dSafeDi
|
||||
return -1 ;
|
||||
// porto in locale alla superficie il centro della sfera
|
||||
Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frSurf) ;
|
||||
// verifico l'a collisione'interferenza
|
||||
// verifico l'interferenza
|
||||
return ( TestSpheSurfTm( ptCenL, dR, *pStm, dSafeDist) ? 1 : 0) ;
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ ExeTestSpheSurface( const Point3d& ptCen, double dR, int nSurfId, double dSafeDi
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
MyTestSurfTmSurfTm( int nSurfTm1Id, int nSurfTm2Id, double dSafeDist)
|
||||
MyTestSurfTmSurfTm( int nSurfTm1Id, int nSurfTm2Id, double dSafeDist, bool bTestEnclosion)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, -1)
|
||||
@@ -288,26 +288,27 @@ MyTestSurfTmSurfTm( int nSurfTm1Id, int nSurfTm2Id, double dSafeDist)
|
||||
const ISurfTriMesh* pStm2 = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfTm2Id)) ;
|
||||
if ( pStm2 == nullptr)
|
||||
return -1 ;
|
||||
// verifico l'a collisione'interferenza
|
||||
return ( TestSurfTmSurfTm( *pStm1, *pStm2, dSafeDist) ? 1 : 0) ;
|
||||
// verifico l'interferenza
|
||||
return ( TestSurfTmSurfTm( *pStm1, *pStm2, dSafeDist, bTestEnclosion) ? 1 : 0) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeTestSurfaceSurface( int nSurf1Id, int nSurf2Id, double dSafeDist)
|
||||
ExeTestSurfaceSurface( int nSurf1Id, int nSurf2Id, double dSafeDist, bool bTestEnclosion)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
int nRes = -1 ;
|
||||
if ( pGeomDB != nullptr) {
|
||||
if ( pGeomDB->GetGeoType( nSurf1Id) == SRF_TRIMESH && pGeomDB->GetGeoType( nSurf2Id) == SRF_TRIMESH)
|
||||
nRes = MyTestSurfTmSurfTm( nSurf1Id, nSurf2Id, dSafeDist) ;
|
||||
// è da aggiungere il test con le superfici di Bezier
|
||||
nRes = MyTestSurfTmSurfTm( nSurf1Id, nSurf2Id, dSafeDist, bTestEnclosion) ;
|
||||
// è da aggiungere il test con le superfici di Bezier
|
||||
}
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTestSurfaceSurface({" + IdToString( nSurf1Id) + "," +
|
||||
IdToString( nSurf2Id) + "," +
|
||||
ToString( dSafeDist) + ")" +
|
||||
ToString( dSafeDist) + "," +
|
||||
( bTestEnclosion ? "true" : "false") + ")" +
|
||||
" -- Res=" + ToString( nRes) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
|
||||
+349
-278
@@ -29,29 +29,30 @@
|
||||
|
||||
using namespace std ;
|
||||
|
||||
static string s_sKey_Sync_Coord = "KeyOldCoord" ;
|
||||
static string s_sKey_Auto_Trim = "AutoTrim" ;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
bool
|
||||
ExeTrimmingAutoSearch( int nParentId, int nSurfLayerId, double dShapeLinTol, double dShapeAngTol,
|
||||
double dLinTol, double dEdgeLinTol, double dAngTol, double dAngFaceTol,
|
||||
const STRVECTOR& vsShapes)
|
||||
ExeTrimmingGetHoleBorder( int nParentId, const INTVECTOR& vSurfIds, const INTVECTOR& vOtherSurfIds,
|
||||
double dSurfLinTol, double dSurfAngTol, double dEdgeLinTol, double dEdgeAngTol,
|
||||
double dEdgeThick, int& nFirstId, int& nCount)
|
||||
{
|
||||
// Verifica database geometrico
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
|
||||
// Inizializzo i valori di ritorno
|
||||
nFirstId = GDB_ID_NULL ;
|
||||
nCount = 0 ;
|
||||
|
||||
// Se non ho geometrie da ricercare, non faccio nulla
|
||||
if ( vsShapes.empty())
|
||||
if ( vSurfIds.empty())
|
||||
return true ;
|
||||
|
||||
// Recupero le superfici presenti nel Layer
|
||||
CISURFPVECTOR vSurfs ; vSurfs.reserve( pGeomDB->GetGroupObjs( nSurfLayerId)) ;
|
||||
int nId = pGeomDB->GetFirstInGroup( nSurfLayerId) ;
|
||||
while ( nId != GDB_ID_NULL) {
|
||||
// Recupero l'entità
|
||||
const IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nId) ;
|
||||
// Recupero le superfici da cui estrarre i bordi
|
||||
CISURFPVECTOR vpSurfs ; vpSurfs.reserve( vSurfIds.size()) ;
|
||||
for ( int i = 0 ; i < ssize( vSurfIds) ; ++ i) {
|
||||
int nSurfId = vSurfIds[i] ;
|
||||
// Recupero l'entità
|
||||
const IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nSurfId) ;
|
||||
if ( pGeoObj != nullptr) {
|
||||
// Recupero il Tipo
|
||||
int nType = pGeoObj->GetType() ;
|
||||
@@ -59,81 +60,89 @@ ExeTrimmingAutoSearch( int nParentId, int nSurfLayerId, double dShapeLinTol, dou
|
||||
// Recupero la superficie
|
||||
const ISurf* pSurf = GetSurf( pGeoObj) ;
|
||||
if ( pSurf != nullptr && pSurf->IsValid())
|
||||
vSurfs.emplace_back( pSurf) ;
|
||||
vpSurfs.emplace_back( pSurf) ;
|
||||
}
|
||||
}
|
||||
nId = pGeomDB->GetNext( nId) ;
|
||||
}
|
||||
// Se non ho superfici non faccio nulla
|
||||
if ( vSurfs.empty())
|
||||
if ( vpSurfs.empty())
|
||||
return false ;
|
||||
|
||||
// Recupero Le Superfici Selezionate, Le Curve e Le Bezier rigate
|
||||
ISURFPOMATRIX matSelSurfMatrix ;
|
||||
ICRVCOMPOPOMATRIX matCompoBorders ;
|
||||
ISURFBEZPOVECTOR vSurfBz ;
|
||||
bool bOk = GetTrimmingAutoEntities( vSurfs, dShapeLinTol, dShapeAngTol, dLinTol, dEdgeLinTol, dAngTol, dAngFaceTol, vsShapes,
|
||||
matSelSurfMatrix, matCompoBorders, vSurfBz) ;
|
||||
|
||||
// Per sicurezza verifico che tutte le entità siano a dimensione corretta
|
||||
bOk = bOk && ( ssize( matSelSurfMatrix) == ssize( matCompoBorders)) &&
|
||||
( ssize( matSelSurfMatrix) == ssize( vSurfBz)) ;
|
||||
|
||||
// Per ogni Entità ricavata inserisco le Geometrie nel Layer
|
||||
// NB. Ordine di Inserimento : Surf -> Edges -> bezier
|
||||
// Una anomalia nella serie blocca il flusso corrente e passa al successivo
|
||||
int nCount = -1 ;
|
||||
for ( int i = 0 ; bOk && i < int( matSelSurfMatrix.size()) ; ++ i) {
|
||||
// Verifico che la Superficie sia Valida
|
||||
bool bOkEntity = true ;
|
||||
for ( int j = 0 ; bOkEntity && j < ssize( matSelSurfMatrix[i]) ; ++ j)
|
||||
bOkEntity = ( ! IsNull( matSelSurfMatrix[i][j]) && matSelSurfMatrix[i][j]->IsValid()) ;
|
||||
if ( ! bOkEntity)
|
||||
continue ; // anomalia serie livello superfici di selezione
|
||||
for ( int j = 0 ; bOk && j < ssize( matSelSurfMatrix[i]) ; ++ j) {
|
||||
int nSurfId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( matSelSurfMatrix[i][j])) ;
|
||||
bOk = ( ( nSurfId != GDB_ID_NULL) &&
|
||||
( pGeomDB->SetInfo( nSurfId, s_sKey_Auto_Trim, ToString( ++ nCount)))) ;
|
||||
// Calcolo il Centroide delle superfici complessive
|
||||
Point3d ptRef = P_INVALID ;
|
||||
if ( ! vOtherSurfIds.empty()) {
|
||||
int nToTSurf = 0 ;
|
||||
for ( int nOtherSurfId : vOtherSurfIds) {
|
||||
// Recupero l'entità
|
||||
const IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nOtherSurfId) ;
|
||||
if ( pGeoObj != nullptr) {
|
||||
// Recupero il Tipo
|
||||
int nType = pGeoObj->GetType() ;
|
||||
if ( nType == SRF_TRIMESH || nType == SRF_BEZIER) {
|
||||
// Recupero la superficie
|
||||
const ISurf* pSurf = GetSurf( pGeoObj) ;
|
||||
if ( pSurf != nullptr && pSurf->IsValid()) {
|
||||
// Recupero il Centroide
|
||||
Point3d ptCentroid ;
|
||||
pSurf->GetCentroid( ptCentroid) ;
|
||||
if ( ! ptRef.IsValid())
|
||||
ptRef = ptCentroid ;
|
||||
else
|
||||
ptRef += ptCentroid ;
|
||||
++ nToTSurf ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! bOk)
|
||||
break ; // anomalia bloccante
|
||||
// Verifico che Le Curve di Edges ( Bezier ) siano Valide
|
||||
for ( int j = 0 ; bOkEntity && j < ssize( matCompoBorders[i]) ; ++ j)
|
||||
bOkEntity = ( ! IsNull( matCompoBorders[i][j]) && matCompoBorders[i][j]->IsValid()) ;
|
||||
if ( ! bOkEntity)
|
||||
continue ; // anomalia serie livello curve di bordo
|
||||
for ( int j = 0 ; bOk && j < ssize( matCompoBorders[i]) ; ++ j) {
|
||||
int nCrvId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( matCompoBorders[i][j])) ;
|
||||
bOk = ( ( nCrvId != GDB_ID_NULL) &&
|
||||
( pGeomDB->SetInfo( nCrvId, s_sKey_Auto_Trim, ToString( nCount)))) ;
|
||||
if ( nToTSurf > 0) {
|
||||
for ( const ISurf* pSurf : vpSurfs) {
|
||||
Point3d ptCentroid ;
|
||||
pSurf->GetCentroid( ptCentroid) ;
|
||||
if ( ! ptRef.IsValid())
|
||||
ptRef = ptCentroid ;
|
||||
else
|
||||
ptRef += ptCentroid ;
|
||||
++ nToTSurf ;
|
||||
}
|
||||
ptRef /= nToTSurf ;
|
||||
}
|
||||
}
|
||||
|
||||
// Recupero i Bordi per fori ed asole
|
||||
ICRVCOMPOPOVECTOR vHoleBorders ;
|
||||
bool bOk = GetTrimmingHoleBorders( vpSurfs, ptRef, dSurfLinTol, dSurfAngTol, dEdgeLinTol, dEdgeAngTol,
|
||||
dEdgeThick, vHoleBorders) ;
|
||||
if ( bOk) {
|
||||
// Inserisco le curve nel DB e imposto i parametri di ritorno
|
||||
bool bFirst = true ;
|
||||
for ( int i = 0 ; bOk && i < ssize( vHoleBorders) ; ++ i) {
|
||||
// Verifico che sia valida
|
||||
if ( ! IsNull( vHoleBorders[i]) && vHoleBorders[i]->IsValid()) {
|
||||
int nCrvId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vHoleBorders[i])) ;
|
||||
bOk = ( nCrvId != GDB_ID_NULL) ;
|
||||
if ( bOk) {
|
||||
++ nCount ;
|
||||
if ( bFirst) {
|
||||
nFirstId = nCrvId ;
|
||||
bFirst = false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! bOk)
|
||||
break ; // anomalia bloccante
|
||||
// Verifico che le Superfici di Bezier rigate siano Valide
|
||||
bOkEntity = ( ! IsNull( vSurfBz[i]) && vSurfBz[i]->IsValid()) ;
|
||||
if ( ! bOkEntity)
|
||||
continue ; // anomalia seria livello Bezier Rigata
|
||||
int nBzId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vSurfBz[i])) ;
|
||||
bOk = ( ( nBzId != GDB_ID_NULL) &&
|
||||
( pGeomDB->SetInfo( nBzId, s_sKey_Auto_Trim, ToString( nCount)))) ;
|
||||
if ( ! bOk)
|
||||
break ; // anomali bloccante
|
||||
}
|
||||
|
||||
ExeSetModified() ;
|
||||
|
||||
// Se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTrimmingAutoSearch(" + ToString( nParentId) + "," +
|
||||
ToString( nSurfLayerId) + "," +
|
||||
ToString( dShapeLinTol) + "," +
|
||||
ToString( dShapeAngTol) + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
ToString( dEdgeLinTol) + "," +
|
||||
ToString( dAngTol) + "," +
|
||||
ToString( dAngFaceTol) + "," +
|
||||
ToString( vsShapes) + ")" +
|
||||
" -- bOk=" + ToString( bOk) ;
|
||||
string sLua = "EgtTrimmingGetHoleBorder(" + ToString( nParentId) + "," +
|
||||
ToString( vSurfIds) + "," +
|
||||
ToString( dSurfLinTol) + "," +
|
||||
ToString( dSurfAngTol) + "," +
|
||||
ToString( dEdgeLinTol) + "," +
|
||||
ToString( dEdgeAngTol) + "," +
|
||||
ToString( dEdgeThick) + ")" +
|
||||
" bOk=" + ToString( bOk) +
|
||||
" nNewSurfId=" + ToString( nFirstId) + ", nCount= " + ToString( nCount) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
|
||||
@@ -141,43 +150,47 @@ ExeTrimmingAutoSearch( int nParentId, int nSurfLayerId, double dShapeLinTol, dou
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
bool
|
||||
ExeTrimmingGetSurfTmFaceAdj( int nSurfId, const INTVECTOR& vTria, const PNTVECTOR& vPts,
|
||||
double dAngTol, double dSize, double dSizeTol, INTVECTOR& vOtherFaces)
|
||||
int
|
||||
ExeTrimmingGetSurfTmFaceAdj( int nParentId, int nSurfId, int nTria, const Point3d& ptTria,
|
||||
double dAngTol, double dSize, double dSizeTol)
|
||||
{
|
||||
// Verifica database geometrico
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
|
||||
// Recupero la superficie TriMesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfId)) ;
|
||||
bool bOk = ( pStm != nullptr && pStm->IsValid()) ;
|
||||
|
||||
// Verifico che le facce appartengano alla superficie
|
||||
bOk = bOk && ( ! vTria.empty()) ;
|
||||
|
||||
// Recupero l'insieme dei triangoli
|
||||
// Recupero la superficie formata dai triangoli di adiacenza
|
||||
int nNewSurfId = GDB_ID_NULL ;
|
||||
if ( bOk) {
|
||||
INTVECTOR vOtherTria ; vOtherTria.reserve( pStm->GetTriangleCount()) ;
|
||||
bOk = GetTrimmingStmAdjTria( pStm, vTria, vPts, dAngTol, dSize, dSizeTol, vOtherTria) ;
|
||||
// Per ogni triangolo ricavato, recupero la faccia corrispondente
|
||||
set<int> setFaces ;
|
||||
for ( const int& nT : vOtherTria)
|
||||
setFaces.insert( pStm->GetFacetFromTria( nT)) ;
|
||||
vOtherFaces.assign( setFaces.begin(), setFaces.end()) ;
|
||||
PtrOwner<ISurfTriMesh> pStmAdjFace( CreateSurfTriMesh()) ;
|
||||
bOk = ( ! IsNull( pStmAdjFace) && pStmAdjFace->AdjustTopology()) ;
|
||||
bOk = GetTrimmingStmAdjTria( pStm, nTria, ptTria, dAngTol, dSize, dSizeTol, pStmAdjFace) ;
|
||||
bOk = ( ! IsNull( pStmAdjFace) && pStmAdjFace->IsValid() && pStmAdjFace->GetTriangleCount() > 0) ;
|
||||
// Inserisco la Superficie nel DB geometrico
|
||||
if ( bOk) {
|
||||
nNewSurfId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStmAdjFace)) ;
|
||||
bOk = ( nNewSurfId != GDB_ID_NULL) ;
|
||||
}
|
||||
}
|
||||
|
||||
ExeSetModified() ;
|
||||
// Se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTrimmingGetSurfTmFromFaceAdj(" + ToString( nSurfId) + "," +
|
||||
ToString( vTria) + "," +
|
||||
string sLua = "EgtTrimmingGetSurfTmFromFaceAdj(" + ToString( nParentId) + "," +
|
||||
ToString( nSurfId) + "," +
|
||||
ToString( nTria) + "," +
|
||||
"{ " + ToString( ptTria.x) + "," +
|
||||
ToString( ptTria.y) + "," +
|
||||
ToString( ptTria.z) + "}," +
|
||||
ToString( dAngTol) + ")" +
|
||||
" -- bOk=" + ToString( bOk) + "vOtherFaces=" + ToString( vOtherFaces) ;
|
||||
" nNewSurfId=" + ToString( nNewSurfId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
|
||||
return bOk ;
|
||||
return nNewSurfId ;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -248,7 +261,7 @@ ExeTrimmingGetAdjSurfs( const INTVECTOR& vSurfId, const INTVECTOR& vOtherSurfId,
|
||||
{
|
||||
// Verifica database geometrico
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
|
||||
// Recupero le superfici di Riferimento
|
||||
CISURFPVECTOR vRefSurf ; vRefSurf.reserve( vSurfId.size()) ;
|
||||
@@ -275,16 +288,16 @@ ExeTrimmingGetAdjSurfs( const INTVECTOR& vSurfId, const INTVECTOR& vOtherSurfId,
|
||||
INTVECTOR vMyInds ;
|
||||
bOk = bOk && GetTrimmingAdjSurfs( vRefSurf, vOtherSurf, dLinTol, dAngTol, dAngFaceTol, vMyInds) ;
|
||||
if ( bOk) {
|
||||
for ( const int& myInd : vMyInds)
|
||||
for ( int myInd : vMyInds)
|
||||
vResId.push_back( vIds[myInd]) ;
|
||||
}
|
||||
|
||||
ExeSetModified() ;
|
||||
// Se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTrimmingGetAdjSurf(" + ToString( vSurfId) + "," +
|
||||
ToString( vOtherSurfId) + "," +
|
||||
ToString( dAngTol) + ")" +
|
||||
string sLua = "EgtTrimmingGetAdjSurfs(" + ToString( vSurfId) + "," +
|
||||
ToString( vOtherSurfId) + "," +
|
||||
ToString( dAngTol) + ")" +
|
||||
" -- bOk=" + ToString( bOk) + ",vResId=" + ToString( vResId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
@@ -294,12 +307,12 @@ ExeTrimmingGetAdjSurfs( const INTVECTOR& vSurfId, const INTVECTOR& vOtherSurfId,
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
bool
|
||||
ExeTrimmingGetBorders( int nParentId, const SELVECTOR& vIds, double dLinTol, double dAngTol,
|
||||
int& nCount, int& nFirstId)
|
||||
ExeTrimmingGetBorders( int nParentId, const SELVECTOR& vIds, double dSurfLinTol, double dSurfAngTol,
|
||||
double dLinTol, double dAngTol, int& nFirstId, int& nCount)
|
||||
{
|
||||
// Verifica database geometrico
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
|
||||
// Parametri da restituire
|
||||
nFirstId = GDB_ID_NULL ;
|
||||
@@ -330,14 +343,14 @@ ExeTrimmingGetBorders( int nParentId, const SELVECTOR& vIds, double dLinTol, dou
|
||||
uMapPos[*nIter] = nSurf ;
|
||||
++ nSurf ;
|
||||
}
|
||||
// Recupero il vettore di Selezione associato non più agli Id delle superficie ma alle loro posizioni nel vettore
|
||||
vector<SelData> vFaces ; vFaces.reserve( vIds.size()) ;
|
||||
// Recupero il vettore di Selezione associato non più agli Id delle superficie ma alle loro posizioni nel vettore
|
||||
SELVECTOR vFaces ; vFaces.reserve( vIds.size()) ;
|
||||
for ( int i = 0 ; bOk && i < int( vIds.size()) ; ++ i)
|
||||
vFaces.emplace_back( uMapPos[vIds[i].nId], vIds[i].nSub) ;
|
||||
|
||||
// Calcolo le curve di Edge grezze ( quindi i tratti lineari)
|
||||
ICRVCOMPOPOVECTOR vRawEdges ;
|
||||
bOk = bOk && GetTrimmingRawEdges( vpSurf, vFaces, dLinTol, dAngTol, vRawEdges) &&
|
||||
bOk = bOk && GetTrimmingRawEdges( vpSurf, vFaces, dSurfLinTol, dSurfAngTol, vRawEdges) &&
|
||||
( ! vRawEdges.empty()) ;
|
||||
|
||||
// Calcolo le curve di Edge approssimate mediante curve di Bezier
|
||||
@@ -360,6 +373,8 @@ ExeTrimmingGetBorders( int nParentId, const SELVECTOR& vIds, double dLinTol, dou
|
||||
// Se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTrimmingGetBorders(" + IdToString( nParentId) + "," +
|
||||
ToString( dSurfLinTol) + "," +
|
||||
ToString( dSurfAngTol) + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
ToString( dAngTol) + ")" ;
|
||||
sLua += " -- bOk=" + ToString( bOk) +
|
||||
@@ -372,12 +387,13 @@ ExeTrimmingGetBorders( int nParentId, const SELVECTOR& vIds, double dLinTol, dou
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
bool
|
||||
ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dLinTol,
|
||||
double dAngTol, double dThick, Point3d& ptNear, int& nCount, int& nFirstId)
|
||||
ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dSurfLinTol,
|
||||
double dSurfAngTol, double dLinTol, double dAngTol, double dThick,
|
||||
int& nFirstId, int& nCount)
|
||||
{
|
||||
// Verifica database geometrico
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
|
||||
// Parametri da restituire
|
||||
nFirstId = GDB_ID_NULL ;
|
||||
@@ -408,77 +424,33 @@ ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dLi
|
||||
uMapPos[*nIter] = nSurf ;
|
||||
++ nSurf ;
|
||||
}
|
||||
// Recupero il vettore di Selezione associato non più agli Id delle superficie ma alle loro posizioni nel vettore
|
||||
vector<SelData> vFaces ; vFaces.reserve( vIds.size()) ;
|
||||
// Recupero il vettore di Selezione associato non più agli Id delle superficie ma alle loro posizioni nel vettore
|
||||
SELVECTOR vFaces ; vFaces.reserve( vIds.size()) ;
|
||||
for ( int i = 0 ; bOk && i < int( vIds.size()) ; ++ i)
|
||||
vFaces.emplace_back( uMapPos[vIds[i].nId], vIds[i].nSub) ;
|
||||
|
||||
// Calcolo le curve di Edge approssimate mediante curve di Bezier
|
||||
ICRVCOMPOPOVECTOR vBezierEdges ;
|
||||
bOk = bOk && GetTrimmingFinalBorders( vpSurf, vFaces, dLinTol, dAngTol, dThick, vBezierEdges) ;
|
||||
bOk = bOk && GetTrimmingFinalBorders( vpSurf, vFaces, dSurfLinTol, dSurfAngTol, dLinTol, dAngTol, dThick, vBezierEdges) ;
|
||||
if ( bOk) {
|
||||
// Se non ho un punto di vicinanza, le inserisco tutte
|
||||
if ( ! ptNear.IsValid()) {
|
||||
nCount = int( vBezierEdges.size()) ;
|
||||
// Scorro i gli Edges ottenuti
|
||||
for ( int nCrv = 0 ; bOk && nCrv < nCount ; ++ nCrv) {
|
||||
vBezierEdges[nCrv]->ToLoc( frDest) ;
|
||||
// Inserisco la curva nel DB Geometrico
|
||||
int nCurrId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vBezierEdges[nCrv])) ;
|
||||
bOk = ( nCurrId != GDB_ID_NULL) ;
|
||||
if ( nCrv == 0)
|
||||
nFirstId = nCurrId ;
|
||||
}
|
||||
}
|
||||
// Se ho un punto di vicinanza, cerco la coppia di curve più vicina
|
||||
else {
|
||||
// Se solo una coppia di curve, le inserisco e non ho ambiguità
|
||||
if ( int( vBezierEdges.size()) == 2) {
|
||||
nCount = int( vBezierEdges.size()) ;
|
||||
// Scorro gli Edges ottenuti
|
||||
for ( int nCrv = 0 ; bOk && nCrv < nCount ; ++ nCrv) {
|
||||
vBezierEdges[nCrv]->ToLoc( frDest) ;
|
||||
// Inserisco la curva nel DB Geometrico
|
||||
int nCurrId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vBezierEdges[nCrv])) ;
|
||||
bOk = ( nCurrId != GDB_ID_NULL) ;
|
||||
if ( nCrv == 0)
|
||||
nFirstId = nCurrId ;
|
||||
}
|
||||
}
|
||||
// altrimenti cerco la coppia più vicia
|
||||
else {
|
||||
double dSqMinDist = INFINITO ;
|
||||
int nInd = 0 ;
|
||||
for ( int i = 0 ; i + 1 < int( vBezierEdges.size()) ; i = i + 2) {
|
||||
double dSqDist = 0., dSqDist1 = 0. ;
|
||||
if ( DistPointCurve( ptNear, *vBezierEdges[i]).GetSqDist( dSqDist) &&
|
||||
DistPointCurve( ptNear, *vBezierEdges[i + 1]).GetSqDist( dSqDist1)) {
|
||||
double dCurrMinSqDist = min( dSqDist, dSqDist1) ;
|
||||
if ( dCurrMinSqDist < dSqMinDist) {
|
||||
dSqMinDist = dCurrMinSqDist ;
|
||||
nInd = i ;
|
||||
}
|
||||
}
|
||||
}
|
||||
vBezierEdges[nInd]->ToLoc( frDest) ;
|
||||
vBezierEdges[nInd + 1]->ToLoc( frDest) ;
|
||||
int nCurrId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vBezierEdges[nInd])) ;
|
||||
int nCurrId1 = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vBezierEdges[nInd + 1])) ;
|
||||
bOk = ( nCurrId != GDB_ID_NULL && nCurrId1 != GDB_ID_NULL) ;
|
||||
if ( bOk) {
|
||||
nFirstId = nCurrId1 ;
|
||||
nCount = 2 ;
|
||||
}
|
||||
}
|
||||
nCount = int( vBezierEdges.size()) ;
|
||||
// Scorro i gli Edges ottenuti
|
||||
for ( int nCrv = 0 ; bOk && nCrv < nCount ; ++ nCrv) {
|
||||
vBezierEdges[nCrv]->ToLoc( frDest) ;
|
||||
// Inserisco la curva nel DB Geometrico
|
||||
int nCurrId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vBezierEdges[nCrv])) ;
|
||||
bOk = ( nCurrId != GDB_ID_NULL) ;
|
||||
if ( nCrv == 0)
|
||||
nFirstId = nCurrId ;
|
||||
}
|
||||
}
|
||||
|
||||
ExeSetModified() ;
|
||||
// Se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTrimmingGetBorders(" + IdToString( nParentId) + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
ToString( dAngTol) + ")" ;
|
||||
string sLua = "EgtTrimmingGetBordersByNormals(" + IdToString( nParentId) + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
ToString( dAngTol) + ")" ;
|
||||
sLua += " -- bOk=" + ToString( bOk) +
|
||||
" -- FirstId=" + ToString( nFirstId) + " CurveCount=" + ToString( nCount) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
@@ -495,7 +467,7 @@ ExeTrimmingGetFinalBorders( int nParentId, const INTVECTOR& vCrvBezierId, double
|
||||
{
|
||||
// Verifica database geometrico
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
|
||||
// Parametri da restituire
|
||||
nFirstId = GDB_ID_NULL ;
|
||||
@@ -542,10 +514,10 @@ ExeTrimmingGetFinalBorders( int nParentId, const INTVECTOR& vCrvBezierId, double
|
||||
|
||||
// Se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTrimmingGetFinalEdges(" + IdToString( nParentId) + "," +
|
||||
ToString( vCrvBezierId) + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
ToString( dAngTol) + "," ;
|
||||
string sLua = "EgtTrimmingGetFinalBorders(" + IdToString( nParentId) + "," +
|
||||
ToString( vCrvBezierId) + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
ToString( dAngTol) + "," ;
|
||||
sLua += "{" ;
|
||||
for ( int nP = 0 ; nP < int( vBrkPts.size()) ; ++ nP) {
|
||||
sLua += "(" + ToString( vBrkPts[nP].x) + ", " + ToString( vBrkPts[nP].y) + ", " + ToString( vBrkPts[nP].z) + ")" +
|
||||
@@ -605,34 +577,43 @@ ExeTrimmingGetRuledBezier( int nParentId, const INTVECTOR& vIds, int nEdge1Id, i
|
||||
|
||||
// Recupero i punti di sincronizzazione ( se presenti)
|
||||
BIPNTVECTOR vSyncPoints ; vSyncPoints.reserve( pGeomDB->GetGroupObjs( vnLineId.size())) ;
|
||||
INTVECTOR vIndPriority ; vIndPriority.reserve( vSyncPoints.size()) ;
|
||||
INTVECTOR vIndVisible ; vIndVisible.reserve( vSyncPoints.size()) ;
|
||||
for ( int i = 0 ; bOk && i < int( vnLineId.size()) ; ++ i) {
|
||||
for ( int i = 0 ; bOk && i < ssize( vnLineId) ; ++ i) {
|
||||
// Recupero la Curva
|
||||
const ICurve* pLine = GetCurve( pGeomDB->GetGeoObj( vnLineId[i])) ;
|
||||
bOk = bOk && ( pLine != nullptr && pLine->IsValid()) ;
|
||||
if ( bOk) {
|
||||
// Recupero gli Estremi
|
||||
Point3d ptStart ; pLine->GetStartPoint( ptStart) ;
|
||||
Point3d ptEnd ; pLine->GetEndPoint( ptEnd) ;
|
||||
// Mi assicuro che gli estremi siano sulle curve di Bordo e orientati correttamente ( nel caso inverto)
|
||||
double dSqDistS1 = INFINITO ;
|
||||
if ( ! DistPointCurve( ptStart, *pCrvEdge1).GetSqDist( dSqDistS1))
|
||||
continue ;
|
||||
if ( dSqDistS1 < dLinTol * dLinTol) {
|
||||
double dSqDistE2 = INFINITO ;
|
||||
if ( ! DistPointCurve( ptEnd, *pCrvEdge2).GetSqDist( dSqDistE2) ||
|
||||
dSqDistE2 > dLinTol * dLinTol)
|
||||
continue ;
|
||||
}
|
||||
else {
|
||||
double dSqDistS2 = INFINITO ;
|
||||
if ( ! DistPointCurve( ptStart, *pCrvEdge2).GetSqDist( dSqDistS2) ||
|
||||
dSqDistS2 > dLinTol * dLinTol)
|
||||
continue ;
|
||||
double dSqDistE1 = INFINITO ;
|
||||
if ( ! DistPointCurve( ptEnd, *pCrvEdge1).GetSqDist( dSqDistE1) ||
|
||||
dSqDistE1 > dLinTol * dLinTol)
|
||||
continue ;
|
||||
swap( ptStart, ptEnd) ;
|
||||
}
|
||||
vSyncPoints.emplace_back( make_pair( ptStart, ptEnd)) ;
|
||||
// Verifico se la linea è visibile all'utente
|
||||
int nStatus = GDB_ST_OFF ;
|
||||
if ( pGeomDB->GetStatus( vnLineId[i], nStatus) && nStatus == GDB_ST_ON)
|
||||
vIndVisible.emplace_back( int( vSyncPoints.size() - 1)) ;
|
||||
// Verifico mediante le Info se la curva è stata modificata o aggiunta ( quindi prioritaria)
|
||||
DBLVECTOR vdOldCoor ; vdOldCoor.reserve( 6) ;
|
||||
if ( ! pGeomDB->GetInfo( vnLineId[i], s_sKey_Sync_Coord, vdOldCoor) ||
|
||||
int( vdOldCoor.size()) != 6 ||
|
||||
! AreSamePointApprox( ptStart, Point3d( vdOldCoor[0], vdOldCoor[1], vdOldCoor[2])) ||
|
||||
! AreSamePointApprox( ptEnd, Point3d( vdOldCoor[3], vdOldCoor[4], vdOldCoor[5])))
|
||||
vIndPriority.emplace_back( int( vSyncPoints.size()) - 1) ;
|
||||
}
|
||||
}
|
||||
|
||||
// Recupero la superficie Bezier rigata
|
||||
PtrOwner<ISurfBezier> pSurfBzRuled ;
|
||||
if ( bOk) {
|
||||
pSurfBzRuled.Set( GetTrimmingRuledBezier( vpSurf, pCrvEdge1, pCrvEdge2, dMyLinTol, vSyncPoints, vIndPriority, vIndVisible)) ;
|
||||
pSurfBzRuled.Set( GetTrimmingRuledBezier( vpSurf, pCrvEdge1, pCrvEdge2, dMyLinTol, vSyncPoints)) ;
|
||||
bOk = bOk && ( ! IsNull( pSurfBzRuled) && pSurfBzRuled->IsValid()) ;
|
||||
}
|
||||
|
||||
@@ -662,15 +643,95 @@ ExeTrimmingGetRuledBezier( int nParentId, const INTVECTOR& vIds, int nEdge1Id, i
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
bool
|
||||
ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, double dLinTol,
|
||||
int& nFirstId, int& nCount)
|
||||
ExeTrimmingInterpolateSyncLines( int nParentId, int nSync1Id, int nSync2Id, int nBorder1Id,
|
||||
int nBorder2Id, double dEdgeLinTol, double dEdgeAngTol,
|
||||
int& nFirstId, int& nCount)
|
||||
{
|
||||
// Verifica database geometrico
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
|
||||
// Reset parametri di ritorno
|
||||
nFirstId = GDB_ID_NULL ;
|
||||
nCount = 0 ;
|
||||
|
||||
// Aggiusto la tolleranza lineare e angolare se necessario
|
||||
double dMyEdgeLinTol = Clamp( dEdgeLinTol, EPS_SMALL, 1e5 * EPS_SMALL) ;
|
||||
double dMyEdgeAngTol = Clamp( dEdgeAngTol, EPS_ANG_SMALL, 60.) ;
|
||||
|
||||
// recupero le due curve di sincronizzazione
|
||||
const ICurve* pSync1 = GetCurve( pGeomDB->GetGeoObj( nSync1Id)) ;
|
||||
const ICurve* pSync2 = GetCurve( pGeomDB->GetGeoObj( nSync2Id)) ;
|
||||
bool bOk = ( pSync1 != nullptr && pSync1->IsValid() &&
|
||||
pSync2 != nullptr && pSync2->IsValid()) ;
|
||||
|
||||
// Recupero le due curve di bordo
|
||||
const ICurve* pCrvEdge1 = GetCurve( pGeomDB->GetGeoObj( nBorder1Id)) ;
|
||||
const ICurve* pCrvEdge2 = GetCurve( pGeomDB->GetGeoObj( nBorder2Id)) ;
|
||||
bOk = bOk && ( pCrvEdge1 != nullptr && pCrvEdge1->IsValid()) ;
|
||||
bOk = bOk && ( pCrvEdge2 != nullptr && pCrvEdge2->IsValid()) ;
|
||||
|
||||
// Calcolo le Curve di sincornizzazione Interpolate
|
||||
BIPNTVECTOR vSyncPoints ;
|
||||
bOk = bOk && GetTrimmingSyncInterpolation( pCrvEdge1, pCrvEdge2, pSync1, pSync2, dMyEdgeLinTol,
|
||||
dMyEdgeAngTol, vSyncPoints) ;
|
||||
if ( bOk && ! vSyncPoints.empty()) {
|
||||
// Inserisco le curve di sincronizzazione nel DB
|
||||
// [orientate da pCrvEdge1 a pCrvEdge2]
|
||||
for ( int i = 0 ; bOk && i < ssize( vSyncPoints) ; ++ i) {
|
||||
PtrOwner<ICurveLine> pSyncLine( CreateCurveLine()) ;
|
||||
bOk = ( ! IsNull( pSyncLine) && pSyncLine->Set( vSyncPoints[i].first, vSyncPoints[i].second)) ;
|
||||
if ( bOk) {
|
||||
if ( pCrvEdge1->IsPointOn( vSyncPoints[i].second, dMyEdgeLinTol))
|
||||
pSyncLine->Invert() ;
|
||||
int nSyncId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSyncLine)) ;
|
||||
bOk = ( nSyncId != CMD_ID_NULL) ;
|
||||
if ( i == 0)
|
||||
nFirstId = nSyncId ;
|
||||
}
|
||||
}
|
||||
nCount = ssize( vSyncPoints) ;
|
||||
}
|
||||
|
||||
ExeSetModified() ;
|
||||
// Se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTrimmingInterpolateSyncLines(" + ToString( nParentId) + "," +
|
||||
ToString( nSync1Id) + "," +
|
||||
ToString( nSync2Id) + "," +
|
||||
ToString( nBorder1Id) + "," +
|
||||
ToString( nBorder2Id) + "," +
|
||||
ToString( dEdgeLinTol) + "," +
|
||||
ToString( dEdgeAngTol) + ")" +
|
||||
" -- bOk=" + ToString( bOk) +
|
||||
" -- nFirstId=" + ToString( nFirstId) + " nCount=" + ToString( nCount) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
bool
|
||||
ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, double dLinTol,
|
||||
double dAngTol, int nLineNbr, bool bShowOnCorners,
|
||||
int& nFirstId, int& nCount)
|
||||
{
|
||||
// Verifica database geometrico
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
|
||||
// Imposto i parametri di ritorno
|
||||
nFirstId = GDB_ID_NULL ;
|
||||
nCount = 0 ;
|
||||
|
||||
// Se non devo visualizzare alcuna linea, non faccio nulla
|
||||
if ( nLineNbr <= 0 && ! bShowOnCorners)
|
||||
return true ;
|
||||
|
||||
// Se necessario aggiusto le tolleranze
|
||||
double dMyLinTol = Clamp( dLinTol, EPS_SMALL, 1e5 * EPS_SMALL) ;
|
||||
double dMyAngTol = Clamp( dAngTol, EPS_ANG_SMALL, ANG_RIGHT) ;
|
||||
|
||||
// Recupero il riferimento del gruppo di destinazione
|
||||
Frame3d frDest ;
|
||||
@@ -682,24 +743,110 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl
|
||||
bOk = bOk && ( pCrvEdge1 != nullptr && pCrvEdge1->IsValid() &&
|
||||
pCrvEdge2 != nullptr && pCrvEdge2->IsValid()) ;
|
||||
|
||||
// Verifico che le curve siano entrambe Aperte o entrambe Chiuse
|
||||
bOk = bOk && ( pCrvEdge1->IsClosed() == pCrvEdge2->IsClosed()) ;
|
||||
|
||||
// Recupero i punti di sincronizzazione
|
||||
BIPNTVECTOR vSyncPoints ;
|
||||
bOk = bOk && GetTrimmingSurfBzSyncPoints( pCrvEdge1, pCrvEdge2, dMyLinTol, vSyncPoints) &&
|
||||
( ! vSyncPoints.empty()) ;
|
||||
nCount = int( vSyncPoints.size()) ;
|
||||
int nToTSyncLines = ssize( vSyncPoints) ;
|
||||
|
||||
// Inserisco i tratti di sincronizzazione nel DB Geometrico
|
||||
for ( int nL = 0 ; nL < int( vSyncPoints.size()) ; ++ nL) {
|
||||
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
|
||||
if ( ! IsNull( pLine) && pLine->Set( vSyncPoints[nL].first, vSyncPoints[nL].second)) {
|
||||
int nLineId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pLine)) ;
|
||||
if ( nLineId != GDB_ID_NULL) {
|
||||
if ( nL == 0)
|
||||
// Ogni punto di sincronizzazione deve avere gli estremi sulle curve di Bordo
|
||||
for ( int i = 0 ; bOk && i < ssize( vSyncPoints) ; ++ i) {
|
||||
double dSqDistStart = INFINITO, dSqDistEnd = INFINITO ;
|
||||
bOk = ( DistPointCurve( vSyncPoints[i].first, *pCrvEdge1).GetSqDist( dSqDistStart) &&
|
||||
dSqDistStart < dMyLinTol * dMyLinTol &&
|
||||
DistPointCurve( vSyncPoints[i].second, *pCrvEdge2).GetSqDist( dSqDistEnd) &&
|
||||
dSqDistEnd < dMyLinTol * dMyLinTol) ;
|
||||
}
|
||||
|
||||
if ( bOk) {
|
||||
INTSET setInds ;
|
||||
// Se devo visualizzare più linee di quante ne ho ricavate, allora le devo visualizzare tutte
|
||||
if ( nLineNbr >= nToTSyncLines) {
|
||||
for ( int i = 0 ; i < nToTSyncLines ; ++ i)
|
||||
setInds.insert( i) ;
|
||||
}
|
||||
// Altrimenti
|
||||
else {
|
||||
// Se voglio visualizzare gli Spigoli
|
||||
if ( bShowOnCorners) {
|
||||
for ( int nL = 0 ; bOk && nL < nToTSyncLines ; ++ nL) {
|
||||
// Controllo se punto su spigolo della curva
|
||||
double dU = 0. ;
|
||||
Vector3d vtTanPrev, vtTanAft ;
|
||||
Point3d ptUseless ;
|
||||
bOk = ( pCrvEdge1->GetParamAtPoint( vSyncPoints[nL].first, dU, dMyLinTol) &&
|
||||
pCrvEdge1->GetPointD1D2( dU, ICurve::FROM_MINUS, ptUseless, &vtTanPrev) &&
|
||||
pCrvEdge1->GetPointD1D2( dU, ICurve::FROM_PLUS, ptUseless, &vtTanAft)) ;
|
||||
if ( ! bOk)
|
||||
break ;
|
||||
vtTanPrev.Normalize() ;
|
||||
vtTanAft.Normalize() ;
|
||||
if ( vtTanPrev * vtTanAft < cos( ( dMyAngTol + EPS_ANG_SMALL) * DEGTORAD)) {
|
||||
setInds.insert( nL) ;
|
||||
continue ;
|
||||
}
|
||||
bOk = ( pCrvEdge2->GetParamAtPoint( vSyncPoints[nL].second, dU, dMyLinTol) &&
|
||||
pCrvEdge2->GetPointD1D2( dU, ICurve::FROM_MINUS, ptUseless, &vtTanPrev) &&
|
||||
pCrvEdge2->GetPointD1D2( dU, ICurve::FROM_PLUS, ptUseless, &vtTanAft)) ;
|
||||
if ( ! bOk)
|
||||
break ;
|
||||
vtTanPrev.Normalize() ;
|
||||
vtTanAft.Normalize() ;
|
||||
if ( vtTanPrev * vtTanAft < cos( ( dMyAngTol + EPS_ANG_SMALL) * DEGTORAD)) {
|
||||
setInds.insert( nL) ;
|
||||
continue ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Se devo mostrare alcune Linee
|
||||
if ( bOk && nLineNbr > 0) {
|
||||
bool bBothOpen = ( ! pCrvEdge1->IsClosed() && ! pCrvEdge2->IsClosed()) ;
|
||||
bool bBothClosed = ( ! bBothOpen) ;
|
||||
int nLastIdx = nToTSyncLines - 1 ;
|
||||
if ( bBothClosed) {
|
||||
int nLine = nLineNbr ;
|
||||
if ( nLine == 1)
|
||||
setInds.insert( 0) ;
|
||||
else {
|
||||
int nMaxIndex = nToTSyncLines - 2 ;
|
||||
for ( int i = 0 ; i < nLine ; ++ i) {
|
||||
double dT = double( i) / double( nLine) ;
|
||||
int nIdx = int( 0.5 + dT * nMaxIndex) ;
|
||||
setInds.insert( nIdx) ;
|
||||
}
|
||||
setInds.erase( nLastIdx) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
int nInternal = nLineNbr ;
|
||||
setInds.insert( 0) ;
|
||||
setInds.insert( nLastIdx) ;
|
||||
int nMaxIndex = nLastIdx ;
|
||||
for ( int i = 0; i < nInternal ; ++ i) {
|
||||
double dT = double( i + 1) / double( nInternal + 1) ;
|
||||
int nIdx = int( 0.5 + dT * nMaxIndex) ;
|
||||
setInds.insert( nIdx) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Visualizzo i segmenti lineari di sincronizzazione per ogni indice ricavato
|
||||
bool bFirst = true ;
|
||||
for ( auto Iter = setInds.begin() ; bOk && Iter != setInds.end() ; ++ Iter) {
|
||||
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
|
||||
bOk = ( ! IsNull( pLine) && pLine->Set( vSyncPoints[*Iter].first, vSyncPoints[*Iter].second)) ;
|
||||
if ( bOk) {
|
||||
int nLineId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pLine)) ;
|
||||
bOk = ( nLineId != GDB_ID_NULL) ;
|
||||
if ( bFirst) {
|
||||
nFirstId = nLineId ;
|
||||
// Memorizzo come Info le coordinate dei punti ( per tenere traccia in futuro di modifiche)
|
||||
DBLVECTOR vdCoordInfo = { vSyncPoints[nL].first.x, vSyncPoints[nL].first.y, vSyncPoints[nL].first.z,
|
||||
vSyncPoints[nL].second.x, vSyncPoints[nL].second.y, vSyncPoints[nL].second.z} ;
|
||||
pGeomDB->SetInfo( nLineId, s_sKey_Sync_Coord, vdCoordInfo) ;
|
||||
bFirst = false ;
|
||||
}
|
||||
++ nCount ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -719,79 +866,3 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeTrimmingSkimSyncPoints( int nEdge1Id, int nEdge2Id, const INTVECTOR& vnLineId, double dLinTol,
|
||||
double dAngTol, int nMaxInvLine)
|
||||
{
|
||||
// Verifica database geometrico
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
|
||||
// Se necessario aggiusto le tolleranze
|
||||
double dMyLinTol = Clamp( dLinTol, EPS_SMALL, 1e5 * EPS_SMALL) ;
|
||||
double dMyAngTol = Clamp( dAngTol, 1., 45.) ;
|
||||
int nMyMaxInvLine = Clamp( nMaxInvLine, 1, 100) ;
|
||||
|
||||
// Recupero le due Curve di bordo
|
||||
const ICurve* pCrvEdge1 = GetCurve( pGeomDB->GetGeoObj( nEdge1Id)) ;
|
||||
const ICurve* pCrvEdge2 = GetCurve( pGeomDB->GetGeoObj( nEdge2Id)) ;
|
||||
bool bOk = ( pCrvEdge1 != nullptr && pCrvEdge1->IsValid() && pCrvEdge2 != nullptr && pCrvEdge2->IsValid()) ;
|
||||
|
||||
// Definisco il vettore degli Estremi
|
||||
BIPNTVECTOR vSyncPoints ; vSyncPoints.reserve( vnLineId.size()) ;
|
||||
for ( int i = 0 ; bOk && i < int( vnLineId.size()) ; ++ i) {
|
||||
const ICurve* pLine = GetCurve( pGeomDB->GetGeoObj( vnLineId[i])) ;
|
||||
bOk = ( pLine != nullptr && pLine->IsValid()) ;
|
||||
if ( bOk) {
|
||||
Point3d ptStart, ptEnd ;
|
||||
bOk = ( pLine->GetStartPoint( ptStart) && pLine->GetEndPoint( ptEnd)) ;
|
||||
if ( bOk)
|
||||
vSyncPoints.emplace_back( make_pair( ptStart, ptEnd)) ;
|
||||
}
|
||||
}
|
||||
|
||||
// Scelta di Selezione delle linee di sincronizzazione
|
||||
// 1) In presenza di Spigoli, vengono sempre visualizzate ( Spigolo definito da tolleranza angolare)
|
||||
// 2) 1 Curva su 'nMyMaxInvLine' viene mostrata altrimenti
|
||||
int nInvisibleCount = 0 ;
|
||||
for ( int nL = 0 ; bOk && nL < int( vSyncPoints.size()) ; ++ nL) {
|
||||
bool bVisible = false ;
|
||||
Point3d ptUseless = P_INVALID ;
|
||||
// Recupero gli Estremi e controllo se sono su uno spigolo tra una delle due curve
|
||||
double dUS = 0. ;
|
||||
bOk = bOk && pCrvEdge1->GetParamAtPoint( vSyncPoints[nL].first, dUS, dMyLinTol) ;
|
||||
if ( bOk) {
|
||||
Vector3d vtPrev, vtAft ;
|
||||
bOk = pCrvEdge1->GetPointD1D2( dUS, ICurve::FROM_MINUS, ptUseless, &vtPrev) &&
|
||||
pCrvEdge1->GetPointD1D2( dUS, ICurve::FROM_PLUS, ptUseless, &vtAft) ;
|
||||
if ( bOk) {
|
||||
vtPrev.Normalize() ; vtAft.Normalize() ;
|
||||
bVisible = ( vtPrev * vtAft < cos( ( dMyAngTol + EPS_ANG_SMALL) * DEGTORAD)) ;
|
||||
if ( ! bVisible) {
|
||||
double dUE = 0. ;
|
||||
bOk = bOk && pCrvEdge2->GetParamAtPoint( vSyncPoints[nL].second, dUE, dMyLinTol) ;
|
||||
bOk = pCrvEdge2->GetPointD1D2( dUE, ICurve::FROM_MINUS, ptUseless, &vtPrev) &&
|
||||
pCrvEdge2->GetPointD1D2( dUE, ICurve::FROM_PLUS, ptUseless, &vtAft) ;
|
||||
if ( bOk) {
|
||||
vtPrev.Normalize() ; vtAft.Normalize() ;
|
||||
bVisible = ( vtPrev * vtAft < cos( ( dMyAngTol + EPS_ANG_SMALL) * DEGTORAD)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( bOk) {
|
||||
// Imposto lo Stato
|
||||
if ( ! bVisible)
|
||||
++ nInvisibleCount ;
|
||||
if ( nInvisibleCount == nMyMaxInvLine) {
|
||||
bVisible = true ;
|
||||
nInvisibleCount = 0 ;
|
||||
}
|
||||
pGeomDB->SetStatus( vnLineId[nL], bVisible ? GDB_ST_ON : GDB_ST_OFF) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
Binary file not shown.
+15
-7
@@ -1051,21 +1051,27 @@ LuaCreateSurfBezierRational( lua_State* L)
|
||||
static int
|
||||
LuaCreateSurfBezierLeaves( lua_State* L)
|
||||
{
|
||||
// 2, 3 o 4 parametri : ParentId, nId [, nTextHeight] [, bShowTrim]
|
||||
// 2, 3 o 4 parametri : ParentId, nId [, nTextHeight] [, bShowTrim] [, bRefined]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nSurfBzId ;
|
||||
LuaCheckParam( L, 2, nSurfBzId)
|
||||
int nTextHeight = 50 ;
|
||||
bool bShowTrim = false ;
|
||||
if ( LuaGetParam( L, 3, nTextHeight))
|
||||
LuaGetParam( L, 4, bShowTrim) ;
|
||||
else
|
||||
bool bRefined = false ;
|
||||
// testo più due booleani o solo due booleani
|
||||
if ( LuaGetParam( L, 3, nTextHeight)) {
|
||||
if ( LuaGetParam( L, 4, bShowTrim))
|
||||
LuaGetParam( L, 5, bRefined) ;
|
||||
}
|
||||
else {
|
||||
LuaGetParam( L, 3, bShowTrim) ;
|
||||
LuaGetParam( L, 4, bRefined) ;
|
||||
}
|
||||
LuaClearStack( L) ;
|
||||
// creo la superficie
|
||||
int nCount = 0 ;
|
||||
int nId = ExeCreateSurfBezierLeaves( nParentId, nSurfBzId, nTextHeight, bShowTrim, &nCount) ;
|
||||
int nId = ExeCreateSurfBezierLeaves( nParentId, nSurfBzId, nTextHeight, bShowTrim, bRefined, &nCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL) {
|
||||
LuaSetParam( L, nId) ;
|
||||
@@ -1386,7 +1392,7 @@ LuaCreateSurfBzRuled( lua_State* L)
|
||||
static int
|
||||
LuaCreateSurfBzRuledGuided( lua_State* L)
|
||||
{
|
||||
// 4 o 5 o 6 parametri : ParentId, CrvId1, CrvId2 nLayGuides [, bCapEnds] [, dTol]
|
||||
// 4 o 5 o 6 parametri : ParentId, CrvId1, CrvId2, nLayGuides [, bCapEnds] [, dTol]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nCrvId1 ;
|
||||
@@ -1402,8 +1408,10 @@ LuaCreateSurfBzRuledGuided( lua_State* L)
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
LuaGetParam( L, nPar, dLinTol) ;
|
||||
LuaClearStack( L) ;
|
||||
BIPNTVECTOR vGuides ;
|
||||
|
||||
// creo una surf bezier come rigata tra le due curve passate, usando le isocurve nel layer nLayIso
|
||||
int nId = ExeCreateSurfBzRuledGuided( nParentId, nCrvId1, nCrvId2, nLayGuides, bCapEnds, dLinTol) ;
|
||||
int nId = ExeCreateSurfBzRuledGuided( nParentId, nCrvId1, nCrvId2, vGuides, bCapEnds, dLinTol, nLayGuides) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
|
||||
+55
-6
@@ -48,7 +48,7 @@ LuaSurfIsClosed( lua_State* L)
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// verifico se è superficie chiusa
|
||||
// verifico se � superficie chiusa
|
||||
bool bOk = ExeSurfIsClosed( nId) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
@@ -218,7 +218,7 @@ LuaSurfFrMoveSimpleNoCollision( lua_State* L)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 4, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// verifico quale è la massima traslazione possibile
|
||||
// verifico quale � la massima traslazione possibile
|
||||
double dLen = vtMove.Len() ;
|
||||
Vector3d vtDir = ( dLen > EPS_SMALL ? vtMove / dLen : V_NULL) ;
|
||||
bool bOk = ExeSurfFrMoveSimpleNoCollision( nId1, nId2, vtDir, dLen, nRefType) ;
|
||||
@@ -246,7 +246,7 @@ LuaSurfFrRotateSimpleNoCollision( lua_State* L)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 5, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// verifico quale è la massima (in valore assoluto) rotazione possibile
|
||||
// verifico quale � la massima (in valore assoluto) rotazione possibile
|
||||
bool bOk = ExeSurfFrRotateSimpleNoCollision( nId1, nId2, ptCen, dAngDeg, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
@@ -301,6 +301,25 @@ LuaSurfTmPartCount( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmGetPartAndShellFromFacet( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id SurfTm, Id Facet
|
||||
int nIdSurfTm ;
|
||||
LuaCheckParam( L, 1, nIdSurfTm)
|
||||
int nIdFacet ;
|
||||
LuaCheckParam( L, 2, nIdFacet)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il numero di parti della superficie trimesh
|
||||
int nPart = - 1 ;
|
||||
int nShell = - 1 ;
|
||||
ExeSurfTmGetPartAndShellFromFacet( nIdSurfTm, nIdFacet, nPart, nShell) ;
|
||||
LuaSetParam( L, nPart) ;
|
||||
LuaSetParam( L, nShell) ;
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmGetVertex( lua_State* L)
|
||||
@@ -335,7 +354,7 @@ LuaSurfTmGetNearestVertex( lua_State* L)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 3, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il vertice più vicino della superficie
|
||||
// recupero il vertice pi� vicino della superficie
|
||||
int nVert ;
|
||||
Point3d ptVert ;
|
||||
bool bOk = ExeSurfTmGetNearestVertex( nId, ptNear, nRefId, nVert, ptVert) ;
|
||||
@@ -556,7 +575,7 @@ LuaSurfTmFacetNearestEndPoint( lua_State* L)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 4, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il punto End più vicino della faccia della superficie trimesh
|
||||
// recupero il punto End pi� vicino della faccia della superficie trimesh
|
||||
Point3d ptEnd ;
|
||||
Vector3d vtN ;
|
||||
if ( ExeSurfTmFacetNearestEndPoint( nId, nFacet, ptNear, nRefId, ptEnd, vtN)) {
|
||||
@@ -584,7 +603,7 @@ LuaSurfTmFacetNearestMidPoint( lua_State* L)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 4, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il punto Mid più vicino della faccia della superficie trimesh
|
||||
// recupero il punto Mid pi� vicino della faccia della superficie trimesh
|
||||
Point3d ptMid ;
|
||||
Vector3d vtN ;
|
||||
if ( ExeSurfTmFacetNearestMidPoint( nId, nFacet, ptNear, nRefId, ptMid, vtN)) {
|
||||
@@ -1140,6 +1159,34 @@ LuaSurfBezierGetCurveV( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfBezParamsFromPoint( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : nSurfId, ptOnSurf [, nRefId]
|
||||
int nSurfId ;
|
||||
LuaCheckParam( L, 1, nSurfId)
|
||||
Point3d ptOnSurf ;
|
||||
LuaCheckParam( L, 2, ptOnSurf)
|
||||
int nRefId = nSurfId ;
|
||||
LuaGetParam( L, 3, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero le coordinate parametriche del punto
|
||||
double dU = - 1 ;
|
||||
double dV = - 1 ;
|
||||
bool bOk = ExeSurfBezierParamsFromPoint( nSurfId, ptOnSurf, nRefId, dU, dV) ;
|
||||
if ( bOk) {
|
||||
LuaSetParam( L, dU) ;
|
||||
LuaSetParam( L, dV) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfBezierGetInfo( lua_State* L)
|
||||
@@ -1280,6 +1327,7 @@ LuaInstallGdbGetSurf( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmVertexCount", LuaSurfTmVertexCount) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetCount", LuaSurfTmFacetCount) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmPartCount", LuaSurfTmPartCount) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetPartAndShellFromFacet", LuaSurfTmGetPartAndShellFromFacet) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetVertex", LuaSurfTmGetVertex) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetNearestVertex", LuaSurfTmGetNearestVertex) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmTriangleNormVersor", LuaSurfTmTriangleNormVersor) ;
|
||||
@@ -1312,6 +1360,7 @@ LuaInstallGdbGetSurf( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetPointNrmD1", LuaSurfBezierGetPointNrmD1) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetCurveU", LuaSurfBezierGetCurveU) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetCurveV", LuaSurfBezierGetCurveV) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezParamsFromPoint", LuaSurfBezParamsFromPoint) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetInfo", LuaSurfBezierGetInfo) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetControlCurveU", LuaSurfBezierGetControlCurveU) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetControlCurveV", LuaSurfBezierGetControlCurveV) ;
|
||||
|
||||
+20
-12
@@ -933,16 +933,18 @@ LuaRemoveCurveCompoUndercutOnY( lua_State* L)
|
||||
static int
|
||||
LuaCurveCompoSetTempProp( lua_State* L)
|
||||
{
|
||||
// 3 parametri : Id, nCrv, nProp
|
||||
// 3 parametri : Id, nCrv, nProp [, nPropInd]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nCrv ;
|
||||
LuaCheckParam( L, 2, nCrv)
|
||||
int nProp ;
|
||||
LuaCheckParam( L, 3, nProp)
|
||||
int nPropInd = 0 ;
|
||||
LuaGetParam( L, 4, nPropInd) ;
|
||||
LuaClearStack( L) ;
|
||||
// imposto sulla curva della composita la proprietà temporanea
|
||||
bool bOk = ExeCurveCompoSetTempProp( nId, nCrv, nProp) ;
|
||||
bool bOk = ExeCurveCompoSetTempProp( nId, nCrv, nProp, nPropInd) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
@@ -951,16 +953,18 @@ LuaCurveCompoSetTempProp( lua_State* L)
|
||||
static int
|
||||
LuaCurveCompoSetTempParam( lua_State* L)
|
||||
{
|
||||
// 3 parametri : Id, nCrv, dParam
|
||||
// 3 parametri : Id, nCrv, dParam [, nParamInd]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nCrv ;
|
||||
LuaCheckParam( L, 2, nCrv)
|
||||
double dParam ;
|
||||
LuaCheckParam( L, 3, dParam)
|
||||
int nParamInd = 0 ;
|
||||
LuaGetParam( L, 4, nParamInd) ;
|
||||
LuaClearStack( L) ;
|
||||
// imposto sulla curva della composita il parametro temporaneo
|
||||
bool bOk = ExeCurveCompoSetTempParam( nId, nCrv, dParam) ;
|
||||
bool bOk = ExeCurveCompoSetTempParam( nId, nCrv, dParam, nParamInd) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
@@ -1027,7 +1031,7 @@ LuaProjectCurveOnSurf( lua_State* L)
|
||||
static int
|
||||
LuaProjectCurveOnSurfDir( lua_State* L)
|
||||
{
|
||||
// 4, 5, 6, 7 o 8 parametri : nCurveId, vSurfId, vtDir, nDestGrpId [, dLinTol [, dMaxSegmLen] [, bDirFromProj] [, nRefType]]
|
||||
// 4, 5, 6, 7 o 8 parametri : nCurveId, vSurfId, vtDir, nDestGrpId [, dLinTol [, dMaxSegmLen] [, bDirFromProj] [,bFromVsTo] [, nRefType]]
|
||||
int nCurveId ;
|
||||
LuaCheckParam( L, 1, nCurveId)
|
||||
INTVECTOR vSurfId ;
|
||||
@@ -1039,14 +1043,16 @@ LuaProjectCurveOnSurfDir( lua_State* L)
|
||||
double dLinTol = 0.01 ;
|
||||
double dMaxSegmLen = INFINITO ;
|
||||
bool bDirFromProj = false ;
|
||||
bool bFromVsTo = true ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
if ( LuaGetParam( L, 5, dLinTol) &&
|
||||
LuaGetParam( L, 6, dMaxSegmLen) &&
|
||||
LuaGetParam( L, 7, bDirFromProj))
|
||||
LuaGetParam( L, 8, nRefType) ;
|
||||
LuaGetParam( L, 7, bDirFromProj) &&
|
||||
LuaGetParam( L, 8, bFromVsTo))
|
||||
LuaGetParam( L, 9, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// proietto la curva su una o più superfici secondo la direzione data
|
||||
bool bOk = ExeProjectCurveOnSurfDir( nCurveId, vSurfId, vtDir, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromProj, nRefType) ;
|
||||
bool bOk = ExeProjectCurveOnSurfDir( nCurveId, vSurfId, vtDir, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromProj, bFromVsTo, nRefType) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
@@ -1055,7 +1061,7 @@ LuaProjectCurveOnSurfDir( lua_State* L)
|
||||
static int
|
||||
LuaProjectCurveOnSurfExt( lua_State* L)
|
||||
{
|
||||
// 4, 5, 6 o 7 parametri : nCurveId, vSurfId, nGuideId, nDestGrpId [, dLinTol [, dMaxSegmLen] [, bDirFromGuide]]
|
||||
// 4, 5, 6 o 7 parametri : nCurveId, vSurfId, nGuideId, nDestGrpId [, dLinTol [, dMaxSegmLen] [, bDirFromGuide] [,bFromVsTo]]
|
||||
int nCurveId ;
|
||||
LuaCheckParam( L, 1, nCurveId)
|
||||
INTVECTOR vSurfId ;
|
||||
@@ -1067,12 +1073,14 @@ LuaProjectCurveOnSurfExt( lua_State* L)
|
||||
double dLinTol = 0.01 ;
|
||||
double dMaxSegmLen = INFINITO ;
|
||||
bool bDirFromGuide = false ;
|
||||
bool bFromVsTo = true ;
|
||||
if ( LuaGetParam( L, 5, dLinTol) &&
|
||||
LuaGetParam( L, 6, dMaxSegmLen))
|
||||
LuaGetParam( L, 7, bDirFromGuide) ;
|
||||
LuaGetParam( L, 6, dMaxSegmLen) &&
|
||||
LuaGetParam( L, 7, bDirFromGuide))
|
||||
LuaGetParam( L, 8, bFromVsTo) ;
|
||||
LuaClearStack( L) ;
|
||||
// proietto la curva su una o più superfici secondo la direzione verso la guida
|
||||
bool bOk = ExeProjectCurveOnSurfExt( nCurveId, vSurfId, nGuideId, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromGuide) ;
|
||||
bool bOk = ExeProjectCurveOnSurfExt( nCurveId, vSurfId, nGuideId, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromGuide, bFromVsTo) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
+21
-2
@@ -565,7 +565,7 @@ LuaSurfTmGetShowEdges( lua_State* L)
|
||||
static int
|
||||
LuaSurfTmSetSmoothAng( lua_State* L)
|
||||
{
|
||||
// 2 parametri : nId, nCutterId
|
||||
// 2 parametri : nId, dAngDeg
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dAngDeg ;
|
||||
@@ -577,6 +577,24 @@ LuaSurfTmSetSmoothAng( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmGetSmoothAng( lua_State* L)
|
||||
{
|
||||
// 1 parametro : nId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero lo smooth angle della superficie
|
||||
double dAngDeg ;
|
||||
bool bOk = ExeSurfTmGetSmoothAng( nId, dAngDeg) ;
|
||||
if ( bOk)
|
||||
LuaSetParam( L, dAngDeg) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmOffset( lua_State* L)
|
||||
@@ -664,7 +682,7 @@ LuaSurfBzTrim( lua_State* L)
|
||||
bool
|
||||
LuaInstallGdbModifySurf( LuaMgr& luaMgr)
|
||||
{
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
bool bOk = true ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtInvertSurf", LuaInvertSurf) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExplodeSurf", LuaExplodeSurf) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtApproxSurf", LuaApproxSurf) ;
|
||||
@@ -694,6 +712,7 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSetShowEdges", LuaSurfTmSetShowEdges) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetShowEdges", LuaSurfTmGetShowEdges) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSetSmoothAng", LuaSurfTmSetSmoothAng) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetSmoothAng", LuaSurfTmGetSmoothAng) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmOffset", LuaSurfTmOffset) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmThickeningOffset", LuaSurfTmThickeningOffset) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCutSurfBzPlane", LuaCutSurfBzPlane) ;
|
||||
|
||||
+44
-3
@@ -73,6 +73,25 @@ LuaVolZmapSetShowEdges( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapGetShowEdges( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// imposto flag visualizzazione spigoli vivi
|
||||
bool bShow ;
|
||||
bool bOk = ExeVolZmapGetShowEdges( nId, bShow) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, bShow) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaRemoveVolZmapPart( lua_State* L)
|
||||
@@ -402,7 +421,7 @@ LuaUpdateVolZmapByAddingSurfTm( lua_State* L)
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaUniformVolZmap( lua_State* L)
|
||||
LuaVolZmapMakeUniform( lua_State* L)
|
||||
{
|
||||
// 2 o 3 o 4 parametri : nVolZmapId, dToler [, bExtensionFirst] [, nToolNum]
|
||||
int nVolZmapId ;
|
||||
@@ -414,7 +433,7 @@ LuaUniformVolZmap( lua_State* L)
|
||||
int nToolNum = 0 ;
|
||||
LuaGetParam( L, 4, nToolNum) ;
|
||||
LuaClearStack( L) ;
|
||||
bool bOk = ExeUniformVolZmap( nVolZmapId, dToler, bExtensionFirst, nToolNum) ;
|
||||
bool bOk = ExeVolZmapMakeUniform( nVolZmapId, dToler, bExtensionFirst, nToolNum) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
@@ -437,6 +456,26 @@ LuaVolZmapOffset( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapRemoveFins( lua_State* L)
|
||||
{
|
||||
// 3 parametri : Id, vtDir, dThick
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId) ;
|
||||
Vector3d vtDir ;
|
||||
LuaCheckParam( L, 2, vtDir) ;
|
||||
double dThick ;
|
||||
LuaCheckParam( L, 3, dThick) ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 4, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// Eseguo la rimozione delle alette
|
||||
bool bOk = ExeVolZMapRemoveFins( nId, vtDir, dThick, nRefType) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbModifyVol( LuaMgr& luaMgr)
|
||||
@@ -445,6 +484,7 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExplodeVolume", LuaExplodeVolume) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapChangeResolution", LuaVolZmapChangeResolution) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetShowEdges", LuaVolZmapSetShowEdges) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetShowEdges", LuaVolZmapGetShowEdges) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveVolZmapPart", LuaRemoveVolZmapPart) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetStdTool", LuaVolZmapSetStdTool) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetAdvTool", LuaVolZmapSetAdvTool) ;
|
||||
@@ -458,7 +498,8 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapMillingStep", LuaVolZmapMillingStep) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCutVolZmapPlane", LuaCutVolZmapPlane) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtUpdateVolZmapByAddingSurfTm", LuaUpdateVolZmapByAddingSurfTm ) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtUniformVolZmap", LuaUniformVolZmap) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapMakeUniform", LuaVolZmapMakeUniform) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapOffset", LuaVolZmapOffset) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapRemoveFins", LuaVolZmapRemoveFins) ;
|
||||
return bOk ;
|
||||
}
|
||||
@@ -563,6 +563,25 @@ LuaCopyGlobEx( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaDuplicateGeomDB( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : nSouCtx, nDestCtx [, bSkipTemp]
|
||||
int nSouCtx ;
|
||||
LuaCheckParam( L, 1, nSouCtx)
|
||||
int nDestCtx ;
|
||||
LuaCheckParam( L, 2, nDestCtx)
|
||||
bool bSkipTemp = false ;
|
||||
LuaGetParam( L, 3, bSkipTemp) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo la copia
|
||||
bool bOk = ExeDuplicateGeomDB( nSouCtx, nDestCtx, bSkipTemp) ;
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaRelocate( lua_State* L)
|
||||
@@ -718,6 +737,7 @@ LuaInstallGdbObjects( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCopyEx", LuaCopyEx) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCopyGlob", LuaCopyGlob) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCopyGlobEx", LuaCopyGlobEx) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtDuplicateGeomDB", LuaDuplicateGeomDB) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtRelocate", LuaRelocate) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtRelocateGlob", LuaRelocateGlob) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGroupSwap", LuaGroupSwap) ;
|
||||
|
||||
+289
-120
@@ -30,6 +30,7 @@
|
||||
#include "/EgtDev/Include/EgtIniFile.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EgtStringConverter.h"
|
||||
#include <sstream>
|
||||
#include <Windowsx.h>
|
||||
#include <shlobj.h>
|
||||
|
||||
@@ -898,6 +899,21 @@ LuaEraseDirectory( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaEraseNonEmptyDirectory( lua_State* L)
|
||||
{
|
||||
// 1 parametro : sDir
|
||||
string sDir ;
|
||||
LuaCheckParam( L, 1, sDir)
|
||||
LuaClearStack( L) ;
|
||||
// cancello direttorio (deve essere vuoto)
|
||||
bool bOk = EraseNonEmptyDirectory( sDir) ;
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTextFileCompare( lua_State* L)
|
||||
@@ -1198,146 +1214,298 @@ LuaReleaseMutex( lua_State* L)
|
||||
//-------------------------------------------------------------------------------
|
||||
const int MAX_CTRLS = IDC_TEXT8 -IDC_TEXT1 + 1 ;
|
||||
const int OFFS_CTRLS = 40 ;
|
||||
enum TYPE_CTRLS { CTRL_NONE = 0, CTRL_CHECK = 1, CTRL_COMBO = 2, CTRL_EDIT = 3} ;
|
||||
enum TYPE_CTRLS { CTRL_NONE = 0, CTRL_CHECK = 1, CTRL_COMBO = 2, CTRL_EDIT = 3, CTRL_COLOR = 4} ;
|
||||
static int s_nCtrls = 0 ;
|
||||
static string s_sCaption ;
|
||||
static string s_sText[MAX_CTRLS] ;
|
||||
static string s_sEdit[MAX_CTRLS] ;
|
||||
static int s_nType[MAX_CTRLS] ;
|
||||
static COLORREF s_CustomColors[16] = {12632256} ; // 16 colori GRAY
|
||||
static bool s_bCustomColorsInit = false ; // flag di inizializzazione colori
|
||||
const char* SEC_SCENE = "Scene" ;
|
||||
const char* KEY_CUSTOMCOLORS = "CustomColors" ;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
{
|
||||
// variabili static locali per mantenere lo stato tra chiamate per selezione colori
|
||||
static COLORREF selectedColor[MAX_CTRLS] = {0} ; // BLACK
|
||||
static HBRUSH hColorBrush[MAX_CTRLS] = {NULL} ; // non definito
|
||||
|
||||
switch ( message) {
|
||||
case WM_INITDIALOG :
|
||||
{
|
||||
// dati del dialogo
|
||||
HWND hwndOwner = GetParent( hwndDlg) ;
|
||||
if ( hwndOwner == nullptr)
|
||||
hwndOwner = GetDesktopWindow() ;
|
||||
RECT rcOwner, rcDlg ;
|
||||
GetWindowRect( hwndOwner, &rcOwner) ;
|
||||
GetWindowRect( hwndDlg, &rcDlg) ;
|
||||
// determino la posizione dell'ultima riga di dati da visualizzare
|
||||
HWND hwndLR = GetDlgItem( hwndDlg, IDC_TEXT1 + Clamp( s_nCtrls, 1, MAX_CTRLS) - 1) ;
|
||||
RECT rcLR ;
|
||||
GetWindowRect( hwndLR, &rcLR) ;
|
||||
POINT ptLR{ rcLR.left, rcLR.top} ;
|
||||
ScreenToClient( hwndDlg, &ptLR) ;
|
||||
// centro e scalo il dialogo
|
||||
int nNewH = rcLR.top - rcOwner.top + 2 * OFFS_CTRLS ; // non chiaro perchè va sottratto rcOwner.top ma funziona sempre
|
||||
SetWindowPos( hwndDlg,
|
||||
HWND_TOP,
|
||||
( rcOwner.left + rcOwner.right - ( rcDlg.right - rcDlg.left)) / 2,
|
||||
( rcOwner.top + rcOwner.bottom - nNewH) / 2,
|
||||
( rcDlg.right - rcDlg.left),
|
||||
nNewH,
|
||||
0) ;
|
||||
// riposiziono il bottone Ok
|
||||
HWND hwndOk = GetDlgItem( hwndDlg, IDOK) ;
|
||||
RECT rcOk ;
|
||||
GetWindowRect( hwndOk, &rcOk) ;
|
||||
POINT ptOk{ rcOk.left, rcOk.top} ;
|
||||
ScreenToClient( hwndDlg, &ptOk) ;
|
||||
SetWindowPos( hwndOk,
|
||||
hwndDlg,
|
||||
ptOk.x,
|
||||
ptLR.y + OFFS_CTRLS,
|
||||
0, 0,
|
||||
SWP_NOSIZE | SWP_NOZORDER) ;
|
||||
// riposiziono il bottone Cancel
|
||||
HWND hwndCl = GetDlgItem( hwndDlg, IDCANCEL) ;
|
||||
RECT rcCl ;
|
||||
GetWindowRect( hwndCl, &rcCl) ;
|
||||
POINT ptCl{ rcCl.left, rcCl.top} ;
|
||||
ScreenToClient( hwndDlg, &ptCl) ;
|
||||
SetWindowPos( hwndCl,
|
||||
hwndDlg,
|
||||
ptCl.x,
|
||||
ptLR.y + OFFS_CTRLS,
|
||||
0, 0,
|
||||
SWP_NOSIZE | SWP_NOZORDER) ;
|
||||
}
|
||||
// assegno titolo del dialogo
|
||||
SetWindowText( hwndDlg, stringtoW( s_sCaption)) ;
|
||||
// assegno testi e valori di default e nascondo linee dei controlli non usati
|
||||
for ( int i = 0 ; i < MAX_CTRLS ; ++ i) {
|
||||
if ( i < s_nCtrls) {
|
||||
SetDlgItemText( hwndDlg, IDC_TEXT1 + i, stringtoW( s_sText[i])) ;
|
||||
if ( s_sEdit[i].find( "CK:") == 0) {
|
||||
bool bChecked = false ;
|
||||
FromString( s_sEdit[i].substr( 3), bChecked) ;
|
||||
CheckDlgButton( hwndDlg, IDC_CHECK1 + i, ( bChecked ? BST_CHECKED : BST_UNCHECKED)) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ;
|
||||
s_nType[i] = CTRL_CHECK ;
|
||||
case WM_INITDIALOG :
|
||||
{
|
||||
// colore di default
|
||||
COLORREF defaultColor = RGB( 255, 0, 0) ;
|
||||
// inizializzazione colori e brush
|
||||
for ( int i = 0 ; i < MAX_CTRLS ; ++ i) {
|
||||
selectedColor[i] = defaultColor ;
|
||||
if ( hColorBrush[i] != NULL)
|
||||
DeleteObject( hColorBrush[i]) ;
|
||||
hColorBrush[i] = CreateSolidBrush( selectedColor[i]) ;
|
||||
}
|
||||
else if ( s_sEdit[i].find( "CB:") == 0) {
|
||||
string sList = s_sEdit[i].substr( 3) ;
|
||||
STRVECTOR vsVal ;
|
||||
Tokenize( sList, ",", vsVal) ;
|
||||
int nSel = 0 ;
|
||||
HWND hwndCBox = GetDlgItem( hwndDlg, IDC_COMBO1 + i) ;
|
||||
for ( int j = 0 ; j < int( vsVal.size()) ; ++ j) {
|
||||
string sItem ;
|
||||
if ( vsVal[j][0] == '*') {
|
||||
nSel = j ;
|
||||
sItem = vsVal[j].substr( 1) ;
|
||||
}
|
||||
else
|
||||
sItem = vsVal[j] ;
|
||||
ComboBox_AddString( hwndCBox, stringtoW( sItem)) ;
|
||||
// dati del dialogo
|
||||
HWND hwndOwner = GetParent( hwndDlg) ;
|
||||
if ( hwndOwner == nullptr)
|
||||
hwndOwner = GetDesktopWindow() ;
|
||||
RECT rcOwner, rcDlg ;
|
||||
GetWindowRect( hwndOwner, &rcOwner) ;
|
||||
GetWindowRect( hwndDlg, &rcDlg) ;
|
||||
// determino la posizione dell'ultima riga di dati da visualizzare
|
||||
HWND hwndLR = GetDlgItem( hwndDlg, IDC_TEXT1 + Clamp( s_nCtrls, 1, MAX_CTRLS) - 1) ;
|
||||
RECT rcLR ;
|
||||
GetWindowRect( hwndLR, &rcLR) ;
|
||||
POINT ptLR{ rcLR.left, rcLR.top} ;
|
||||
ScreenToClient( hwndDlg, &ptLR) ;
|
||||
// centro e scalo il dialogo
|
||||
int nNewH = rcLR.top - rcOwner.top + 2 * OFFS_CTRLS ; // non chiaro perchè va sottratto rcOwner.top ma funziona sempre
|
||||
SetWindowPos( hwndDlg,
|
||||
HWND_TOP,
|
||||
( rcOwner.left + rcOwner.right - ( rcDlg.right - rcDlg.left)) / 2,
|
||||
( rcOwner.top + rcOwner.bottom - nNewH) / 2,
|
||||
( rcDlg.right - rcDlg.left),
|
||||
nNewH,
|
||||
0) ;
|
||||
// riposiziono il bottone Ok
|
||||
HWND hwndOk = GetDlgItem( hwndDlg, IDOK) ;
|
||||
RECT rcOk ;
|
||||
GetWindowRect( hwndOk, &rcOk) ;
|
||||
POINT ptOk{ rcOk.left, rcOk.top} ;
|
||||
ScreenToClient( hwndDlg, &ptOk) ;
|
||||
SetWindowPos( hwndOk,
|
||||
hwndDlg,
|
||||
ptOk.x,
|
||||
ptLR.y + OFFS_CTRLS,
|
||||
0, 0,
|
||||
SWP_NOSIZE | SWP_NOZORDER) ;
|
||||
// riposiziono il bottone Cancel
|
||||
HWND hwndCl = GetDlgItem( hwndDlg, IDCANCEL) ;
|
||||
RECT rcCl ;
|
||||
GetWindowRect( hwndCl, &rcCl) ;
|
||||
POINT ptCl{ rcCl.left, rcCl.top} ;
|
||||
ScreenToClient( hwndDlg, &ptCl) ;
|
||||
SetWindowPos( hwndCl,
|
||||
hwndDlg,
|
||||
ptCl.x,
|
||||
ptLR.y + OFFS_CTRLS,
|
||||
0, 0,
|
||||
SWP_NOSIZE | SWP_NOZORDER) ;
|
||||
}
|
||||
// assegno titolo del dialogo
|
||||
SetWindowText( hwndDlg, stringtoW( s_sCaption)) ;
|
||||
// assegno testi e valori di default e nascondo linee dei controlli non usati
|
||||
for ( int i = 0 ; i < MAX_CTRLS ; ++ i) {
|
||||
if ( i < s_nCtrls) {
|
||||
SetDlgItemText( hwndDlg, IDC_TEXT1 + i, stringtoW( s_sText[i])) ;
|
||||
if ( s_sEdit[i].find( "CK:") == 0) {
|
||||
bool bChecked = false ;
|
||||
FromString( s_sEdit[i].substr( 3), bChecked) ;
|
||||
CheckDlgButton( hwndDlg, IDC_CHECK1 + i, ( bChecked ? BST_CHECKED : BST_UNCHECKED)) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ;
|
||||
s_nType[i] = CTRL_CHECK ;
|
||||
}
|
||||
else if ( s_sEdit[i].find( "CB:") == 0) {
|
||||
string sList = s_sEdit[i].substr( 3) ;
|
||||
STRVECTOR vsVal ;
|
||||
Tokenize( sList, ",", vsVal) ;
|
||||
int nSel = 0 ;
|
||||
HWND hwndCBox = GetDlgItem( hwndDlg, IDC_COMBO1 + i) ;
|
||||
for ( int j = 0 ; j < int( vsVal.size()) ; ++ j) {
|
||||
string sItem ;
|
||||
if ( vsVal[j][0] == '*') {
|
||||
nSel = j ;
|
||||
sItem = vsVal[j].substr( 1) ;
|
||||
}
|
||||
else
|
||||
sItem = vsVal[j] ;
|
||||
ComboBox_AddString( hwndCBox, stringtoW( sItem)) ;
|
||||
}
|
||||
ComboBox_SetCurSel( hwndCBox, nSel) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ;
|
||||
s_nType[i] = CTRL_COMBO ;
|
||||
}
|
||||
else if ( s_sEdit[i].find( "CP:") == 0) {
|
||||
string sVal = s_sEdit[i].substr( 3) ;
|
||||
Color CColor ;
|
||||
if ( ! FromString( sVal, CColor))
|
||||
CColor = INVISIBLE ;
|
||||
selectedColor[i] = RGB( CColor.GetIntRed(), CColor.GetIntGreen(), CColor.GetIntBlue()) ;
|
||||
if ( hColorBrush[i] != NULL)
|
||||
DeleteObject( hColorBrush[i]) ;
|
||||
hColorBrush[i] = CreateSolidBrush( selectedColor[i]) ;
|
||||
// recupero i valori dei colori personalizzati dal file .ini
|
||||
if ( ! s_bCustomColorsInit) {
|
||||
// recupero il file Ini
|
||||
string sIniFile = ExeGetIniFile() ;
|
||||
if ( ! sIniFile.empty()) {
|
||||
string sCustomVals = GetPrivateProfileStringUtf8( SEC_SCENE, KEY_CUSTOMCOLORS, "", sIniFile.c_str()) ;
|
||||
STRVECTOR vsWinColors ; Tokenize( sCustomVals, ",", vsWinColors) ;
|
||||
for ( int j = 0 ; j < ssize( vsWinColors) && j < 16 ; ++ j) {
|
||||
unsigned int unVal ;
|
||||
if ( FromString( vsWinColors[j], unVal)) {
|
||||
unsigned int unR = unVal & 0xFF ;
|
||||
unsigned int unG = ( unVal >> 8) & 0xFF ;
|
||||
unsigned int unB = ( unVal >> 16) & 0xFF ;
|
||||
s_CustomColors[j] = RGB( unR, unG, unB) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
s_bCustomColorsInit = true ;
|
||||
}
|
||||
// nascondo qualsiasi tipo di componente ( per sicurezza)
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ;
|
||||
|
||||
// margini per dimensione del rettangolo preview pickColor
|
||||
const int MARGIN_RIGHT = 8 ; // spazio tra preview e bordo destro dialog
|
||||
const int PREVIEW_HEIGHT = 20 ; // altezza del rettangolo
|
||||
const int PREVIEW_MIN_WIDTH = 40 ; // larghezza minima
|
||||
|
||||
// ottieni o crea la static preview (allargata fino al bordo destro del dialog)
|
||||
HWND hwndPreview = NULL ;
|
||||
RECT rcLabel ;
|
||||
HWND hwndLabel = GetDlgItem( hwndDlg, IDC_TEXT1 + i) ;
|
||||
RECT rcClient ; GetClientRect( hwndDlg, &rcClient) ; // coordinate client del dialog
|
||||
if ( hwndLabel && GetWindowRect( hwndLabel, &rcLabel)) {
|
||||
// converti rcLabel in coordinate client
|
||||
POINT ptLabel = { rcLabel.right, rcLabel.top } ;
|
||||
ScreenToClient( hwndDlg, &ptLabel) ;
|
||||
int x = ptLabel.x + 8 ; // distanza dal label
|
||||
int y = ptLabel.y ;
|
||||
int width = rcClient.right - x - MARGIN_RIGHT ;
|
||||
if ( width < PREVIEW_MIN_WIDTH)
|
||||
width = PREVIEW_MIN_WIDTH ;
|
||||
hwndPreview = CreateWindowEx( 0, L"STATIC", NULL,
|
||||
WS_CHILD | WS_VISIBLE | SS_NOTIFY | SS_CENTERIMAGE | WS_BORDER,
|
||||
x, y, width, PREVIEW_HEIGHT,
|
||||
hwndDlg, ( HMENU)( IDC_COLOR1 + i),
|
||||
GetModuleHandle( NULL), NULL) ;
|
||||
}
|
||||
// pulizia elementi testuali
|
||||
if ( hwndPreview) {
|
||||
SetWindowText( hwndPreview, L"") ;
|
||||
SetWindowPos( hwndPreview, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) ;
|
||||
InvalidateRect( hwndPreview, NULL, TRUE) ;
|
||||
UpdateWindow( hwndPreview) ;
|
||||
}
|
||||
s_nType[i] = CTRL_COLOR ;
|
||||
}
|
||||
else {
|
||||
SetDlgItemText( hwndDlg, IDC_EDIT1 + i, stringtoW( s_sEdit[i])) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ;
|
||||
s_nType[i] = CTRL_EDIT ;
|
||||
}
|
||||
ComboBox_SetCurSel( hwndCBox, nSel) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ;
|
||||
s_nType[i] = CTRL_COMBO ;
|
||||
}
|
||||
else {
|
||||
SetDlgItemText( hwndDlg, IDC_EDIT1 + i, stringtoW( s_sEdit[i])) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_TEXT1 + i), SW_HIDE) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ;
|
||||
s_nType[i] = CTRL_EDIT ;
|
||||
s_nType[i] = CTRL_NONE ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_TEXT1 + i), SW_HIDE) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ;
|
||||
s_nType[i] = CTRL_NONE ;
|
||||
break ;
|
||||
case WM_CTLCOLORSTATIC :
|
||||
{
|
||||
HDC hdcStatic = ( HDC)wParam ;
|
||||
HWND hwndCtrl = ( HWND)lParam ;
|
||||
int ctrlId = GetDlgCtrlID( hwndCtrl) ;
|
||||
if ( ctrlId >= IDC_COLOR1 && ctrlId <= IDC_COLOR8) {
|
||||
int idx = ctrlId - IDC_COLOR1 ;
|
||||
if ( hColorBrush[idx] == NULL)
|
||||
hColorBrush[idx] = CreateSolidBrush( selectedColor[idx]) ;
|
||||
SetBkMode( hdcStatic, OPAQUE) ;
|
||||
SetBkColor( hdcStatic, selectedColor[idx]) ;
|
||||
return ( INT_PTR)hColorBrush[idx] ;
|
||||
}
|
||||
}
|
||||
break ;
|
||||
case WM_COMMAND : {
|
||||
int id = LOWORD( wParam) ;
|
||||
int code = HIWORD( wParam) ;
|
||||
// comando di Preview per brush di colori mediante click del mouse
|
||||
if ( code == STN_CLICKED && id >= IDC_COLOR1 && id <= IDC_COLOR8) {
|
||||
int idx = id - IDC_COLOR1 ;
|
||||
HWND hwndPreview = GetDlgItem( hwndDlg, IDC_COLOR1 + idx) ;
|
||||
if ( ! hwndPreview)
|
||||
return TRUE ;
|
||||
// apertura ChooseColor (usa hwndDlg come owner)
|
||||
CHOOSECOLOR cc = {} ;
|
||||
cc.lStructSize = sizeof( cc) ;
|
||||
cc.hwndOwner = hwndDlg ;
|
||||
cc.lpCustColors = s_CustomColors ;
|
||||
cc.rgbResult = selectedColor[idx] ;
|
||||
cc.Flags = CC_FULLOPEN | CC_RGBINIT ;
|
||||
if ( ChooseColor( &cc)) {
|
||||
selectedColor[idx] = cc.rgbResult ;
|
||||
// salvo nel file Ini i nuovi colori personalizzati
|
||||
string sIniFile = ExeGetIniFile() ;
|
||||
if ( ! sIniFile.empty()) {
|
||||
string sOut = "" ;
|
||||
for ( int j = 0 ; j < ssize( s_CustomColors) && j < 16 ; ++ j)
|
||||
sOut += ToString( ( unsigned int)s_CustomColors[j]) + "," ;
|
||||
sOut.pop_back() ;
|
||||
WritePrivateProfileStringUtf8( SEC_SCENE, KEY_CUSTOMCOLORS, sOut.c_str(), sIniFile.c_str()) ;
|
||||
}
|
||||
if ( hColorBrush[idx] != NULL)
|
||||
DeleteObject( hColorBrush[idx]) ;
|
||||
hColorBrush[idx] = CreateSolidBrush( selectedColor[idx]) ;
|
||||
InvalidateRect(hwndPreview, NULL, TRUE) ;
|
||||
UpdateWindow( hwndPreview) ;
|
||||
}
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
switch ( LOWORD( wParam)) {
|
||||
case IDOK :
|
||||
for ( int i = 0 ; i < s_nCtrls ; ++ i) {
|
||||
AtoWEX<128> wsEdit( "") ;
|
||||
s_sEdit[i] = "" ;
|
||||
switch ( s_nType[i]) {
|
||||
case CTRL_CHECK :
|
||||
s_sEdit[i] = ( IsDlgButtonChecked( hwndDlg, IDC_CHECK1 + i) == BST_CHECKED ? "1" : "0") ;
|
||||
break ;
|
||||
case CTRL_COMBO :
|
||||
if ( GetDlgItemText( hwndDlg, IDC_COMBO1 + i, LPWSTR( wsEdit), 128) > 0)
|
||||
s_sEdit[i] = wstrztoA( wsEdit) ;
|
||||
break ;
|
||||
case CTRL_EDIT :
|
||||
if ( GetDlgItemText( hwndDlg, IDC_EDIT1 + i, LPWSTR( wsEdit), 128) > 0)
|
||||
s_sEdit[i] = wstrztoA( wsEdit) ;
|
||||
break ;
|
||||
case CTRL_COLOR :
|
||||
{
|
||||
COLORREF col = selectedColor[i] ;
|
||||
BYTE r = GetRValue( col), g = GetGValue( col), b = GetBValue( col) ;
|
||||
char buf[16] ;
|
||||
sprintf_s( buf, sizeof( buf), "%u,%u,%u", r, g, b) ;
|
||||
s_sEdit[i] = buf ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
[[fallthrough]] ;
|
||||
case IDCANCEL : {
|
||||
// pulizia brush colori
|
||||
for ( int i = 0 ; i < MAX_CTRLS ; ++ i) {
|
||||
if ( hColorBrush[i] != NULL) {
|
||||
DeleteObject( hColorBrush[i]) ;
|
||||
hColorBrush[i] = NULL ;
|
||||
}
|
||||
}
|
||||
EndDialog( hwndDlg, wParam) ;
|
||||
return TRUE ;
|
||||
}
|
||||
}
|
||||
}
|
||||
break ;
|
||||
case WM_COMMAND :
|
||||
switch ( LOWORD( wParam)) {
|
||||
case IDOK :
|
||||
for ( int i = 0 ; i < s_nCtrls ; ++ i) {
|
||||
AtoWEX<128> wsEdit( "") ;
|
||||
s_sEdit[i] = "" ;
|
||||
switch ( s_nType[i]) {
|
||||
case CTRL_CHECK :
|
||||
s_sEdit[i] = ( IsDlgButtonChecked( hwndDlg, IDC_CHECK1 + i) == BST_CHECKED ? "1" : "0") ;
|
||||
break ;
|
||||
case CTRL_COMBO :
|
||||
if ( GetDlgItemText( hwndDlg, IDC_COMBO1 + i, LPWSTR( wsEdit), 128) > 0)
|
||||
s_sEdit[i] = wstrztoA( wsEdit) ;
|
||||
break ;
|
||||
case CTRL_EDIT :
|
||||
if ( GetDlgItemText( hwndDlg, IDC_EDIT1 + i, LPWSTR( wsEdit), 128) > 0)
|
||||
s_sEdit[i] = wstrztoA( wsEdit) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
[[fallthrough]] ;
|
||||
case IDCANCEL :
|
||||
EndDialog( hwndDlg, wParam) ;
|
||||
return TRUE ;
|
||||
}
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
@@ -1419,6 +1587,7 @@ LuaInstallGeneral( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCreateDirectory", LuaCreateDirectory) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtEmptyDirectory", LuaEmptyDirectory) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtEraseDirectory", LuaEraseDirectory) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtEraseNonEmptyDirectory", LuaEraseNonEmptyDirectory) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTextFileCompare", LuaTextFileCompare) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtBinaryFileCompare", LuaBinaryFileCompare) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetStringFromIni", LuaGetStringFromIni) ;
|
||||
|
||||
+123
-13
@@ -1462,7 +1462,7 @@ LuaTdbIsCurrToolModified( lua_State* L)
|
||||
{
|
||||
// nessun parametro
|
||||
LuaClearStack( L) ;
|
||||
// verifico se l'utensile corrente è stato modificato
|
||||
// verifico se l'utensile corrente � stato modificato
|
||||
bool bOk = ExeTdbIsCurrToolModified() ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
@@ -2037,7 +2037,7 @@ LuaMdbIsCurrMachiningModified( lua_State* L)
|
||||
{
|
||||
// nessun parametro
|
||||
LuaClearStack( L) ;
|
||||
// verifico se la lavorazione corrente è stata modificata
|
||||
// verifico se la lavorazione corrente � stata modificata
|
||||
bool bOk = ExeMdbIsCurrMachiningModified() ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
@@ -3233,6 +3233,25 @@ LuaGetClEntIndex( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetClEntFeed( lua_State* L)
|
||||
{
|
||||
// 1 parametro : nEntId
|
||||
int nEntId ;
|
||||
LuaGetParam( L, 1, nEntId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero la feed
|
||||
double dFeed ;
|
||||
bool bOk = ExeGetClEntFeed( nEntId, dFeed) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, dFeed) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetClEntAxesStatus( lua_State* L)
|
||||
@@ -3290,6 +3309,60 @@ LuaGetClEntAxesVal( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetClEntTDir( lua_State* L)
|
||||
{
|
||||
// 1 parametro : nEntId
|
||||
int nEntId ;
|
||||
LuaGetParam( L, 1, nEntId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero vTDir
|
||||
Vector3d vTDir ;
|
||||
bool bOk = ExeGetClEntTDir( nEntId, vTDir) ;
|
||||
if ( bOk)
|
||||
LuaSetParam( L, vTDir) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetClEntCDir( lua_State* L)
|
||||
{
|
||||
// 1 parametro : nEntId
|
||||
int nEntId ;
|
||||
LuaGetParam( L, 1, nEntId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero vCDir
|
||||
Vector3d vCDir ;
|
||||
bool bOk = ExeGetClEntCDir( nEntId, vCDir) ;
|
||||
if ( bOk)
|
||||
LuaSetParam( L, vCDir) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetClEntADir( lua_State* L)
|
||||
{
|
||||
// 1 parametro : nEntId
|
||||
int nEntId ;
|
||||
LuaGetParam( L, 1, nEntId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero vADir
|
||||
Vector3d vADir ;
|
||||
bool bOk = ExeGetClEntADir( nEntId, vADir) ;
|
||||
if ( bOk)
|
||||
LuaSetParam( L, vADir) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Simulation
|
||||
//-------------------------------------------------------------------------------
|
||||
@@ -3473,7 +3546,7 @@ LuaSimGetMoveInfo( lua_State* L)
|
||||
{
|
||||
// nessun parametro
|
||||
LuaClearStack( L) ;
|
||||
// recupero tipo e veolcità del movimento corrente
|
||||
// recupero tipo e veolcit� del movimento corrente
|
||||
int nGmove ;
|
||||
double dFeed ;
|
||||
bool bOk = ExeSimGetMoveInfo( nGmove, dFeed) ;
|
||||
@@ -3759,11 +3832,38 @@ LuaGetCalcAngles( lua_State* L)
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetCalcAnglesEx( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : vtDirT, vtDirA
|
||||
Vector3d vtDirT ;
|
||||
LuaCheckParam( L, 1, vtDirT)
|
||||
Vector3d vtDirA ;
|
||||
LuaGetParam( L, 2, vtDirA) ;
|
||||
LuaClearStack( L) ;
|
||||
// calcolo gli angoli macchina dalle direzioni fresa e ausiliaria
|
||||
int nStat ; DBLVECTOR vAng1, vAng2 ;
|
||||
bool bOk = ExeGetCalcAngles( vtDirT, vtDirA, nStat, vAng1, vAng2) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk) {
|
||||
LuaSetParam( L, bOk) ;
|
||||
LuaSetParam( L, nStat) ;
|
||||
LuaSetParam( L, vAng1) ;
|
||||
LuaSetParam( L, vAng2) ;
|
||||
return 4 ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetCalcPositions( lua_State* L)
|
||||
{
|
||||
// da 2 a 5 parametri : ptP, dAngA [, dAngB] [, dAngC] [, dAngD]
|
||||
// da 1 a 5 parametri : ptP [, dAngR1] [, dAngR2] [, dAngR3] [, dAngR4]
|
||||
Point3d ptP ;
|
||||
LuaCheckParam( L, 1, ptP)
|
||||
DBLVECTOR vAng ;
|
||||
@@ -3781,7 +3881,7 @@ LuaGetCalcPositions( lua_State* L)
|
||||
// restituisco il risultato
|
||||
if ( bOk) {
|
||||
LuaSetParam( L, bOk) ;
|
||||
LuaSetParam( L, 0) ; // assegnato per compatibilità
|
||||
LuaSetParam( L, 0) ; // assegnato per compatibilità
|
||||
LuaSetParam( L, dX) ;
|
||||
LuaSetParam( L, dY) ;
|
||||
LuaSetParam( L, dZ) ;
|
||||
@@ -3909,21 +4009,26 @@ LuaGetCalcAuxDirFromAngles( lua_State* L)
|
||||
static int
|
||||
LuaVerifyOutstroke( lua_State* L)
|
||||
{
|
||||
// 5 parametri : dX, dY, dZ, dAngA, dAngB
|
||||
// 3 o 4 o 5 o 6 o 7 parametri : dX, dY, dZ [, dAngR1] [, dAngR2] [, dAngR3] [, dAngR4]
|
||||
double dX ;
|
||||
LuaCheckParam( L, 1, dX)
|
||||
double dY ;
|
||||
LuaCheckParam( L, 2, dY)
|
||||
double dZ ;
|
||||
LuaCheckParam( L, 3, dZ)
|
||||
double dAngA ;
|
||||
LuaCheckParam( L, 4, dAngA)
|
||||
double dAngB ;
|
||||
LuaCheckParam( L, 5, dAngB)
|
||||
DBLVECTOR vAng ;
|
||||
int i ;
|
||||
for ( i = 4 ; i <= 7 ; ++ i) {
|
||||
double dAng ;
|
||||
if ( LuaGetParam( L, i, dAng))
|
||||
vAng.emplace_back( dAng) ;
|
||||
else
|
||||
break ;
|
||||
}
|
||||
LuaClearStack( L) ;
|
||||
// imposto la tavola corrente per il calcolo
|
||||
int nStat ;
|
||||
bool bOk = ExeVerifyOutstroke( dX, dY, dZ, dAngA, dAngB, nStat) ;
|
||||
bool bOk = ExeVerifyOutstroke( dX, dY, dZ, vAng, nStat) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk) {
|
||||
LuaSetParam( L, ( nStat == 0)) ;
|
||||
@@ -4628,10 +4733,14 @@ LuaInstallMachMgr( LuaMgr& luaMgr)
|
||||
// CL Entities Interrogations
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntMove", LuaGetClEntMove) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntFlag", LuaGetClEntFlag) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntIndex", LuaGetClEntIndex) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntIndex", LuaGetClEntIndex) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntFeed", LuaGetClEntFeed) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntAxesStatus", LuaGetClEntAxesStatus) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntAxesMask", LuaGetClEntAxesMask) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntAxesVal", LuaGetClEntAxesVal) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntAxesVal", LuaGetClEntAxesVal) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntTDir", LuaGetClEntTDir) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntCDir", LuaGetClEntCDir) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntADir", LuaGetClEntADir) ;
|
||||
// Simulation
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSimInit", LuaSimInit) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSimStart", LuaSimStart) ;
|
||||
@@ -4677,6 +4786,7 @@ LuaInstallMachMgr( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetAllCurrAxesNames", LuaGetAllCurrAxesNames) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetRotAxisBlocked", LuaGetRotAxisBlocked) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetCalcAngles", LuaGetCalcAngles) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetCalcAnglesEx", LuaGetCalcAnglesEx) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetCalcPositions", LuaGetCalcPositions) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetRobotAngles", LuaGetRobotAngles) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetCalcTipFromPositions", LuaGetCalcTipFromPositions) ;
|
||||
|
||||
+15
-1
@@ -73,6 +73,19 @@ LuaDraw( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaRedraw( lua_State* L)
|
||||
{
|
||||
// nessun parametro
|
||||
LuaClearStack( L) ;
|
||||
// forzo ridisegno
|
||||
bool bOk = ExeRedraw() ;
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetShowMode( lua_State* L)
|
||||
@@ -378,10 +391,11 @@ LuaSetShowSurfBezierTol( lua_State* L)
|
||||
bool
|
||||
LuaInstallScene( LuaMgr& luaMgr)
|
||||
{
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
bool bOk = true ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSetBackground", LuaSetBackground) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetBackground", LuaGetBackground) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtDraw", LuaDraw) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtRedraw", LuaRedraw) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSetShowMode", LuaSetShowMode) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSetShowCurveDirection", LuaSetShowCurveDirection) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSetShowTriaAdv", LuaSetShowTriaAdv) ;
|
||||
|
||||
@@ -169,16 +169,18 @@ LuaTestSpheSurface( lua_State* L)
|
||||
static int
|
||||
LuaTestSurfaceSurface( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nSurf1Id, nSurf2Id, dSafeDist
|
||||
// 3 o 4 parametri : nSurf1Id, nSurf2Id, dSafeDist [, bTestEnclusion]
|
||||
int nSurf1Id ;
|
||||
LuaCheckParam( L, 1, nSurf1Id)
|
||||
int nSurf2Id ;
|
||||
LuaCheckParam( L, 2, nSurf2Id)
|
||||
double dSafeDist ;
|
||||
LuaCheckParam( L, 3, dSafeDist)
|
||||
bool bTestEnclusion = false ;
|
||||
LuaGetParam( L, 4, bTestEnclusion) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo verifica di interferenza
|
||||
int nRes = ExeTestSurfaceSurface( nSurf1Id, nSurf2Id, dSafeDist) ;
|
||||
int nRes = ExeTestSurfaceSurface( nSurf1Id, nSurf2Id, dSafeDist, bTestEnclusion) ;
|
||||
// restituisco il risultato
|
||||
if ( nRes >= 0)
|
||||
LuaSetParam( L, ( nRes != 0)) ;
|
||||
|
||||
+132
-121
@@ -21,75 +21,59 @@ using namespace std ;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTrimmingAutoSearch( lua_State* L)
|
||||
LuaTrimmingGetHoleBorder( lua_State* L)
|
||||
{
|
||||
// 9 Parametri : nParentId, nSurfLayerId, dShapeLinTol, dShapeAngTol, dLinTol, dEdgeLinTol, dAngTol, dAngFaceTol, vsShapes
|
||||
// 7 parametri : nPartId, vSurfIds, vOtherSurfIds, dSurfLinTol, dSurfAngTol, dEdgeLinTol, dEdgeAngTol, dEdgeThick
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId) ;
|
||||
int nSurfLayerId ;
|
||||
LuaCheckParam( L, 2, nSurfLayerId) ;
|
||||
double dShapeLinTol ;
|
||||
LuaCheckParam( L, 3, dShapeLinTol) ;
|
||||
double dShapeAngTol ;
|
||||
LuaCheckParam( L, 4, dShapeAngTol) ;
|
||||
double dLinTol ;
|
||||
LuaCheckParam( L, 5, dLinTol) ;
|
||||
INTVECTOR vSurfIds ;
|
||||
LuaCheckParam( L, 2, vSurfIds) ;
|
||||
INTVECTOR vOtherSurfIds ;
|
||||
LuaCheckParam( L, 3, vOtherSurfIds) ;
|
||||
double dSurfLinTol ;
|
||||
LuaCheckParam( L, 4, dSurfLinTol) ;
|
||||
double dSurfAngTol ;
|
||||
LuaCheckParam( L, 5, dSurfAngTol) ;
|
||||
double dEdgeLinTol ;
|
||||
LuaCheckParam( L, 6, dEdgeLinTol) ;
|
||||
double dAngTol ;
|
||||
LuaCheckParam( L, 7, dAngTol) ;
|
||||
double dAngFaceTol ;
|
||||
LuaCheckParam( L, 8, dAngFaceTol) ;
|
||||
STRVECTOR vsShapes ;
|
||||
LuaCheckParam( L, 9, vsShapes) ;
|
||||
double dEdgeAngTol ;
|
||||
LuaCheckParam( L, 7, dEdgeAngTol) ;
|
||||
double dEdgeThick ;
|
||||
LuaCheckParam( L, 8, dEdgeThick) ;
|
||||
LuaClearStack( L) ;
|
||||
// Recupero le lavorazioni di Trimming associate
|
||||
INTVECTOR vOtherFaces ;
|
||||
bool bOk = ExeTrimmingAutoSearch( nParentId, nSurfLayerId, dShapeLinTol, dShapeAngTol, dLinTol,
|
||||
dEdgeLinTol, dAngTol, dAngFaceTol, vsShapes) ;
|
||||
return bOk ;
|
||||
// Recupero le Curve per Asole e Fori
|
||||
int nFirstId = GDB_ID_NULL, nCount = 0 ;
|
||||
bool bOk = ExeTrimmingGetHoleBorder( nParentId, vSurfIds, vOtherSurfIds, dSurfLinTol, dSurfAngTol, dEdgeLinTol,
|
||||
dEdgeAngTol, dEdgeThick, nFirstId, nCount) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
LuaSetParam( L, nFirstId) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
return 3 ;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTrimmingGetSurfTmFaceAdj( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nSurfId, vFaces, dAngTol
|
||||
int nSurfId = GDB_ID_NULL ;
|
||||
LuaCheckParam( L, 1, nSurfId) ;
|
||||
INTVECTOR vTria ;
|
||||
LuaCheckParam( L, 2, vTria) ;
|
||||
PNTVECTOR vPts ;
|
||||
LuaCheckParam( L, 3, vPts) ;
|
||||
double dAngTol = 0. ;
|
||||
LuaCheckParam( L, 4, dAngTol) ;
|
||||
double dSize = 0. ;
|
||||
LuaCheckParam( L, 5, dSize) ;
|
||||
double dSizeTol = 0. ;
|
||||
LuaCheckParam( L, 6, dSizeTol) ;
|
||||
// 7 parametri : nParentId, nSurfId, nTria, ptTria, dAngTol, dSize, dSizeTol
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId) ;
|
||||
int nSurfId ;
|
||||
LuaCheckParam( L, 2, nSurfId)
|
||||
int nTria ;
|
||||
LuaCheckParam( L, 3, nTria)
|
||||
Point3d ptTria ;
|
||||
LuaCheckParam( L, 4, ptTria)
|
||||
double dAngTol ;
|
||||
LuaCheckParam( L, 5, dAngTol)
|
||||
double dSize ;
|
||||
LuaCheckParam( L, 6, dSize)
|
||||
double dSizeTol ;
|
||||
LuaCheckParam( L, 7, dSizeTol)
|
||||
LuaClearStack( L) ;
|
||||
// Recupero le facce adiacenti in tolleranza angolare
|
||||
INTVECTOR vOtherFaces ;
|
||||
bool bOk = ExeTrimmingGetSurfTmFaceAdj( nSurfId, vTria, vPts, dAngTol, dSize, dSizeTol, vOtherFaces) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
if ( bOk)
|
||||
LuaSetParam( L, vOtherFaces) ;
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTrimmingGetSurfTmFromStmFaces( lua_State* L)
|
||||
{
|
||||
// 3 Parametri : nParentId, nSurfId, vFaces
|
||||
int nParentId = GDB_ID_NULL ;
|
||||
LuaCheckParam( L, 1, nParentId) ;
|
||||
int nSurfId = GDB_ID_NULL ;
|
||||
LuaCheckParam( L, 2, nSurfId) ;
|
||||
INTVECTOR vFaces ;
|
||||
LuaCheckParam( L, 3, vFaces) ;
|
||||
LuaClearStack( L) ;
|
||||
int nNewSurfId = ExeTrimmingGetSurfTmFromStmFaces( nParentId, nSurfId, vFaces) ;
|
||||
int nNewSurfId = ExeTrimmingGetSurfTmFaceAdj( nParentId, nSurfId, nTria, ptTria, dAngTol, dSize, dSizeTol) ;
|
||||
LuaSetParam( L, nNewSurfId) ;
|
||||
return 1 ;
|
||||
}
|
||||
@@ -98,19 +82,19 @@ LuaTrimmingGetSurfTmFromStmFaces( lua_State* L)
|
||||
static int
|
||||
LuaTrimmingGetAdjSurfs( lua_State* L)
|
||||
{
|
||||
// 4 parametri : nRefSfrId, vAllSurfId, dLinTol, dAngTol
|
||||
// 5 parametri : nRefSfrId, vAllSurfId, dLinTol, dAngTol, dAngFaceTol
|
||||
INTVECTOR vRefSurfId ;
|
||||
LuaCheckParam( L, 1, vRefSurfId) ;
|
||||
LuaCheckParam( L, 1, vRefSurfId)
|
||||
INTVECTOR vOtherSurfId ;
|
||||
LuaCheckParam( L, 2, vOtherSurfId) ;
|
||||
LuaCheckParam( L, 2, vOtherSurfId)
|
||||
double dLinTol ;
|
||||
LuaCheckParam( L, 3, dLinTol) ;
|
||||
LuaCheckParam( L, 3, dLinTol)
|
||||
double dAngTol ;
|
||||
LuaCheckParam( L, 4, dAngTol) ;
|
||||
LuaCheckParam( L, 4, dAngTol)
|
||||
double dAngFaceTol ;
|
||||
LuaCheckParam( L, 5, dAngFaceTol) ;
|
||||
LuaCheckParam( L, 5, dAngFaceTol)
|
||||
LuaClearStack( L) ;
|
||||
// Calcolo le facce adianceti per tolleranza
|
||||
// Calcolo le facce adiacenti per tolleranza
|
||||
INTVECTOR vOtherSurf ;
|
||||
bool bOk = ExeTrimmingGetAdjSurfs( vRefSurfId, vOtherSurfId, dLinTol, dAngTol, dAngFaceTol, vOtherSurf) ;
|
||||
// Restituisco il risultato
|
||||
@@ -123,19 +107,24 @@ LuaTrimmingGetAdjSurfs( lua_State* L)
|
||||
static int
|
||||
LuaTrimmingGetBorders( lua_State* L)
|
||||
{
|
||||
// 4 parametri : nParentId, vIds, dLinTol, dAngTol
|
||||
// 6 parametri : nParentId, vIds, dSurfLinTol, dSurfAngTol, dLinTol, dAngTol
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId) ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
SELVECTOR vIds ;
|
||||
LuaCheckParam( L, 2, vIds) ;
|
||||
LuaCheckParam( L, 2, vIds)
|
||||
double dSurfLinTol ;
|
||||
LuaCheckParam( L, 3, dSurfLinTol) ;
|
||||
double dSurfAngTol ;
|
||||
LuaCheckParam( L, 4, dSurfAngTol) ;
|
||||
double dLinTol ;
|
||||
LuaCheckParam( L, 3, dLinTol) ;
|
||||
LuaCheckParam( L, 5, dLinTol)
|
||||
double dAngTol ;
|
||||
LuaCheckParam( L, 4, dAngTol) ;
|
||||
LuaCheckParam( L, 6, dAngTol)
|
||||
LuaClearStack( L) ;
|
||||
// Creo le curve di Edge grezze
|
||||
int nCount = 0 ;
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
bool bOk = ExeTrimmingGetBorders( nParentId, vIds, dLinTol, dAngTol, nCount, nFirstId) ;
|
||||
int nCount = 0 ;
|
||||
bool bOk = ExeTrimmingGetBorders( nParentId, vIds, dSurfLinTol, dSurfAngTol, dLinTol, dAngTol, nFirstId, nCount) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
LuaSetParam( L, nFirstId) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
@@ -146,23 +135,26 @@ LuaTrimmingGetBorders( lua_State* L)
|
||||
static int
|
||||
LuaTrimmingGetBordersByNormals( lua_State* L)
|
||||
{
|
||||
// 5 o 6 parametri : nParentId, vIds, dLinTol, dAngTol, dThickness, ptNear
|
||||
// 7 o 8 parametri : nParentId, vIds, dSurfLinTol, dSurfAngTol, dThickness
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId) ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
SELVECTOR vIds ;
|
||||
LuaCheckParam( L, 2, vIds) ;
|
||||
LuaCheckParam( L, 2, vIds)
|
||||
double dSurfLinTol ;
|
||||
LuaCheckParam( L, 3, dSurfLinTol) ;
|
||||
double dSurfAngTol ;
|
||||
LuaCheckParam( L, 4, dSurfAngTol) ;
|
||||
double dLinTol ;
|
||||
LuaCheckParam( L, 3, dLinTol) ;
|
||||
LuaCheckParam( L, 5, dLinTol)
|
||||
double dAngTol ;
|
||||
LuaCheckParam( L, 4, dAngTol) ;
|
||||
double dThickness = 10. * EPS_SMALL ;
|
||||
LuaCheckParam( L, 5, dThickness) ;
|
||||
Point3d ptNear = P_INVALID ;
|
||||
LuaGetParam( L, 6, ptNear) ;
|
||||
LuaCheckParam( L, 6, dAngTol)
|
||||
double dThickness ;
|
||||
LuaCheckParam( L, 7, dThickness)
|
||||
LuaClearStack( L) ;
|
||||
// Creo le curve di Edge grezze
|
||||
int nCount = 0 ;
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
bool bOk = ExeTrimmingGetBordersByNormals( nParentId, vIds, dLinTol, dAngTol, dThickness, ptNear, nCount, nFirstId) ;
|
||||
int nCount = 0 ;
|
||||
bool bOk = ExeTrimmingGetBordersByNormals( nParentId, vIds, dSurfLinTol, dSurfAngTol, dLinTol, dAngTol, dThickness, nFirstId, nCount) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
LuaSetParam( L, nFirstId) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
@@ -173,29 +165,31 @@ LuaTrimmingGetBordersByNormals( lua_State* L)
|
||||
static int
|
||||
LuaTrimmingGetFinalBorders( lua_State* L)
|
||||
{
|
||||
// 4 o 5 o 6 o 7 parametri : nParentId, vCrvBezierId, dLinTol, dAngTol [,vBreakingPts] [,dThick] [,dThickTol]
|
||||
// 4 o 5 o 6 o 7 parametri : nParentId, vCrvBezierId, dLinTol, dAngTol [,vBreakingPts] [,dThick [,dThickTol]]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId) ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
INTVECTOR vCrvBezierId ;
|
||||
LuaCheckParam( L, 2, vCrvBezierId) ;
|
||||
LuaCheckParam( L, 2, vCrvBezierId)
|
||||
double dLinTol ;
|
||||
LuaCheckParam( L, 3, dLinTol) ;
|
||||
LuaCheckParam( L, 3, dLinTol)
|
||||
double dAngTol ;
|
||||
LuaCheckParam( L, 4, dAngTol) ;
|
||||
LuaCheckParam( L, 4, dAngTol)
|
||||
PNTVECTOR vBreakingPts ;
|
||||
double dThick = 0., dThickTol = EPS_SMALL ;
|
||||
int nInd = 5 ;
|
||||
if ( LuaGetParam( L, nInd, vBreakingPts))
|
||||
++ nInd ;
|
||||
double dThick = 0., dThickTol = EPS_SMALL ;
|
||||
if ( LuaGetParam( L, nInd, dThick)) {
|
||||
if ( ! LuaGetParam( L, nInd + 1, dThickTol)) {
|
||||
LuaClearStack( L) ;
|
||||
LuaSetParam( L, false) ;
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
LuaClearStack( L) ;
|
||||
// Creo le curve Edges
|
||||
int nCount = 0 ;
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
int nCount = 0 ;
|
||||
bool bOk = ExeTrimmingGetFinalBorders( nParentId, vCrvBezierId, dLinTol, dAngTol, vBreakingPts, dThick, dThickTol,
|
||||
nFirstId, nCount) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
@@ -208,17 +202,17 @@ LuaTrimmingGetFinalBorders( lua_State* L)
|
||||
static int
|
||||
LuaTrimmingGetRuledBezier( lua_State* L)
|
||||
{
|
||||
// 5 o 6 parametri : nParentId, vIds, nEdge1Id, nEdge2Id, dLinTol [,vSyncPointsIds]
|
||||
// 5 o 6 parametri : nParentId, vIds, nEdge1Id, nEdge2Id, dLinTol [,vnLineId]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId) ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
INTVECTOR vIds ;
|
||||
LuaCheckParam( L, 2, vIds) ; // serve per orientare la superficie rigata ( Ids delle superfici)
|
||||
int nEdge1Id ;
|
||||
LuaCheckParam( L, 3, nEdge1Id) ;
|
||||
LuaCheckParam( L, 3, nEdge1Id)
|
||||
int nEdge2Id ;
|
||||
LuaCheckParam( L, 4, nEdge2Id) ;
|
||||
LuaCheckParam( L, 4, nEdge2Id)
|
||||
double dLinTol ;
|
||||
LuaCheckParam( L, 5, dLinTol) ;
|
||||
LuaCheckParam( L, 5, dLinTol)
|
||||
INTVECTOR vnLineId ;
|
||||
LuaGetParam( L, 6, vnLineId) ;
|
||||
LuaClearStack( L) ;
|
||||
@@ -230,48 +224,63 @@ LuaTrimmingGetRuledBezier( lua_State* L)
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTrimmingGetSurfBzSyncPoints( lua_State* L)
|
||||
LuaTrimmingInterpolateSyncLines( lua_State* L)
|
||||
{
|
||||
// 4 o 5 parametri : nParentId, nEdge0Id, nEdge1Id, dLinTol [,nMaxLines]
|
||||
// 7 parametri : nParentId, nFirstSyncId, nSecondSyncId, nBorder1Id, nBorder2Id, dEdgeLinTol, dEdgeAngTol
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId) ;
|
||||
int nEdge1Id ;
|
||||
LuaCheckParam( L, 2, nEdge1Id) ;
|
||||
int nEdge2Id ;
|
||||
LuaCheckParam( L, 3, nEdge2Id) ;
|
||||
double dLinTol ;
|
||||
LuaCheckParam( L, 4, dLinTol) ;
|
||||
// Inserisco i tratti lineari associati ai punti di sincronizzazione
|
||||
int nSync1Id ;
|
||||
LuaCheckParam( L, 2, nSync1Id) ;
|
||||
int nSync2Id ;
|
||||
LuaCheckParam( L, 3, nSync2Id) ;
|
||||
int nBorder1Id ;
|
||||
LuaCheckParam( L, 4, nBorder1Id) ;
|
||||
int nBorder2Id ;
|
||||
LuaCheckParam( L, 5, nBorder2Id) ;
|
||||
double dEdgeLinTol ;
|
||||
LuaCheckParam( L, 6, dEdgeLinTol) ;
|
||||
double dEdgeAngTol ;
|
||||
LuaCheckParam( L, 7, dEdgeAngTol) ;
|
||||
LuaClearStack( L) ;
|
||||
// Interpolo le curve di sincronizzazione
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
int nCount = 0 ;
|
||||
bool bOk = ExeTrimmingGetSurfBzSyncPoints( nParentId, nEdge1Id, nEdge2Id, dLinTol, nFirstId, nCount) ;
|
||||
bool bOk = ExeTrimmingInterpolateSyncLines( nParentId, nSync1Id, nSync2Id, nBorder1Id,
|
||||
nBorder2Id, dEdgeLinTol, dEdgeAngTol, nFirstId, nCount) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
LuaSetParam( L, nFirstId) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
return 3 ;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTrimmingSkimSyncPoints( lua_State* L)
|
||||
LuaTrimmingGetSurfBzSyncPoints( lua_State* L)
|
||||
{
|
||||
// 5 o 6 parametri : nEdge1Id, nEdge2Id, vnLineId, dLinTol, dAngTol [,nMaxInvLine]
|
||||
// 7 parametri : nParentId, nEdge1Id, nEdge2Id, dLinTol, dAngTol, nLinesNbr, bShowOnCorners
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nEdge1Id ;
|
||||
LuaCheckParam( L, 1, nEdge1Id) ;
|
||||
LuaCheckParam( L, 2, nEdge1Id)
|
||||
int nEdge2Id ;
|
||||
LuaCheckParam( L, 2, nEdge2Id) ;
|
||||
INTVECTOR vnLineId ;
|
||||
LuaCheckParam( L, 3, vnLineId) ;
|
||||
LuaCheckParam( L, 3, nEdge2Id)
|
||||
double dLinTol ;
|
||||
LuaCheckParam( L, 4, dLinTol) ;
|
||||
LuaCheckParam( L, 4, dLinTol)
|
||||
double dAngTol ;
|
||||
LuaCheckParam( L, 5, dAngTol) ;
|
||||
int nMaxInvLine = 4 ;
|
||||
LuaGetParam( L, 6, nMaxInvLine) ;
|
||||
// Nascondo/Visualizzo i tratti lineari di sincronizzazione
|
||||
bool bOk = ExeTrimmingSkimSyncPoints( nEdge1Id, nEdge2Id, vnLineId, dLinTol, dAngTol, nMaxInvLine) ;
|
||||
LuaCheckParam( L, 5, dAngTol)
|
||||
int nLineNbr ;
|
||||
LuaCheckParam( L, 6, nLineNbr)
|
||||
bool bShowOnCorners ;
|
||||
LuaCheckParam( L, 7, bShowOnCorners)
|
||||
LuaClearStack( L) ;
|
||||
// Inserisco i tratti lineari associati ai punti di sincronizzazione
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
int nCount = 0 ;
|
||||
bool bOk = ExeTrimmingGetSurfBzSyncPoints( nParentId, nEdge1Id, nEdge2Id, dLinTol, dAngTol, nLineNbr, bShowOnCorners, nFirstId, nCount) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
LuaSetParam( L, nFirstId) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
return 3 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
@@ -279,17 +288,19 @@ bool
|
||||
LuaInstallTrimming( LuaMgr& luaMgr)
|
||||
{
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
// ---
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingAutoSearch", LuaTrimmingAutoSearch) ;
|
||||
// ---
|
||||
// --- Ricerca Fori e Asole
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetHoleBorder", LuaTrimmingGetHoleBorder) ;
|
||||
// --- Ricerca Superifici
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetSurfTmFaceAdj", LuaTrimmingGetSurfTmFaceAdj) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetSurfTmFromStmFaces", LuaTrimmingGetSurfTmFromStmFaces) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetAdjSurf", LuaTrimmingGetAdjSurfs) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetAdjSurfs", LuaTrimmingGetAdjSurfs) ;
|
||||
// --- Estrazione dei Bordi
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetBorders", LuaTrimmingGetBorders) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetBordersByNormals", LuaTrimmingGetBordersByNormals) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetFinalBorders", LuaTrimmingGetFinalBorders) ;
|
||||
// --- Recupero Surf Bezier Ruled
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetRuledBezier", LuaTrimmingGetRuledBezier) ;
|
||||
// --- Recupero linee di sincronizzazione
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingInterpolateSyncLines", LuaTrimmingInterpolateSyncLines) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetSurfBzSyncPoints", LuaTrimmingGetSurfBzSyncPoints) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingSkimSyncPoints", LuaTrimmingSkimSyncPoints) ;
|
||||
return bOk ;
|
||||
}
|
||||
+9
-1
@@ -37,7 +37,15 @@
|
||||
#define IDC_CHECK6 1036
|
||||
#define IDC_CHECK7 1037
|
||||
#define IDC_CHECK8 1038
|
||||
#define IDC_PICTURE1 1041
|
||||
#define IDC_COLOR1 1041
|
||||
#define IDC_COLOR2 1042
|
||||
#define IDC_COLOR3 1043
|
||||
#define IDC_COLOR4 1044
|
||||
#define IDC_COLOR5 1045
|
||||
#define IDC_COLOR6 1046
|
||||
#define IDC_COLOR7 1047
|
||||
#define IDC_COLOR8 1048
|
||||
#define IDC_PICTURE1 1101
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user