EgtGraphics 1.6x3 :
- aggiunto oggetto MultiGraphics per accelerare visualizzazione Zmap in modifica.
This commit is contained in:
@@ -0,0 +1,202 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2017-2017
|
||||
//----------------------------------------------------------------------------
|
||||
// File : ObjMultiGraphics.cpp Data : 02.02.17 Versione : 1.6x3
|
||||
// Contenuto : Implementazione classe multi-grafica di un oggetto geometrico.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 02.02.17 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "ObjMultiGraphics.h"
|
||||
#include "ObjNewGraphics.h"
|
||||
#include "ObjOldGraphics.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ObjMultiGraphics::~ObjMultiGraphics( void)
|
||||
{
|
||||
for ( size_t i = 0 ; i < m_vOEGR.size() ; ++ i) {
|
||||
delete m_vOEGR[i] ;
|
||||
m_vOEGR[i] = nullptr ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
ObjMultiGraphics::Reset( void)
|
||||
{
|
||||
m_bValid = false ;
|
||||
m_nCurr = - 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
ObjMultiGraphics::SetScene( Scene* pScene)
|
||||
{
|
||||
m_pScene = pScene ;
|
||||
for ( size_t i = 0 ; i < m_vOEGR.size() ; ++ i)
|
||||
m_vOEGR[i]->SetScene( pScene) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjMultiGraphics::SetCurrent( int nCurr)
|
||||
{
|
||||
if ( nCurr < 0 || nCurr >= int( m_vOEGR.size())) {
|
||||
m_nCurr = - 1 ;
|
||||
return false ;
|
||||
}
|
||||
m_nCurr = nCurr ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
ObjMultiGraphics::Clear( void)
|
||||
{
|
||||
m_bValid = false ;
|
||||
if ( m_nCurr < 0 || m_nCurr >= int( m_vOEGR.size()))
|
||||
return ;
|
||||
m_vOEGR[m_nCurr]->Clear() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjMultiGraphics::AddColor( const Color& colC)
|
||||
{
|
||||
if ( m_nCurr < 0 || m_nCurr >= int( m_vOEGR.size()))
|
||||
return false ;
|
||||
return m_vOEGR[m_nCurr]->AddColor( colC) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjMultiGraphics::AddMaterial( const Color& colAmb, const Color& colDiff,
|
||||
const Color& colSpec, float fShin)
|
||||
{
|
||||
if ( m_nCurr < 0 || m_nCurr >= int( m_vOEGR.size()))
|
||||
return false ;
|
||||
return m_vOEGR[m_nCurr]->AddMaterial( colAmb, colDiff, colSpec, fShin) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjMultiGraphics::AddBackMaterial( const Color& colAmbDiff)
|
||||
{
|
||||
if ( m_nCurr < 0 || m_nCurr >= int( m_vOEGR.size()))
|
||||
return false ;
|
||||
return m_vOEGR[m_nCurr]->AddBackMaterial( colAmbDiff) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjMultiGraphics::AddPoint( const Point3d& ptP, bool bAux)
|
||||
{
|
||||
if ( m_nCurr < 0 || m_nCurr >= int( m_vOEGR.size()))
|
||||
return false ;
|
||||
m_bValid = true ;
|
||||
return m_vOEGR[m_nCurr]->AddPoint( ptP, bAux) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjMultiGraphics::AddLines( const PNTVECTOR& vPnt, bool bAux)
|
||||
{
|
||||
if ( m_nCurr < 0 || m_nCurr >= int( m_vOEGR.size()))
|
||||
return false ;
|
||||
m_bValid = true ;
|
||||
return m_vOEGR[m_nCurr]->AddLines( vPnt, bAux) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjMultiGraphics::AddPolyLine( const PolyLine& PL, bool bAux)
|
||||
{
|
||||
if ( m_nCurr < 0 || m_nCurr >= int( m_vOEGR.size()))
|
||||
return false ;
|
||||
m_bValid = true ;
|
||||
return m_vOEGR[m_nCurr]->AddPolyLine( PL, bAux) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjMultiGraphics::StartTriangles( int nNum, bool bAux)
|
||||
{
|
||||
if ( m_nCurr < 0 || m_nCurr >= int( m_vOEGR.size()))
|
||||
return false ;
|
||||
return m_vOEGR[m_nCurr]->StartTriangles( nNum, bAux) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjMultiGraphics::AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, const TriNormals3d& TNrms)
|
||||
{
|
||||
if ( m_nCurr < 0 || m_nCurr >= int( m_vOEGR.size()))
|
||||
return false ;
|
||||
return m_vOEGR[m_nCurr]->AddTriangle( Tria, TFlags, TNrms) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjMultiGraphics::EndTriangles( void)
|
||||
{
|
||||
if ( m_nCurr < 0 || m_nCurr >= int( m_vOEGR.size()))
|
||||
return false ;
|
||||
m_bValid = true ;
|
||||
return m_vOEGR[m_nCurr]->EndTriangles() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjMultiGraphics::Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bShowAux)
|
||||
{
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < m_vOEGR.size() ; ++ i) {
|
||||
if ( m_vOEGR[i] != nullptr &&
|
||||
m_vOEGR[i]->IsValid() &&
|
||||
! m_vOEGR[i]->Draw( nStat, nMark, bSurfSha, nAlpha, bShowAux))
|
||||
bOk = false ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjMultiGraphics::GetLocalBBox( BBox3d& b3Loc) const
|
||||
{
|
||||
// svuoto BBox
|
||||
m_b3Loc.Reset() ;
|
||||
// aggiorno il bbox con quello dei componenti
|
||||
for ( size_t i = 0 ; i < m_vOEGR.size() ; ++ i) {
|
||||
if ( m_vOEGR[i] != nullptr &&
|
||||
m_vOEGR[i]->IsValid()) {
|
||||
BBox3d b3Temp ;
|
||||
if ( m_vOEGR[i]->GetLocalBBox( b3Temp))
|
||||
m_b3Loc.Add( b3Temp) ;
|
||||
}
|
||||
}
|
||||
// copio
|
||||
b3Loc = m_b3Loc ;
|
||||
// verifico non sia vuoto
|
||||
return ! m_b3Loc.IsEmpty() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ObjMultiGraphics::ObjMultiGraphics( int nCount, bool bNewWay)
|
||||
{
|
||||
m_pScene = nullptr ;
|
||||
m_bValid = false ;
|
||||
m_vOEGR.reserve( nCount) ;
|
||||
for ( int i = 0 ; i < nCount ; ++ i) {
|
||||
if ( bNewWay)
|
||||
m_vOEGR.emplace_back( new ObjNewGraphics) ;
|
||||
else
|
||||
m_vOEGR.emplace_back( new ObjOldGraphics) ;
|
||||
}
|
||||
m_nCurr = - 1 ;
|
||||
}
|
||||
Reference in New Issue
Block a user