45e3e41eac
- ricompilato.
503 lines
18 KiB
C++
503 lines
18 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : MachMgr.cpp Data : 16.04.15 Versione : 1.6d3
|
|
// Contenuto : Implementazione gestione grezzi e pezzi della classe MachMgr.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 16.04.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "DllMain.h"
|
|
#include "MachMgr.h"
|
|
#include "MachConst.h"
|
|
#include "Disposition.h"
|
|
#include "/EgtDev/Include/EGkCurveComposite.h"
|
|
#include "/EgtDev/Include/EGkGdbIterator.h"
|
|
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
|
#include "/EgtDev/Include/EGkStmStandard.h"
|
|
#include "/EgtDev/Include/EGkStmFromCurves.h"
|
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
MachMgr::GetRawPartCount( void) const
|
|
{
|
|
// recupero il gruppo dei grezzi nella macchinata corrente
|
|
int nRawGroupId = GetCurrRawGroupId() ;
|
|
if ( nRawGroupId == GDB_ID_NULL)
|
|
return 0 ;
|
|
// ritorno numero dei grezzi della macchinata
|
|
return m_pGeomDB->GetGroupObjs( nRawGroupId) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
MachMgr::GetFirstRawPart( void) const
|
|
{
|
|
// recupero il gruppo dei grezzi nella macchinata corrente
|
|
int nRawGroupId = GetCurrRawGroupId() ;
|
|
if ( nRawGroupId == GDB_ID_NULL)
|
|
return GDB_ID_NULL ;
|
|
// recupero il primo sottogruppo
|
|
int nId = m_pGeomDB->GetFirstGroupInGroup( nRawGroupId) ;
|
|
return nId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
MachMgr::GetNextRawPart( int nId) const
|
|
{
|
|
// recupero il gruppo dei grezzi nella macchinata corrente
|
|
int nRawGroupId = GetCurrRawGroupId() ;
|
|
if ( nRawGroupId == GDB_ID_NULL)
|
|
return GDB_ID_NULL ;
|
|
// verifico che il gruppo ricevuto sia corretto
|
|
if ( m_pGeomDB->GetParentId( nId) != nRawGroupId)
|
|
return GDB_ID_NULL ;
|
|
// recupero il successivo sottogruppo
|
|
int nNextId = m_pGeomDB->GetNextGroup( nId) ;
|
|
return nNextId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
MachMgr::AddRawPart( const Point3d& ptOrig, double dLen, double dWidth, double dHeight, Color cCol)
|
|
{
|
|
// recupero il gruppo dei grezzi nella macchinata corrente
|
|
int nRawGroupId = GetCurrRawGroupId() ;
|
|
if ( nRawGroupId == GDB_ID_NULL)
|
|
return GDB_ID_NULL ;
|
|
// creo il solido
|
|
PtrOwner<ISurfTriMesh> pStm( GetSurfTriMeshBox( dLen, dWidth, dHeight)) ;
|
|
if ( IsNull( pStm))
|
|
return GDB_ID_NULL ;
|
|
// inserisco il gruppo del grezzo nei grezzi della macchinata
|
|
int nRawId = m_pGeomDB->AddGroup( GDB_ID_NULL, nRawGroupId, Frame3d( ptOrig)) ;
|
|
if ( nRawId == GDB_ID_NULL)
|
|
return GDB_ID_NULL ;
|
|
// assegno il nome al gruppo
|
|
bool bOk = m_pGeomDB->SetName( nRawId, MACH_RAW_PART) ;
|
|
// inserisco il solido nel gruppo
|
|
int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nRawId, Release( pStm)) ;
|
|
bOk = bOk && ( nId != GDB_ID_NULL) ;
|
|
// assegno il nome al solido
|
|
bOk = bOk && m_pGeomDB->SetName( nId, MACH_RAW_SOLID) ;
|
|
// assegno il colore al solido
|
|
bOk = bOk && m_pGeomDB->SetMaterial( nId, cCol) ;
|
|
// calcolo il punto centro del solido
|
|
bOk = bOk && SetRawPartCenter( nRawId) ;
|
|
// se qualcosa è andato storto, cancello tutto
|
|
if ( ! bOk) {
|
|
m_pGeomDB->Erase( nRawId) ;
|
|
return GDB_ID_NULL ;
|
|
}
|
|
// tutto ok
|
|
return nRawId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
MachMgr::AddRawPart( int nCrvId, double dOverMat, double dZmin, double dHeight, Color cCol)
|
|
{
|
|
// recupero il gruppo dei grezzi nella macchinata corrente
|
|
int nRawGroupId = GetCurrRawGroupId() ;
|
|
if ( nRawGroupId == GDB_ID_NULL)
|
|
return GDB_ID_NULL ;
|
|
// recupero l'ingombro della curva in globale
|
|
BBox3d b3Crv ;
|
|
if ( ! m_pGeomDB->GetGlobalBBox( nCrvId, b3Crv))
|
|
return GDB_ID_NULL ;
|
|
// recupero il riferimento della curva
|
|
Frame3d frCrv ;
|
|
if ( ! m_pGeomDB->GetGlobFrame( nCrvId, frCrv))
|
|
return GDB_ID_NULL ;
|
|
// recupero la curva
|
|
const ICurve* pCrv = GetCurve( m_pGeomDB->GetGeoObj( nCrvId)) ;
|
|
if ( pCrv == nullptr)
|
|
return GDB_ID_NULL ;
|
|
// copio la curva in una composita
|
|
PtrOwner<ICurveComposite> pMyCrv( CreateCurveComposite()) ;
|
|
if ( IsNull( pMyCrv) || ! pMyCrv->AddCurve( *pCrv))
|
|
return GDB_ID_NULL ;
|
|
// determino il riferimento del grezzo
|
|
Point3d ptOrig = b3Crv.GetMin() ;
|
|
ptOrig.z = dZmin ;
|
|
Frame3d frRaw( ptOrig) ;
|
|
// porto la curva in questo riferimento
|
|
pMyCrv->LocToLoc( frCrv, frRaw) ;
|
|
// la schiaccio a Z = 0
|
|
if ( ! pMyCrv->Scale( Frame3d(), 1, 1, 0))
|
|
return GDB_ID_NULL ;
|
|
// se non è chiusa, la chiudo
|
|
if ( ! pMyCrv->IsClosed())
|
|
pMyCrv->Close() ;
|
|
// la oriento in senso CCW
|
|
double dAreaXY ;
|
|
if ( ! pMyCrv->GetAreaXY( dAreaXY))
|
|
return GDB_ID_NULL ;
|
|
if ( dAreaXY < 0)
|
|
pMyCrv->Invert() ;
|
|
// ne eseguo l'offset
|
|
if ( ! pMyCrv->SimpleOffset( dOverMat, ICurve::OFF_EXTEND))
|
|
return GDB_ID_NULL ;
|
|
// creo il solido
|
|
PtrOwner<ISurfTriMesh> pStm( GetSurfTriMeshByExtrusion( Get( pMyCrv), Vector3d(0,0,dHeight), true)) ;
|
|
if ( IsNull( pStm))
|
|
return GDB_ID_NULL ;
|
|
// inserisco il gruppo del grezzo nella macchinata
|
|
int nRawId = m_pGeomDB->AddGroup( GDB_ID_NULL, nRawGroupId, frRaw) ;
|
|
if ( nRawId == GDB_ID_NULL)
|
|
return GDB_ID_NULL ;
|
|
// assegno il nome al gruppo
|
|
bool bOk = m_pGeomDB->SetName( nRawId, MACH_RAW_PART) ;
|
|
// inserisco il solido nel gruppo
|
|
int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nRawId, Release( pStm)) ;
|
|
bOk = bOk && ( nId != GDB_ID_NULL) ;
|
|
// assegno il nome al solido
|
|
bOk = bOk && m_pGeomDB->SetName( nId, MACH_RAW_SOLID) ;
|
|
// assegno il colore al solido
|
|
bOk = bOk && m_pGeomDB->SetMaterial( nId, cCol) ;
|
|
// calcolo il punto centro del solido
|
|
bOk = bOk && SetRawPartCenter( nRawId) ;
|
|
// se qualcosa è andato storto, cancello tutto
|
|
if ( ! bOk) {
|
|
m_pGeomDB->Erase( nRawId) ;
|
|
return GDB_ID_NULL ;
|
|
}
|
|
// tutto ok
|
|
return nRawId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
MachMgr::AddRawPart( int nSurfId, Color cCol)
|
|
{
|
|
// recupero il gruppo dei grezzi nella macchinata corrente
|
|
int nRawGroupId = GetCurrRawGroupId() ;
|
|
if ( nRawGroupId == GDB_ID_NULL)
|
|
return GDB_ID_NULL ;
|
|
// recupero l'ingombro della superficie in globale
|
|
BBox3d b3Crv ;
|
|
if ( ! m_pGeomDB->GetGlobalBBox( nSurfId, b3Crv))
|
|
return GDB_ID_NULL ;
|
|
// inserisco il gruppo del grezzo nella macchinata
|
|
Frame3d frRaw( b3Crv.GetMin()) ;
|
|
int nRawId = m_pGeomDB->AddGroup( GDB_ID_NULL, nRawGroupId, frRaw) ;
|
|
if ( nRawId == GDB_ID_NULL)
|
|
return GDB_ID_NULL ;
|
|
// assegno il nome al gruppo
|
|
bool bOk = m_pGeomDB->SetName( nRawId, MACH_RAW_PART) ;
|
|
// copio la superficie nel gruppo
|
|
int nId = m_pGeomDB->CopyGlob( nSurfId, GDB_ID_NULL, nRawId) ;
|
|
bOk = bOk && ( nId != GDB_ID_NULL) ;
|
|
// assegno il nome al solido
|
|
bOk = bOk && m_pGeomDB->SetName( nId, MACH_RAW_SOLID) ;
|
|
// assegno il colore al solido
|
|
bOk = bOk && m_pGeomDB->SetMaterial( nId, cCol) ;
|
|
// rendo visibile il solido
|
|
bOk = bOk && m_pGeomDB->SetStatus( nId, GDB_ST_ON) ;
|
|
// calcolo il punto centro del solido
|
|
bOk = bOk && SetRawPartCenter( nRawId) ;
|
|
// se qualcosa è andato storto, cancello tutto
|
|
if ( ! bOk) {
|
|
m_pGeomDB->Erase( nRawId) ;
|
|
return GDB_ID_NULL ;
|
|
}
|
|
// nascondo la superficie originale
|
|
m_pGeomDB->SetStatus( nSurfId, GDB_ST_OFF) ;
|
|
// tutto ok
|
|
return nRawId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
MachMgr::AddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color cCol)
|
|
{
|
|
// verifico il gruppo dei grezzi nella macchinata corrente
|
|
if ( GetCurrRawGroupId() == GDB_ID_NULL)
|
|
return GDB_ID_NULL ;
|
|
// verifico che il pezzo non sia già usato nella macchinata corrente
|
|
if ( m_pGeomDB->GetParentId( nPartId) != GDB_ID_ROOT)
|
|
return GDB_ID_NULL ;
|
|
// recupero il tipo di oggetto per definire il grezzo
|
|
int nGtype = m_pGeomDB->GetGeoType( nCrvSrfId) ;
|
|
// costruzione del grezzo
|
|
int nRawId = GDB_ID_NULL ;
|
|
// se grezzo da superficie (per ora senza possibilità di offset)
|
|
if ( ( nGtype & GEO_SURF) != 0) {
|
|
// inserisco il grezzo
|
|
nRawId = AddRawPart( nCrvSrfId, cCol) ;
|
|
}
|
|
// se altrimenti grezzo da contorno
|
|
else if ( ( nGtype & GEO_CURVE) != 0) {
|
|
// determino l'ingombro del pezzo
|
|
BBox3d b3Part ;
|
|
if ( ! m_pGeomDB->GetGlobalBBox( nPartId, b3Part))
|
|
return GDB_ID_NULL ;
|
|
// inserisco il grezzo
|
|
double dZmin = b3Part.GetMin().z ;
|
|
double dH = ( b3Part.GetMax() - b3Part.GetMin()).z ;
|
|
if ( dH < RAW_MIN_H)
|
|
dH = RAW_MIN_H ;
|
|
nRawId = AddRawPart( nCrvSrfId, dOverMat, dZmin, dH, cCol) ;
|
|
}
|
|
// altrimenti grezzo rettangolare da ingombro pezzo
|
|
else {
|
|
// determino l'ingombro del pezzo
|
|
BBox3d b3Part ;
|
|
if ( ! m_pGeomDB->GetGlobalBBox( nPartId, b3Part))
|
|
return GDB_ID_NULL ;
|
|
// deduco i dati del grezzo
|
|
Point3d ptMin = b3Part.GetMin() - Vector3d( dOverMat, dOverMat, 0) ;
|
|
Point3d ptMax = b3Part.GetMax() + Vector3d( dOverMat, dOverMat, 0) ;
|
|
Vector3d vtDiff = ptMax - ptMin ;
|
|
if ( vtDiff.z < RAW_MIN_H)
|
|
vtDiff.z = RAW_MIN_H ;
|
|
// inserisco il grezzo
|
|
nRawId = AddRawPart( ptMin, vtDiff.x, vtDiff.y, vtDiff.z, cCol) ;
|
|
}
|
|
// verifico costruzione grezzo
|
|
if ( nRawId == GDB_ID_NULL)
|
|
return GDB_ID_NULL ;
|
|
// inserisco il pezzo nel grezzo
|
|
if ( ! AddPartToRawPart( nPartId, nRawId)) {
|
|
RemoveRawPart( nRawId) ;
|
|
return GDB_ID_NULL ;
|
|
}
|
|
return nRawId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::ModifyRawPartSize( int nRawId, double dLength, double dWidth, double dHeight)
|
|
{
|
|
// le nuove dimensioni non possono essere nulle
|
|
if ( dLength < EPS_SMALL || dWidth < EPS_SMALL || dHeight < EPS_SMALL)
|
|
return false ;
|
|
// verifica validità grezzo
|
|
if ( ! VerifyRawPart( nRawId))
|
|
return false ;
|
|
// recupero il solido del grezzo
|
|
int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
|
if ( nRawSolId == GDB_ID_NULL)
|
|
return false ;
|
|
// recupero il box del grezzo
|
|
BBox3d b3Raw ;
|
|
if ( ! m_pGeomDB->GetLocalBBox( nRawSolId, b3Raw))
|
|
return false ;
|
|
// determino il coefficente di scalatura in X
|
|
double dOldL = b3Raw.GetMax().x - b3Raw.GetMin().x ;
|
|
if ( dOldL < EPS_SMALL)
|
|
return false ;
|
|
double dCoeffX = dLength / dOldL ;
|
|
// determino il coefficente di scalatura in Y
|
|
double dOldW = b3Raw.GetMax().y - b3Raw.GetMin().y ;
|
|
if ( dOldW < EPS_SMALL)
|
|
return false ;
|
|
double dCoeffY = dWidth / dOldW ;
|
|
// determino il coefficente di scalatura in Z
|
|
double dOldH = b3Raw.GetMax().z - b3Raw.GetMin().z ;
|
|
if ( dOldH < EPS_SMALL)
|
|
return false ;
|
|
double dCoeffZ = dHeight / dOldH ;
|
|
// eseguo scalatura
|
|
bool bOk = m_pGeomDB->Scale( nRawSolId, Frame3d( b3Raw.GetMin()), dCoeffX, dCoeffY, dCoeffZ) ;
|
|
// dichiaro centro da ricalcolare
|
|
ResetRawPartCenter( nRawId) ;
|
|
return bOk ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::ModifyRawPartHeight( int nRawId, double dHeight)
|
|
{
|
|
// la nuova altezza non può essere nulla
|
|
if ( dHeight < EPS_SMALL)
|
|
return false ;
|
|
// verifica validità grezzo
|
|
if ( ! VerifyRawPart( nRawId))
|
|
return false ;
|
|
// recupero il solido del grezzo
|
|
int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
|
if ( nRawSolId == GDB_ID_NULL)
|
|
return false ;
|
|
// recupero il box del grezzo
|
|
BBox3d b3Raw ;
|
|
if ( ! m_pGeomDB->GetLocalBBox( nRawSolId, b3Raw))
|
|
return false ;
|
|
// determino il coefficente di scalatura in Z
|
|
double dOldH = b3Raw.GetMax().z - b3Raw.GetMin().z ;
|
|
if ( dOldH < EPS_SMALL)
|
|
return false ;
|
|
double dCoeff = dHeight / dOldH ;
|
|
// eseguo scalatura
|
|
bool bOk = m_pGeomDB->Scale( nRawSolId, Frame3d( b3Raw.GetMin()), 1, 1, dCoeff) ;
|
|
// dichiaro centro da ricalcolare
|
|
ResetRawPartCenter( nRawId) ;
|
|
return bOk ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::RemoveRawPart( int nRawId)
|
|
{
|
|
// verifica validità grezzo
|
|
if ( ! VerifyRawPart( nRawId))
|
|
return false ;
|
|
// devo estrarre i pezzi e riportarli in lista generale
|
|
SwapRawPartParts( nRawId, false) ;
|
|
// cancello il grezzo
|
|
m_pGeomDB->Erase( nRawId) ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::VerifyRawPart( int nRawId) const
|
|
{
|
|
// recupero il gruppo dei grezzi nella macchinata corrente
|
|
int nRawGroupId = GetCurrRawGroupId() ;
|
|
if ( nRawGroupId == GDB_ID_NULL)
|
|
return false ;
|
|
// verifico che questo grezzo ne faccia parte
|
|
if ( m_pGeomDB->GetParentId( nRawId) != nRawGroupId)
|
|
return false ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg)
|
|
{
|
|
// recupero la prima operazione, deve essere la disposizione
|
|
int nDispId = GetFirstOperation() ;
|
|
// recupero l'oggetto disposizione
|
|
Disposition* pDisp = dynamic_cast<Disposition*>( m_pGeomDB->GetUserObj( nDispId)) ;
|
|
if ( pDisp == nullptr)
|
|
return false ;
|
|
// eseguo l'operazione
|
|
return pDisp->RotateRawPart( nRawId, vtAx, dAngRotDeg) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::MoveToCornerRawPart( int nRawId, const Point3d& ptP, int nFlag)
|
|
{
|
|
// recupero la prima operazione, deve essere la disposizione
|
|
int nDispId = GetFirstOperation() ;
|
|
// recupero l'oggetto disposizione
|
|
Disposition* pDisp = dynamic_cast<Disposition*>( m_pGeomDB->GetUserObj( nDispId)) ;
|
|
if ( pDisp == nullptr)
|
|
return false ;
|
|
// eseguo l'operazione
|
|
return pDisp->MoveToCornerRawPart( nRawId, ptP, nFlag) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag)
|
|
{
|
|
// recupero la prima operazione, deve essere la disposizione
|
|
int nDispId = GetFirstOperation() ;
|
|
// recupero l'oggetto disposizione
|
|
Disposition* pDisp = dynamic_cast<Disposition*>( m_pGeomDB->GetUserObj( nDispId)) ;
|
|
if ( pDisp == nullptr)
|
|
return false ;
|
|
// eseguo l'operazione
|
|
return pDisp->MoveToCenterRawPart( nRawId, ptP, nFlag) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::MoveRawPart( int nRawId, const Vector3d& vtMove)
|
|
{
|
|
// recupero la prima operazione, deve essere la disposizione
|
|
int nDispId = GetFirstOperation() ;
|
|
// recupero l'oggetto disposizione
|
|
Disposition* pDisp = dynamic_cast<Disposition*>( m_pGeomDB->GetUserObj( nDispId)) ;
|
|
if ( pDisp == nullptr)
|
|
return false ;
|
|
// eseguo l'operazione
|
|
return pDisp->MoveRawPart( nRawId,vtMove) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::SetRawPartCenter( int nRawId)
|
|
{
|
|
// recupero il solido
|
|
int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
|
const ISurfTriMesh* pStm = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nRawSolId)) ;
|
|
if ( pStm == nullptr)
|
|
return false ;
|
|
// recupero il punto centro, se non esiste lo creo
|
|
int nGPntId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_CENTER) ;
|
|
if ( nGPntId == GDB_ID_NULL) {
|
|
PtrOwner<IGeoPoint3d> pGeoPnt( CreateGeoPoint3d()) ;
|
|
nGPntId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nRawId, Release( pGeoPnt)) ;
|
|
m_pGeomDB->SetName( nGPntId, MACH_RAW_CENTER) ;
|
|
Color cCol ;
|
|
if ( m_pGeomDB->GetCalcMaterial( nRawSolId, cCol))
|
|
m_pGeomDB->SetMaterial( nGPntId, cCol) ;
|
|
}
|
|
IGeoPoint3d* pGeoPnt = GetGeoPoint3d( m_pGeomDB->GetGeoObj( nGPntId)) ;
|
|
if ( pGeoPnt == nullptr)
|
|
return false ;
|
|
// calcolo il valore del centro
|
|
Point3d ptCen ;
|
|
if ( ! pStm->GetCentroid( ptCen))
|
|
return false ;
|
|
// aggiorno e imposto modo a standard
|
|
return ( pGeoPnt->Set( ptCen) && m_pGeomDB->SetMode( nGPntId, GDB_MD_STD)) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::ResetRawPartCenter( int nRawId)
|
|
{
|
|
// recupero il punto centro
|
|
int nGPntId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_CENTER) ;
|
|
if ( nGPntId == GDB_ID_NULL)
|
|
return true ;
|
|
// imposto modo a bloccato
|
|
return m_pGeomDB->SetMode( nGPntId, GDB_MD_HIDDEN) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::GetRawPartCenter( int nRawId, Point3d& ptCen)
|
|
{
|
|
// cerco di recuperare l'oggetto
|
|
int nGPntId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_CENTER) ;
|
|
// ne verifico la validità
|
|
int nMode ;
|
|
if ( nGPntId == GDB_ID_NULL ||
|
|
! m_pGeomDB->GetMode( nGPntId, nMode) || nMode != GDB_MD_STD) {
|
|
// provo a crearlo
|
|
SetRawPartCenter( nRawId) ;
|
|
nGPntId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_CENTER) ;
|
|
// se c'è ancora errore
|
|
if ( nGPntId == GDB_ID_NULL)
|
|
return false ;
|
|
}
|
|
// ne recupero il riferimento globale
|
|
Frame3d frGPnt ;
|
|
if ( ! m_pGeomDB->GetGlobFrame( nGPntId, frGPnt))
|
|
return false ;
|
|
// recupero il punto
|
|
IGeoPoint3d* pGeoPnt = GetGeoPoint3d( m_pGeomDB->GetGeoObj( nGPntId)) ;
|
|
if ( pGeoPnt == nullptr)
|
|
return false ;
|
|
ptCen = pGeoPnt->GetPoint() ;
|
|
ptCen.ToGlob( frGPnt) ;
|
|
return true ;
|
|
}
|