EgtGeomKernel 1.5f1 :

- aggiunta entità testo (con font Nfe e di sistema)
- in tutte le rotate ora l'angolo è in gradi
- aggiunta trasformazione Shear (scorrimento)
- aggiunta trsformazione LocToLoc
- Set/GetInfo specializzate per i diversi tipi di informazioni
- Copy e Relocate con possibilità di indicare l'entità di riferimento rispetto a cui inserire
- aggiunte trasformazioni a PolyLine.
This commit is contained in:
Dario Sassi
2014-06-03 13:19:54 +00:00
parent a52d73aa7a
commit 41a38fef3b
44 changed files with 3257 additions and 248 deletions
+208 -66
View File
@@ -306,16 +306,20 @@ GeomDB::GetGdbObj( int nId) const
//----------------------------------------------------------------------------
bool
GeomDB::InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter)
GeomDB::InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter, bool bTestId)
{
// verifico validità oggetto puntato
if ( pGObj == nullptr)
return false ;
// verifica validità e unicità del nome
if ( pGObj->m_nId <= GDB_ID_ROOT || ExistsObj( pGObj->m_nId))
// se richista, verifica validità e unicità del nome
if ( bTestId && ( pGObj->m_nId <= GDB_ID_ROOT || ExistsObj( pGObj->m_nId)))
return false ;
// oggetto e riferimento non possono essere la stessa cosa
if ( pGObj->m_nId == nRefId)
return ( nSonBeforeAfter != GDB_SON) ;
// cerco il riferimento
GdbObj* pGRef = GetGdbObj( nRefId) ;
if ( pGRef == nullptr)
@@ -341,8 +345,11 @@ GeomDB::InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter)
return false ;
}
// inserisco in mappa Id
return m_IdManager.AddObj( pGObj->m_nId, pGObj) ;
// se richiesto, inserisco in mappa Id
if ( bTestId)
return m_IdManager.AddObj( pGObj->m_nId, pGObj) ;
else
return true ;
}
//----------------------------------------------------------------------------
@@ -390,7 +397,7 @@ GeomDB::AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj)
//----------------------------------------------------------------------------
int
GeomDB::InsertGeoObj( int nId, int nRefId, int nBeforeAfter, IGeoObj* pGeoObj)
GeomDB::InsertGeoObj( int nId, int nRefId, int nSonBeforeAfter, IGeoObj* pGeoObj)
{
// assegno GeoObj a gestore puntatore con rilascio automatico
PtrOwner<IGeoObj> pRPGeoObj( pGeoObj) ;
@@ -411,7 +418,7 @@ GeomDB::InsertGeoObj( int nId, int nRefId, int nBeforeAfter, IGeoObj* pGeoObj)
// assegno dati
pGdbGeo->m_pGeoObj = Release( pRPGeoObj) ;
// inserisco nel DB
if ( ! InsertInGeomDB( pGdbGeo, nRefId, nBeforeAfter)) {
if ( ! InsertInGeomDB( pGdbGeo, nRefId, nSonBeforeAfter)) {
delete pGdbGeo ;
return GDB_ID_NULL ;
}
@@ -638,36 +645,7 @@ GeomDB::GetRefBBox( int nId, const Frame3d& frRef, BBox3d& b3Ref, int nFlag) con
//----------------------------------------------------------------------------
int
GeomDB::Copy( int nIdSou, int nIdDest, int nParentIdDest)
{
// verifico Id destinazione
if ( nIdDest <= GDB_ID_ROOT)
nIdDest = m_IdManager.GetNewId() ;
if ( ExistsObj( nIdDest))
return GDB_ID_NULL ;
// verifico esistenza del sorgente
GdbObj* pGdOSou ;
if ( ( pGdOSou = GetGdbObj( nIdSou)) == nullptr)
return GDB_ID_NULL ;
// eseguo la copia
GdbObj* pGdODest ;
if ( ( pGdODest = pGdOSou->Clone( nIdDest, m_IdManager)) == nullptr)
return GDB_ID_NULL ;
// inserisco nel DB
if ( ! InsertInGeomDB( pGdODest, nParentIdDest, GDB_SON)) {
delete pGdODest ;
return GDB_ID_NULL ;
}
return nIdDest ;
}
//----------------------------------------------------------------------------
int
GeomDB::CopyGlob( int nIdSou, int nIdDest, int nParentIdDest)
GeomDB::Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter, bool bGlob)
{
// verifico Id destinazione
if ( nIdDest <= GDB_ID_ROOT)
@@ -680,40 +658,53 @@ GeomDB::CopyGlob( int nIdSou, int nIdDest, int nParentIdDest)
if ( pGdOSou == nullptr)
return GDB_ID_NULL ;
// recupero il riferimento del sorgente
Frame3d frSou ;
if ( ! GetGlobFrame( nIdSou, frSou))
// verifico esistenza del padre
GdbGroup* pGroupSou = pGdOSou->GetParent() ;
if ( pGroupSou == nullptr)
return false ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! GetGroupGlobFrame( nParentIdDest, frDest))
// cerco il padre di destinazione
int nParentIdDest = (( nSonBeforeAfter == GDB_SON) ? nRefId : GetParentId( nRefId)) ;
GdbGroup* pGroupDest = GetGdbGroup( nParentIdDest) ;
if ( pGroupDest == nullptr)
return false ;
// eseguo la copia
GdbObj* pGdODest ;
if ( ( pGdODest = pGdOSou->Clone( nIdDest, m_IdManager)) == nullptr)
PtrOwner<GdbObj> pGdODest( pGdOSou->Clone( nIdDest, m_IdManager)) ;
if ( ! ::IsValid( pGdODest))
return GDB_ID_NULL ;
// porto la copia da riferimento sorgente a quello destinazione
if ( ! AreSameFrame( frSou, frDest)) {
pGdODest->ToGlob( frSou) ;
pGdODest->ToLoc( frDest) ;
}
// inserisco nel DB
if ( ! InsertInGeomDB( pGdODest, nParentIdDest, GDB_SON)) {
delete pGdODest ;
return GDB_ID_NULL ;
// se in globale
if ( bGlob) {
// recupero il riferimento del sorgente
Frame3d frSou ;
if ( ! pGroupSou->GetGlobFrame( frSou))
return GDB_ID_NULL ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! pGroupDest->GetGlobFrame( frDest))
return GDB_ID_NULL ;
// porto la copia da riferimento sorgente a quello destinazione
pGdODest->LocToLoc( frSou, frDest) ;
}
// inserisco nel DB (non rilascio il puntatore)
if ( ! InsertInGeomDB( ::Get( pGdODest), nRefId, nSonBeforeAfter))
return GDB_ID_NULL ;
// rilascio il puntatore
::Release( pGdODest) ;
return nIdDest ;
}
//----------------------------------------------------------------------------
bool
GeomDB::Relocate( int nId, int nNewParentId, bool bGlob)
GeomDB::Relocate( int nId, int nRefId, int nSonBeforeAfter, bool bGlob)
{
// l'oggetto e il riferimento non possono coincidere
if ( nId == nRefId)
return ( nSonBeforeAfter != GDB_SON) ;
// verifico esistenza dell'oggetto
GdbObj* pGdbObj = GetGdbObj( nId) ;
if ( pGdbObj == nullptr)
@@ -725,29 +716,27 @@ GeomDB::Relocate( int nId, int nNewParentId, bool bGlob)
return false ;
// cerco il nuovo padre
int nNewParentId = (( nSonBeforeAfter == GDB_SON) ? nRefId : GetParentId( nRefId)) ;
GdbGroup* pNewGroup = GetGdbGroup( nNewParentId) ;
if ( pNewGroup == nullptr)
return false ;
// se vecchio e nuovo padre coincidono, non devo fare alcunché
if ( pGroup->m_nId == pNewGroup->m_nId)
// se riferimento al padre e vecchio e nuovo padre coincidono, non devo fare alcunché
if ( nSonBeforeAfter == GDB_SON && pGroup->m_nId == pNewGroup->m_nId)
return true ;
// se rilocazione in globale
if ( bGlob) {
// recupero il riferimento del sorgente
Frame3d frCurr ;
Frame3d frCurr ;
if ( ! pGroup->GetGlobFrame( frCurr))
return false ;
// recupero il riferimento del nuovo padre
Frame3d frNew ;
Frame3d frNew ;
if ( ! pNewGroup->GetGlobFrame( frNew))
return false ;
// porto l'oggetto dal riferimento originale a quello nuovo
if ( ! AreSameFrame( frCurr, frNew)) {
pGdbObj->ToGlob( frCurr) ;
pGdbObj->ToLoc( frNew) ;
}
pGdbObj->LocToLoc( frCurr, frNew) ;
}
// sistemazioni in eventuali GdbIterator con quell'oggetto corrente
@@ -756,8 +745,8 @@ GeomDB::Relocate( int nId, int nNewParentId, bool bGlob)
// lo estraggo dalla posizione corrente del DB geometrico
pGdbObj->Remove() ;
// lo inserisco in coda alla lista del padre
if ( ! pGdbObj->AddTail( pNewGroup)) {
// lo inserisco nella posizione opportuna
if ( ! InsertInGeomDB( pGdbObj, nRefId, nSonBeforeAfter, false)) {
// in caso di errore (condizione assai remota qui) cancello tutto
m_IdManager.RemoveObj( pGdbObj->m_nId) ;
m_SelManager.RemoveObj( pGdbObj) ;
@@ -1031,6 +1020,69 @@ GeomDB::MirrorGroup( int nId, const Point3d& ptOn, const Vector3d& vtNorm)
return pGdbGroup->Mirror( ptOnLoc, vtNormLoc) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::Shear( int nId, const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
{
// recupero l'oggetto
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// eseguo l'operazione
return pGdbObj->Shear( ptOn, vtNorm, vtDir, dCoeff) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::ShearGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
{
// recupero l'oggetto
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frObj ;
if ( ! GetGlobFrame( nId, frObj))
return false ;
// porto i parametri di shear in locale
Point3d ptOnLoc = ptOn ;
if ( ! ptOnLoc.ToLoc( frObj))
return false ;
Vector3d vtNormLoc = vtNorm ;
if ( ! vtNormLoc.ToLoc( frObj))
return false ;
Vector3d vtDirLoc = vtDir ;
if ( ! vtDirLoc.ToLoc( frObj))
return false ;
// eseguo l'operazione
return pGdbObj->Shear( ptOnLoc, vtNormLoc, vtDirLoc, dCoeff) ;
}
//----------------------------------------------------------------------------
// La specchiatura è espressa nel riferimento del gruppo (ovvero il proprio).
//----------------------------------------------------------------------------
bool
GeomDB::ShearGroup( int nId, const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
{
// recupero il gruppo Gdb
GdbGroup* pGdbGroup ;
if ( ( pGdbGroup = GetGdbGroup( nId)) == nullptr)
return false ;
// utilizzo il riferimento proprio
// porto i parametri di mirror nel riferimento in cui è immerso
Point3d ptOnLoc = ptOn ;
if ( ! ptOnLoc.ToGlob( pGdbGroup->GetFrame()))
return false ;
Vector3d vtNormLoc = vtNorm ;
if ( ! vtNormLoc.ToGlob( pGdbGroup->GetFrame()))
return false ;
Vector3d vtDirLoc = vtDir ;
if ( ! vtDirLoc.ToLoc( pGdbGroup->GetFrame()))
return false ;
// eseguo l'operazione
return pGdbGroup->Shear( ptOnLoc, vtNormLoc, vtDirLoc, dCoeff) ;
}
//----------------------------------------------------------------------------
// Selection
//----------------------------------------------------------------------------
@@ -1798,6 +1850,48 @@ GeomDB::SetInfo( int nId, const string& sKey, const string& sInfo)
return pGdbObj->SetInfo( sKey, sInfo) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SetInfo( int nId, const string& sKey, bool bInfo)
{
return SetInfo( nId, sKey, ToString( bInfo)) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SetInfo( int nId, const string& sKey, int nInfo)
{
return SetInfo( nId, sKey, ToString( nInfo)) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SetInfo( int nId, const string& sKey, double dInfo)
{
return SetInfo( nId, sKey, ToString( dInfo)) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SetInfo( int nId, const string& sKey, const Point3d& ptInfo)
{
return SetInfo( nId, sKey, ToString( ptInfo)) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SetInfo( int nId, const string& sKey, const Vector3d& vtInfo)
{
return SetInfo( nId, sKey, ToString( vtInfo)) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SetInfo( int nId, const string& sKey, const Frame3d& frInfo)
{
return SetInfo( nId, sKey, ToString( frInfo)) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetInfo( int nId, const string& sKey, string& sInfo) const
@@ -1811,6 +1905,54 @@ GeomDB::GetInfo( int nId, const string& sKey, string& sInfo) const
return pGdbObj->GetInfo( sKey, sInfo) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetInfo( int nId, const string& sKey, bool& bInfo) const
{
string sInfo ;
return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, bInfo)) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetInfo( int nId, const string& sKey, int& nInfo) const
{
string sInfo ;
return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, nInfo)) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetInfo( int nId, const string& sKey, double& dInfo) const
{
string sInfo ;
return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, dInfo)) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetInfo( int nId, const string& sKey, Point3d& ptInfo) const
{
string sInfo ;
return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, ptInfo)) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetInfo( int nId, const string& sKey, Vector3d& vtInfo) const
{
string sInfo ;
return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, vtInfo)) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetInfo( int nId, const string& sKey, Frame3d& frInfo) const
{
string sInfo ;
return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, frInfo)) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::ExistsInfo( int nId, const string& sKey) const