Compare commits

...

31 Commits

Author SHA1 Message Date
Riccardo Elitropi 7b90347b3f EgtExecutor (ModelessDialog) :
- Aggiunta gestione dialoghi non modali.
2026-06-23 12:28:54 +02:00
Dario Sassi 58093bda7f EgtExecutor 3.1f3 :
- ricompilazione con cambio versione.
2026-06-19 18:57:42 +02:00
Riccardo Elitropi e9439f04aa EgtExecutor (ModeLessDialog) :
- prima versione di dialogo non modale.
2026-06-19 10:45:31 +02:00
Riccardo Elitropi d569c7d8ee EgtExecutor (ModelessDialog) :
- aggiunti e aggiornati file persi durante merge.
2026-06-19 09:37:02 +02:00
Riccardo Elitropi 69e42f8e50 Merge commit '9ca84312b4f6c0ca6820cfaabcfa5911b8bfd352' into ModelessDialog 2026-06-19 09:00:39 +02:00
Riccardo Elitropi 9ca84312b4 EgtExecutor :
- Aggiunto parametro in CalcPocketing.
2026-06-19 08:56:08 +02:00
Dario Sassi a4a27a6d44 EgtExecutor :
- in ExePocketing aggiunta gestione lati OPEN (aperti) e OPEN2 (aperti da non oltrepassare).
2026-06-17 09:21:12 +02:00
Daniele Bariletti 58a86feccc EgtExecutor 3.1f2 :
- cambio versione.
2026-06-15 08:48:37 +02:00
Daniele Bariletti 20de52bf58 EgtExecutor :
- spostate le funzioni di offset.
- aggiunta la funzione di offset 3d delle curve.
2026-06-15 08:39:46 +02:00
Dario Sassi 62a8693ce5 EgtExecutor 3.1f1 :
- ricompilazione con cambio versione.
2026-06-08 18:37:24 +02:00
Daniele Bariletti 6015609ade Merge branch '5AxTrimming' 2026-05-26 11:28:04 +02:00
Daniele Bariletti 60e7f9040a EgtExecutor :
- aggiunto check per la scelta del lato a cui appliare l'interpolazione delle direzioni di lavorazione
- corretta gestione delle direzioni rispetto al bordo scelto per l'operazione di interpolazione.
2026-05-22 10:44:43 +02:00
Daniele Bariletti a2c8797930 EgtExecutor :
- gestito l'ordine delle curve di bordo nella TrimmingGetToolOrientationLines.
2026-05-19 17:31:07 +02:00
Daniele Bariletti efe2bba18b Merge branch 'master' into 5AxTrimming 2026-05-19 16:40:59 +02:00
Daniele Bariletti 411abdc66d EgtExecutor 3.1e3 :
- aggiunta funzione per la copia delle info da un oggetto ad un altro.
- cambio versione.
2026-05-19 16:40:46 +02:00
Daniele Bariletti 56973037ab EgtExecutor :
- piccole correzioni e migliorie a trimming.
2026-05-19 15:35:25 +02:00
Daniele Bariletti edb45ce149 EgtExecutor :
- piccola correzione.
2026-05-18 17:12:14 +02:00
Riccardo Elitropi 063b0f5cc4 EgtExecutor (5AxTrimming) :
- prima versione per Linee di Direzione Utensile.
2026-05-15 18:03:54 +02:00
Dario Sassi 2da612140e EgtExecutor :
- aggiunte funzioni exe/lua AddRawPartGen (per definire un nuovo grezzo a partire da una curva con spessore o da una superficie).
2026-05-15 11:43:08 +02:00
Riccardo Elitropi 5d6f9c5d1d EgtExecutor :
- in ExePocketing aggiunto flag per CalcPocketing per ToolCompensation (Default=false).
2026-05-14 15:31:35 +02:00
Dario Sassi 83ee155b8a EgtExecutor :
- modifiche a EgtSurfTmSwept per avere RMF anche con curve piane e garantendo la retrocompatibilità.
2026-05-14 13:04:07 +02:00
SaraP 3ff02fe0fe EgtExecutor :
- nelle funzioni exe e lua ChainCurvesInGroup e ReorderCurvesInGroup aggiunta tolleranza come parametro opzionale.
2026-05-12 15:09:11 +02:00
Dario Sassi 52cb174832 EgtExecutor 3.1e2 :
- ricompilazione con cambio versione.
2026-05-12 09:48:45 +02:00
Riccardo Elitropi d3a6f99ba5 EgtExecutor :
- in CalcPocketing aggiunto flag per Conventional Milling ( default=true) per ExePocketing.
2026-05-11 10:07:37 +02:00
Riccardo Elitropi 5d5a8bd01e Merge commit 'e31fcee3386361d8265e138accf2b6bf49858643' into ModelessDialog 2026-05-08 08:44:13 +02:00
Riccardo Elitropi 292361139a EgtExecutor (ModelessDialog) :
- primo commit.
2026-05-08 08:40:01 +02:00
Dario Sassi e31fcee338 EgtExecutor 3.1e1 :
- ricompilazione con cambio versione.
2026-05-07 12:23:40 +02:00
Daniele Bariletti 4746474864 EgtExecutor :
- aggiunto argomento alla RegolarizeSurfaceLocally.
2026-05-07 11:29:44 +02:00
Daniele Bariletti 7cefd64b2a EgtExecutor :
- modificata funzione per la regolarize.
2026-04-22 16:42:46 +02:00
Daniele Bariletti 8a51d5e3a5 Merge branch 'Trimming' 2026-04-21 15:09:38 +02:00
Dario Sassi 00e6d24f2e EgtExecutor 3.1d3 :
- piccoli aggiustamenti.
2026-04-19 10:55:49 +02:00
24 changed files with 1952 additions and 567 deletions
+91
View File
@@ -0,0 +1,91 @@
//----------------------------------------------------------------------------
// EgalTech 2026-2026
//----------------------------------------------------------------------------
// File : AuxDialogBox.cpp Data : 24.04.26 Versione : 3.1d4
// Contenuto : Funzioni DialogBox.
//
//
// Modifiche : 24.04.26 RE Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "EXE.h"
#include "EXE_Macro.h"
#include "AuxDialogBox.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EgtStringConverter.h"
using namespace std ;
#pragma comment( lib, "Comctl32.lib") // per funzioni LRESULT CALLBACK
HWND phDlgModeless = nullptr ;
int nDlgModelessItem = -1 ;
//-----------------------------------------------------------------------------
bool
UpdateIdsModelessDialog( HWND phDlgModeless, int nDlgModelessItem)
{
// se DialogBox Modeless non inizializzato, esco
if ( phDlgModeless == nullptr)
return false ;
// se Id del controllo da aggiornare non valido, esco
if ( nDlgModelessItem == -1)
return false ;
// recupero tutti gli elementi selezionati
string sIds ;
int nId = ExeGetFirstSelectedObj() ;
while ( nId != GDB_ID_NULL) {
sIds.append( ToString( nId) + string{","}) ;
nId = ExeGetNextSelectedObj() ;
}
if ( ! sIds.empty())
sIds.pop_back() ;
// aggiorno il contenuto nel dialogo
return ( SetDlgItemText( phDlgModeless, nDlgModelessItem, stringtoW( sIds))) ;
}
//-----------------------------------------------------------------------------
LRESULT
CALLBACK UpdateSelectionModelessDialog( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
if ( msg == WM_GETDLGCODE)
return DLGC_WANTALLKEYS ;
if ( msg == WM_KEYDOWN && wParam == VK_RETURN) {
// dwRefData contiene l'ID dell'EDIT
int nEditId = int( dwRefData) ;
HWND hwndDlg = GetParent(hwnd) ;
if ( hwndDlg == nullptr)
return FALSE ;
// recupero il testo dell'EDIT corretto
string sIds ;
AtoWEX<128> wsEdit( "") ;
if ( GetDlgItemText( hwndDlg, nEditId, LPWSTR( wsEdit), 128) > 0)
sIds = wstrztoA( wsEdit) ;
// deseleziono tutto
ExeDeselectAll() ;
// seleziono gli ID contenuti
if ( ! sIds.empty()) {
STRVECTOR vsIds;
Tokenize( sIds, ",", vsIds) ;
for ( const string& s : vsIds) {
int nId = GDB_ID_NULL ;
if ( FromString( s, nId) && nId != GDB_ID_NULL)
ExeSelectObj( nId) ;
}
}
// aggiorno la grafica ed esco
ExeDraw() ;
return TRUE ;
}
return ( DefSubclassProc( hwnd, msg, wParam, lParam)) ;
}
+31
View File
@@ -0,0 +1,31 @@
//----------------------------------------------------------------------------
// EgalTech 2026-2026
//----------------------------------------------------------------------------
// File : AuxDialogBox.h Data : 24.04.2026 Versione : 3.1d4
// Contenuto : Prototipi funzioni DialogBox.
//
//
//
// Modifiche : 22.04.26 RE Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "stdafx.h"
#include "resource.h"
#include "/EgtDev/Include/ExeExecutor.h"
#include "/EgtDev/Include/EGkLuaAux.h"
#include <shlobj.h>
//----------------------------------------------------------------------------
// Identificativo della finestra ModeLess corrente ( nullptr se non esiste)
extern HWND phDlgModeless ;
extern int nDlgModelessItem ;
// Funzione per passaggi di parametri tra Selezione DB e dialogo non modale
bool UpdateIdsModelessDialog( HWND phDlgModeless, int UpdateIdsModelessDialog) ;
//Funzione per selezionare gli Id presenti all'interno dei un EditText
LRESULT CALLBACK UpdateSelectionModelessDialog( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) ;
+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)
+16
View File
@@ -15,6 +15,7 @@
#include "stdafx.h"
#include "EXE.h"
#include "EXE_Macro.h"
#include "AuxDialogBox.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EgtStringConverter.h"
@@ -76,6 +77,9 @@ ExeSelectObj( int nId)
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// verifico se presente un dialogo modeless per aggiornare i valori
if ( bOk && phDlgModeless != nullptr && nDlgModelessItem != -1)
UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ;
// restituisco risultato
return bOk ;
}
@@ -100,6 +104,9 @@ ExeDeselectObj( int nId)
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// verifico se presente un dialogo modeless per aggiornare i valori
if ( bOk && phDlgModeless != nullptr && nDlgModelessItem != -1)
UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ;
// restituisco risultato
return bOk ;
}
@@ -160,6 +167,9 @@ ExeDeselectAll( void)
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// verifico se presente un dialogo modeless per aggiornare i valori
if ( bOk && phDlgModeless != nullptr && nDlgModelessItem != -1)
UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ;
// restituisco risultato
return bOk ;
}
@@ -186,6 +196,9 @@ ExeSelectGroupObjs( int nGroupId)
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// verifico se presente un dialogo modeless per aggiornare i valori
if ( bOk && phDlgModeless != nullptr && nDlgModelessItem != -1)
UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ;
// restituisco risultato
return bOk ;
}
@@ -209,6 +222,9 @@ ExeDeselectGroupObjs( int nGroupId)
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// verifico se presente un dialogo modeless per aggiornare i valori
if ( bOk && phDlgModeless != nullptr && nDlgModelessItem != -1)
UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ;
// restituisco risultato
return bOk ;
}
+29 -8
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) ;
@@ -3142,12 +3163,12 @@ ExeGetClEntAxesVal( int nEntId, DBLVECTOR& vAxes)
//-----------------------------------------------------------------------------
bool
ExeGetClEntTDir( int nEntId, Vector3d& vTDir)
ExeGetClEntTDir( int nEntId, Vector3d& vtTDir)
{
IMachMgr* pMachMgr = GetCurrMachMgr() ;
VERIFY_MACHMGR( pMachMgr, false) ;
// recupero vTDir
return pMachMgr->GetClEntTDir( nEntId, vTDir) ;
// recupero TDir
return pMachMgr->GetClEntTDir( nEntId, vtTDir) ;
}
//-----------------------------------------------------------------------------
@@ -3162,12 +3183,12 @@ ExeGetClEntCDir( int nEntId, Vector3d& vtCDir)
//-----------------------------------------------------------------------------
bool
ExeGetClEntADir( int nEntId, Vector3d& vADir)
ExeGetClEntADir( int nEntId, Vector3d& vtADir)
{
IMachMgr* pMachMgr = GetCurrMachMgr() ;
VERIFY_MACHMGR( pMachMgr, false) ;
// recupero ADir
return pMachMgr->GetClEntADir( nEntId, vADir) ;
return pMachMgr->GetClEntADir( nEntId, vtADir) ;
}
//-----------------------------------------------------------------------------
+573 -5
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 ;
// ---------------------------------------------------------------------------
@@ -869,9 +874,569 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl
// ---------------------------------------------------------------------------
bool
ExeRegolarizeSurfaceLocally( int nSurfId, int nSyncStartId, int nSyncEndId, double dLinTol)
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, int nType)
{
bool bOk = true ;
// Verifica database geometrico
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
@@ -888,8 +1453,11 @@ ExeRegolarizeSurfaceLocally( int nSurfId, int nSyncStartId, int nSyncEndId, doub
Point3d ptS2 ; pSyncEnd->GetStartPoint( ptS2) ;
Point3d ptE2 ; pSyncEnd->GetEndPoint( ptE2) ;
BIPOINT bpIsoEnd( ptS2, ptE2) ;
PtrOwner<ISurfBezier> pNewSurf( RegolarizeBordersLocally( pSurfBez, bpIsoStart, bpIsoEnd, dLinTol, nType)) ;
if ( IsNull( pNewSurf))
return GDB_ID_NULL ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pNewSurf)) ;
bOk = RegolarizeBordersLocally( pSurfBez, bpIsoStart, bpIsoEnd, 0.2) ;
return bOk ;
return nId ;
}
BIN
View File
Binary file not shown.
+2
View File
@@ -228,6 +228,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="..\Include\EXeConst.h" />
<ClInclude Include="..\Include\EXeDllMain.h" />
<ClInclude Include="..\Include\EXeExecutor.h" />
<ClInclude Include="AuxDialogBox.h" />
<ClInclude Include="DllExch3dm.h" />
<ClInclude Include="DllMain.h" />
<ClInclude Include="DllNesting.h" />
@@ -249,6 +250,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="stdafx.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="AuxDialogBox.cpp" />
<ClCompile Include="DllExch3dm.cpp" />
<ClCompile Include="DllNesting.cpp" />
<ClCompile Include="EXE_Base64.cpp" />
+6
View File
@@ -111,6 +111,9 @@
<ClInclude Include="DllExch3dm.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="AuxDialogBox.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="LUA_Exchange.cpp">
@@ -431,6 +434,9 @@
<ClCompile Include="LUA_Base64.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
<ClCompile Include="AuxDialogBox.cpp">
<Filter>File di origine\Global</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="EgtExecutor.rc">
+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) ;
+455 -96
View File
@@ -1,4 +1,4 @@
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : LUA_General.cpp Data : 27.09.14 Versione : 1.5i5
@@ -18,6 +18,7 @@
#include "LUA.h"
#include "GenTools.h"
#include "resource.h"
#include "AuxDialogBox.h"
#include "/EgtDev/Include/ExeExecutor.h"
#include "/EgtDev/Include/EGkLuaAux.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
@@ -118,7 +119,7 @@ LuaGetKeyPressed( lua_State* L)
int nKeyCode ;
LuaCheckParam( L, 1, nKeyCode)
LuaClearStack( L) ;
// se abilitata UI, controllo se il tasto indicato è premuto
// se abilitata UI, controllo se il tasto indicato è premuto
bool bPressed = false ;
if ( ExeGetEnableUI()) {
bPressed = (( GetAsyncKeyState( nKeyCode) & 0x8000) != 0) ;
@@ -181,7 +182,7 @@ LuaSplitString( lua_State* L)
LuaClearStack( L) ;
// se ricevuta stringa, la divido in parti separate da sSep
if ( bFound) {
// eseguo separazione (se tra i separatori c'è spazio ora tokenize collassa eventuali spazi consecutivi in uno solo)
// eseguo separazione (se tra i separatori c'è spazio ora tokenize collassa eventuali spazi consecutivi in uno solo)
STRVECTOR vsVal ;
Tokenize( sVal, sSep, vsVal) ;
// ritorno il risultato
@@ -516,7 +517,7 @@ LuaOutLog( lua_State* L)
LuaClearStack( L) ;
// accodo il messaggio nel file di log
ExeOutLog( sOut, nDbgLev) ;
// non c'è risultato
// non c'è risultato
return 0 ;
}
@@ -1178,7 +1179,7 @@ LuaCloseExe( lua_State* L)
// eseguo chiusura forzata
if ( ExeOnTerminateProcess( nExitCode))
TerminateProcess( GetCurrentProcess(), abs( nExitCode)) ;
// restituisco il risultato (se arrivo qui vuol dire che non è consnetito terminare l'esecuzione)
// restituisco il risultato (se arrivo qui vuol dire che non è consnetito terminare l'esecuzione)
LuaSetParam( L, false) ;
return 1 ;
}
@@ -1212,22 +1213,154 @@ LuaReleaseMutex( lua_State* L)
}
//-------------------------------------------------------------------------------
const int MAX_CTRLS = IDC_TEXT8 -IDC_TEXT1 + 1 ;
// =================================== DIALOG ===================================
// Variabili Globali
const int OFFS_CTRLS = 40 ;
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] ;
enum TYPE_CTRLS { CTRL_NONE = 0, CTRL_CHECK = 1, CTRL_COMBO = 2, CTRL_EDIT = 3, CTRL_COLOR = 4, CTRL_BUTTON = 5} ;
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" ;
// Dialogo Modeless
const int MAX_CTRLS = IDC_TEXT8 - IDC_TEXT1 + 1 ;
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] ;
struct DialogContext {
bool bDone = false ; // flag per chiusura dialogo (X/Ok/Cancel)
bool bCancelled = false ; // true se X/Cancel
bool bSelecting = false ; // true quando un BS + in modalità selezione
int nLastBS = -1 ; // indice dell'ultimo BS premuto
STRVECTOR vsResult ; // valori finali da ritornare a Lua
} ;
static string s_sIdSel_ML ;
static bool s_bSelectionMode = false ; // se true allora diventa dialogo "Modeless"
static int s_nActiveRow = - 1 ; // indice della riga di "BS:" attiva
//-------------------------------------------------------------------------------
// OnClosingDialog
//
// Scopo:
// Gestisce la chiusura del dialogo modeless in modo centralizzato e sicuro.
// Questa funzione viene chiamata quando lutente chiude il dialogo tramite:
// - OK
// - Cancel
// - pulsante X
// - WM_CLOSE
//
// Comportamento:
// - Riabilita la finestra principale (Main Window), che era stata disabilitata durante il funzionamento
// modale del dialogo.
//
// - Distrugge la finestra del dialogo.
//
// - Riporta il focus alla finestra principale, garantendo continuità nellinterazione dellutente.
//
// - Deseleziona tutti gli oggetti nella scena e aggiorna la vista, in modo che nessuna selezione residua
// rimanga attiva dopo la chiusura.
//-------------------------------------------------------------------------------
static void
OnClosingDialog( HWND hwndDlg) {
// reset stato globale
s_bSelectionMode = false ;
s_nActiveRow = -1 ;
nDlgModelessItem = -1 ;
// il controllo passa al Main
HWND hMain = GetParent( hwndDlg) ;
EnableWindow( hMain, TRUE) ;
DestroyWindow( hwndDlg) ;
phDlgModeless = nullptr ;
SetFocus( hMain) ;
// deseleziono tutto
ExeDeselectAll() ;
ExeDraw() ;
}
//-------------------------------------------------------------------------------
// StartSelectionMode
//
// Scopo:
// Attiva la modalità di selezione (modeless) del dialogo. Questa modalità permette allutente di interagire
// con la scena mentre il dialogo rimane aperto e attivo.
//
// Parametri:
// hDlg → handle del dialogo
// nEditId → ID delledit associato al pulsante BS premuto
// nActiveRow → indice della riga BS attiva (0..MAX_CTRLS-1)
//-------------------------------------------------------------------------------
static void
StartSelectionMode( HWND hDlg, int nEditId, int nActiveRow)
{
// il dialogo torna modeless rispetto alla scena
HWND hMain = GetParent( hDlg) ;
EnableWindow( hMain, TRUE) ;
// resta comunque in primo piano
SetWindowPos( hDlg, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) ;
// disabilito tutti gli edit associati ai BS tranne che quello attivo
for ( int i = 0; i < s_nCtrls ; ++ i) {
if (s_sEdit[i].find( "BS:") == 0) {
int idEdit = IDC_EDIT1 + i ;
EnableWindow( GetDlgItem( hDlg, idEdit), ( i == nActiveRow ? TRUE : FALSE)) ;
}
}
// seleziono solo gli elementi presenti nell'edit corrispondente
nDlgModelessItem = - 1 ; // !<-- Temporaneo [***]
ExeDeselectAll() ; // !<-- NB. avendo messo nDlgModelessItem = -1 il testo non viene rimosso
s_bSelectionMode = true ;
s_nActiveRow = nActiveRow ;
nDlgModelessItem = nEditId ; // !<-- Aggiorno [***]
AtoWEX<128> wsEdit( "") ;
GetDlgItemText( hDlg, nEditId, LPWSTR( wsEdit), 128) ;
string sIds = wstrztoA( wsEdit) ;
STRVECTOR vsIds ;
Tokenize( sIds, ",", vsIds) ;
for ( const string& sId : vsIds) {
int nId = GDB_ID_NULL ;
if ( FromString( sId, nId) && nId != GDB_ID_NULL)
ExeSelectObj( nId) ;
}
ExeDraw() ;
}
//-------------------------------------------------------------------------------
// EndSelectionMode
//
// Scopo:
// Termina la modalità di selezione e riporta il dialogo in stato modale.
//-------------------------------------------------------------------------------
static void
EndSelectionMode( HWND hDlg)
{
s_bSelectionMode = false ;
s_nActiveRow = -1 ;
nDlgModelessItem = -1 ;
// disabilito tutti gli edit associati ai BS
for ( int i = 0; i < s_nCtrls ; ++ i) {
if ( s_sEdit[i].find( "BS:") == 0) {
int idEdit = IDC_EDIT1 + i ;
EnableWindow( GetDlgItem( hDlg, idEdit), FALSE) ;
SetDlgItemText( hDlg, IDC_BUTTON_SEL1 + i, stringtoW( string{ "-"})) ;
}
}
// il dialogo torna modale
HWND hMain = GetParent( hDlg) ;
EnableWindow( hMain, FALSE) ;
SetFocus( hDlg) ;
// deseleziono tutto
ExeDeselectAll() ; //!<-- NB. avendo messo nDlgModelessItem = -1 il testo non viene rimosso
ExeDraw() ;
}
//-------------------------------------------------------------------------------
BOOL
CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
CALLBACK DialogBoxModelessProc( 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
@@ -1236,6 +1369,14 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam
switch ( message) {
case WM_INITDIALOG :
{
// imposto il dialogo come modale
HWND hMain = GetParent( hwndDlg) ;
EnableWindow( hMain, FALSE) ;
SetFocus( hwndDlg) ;
// imposto il contesto della funzione per recuperalo in futuro (per la funzione di CallBack Lua)
SetWindowLongPtr( hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam) ;
// colore di default
COLORREF defaultColor = RGB( 255, 0, 0) ;
// inizializzazione colori e brush
@@ -1259,60 +1400,61 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam
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,
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) ;
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) ;
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) ;
SetWindowPos( hwndCl, hwndDlg, ptCl.x, ptLR.y + OFFS_CTRLS, 0, 0, SWP_NOSIZE | SWP_NOZORDER) ;
// stile finestra
LONG style = GetWindowLong( hwndDlg, GWL_STYLE) ;
style |= WS_SYSMENU ;
SetWindowLong( hwndDlg, GWL_STYLE, style) ;
}
// 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) {
// imposto il testo nella riga corrente
SetDlgItemText( hwndDlg, IDC_TEXT1 + i, stringtoW( s_sText[i])) ;
// --- se CheckBox
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) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ; // nascondo Edit
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ; // nascondo Combo
ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_SEL1 + i), SW_HIDE) ; // nascondo Button di selezione
s_nType[i] = CTRL_CHECK ;
}
// --- se ComboBox
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) {
for ( int j = 0 ; j < ssize( vsVal) ; ++ j) {
string sItem ;
if ( vsVal[j][0] == '*') {
nSel = j ;
@@ -1323,10 +1465,19 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam
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) ;
int nEditHeight = int( SendMessage( hwndCBox, CB_GETITEMHEIGHT, (WPARAM)-1, 0)) ;
int nItemHeight = int( SendMessage( hwndCBox, CB_GETITEMHEIGHT, 0, 0)) ;
int nTotalHeight = nEditHeight + nItemHeight * ( ssize( vsVal) + 1) ;
RECT rc ; GetWindowRect( hwndCBox, &rc) ;
HWND parent = GetParent(hwndCBox) ; MapWindowPoints( NULL, parent, (LPPOINT)&rc, 2) ;
SetWindowPos( hwndCBox, NULL, rc.left, rc.top, rc.right - rc.left, nTotalHeight, SWP_NOZORDER) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ; // nascondo Edit
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ; // nascondo CheckBox
ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_SEL1 + i), SW_HIDE) ; // nascondo Button di selezione
s_nType[i] = CTRL_COMBO ;
}
// --- se ColorPicker
else if ( s_sEdit[i].find( "CP:") == 0) {
string sVal = s_sEdit[i].substr( 3) ;
Color CColor ;
@@ -1355,28 +1506,28 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam
}
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) ;
// nascondo qualsiasi tipo di componente
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ; // nascondo Edit
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ; // nascondo Combo
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ; // nascondo Check
ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_SEL1 + i), SW_HIDE) ; // nascondo Button di selezione
// 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)
// creazione della static preview
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)) {
HWND hwndEdit = GetDlgItem( hwndDlg, IDC_EDIT1 + i) ;
RECT rcEdit ; GetClientRect( hwndDlg, &rcEdit) ; // coordinate client del dialog
if ( hwndEdit != nullptr && GetWindowRect( hwndEdit, &rcEdit)) {
// 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 ;
POINT ptEdit = { rcEdit.left, rcEdit.top } ;
ScreenToClient( hwndDlg, &ptEdit) ;
int x = ptEdit.x ;
int y = ptEdit.y ;
int width = rcEdit.right - rcEdit.left ;
if ( width < PREVIEW_MIN_WIDTH)
width = PREVIEW_MIN_WIDTH ;
hwndPreview = CreateWindowEx( 0, L"STATIC", NULL,
@@ -1394,22 +1545,42 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam
}
s_nType[i] = CTRL_COLOR ;
}
// --- se Button di selezione
else if ( s_sEdit[i].find( "BS:") == 0) {
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ; // nascondo la Combo
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ; // nascondo la Check
SetDlgItemText( hwndDlg, IDC_BUTTON_SEL1 + i, stringtoW( string{ "-"})) ; // modalità non Selezione
EnableWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), FALSE) ; // disattivo la Edit
// associo alla casella di testo la funzione di KeyPress su Enter
HWND hEdit = GetDlgItem( hwndDlg, IDC_EDIT1 + i) ;
if ( hEdit != nullptr)
SetWindowSubclass( hEdit, UpdateSelectionModelessDialog, 1, (DWORD_PTR)( IDC_EDIT1 + i)) ;
s_nType[i] = CTRL_BUTTON ;
}
// --- se Testo
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) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ; // nascondo Combo
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ; // nascondo Check
ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_SEL1 + i), SW_HIDE) ; // nascondo Button di selezione
s_nType[i] = CTRL_EDIT ;
}
}
// se numero di controllo superiore al massimo, non visualizzo nullo ( in questo caso aggiungere elementi a Dialog in .rc)
else {
// nascondo tutto
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) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_SEL1 + i), SW_HIDE) ;
s_nType[i] = CTRL_NONE ;
}
}
break ;
case WM_CTLCOLORSTATIC :
{
HDC hdcStatic = ( HDC)wParam ;
@@ -1425,11 +1596,58 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam
}
}
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) {
// --- se click di un Button di selezione
if ( id >= IDC_BUTTON_SEL1 && id < IDC_BUTTON_SEL1 + MAX_CTRLS) {
int nBtnId = id ;
int nEditId = IDC_EDIT1 + ( id - IDC_BUTTON_SEL1) ;
int nActiveRow = nEditId - IDC_EDIT1 ;
// se il bottone premuto è lo stesso
if ( nDlgModelessItem == nEditId) {
// se selezione attiva, allora deve terminare
if ( s_bSelectionMode) {
SetDlgItemText( hwndDlg, nBtnId, stringtoW( string{ "-"})) ;
EndSelectionMode( hwndDlg) ;
}
// se selezione non attiva, allora viene attivata
else {
SetDlgItemText( hwndDlg, nBtnId, stringtoW( string{ "S"})) ;
StartSelectionMode( hwndDlg, nEditId, nActiveRow) ;
}
}
// se nuovo buttone premuto
else {
// se esisteva una selezione precedente, questa viene annullata
if ( nDlgModelessItem != -1) {
// recupero il Button di selezione precedente e modifico il suo testo
int nPrevBtnId = IDC_BUTTON_SEL1 + ( nDlgModelessItem - IDC_EDIT1) ;
SetDlgItemText( hwndDlg, nPrevBtnId, stringtoW( string{ "-"})) ;
}
// la selezione passa al comando corrente
nDlgModelessItem = nEditId ;
SetDlgItemText( hwndDlg, nBtnId, stringtoW( string{ "S"})) ;
// il dialogo diventa "Modeless" temporaneamente
s_nActiveRow = nEditId - IDC_EDIT1 ;
StartSelectionMode( hwndDlg, nEditId, nActiveRow) ;
}
return TRUE ; // !<-- esco
}
// --- se comando di Preview per brush di colori mediante click del mouse
else if ( code == STN_CLICKED && id >= IDC_COLOR1 && id <= IDC_COLOR8) {
// se selezione attiva, allora deve terminare
if ( s_bSelectionMode) {
// se esisteva una selezione precedente, questa viene annullata
if ( nDlgModelessItem != -1) {
// recupero il Button di selezione precedente e modifico il suo testo
int nPrevBtnId = IDC_BUTTON_SEL1 + ( nDlgModelessItem - IDC_EDIT1) ;
SetDlgItemText( hwndDlg, nPrevBtnId, stringtoW( string{ "-"})) ;
}
EndSelectionMode( hwndDlg) ;
}
int idx = id - IDC_COLOR1 ;
HWND hwndPreview = GetDlgItem( hwndDlg, IDC_COLOR1 + idx) ;
if ( ! hwndPreview)
@@ -1458,38 +1676,62 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam
InvalidateRect(hwndPreview, NULL, TRUE) ;
UpdateWindow( hwndPreview) ;
}
return TRUE ;
return TRUE ; // !<-- Esco
}
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 ;
case IDOK : {
// recupero il contesto impostato alla creazione della finestra (durante esecuzione WM_INITDIALOG)
DialogContext* ctx = (DialogContext*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA) ;
if ( ctx != nullptr) {
// inizializzo i risultati
ctx->vsResult.clear() ;
ctx->vsResult.reserve( s_nCtrls) ;
// recupero i valori degli Item
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 ;
case CTRL_BUTTON :
if ( GetDlgItemText( hwndDlg, IDC_EDIT1 + i, LPWSTR( wsEdit), 128) > 0)
s_sEdit[i] = wstrztoA( wsEdit) ;
break ;
}
// inserisco i valori all'interno della tabella Lua
ctx->vsResult.push_back( s_sEdit[i]) ;
}
ctx->bCancelled = false ;
ctx->bDone = true ;
}
[[fallthrough]] ;
// chiudo il dialogo
OnClosingDialog( hwndDlg) ;
return TRUE ;
}
[[fallthrough]] ;
case IDCANCEL : {
// pulizia brush colori
for ( int i = 0 ; i < MAX_CTRLS ; ++ i) {
@@ -1498,16 +1740,96 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam
hColorBrush[i] = NULL ;
}
}
EndDialog( hwndDlg, wParam) ;
// recupero il contesto impostato alla creazione della finestra ( durante esecuzione WM_INITDIALOG) e se esiste lo rimuovo
DialogContext* ctx = (DialogContext*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA) ;
if ( ctx != nullptr) {
ctx->bCancelled = true ;
ctx->bDone = true ;
}
// chiudo il dialogo
OnClosingDialog( hwndDlg) ;
return TRUE ;
}
}
// se siamo in modalità di Selezione e il comando attivo non si riferisce ad un button di Selezione (BS), il dialogo torna modale
if ( s_bSelectionMode) {
bool bIsBS = ( id >= IDC_BUTTON_SEL1 && id < IDC_BUTTON_SEL1 + MAX_CTRLS) ;
bool bIsActiveEdit = ( id == IDC_EDIT1 + s_nActiveRow) ;
// il dialogo torna modale
if ( ! bIsBS && ! bIsActiveEdit)
EndSelectionMode( hwndDlg) ;
}
break ;
}
case WM_CLOSE : {
// recupero il contesto impostato alla creazione della finestra ( durante esecuzione WM_INITDIALOG) e se esiste lo rimuovo
DialogContext* ctx = (DialogContext*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA) ;
if ( ctx != nullptr) {
ctx->bCancelled = true ;
ctx->bDone = true ;
}
// chiudo il dialogo
OnClosingDialog( hwndDlg) ;
return TRUE ;
}
}
return FALSE ;
}
//-------------------------------------------------------------------------------
// LuaDialogBox (Modeless)
//
// Scopo:
// ------
// Questa funzione implementa un dialogo "modale" dal punto di vista del codice Lua, ma "modeless" dal punto di vista della
// UI Windows quando necessario. Lobiettivo è permettere al codice Lua di rimanere sospeso finché lutente non chiude il
// dialogo (OK/Cancel/X), mantenendo però la UI attiva e permettendo selezioni nella scena quando lutente preme un pulsante
// BS (Button Selection).
//
// Perché serve:
// -------------
// - I dialoghi modali standard (DialogBox) bloccano completamente la UI, mentre i dialoghi modeless standard (CreateDialog)
// NON bloccano il codice Lua.
// - Le coroutine Lua (lua_yield/lua_resume) non sono utilizzabili in questo contesto perché il thread principale
// dellapplicazione non può essere sospeso tramite yield: il codice Lua non riprende correttamente e la UI non si
// aggiorna coerentemente)
//
// Come funziona:
// --------------
// 1) Il dialogo viene creato con CreateDialogParam(), quindi la UI rimane attiva.
// 2) La funzione NON ritorna subito: entra in un message loop locale (Esattamente equivalente al loop all'interno di
// DialogBox()). Il cuore del loop è GetMessage(), che è una chiamata BLOCCANTE. Significa che il thread rimane in
// attesa senza consumare CPU finché non arriva un messaggio. Non c’è polling, non c’è busy loop. Il comportamento è
// identico a quello di un dialogo modale nativo.
// 3) Il ciclo rimane attivo finché:
// - lutente non chiude il dialogo (OK/Cancel/X)
// - oppure la finestra viene distrutta
// In quel momento ctx->bDone viene impostato a true.
// 4) Durante la vita del dialogo, se lutente preme un pulsante BS, il dialogo diventa temporaneamente "modeless":
// - la main window viene abilitata
// - il dialogo rimane abilitato ma passa in secondo piano logico
// - lutente può selezionare oggetti nella scena
// Quando la selezione termina, il dialogo torna modale.
// 5) Quando il dialogo chiude, i valori vengono copiati in ctx->vsResult e ritornati a Lua come risultato della funzione.
//
// Vantaggi della soluzione:
// -------------------------
// - Lua rimane bloccato come con un dialogo modale tradizionale.
// - La UI rimane completamente attiva.
// - Le selezioni BS (mediante Button Selection) funzionano senza bloccare il programma.
// - Nessun uso di coroutine Lua (che non erano affidabili in questo contesto).
// - Nessun consumo CPU anomalo.
// - Comportamento stabile e prevedibile.
//
// Nota importante:
// ----------------
// Il dialogo NON viene mai disabilitato durante la selezione BS (Button Selection). Solo la main window viene
// abilitata temporaneamente.
// Questo è fondamentale: disabilitare il dialogo impedirebbe allutente di poterlo riselezionare dopo la selezione nella scena.
//
static int
LuaDialogBox( lua_State* L)
{
@@ -1516,7 +1838,7 @@ LuaDialogBox( lua_State* L)
s_nCtrls = 0 ;
for ( int i = 0 ; i < MAX_CTRLS ; ++ i) {
STRVECTOR vData ;
if ( LuaGetParam( L, 2 + i, vData) && vData.size() >= 2) {
if ( LuaGetParam( L, 2 + i, vData) && ssize( vData) >= 2) {
s_sText[i] = Trim( vData[0]) ;
s_sEdit[i] = Trim( vData[1]) ;
++ s_nCtrls ;
@@ -1525,24 +1847,62 @@ LuaDialogBox( lua_State* L)
break ;
}
LuaClearStack( L) ;
// se abilitata UI, lancio dialogo
if ( ExeGetEnableUI()) {
// lancio dialogo
HWND hTopWnd = ExeGetMainWindowHandle() ;
bool bOk = ( DialogBox( GetModuleIstance(), MAKEINTRESOURCE( IDD_LUADLG), hTopWnd, (DLGPROC)DialogBoxProc) == IDOK) ;
// restituzione parametri
if ( bOk) {
STRVECTOR vRes ;
for ( int i = 0 ; i < s_nCtrls ; ++ i)
vRes.emplace_back( s_sEdit[i]) ;
LuaSetParam( L, vRes) ;
}
else {
LuaSetParam( L) ;
// se UI disabilitata, esco
if ( ! ExeGetEnableUI()) {
LuaSetParam( L) ;
return 1 ;
}
// se dialogo Modeless già aperto, errore
if ( phDlgModeless != nullptr) {
LuaSetParam( L) ;
return 1 ;
}
// creazione del contesto e della Coroutine da gestire
DialogContext* ctx = new DialogContext() ;
if ( ctx == nullptr) {
LuaSetParam( L) ;
return 1 ;
}
// creazione di un dialogo Modeless
HWND hTopWnd = ExeGetMainWindowHandle() ;
nDlgModelessItem = -1 ;
phDlgModeless = ( CreateDialogParam( GetModuleIstance(), MAKEINTRESOURCE( IDD_LUADLG), hTopWnd,
(DLGPROC)DialogBoxModelessProc, (LPARAM)ctx)) ;
if ( phDlgModeless == nullptr) {
delete( ctx) ;
ctx = nullptr ;
LuaSetParam( L) ;
return 1 ;
}
// porto la finestra in primo piano
ShowWindow( phDlgModeless, SW_SHOW) ;
SetForegroundWindow( phDlgModeless) ;
// message Loop Modale (ripresa del Loop come da dialogo modale)
MSG msg ;
while ( ! ctx->bDone && IsWindow( phDlgModeless)) {
if ( GetMessage( &msg, NULL, 0, 0) <= 0)
break ;
if ( ! IsDialogMessage( phDlgModeless, &msg)) {
TranslateMessage( &msg) ;
DispatchMessage( &msg) ;
}
}
// ritorno i valori lua
if ( ctx->bCancelled)
LuaSetParam( L, false) ;
else
LuaSetParam( L) ;
LuaSetParam( L, ctx->vsResult) ;
// libero la memoria
delete ctx ;
ctx = nullptr ;
return 1 ;
}
@@ -1607,6 +1967,5 @@ LuaInstallGeneral( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtCreateMutex", LuaCreateMutex) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtReleaseMutex", LuaReleaseMutex) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtDialogBox", LuaDialogBox) ;
return bOk ;
}
+36 -12
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)
@@ -3317,11 +3340,11 @@ LuaGetClEntTDir( lua_State* L)
int nEntId ;
LuaGetParam( L, 1, nEntId) ;
LuaClearStack( L) ;
// recupero vTDir
Vector3d vTDir ;
bool bOk = ExeGetClEntTDir( nEntId, vTDir) ;
// recupero TDir
Vector3d vtTDir ;
bool bOk = ExeGetClEntTDir( nEntId, vtTDir) ;
if ( bOk)
LuaSetParam( L, vTDir) ;
LuaSetParam( L, vtTDir) ;
else
LuaSetParam( L) ;
return 1 ;
@@ -3335,11 +3358,11 @@ LuaGetClEntCDir( lua_State* L)
int nEntId ;
LuaGetParam( L, 1, nEntId) ;
LuaClearStack( L) ;
// recupero vCDir
Vector3d vCDir ;
bool bOk = ExeGetClEntCDir( nEntId, vCDir) ;
// recupero CDir
Vector3d vtCDir ;
bool bOk = ExeGetClEntCDir( nEntId, vtCDir) ;
if ( bOk)
LuaSetParam( L, vCDir) ;
LuaSetParam( L, vtCDir) ;
else
LuaSetParam( L) ;
return 1 ;
@@ -3353,11 +3376,11 @@ LuaGetClEntADir( lua_State* L)
int nEntId ;
LuaGetParam( L, 1, nEntId) ;
LuaClearStack( L) ;
// recupero vADir
Vector3d vADir ;
bool bOk = ExeGetClEntADir( nEntId, vADir) ;
// recupero ADir
Vector3d vtADir ;
bool bOk = ExeGetClEntADir( nEntId, vtADir) ;
if ( bOk)
LuaSetParam( L, vADir) ;
LuaSetParam( L, vtADir) ;
else
LuaSetParam( L) ;
return 1 ;
@@ -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) ;
+92 -7
View File
@@ -283,21 +283,103 @@ 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)
{
int nParentId = GDB_ID_NULL ;
LuaCheckParam( L, 1, nParentId)
int nSurfId = GDB_ID_NULL ;
LuaCheckParam( L, 1, nSurfId)
LuaCheckParam( L, 2, nSurfId)
int nSyncStartId ;
LuaCheckParam( L, 2, nSyncStartId)
LuaCheckParam( L, 3, nSyncStartId)
int nSyncEndId ;
LuaCheckParam( L, 3, nSyncEndId)
LuaCheckParam( L, 4, nSyncEndId)
double dLinTol ;
LuaCheckParam( L, 4, dLinTol)
bool bOk = ExeRegolarizeSurfaceLocally( nSurfId, nSyncStartId, nSyncEndId, dLinTol) ;
LuaSetParam( L, bOk) ;
LuaCheckParam( L, 5, dLinTol)
int nType = 0 ;
LuaCheckParam( L, 6, nType)
int nId = ExeRegolarizeSurfaceLocally( nParentId, nSurfId, nSyncStartId, nSyncEndId, dLinTol, nType) ;
LuaSetParam( L, nId) ;
return 1 ;
}
@@ -320,6 +402,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 ;
+18 -4
View File
@@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by EgtExecutor.rc
// File di inclusione generato con Microsoft Visual C++.
// Utilizzato da EgtExecutor.rc
//
#define VS_VERSION_INFO 1
#define IDD_LUADLG 101
@@ -13,6 +13,7 @@
#define IDC_TEXT6 1006
#define IDC_TEXT7 1007
#define IDC_TEXT8 1008
#define IDC_EDIT1 1011
#define IDC_EDIT2 1012
#define IDC_EDIT3 1013
@@ -21,6 +22,7 @@
#define IDC_EDIT6 1016
#define IDC_EDIT7 1017
#define IDC_EDIT8 1018
#define IDC_COMBO1 1021
#define IDC_COMBO2 1022
#define IDC_COMBO3 1023
@@ -29,6 +31,7 @@
#define IDC_COMBO6 1026
#define IDC_COMBO7 1027
#define IDC_COMBO8 1028
#define IDC_CHECK1 1031
#define IDC_CHECK2 1032
#define IDC_CHECK3 1033
@@ -37,6 +40,7 @@
#define IDC_CHECK6 1036
#define IDC_CHECK7 1037
#define IDC_CHECK8 1038
#define IDC_COLOR1 1041
#define IDC_COLOR2 1042
#define IDC_COLOR3 1043
@@ -45,15 +49,25 @@
#define IDC_COLOR6 1046
#define IDC_COLOR7 1047
#define IDC_COLOR8 1048
#define IDC_BUTTON_SEL1 1051
#define IDC_BUTTON_SEL2 1052
#define IDC_BUTTON_SEL3 1053
#define IDC_BUTTON_SEL4 1054
#define IDC_BUTTON_SEL5 1055
#define IDC_BUTTON_SEL6 1056
#define IDC_BUTTON_SEL7 1057
#define IDC_BUTTON_SEL8 1058
#define IDC_PICTURE1 1101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_RESOURCE_VALUE 109
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1030
#define _APS_NEXT_CONTROL_VALUE 1074
#define _APS_NEXT_SYMED_VALUE 115
#endif
#endif