EgtGeomKernel 1.5h4 :
- uso set di istruzioni SSE2 - miglioramenti generali ad ApproxWithArcs - estensione uso di PolyLine e PolyArc - a TSC aggiunta funzione CurveCompo.FromCurveApproximation.
This commit is contained in:
+113
-29
@@ -1606,6 +1606,9 @@ GdbExecutor::ExecuteCurveCompo( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// creazione per interpolazione di punti
|
||||
else if ( sCmd2 == "PINTERP" || sCmd2 == "FROMPOINTINTERPOLATION")
|
||||
return CurveCompoFromPointInterpolation( vsParams) ;
|
||||
// creazione per approssimazione di curva
|
||||
else if ( sCmd2 == "CAPPROX" || sCmd2 == "FROMCURVEAPPROXIMATION")
|
||||
return CurveCompoFromCurveApproximation( vsParams) ;
|
||||
// creazione da split di curva semplice
|
||||
else if ( sCmd2 == "S" || sCmd2 == "FROMSPLIT")
|
||||
return CurveCompoFromSplit( vsParams) ;
|
||||
@@ -1724,15 +1727,15 @@ GdbExecutor::CurveCompoFromPoints( const STRVECTOR& vsParams)
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
|
||||
return false ;
|
||||
// recupero i punti
|
||||
PNTVECTOR vPoints ;
|
||||
if ( ! GetPointsParam( vsParams[2], frDest, vPoints))
|
||||
PolyLine PL ;
|
||||
if ( ! GetPointsParam( vsParams[2], frDest, PL))
|
||||
return false ;
|
||||
// creo la curva composita
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
if ( ! IsValid( pCrvCompo))
|
||||
return false ;
|
||||
// inserisco i segmenti che uniscono i punti
|
||||
if ( ! pCrvCompo->FromPointVector( vPoints))
|
||||
if ( ! pCrvCompo->FromPolyLine( PL))
|
||||
return false ;
|
||||
// inserisco la curva composita nel DB
|
||||
return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvCompo)) ;
|
||||
@@ -1750,15 +1753,15 @@ GdbExecutor::CurveCompoFromPointBulges( const STRVECTOR& vsParams)
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
|
||||
return false ;
|
||||
// recupero i punti
|
||||
UPNTVECTOR vPointWs ;
|
||||
if ( ! GetPointWsParam( vsParams[2], frDest, vPointWs))
|
||||
PolyArc PA ;
|
||||
if ( ! GetPointWsParam( vsParams[2], frDest, PA))
|
||||
return false ;
|
||||
// creo la curva composita
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
if ( ! IsValid( pCrvCompo))
|
||||
return false ;
|
||||
// inserisco i segmenti che uniscono i punti
|
||||
if ( ! pCrvCompo->FromPointBulgeVector( vPointWs, Z_AX))
|
||||
if ( ! pCrvCompo->FromPolyArc( PA))
|
||||
return false ;
|
||||
// inserisco la curva composita nel DB
|
||||
return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvCompo)) ;
|
||||
@@ -1776,8 +1779,8 @@ GdbExecutor::CurveCompoFromPointInterpolation( const STRVECTOR& vsParams)
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
|
||||
return false ;
|
||||
// recupero i punti
|
||||
PNTVECTOR vPoints ;
|
||||
if ( ! GetPointsParam( vsParams[2], frDest, vPoints))
|
||||
PolyLine PL ;
|
||||
if ( ! GetPointsParam( vsParams[2], frDest, PL))
|
||||
return false ;
|
||||
// recupero il metodo di interpolazione
|
||||
string sMethod = vsParams[3] ;
|
||||
@@ -1800,8 +1803,11 @@ GdbExecutor::CurveCompoFromPointInterpolation( const STRVECTOR& vsParams)
|
||||
// oggetto interpolatore
|
||||
CurveByInterp crvByInterp ;
|
||||
crvByInterp.Start() ;
|
||||
for ( int i = 0 ; i < int( vPoints.size()) ; ++ i)
|
||||
crvByInterp.AddPoint( vPoints[i]) ;
|
||||
Point3d ptP ;
|
||||
for ( bool bFound = PL.GetFirstPoint( ptP) ;
|
||||
bFound ;
|
||||
bFound = PL.GetNextPoint( ptP))
|
||||
crvByInterp.AddPoint( ptP) ;
|
||||
crvByInterp.End() ;
|
||||
PtrOwner<ICurve> pCrv( crvByInterp.GetCurve( nMethod, nType)) ;
|
||||
if ( ! ::IsValid( pCrv))
|
||||
@@ -1810,6 +1816,51 @@ GdbExecutor::CurveCompoFromPointInterpolation( const STRVECTOR& vsParams)
|
||||
return AddGeoObj( vsParams[0], vsParams[1], ::Release( pCrv)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::CurveCompoFromCurveApproximation( const STRVECTOR& vsParams)
|
||||
{
|
||||
// 5 parametri : Id, ParentId, SouCrvId, Method, dLinTol5
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frDest ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
|
||||
return false ;
|
||||
// recupero Id della curva sorgente
|
||||
int nSouId = GetIdParam( vsParams[2]) ;
|
||||
// recupero il tipo di approssimazione
|
||||
string sType = vsParams[3] ;
|
||||
ToUpper( sType) ;
|
||||
int nType = 1 ;
|
||||
if ( sType == "LINES")
|
||||
nType = 1 ;
|
||||
else if ( sType == "BIARCS")
|
||||
nType = 2 ;
|
||||
// recupero la tolleranza lineare
|
||||
double dLinTol ;
|
||||
if ( ! FromString( vsParams[4], dLinTol))
|
||||
return false ;
|
||||
// eseguo l'approssimazione
|
||||
PtrOwner<ICurveComposite> pCC( CreateCurveComposite()) ;
|
||||
if ( ! IsValid( pCC))
|
||||
return false ;
|
||||
if ( nType == 1) { // con linee
|
||||
PolyLine PL ;
|
||||
if ( ! GetPolyLineFromCurve( nSouId,frDest, dLinTol, PL) ||
|
||||
! pCC->FromPolyLine( PL))
|
||||
return false ;
|
||||
}
|
||||
else { // con bi-archi
|
||||
PolyArc PA ;
|
||||
if ( ! GetPolyArcFromCurve( nSouId,frDest, dLinTol, PA) ||
|
||||
! pCC->FromPolyArc( PA))
|
||||
return false ;
|
||||
}
|
||||
// inserisco la curva composita nel DB
|
||||
return AddGeoObj( vsParams[0], vsParams[1], ::Release( pCC)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::CurveCompoFromSplit( const STRVECTOR& vsParams)
|
||||
@@ -2279,7 +2330,7 @@ GdbExecutor::SurfTriMeshByContour( const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
// calcolo la polilinea che approssima la curva
|
||||
PolyLine PL ;
|
||||
if ( ! GetPolylineFromCurve( nIdCrv, frDest, dLinTol, PL))
|
||||
if ( ! GetPolyLineFromCurve( nIdCrv, frDest, dLinTol, PL))
|
||||
return false ;
|
||||
// creo la superficie
|
||||
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
|
||||
@@ -2311,7 +2362,7 @@ GdbExecutor::SurfTriMeshByExtrusion( const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
// calcolo la polilinea che approssima la curva
|
||||
PolyLine PL ;
|
||||
if ( ! GetPolylineFromCurve( nIdCrv, frDest, dLinTol, PL))
|
||||
if ( ! GetPolyLineFromCurve( nIdCrv, frDest, dLinTol, PL))
|
||||
return false ;
|
||||
// recupero il vettore di estrusione
|
||||
Vector3d vtExtr ;
|
||||
@@ -2347,13 +2398,13 @@ GdbExecutor::SurfTriMeshByTwoPaths( const STRVECTOR& vsParams)
|
||||
int nIdCrv1 = GetIdParam( vsParams[2]) ;
|
||||
// calcolo la polilinea che approssima la prima curva
|
||||
PolyLine PL1 ;
|
||||
if ( ! GetPolylineFromCurve( nIdCrv1, frDest, dLinTol, PL1))
|
||||
if ( ! GetPolyLineFromCurve( nIdCrv1, frDest, dLinTol, PL1))
|
||||
return false ;
|
||||
// recupero l'identificativo della seconda curva
|
||||
int nIdCrv2 = GetIdParam( vsParams[3]) ;
|
||||
// calcolo la polilinea che approssima la seconda curva
|
||||
PolyLine PL2 ;
|
||||
if ( ! GetPolylineFromCurve( nIdCrv2, frDest, dLinTol, PL2))
|
||||
if ( ! GetPolyLineFromCurve( nIdCrv2, frDest, dLinTol, PL2))
|
||||
return false ;
|
||||
// creo la superficie
|
||||
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
|
||||
@@ -2403,7 +2454,7 @@ GdbExecutor::SurfTriMeshByScrewing( bool bMove, const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
// calcolo la polilinea che approssima la curva
|
||||
PolyLine PL ;
|
||||
if ( ! GetPolylineFromCurve( nIdCrv, frDest, dLinTol, PL))
|
||||
if ( ! GetPolyLineFromCurve( nIdCrv, frDest, dLinTol, PL))
|
||||
return false ;
|
||||
// recupero il punto dell'asse di rivoluzione
|
||||
Point3d ptAx ;
|
||||
@@ -2436,7 +2487,7 @@ GdbExecutor::SurfTriMeshByScrewing( bool bMove, const STRVECTOR& vsParams)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::GetPolylineFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyLine& PL)
|
||||
GdbExecutor::GetPolyLineFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyLine& PL)
|
||||
{
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nId)) ;
|
||||
@@ -2468,6 +2519,40 @@ GdbExecutor::GetPolylineFromCurve( int nId, const Frame3d& frDest, double dLinTo
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::GetPolyArcFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyArc& PA)
|
||||
{
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nId)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento della curva
|
||||
Frame3d frCrv ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nId, frCrv))
|
||||
return false ;
|
||||
// calcolo la polilinea che approssima la curva
|
||||
// se i riferimenti sono uguali
|
||||
if ( AreSameFrame( frCrv, frDest)) {
|
||||
// ricavo l'approssimazione
|
||||
if ( ! pCrv->ApproxWithArcs( dLinTol, ANG_TOL_STD_DEG, PA))
|
||||
return false ;
|
||||
}
|
||||
// altrimenti devo prima trasformare la curva
|
||||
else {
|
||||
// creo una copia della curva (da buttare alla fine)
|
||||
PtrOwner<ICurve> pModCrv( pCrv->Clone()) ;
|
||||
if ( ! IsValid( pModCrv))
|
||||
return false ;
|
||||
// eseguo la trasformazione
|
||||
pModCrv->LocToLoc( frCrv, frDest) ;
|
||||
// ricavo l'approssimazione
|
||||
if ( ! pModCrv->ApproxWithArcs( dLinTol, ANG_TOL_STD_DEG, PA))
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::SurfTriMeshChangeSmoothAng( const STRVECTOR& vsParams)
|
||||
@@ -3294,14 +3379,13 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::GetPointsParam( const string& sParam, const Frame3d& frPnt, PNTVECTOR& vPoints)
|
||||
GdbExecutor::GetPointsParam( const string& sParam, const Frame3d& frPnt, PolyLine& PL)
|
||||
{
|
||||
// divido in parti
|
||||
STRVECTOR vsPoints ;
|
||||
Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsPoints) ;
|
||||
// converto in punti
|
||||
vPoints.clear() ;
|
||||
vPoints.reserve( vsPoints.size()) ;
|
||||
PL.Clear() ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsPoints.begin() ; Iter != vsPoints.end() ; ++Iter) {
|
||||
Trim( (*Iter), " \t\r\n") ;
|
||||
@@ -3309,17 +3393,17 @@ GdbExecutor::GetPointsParam( const string& sParam, const Frame3d& frPnt, PNTVECT
|
||||
int nId = m_pGDB->GetFirstSelectedObj() ;
|
||||
while ( nId != GDB_ID_NULL) {
|
||||
Point3d ptP ;
|
||||
if ( ! GetPointParam( ToString( nId), frPnt, ptP))
|
||||
if ( ! GetPointParam( ToString( nId), frPnt, ptP) ||
|
||||
! PL.AddUPoint( 0, ptP))
|
||||
return false ;
|
||||
vPoints.push_back( ptP) ;
|
||||
nId = m_pGDB->GetNextSelectedObj() ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Point3d ptP ;
|
||||
if ( ! GetPointParam( *Iter, frPnt, ptP))
|
||||
if ( ! GetPointParam( *Iter, frPnt, ptP) ||
|
||||
! PL.AddUPoint( 0, ptP))
|
||||
return false ;
|
||||
vPoints.push_back( ptP) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3370,21 +3454,21 @@ GdbExecutor::GetPointWParam( const string& sParam, const Frame3d& frPnt, Point3d
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::GetPointWsParam( const string& sParam, const Frame3d& frPnt, UPNTVECTOR& vPointWs)
|
||||
GdbExecutor::GetPointWsParam( const string& sParam, const Frame3d& frPnt, PolyArc& PA)
|
||||
{
|
||||
// divido in parti
|
||||
STRVECTOR vsPointWs ;
|
||||
Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsPointWs) ;
|
||||
// converto in punti
|
||||
vPointWs.clear() ;
|
||||
vPointWs.reserve( vsPointWs.size()) ;
|
||||
PA.Clear() ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsPointWs.begin() ; Iter != vsPointWs.end() ; ++Iter) {
|
||||
Trim( (*Iter), " \t\r\n") ;
|
||||
UPOINT ptPW ;
|
||||
if ( ! GetPointWParam( *Iter, frPnt, ptPW.second, ptPW.first))
|
||||
Point3d ptP ;
|
||||
double dBulge ;
|
||||
if ( ! GetPointWParam( *Iter, frPnt, ptP, dBulge) ||
|
||||
! PA.AddUPoint( 0, ptP, dBulge))
|
||||
return false ;
|
||||
vPointWs.push_back( ptPW) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
|
||||
Reference in New Issue
Block a user