EgtExecutor :

- spostate le funzioni di offset.
- aggiunta la funzione di offset 3d delle curve.
This commit is contained in:
Daniele Bariletti
2026-06-15 08:39:46 +02:00
parent 62a8693ce5
commit 20de52bf58
6 changed files with 523 additions and 415 deletions
+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 ;
}