EgtExecutor 1.6i8 :

- aggiunta OffsetCurveAdv per EXE e LUA.
This commit is contained in:
Dario Sassi
2015-09-25 13:17:55 +00:00
parent 2ca704432a
commit 3a3b43ee8c
3 changed files with 86 additions and 9 deletions
+59 -9
View File
@@ -27,6 +27,7 @@
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkCurveLocal.h"
#include "/EgtDev/Include/EgkCurveAux.h"
#include "/EgtDev/Include/EgkOffsetCurve.h"
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
#include "/EgtDev/Include/EGkExtTExt.h"
#include "/EgtDev/Include/EGkGdbIterator.h"
@@ -91,6 +92,52 @@ ExeOffsetCurve( int nId, double dDist, int nType)
return bOk ;
}
//----------------------------------------------------------------------------
int
ExeOffsetCurveAdv( int nId, double dDist, int nType, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero la curva
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
// eseguo l'offset
OffsetCurve OffsCrv ;
bool bOk = OffsCrv.Make( pCurve, dDist, nType) ;
// salvo le curve di offset
int nCount = 0 ;
int nFirstId = GDB_ID_NULL ;
PtrOwner<ICurve> pOffs( OffsCrv.GetCurve()) ;
while ( bOk && ! IsNull( pOffs)) {
// inserisco la curva nel DB geometrico
int nNewId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, 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 ;
// passo alla successiva
pOffs.Set( OffsCrv.GetCurve()) ;
}
if ( ! bOk)
nCount = - 1 ;
ExeSetModified() ;
// 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 ;
}
//----------------------------------------------------------------------------
bool
ExeChangeClosedCurveStartPoint( int nId, const Point3d& ptP, int nRefType)
@@ -645,19 +692,22 @@ ExeSplitCurveAtPoint( int nId, const Point3d& ptOn, int nRefType)
int nFlag ;
if ( ! dstPC.GetParamAtMinDistPoint( 0, dU, nFlag) || nFlag != MDPCI_NORMAL)
bOk = false ;
// se sull'inizio, provo se c'è una soluzione successiva
if ( bOk && dU < EPS_PARAM)
dstPC.GetParamAtMinDistPoint( 1, dU, nFlag) ;
}
// verifico che il punto di taglio sia interno alla curva
bool bIsInside = false ;
if ( bOk) {
Point3d ptStart ;
Point3d ptEnd ;
Point3d ptBreak ;
if ( pCurve->GetStartPoint( ptStart) &&
pCurve->GetEndPoint( ptEnd) &&
pCurve->GetPointD1D2( dU, ICurve::FROM_MINUS, ptBreak)) {
bIsInside = ! AreSamePointApprox( ptBreak, ptStart) &&
! AreSamePointApprox( ptBreak, ptEnd) ;
}
// determino lunghezza totale della curva
double dLen ;
bOk = bOk && pCurve->GetLength( dLen) ;
// determino lunghezza al parametro di taglio
double dCutLen ;
bOk = bOk && pCurve->GetLengthAtParam( dU, dCutLen) ;
// interno se la lunghezza al parametro e la lunghezza rimanente sono entrambe significative
if ( bOk && dCutLen > EPS_SMALL && dLen - dCutLen > EPS_SMALL)
bIsInside = true ;
}
// se il punto di taglio è interno, devo realmente tagliare
int nNewId = GDB_ID_NULL ;