EgtExecutor 1.6g2 :

- ExeSplitCurve ora mette le curve risultato in Id contigui
- aggiunta ExeSplitCurveAtSelfInters
- aggiunta ExeGetNewId
- aggiunta ExeCurveSelfIntersNbr
- ExeIntersectionPoint funziona anche con auto-intersezioni
- il tutto anche per le funzioni lua equivalenti.
This commit is contained in:
Dario Sassi
2015-07-07 18:30:47 +00:00
parent 57d69257f1
commit d070901ce0
7 changed files with 195 additions and 10 deletions
+82 -5
View File
@@ -23,11 +23,13 @@
#include "/EgtDev/Include/EGkCurveArc.h"
#include "/EgtDev/Include/EGkCurveBezier.h"
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkIntersCurves.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkExtTExt.h"
#include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include <functional>
using namespace std ;
@@ -501,9 +503,12 @@ ExeSplitCurve( int nId, int nParts)
bOk = bOk && pCurve->GetLength( dLenTot) ;
// lunghezza di una parte
double dLen = dLenTot / nParts ;
bOk = bOk && ( dLen > 10 * EPS_SMALL) ;
// recupero un intervallo di id contigui per tutte le parti
int nFirstId = pGeomDB->GetNewId() ;
bOk = bOk && pGeomDB->ChangeId( nId, nFirstId) ;
int nCurrId = nFirstId ;
// eseguo la divisione
int nFirstId = GDB_ID_NULL ;
int nCurrId = nId ;
for ( int i = 1; i < nParts ; ++ i) {
// copio la curva
int nCopyId = pGeomDB->Copy( nCurrId, GDB_ID_NULL, nCurrId, GDB_AFTER) ;
@@ -515,9 +520,6 @@ ExeSplitCurve( int nId, int nParts)
// la copia diventa il nuovo corrente
nCurrId = nCopyId ;
pCurve = pCopyCrv ;
// salvo identificativo prima copia
if ( nFirstId == GDB_ID_NULL)
nFirstId = nCopyId ;
}
nFirstId = ( bOk ? nFirstId : GDB_ID_NULL) ;
ExeSetModified() ;
@@ -592,6 +594,81 @@ ExeSplitCurveAtPoint( int nId, const Point3d& ptOn, int nRefType)
return nNewId ;
}
//----------------------------------------------------------------------------
int
ExeSplitCurveAtSelfInters( int nId, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pCurve != nullptr) ;
// calcolo le auto-intersezioni
SelfIntersCurve sintC( *pCurve) ;
DBLVECTOR vU ;
IntCrvCrvInfo iccInfo ;
for ( int i = 0 ; sintC.GetIntCrvCrvInfo( i, iccInfo) ; ++ i) {
if ( ! iccInfo.bOverlap) {
vU.push_back( iccInfo.IciA[0].dU) ;
vU.push_back( iccInfo.IciB[0].dU) ;
}
else {
vU.push_back( iccInfo.IciA[0].dU) ;
vU.push_back( iccInfo.IciA[1].dU) ;
vU.push_back( iccInfo.IciB[0].dU) ;
vU.push_back( iccInfo.IciB[1].dU) ;
}
}
// ordino il vettore in senso crescente
sort( vU.begin(), vU.end(), less<double>()) ;
// calcolo il vettore delle lunghezze di ogni parte di curva
double dLen ;
bOk = bOk && pCurve->GetLength( dLen) ;
DBLVECTOR vPartLen ;
double dLenPrev = 0 ;
for ( const auto& dU : vU) {
double dULen, dPartLen ;
bOk = bOk && pCurve->GetLengthAtParam( dU, dULen) ;
dPartLen = dULen - dLenPrev ;
// le curve prima e dopo devono avere una lunghezza significativa
if ( dPartLen > EPS_SMALL && dLen - dULen > EPS_SMALL) {
vPartLen.push_back( dPartLen) ;
dLenPrev = dULen ;
}
}
// recupero un intervallo di id contigui per tutte le parti
int nFirstId = pGeomDB->GetNewId() ;
bOk = bOk && pGeomDB->ChangeId( nId, nFirstId) ;
int nCurrId = nFirstId ;
// eseguo la divisione
int nCount = 1 ;
for ( auto& dPartLen : vPartLen) {
// copio la curva
int nCopyId = pGeomDB->Copy( nCurrId, GDB_ID_NULL, nCurrId, GDB_AFTER) ;
ICurve* pCopyCrv = GetCurve( pGeomDB->GetGeoObj( nCopyId)) ;
bOk = bOk && ( pCopyCrv != nullptr) ;
++ nCount ;
// tengo la prima parte dell'originale e la seconda parte della copia
bOk = bOk && pCurve->TrimEndAtLen( dPartLen) ;
bOk = bOk && pCopyCrv->TrimStartAtLen( dPartLen) ;
// la copia diventa il nuovo corrente
nCurrId = nCopyId ;
pCurve = pCopyCrv ;
}
nFirstId = ( bOk ? nFirstId : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSplitCurveAtSelfIntersections(" + ToString( nId) + ")" +
" -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultati
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
}
//-------------------------------------------------------------------------------
bool
ExeModifyCurveCircleCPN( int nId, const Point3d& ptOn, int nRefType)