EgtGraphics 1.6x3 :

- aggiunto oggetto MultiGraphics per accelerare visualizzazione Zmap in modifica.
This commit is contained in:
Dario Sassi
2017-02-02 20:01:05 +00:00
parent e44c4709ce
commit 912e699047
9 changed files with 372 additions and 74 deletions
BIN
View File
Binary file not shown.
+2
View File
@@ -226,6 +226,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="..\Include\EGrScene.h" />
<ClInclude Include="DllMain.h" />
<ClInclude Include="EGrUtils.h" />
<ClInclude Include="ObjMultiGraphics.h" />
<ClInclude Include="SceExecutor.h" />
<ClInclude Include="GraphObjs.h" />
<ClInclude Include="ObjEGrGraphics.h" />
@@ -239,6 +240,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
</ItemGroup>
<ItemGroup>
<ClCompile Include="EGrDllMain.cpp" />
<ClCompile Include="ObjMultiGraphics.cpp" />
<ClCompile Include="SceExecutor.cpp" />
<ClCompile Include="ObjNewGraphics.cpp" />
<ClCompile Include="ObjOldGraphics.cpp" />
+6
View File
@@ -81,6 +81,9 @@
<ClInclude Include="TextureMgr.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="ObjMultiGraphics.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
@@ -128,6 +131,9 @@
<ClCompile Include="SceneTexture.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="ObjMultiGraphics.cpp">
<Filter>File di origine</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="EgtGraphics.rc">
+1
View File
@@ -31,6 +31,7 @@ class ObjEGrGraphics : public IObjGraphics
virtual bool IsValid( void) = 0 ;
virtual void SetScene( Scene* pScene) = 0 ;
virtual Scene* GetScene( void) = 0 ;
virtual bool SetCurrent( int nCurr) { return false ; } ;
virtual void Clear( void) = 0 ;
virtual bool AddColor( const Color& colC) = 0 ;
virtual bool AddMaterial( const Color& colAmb, const Color& colDiff,
+202
View File
@@ -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 ;
}
+56
View File
@@ -0,0 +1,56 @@
//----------------------------------------------------------------------------
// EgalTech 2017-2017
//----------------------------------------------------------------------------
// File : ObjMultiGraphics.h Data : 02.02.17 Versione : 1.6x3
// Contenuto : Dichiarazione classe multi-grafica di un oggetto geometrico.
//
//
//
// Modifiche : 02.02.17 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "ObjEGrGraphics.h"
#include <vector>
//----------------------------------------------------------------------------
class ObjMultiGraphics : public ObjEGrGraphics
{
public : // IObjGraphics
~ObjMultiGraphics( void) override ;
void Reset( void) override ;
public : // ObjEGrGraphics
bool IsValid( void) override
{ return m_bValid ; }
void SetScene( Scene* pScene) override ;
Scene* GetScene( void) override
{ return m_pScene ; }
bool SetCurrent( int nCurr) ;
void Clear( void) override ;
bool AddColor( const Color& colC) override ;
bool AddMaterial( const Color& colAmb, const Color& colDiff,
const Color& colSpec, float fShin) override ;
bool AddBackMaterial( const Color& colAmbDiff) override ;
bool AddPoint( const Point3d& ptP, bool bAux = false) override ;
bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) override ;
bool AddPolyLine( const PolyLine& PL, bool bAux = false) override ;
bool StartTriangles( int nNum, bool bAux = false) override ;
bool AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, const TriNormals3d& TNrms) override ;
bool EndTriangles( void) override ;
bool Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bShowAux) override ;
bool GetLocalBBox( BBox3d& b3Loc) const override ;
public :
ObjMultiGraphics( int nCount, bool bNewWay) ;
private :
Scene* m_pScene ; // puntatore alla scena
bool m_bValid ; // flag
mutable BBox3d m_b3Loc ; // BoundingBox locale
int m_nCurr ; // Graphics corrente
std::vector<ObjEGrGraphics*> m_vOEGR ; // vettore di Graphics
} ;
+22 -22
View File
@@ -55,30 +55,30 @@ typedef std::list<NgAtom> NGALIST ;
class ObjNewGraphics : public ObjEGrGraphics
{
public : // IObjGraphics
virtual ~ObjNewGraphics( void) ;
virtual void Reset( void) ;
~ObjNewGraphics( void) override ;
void Reset( void) override ;
public : // ObjEGrGraphics
virtual bool IsValid( void)
{ return m_bValid ; }
virtual void SetScene( Scene* pScene)
{ m_pScene = pScene ; }
virtual Scene* GetScene( void)
{ return m_pScene ; }
virtual void Clear( void) ;
virtual bool AddColor( const Color& colC) ;
virtual bool AddMaterial( const Color& colAmb, const Color& colDiff,
const Color& colSpec, float fShin) ;
virtual bool AddBackMaterial( const Color& colAmbDiff) ;
virtual bool AddPoint( const Point3d& ptP, bool bAux = false) ;
virtual bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) ;
virtual bool AddPolyLine( const PolyLine& PL, bool bAux = false) ;
virtual bool StartTriangles( int nNum, bool bAux = false) ;
virtual bool AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, const TriNormals3d& TNrms) ;
virtual bool EndTriangles( void) ;
virtual bool Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bShowAux) ;
virtual bool GetLocalBBox( BBox3d& b3Loc) const
{ b3Loc = m_b3Loc ; return ! m_b3Loc.IsEmpty() ; }
bool IsValid( void) override
{ return m_bValid ; }
void SetScene( Scene* pScene) override
{ m_pScene = pScene ; }
Scene* GetScene( void) override
{ return m_pScene ; }
void Clear( void) override ;
bool AddColor( const Color& colC) override ;
bool AddMaterial( const Color& colAmb, const Color& colDiff,
const Color& colSpec, float fShin) override ;
bool AddBackMaterial( const Color& colAmbDiff) override ;
bool AddPoint( const Point3d& ptP, bool bAux = false) override ;
bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) override ;
bool AddPolyLine( const PolyLine& PL, bool bAux = false) override ;
bool StartTriangles( int nNum, bool bAux = false) override ;
bool AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, const TriNormals3d& TNrms) override ;
bool EndTriangles( void) override ;
bool Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bShowAux) override ;
bool GetLocalBBox( BBox3d& b3Loc) const override
{ b3Loc = m_b3Loc ; return ! m_b3Loc.IsEmpty() ; }
public :
ObjNewGraphics( void) : m_pScene( nullptr), m_bValid( false) {}
+22 -22
View File
@@ -60,30 +60,30 @@ typedef std::vector<OgAtom> OGAVECT ;
class ObjOldGraphics : public ObjEGrGraphics
{
public : // IObjGraphics
virtual ~ObjOldGraphics( void) ;
virtual void Reset( void) ;
~ObjOldGraphics( void) override ;
void Reset( void) override ;
public : // ObjEGrGraphics
virtual bool IsValid( void)
{ return m_bValid ; }
virtual void SetScene( Scene* pScene)
{ m_pScene = pScene ; }
virtual Scene* GetScene( void)
{ return m_pScene ; }
virtual void Clear( void) ;
virtual bool AddColor( const Color& colC) ;
virtual bool AddMaterial( const Color& colAmb, const Color& colDiff,
const Color& colSpec, float fShin) ;
virtual bool AddBackMaterial( const Color& colAmbDiff) ;
virtual bool AddPoint( const Point3d& ptP, bool bAux = false) ;
virtual bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) ;
virtual bool AddPolyLine( const PolyLine& PL, bool bAux = false) ;
virtual bool StartTriangles( int nNum, bool bAux = false) ;
virtual bool AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, const TriNormals3d& TNrms) ;
virtual bool EndTriangles( void) ;
virtual bool Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bShowAux) ;
virtual bool GetLocalBBox( BBox3d& b3Loc) const
{ b3Loc = m_b3Loc ; return ! m_b3Loc.IsEmpty() ; }
bool IsValid( void) override
{ return m_bValid ; }
void SetScene( Scene* pScene) override
{ m_pScene = pScene ; }
Scene* GetScene( void) override
{ return m_pScene ; }
void Clear( void) override ;
bool AddColor( const Color& colC) override ;
bool AddMaterial( const Color& colAmb, const Color& colDiff,
const Color& colSpec, float fShin) override ;
bool AddBackMaterial( const Color& colAmbDiff) override ;
bool AddPoint( const Point3d& ptP, bool bAux = false) override ;
bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) override ;
bool AddPolyLine( const PolyLine& PL, bool bAux = false) override ;
bool StartTriangles( int nNum, bool bAux = false) override ;
bool AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, const TriNormals3d& TNrms) override ;
bool EndTriangles( void) override ;
bool Draw( int nStat, int nMark, bool bSurfSha, int nAlpha, bool bShowAux) override ;
bool GetLocalBBox( BBox3d& b3Loc) const override
{ b3Loc = m_b3Loc ; return ! m_b3Loc.IsEmpty() ; }
public :
ObjOldGraphics( void) : m_pScene( nullptr), m_nCurrMode( GL_NONE), m_bValid( false) {}
+61 -30
View File
@@ -16,7 +16,9 @@
#include "Scene.h"
#include "ObjOldGraphics.h"
#include "ObjNewGraphics.h"
#include "ObjMultiGraphics.h"
#include "EGrUtils.h"
#include "DllMain.h"
#include "/EgtDev/Include/EgtILogger.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGkFrame3d.h"
@@ -35,7 +37,7 @@
using namespace std ;
//------------------------------ Local functions -----------------------------
static ObjEGrGraphics* CreateObjEGrGraphics( bool bNewWay) ;
static ObjEGrGraphics* CreateObjEGrGraphics( int nCount, bool bNewWay) ;
static bool CalcCurveTailMark( const Vector3d& vtRef, const PolyLine& plCrv, PolyLine& plMark) ;
static bool CalcCurveTipArrow( const Vector3d& vtRef, const PolyLine& plCrv, PolyLine& plArr) ;
static bool CalcConnectingLines( const PolyLine& plCrv, const Vector3d& vtTh, bool bDense, PNTVECTOR& vPnt) ;
@@ -171,7 +173,18 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
// se non esiste grafica associata, la creo
if ( pGeoObj->GetObjGraphics() == nullptr) {
// nuova modalità grafica solo per superfici con molti triangoli
// oggetto grafico molteplice solo per Zmap che lo richiedono
int nCount = 0 ;
if ( nGeoType == VOL_ZMAP) {
const IVolZmap* pZmap = GetVolZmap( pGeoObj) ;
if ( pZmap != nullptr) {
switch ( m_nShowZmap) {
case ZSM_SURF : nCount = pZmap->GetBlockCount() ; break ;
case ZSM_BOTH : nCount = pZmap->GetBlockCount() + 1 ; break ;
}
}
}
// nuova modalità grafica solo per superfici con molti triangoli o solidi Zmap
const int N_MIN_TRIA_NEWWAY = 100 ;
bool bNewWay = false ;
if ( m_bNewWay) {
@@ -188,7 +201,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
bNewWay = true ;
}
}
ObjEGrGraphics* pGraphics = CreateObjEGrGraphics( bNewWay) ;
ObjEGrGraphics* pGraphics = CreateObjEGrGraphics( nCount, bNewWay) ;
if ( pGraphics == nullptr)
return false ;
pGraphics->SetScene( this) ;
@@ -329,36 +342,52 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
const IVolZmap* pZmap = GetVolZmap( pGeoObj) ;
if ( pZmap == nullptr)
return false ;
// recupero il materiale
// recupero il materiale
Material mMat ;
if ( ! iIter.GetCalcMaterial( mMat))
mMat.Set( m_colDef) ;
// impostazioni iniziali
pGraphics->Clear() ;
// visualizzazione superficie
if ( m_nShowZmap != ZSM_LINES) {
pGraphics->AddColor( siObj.colObj) ; // per wireframe
pGraphics->AddMaterial( mMat.GetAmbient(), mMat.GetDiffuse(),
mMat.GetSpecular(), mMat.GetShininess()) ;
pGraphics->AddBackMaterial( GetSurfBackColor( mMat.GetDiffuse())) ;
// recupero la geometria
TRIA3DLIST lstTria ;
pZmap->GetAllTriangles( lstTria) ;
// passo i triangoli alla grafica
pGraphics->StartTriangles( int( lstTria.size())) ;
for ( const auto& Tria : lstTria) {
TriFlags3d TFlags ;
TriNormals3d TNrms ;
for ( int i = 0 ; i < 3 ; ++i) {
TFlags.bFlag[i] = true ;
TNrms.vtN[i] = Tria.GetN() ;
}
pGraphics->AddTriangle( Tria, TFlags, TNrms) ;
}
pGraphics->EndTriangles() ;
// ciclo sui blocchi da aggiornare
std::vector<bool> vUpdate ;
pZmap->GetBlockInfo( vUpdate) ;
int nCount = int( vUpdate.size()) ;
for ( int i = 0 ; i < nCount ; ++ i) {
// se da non aggiornare, vado oltre
if ( ! vUpdate[i])
continue ;
// imposto indice blocco corrente
pGraphics->SetCurrent( i) ;
// lo pulisco
pGraphics->Clear() ;
// visualizzazione superficie
if ( m_nShowZmap != ZSM_LINES) {
pGraphics->AddColor( siObj.colObj) ; // per wireframe
pGraphics->AddMaterial( mMat.GetAmbient(), mMat.GetDiffuse(),
mMat.GetSpecular(), mMat.GetShininess()) ;
pGraphics->AddBackMaterial( GetSurfBackColor( mMat.GetDiffuse())) ;
// recupero la geometria
TRIA3DLIST lstTria ;
pZmap->GetBlockTriangles( i, lstTria) ;
// passo i triangoli alla grafica
pGraphics->StartTriangles( int( lstTria.size())) ;
for ( const auto& Tria : lstTria) {
TriFlags3d TFlags ;
TriNormals3d TNrms ;
for ( int j = 0 ; j < 3 ; ++ j) {
TFlags.bFlag[j] = true ;
TNrms.vtN[j] = Tria.GetN() ;
}
pGraphics->AddTriangle( Tria, TFlags, TNrms) ;
}
pGraphics->EndTriangles() ;
}
}
// visualizzazione spilloni
// visualizzazione spilloni (sempre nell'ultimo blocco)
if ( m_nShowZmap == ZSM_LINES || m_nShowZmap == ZSM_BOTH) {
// imposto indice blocco corrente
pGraphics->SetCurrent( nCount) ;
// lo pulisco
pGraphics->Clear() ;
// ciclo sui tre gruppi di spilloni
Color vCol[3] = {BLUE, RED, GREEN} ;
for ( int k = 0 ; k < 3 ; ++ k) {
pGraphics->AddColor( vCol[k]) ;
@@ -578,9 +607,11 @@ Scene::DeleteObjGraphicsGroup( int nId)
//------------------------------ Local functions -----------------------------
//----------------------------------------------------------------------------
static ObjEGrGraphics*
CreateObjEGrGraphics( bool bNewWay)
CreateObjEGrGraphics( int nCount, bool bNewWay)
{
if ( bNewWay)
if ( nCount > 1)
return ( new ObjMultiGraphics( nCount, bNewWay)) ;
else if ( bNewWay)
return ( new ObjNewGraphics) ;
else
return ( new ObjOldGraphics) ;