EgtGeomKernel 1.5g1 :
- alle curve aggiunto il metodo CopyParamRange (per curve chiuse ammatte range che passano dal punto di chiusura) - trasformato il metodo Copy di tutti gli oggetti geometrici in CopyFrom - a TSC aggiunte funzioni CopyCurveByParamRange e SplitCurveByClass - migliorata gestione intersezioni sovrapposte - aggiunta classificazione parti di curva (IN,OUT,ONP,ONM) da intersezioni con altra curva chiusa.
This commit is contained in:
+155
-8
@@ -120,10 +120,14 @@ GdbExecutor::GdbExecutor( void)
|
||||
m_ExecMgr.Insert( "SHEAR", &GdbExecutor::ExecuteShear) ;
|
||||
m_ExecMgr.Insert( "INVC", &GdbExecutor::ExecuteInvertCurve) ;
|
||||
m_ExecMgr.Insert( "INVERTCURVE", &GdbExecutor::ExecuteInvertCurve) ;
|
||||
m_ExecMgr.Insert( "COPYC", &GdbExecutor::ExecuteCopyCurve) ;
|
||||
m_ExecMgr.Insert( "COPYCURVE", &GdbExecutor::ExecuteCopyCurve) ;
|
||||
m_ExecMgr.Insert( "INVS", &GdbExecutor::ExecuteInvertSurf) ;
|
||||
m_ExecMgr.Insert( "INVERTSURF", &GdbExecutor::ExecuteInvertSurf) ;
|
||||
m_ExecMgr.Insert( "TRC", &GdbExecutor::ExecuteTrimCurve) ;
|
||||
m_ExecMgr.Insert( "TRIMCURVE", &GdbExecutor::ExecuteTrimCurve) ;
|
||||
m_ExecMgr.Insert( "SPC", &GdbExecutor::ExecuteSplitCurve) ;
|
||||
m_ExecMgr.Insert( "SPLITCURVE", &GdbExecutor::ExecuteSplitCurve) ;
|
||||
m_ExecMgr.Insert( "NEW", &GdbExecutor::ExecuteNew) ;
|
||||
m_ExecMgr.Insert( "LOAD", &GdbExecutor::ExecuteLoad) ;
|
||||
m_ExecMgr.Insert( "SAVE", &GdbExecutor::ExecuteSave) ;
|
||||
@@ -726,7 +730,7 @@ GdbExecutor::CurveLineTgTwoArcs( const STRVECTOR& vsParams)
|
||||
PtrOwner<ICurveArc> pArc2Loc( CreateCurveArc()) ;
|
||||
if ( ! IsValid( pArc2Loc))
|
||||
return false ;
|
||||
pArc2Loc->Copy( pArc2) ;
|
||||
pArc2Loc->CopyFrom( pArc2) ;
|
||||
pArc2Loc->LocToLoc( frArc2, frArc1) ;
|
||||
// recupero il secondo punto vicino e lo porto nel riferimento del primo arco
|
||||
Point3d ptNear2 ;
|
||||
@@ -2642,7 +2646,7 @@ GdbExecutor::TextOutline( const STRVECTOR& vsParams)
|
||||
ICURVEPLIST::iterator iIter ;
|
||||
for ( iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) {
|
||||
(*iIter)->LocToLoc( frTXT, frDest) ;
|
||||
if ( ! m_pGDB->AddGeoObj( GDB_ID_NULL, nIdDest, (*iIter))) {
|
||||
if ( m_pGDB->AddGeoObj( GDB_ID_NULL, nIdDest, (*iIter)) == GDB_ID_NULL) {
|
||||
delete (*iIter) ;
|
||||
bOk = false ;
|
||||
}
|
||||
@@ -2712,12 +2716,21 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
// verifico siano 3 parti e le converto
|
||||
if ( vsParams.size() != 3)
|
||||
// se 2 parti, allora Z = 0
|
||||
if ( vsParams.size() == 2) {
|
||||
vtV.z = 0 ;
|
||||
return ( FromString( vsParams[0], vtV.x) &&
|
||||
FromString( vsParams[1], vtV.y)) ;
|
||||
}
|
||||
// se 3 parti
|
||||
else if ( vsParams.size() == 3) {
|
||||
return ( FromString( vsParams[0], vtV.x) &&
|
||||
FromString( vsParams[1], vtV.y) &&
|
||||
FromString( vsParams[2], vtV.z)) ;
|
||||
}
|
||||
// altrimenti errore
|
||||
else
|
||||
return false ;
|
||||
return ( FromString( vsParams[0], vtV.x) &&
|
||||
FromString( vsParams[1], vtV.y) &&
|
||||
FromString( vsParams[2], vtV.z)) ;
|
||||
}
|
||||
// se altrimenti vettore predefinito X_AX
|
||||
else if ( sParam == "X_AX") {
|
||||
@@ -4350,7 +4363,7 @@ GdbExecutor::ExecuteShear( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
bool
|
||||
GdbExecutor::ExecuteInvertCurve( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// 1 parametro ( Nome/i)
|
||||
// 1 parametro : Id/s
|
||||
if ( vsParams.size() != 1)
|
||||
return false ;
|
||||
// recupero lista nomi
|
||||
@@ -4368,6 +4381,50 @@ GdbExecutor::ExecuteInvertCurve( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecuteCopyCurve( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
if ( sCmd2 == "PR" || sCmd2 == "PARAMRANGE")
|
||||
return CopyCurveByParamRange( vsParams) ;
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::CopyCurveByParamRange( const STRVECTOR& vsParams)
|
||||
{
|
||||
// 5 parametri : IdCrv, IdDest, IdGroupDest, StartPar, EndPar
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero la curva sorgente
|
||||
int nIdCrv = GetIdParam( vsParams[0]) ;
|
||||
const ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nIdCrv)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
// recupero il suo riferimento
|
||||
Frame3d frCrv ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdCrv, frCrv))
|
||||
return false ;
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frDest ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[2]), frDest))
|
||||
return false ;
|
||||
// recupero i parametri del range
|
||||
double dUStart, dUEnd ;
|
||||
if ( ! FromString( vsParams[3], dUStart) ||
|
||||
! FromString( vsParams[4], dUEnd))
|
||||
return false ;
|
||||
// copio la parte di curva che interessa e la porto nel riferimento del gruppo destinazione
|
||||
PtrOwner<ICurve> pCopy( pCrv->CopyParamRange( dUStart, dUEnd)) ;
|
||||
if ( ! ::IsValid( pCopy))
|
||||
return false ;
|
||||
pCopy->LocToLoc( frCrv, frDest) ;
|
||||
// la inserisco nel gruppo
|
||||
return AddGeoObj( vsParams[1], vsParams[2], ::Release( pCopy)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecuteInvertSurf( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
@@ -4461,6 +4518,96 @@ GdbExecutor::ExecuteTrimCurve( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecuteSplitCurve( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
if ( sCmd2 == "C" || sCmd2 == "CLASS")
|
||||
return SplitCurveByClass( vsParams) ;
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::SplitCurveByClass( const STRVECTOR& vsParams)
|
||||
{
|
||||
// 6 parametri : IdCurve, IdClosedCurve, IdGroupIn, IdGroupOut, IdGroupOnP, IdGroupOnM
|
||||
if ( vsParams.size() != 6)
|
||||
return false ;
|
||||
// recupero l'indice delle due curve
|
||||
int nIdCrv = GetIdParam( vsParams[0]) ;
|
||||
int nIdCloCrv = GetIdParam( vsParams[1]) ;
|
||||
// verifico siano due curve
|
||||
const ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nIdCrv)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
const ICurve* pCloCrv = GetCurve( m_pGDB->GetGeoObj( nIdCloCrv)) ;
|
||||
if ( pCloCrv == nullptr)
|
||||
return false ;
|
||||
// verifico che la seconda sia chiusa
|
||||
if ( ! pCloCrv->IsClosed())
|
||||
return false ;
|
||||
// recupero i riferimenti in cui sono immerse
|
||||
Frame3d frCrv ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdCrv, frCrv))
|
||||
return false ;
|
||||
Frame3d frCloCrv ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdCloCrv, frCloCrv))
|
||||
return false ;
|
||||
// se i riferimenti sono diversi, porto la seconda curva nel riferimento della prima
|
||||
PtrOwner<ICurve> crvTrans( nullptr) ;
|
||||
if ( ! AreSameFrame( frCrv, frCloCrv)) {
|
||||
crvTrans.Set( pCloCrv->Clone()) ;
|
||||
if ( ! ::IsValid( crvTrans))
|
||||
return false ;
|
||||
crvTrans->LocToLoc( frCloCrv, frCrv) ;
|
||||
pCloCrv = ::Get( crvTrans) ;
|
||||
}
|
||||
// calcolo le intersezioni tra le due curve
|
||||
IntersCurveCurve intCC( *pCrv, *pCloCrv, true) ;
|
||||
// recupero la classificazione della prima curva
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( ! intCC.GetCurveClassification( 0, ccClass))
|
||||
return false ;
|
||||
// recupero gli indici dei gruppi destinazione e i loro riferimenti
|
||||
const int N_GRP = 4 ;
|
||||
int nIdGrp[N_GRP] ; // 0->IN, 1->OUT, 2->ON_P, 3->ON_M
|
||||
Frame3d frGrp[N_GRP] ;
|
||||
for ( int j = 0 ; j < N_GRP ; ++ j) {
|
||||
nIdGrp[j] = GetIdParam( vsParams[j+2]) ;
|
||||
if ( nIdGrp[j] >= GDB_ID_ROOT && ! m_pGDB->GetGroupGlobFrame( nIdGrp[j], frGrp[j]))
|
||||
return false ;
|
||||
}
|
||||
// copio gli split nei diversi gruppi
|
||||
for ( int i = 0 ; i < int( ccClass.size()) ; ++ i) {
|
||||
// recupero indice di gruppo
|
||||
int nGrp ;
|
||||
switch ( ccClass[i].nClass) {
|
||||
case CRVC_IN : nGrp = 0 ; break ;
|
||||
case CRVC_OUT : nGrp = 1 ; break ;
|
||||
case CRVC_ON_P : nGrp = 2 ; break ;
|
||||
case CRVC_ON_M : nGrp = 3 ; break ;
|
||||
default : return false ;
|
||||
}
|
||||
// se gruppo non richiesto, vado oltre
|
||||
if ( nIdGrp[nGrp] < GDB_ID_ROOT)
|
||||
continue ;
|
||||
// se curva praticamente nulla, vado oltre
|
||||
if ( fabs( ccClass[i].dParS - ccClass[i].dParE) < 10 * EPS_PARAM)
|
||||
continue ;
|
||||
// copio la parte di curva che interessa e la porto nel riferimento del gruppo
|
||||
PtrOwner<ICurve> pSplit( pCrv->CopyParamRange( ccClass[i].dParS, ccClass[i].dParE)) ;
|
||||
if ( ! ::IsValid( pSplit))
|
||||
return false ;
|
||||
pSplit->LocToLoc( frCrv, frGrp[nGrp]) ;
|
||||
// la inserisco nel gruppo
|
||||
if ( m_pGDB->AddGeoObj( GDB_ID_NULL, nIdGrp[nGrp], ::Release( pSplit)) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecuteNew( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
|
||||
Reference in New Issue
Block a user