EgtExecutor 1.6h2 :

- aggiunta CreateSurfFlatRegion per EXE e LUA
- aggiunta TrimCurveWithRegion per EXE e LUA
- aggiunta ExtractSurfFrLoop per EXE e LUA.
This commit is contained in:
Dario Sassi
2015-08-07 10:48:19 +00:00
parent af849e6202
commit 064fb60719
7 changed files with 256 additions and 0 deletions
+89
View File
@@ -25,9 +25,12 @@
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkIntersCurves.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkCurveLocal.h"
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
#include "/EgtDev/Include/EGkExtTExt.h"
#include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkIntervals.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include <functional>
@@ -487,6 +490,92 @@ ExeTrimExtendCurveByLen( int nId, double dLen, const Point3d& ptNear, int nRefTy
return bOk ;
}
//----------------------------------------------------------------------------
static int
MyTrimCurveWithRegion( int nCrvId, int nRegId, bool bInVsOut, bool bOn, int& nCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la regione
ISurfFlatRegion* pSFR = GetSurfFlatRegion( pGeomDB->GetGeoObj( nRegId)) ;
if ( pSFR == nullptr)
return GDB_ID_NULL ;
// recupero il riferimento della regione
Frame3d frReg ;
if ( ! pGeomDB->GetGlobFrame( nRegId, frReg))
return GDB_ID_NULL ;
// recupero la curva
ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ;
if ( pCrv == nullptr)
return GDB_ID_NULL ;
// recupero la curva in locale alla regione
CurveLocal CrvLoc( pGeomDB, nCrvId, frReg) ;
if ( CrvLoc.Get() == nullptr)
return GDB_ID_NULL ;
// calcolo la classificazione della curva rispetto alla regione
CRVCVECTOR ccClass ;
if ( ! pSFR->GetCurveClassification( *CrvLoc.Get(), ccClass))
return GDB_ID_NULL ;
// determino gli intervalli di curva da conservare
Intervals inOk ;
for ( auto& ccOne : ccClass) {
if ( ( bInVsOut && ccOne.nClass == CRVC_IN) ||
( ! bInVsOut && ccOne.nClass == CRVC_OUT) ||
( bOn && ( ccOne.nClass == CRVC_ON_P || ccOne.nClass == CRVC_ON_M)))
inOk.Add( ccOne.dParE, ccOne.dParS) ;
}
// recupero un intervallo di id contigui per tutte le parti
int nFirstId = pGeomDB->GetNewId() ;
if ( ! pGeomDB->ChangeId( nCrvId, nFirstId))
return GDB_ID_NULL ;
int nCurrId = nFirstId ;
// eseguo la divisione
nCount = 0 ;
double dParS, dParE ;
bool bFound = inOk.GetFirst( dParS, dParE) ;
while ( bFound) {
// copio la curva
int nCopyId = pGeomDB->Copy( nCurrId, GDB_ID_NULL, nCurrId, GDB_AFTER) ;
ICurve* pCopyCrv = GetCurve( pGeomDB->GetGeoObj( nCopyId)) ;
if ( pCopyCrv == nullptr)
return GDB_ID_NULL ;
++ nCount ;
// modifico l'originale
if ( ! pCrv->TrimStartEndAtParam( dParS, dParE))
return GDB_ID_NULL ;
// la copia diventa il nuovo corrente
nCurrId = nCopyId ;
pCrv = pCopyCrv ;
// passo alla successiva divisione
bFound = inOk.GetNext( dParS, dParE) ;
}
// cancello l'ultima copia (se non c'erano intervalli validi è l'originale)
pGeomDB->Erase( nCurrId) ;
return nFirstId ;
}
//----------------------------------------------------------------------------
int
ExeTrimCurveWithRegion( int nCrvId, int nRegId, bool bInVsOut, bool bOn, int* pnCount)
{
int nCount ;
int nFirstId = MyTrimCurveWithRegion( nCrvId, nRegId, bInVsOut, bOn, nCount) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtTrimCurveWithRegion(" + ToString( nCrvId) + "," +
ToString( nRegId) + "," +
ToString( bInVsOut) + "," +
ToString( bOn) + ")" +
" -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultati
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
}
//----------------------------------------------------------------------------
int
ExeSplitCurve( int nId, int nParts)