Merge commit '9ca84312b4f6c0ca6820cfaabcfa5911b8bfd352' into ModelessDialog

This commit is contained in:
Riccardo Elitropi
2026-06-19 09:00:39 +02:00
17 changed files with 1298 additions and 439 deletions
+4
View File
@@ -28,6 +28,10 @@ const double ANG_TOL_MAX_DEG = 60 ;
// Curve originali di composite o curva originale di area danneggiata
const std::string CRV_ORIG = "ORIG" ;
// Per lati aperti di contorni per pocketing
const std::string PCK_KEY_OPEN = "OPEN" ;
const std::string PCK_KEY_OPEN2 = "OPEN2" ;
// Per FlatParts (Nesting)
const std::string NST_PARTREG_LAYER = "Region" ;
const std::string NST_PARTREG_ORIG_LAYER = "Region.orig" ;
+176
View File
@@ -20,6 +20,7 @@
#include "GeoTools.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EXeConst.h"
#include "/EgtDev/Include/EGkGeoCollection.h"
#include "/EgtDev/Include/EGkCurveLine.h"
#include "/EgtDev/Include/EGkLinePntTgCurve.h"
#include "/EgtDev/Include/EGkLinePntPerpCurve.h"
@@ -42,9 +43,11 @@
#include "/EgtDev/Include/EGkCurveByApprox.h"
#include "/EgtDev/Include/EGkCurveAux.h"
#include "/EgtDev/Include/EGkOffsetCurve.h"
#include "/EgtDev/Include/EGkOffsetCurve3d.h"
#include "/EgtDev/Include/EGkCurveLocal.h"
#include "/EgtDev/Include/EGkSurfTriMesh.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkProjectCurveSurf.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
@@ -2634,3 +2637,176 @@ CalcExtrusion( IGeomDB* pGeomDB, int nParentId, int nRefType)
vtExtr.LocToLoc( pGeomDB->GetGridFrame(), frEnt) ;
return vtExtr ;
}
//----------------------------------------------------------------------------
int
ExeOffsetCurveAdv( int nId, double dDist, int nType, int* pnCount, double dLinTol)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
// eseguo l'offset
OffsetCurve OffsCrv( dLinTol) ;
bool bOk = OffsCrv.Make( pCurve, dDist, nType) ;
// salvo le curve di offset
int nRefId = nId ;
int nCount = 0 ;
int nFirstId = GDB_ID_NULL ;
PtrOwner<ICurve> pOffs( OffsCrv.GetLongerCurve()) ;
while ( bOk && ! IsNull( pOffs)) {
// inserisco la curva nel DB geometrico
int nNewId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nRefId, GDB_AFTER, Release( pOffs)) ;
// copio gli attributi
pGeomDB->CopyAttributes( nId, nNewId) ;
// aggiorno contatori
if ( nNewId != GDB_ID_NULL)
++ nCount ;
if ( nFirstId == GDB_ID_NULL)
nFirstId = nNewId ;
// aggiorno Id di riferimento per inserimento
if ( nNewId != GDB_ID_NULL)
nRefId = nNewId ;
// passo alla successiva
pOffs.Set( OffsCrv.GetLongerCurve()) ;
}
if ( bOk)
ExeSetModified() ;
else
nCount = - 1 ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua ;
sLua = "EgtOffsetCurveAdv(" + ToString( nId) + "," +
ToString( dDist) + "," +
OffsTypeToString( nType) + ")" +
" -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
}
//----------------------------------------------------------------------------
int
ExeCurveGetFatCurve( int nId, int nDestGrpId, double dRad, bool bSquareEnds, bool bSquareMids, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCrv == nullptr)
return GDB_ID_NULL ;
// recupero il riferimento della curva
Frame3d frCrv ;
if ( ! pGeomDB->GetGlobFrame( nId, frCrv))
return GDB_ID_NULL ;
// recupero il riferimento di destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest))
return GDB_ID_NULL ;
// Calcolo la curva ingrossata
ICURVEPOVECTOR vCrv ;
CalcCurveFatCurve( *pCrv, vCrv, dRad, bSquareEnds, bSquareMids) ;
// inserisco i risultati nel DB geometrico
int nFirstId = GDB_ID_NULL ;
int nCount = 0 ;
for ( int i = 0 ; i < int( vCrv.size()) ; i++) {
vCrv[i]->LocToLoc( frCrv, frDest) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vCrv[i])) ;
if ( nId != GDB_ID_NULL) {
nCount ++ ;
if ( nFirstId == GDB_ID_NULL)
nFirstId = nId ;
}
}
ExeSetModified() ;
if ( IsCmdLog()) {
string sLua = "EgtCurveGetFatCurve(" + ToString( nId) + "," +
ToString( nDestGrpId) + ")" +
" FirstId=" + ToString( nFirstId) + " nCurveCount=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultati
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
}
//----------------------------------------------------------------------------
int
ExeOffsetCurve3d( int nId, int nSurfId, double dDist, int nType, int* pnCount, double dLinTol)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCurve == nullptr)
return GDB_ID_NULL ;
// recupero la superficie
const ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nSurfId)) ;
if ( pSurf == nullptr)
return GDB_ID_NULL ;
// proietto la curva sulla superficie in modo da ottenere tutte le normali della superficie lungo la curva proiettata
CISURFPVECTOR vpSurf ;
vpSurf.push_back( pSurf) ;
double dMaxSegLen = 2.5 ;
bool bSharpEdges = true ;
PNT5AXVECTOR vPt5ax ;
if ( ! ProjectCurveOnSurf( *pCurve, vpSurf, dLinTol, dMaxSegLen, bSharpEdges, vPt5ax))
return GDB_ID_NULL ;
PolyLine PL ;
VCT3DVECTOR vOffDir ;
for ( int i = 0 ; i < ssize( vPt5ax) ; ++i) {
PL.AddUPoint( i, vPt5ax[i].ptP) ;
vOffDir.push_back( vPt5ax[i].vtDir1) ;
}
// eseguo l'offset
OffsetCurve3d OffsCrv( dLinTol) ;
bool bOk = OffsCrv.Make( PL, vOffDir, dDist, nType) ;
// salvo le curve di offset
int nRefId = nId ;
int nCount = 0 ;
int nFirstId = GDB_ID_NULL ;
PtrOwner<ICurve> pOffs( OffsCrv.GetLongerCurve()) ;
while ( bOk && ! IsNull( pOffs)) {
// inserisco la curva nel DB geometrico
int nNewId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nRefId, GDB_AFTER, Release( pOffs)) ;
// copio gli attributi
pGeomDB->CopyAttributes( nId, nNewId) ;
// aggiorno contatori
if ( nNewId != GDB_ID_NULL)
++ nCount ;
if ( nFirstId == GDB_ID_NULL)
nFirstId = nNewId ;
// aggiorno Id di riferimento per inserimento
if ( nNewId != GDB_ID_NULL)
nRefId = nNewId ;
// passo alla successiva
pOffs.Set( OffsCrv.GetLongerCurve()) ;
}
if ( bOk)
ExeSetModified() ;
else
nCount = - 1 ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua ;
sLua = "EgtOffsetCurveAdv(" + ToString( nId) + "," +
ToString( dDist) + "," +
OffsTypeToString( nType) + ")" +
" -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
}
+186 -1
View File
@@ -22,12 +22,13 @@
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EXeConst.h"
#include "/EgtDev/Include/EGkGeoPoint3d.h"
#include "/EgtDev/Include/EGkGeoPoint3d.h"
#include "/EgtDev/Include/EGkCurve.h"
#include "/EgtDev/Include/EGkCurveLocal.h"
#include "/EgtDev/Include/EGkCurveArc.h"
#include "/EgtDev/Include/EGkCurveBezier.h"
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkCurveAux.h"
#include "/EgtDev/Include/EGkMedialAxis.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkIntersCurves.h"
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
@@ -923,4 +924,188 @@ ExeCopyParamRange( int nCrvId, double dUStart, double dUEnd, int nDestGrpId)
ExeSetModified() ;
return nSubCrvId ;
}
//----------------------------------------------------------------------------
int
ExeCurveMedialAxis( int nId)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
// eseguo il calcolo
PolyLine PL ;
if ( ! CurveSimpleMedialAxis( pCurve, PL))
return GDB_ID_NULL ;
// creo la curva
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
if ( IsNull( pCompo) || ! pCompo->FromPolyLine( PL))
return GDB_ID_NULL ;
// la inserisco nel DB geometrico
int nNewId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_AFTER, Release( pCompo)) ;
// copio gli attributi
pGeomDB->CopyAttributes( nId, nNewId) ;
// notifico la modifica
if ( nNewId != GDB_ID_NULL)
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua ;
sLua = "EgtCurveMedialAxis(" + ToString( nId) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
return nNewId ;
}
//----------------------------------------------------------------------------
int
ExeCurveGetVoronoi( const INTVECTOR& vIds, int nDestGrpId, int nBound, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
if ( vIds.empty())
return false ;
// recupero il riferimento della prima curva che sarà utilizzato da Voronoi
Frame3d frCrv ;
if ( ! pGeomDB->GetGlobFrame( vIds[0], frCrv))
return GDB_ID_NULL ;
// recupero il riferimento di destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest))
return GDB_ID_NULL ;
// Calcolo diagramma di Voronoi
ICURVEPOVECTOR vCrv ;
if ( int( vIds.size()) == 1) {
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( vIds[0])) ;
if ( pCrv == nullptr)
return GDB_ID_NULL ;
// calcolo
CalcCurveVoronoiDiagram( *pCrv, vCrv, nBound) ;
}
else {
// recupero le curve e le porto in locale al frame della prima curva
CICURVEPVECTOR vOrigCrvs ;
for ( int i = 0 ; i < int( vIds.size()) ; i ++) {
CurveLocal CrvLoc( pGeomDB, vIds[i], frCrv) ;
if ( CrvLoc.Get() == nullptr) {
for ( auto pCrv : vOrigCrvs)
delete( pCrv) ;
return GDB_ID_NULL ;
}
vOrigCrvs.emplace_back( CrvLoc->Clone()) ;
}
// calcolo
CalcCurvesVoronoiDiagram( vOrigCrvs, vCrv, nBound) ;
// libero la memoria
for ( auto pCrv : vOrigCrvs)
delete( pCrv) ;
}
// inserisco i risultati nel DB geometrico
int nFirstId = GDB_ID_NULL ;
int nCount = 0 ;
for ( int i = 0 ; i < int( vCrv.size()) ; i++) {
vCrv[i]->LocToLoc( frCrv, frDest) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vCrv[i])) ;
if ( nId != GDB_ID_NULL) {
nCount ++ ;
if ( nFirstId == GDB_ID_NULL)
nFirstId = nId ;
}
}
ExeSetModified() ;
if ( IsCmdLog()) {
string sLua = "EgtCurveGetVoronoi({" + ToString( vIds) + "}," +
ToString( nDestGrpId) + ")" +
" FirstId=" + ToString( nFirstId) + " nCurveCount=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultati
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
}
//----------------------------------------------------------------------------
int
ExeCurveGetMedialAxis( const INTVECTOR& vIds, int nDestGrpId, int nSide, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
if ( vIds.empty())
return false ;
// recupero il riferimento della prima curva che sarà utilizzato da Voronoi
Frame3d frCrv ;
if ( ! pGeomDB->GetGlobFrame( vIds[0], frCrv))
return GDB_ID_NULL ;
// recupero il riferimento di destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest))
return GDB_ID_NULL ;
// Calcolo il Medial Axis
ICURVEPOVECTOR vCrv ;
if ( int( vIds.size()) == 1) {
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( vIds[0])) ;
if ( pCrv == nullptr)
return GDB_ID_NULL ;
// calcolo
CalcCurveMedialAxis( *pCrv, vCrv, nSide) ;
}
else {
// recupero le curve e le porto in locale al frame della prima curva
CICURVEPVECTOR vOrigCrvs ;
for ( int i = 0 ; i < int( vIds.size()) ; i ++) {
CurveLocal CrvLoc( pGeomDB, vIds[i], frCrv) ;
if ( CrvLoc.Get() == nullptr) {
for ( auto pCrv : vOrigCrvs)
delete( pCrv) ;
return GDB_ID_NULL ;
}
vOrigCrvs.emplace_back( CrvLoc->Clone()) ;
}
// calcolo
CalcCurvesMedialAxis( vOrigCrvs, vCrv, nSide) ;
// libero la memoria
for ( auto pCrv : vOrigCrvs)
delete( pCrv) ;
}
// inserisco i risultati nel DB geometrico
int nFirstId = GDB_ID_NULL ;
int nCount = 0 ;
for ( int i = 0 ; i < int( vCrv.size()) ; i++) {
vCrv[i]->LocToLoc( frCrv, frDest) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vCrv[i])) ;
if ( nId != GDB_ID_NULL) {
nCount ++ ;
if ( nFirstId == GDB_ID_NULL)
nFirstId = nId ;
}
}
ExeSetModified() ;
if ( IsCmdLog()) {
string sLua = "EgtCurveMedialAxisAdv(" + ToString( vIds[0]) + "," +
ToString( nSide) + "," +
ToString( nDestGrpId) + ")" +
" FirstId=" + ToString( nFirstId) + " nCurveCount=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultati
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
}
+21 -4
View File
@@ -14,6 +14,7 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "EXE.h"
#include "EXE_Const.h"
#include "EXE_Macro.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EGkSfrCreate.h"
@@ -31,16 +32,32 @@ ExePocketing( int nId, double dRad, double dStep, double dAngle, int nType, bool
VERIFY_GEOMDB( pGeomDB, false) ;
// recupero la FlatRegion da svuotare
PtrOwner<ISurfFlatRegion> pMySfr ;
const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId)) ;
PtrOwner<ISurfFlatRegion> pMySfr ;
// altrimenti verifico se curva chiusa e piana
if ( pSfr == nullptr) {
// verifico se è una curva chiusa e piana che permette di definire una regione
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ;
Plane3d plPlane ;
if ( pCrv == nullptr || ! pCrv->IsFlat( plPlane, true, 10 * EPS_SMALL))
return false ;
// ne faccio una copia
PtrOwner<ICurveComposite> pCompo( ConvertCurveToComposite( pCrv->Clone())) ;
for ( int i = 0 ; i < pCompo->GetCurveCount() ; ++ i)
pCompo->SetCurveTempProp( i, 0) ;
// recupero eventuali info sui lati aperti
INTVECTOR vOpen ;
if ( pGeomDB->GetInfo( nId, PCK_KEY_OPEN, vOpen)) {
for ( int i : vOpen)
pCompo->SetCurveTempProp( i, 1) ;
}
else if ( pGeomDB->GetInfo( nId, PCK_KEY_OPEN2, vOpen)) {
for ( int i : vOpen)
pCompo->SetCurveTempProp( i, 2) ;
}
// creo la flat region
SurfFlatRegionByContours SfrCntr ;
SfrCntr.AddCurve( pCrv->Clone()) ;
SfrCntr.AddCurve( Release( pCompo)) ;
pMySfr.Set( SfrCntr.GetSurf()) ;
if ( IsNull( pMySfr))
return false ;
@@ -59,8 +76,8 @@ ExePocketing( int nId, double dRad, double dStep, double dAngle, int nType, bool
// 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, 0, INFINITO, 0, 0, INFINITO, false, 0., 0., vCrvCompoRes) ;
bool bOk = CalcPocketing( pSfr, dRad, 0, dStep, dAngle, 0, nType, bSmooth, true, false, false, true, false, false, true, P_INVALID, nullptr,
false, dStep, 0, INFINITO, 0, 0, INFINITO, false, 0., 0., false, vCrvCompoRes) ;
nFirstId = GDB_ID_NULL ;
nCrvCount = int( vCrvCompoRes.size()) ;
if ( bOk && nCrvCount > 0) {
+8 -294
View File
@@ -32,7 +32,6 @@
#include "/EgtDev/Include/EGkSurfLocal.h"
#include "/EgtDev/Include/EGkCurveAux.h"
#include "/EgtDev/Include/EGkOffsetCurve.h"
#include "/EgtDev/Include/EGkMedialAxis.h"
#include "/EgtDev/Include/EGkChainCurves.h"
#include "/EgtDev/Include/EGkProjectCurveSurf.h"
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
@@ -103,90 +102,6 @@ ExeOffsetCurve( int nId, double dDist, int nType)
return bOk ;
}
//----------------------------------------------------------------------------
int
ExeOffsetCurveAdv( int nId, double dDist, int nType, int* pnCount, double dLinTol)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
// eseguo l'offset
OffsetCurve OffsCrv( dLinTol) ;
bool bOk = OffsCrv.Make( pCurve, dDist, nType) ;
// salvo le curve di offset
int nRefId = nId ;
int nCount = 0 ;
int nFirstId = GDB_ID_NULL ;
PtrOwner<ICurve> pOffs( OffsCrv.GetLongerCurve()) ;
while ( bOk && ! IsNull( pOffs)) {
// inserisco la curva nel DB geometrico
int nNewId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nRefId, GDB_AFTER, Release( pOffs)) ;
// copio gli attributi
pGeomDB->CopyAttributes( nId, nNewId) ;
// aggiorno contatori
if ( nNewId != GDB_ID_NULL)
++ nCount ;
if ( nFirstId == GDB_ID_NULL)
nFirstId = nNewId ;
// aggiorno Id di riferimento per inserimento
if ( nNewId != GDB_ID_NULL)
nRefId = nNewId ;
// passo alla successiva
pOffs.Set( OffsCrv.GetLongerCurve()) ;
}
if ( bOk)
ExeSetModified() ;
else
nCount = - 1 ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua ;
sLua = "EgtOffsetCurveAdv(" + ToString( nId) + "," +
ToString( dDist) + "," +
OffsTypeToString( nType) + ")" +
" -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
}
//----------------------------------------------------------------------------
int
ExeCurveMedialAxis( int nId)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
// eseguo il calcolo
PolyLine PL ;
if ( ! CurveSimpleMedialAxis( pCurve, PL))
return GDB_ID_NULL ;
// creo la curva
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
if ( IsNull( pCompo) || ! pCompo->FromPolyLine( PL))
return GDB_ID_NULL ;
// la inserisco nel DB geometrico
int nNewId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_AFTER, Release( pCompo)) ;
// copio gli attributi
pGeomDB->CopyAttributes( nId, nNewId) ;
// notifico la modifica
if ( nNewId != GDB_ID_NULL)
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua ;
sLua = "EgtCurveMedialAxis(" + ToString( nId) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
return nNewId ;
}
//-------------------------------------------------------------------------------
bool
ExeApproxCurve( int nId, int nApprType, double dLinTol, double dMaxSegmLen)
@@ -2358,7 +2273,7 @@ ExeCurveCompoSetTempParam( int nId, int nCrv, double dParam, int nParamInd)
//-------------------------------------------------------------------------------
static bool
MyChainCurvesInGroup( int nGroupId, const Point3d& ptNear, bool bAllowInvert, int nRefType)
MyChainCurvesInGroup( int nGroupId, const Point3d& ptNear, bool bAllowInvert, int nRefType, double dToler)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
@@ -2368,7 +2283,6 @@ MyChainCurvesInGroup( int nGroupId, const Point3d& ptNear, bool bAllowInvert, in
if ( ! pGeomDB->GetGroupGlobFrame( nGroupId, frGrp))
return false ;
// preparo i dati per il concatenamento
double dToler = 10 * EPS_SMALL ;
ChainCurves chainC ;
chainC.Init( bAllowInvert, dToler, pGeomDB->GetGroupObjs( nGroupId)) ;
int nId = pGeomDB->GetFirstInGroup( nGroupId) ;
@@ -2412,9 +2326,9 @@ MyChainCurvesInGroup( int nGroupId, const Point3d& ptNear, bool bAllowInvert, in
//-------------------------------------------------------------------------------
bool
ExeChainCurvesInGroup( int nGroupId, const Point3d& ptNear, int nRefType)
ExeChainCurvesInGroup( int nGroupId, const Point3d& ptNear, int nRefType, double dToler)
{
bool bOk = MyChainCurvesInGroup( nGroupId, ptNear, true, nRefType) ;
bool bOk = MyChainCurvesInGroup( nGroupId, ptNear, true, nRefType, dToler) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
@@ -2429,9 +2343,9 @@ ExeChainCurvesInGroup( int nGroupId, const Point3d& ptNear, int nRefType)
//-------------------------------------------------------------------------------
bool
ExeReorderCurvesInGroup( int nGroupId, const Point3d& ptNear, int nRefType)
ExeReorderCurvesInGroup( int nGroupId, const Point3d& ptNear, int nRefType, double dToler)
{
bool bOk = MyChainCurvesInGroup( nGroupId, ptNear, false, nRefType) ;
bool bOk = MyChainCurvesInGroup( nGroupId, ptNear, false, nRefType, dToler) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
@@ -2463,8 +2377,9 @@ MyProjectCurveOnSurf( int nCurveId, const INTVECTOR& vnSurfId, int nDestGrpId,
return false ;
// recupero il riferimento della prima superficie
Frame3d frSurf ;
if ( ! pGeomDB->GetGlobFrame( vnSurfId[0], frSurf))
return false ;
//if ( ! pGeomDB->GetGlobFrame( vnSurfId[0], frSurf))
// return false ;
// recupero le superfici e le porto tutte in locale alla prima
SURFLOCALVECTOR vSurfL ; vSurfL.reserve( vnSurfId.size()) ;
CISURFPVECTOR vpSurf ; vpSurf.reserve( vnSurfId.size()) ;
@@ -2786,207 +2701,6 @@ ExeProjectCurveOnSurfExt( int nCurveId, const INTVECTOR& vnSurfId, int nGuideId,
return bOk ;
}
//----------------------------------------------------------------------------
int
ExeCurveGetVoronoi( const INTVECTOR& vIds, int nDestGrpId, int nBound, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
if ( vIds.empty())
return false ;
// recupero il riferimento della prima curva che sarà utilizzato da Voronoi
Frame3d frCrv ;
if ( ! pGeomDB->GetGlobFrame( vIds[0], frCrv))
return GDB_ID_NULL ;
// recupero il riferimento di destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest))
return GDB_ID_NULL ;
// Calcolo diagramma di Voronoi
ICURVEPOVECTOR vCrv ;
if ( int( vIds.size()) == 1) {
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( vIds[0])) ;
if ( pCrv == nullptr)
return GDB_ID_NULL ;
// calcolo
CalcCurveVoronoiDiagram( *pCrv, vCrv, nBound) ;
}
else {
// recupero le curve e le porto in locale al frame della prima curva
CICURVEPVECTOR vOrigCrvs ;
for ( int i = 0 ; i < int( vIds.size()) ; i ++) {
CurveLocal CrvLoc( pGeomDB, vIds[i], frCrv) ;
if ( CrvLoc.Get() == nullptr) {
for ( auto pCrv : vOrigCrvs)
delete( pCrv) ;
return GDB_ID_NULL ;
}
vOrigCrvs.emplace_back( CrvLoc->Clone()) ;
}
// calcolo
CalcCurvesVoronoiDiagram( vOrigCrvs, vCrv, nBound) ;
// libero la memoria
for ( auto pCrv : vOrigCrvs)
delete( pCrv) ;
}
// inserisco i risultati nel DB geometrico
int nFirstId = GDB_ID_NULL ;
int nCount = 0 ;
for ( int i = 0 ; i < int( vCrv.size()) ; i++) {
vCrv[i]->LocToLoc( frCrv, frDest) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vCrv[i])) ;
if ( nId != GDB_ID_NULL) {
nCount ++ ;
if ( nFirstId == GDB_ID_NULL)
nFirstId = nId ;
}
}
ExeSetModified() ;
if ( IsCmdLog()) {
string sLua = "EgtCurveGetVoronoi({" + ToString( vIds) + "}," +
ToString( nDestGrpId) + ")" +
" FirstId=" + ToString( nFirstId) + " nCurveCount=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultati
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
}
//----------------------------------------------------------------------------
int
ExeCurveGetMedialAxis( const INTVECTOR& vIds, int nDestGrpId, int nSide, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
if ( vIds.empty())
return false ;
// recupero il riferimento della prima curva che sarà utilizzato da Voronoi
Frame3d frCrv ;
if ( ! pGeomDB->GetGlobFrame( vIds[0], frCrv))
return GDB_ID_NULL ;
// recupero il riferimento di destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest))
return GDB_ID_NULL ;
// Calcolo il Medial Axis
ICURVEPOVECTOR vCrv ;
if ( int( vIds.size()) == 1) {
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( vIds[0])) ;
if ( pCrv == nullptr)
return GDB_ID_NULL ;
// calcolo
CalcCurveMedialAxis( *pCrv, vCrv, nSide) ;
}
else {
// recupero le curve e le porto in locale al frame della prima curva
CICURVEPVECTOR vOrigCrvs ;
for ( int i = 0 ; i < int( vIds.size()) ; i ++) {
CurveLocal CrvLoc( pGeomDB, vIds[i], frCrv) ;
if ( CrvLoc.Get() == nullptr) {
for ( auto pCrv : vOrigCrvs)
delete( pCrv) ;
return GDB_ID_NULL ;
}
vOrigCrvs.emplace_back( CrvLoc->Clone()) ;
}
// calcolo
CalcCurvesMedialAxis( vOrigCrvs, vCrv, nSide) ;
// libero la memoria
for ( auto pCrv : vOrigCrvs)
delete( pCrv) ;
}
// inserisco i risultati nel DB geometrico
int nFirstId = GDB_ID_NULL ;
int nCount = 0 ;
for ( int i = 0 ; i < int( vCrv.size()) ; i++) {
vCrv[i]->LocToLoc( frCrv, frDest) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vCrv[i])) ;
if ( nId != GDB_ID_NULL) {
nCount ++ ;
if ( nFirstId == GDB_ID_NULL)
nFirstId = nId ;
}
}
ExeSetModified() ;
if ( IsCmdLog()) {
string sLua = "EgtCurveMedialAxisAdv(" + ToString( vIds[0]) + "," +
ToString( nSide) + "," +
ToString( nDestGrpId) + ")" +
" FirstId=" + ToString( nFirstId) + " nCurveCount=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultati
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
}
//----------------------------------------------------------------------------
int
ExeCurveGetFatCurve( int nId, int nDestGrpId, double dRad, bool bSquareEnds, bool bSquareMids, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCrv == nullptr)
return GDB_ID_NULL ;
// recupero il riferimento della curva
Frame3d frCrv ;
if ( ! pGeomDB->GetGlobFrame( nId, frCrv))
return GDB_ID_NULL ;
// recupero il riferimento di destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest))
return GDB_ID_NULL ;
// Calcolo la curva ingrossata
ICURVEPOVECTOR vCrv ;
CalcCurveFatCurve( *pCrv, vCrv, dRad, bSquareEnds, bSquareMids) ;
// inserisco i risultati nel DB geometrico
int nFirstId = GDB_ID_NULL ;
int nCount = 0 ;
for ( int i = 0 ; i < int( vCrv.size()) ; i++) {
vCrv[i]->LocToLoc( frCrv, frDest) ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vCrv[i])) ;
if ( nId != GDB_ID_NULL) {
nCount ++ ;
if ( nFirstId == GDB_ID_NULL)
nFirstId = nId ;
}
}
ExeSetModified() ;
if ( IsCmdLog()) {
string sLua = "EgtCurveGetFatCurve(" + ToString( nId) + "," +
ToString( nDestGrpId) + ")" +
" FirstId=" + ToString( nFirstId) + " nCurveCount=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultati
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
}
//----------------------------------------------------------------------------
bool
ExeCurveBezierIncreaseDegree( int nCrvId)
+10
View File
@@ -842,6 +842,16 @@ ExeGetAllInfo( int nId, STRVECTOR& vsInfo)
return pGeomDB->GetAllInfo( nId, vsInfo) ;
}
//-----------------------------------------------------------------------------
bool
ExeCopyAllInfoFrom( int nId, int nSouId)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// copio tutte le info
return pGeomDB->CopyAllInfoFrom( nId, nSouId) ;
}
//-----------------------------------------------------------------------------
bool
ExeSetTextureName( int nId, const string& sTxrName)
+24 -3
View File
@@ -524,17 +524,38 @@ ExeAddRawPart( Point3d ptOrig, double dLength, double dWidth, double dHeight, Co
//-----------------------------------------------------------------------------
int
ExeAddRawPartWithPart( int nPartId, int nCrvId, double dOverMat, Color cCol)
ExeAddRawPartGen( int nCrvSrfId, double dOverMat, Color cCol)
{
IMachMgr* pMachMgr = GetCurrMachMgr() ;
VERIFY_MACHMGR( pMachMgr, GDB_ID_NULL)
// inserisco grezzo con pezzo nella macchinata corrente
int nId = pMachMgr->AddRawPartWithPart( nPartId, nCrvId, dOverMat, cCol) ;
int nId = pMachMgr->AddRawPart( nCrvSrfId, dOverMat, cCol) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtAddRawPartGen(" + ToString( nCrvSrfId) + "," +
ToString( dOverMat) + ",{" +
ToString( cCol) + "})" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco il risultato
return nId ;
}
//-----------------------------------------------------------------------------
int
ExeAddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color cCol)
{
IMachMgr* pMachMgr = GetCurrMachMgr() ;
VERIFY_MACHMGR( pMachMgr, GDB_ID_NULL)
// inserisco grezzo con pezzo nella macchinata corrente
int nId = pMachMgr->AddRawPartWithPart( nPartId, nCrvSrfId, dOverMat, cCol) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtAddRawPartWithPart(" + ToString( nPartId) + "," +
ToString( nCrvId) + "," +
ToString( nCrvSrfId) + "," +
ToString( dOverMat) + ",{" +
ToString( cCol) + "})" +
" -- Id=" + ToString( nId) ;
+566 -1
View File
@@ -16,6 +16,8 @@
#include "DllExchange.h"
#include "GeoTools.h"
#include "AuxTools.h"
#include "/EgtDev/Include/EGkGeoVector3d.h"
#include "/EgtDev/Include/EGkCurveAux.h"
#include "/EgtDev/Include/EgtNumUtils.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
@@ -24,9 +26,12 @@
#include "/EgtDev/Include/EGkTrimming.h"
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkDistPointSurfBz.h"
#include "/EgtDev/Include/EGkSbzFromCurves.h"
#include <unordered_map>
#include <algorithm>
using namespace std ;
// ---------------------------------------------------------------------------
@@ -867,11 +872,571 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl
return bOk ;
}
// ---------------------------------------------------------------------------
bool
ExeTrimmingGetToolOrientationLines( int nParentId, int nMainEdgeId, int nOtherEdgeId, bool bMainIsFirstBorder, int nSyncLayerId,
int nLineSId, int nLineEId, bool bShorterSide,
double dThetaStart, double dPhiStart, double dThetaEnd, double dPhiEnd, double dInterpLenS,
double dInterpLenE, double dLinTol,
int& nInterpStartId, int& nStartId, int& nEndId, int& nInterpEndId)
{
// Verifica database geometrico
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// Imposto i parametri di ritorno
nInterpStartId = GDB_ID_NULL, nStartId = GDB_ID_NULL, nEndId = GDB_ID_NULL, nInterpEndId = GDB_ID_NULL ;
// Se necessario aggiusto le tolleranze
double dMyLinTol = Clamp( dLinTol, EPS_SMALL, 1e5 * EPS_SMALL) ;
const double TOL = dMyLinTol ;
// Definisco costanti per interpolazione
const double INTERPOLATION_DIST = 2 ;
const double ISO_PAR_SAMPLE = 20.0 ;
// Recupero il riferimento del gruppo di destinazione
Frame3d frDest ;
bool bOk = ( pGeomDB->GetGlobFrame( nParentId, frDest)) ;
// Recupero le due Curve di bordo
const ICurve* pCrvMainEdge = GetCurve( pGeomDB->GetGeoObj( nMainEdgeId)) ;
const ICurve* pCrvOtherEdge = GetCurve( pGeomDB->GetGeoObj( nOtherEdgeId)) ;
bOk = bOk && ( pCrvMainEdge != nullptr && pCrvMainEdge->IsValid() && pCrvOtherEdge != nullptr && pCrvOtherEdge->IsValid()) ;
// Verifico che le curve siano entrambe Aperte o entrambe Chiuse e memorizzo il risultato
bOk = bOk && ( pCrvMainEdge->IsClosed() == pCrvOtherEdge->IsClosed()) ;
bool bBorderClosed = ( pCrvMainEdge->IsClosed()) ;
// Recupero le Linee di Sincronizzazione iniziali e finali e verifico che giacciano sulle Curve di Bordo
PtrOwner<ICurve> pCrvSyncS( GetCurve( pGeomDB->GetGeoObj( nLineSId))->Clone()) ;
PtrOwner<ICurve> pCrvSyncE( GetCurve( pGeomDB->GetGeoObj( nLineEId))->Clone()) ;
bOk = bOk && ( pCrvSyncS != nullptr && pCrvSyncS->IsValid() && pCrvSyncE != nullptr && pCrvSyncE->IsValid()) ;
BIPOINT Line1, Line2 ;
bOk = bOk && ( pCrvSyncS->GetStartPoint( Line1.first)) && ( pCrvSyncS->GetEndPoint( Line1.second)) ;
bOk = bOk && ( pCrvSyncE->GetStartPoint( Line2.first)) && ( pCrvSyncE->GetEndPoint( Line2.second)) ;
// --- se necessario oriento le linee di Sync in modo che inizino entrambe dal Bordo Main
if ( bOk) {
if ( pCrvMainEdge->IsPointOn( Line1.first, TOL))
bOk = ( pCrvOtherEdge->IsPointOn( Line1.second, TOL)) ;
else if ( pCrvOtherEdge->IsPointOn( Line1.first, TOL)) {
bOk = ( pCrvMainEdge->IsPointOn( Line1.second, TOL)) ;
if ( bOk) {
swap( Line1.first, Line1.second) ;
pCrvSyncS->Invert() ;
}
}
else
bOk = false ;
}
if ( bOk) {
if ( pCrvMainEdge->IsPointOn( Line2.first, TOL))
bOk = ( pCrvOtherEdge->IsPointOn( Line2.second, TOL)) ;
else if ( pCrvOtherEdge->IsPointOn( Line2.first, TOL)) {
bOk = ( pCrvMainEdge->IsPointOn( Line2.second, TOL)) ;
if ( bOk) {
swap( Line2.first, Line2.second) ;
pCrvSyncE->Invert() ;
}
}
else bOk = false ;
}
// Il percorso selezionato è il minore tra le due possibilità di percorrenza
if ( bOk && bBorderClosed) {
double dParS = 0. ;
PtrOwner<ICurveComposite> pCompoMainCL( ConvertCurveToComposite( pCrvMainEdge->Clone())) ;
bOk = ( ! IsNull( pCompoMainCL) && pCompoMainCL->IsValid() &&
pCompoMainCL->GetParamAtPoint( Line1.first, dParS, TOL)) ;
if ( bOk) {
pCompoMainCL->ChangeStartPoint( dParS) ;
double dLenE = 0., dLenMain = 0. ;
bOk = ( pCompoMainCL->GetLengthAtPoint( Line2.first, dLenE, TOL) &&
pCompoMainCL->GetLength( dLenMain)) ;
if ( dLenE > dLenMain / 2. + EPS_SMALL && bShorterSide) {
swap( Line1, Line2) ;
swap( pCrvSyncS, pCrvSyncE) ;
swap( dThetaStart, dThetaEnd) ;
swap( dPhiStart, dPhiEnd) ;
}
}
}
// Calcolo la lunghezza delle due curve di Bordo
double dLenMain = 0., dLenOther = 0. ;
bOk = bOk && ( pCrvMainEdge->GetLength( dLenMain) && pCrvOtherEdge->GetLength( dLenOther) &&
dLenMain > 2. * TOL + dInterpLenS + dInterpLenE + EPS_SMALL &&
dLenOther > 2. * TOL + dInterpLenS + dInterpLenE + EPS_SMALL) ;
// Recupero i punti di sincronizzazione (se presenti)
BIPNTVECTOR vSyncPoints ; vSyncPoints.reserve( pGeomDB->GetGroupObjs( nSyncLayerId)) ;
int nLineId = pGeomDB->GetFirstInGroup( nSyncLayerId) ;
while ( bOk && nLineId != GDB_ID_NULL) {
// Recupero la Curva
const ICurve* pLine = GetCurve( pGeomDB->GetGeoObj( nLineId)) ;
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 ( in un verso o nell'altro, mantengo il verso)
double dDistS1 = INFINITO ;
if ( ! DistPointCurve( ptStart, *pCrvMainEdge).GetDist( dDistS1)) {
nLineId = pGeomDB->GetNext( nLineId) ;
continue ;
}
if ( dDistS1 < dLinTol) {
double dDistE2 = INFINITO ;
if ( ! DistPointCurve( ptEnd, *pCrvOtherEdge).GetDist( dDistE2) || dDistE2 > dLinTol) {
nLineId = pGeomDB->GetNext( nLineId) ;
continue ;
}
}
else {
double dDistS2 = INFINITO ;
if ( ! DistPointCurve( ptStart, *pCrvOtherEdge).GetDist( dDistS2) || dDistS2 > dLinTol) {
nLineId = pGeomDB->GetNext( nLineId) ;
continue ;
}
double dDistE1 = INFINITO ;
if ( ! DistPointCurve( ptEnd, *pCrvMainEdge).GetDist( dDistE1) || dDistE1 > dLinTol) {
nLineId = pGeomDB->GetNext( nLineId) ;
continue ;
}
}
vSyncPoints.emplace_back( make_pair( ptStart, ptEnd)) ;
}
nLineId = pGeomDB->GetNext( nLineId) ;
}
// Recupero la superficie Bezier rigata
PtrOwner<ISurfBezier> pSurfBzRuled ;
if ( bOk) {
if ( bMainIsFirstBorder) {
// Se non ho linee di sincronizzazione
if ( vSyncPoints.empty())
pSurfBzRuled.Set( GetSurfBezierRuledSmooth( pCrvMainEdge, pCrvOtherEdge, vSyncPoints, ISO_PAR_SAMPLE)) ;
// Se ho linee di sincronizzazione
else
pSurfBzRuled.Set( GetSurfBezierRuledGuided( pCrvMainEdge, pCrvOtherEdge, vSyncPoints, dMyLinTol)) ;
}
else {
// Se non ho linee di sincronizzazione
if ( vSyncPoints.empty())
pSurfBzRuled.Set( GetSurfBezierRuledSmooth( pCrvOtherEdge, pCrvMainEdge, vSyncPoints, ISO_PAR_SAMPLE)) ;
// Se ho linee di sincronizzazione
else
pSurfBzRuled.Set( GetSurfBezierRuledGuided( pCrvOtherEdge, pCrvMainEdge, vSyncPoints, dMyLinTol)) ;
}
bOk = bOk && ( ! IsNull( pSurfBzRuled) && pSurfBzRuled->IsValid()) ;
}
// --- Calcolo delle Linee di Orientamento ---
if ( bOk) {
// Rotazione delle curve di Bordo rispetto al Bordo Main
double dLenS ; pCrvSyncS->GetLength( dLenS) ;
Line1.second = Line1.first + FromSpherical( dLenS, dThetaStart, dPhiStart) ;
double dLenE ; pCrvSyncE->GetLength( dLenE) ;
Line2.second = Line2.first + FromSpherical( dLenE, dThetaEnd, dPhiEnd) ;
// --- Eventuale Interpolazione Lineare di Raccordo all'Inizio ---
if ( dInterpLenS > TOL) {
double dExtension = dInterpLenS ;
double dLen = -1. ; pCrvMainEdge->GetLengthAtPoint( Line1.first, dLen, TOL) ;
if ( bBorderClosed) {
dLen -= dInterpLenS ;
if ( dLen < EPS_SMALL)
dLen = dLenMain + dLen ;
}
else {
if ( dLen < dInterpLenS - EPS_SMALL) {
dExtension = dLen ;
dLen = 0 ;
}
}
double dU = - 1;
bOk = pCrvMainEdge->GetParamAtLength( dLen, dU) ;
if ( bOk) {
// Definisco la linea si sincronizzazione
Point3d ptInterpS ; double dParU, dParV ;
PtrOwner<ICurveComposite> pCompoIso( nullptr) ;
BIPOINT LineInterpS ;
bOk = ( pCrvMainEdge->GetPointD1D2( dU, ICurve::FROM_MINUS, ptInterpS) &&
DistPointSurfBz( ptInterpS, *pSurfBzRuled).GetParamsAtMinDistPoint( dParU, dParV) &&
pCompoIso.Set( pSurfBzRuled->GetCurveOnV( dParU)) &&
pCompoIso->IsValid() &&
pCompoIso->GetStartPoint( LineInterpS.first) &&
pCompoIso->GetEndPoint( LineInterpS.second)) ;
if ( ! bMainIsFirstBorder)
swap( LineInterpS.first, LineInterpS.second) ;
if ( bOk) {
bool bFirst = true ;
// Interpolo
double dLenLineInterpS = Dist( LineInterpS.first, LineInterpS.second) ;
double dLenLine1 = Dist( Line1.first, Line1.second) ;
int nStep = max( 1, int( ceil( dExtension / INTERPOLATION_DIST))) ;
Vector3d vtInterpStart = ( LineInterpS.second - LineInterpS.first) ; vtInterpStart.Normalize() ;
Vector3d vtInterpEnd = ( Line1.second - Line1.first) ; vtInterpEnd.Normalize() ;
Vector3d vtDiff = vtInterpEnd - vtInterpStart ;
for ( int i = 0 ; bOk && i < ( nStep - 1) ; ++ i) { // ( nStep - 1) per evitare sovrapposizione con la Copia del vettore
double dI = double( i) ;
Vector3d vtInterp = vtInterpStart + ( dI / ( nStep - 1)) * vtDiff ;
double dUInterpMain = 0. ; Point3d ptInterpOnMain ;
double dCurrLen = dLen + ( dI * dExtension / ( nStep - 1)) ;
if ( dCurrLen > dLenMain)
dCurrLen -= dLenMain ;
bOk = ( pCrvMainEdge->GetParamAtLength( dCurrLen, dUInterpMain) &&
pCrvMainEdge->GetPointD1D2( dUInterpMain, ICurve::FROM_MINUS, ptInterpOnMain)) ;
if ( bOk) {
double dMagnitude = dLenLineInterpS + ( dI / ( nStep - 1)) * ( dLenLine1 - dLenLineInterpS) ;
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
bOk = ( ! IsNull( pLine) && pLine->Set( ptInterpOnMain, ptInterpOnMain + vtInterp * dMagnitude)) ;
if ( bOk) {
int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pLine)) ;
bOk = ( nNewId != GDB_ID_NULL) ;
if ( bOk) {
if ( bFirst) {
nInterpStartId = nNewId ;
bFirst = false ;
}
}
}
}
}
}
}
}
// --- Interpolazione tra le due Linee di Sincronizzazione ---
if ( bOk) {
double dLenS = -1., dLenE = -1 ;
bOk = ( pCrvMainEdge->GetLengthAtPoint( Line1.first, dLenS, TOL) &&
pCrvMainEdge->GetLengthAtPoint( Line2.first, dLenE, TOL)) ;
if ( bOk) {
double dToTDist = 0. ;
if ( dLenS < dLenE)
dToTDist = dLenE - dLenS ;
else
dToTDist = ( dLenMain - dLenS) + dLenE ;
if ( dToTDist > TOL) {
bool bFirst = true ;
// Interpolo
double dLenLine1 = Dist( Line1.first, Line1.second) ;
double dLenLine2 = Dist( Line2.first, Line2.second) ;
int nStep = max( 1, int( ceil( dToTDist / INTERPOLATION_DIST))) ;
Vector3d vtLineS = ( Line1.second - Line1.first) ; vtLineS.Normalize() ;
Vector3d vtLineE = ( Line2.second - Line2.first) ; vtLineE.Normalize() ;
Vector3d vtDiff = ( vtLineE - vtLineS) ;
for ( int i = 0 ; bOk && i <= nStep ; ++ i) {
double dI = double( i) ;
Vector3d vtInterp = vtLineS + ( dI / nStep) * vtDiff ;
double dUInterpMain = 0. ; Point3d ptInterpOnMain ;
double dCurrLen = dLenS + ( dI * dToTDist / nStep) ;
if ( dCurrLen > dLenMain)
dCurrLen -= dLenMain ;
bOk = ( pCrvMainEdge->GetParamAtLength( dCurrLen, dUInterpMain) &&
pCrvMainEdge->GetPointD1D2( dUInterpMain, ICurve::FROM_MINUS, ptInterpOnMain)) ;
if ( bOk) {
double dMagnitude = dLenLine1 + ( dI / nStep) * ( dLenLine2 - dLenLine1) ;
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
bOk = ( ! IsNull( pLine) && pLine->Set( ptInterpOnMain, ptInterpOnMain + vtInterp * dMagnitude)) ;
if ( bOk) {
int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pLine)) ;
bOk = ( nNewId != GDB_ID_NULL) ;
if ( bOk) {
if ( bFirst) {
nStartId = nNewId ;
bFirst = false ;
}
nEndId = nNewId ;
}
}
}
}
}
}
}
// --- Eventuale Interpolazione Lineare di Raccordo alla Fine ---
if ( bOk && dInterpLenE > TOL) {
double dExtension = dInterpLenE ;
double dLen = -1. ; pCrvMainEdge->GetLengthAtPoint( Line2.first, dLen, TOL) ;
if ( bBorderClosed) {
dLen += dInterpLenE ;
if ( dLen > dLenMain - EPS_SMALL)
dLen -= dLenMain ;
}
else {
if ( dLen > dLenMain - dInterpLenE - EPS_SMALL) {
dExtension = dLenMain - dLen ;
dLen = dLenMain ;
}
}
double dU = - 1 ;
bOk = pCrvMainEdge->GetParamAtLength( dLen, dU) ;
if ( bOk) {
// Definisco la linea si sincronizzazione
Point3d ptInterpE ; double dParU, dParV ;
PtrOwner<ICurveComposite> pCompoIso( nullptr) ;
BIPOINT LineInterpE ;
bOk = ( pCrvMainEdge->GetPointD1D2( dU, ICurve::FROM_MINUS, ptInterpE) &&
DistPointSurfBz( ptInterpE, *pSurfBzRuled).GetParamsAtMinDistPoint( dParU, dParV) &&
pCompoIso.Set( pSurfBzRuled->GetCurveOnV( dParU)) &&
pCompoIso->IsValid() &&
pCompoIso->GetStartPoint( LineInterpE.first) &&
pCompoIso->GetEndPoint( LineInterpE.second)) ;
if ( ! bMainIsFirstBorder)
swap( LineInterpE.first, LineInterpE.second) ;
if ( bOk) {
// Interpolo
double dLenLineInterpE = Dist( LineInterpE.first, LineInterpE.second) ;
double dLenLine2 = Dist( Line2.first, Line2.second) ;
int nStep = max( 1, int( ceil( dExtension / INTERPOLATION_DIST))) ;
Vector3d vtInterpStart = ( Line2.second - Line2.first) ; vtInterpStart.Normalize() ;
Vector3d vtInterpEnd = ( LineInterpE.second - LineInterpE.first) ; vtInterpEnd.Normalize() ;
Vector3d vtDiff = vtInterpEnd - vtInterpStart ;
for ( int i = 1 ; bOk && i < nStep ; ++ i) { // i = 1 per evitare la sopvrapposizione con la Copia del vettore
double dI = double( i) ;
Vector3d vtInterp = vtInterpStart + ( dI / ( nStep - 1)) * vtDiff ;
double dUInterpMain = 0. ; Point3d ptInterpOnMain ;
double dCurrLen = ( dLen - dExtension) + ( dI * dExtension / ( nStep - 1)) ;
if ( dCurrLen > dLenMain)
dCurrLen -= dLenMain ;
bOk = ( pCrvMainEdge->GetParamAtLength( dCurrLen, dUInterpMain) &&
pCrvMainEdge->GetPointD1D2( dUInterpMain, ICurve::FROM_MINUS, ptInterpOnMain)) ;
if ( bOk) {
double dMagnitude = dLenLine2 + ( dI / ( nStep - 1)) * ( dLenLineInterpE - dLenLine2) ;
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
bOk = ( ! IsNull( pLine) && pLine->Set( ptInterpOnMain, ptInterpOnMain + vtInterp * dMagnitude)) ;
if ( bOk) {
int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pLine)) ;
bOk = ( nNewId != GDB_ID_NULL) ;
if ( bOk)
nInterpEndId = nNewId ;
}
}
}
}
}
}
}
ExeSetModified() ;
// Se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtTrimmingGetToolOrientationLines(" + ToString( nParentId) + "," +
ToString( nMainEdgeId) + "," +
ToString( nOtherEdgeId) + "," +
ToString( nLineSId) + "," +
ToString( nLineEId) + "," +
ToString( dThetaStart) + "," +
ToString( dPhiStart) + "," +
ToString( dThetaEnd) + "," +
ToString( dPhiEnd) + "," +
ToString( dLinTol) + "," +
ToString( dInterpLenS) + "," +
ToString( dInterpLenE) + "," +
" -- bOk=" + ToString( bOk) +
" -- nInterpStartId=" + ToString( nInterpStartId) + ", nStartId=" + ToString( nStartId) +
", nEndId=" + ToString( nEndId) + ", nInterpEndId=" + ToString( nInterpEndId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
return bOk ;
}
// ---------------------------------------------------------------------------
struct TrimmingInterval {
double dLenStart ;
double dLenEnd ;
Vector3d vtStart ;
Vector3d vtEnd ;
TrimmingInterval()
: dLenStart( - EPS_SMALL), dLenEnd( - EPS_SMALL), vtStart( V_INVALID), vtEnd( V_INVALID) {} ;
TrimmingInterval( double dLenS, double dLenE, const Vector3d& vtS, const Vector3d& vtE)
: dLenStart( dLenS), dLenEnd( dLenE), vtStart( vtS), vtEnd( vtE) {} ;
} ;
typedef vector<TrimmingInterval> TRIMMINGINTERVALVECTOR ;
// ---------------------------------------------------------------------------
bool
GetTrimmingInterval( const IGeomDB* pGeomDB, const ICurveComposite* pCompo, const Frame3d& frCompo, int nIdS, int nIdE, bool bInvert, TrimmingInterval& TrimmingInt)
{
// Verifico validità dei parametri
VERIFY_GEOMDB( pGeomDB, false)
if ( pCompo == nullptr || ! pCompo->IsValid() || ! frCompo.IsValid())
return false ;
// Recupero le linee di Orienting
const ICurve* pGeoCrvS = GetCurve( pGeomDB->GetGeoObj( nIdS)) ;
const ICurve* pGeoCrvE = GetCurve( pGeomDB->GetGeoObj( nIdE)) ;
if ( pGeoCrvS != nullptr && pGeoCrvE != nullptr && pGeoCrvS->IsValid() && pGeoCrvE->IsValid()) {
// Recupero i punti base ches stanno sulla pCompo e i vettori direzioni ( sono ICurveLine*, ma le tratto come ICurve* generiche)
Point3d ptS = P_INVALID ;
Point3d ptE = P_INVALID ;
if ( ! bInvert) {
pGeoCrvS->GetStartPoint( ptS) ; // Line1.ptStart
pGeoCrvE->GetStartPoint( ptE) ; // Line2.ptStart
}
else {
pGeoCrvS->GetEndPoint( ptS) ;
pGeoCrvE->GetEndPoint( ptE) ;
}
Vector3d vtS = V_INVALID ; pGeoCrvS->GetStartDir( vtS) ; // Line1.vtStart
Vector3d vtE = V_INVALID ; pGeoCrvE->GetStartDir( vtE) ; // Line2.vtStart
if ( ptS.IsValid() && ptE.IsValid() && vtS.IsValid() && vtE.IsValid()) {
// Recupero il Frame delle Linee
Frame3d frCrv1, frCrv2 ;
if ( ! pGeomDB->GetGlobFrame( nIdS, frCrv1) || ! pGeomDB->GetGlobFrame( nIdE, frCrv2))
return false ;
// Porto Tali valori nel riferimento dalla Composita
Point3d ptSLoc = GetLocToLoc( ptS, frCrv1, frCompo) ;
Point3d ptELoc = GetLocToLoc( ptE, frCrv2, frCompo) ;
Vector3d vtSLoc = GetLocToLoc( vtS, frCrv1, frCompo) ;
Vector3d vtELoc = GetLocToLoc( vtE, frCrv2, frCompo) ;
// Recupero il parametro sulla curva
double dParS = - EPS_PARAM, dParE = - EPS_PARAM ;
int nFlag = 0 ;
if ( DistPointCurve( ptSLoc, *pCompo).GetParamAtMinDistPoint( EPS_SMALL, dParS, nFlag) &&
DistPointCurve( ptELoc, *pCompo).GetParamAtMinDistPoint( EPS_SMALL, dParE, nFlag)) {
// Recupero la lunghezza su tale curva
double dLenS = - EPS_SMALL, dLenE = - EPS_SMALL ;
if ( pCompo->GetLengthAtParam( dParS, dLenS) && pCompo->GetLengthAtParam( dParE, dLenE)) {
TrimmingInt = TrimmingInterval( dLenS, dLenE, vtSLoc, vtELoc) ;
return true ;
}
}
}
}
return false ;
}
// ---------------------------------------------------------------------------
bool
Exe5AxTrimmingModifyToolDir( int nCrvId, int nPathId, int nTrimLayId, const INTVECTOR& vnOrientingId, const INTVECTOR& vnOrientingISId,
const INTVECTOR& vnOrientingSId, const INTVECTOR& vnOrientingEId, const INTVECTOR& vnOrientingIEId)
{
// Verifica database geometrico
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// Verifico validità dei parametri
bool bOk = ( nCrvId != GDB_ID_NULL && nPathId != GDB_ID_NULL && nTrimLayId != GDB_ID_NULL &&
ssize( vnOrientingId) == ssize( vnOrientingISId) && ssize( vnOrientingISId) == ssize( vnOrientingSId) &&
ssize( vnOrientingSId) == ssize( vnOrientingEId) && ssize( vnOrientingEId) == ssize( vnOrientingIEId)) ;
// Recupero la curva di Bordo e la sua composit associata
const ICurve* pCrvBorder = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ;
bOk = bOk && ( pCrvBorder != nullptr && pCrvBorder->IsValid()) ;
PtrOwner<ICurveComposite> pCompoBorder( nullptr) ;
if ( bOk)
bOk = ( pCompoBorder.Set( ConvertCurveToComposite( pCrvBorder->Clone())) && pCompoBorder->IsValid()) ;
double dLen = - EPS_SMALL ;
if ( bOk)
bOk = pCompoBorder->GetLength( dLen) ;
// Recupero il Frame della curva corrente
Frame3d frCompo ;
bOk = bOk && ( pGeomDB->GetGlobFrame( nCrvId, frCompo)) ;
bool bInvert = false ;
if ( ssize( vnOrientingISId) > 0 && vnOrientingISId[0] != GDB_ID_NULL) {
const ICurve* pGeoCrvS = GetCurve( pGeomDB->GetGeoObj( vnOrientingISId[0])) ;
Point3d ptS ; pGeoCrvS->GetStartPoint( ptS) ;
double dDist = 1 ;
if ( DistPointCurve( ptS, *pCompoBorder).GetDist( dDist) && dDist > EPS_SMALL)
bInvert = true ;
}
// Recupero i versori di interpolazione e creo dei gruppi
TRIMMINGINTERVALVECTOR vInterval ; vInterval.reserve( 3 * ssize( vnOrientingId)) ;
for ( int i = 0 ; bOk && i < ssize( vnOrientingId) ; ++ i) {
// Se presente Interpolazione iniziale
if ( vnOrientingISId[i] != GDB_ID_NULL && vnOrientingSId[i] != GDB_ID_NULL) {
TrimmingInterval myTrimInt ;
if ( GetTrimmingInterval( pGeomDB, pCompoBorder, frCompo, vnOrientingISId[i], vnOrientingSId[i], bInvert, myTrimInt))
vInterval.emplace_back( myTrimInt) ;
}
// Interpolazione ( deve essere sempre presente, ma per scrupolo si controlla lo stesso)
if ( vnOrientingSId[i] != GDB_ID_NULL && vnOrientingEId[i] != GDB_ID_NULL) {
TrimmingInterval myTrimInt ;
if ( GetTrimmingInterval( pGeomDB, pCompoBorder, frCompo, vnOrientingSId[i], vnOrientingEId[i], bInvert, myTrimInt))
vInterval.emplace_back( myTrimInt) ;
}
// Se presente Interpolazione finale
if ( vnOrientingEId[i] != GDB_ID_NULL && vnOrientingIEId[i] != GDB_ID_NULL) {
TrimmingInterval myTrimInt ;
if ( GetTrimmingInterval( pGeomDB, pCompoBorder, frCompo, vnOrientingEId[i], vnOrientingIEId[i], bInvert, myTrimInt))
vInterval.emplace_back( myTrimInt) ;
}
}
// Se ho degli intervalli di Interpolazione
if ( ! vInterval.empty()) {
// Scorro i vettori presenti nel Layer ausiliario della lavorazione
int nId = pGeomDB->GetFirstInGroup( nPathId) ;
while ( bOk && nId != GDB_ID_NULL) {
IGeoVector3d* vGeo = GetGeoVector3d( pGeomDB->GetGeoObj( nId)) ;
if ( vGeo != nullptr && vGeo->IsValid()) {
// Recupero i parametri di tale vettore
Point3d ptBase = vGeo->GetBase() ;
Vector3d vtDirV = V_INVALID ; ;
if ( pGeomDB->GetInfo( nId, "DirV", vtDirV) && vtDirV.IsValid()) {
// Recupero la lunghezza associata al Punto di Base sulla Compo
double dCurrPar = - EPS_SMALL ;
int nFlag = 0 ;
if ( DistPointCurve( ptBase, *pCompoBorder).GetParamAtMinDistPoint( 0., dCurrPar, nFlag)) {
double dCurrLen = - EPS_SMALL ;
if ( pCompoBorder->GetLengthAtParam( dCurrPar, dCurrLen)) {
for ( const TrimmingInterval& CurrInterval : vInterval) {
// Controlli per Intervalli a cavallo dei punti iniziali e finali della curva
double dLenA = CurrInterval.dLenStart ;
double dLenB = CurrInterval.dLenEnd ;
double dLenC = dCurrLen ;
if ( dLenA > dLenB) {
dLenB += dLen ;
if ( dLenC < CurrInterval.dLenStart - EPS_SMALL)
dLenC += dLen ;
}
// Se l'intervallo non è troppo piccolo e se sono all'interno di tale Intervallo
if ( dLenB - dLenA > 10. * EPS_SMALL && /* bastava anche 2 * EPS_SMALL */
dLenA + EPS_SMALL < dLenC && dLenC < dLenB + EPS_SMALL /* estremi esclusi, va bene ? */) {
// Media pesata dei due vettori
double dMeanPar = ( dLenC - dLenA) / ( dLenB - dLenA) ;
Vector3d vtMean = Media( CurrInterval.vtStart, CurrInterval.vtEnd, dMeanPar) ;
// Assegno la Info a tale vettore
pGeomDB->SetInfo( nId, "DirV", vtMean) ;
break ; // non controllo altri intervalli
}
}
}
}
}
}
nId = pGeomDB->GetNext( nId) ;
}
}
ExeSetModified() ;
// Se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtTrimmingGetToolOrientationLines(" + ToString( nCrvId) + "," +
ToString( nPathId) + "," +
ToString( nTrimLayId) + "," +
ToString( vnOrientingId) + "," +
ToString( vnOrientingISId) + "," +
ToString( vnOrientingSId) + "," +
ToString( vnOrientingEId) + "," +
ToString( vnOrientingIEId) + "," +
" -- bOk=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
return bOk ;
}
// ---------------------------------------------------------------------------
int
ExeRegolarizeSurfaceLocally( int nParentId, int nSurfId, int nSyncStartId, int nSyncEndId, double dLinTol)
{
bool bOk = true ;
// Verifica database geometrico
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
BIN
View File
Binary file not shown.
+8
View File
@@ -38,6 +38,8 @@ AdjustId( int nId, int nCtx)
Vector3d
GetVectorLocal( IGeomDB* pGeomDB, const Vector3d& vtV, int nRefType, const Frame3d& frLoc)
{
if ( ! vtV.IsValid())
return vtV ;
Vector3d vtVL( vtV) ;
if ( nRefType == RTY_GLOB)
vtVL.ToLoc( frLoc) ;
@@ -50,6 +52,8 @@ GetVectorLocal( IGeomDB* pGeomDB, const Vector3d& vtV, int nRefType, const Frame
Vector3d
GetVectorInRef( IGeomDB* pGeomDB, const Vector3d& vtV, const Frame3d& frLoc, int nRefType)
{
if ( ! vtV.IsValid())
return vtV ;
Vector3d vtVL( vtV) ;
if ( nRefType == RTY_GLOB)
vtVL.ToGlob( frLoc) ;
@@ -62,6 +66,8 @@ GetVectorInRef( IGeomDB* pGeomDB, const Vector3d& vtV, const Frame3d& frLoc, int
Point3d
GetPointLocal( IGeomDB* pGeomDB, const Point3d& ptP, int nRefType, const Frame3d& frLoc)
{
if ( ! ptP.IsValid())
return ptP ;
Point3d ptPL( ptP) ;
if ( nRefType == RTY_GLOB)
ptPL.ToLoc( frLoc) ;
@@ -74,6 +80,8 @@ GetPointLocal( IGeomDB* pGeomDB, const Point3d& ptP, int nRefType, const Frame3d
Point3d
GetPointInRef( IGeomDB* pGeomDB, const Point3d& ptP, const Frame3d& frLoc, int nRefType)
{
if ( ! ptP.IsValid())
return ptP ;
Point3d ptPL( ptP) ;
if ( nRefType == RTY_GLOB)
ptPL.ToGlob( frLoc) ;
+90
View File
@@ -18,6 +18,7 @@
#include "/EgtDev/Include/EXeConst.h"
#include "/EgtDev/Include/EGkGdbConst.h"
#include "/EgtDev/Include/EGkLuaAux.h"
#include "/EgtDev/Include/EGkCurve.h"
using namespace std ;
@@ -1112,6 +1113,92 @@ LuaCreateCirclesAlongCurve( lua_State* L)
return 2 ;
}
//-------------------------------------------------------------------------------
static int
LuaOffsetCurveAdv( lua_State* L)
{
// 2 o 3 o 4 parametri : Id, dDist [, nType] [, dLinTol]
int nId ;
LuaCheckParam( L, 1, nId)
double dDist ;
LuaCheckParam( L, 2, dDist)
int nType = ICurve::OFF_FILLET ;
LuaGetParam( L, 3, nType) ;
double dLinTol = 10 * EPS_SMALL ;
LuaGetParam( L, 4, dLinTol) ;
LuaClearStack( L) ;
// offset della curva
int nCount ;
int nNewId = ExeOffsetCurveAdv( nId, dDist, nType, &nCount, dLinTol) ;
if ( nCount >= 0) {
LuaSetParam( L, nNewId) ;
LuaSetParam( L, nCount) ;
}
else {
LuaSetParam( L) ;
LuaSetParam( L, nCount) ;
}
return 2 ;
}
//----------------------------------------------------------------------------
static int
LuaCurveGetFatCurve( lua_State* L)
{
// 4 o 5 parametri : Id, nDestGrpId, dRad, bSquare [, bSquareMids]
int nId ;
LuaCheckParam( L, 1, nId)
int nDestGrpId ;
LuaCheckParam( L, 2, nDestGrpId)
double dRad ;
LuaCheckParam( L, 3, dRad)
bool bSquareEnds ;
LuaCheckParam( L, 4, bSquareEnds)
bool bSquareMids = bSquareEnds ;
LuaGetParam( L, 5, bSquareMids) ;
LuaClearStack( L) ;
// eseguo
int nCount = 0 ;
int nNewId = ExeCurveGetFatCurve( nId, nDestGrpId, dRad, bSquareEnds, bSquareMids, &nCount) ;
if ( nNewId != GDB_ID_NULL)
LuaSetParam( L, nNewId) ;
else
LuaSetParam( L) ;
LuaSetParam( L, nCount) ;
return 2 ;
}
//-------------------------------------------------------------------------------
static int
LuaOffsetCurve3d( lua_State* L)
{
// 3 o 4 o 5 parametri : Id, SurfId, dDist [, nType] [, dLinTol]
int nId ;
LuaCheckParam( L, 1, nId)
int nSurfId ;
LuaCheckParam( L, 2, nSurfId)
double dDist ;
LuaCheckParam( L, 3, dDist)
int nType = ICurve::OFF_FILLET ;
LuaGetParam( L, 4, nType) ;
double dLinTol = 10 * EPS_SMALL ;
LuaGetParam( L, 5, dLinTol) ;
LuaClearStack( L) ;
// offset della curva
int nCount ;
int nNewId = ExeOffsetCurve3d( nId, nSurfId, dDist, nType, &nCount, dLinTol) ;
if ( nCount >= 0) {
LuaSetParam( L, nNewId) ;
LuaSetParam( L, nCount) ;
}
else {
LuaSetParam( L) ;
LuaSetParam( L, nCount) ;
}
return 2 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallGdbCreateCurve( LuaMgr& luaMgr)
@@ -1157,5 +1244,8 @@ LuaInstallGdbCreateCurve( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtPolygonFromApothem", LuaCreatePolygonFromApothem) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtPolygonFromSide", LuaCreatePolygonFromSide) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCirclesAlongCurve", LuaCreateCirclesAlongCurve) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtOffsetCurveAdv", LuaOffsetCurveAdv) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveGetFatCurve", LuaCurveGetFatCurve) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtOffsetCurve3d", LuaOffsetCurve3d) ;
return bOk ;
}
+1 -1
View File
@@ -805,7 +805,7 @@ LuaCreateSurfTmSwept( lua_State* L)
int nGuideId ;
LuaCheckParam( L, 3, nGuideId)
int nPar = 4 ;
Vector3d vtAx = V_NULL ;
Vector3d vtAx = V_INVALID ;
if ( LuaGetParam( L, nPar, vtAx))
++ nPar ;
bool bCapEnds ;
+68
View File
@@ -673,6 +673,71 @@ LuaCopyParamRange( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCurveMedialAxis( lua_State* L)
{
// 1 parametro : Id
int nId ;
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// calcolo del Medial Axis della curva
int nNewId = ExeCurveMedialAxis( nId) ;
if ( nNewId != GDB_ID_NULL)
LuaSetParam( L, nNewId) ;
else
LuaSetParam( L) ;
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaCurveMedialAxisAdv( lua_State* L)
{
// 2 o 3 parametri : Id/s, nDestGrpId [, nSide]
INTVECTOR vIds ;
LuaCheckParam( L, 1, vIds)
int nDestGrpId ;
LuaCheckParam( L, 2, nDestGrpId)
int nSide = 1 ; // WMAT_LEFT
LuaGetParam( L, 3, nSide) ;
LuaClearStack( L) ;
// eseguo
int nCount = 0 ;
int nNewId = ExeCurveGetMedialAxis( vIds, nDestGrpId, nSide, &nCount) ;
if ( nNewId != GDB_ID_NULL)
LuaSetParam( L, nNewId) ;
else
LuaSetParam( L) ;
LuaSetParam( L, nCount) ;
return 2 ;
}
//----------------------------------------------------------------------------
static int
LuaCurveGetVoronoi( lua_State* L)
{
// 2 o 3 parametri : Id/s, nDestGrpId [, nBound]
INTVECTOR vIds ;
LuaCheckParam( L, 1, vIds)
int nDestGrpId ;
LuaCheckParam( L, 2, nDestGrpId)
int nBound = 3 ; // VORONOI_STD_BOUND
LuaGetParam( L, 3, nBound) ;
LuaClearStack( L) ;
// eseguo
int nCount = 0 ;
int nNewId = ExeCurveGetVoronoi( vIds, nDestGrpId, nBound, &nCount) ;
if ( nNewId != GDB_ID_NULL)
LuaSetParam( L, nNewId) ;
else
LuaSetParam( L) ;
LuaSetParam( L, nCount) ;
return 2 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallGdbGetCurve( LuaMgr& luaMgr)
@@ -711,5 +776,8 @@ LuaInstallGdbGetCurve( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtShowCurveBezierControlPoints", LuaShowCurveBezierControlPoints) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCopyCompoSubCurve", LuaCopyCompoSubCurve) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCopyParamRange", LuaCopyParamRange) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveMedialAxis", LuaCurveMedialAxis) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveGetVoronoi", LuaCurveGetVoronoi) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveMedialAxisAdv", LuaCurveMedialAxisAdv) ;
return bOk ;
}
+13 -135
View File
@@ -56,51 +56,6 @@ LuaOffsetCurve( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaOffsetCurveAdv( lua_State* L)
{
// 2 o 3 o 4 parametri : Id, dDist [, nType] [, dLinTol]
int nId ;
LuaCheckParam( L, 1, nId)
double dDist ;
LuaCheckParam( L, 2, dDist)
int nType = ICurve::OFF_FILLET ;
LuaGetParam( L, 3, nType) ;
double dLinTol = 10 * EPS_SMALL ;
LuaGetParam( L, 4, dLinTol) ;
LuaClearStack( L) ;
// offset della curva
int nCount ;
int nNewId = ExeOffsetCurveAdv( nId, dDist, nType, &nCount, dLinTol) ;
if ( nCount >= 0) {
LuaSetParam( L, nNewId) ;
LuaSetParam( L, nCount) ;
}
else {
LuaSetParam( L) ;
LuaSetParam( L, nCount) ;
}
return 2 ;
}
//-------------------------------------------------------------------------------
static int
LuaCurveMedialAxis( lua_State* L)
{
// 1 parametro : Id
int nId ;
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// calcolo del Medial Axis della curva
int nNewId = ExeCurveMedialAxis( nId) ;
if ( nNewId != GDB_ID_NULL)
LuaSetParam( L, nNewId) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaApproxCurve( lua_State* L)
@@ -409,7 +364,7 @@ LuaTrimExtendCurveByLen( lua_State* L)
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 4, nRefType) ;
LuaClearStack( L) ;
// taglio o allungo la curva nell'estremo più vicino al punto
// taglio o allungo la curva nell'estremo più vicino al punto
bool bOk = ExeTrimExtendCurveByLen( nId, dLen, ptNear, nRefType) ;
LuaSetParam( L, bOk) ;
return 1 ;
@@ -943,7 +898,7 @@ LuaCurveCompoSetTempProp( lua_State* L)
int nPropInd = 0 ;
LuaGetParam( L, 4, nPropInd) ;
LuaClearStack( L) ;
// imposto sulla curva della composita la proprietà temporanea
// imposto sulla curva della composita la proprietà temporanea
bool bOk = ExeCurveCompoSetTempProp( nId, nCrv, nProp, nPropInd) ;
LuaSetParam( L, bOk) ;
return 1 ;
@@ -973,16 +928,18 @@ LuaCurveCompoSetTempParam( lua_State* L)
static int
LuaChainCurvesInGroup( lua_State* L)
{
// 2 o 3 parametri : nGroupId, ptNear [, nRefType]
// 2, 3 o 4 parametri : nGroupId, ptNear [, nRefType] [, dToler]
int nGroupId ;
LuaCheckParam( L, 1, nGroupId)
Point3d ptNear ;
LuaCheckParam( L, 2, ptNear)
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 3, nRefType) ;
double dToler = 10 * EPS_SMALL ;
LuaGetParam( L, 4, dToler) ;
LuaClearStack( L) ;
// concateno le curve nel gruppo (senza fonderle in una curva composita)
bool bOk = ExeChainCurvesInGroup( nGroupId, ptNear, nRefType) ;
bool bOk = ExeChainCurvesInGroup( nGroupId, ptNear, nRefType, dToler) ;
LuaSetParam( L, bOk) ;
return 1 ;
}
@@ -991,16 +948,18 @@ LuaChainCurvesInGroup( lua_State* L)
static int
LuaReorderCurvesInGroup( lua_State* L)
{
// 2 o 3 parametri : nGroupId, ptNear [, nRefType]
// 2, 3 o 4 parametri : nGroupId, ptNear [, nRefType] [, dToler]
int nGroupId ;
LuaCheckParam( L, 1, nGroupId)
Point3d ptNear ;
LuaCheckParam( L, 2, ptNear)
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 3, nRefType) ;
double dToler = 10 * EPS_SMALL ;
LuaGetParam( L, 4, dToler) ;
LuaClearStack( L) ;
// riordino le curve nel gruppo (senza fonderle in una curva composita)
bool bOk = ExeReorderCurvesInGroup( nGroupId, ptNear, nRefType) ;
bool bOk = ExeReorderCurvesInGroup( nGroupId, ptNear, nRefType, dToler) ;
LuaSetParam( L, bOk) ;
return 1 ;
}
@@ -1021,7 +980,7 @@ LuaProjectCurveOnSurf( lua_State* L)
if ( LuaGetParam( L, 4, dLinTol))
LuaGetParam( L, 5, dMaxSegmLen) ;
LuaClearStack( L) ;
// proietto la curva su una o più superfici a minima distanza
// proietto la curva su una o più superfici a minima distanza
bool bOk = ExeProjectCurveOnSurf( nCurveId, vSurfId, nDestGrpId, dLinTol, dMaxSegmLen) ;
LuaSetParam( L, bOk) ;
return 1 ;
@@ -1051,7 +1010,7 @@ LuaProjectCurveOnSurfDir( lua_State* L)
LuaGetParam( L, 8, bFromVsTo))
LuaGetParam( L, 9, nRefType) ;
LuaClearStack( L) ;
// proietto la curva su una o più superfici secondo la direzione data
// proietto la curva su una o più superfici secondo la direzione data
bool bOk = ExeProjectCurveOnSurfDir( nCurveId, vSurfId, vtDir, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromProj, bFromVsTo, nRefType) ;
LuaSetParam( L, bOk) ;
return 1 ;
@@ -1079,88 +1038,12 @@ LuaProjectCurveOnSurfExt( lua_State* L)
LuaGetParam( L, 7, bDirFromGuide))
LuaGetParam( L, 8, bFromVsTo) ;
LuaClearStack( L) ;
// proietto la curva su una o più superfici secondo la direzione verso la guida
// proietto la curva su una o più superfici secondo la direzione verso la guida
bool bOk = ExeProjectCurveOnSurfExt( nCurveId, vSurfId, nGuideId, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromGuide, bFromVsTo) ;
LuaSetParam( L, bOk) ;
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaCurveGetVoronoi( lua_State* L)
{
// 2 o 3 parametri : Id/s, nDestGrpId [, nBound]
INTVECTOR vIds ;
LuaCheckParam( L, 1, vIds)
int nDestGrpId ;
LuaCheckParam( L, 2, nDestGrpId)
int nBound = 3 ; // VORONOI_STD_BOUND
LuaGetParam( L, 3, nBound) ;
LuaClearStack( L) ;
// eseguo
int nCount = 0 ;
int nNewId = ExeCurveGetVoronoi( vIds, nDestGrpId, nBound, &nCount) ;
if ( nNewId != GDB_ID_NULL)
LuaSetParam( L, nNewId) ;
else
LuaSetParam( L) ;
LuaSetParam( L, nCount) ;
return 2 ;
}
//----------------------------------------------------------------------------
static int
LuaCurveMedialAxisAdv( lua_State* L)
{
// 2 o 3 parametri : Id/s, nDestGrpId [, nSide]
INTVECTOR vIds ;
LuaCheckParam( L, 1, vIds)
int nDestGrpId ;
LuaCheckParam( L, 2, nDestGrpId)
int nSide = 1 ; // WMAT_LEFT
LuaGetParam( L, 3, nSide) ;
LuaClearStack( L) ;
// eseguo
int nCount = 0 ;
int nNewId = ExeCurveGetMedialAxis( vIds, nDestGrpId, nSide, &nCount) ;
if ( nNewId != GDB_ID_NULL)
LuaSetParam( L, nNewId) ;
else
LuaSetParam( L) ;
LuaSetParam( L, nCount) ;
return 2 ;
}
//----------------------------------------------------------------------------
static int
LuaCurveGetFatCurve( lua_State* L)
{
// 4 o 5 parametri : Id, nDestGrpId, dRad, bSquare [, bSquareMids]
int nId ;
LuaCheckParam( L, 1, nId)
int nDestGrpId ;
LuaCheckParam( L, 2, nDestGrpId)
double dRad ;
LuaCheckParam( L, 3, dRad)
bool bSquareEnds ;
LuaCheckParam( L, 4, bSquareEnds)
bool bSquareMids = bSquareEnds ;
LuaGetParam( L, 5, bSquareMids) ;
LuaClearStack( L) ;
// eseguo
int nCount = 0 ;
int nNewId = ExeCurveGetFatCurve( nId, nDestGrpId, dRad, bSquareEnds, bSquareMids, &nCount) ;
if ( nNewId != GDB_ID_NULL)
LuaSetParam( L, nNewId) ;
else
LuaSetParam( L) ;
LuaSetParam( L, nCount) ;
return 2 ;
}
//----------------------------------------------------------------------------
static int
LuaCurveBezierIncreaseDegree( lua_State* L)
@@ -1232,8 +1115,6 @@ LuaInstallGdbModifyCurve( LuaMgr& luaMgr)
bool bOk = ( &luaMgr != nullptr) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtInvertCurve", LuaInvertCurve) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtOffsetCurve", LuaOffsetCurve) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtOffsetCurveAdv", LuaOffsetCurveAdv) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveMedialAxis", LuaCurveMedialAxis) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtApproxCurve", LuaApproxCurve) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtProjectCurveOnPlane", LuaProjectCurveOnPlane) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtChangeClosedCurveStart", LuaChangeClosedCurveStart) ;
@@ -1286,9 +1167,6 @@ LuaInstallGdbModifyCurve( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtProjectCurveOnSurf", LuaProjectCurveOnSurf) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtProjectCurveOnSurfDir", LuaProjectCurveOnSurfDir) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtProjectCurveOnSurfExt", LuaProjectCurveOnSurfExt) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveGetVoronoi", LuaCurveGetVoronoi) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveMedialAxisAdv", LuaCurveMedialAxisAdv) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveGetFatCurve", LuaCurveGetFatCurve) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveBezierIncreaseDeg", LuaCurveBezierIncreaseDegree) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveBezierDecreaseDeg", LuaCurveBezierDecreaseDegree) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveBezierApproxToNonRat", LuaCurveBezierApproxToNonRat) ;
+18
View File
@@ -693,6 +693,23 @@ LuaGetAllInfo( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCopyAllInfoFrom( lua_State* L)
{
// 2 parametri : Id, SouId
int nId ;
LuaCheckParam( L, 1, nId)
int nSouId ;
LuaCheckParam( L, 2, nSouId)
LuaClearStack( L) ;
// copio tutte le info
bool bOk = ExeCopyAllInfoFrom( nId, nSouId) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSetTextureName( lua_State* L)
@@ -840,6 +857,7 @@ LuaInstallGdbObjAttribs( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtExistsInfo", LuaExistsInfo) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveInfo", LuaRemoveInfo) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetAllInfo", LuaGetAllInfo) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCopyAllInfoFrom", LuaCopyAllInfoFrom) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetTextureName", LuaSetTextureName) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetTextureFrame", LuaSetTextureFrame) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveTextureData", LuaRemoveTextureData) ;
+24
View File
@@ -504,6 +504,7 @@ LuaGetNextRawPart( lua_State* L)
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaAddRawPart( lua_State* L)
@@ -530,6 +531,28 @@ LuaAddRawPart( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaAddRawPartGen( lua_State* L)
{
// 3 parametri : nCrvSrfId, dOverMat, Color
int nCrvSrfId ;
LuaCheckParam( L, 1, nCrvSrfId)
double dOverMat ;
LuaCheckParam( L, 2, dOverMat)
Color cCol ;
LuaCheckParam( L, 3, cCol)
LuaClearStack( L) ;
// inserisco il grezzo nella macchinata corrente
int nInd = ExeAddRawPartGen( nCrvSrfId, dOverMat, cCol) ;
// restituisco il risultato
if ( nInd != GDB_ID_NULL)
LuaSetParam( L, nInd) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaAddRawPartWithPart( lua_State* L)
@@ -4584,6 +4607,7 @@ LuaInstallMachMgr( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtGetFirstRawPart", LuaGetFirstRawPart) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetNextRawPart", LuaGetNextRawPart) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtAddRawPart", LuaAddRawPart) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtAddRawPartGen", LuaAddRawPartGen) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtAddRawPartWithPart", LuaAddRawPartWithPart) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtModifyRawPart", LuaModifyRawPart) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtModifyRawPartSize", LuaModifyRawPartSize) ;
+81
View File
@@ -283,6 +283,84 @@ LuaTrimmingGetSurfBzSyncPoints( lua_State* L)
return 3 ;
}
//-------------------------------------------------------------------------------
static int
LuaTrimmingGetToolOrientationLines( lua_State* L)
{
// 15 parametri : nParentId, nMainEdgeId, nOtherEdgeId, bMainIsFirstBorder, nSyncLayerId, nLineSId, nLineEId, bShorterSide
// dThetaStart, dPhiStart, dThetaEnd, dPhiEnd, dInterpLenS, dInterpLenE, dLinTol
int nParentId ;
LuaCheckParam( L, 1, nParentId)
int nMainEdgeId ;
LuaCheckParam( L, 2, nMainEdgeId)
int nOtherEdgeId ;
LuaCheckParam( L, 3, nOtherEdgeId)
bool bMainIsFirstBorder ;
LuaCheckParam( L, 4, bMainIsFirstBorder)
int nLineSId ;
LuaCheckParam( L, 5, nLineSId)
int nLineEId ;
LuaCheckParam( L, 6, nLineEId)
bool bShorterSide ;
LuaCheckParam( L, 7, bShorterSide)
int nSyncLayerId ;
LuaCheckParam( L, 8, nSyncLayerId)
double dThetaStart ;
LuaCheckParam( L, 9, dThetaStart)
double dPhiStart ;
LuaCheckParam( L, 10, dPhiStart)
double dThetaEnd ;
LuaCheckParam( L, 11, dThetaEnd)
double dPhiEnd ;
LuaCheckParam( L, 12, dPhiEnd) ;
double dInterpLenS ;
LuaCheckParam( L, 13, dInterpLenS)
double dInterpLenE ;
LuaCheckParam( L, 14, dInterpLenE)
double dLinTol ;
LuaCheckParam( L, 15, dLinTol)
LuaClearStack( L) ;
// Inserisco i tratti lineari associati calcolati lungo il percorso
int nInterpStartId = GDB_ID_NULL, nStartId = GDB_ID_NULL, nEndId = GDB_ID_NULL, nInterpEndId = GDB_ID_NULL ;
bool bOk = ExeTrimmingGetToolOrientationLines( nParentId, nMainEdgeId, nOtherEdgeId, bMainIsFirstBorder, nSyncLayerId, nLineSId, nLineEId, bShorterSide,
dThetaStart, dPhiStart, dThetaEnd, dPhiEnd, dInterpLenS, dInterpLenE, dLinTol,
nInterpStartId, nStartId, nEndId, nInterpEndId) ;
LuaSetParam( L, bOk) ;
LuaSetParam( L, nInterpStartId) ;
LuaSetParam( L, nStartId) ;
LuaSetParam( L, nEndId) ;
LuaSetParam( L, nInterpEndId) ;
return 5 ;
}
//-------------------------------------------------------------------------------
static int
Lua5AxTrimmingModifyToolDir( lua_State* L)
{
// 8 parametri : nCrvId, nAuxId, nTrimLayId, vnOrientingId, vnOrientingISId, vnOrientingSId, vnOrientingEId, vnOrientingIEId
int nCrvId ;
LuaCheckParam( L, 1, nCrvId)
int nPathId ;
LuaCheckParam( L, 2, nPathId)
int nTrimLayId ;
LuaCheckParam( L, 3, nTrimLayId)
INTVECTOR vnOrientingId ;
LuaCheckParam( L, 4, vnOrientingId)
INTVECTOR vnOrientingISId ;
LuaCheckParam( L, 5, vnOrientingISId)
INTVECTOR vnOrientingSId ;
LuaCheckParam( L, 6, vnOrientingSId)
INTVECTOR vnOrientingEId ;
LuaCheckParam( L, 7, vnOrientingEId)
INTVECTOR vnOrientingIEId ;
LuaCheckParam( L, 8, vnOrientingIEId) ;
LuaClearStack( L) ;
// Modifico le Direzioni utensile
bool bOk = Exe5AxTrimmingModifyToolDir( nCrvId, nPathId, nTrimLayId, vnOrientingId, vnOrientingISId, vnOrientingSId, vnOrientingEId, vnOrientingIEId) ;
LuaSetParam( L, bOk) ;
return true ;
}
//-------------------------------------------------------------------------------
static int
LuaRegolarizeSurfaceLocally( lua_State* L)
@@ -322,6 +400,9 @@ LuaInstallTrimming( LuaMgr& luaMgr)
// --- Recupero linee di sincronizzazione
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingInterpolateSyncLines", LuaTrimmingInterpolateSyncLines) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetSurfBzSyncPoints", LuaTrimmingGetSurfBzSyncPoints) ;
// --- Recupero linee di Orientamento dell'Utensile e Modifica della lavorazione 5Ax
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetToolOrientationLines", LuaTrimmingGetToolOrientationLines) ;
bOk = bOk && luaMgr.RegisterFunction( "Egt5AxTrimmingModifyToolDir", Lua5AxTrimmingModifyToolDir) ;
// --- Modifica della superficie
bOk = bOk && luaMgr.RegisterFunction( "EgtRegolarizeSurfaceLocally", LuaRegolarizeSurfaceLocally) ;
return bOk ;