EgtGeomKernel 1.5d2 :

- creazione di superfici trimesh da piani contornati e per estrusione
- migliorie a PolyLine
- migliorie a FromString
- modifiche a Vector3d e Point3d.
This commit is contained in:
Dario Sassi
2014-04-09 13:00:17 +00:00
parent d509417136
commit 9b564445cd
15 changed files with 771 additions and 119 deletions
+130
View File
@@ -100,6 +100,8 @@ GdbExecutor::GdbExecutor( void)
m_ExecMgr.Insert( "MIRROR", &GdbExecutor::ExecuteMirror) ;
m_ExecMgr.Insert( "INVC", &GdbExecutor::ExecuteInvertCurve) ;
m_ExecMgr.Insert( "INVERTCURVE", &GdbExecutor::ExecuteInvertCurve) ;
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( "NEW", &GdbExecutor::ExecuteNew) ;
@@ -697,6 +699,7 @@ GdbExecutor::ExecuteCurveCompo( const string& sCmd2, const STRVECTOR& vsParams)
bool
GdbExecutor::ExecuteSurfTriMesh( const string& sCmd2, const STRVECTOR& vsParams)
{
// se inizio creazione con componenti elementari
if ( sCmd2 == "BEGIN") {
// 2 parametri opzionali : numero vertici e numero triangoli
if ( vsParams.size() > 2)
@@ -719,6 +722,7 @@ GdbExecutor::ExecuteSurfTriMesh( const string& sCmd2, const STRVECTOR& vsParams)
m_pGeoObj = pSTM ;
return true ;
}
// se nuovo vertice
else if ( sCmd2 == "VERT" || sCmd2 == "ADDVERTEX") {
// 1 parametro : punto
if ( vsParams.size() != 1)
@@ -734,6 +738,7 @@ GdbExecutor::ExecuteSurfTriMesh( const string& sCmd2, const STRVECTOR& vsParams)
// aggiungo il vertice
return ( pSTM->AddVertex( ptP) != -1) ;
}
// se nuovo triangolo
else if ( sCmd2 == "TRIA" || sCmd2 == "ADDTRIANGLE") {
// 3 parametri : IdV1, IdV2, IdV3
if ( vsParams.size() != 3)
@@ -751,6 +756,7 @@ GdbExecutor::ExecuteSurfTriMesh( const string& sCmd2, const STRVECTOR& vsParams)
// aggiungo il triangolo definito con gli indici dei 3 vertici
return ( pSTM->AddTriangle( nIdVert) != -1) ;
}
// se fine creazione
else if ( sCmd2 == "END") {
// 2 parametri : Id e ParentId
if ( vsParams.size() != 2)
@@ -766,6 +772,108 @@ GdbExecutor::ExecuteSurfTriMesh( const string& sCmd2, const STRVECTOR& vsParams)
m_pGeoObj = nullptr ;
return AddGeoObj( vsParams[0], vsParams[1], pSTM) ;
}
// se creazione per triangolazione di un contorno chiuso e piano
else if ( sCmd2 == "CONT" || sCmd2 == "BYCONTOUR") {
// 3 parametri : Id, ParentId, IdCurve
if ( vsParams.size() != 3)
return false ;
// recupero la curva
int nIdCrv = GetIdParam( vsParams[2]) ;
const ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nIdCrv)) ;
if ( pCrv == nullptr)
return false ;
// recupero il riferimento della curva
Frame3d frCrv ;
if ( ! m_pGDB->GetGlobFrame( nIdCrv, frCrv))
return false ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
return false ;
// calcolo la polilinea che approssima la curva
PolyLine PL ;
// se i riferimenti sono uguali
if ( AreSameFrame( frCrv, frDest)) {
// ricavo l'approssimazione
if ( ! pCrv->ApproxWithLines( 0.01, 15, PL))
return false ;
}
// altrimenti devo prima trasformare la curva
else {
// creo una copia della curva (da buttare alla fine)
PtrOwner<ICurve> pModCrv( GetCurve( pCrv->Clone())) ;
if ( ! IsValid( pModCrv))
return false ;
// eseguo la trasformazione
pModCrv->ToGlob( frCrv) ;
pModCrv->ToLoc( frDest) ;
// ricavo l'approssimazione
if ( ! pCrv->ApproxWithLines( 0.01, 15, PL))
return false ;
}
// creo la superficie
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
if ( ! IsValid( pSTM))
return false ;
// costruisco la triangolazione
if ( ! pSTM->CreateByTriangulation( PL))
return false ;
// inserisco la superficie trimesh nel DB
return AddGeoObj( vsParams[0], vsParams[1], Release( pSTM)) ;
}
// se creazione per estrusione
else if ( sCmd2 == "EXTR" || sCmd2 == "BYEXTRUSION") {
// 4 parametri : Id, ParentId, IdCurve, vtExtr
if ( vsParams.size() != 4)
return false ;
// recupero la curva
int nIdCrv = GetIdParam( vsParams[2]) ;
const ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nIdCrv)) ;
if ( pCrv == nullptr)
return false ;
// recupero il riferimento della curva
Frame3d frCrv ;
if ( ! m_pGDB->GetGlobFrame( nIdCrv, frCrv))
return false ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
return false ;
// calcolo la polilinea che approssima la curva
PolyLine PL ;
// se i riferimenti sono uguali
if ( AreSameFrame( frCrv, frDest)) {
// ricavo l'approssimazione
if ( ! pCrv->ApproxWithLines( 0.01, 15, PL))
return false ;
}
// altrimenti devo prima trasformare la curva
else {
// creo una copia della curva (da buttare alla fine)
PtrOwner<ICurve> pModCrv( GetCurve( pCrv->Clone())) ;
if ( ! IsValid( pModCrv))
return false ;
// eseguo la trasformazione
pModCrv->ToGlob( frCrv) ;
pModCrv->ToLoc( frDest) ;
// ricavo l'approssimazione
if ( ! pCrv->ApproxWithLines( 0.01, 15, PL))
return false ;
}
// recupero il vettore di estrusione
Vector3d vtExtr ;
if ( ! GetVectorParam( vsParams[3], vtExtr))
return false ;
// creo la superficie
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
if ( ! IsValid( pSTM))
return false ;
// costruisco l'estrusione
if ( ! pSTM->CreateByExtrusion( PL, vtExtr))
return false ;
// inserisco la superficie trimesh nel DB
return AddGeoObj( vsParams[0], vsParams[1], Release( pSTM)) ;
}
else
return false ;
}
@@ -1598,6 +1706,28 @@ GdbExecutor::ExecuteInvertCurve( const std::string& sCmd2, const STRVECTOR& vsPa
return true ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteInvertSurf( const std::string& sCmd2, const STRVECTOR& vsParams)
{
// 1 parametro ( Nome/i)
if ( vsParams.size() != 1)
return false ;
// recupero lista nomi
INTVECTOR vnNames ;
if ( ! GetNamesParam( vsParams[0], vnNames))
return false ;
// esecuzione inversione normale superficie
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
ISurf* pSurf = GetSurf( m_pGDB->GetGeoObj( *Iter)) ;
if ( pSurf == nullptr || ! pSurf->Invert())
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteTrimCurve( const std::string& sCmd2, const STRVECTOR& vsParams)