EgtGeomKernel 1.5c1 :

- aggiunta prima gestione attributi.
This commit is contained in:
Dario Sassi
2014-03-06 08:17:26 +00:00
parent 76f1c1ceac
commit 2a2c0065ed
21 changed files with 1284 additions and 714 deletions
+150
View File
@@ -0,0 +1,150 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : Attribs.cpp Data : 05.03.14 Versione : 1.5c1
// Contenuto : Implementazione della classe Attribs.
//
//
//
// Modifiche : 05.03.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "Attribs.h"
#include "/EgtDev/Include/EgnStringUtils.h"
using namespace std ;
//----------------------------------------------------------------------------
bool
Attribs::Dump( string& sOut, const char* szNewLine) const
{
sOut += "Lev=" ;
switch ( m_Data[LEVEL]) {
default : /* LEV_USER */ sOut += "user" ; break ;
case LEV_SYSTEM : sOut += "system" ; break ;
case LEV_TEMP : sOut += "temp" ; break ;
}
sOut += " Mod=" ;
switch ( m_Data[MODE]) {
default : /* MOD_STD */ sOut += "std" ; break ;
case MOD_LOCKED : sOut += "locked" ; break ;
case MOD_HIDDEN : sOut += "hidden" ; break ;
}
sOut += " Sta=" ;
switch ( m_Data[STATUS]) {
default : /* STS_ON */ sOut += "on" ; break ;
case STS_SEL : sOut += "sel" ; break ;
case STS_OFF : sOut += "off" ; break ;
}
sOut += szNewLine ;
sOut += "Mat=" ;
switch ( m_Material) {
case MAT_PARENT : sOut += "by parent" ; break ;
case MAT_COLOR : sOut += "color" ; break ;
case MAT_NULL : sOut += "null" ; break ;
default : sOut += ToString( m_Material) ; break ;
}
if ( m_Material != MAT_PARENT && m_Material != MAT_NULL) {
sOut += " Col=" ;
sOut += ToString( m_Color.GetIntRed()) + "," ;
sOut += ToString( m_Color.GetIntGreen()) + "," ;
sOut += ToString( m_Color.GetIntBlue()) + "," ;
sOut += ToString( m_Color.GetIntAlpha()) ;
}
sOut += szNewLine ;
return true ;
}
//----------------------------------------------------------------------------
bool
Attribs::Save( ostream& osOut) const
{
// flag presenza attributi
osOut << "A" << endl ;
// livello
osOut << ToString( m_Data[LEVEL]) ;
// modo
osOut << "," << ToString( m_Data[MODE]) ;
// stato
osOut << "," << ToString( m_Data[STATUS]) ;
// altro
osOut << "," << ToString( m_Data[OTHER]) ;
// materiale
osOut << ";" << ToString( m_Material) ;
// colore
osOut << ";" << ToString( m_Color.GetIntRed()) ;
osOut << "," << ToString( m_Color.GetIntGreen()) ;
osOut << "," << ToString( m_Color.GetIntBlue()) ;
osOut << "," << ToString( m_Color.GetIntAlpha()) ;
// numero di stringhe (nelle linee successive)
osOut << ";" << ToString( 0) << ";" << endl ;
return true ;
}
//----------------------------------------------------------------------------
bool
Attribs::Load( Scanner& TheScanner)
{
// leggo la prossima linea
string sLine ;
if ( ! TheScanner.GetLine( sLine))
return false ;
// la divido in parametri
STRVECTOR vsParams ;
Tokenize( sLine, ",;", vsParams) ;
// 10 parametri
if ( vsParams.size() != 10)
return false ;
// livello
int nLev ;
if ( ! FromString( vsParams[0], nLev))
return false ;
m_Data[LEVEL] = CLIP( nLev, LEV_USER, LEV_TEMP) ;
// modo
int nMode ;
if ( ! FromString( vsParams[1], nMode))
return false ;
m_Data[MODE] = CLIP( nMode, MOD_STD, MOD_HIDDEN) ;
// stato
int nStat ;
if ( ! FromString( vsParams[2], nStat))
return false ;
m_Data[STATUS] = CLIP( nStat, STS_ON, STS_OFF) ;
// altro
int nOther ;
if ( ! FromString( vsParams[3], nOther))
return false ;
m_Data[OTHER] = CLIP( nOther, 0, 255) ;
// materiale
int nMat ;
if ( ! FromString( vsParams[4], nMat))
return false ;
m_Material = __max( nMat, MAT_PARENT) ;
// colore
int nRed ;
if ( ! FromString( vsParams[5], nRed))
return false ;
int nGreen ;
if ( ! FromString( vsParams[6], nGreen))
return false ;
int nBlue ;
if ( ! FromString( vsParams[7], nBlue))
return false ;
int nAlpha ;
if ( ! FromString( vsParams[8], nAlpha))
return false ;
m_Color.Set( nRed, nGreen, nBlue, nAlpha) ;
// numero di stringhe (nelle linee successive)
int nNext ;
if ( ! FromString( vsParams[9], nNext))
return false ;
return true ;
}
+79
View File
@@ -0,0 +1,79 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : Attribs.h Data : 03.03.14 Versione : 1.5c1
// Contenuto : Dichiarazione della classe GeoAttributes.
//
//
//
// Modifiche : 03.03.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "/EgtDev/Include/EGkColor.h"
#include "/EgtDev/Include/EGnScan.h"
#include <string>
//----------------------------------------------------------------------------
#define CLIP( nV, nMIN, nMAX) (( nV < nMIN) ? nMIN : (( nV > nMAX) ? nMAX : nV))
//----------------------------------------------------------------------------
class Attribs
{
public :
Attribs( void)
{ m_Data[LEVEL] = LEV_USER ; m_Data[MODE] = MOD_STD ;
m_Data[STATUS] = STS_ON ; m_Data[OTHER] = 0 ;
m_Material = MAT_PARENT ; m_Color.Set( 0, 0, 0) ;}
Attribs* Clone( void) const
{ Attribs* pAttribs ;
// alloco oggetto
pAttribs = new(std::nothrow) Attribs ;
if ( pAttribs != nullptr)
*pAttribs = *(const_cast<Attribs*>(this)) ;
return pAttribs ; }
bool Dump( std::string& sOut, const char* szNewLine) const ;
bool Save( std::ostream& osOut) const ;
bool Load( Scanner& TheScanner) ;
void SetLevel( int nLev)
{ m_Data[LEVEL] = CLIP( nLev, LEV_USER, LEV_TEMP) ; }
int GetLevel( void) const
{ return m_Data[LEVEL] ; }
void SetMode( int nMode)
{ m_Data[MODE] = CLIP( nMode, MOD_STD, MOD_HIDDEN) ; }
int GetMode( void) const
{ return m_Data[MODE] ; }
void SetStatus( int nStat)
{ m_Data[STATUS] = CLIP( nStat, STS_ON, STS_OFF) ; }
int GetStatus( void) const
{ return m_Data[STATUS] ; }
void SetMaterial( int nMat)
{ if ( nMat != MAT_COLOR)
m_Material = nMat ; }
int GetMaterial( void) const
{ return m_Material ; }
void SetColor( Color cCol)
{ m_Material = MAT_COLOR ; m_Color = cCol ; }
Color GetColor( void) const
{ return m_Color ; }
public :
enum Level { LEV_USER = 0, LEV_SYSTEM = 1, LEV_TEMP = 2} ;
enum Mode { MOD_STD = 0, MOD_LOCKED = 1, MOD_HIDDEN = 2} ;
enum Status { STS_ON = 0, STS_SEL = 1, STS_OFF = 2} ;
enum { MAT_PARENT = -2, MAT_COLOR = -1, MAT_NULL = 0} ;
private :
enum { LEVEL = 0, MODE = 1, STATUS = 2, OTHER = 3, DIM = 4} ;
private :
unsigned char m_Data[DIM] ;
int m_Material ;
Color m_Color ;
std::string m_sName ;
std::string m_sNotes ;
} ;
BIN
View File
Binary file not shown.
+4 -2
View File
@@ -225,6 +225,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Attribs.cpp" />
<ClCompile Include="BBox3d.cpp" /> <ClCompile Include="BBox3d.cpp" />
<ClCompile Include="DistPointArc.cpp" /> <ClCompile Include="DistPointArc.cpp" />
<ClCompile Include="DistPointCrvAux.cpp" /> <ClCompile Include="DistPointCrvAux.cpp" />
@@ -242,8 +243,8 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="Frame3d.cpp" /> <ClCompile Include="Frame3d.cpp" />
<ClCompile Include="GdbGroup.cpp" /> <ClCompile Include="GdbGroup.cpp" />
<ClCompile Include="GdbIterator.cpp" /> <ClCompile Include="GdbIterator.cpp" />
<ClCompile Include="GdbNode.cpp" />
<ClCompile Include="GdbObj.cpp" /> <ClCompile Include="GdbObj.cpp" />
<ClCompile Include="GdbGeo.cpp" />
<ClCompile Include="GeoFrame3d.cpp" /> <ClCompile Include="GeoFrame3d.cpp" />
<ClCompile Include="GeomDB.cpp" /> <ClCompile Include="GeomDB.cpp" />
<ClCompile Include="GeoObj.cpp" /> <ClCompile Include="GeoObj.cpp" />
@@ -312,8 +313,9 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="CurveLine.h" /> <ClInclude Include="CurveLine.h" />
<ClInclude Include="GdbGroup.h" /> <ClInclude Include="GdbGroup.h" />
<ClInclude Include="GdbIterator.h" /> <ClInclude Include="GdbIterator.h" />
<ClInclude Include="GdbGeo.h" />
<ClInclude Include="GdbObj.h" /> <ClInclude Include="GdbObj.h" />
<ClInclude Include="GdbNode.h" /> <ClInclude Include="Attribs.h" />
<ClInclude Include="GeoConst.h" /> <ClInclude Include="GeoConst.h" />
<ClInclude Include="GeoFrame3d.h" /> <ClInclude Include="GeoFrame3d.h" />
<ClInclude Include="GeomDB.h" /> <ClInclude Include="GeomDB.h" />
+21 -15
View File
@@ -75,18 +75,12 @@
<ClCompile Include="GeomDB.cpp"> <ClCompile Include="GeomDB.cpp">
<Filter>File di origine\Gdb</Filter> <Filter>File di origine\Gdb</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="GdbObj.cpp">
<Filter>File di origine\Gdb</Filter>
</ClCompile>
<ClCompile Include="OutScl.cpp"> <ClCompile Include="OutScl.cpp">
<Filter>File di origine\Script</Filter> <Filter>File di origine\Script</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="GdbExecutor.cpp"> <ClCompile Include="GdbExecutor.cpp">
<Filter>File di origine\Script</Filter> <Filter>File di origine\Script</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="GdbNode.cpp">
<Filter>File di origine\Gdb</Filter>
</ClCompile>
<ClCompile Include="GdbGroup.cpp"> <ClCompile Include="GdbGroup.cpp">
<Filter>File di origine\Gdb</Filter> <Filter>File di origine\Gdb</Filter>
</ClCompile> </ClCompile>
@@ -108,9 +102,6 @@
<ClCompile Include="DistPointCrvBezier.cpp"> <ClCompile Include="DistPointCrvBezier.cpp">
<Filter>File di origine\Distanze</Filter> <Filter>File di origine\Distanze</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="GdbIterator.cpp">
<Filter>File di origine\Distanze</Filter>
</ClCompile>
<ClCompile Include="PolynomialPoint3d.cpp"> <ClCompile Include="PolynomialPoint3d.cpp">
<Filter>File di origine\Base</Filter> <Filter>File di origine\Base</Filter>
</ClCompile> </ClCompile>
@@ -126,6 +117,18 @@
<ClCompile Include="StringUtils3d.cpp"> <ClCompile Include="StringUtils3d.cpp">
<Filter>File di origine\Base</Filter> <Filter>File di origine\Base</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="GdbIterator.cpp">
<Filter>File di origine\Gdb</Filter>
</ClCompile>
<ClCompile Include="GdbGeo.cpp">
<Filter>File di origine\Gdb</Filter>
</ClCompile>
<ClCompile Include="GdbObj.cpp">
<Filter>File di origine\Gdb</Filter>
</ClCompile>
<ClCompile Include="Attribs.cpp">
<Filter>File di origine\Gdb</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="stdafx.h"> <ClInclude Include="stdafx.h">
@@ -203,9 +206,6 @@
<ClInclude Include="..\Include\EgkCurveComposite.h"> <ClInclude Include="..\Include\EgkCurveComposite.h">
<Filter>File di intestazione</Filter> <Filter>File di intestazione</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="GdbObj.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="GeomDB.h"> <ClInclude Include="GeomDB.h">
<Filter>File di intestazione</Filter> <Filter>File di intestazione</Filter>
</ClInclude> </ClInclude>
@@ -218,9 +218,6 @@
<ClInclude Include="GdbExecutor.h"> <ClInclude Include="GdbExecutor.h">
<Filter>File di intestazione</Filter> <Filter>File di intestazione</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="GdbNode.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="GdbGroup.h"> <ClInclude Include="GdbGroup.h">
<Filter>File di intestazione</Filter> <Filter>File di intestazione</Filter>
</ClInclude> </ClInclude>
@@ -317,6 +314,15 @@
<ClInclude Include="ObjGraphicsMgr.h"> <ClInclude Include="ObjGraphicsMgr.h">
<Filter>File di intestazione</Filter> <Filter>File di intestazione</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Attribs.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="GdbGeo.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="GdbObj.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="EgtGeomKernel.rc"> <ResourceCompile Include="EgtGeomKernel.rc">
+44
View File
@@ -128,6 +128,8 @@ GdbExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR&
return ExecuteCurveBez( sCmd2, vsParams) ; return ExecuteCurveBez( sCmd2, vsParams) ;
else if ( sCmd1 == "CC" || sCmd1 == "CURVECOMPO") else if ( sCmd1 == "CC" || sCmd1 == "CURVECOMPO")
return ExecuteCurveCompo( sCmd2, vsParams) ; return ExecuteCurveCompo( sCmd2, vsParams) ;
else if ( sCmd1 == "COL" || sCmd1 == "COLOR")
return ExecuteColor( sCmd2, vsParams) ;
else if ( sCmd1 == "COPY") else if ( sCmd1 == "COPY")
return ExecuteCopy( sCmd2, vsParams) ; return ExecuteCopy( sCmd2, vsParams) ;
else if ( sCmd1 == "ERASE") else if ( sCmd1 == "ERASE")
@@ -882,6 +884,48 @@ GdbExecutor::GetFrameParam( const std::string& sParam, Frame3d& frF)
} }
} }
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteColor( const string& sCmd2, const STRVECTOR& vsParams)
{
// impostazione colore di default
if ( sCmd2 == "DEF" || sCmd2 == "DEFAULT") {
// 3 parametri ( Red, Green, Blue)
if ( vsParams.size() != 3)
return false ;
// recupero i colori
int nRed ;
int nGreen ;
int nBlue ;
if ( ! FromString( vsParams[0], nRed) ||
! FromString( vsParams[1], nGreen) ||
! FromString( vsParams[2], nBlue))
return false ;
Color cCol( nRed, nGreen, nBlue) ;
return m_pGDB->SetDefaultColor( cCol) ;
}
// impostazione colore su oggetto
else {
// 4 o 5 parametri ( Id, Red, Green, Blue, Alpha)
if ( vsParams.size() != 4 && vsParams.size() != 5)
return false ;
// recupero i colori
int nRed ;
int nGreen ;
int nBlue ;
if ( ! FromString( vsParams[1], nRed) ||
! FromString( vsParams[2], nGreen) ||
! FromString( vsParams[3], nBlue))
return false ;
int nAlpha = 100 ;
if ( vsParams.size() == 5 &&
! FromString( vsParams[4], nAlpha))
return false ;
Color cCol( nRed, nGreen, nBlue, nAlpha) ;
return m_pGDB->SetColor( GetIdParam( vsParams[0]), cCol) ;
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
GdbExecutor::ExecuteCopy( const std::string& sCmd2, const STRVECTOR& vsParams) GdbExecutor::ExecuteCopy( const std::string& sCmd2, const STRVECTOR& vsParams)
+1
View File
@@ -46,6 +46,7 @@ class GdbExecutor : public IGdbExecutor
bool ExecuteCurveArc( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool ExecuteCurveArc( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteCurveBez( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool ExecuteCurveBez( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteCurveCompo( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool ExecuteCurveCompo( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteColor( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteCopy( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool ExecuteCopy( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteErase( const STRVECTOR& vsParams) ; bool ExecuteErase( const STRVECTOR& vsParams) ;
bool ExecuteTranslate( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool ExecuteTranslate( const std::string& sCmd2, const STRVECTOR& vsParams) ;
+246
View File
@@ -0,0 +1,246 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : GdbGeo.cpp Data : 24.11.13 Versione : 1.3a1
// Contenuto : Implementazione della classe GdbGeo oggetto del DB geometrico.
//
//
//
// Modifiche : 22.01.13 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "GdbGeo.h"
#include "GeoObjFactory.h"
#include "CurveAux.h"
#include "Attribs.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include <new>
using namespace std ;
//----------------------------------------------------------------------------
GdbGeo::GdbGeo( void)
{
m_pGeoObj = nullptr ;
}
//----------------------------------------------------------------------------
GdbGeo::~GdbGeo( void)
{
if ( m_pGeoObj != nullptr)
delete m_pGeoObj ;
m_pGeoObj = nullptr ;
}
//----------------------------------------------------------------------------
GdbGeo*
GdbGeo::Clone( int nId, IdManager& IdMgr) const
{
GdbGeo* pGdbGeo ;
// alloco oggetto Gdb
pGdbGeo = new(nothrow) GdbGeo ;
if ( pGdbGeo == nullptr)
return nullptr ;
// copio dati oggetto Gdb
pGdbGeo->GdbObj::Copy( this) ;
// assegno nuovo Id
pGdbGeo->m_nId = nId ;
// l'aggiornamento del manager di Id viene fatto all'inserimento nel DB
// copio oggetto Geo
if ( m_pGeoObj != nullptr) {
pGdbGeo->m_pGeoObj = m_pGeoObj->Clone() ;
if ( pGdbGeo->m_pGeoObj == nullptr) {
delete pGdbGeo ;
return nullptr ;
}
}
return pGdbGeo ;
}
//----------------------------------------------------------------------------
GeoObjType
GdbGeo::GetType( void) const
{
// non esiste l'oggetto geometrico
if ( m_pGeoObj == nullptr)
return GEO_NONE ;
return m_pGeoObj->GetType() ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::Save( std::ostream& osOut) const
{
bool bOk = true ;
// tipo entità
osOut << m_pGeoObj->GetKey() << endl ;
// nome
osOut << m_nId << "@" << GetParentId() << endl ;
// attributi
if ( ! GdbObj::SaveAttribs( osOut))
bOk = false ;
// parametri geometrici
osOut << "G" << endl ;
if ( ! m_pGeoObj->Save( osOut))
bOk = false ;
return bOk ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::Load( const std::string& sType, Scanner& TheScanner, int& nParentId)
{
int nType ;
string sLine ;
STRVECTOR vsParams ;
// creo l'oggetto geometrico corrispondente
nType = GEOOBJ_KEYTOTYPE( sType) ;
m_pGeoObj = GEOOBJ_CREATE( nType) ;
if ( m_pGeoObj == nullptr)
return false ;
// leggo la prossima linea
if ( ! TheScanner.GetLine( sLine))
return false ;
// la divido in parametri
Tokenize( sLine, "@", vsParams) ;
// 2 parametri : Id e ParentId
if ( vsParams.size() != 2)
return false ;
// assegno l'identificativo
if ( ! FromString( vsParams[0], m_nId))
return false ;
// assegno l'Id del padre
if ( ! FromString( vsParams[1], nParentId))
return false ;
// leggo la prossima linea
if ( ! TheScanner.GetLine( sLine))
return false ;
// eventuali attributi
if ( sLine == "A") {
if ( ! GdbObj::LoadAttribs( TheScanner))
return false ;
// leggo la prossima linea
if ( ! TheScanner.GetLine( sLine))
return false ;
}
// verifico inizio dati geometrici
if ( sLine != "G")
return false ;
// parametri geometrici
return m_pGeoObj->Load( TheScanner) ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::GetLocalBBox( BBox3d& b3Loc) const
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->GetLocalBBox( b3Loc) ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->GetBBox( frRef, b3Ref) ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::Translate( const Vector3d& vtMove)
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->Translate( vtMove) ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
{
if ( m_pGeoObj == nullptr)
return false ;
// se arco e scalatura non omogenea
if ( m_pGeoObj->GetType() == CRV_ARC &&
(fabs( dCoeffX - dCoeffY) > EPS_SMALL || fabs( dCoeffX - dCoeffZ) > EPS_SMALL)) {
// trasformo in curva di Bezier (semplice o composta)
ICurve* pCrvNew ;
if ( ! ArcToBezierCurve( GetCurve( m_pGeoObj), pCrvNew))
return false ;
// elimino l'arco e lo sostituisco con la curva di Bezier
delete m_pGeoObj ;
m_pGeoObj = pCrvNew ;
}
// eseguo scalatura
return m_pGeoObj->Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->Mirror( ptOn, vtNorm) ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::ToGlob( const Frame3d& frRef)
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->ToGlob( frRef) ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::ToLoc( const Frame3d& frRef)
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->ToLoc( frRef) ;
}
+48
View File
@@ -0,0 +1,48 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : GdbGeo.h Data : 05.03.14 Versione : 1.5c1
// Contenuto : Dichiarazione della classe GdbGeo.
//
//
//
// Modifiche : 22.01.13 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "GdbObj.h"
#include "/EgtDev/Include/EGkGeoObjType.h"
#include <string>
class IGeoObj ;
//----------------------------------------------------------------------------
class GdbGeo : public GdbObj
{
public :
virtual ~GdbGeo( void) ;
virtual GdbGeo* Clone( int nId, IdManager& IdMgr) const ;
virtual bool Save( std::ostream& osOut) const ;
virtual bool Load( const std::string& sType, Scanner& TheScanner, int& nParentId) ;
virtual bool GetLocalBBox( BBox3d& b3Loc) const ;
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const ;
virtual bool Translate( const Vector3d& vtMove) ;
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
{ double dAngRad = dAngDeg * DEGTORAD ;
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ;
virtual bool ToGlob( const Frame3d& frRef) ;
virtual bool ToLoc( const Frame3d& frRef) ;
public :
GdbGeo( void) ;
GeoObjType GetType( void) const ;
public :
IGeoObj* m_pGeoObj ;
} ;
+88 -65
View File
@@ -13,22 +13,22 @@
//--------------------------- Include ---------------------------------------- //--------------------------- Include ----------------------------------------
#include "stdafx.h" #include "stdafx.h"
#include "\EgtDev\Include\EGnStringUtils.h"
#include "GdbGroup.h" #include "GdbGroup.h"
#include "IdManager.h" #include "IdManager.h"
#include "\EgtDev\Include\EGnStringUtils.h"
using namespace std ; using namespace std ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
GdbGroup::GdbGroup( void) GdbGroup::GdbGroup( void)
: m_nNodeCount( 0), m_pFirstNode( nullptr), m_pLastNode( nullptr) : m_nObjCount( 0), m_pFirstObj( nullptr), m_pLastObj( nullptr)
{ {
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
GdbGroup::~GdbGroup( void) GdbGroup::~GdbGroup( void)
{ {
// elimino i figli
Clear() ; Clear() ;
} }
@@ -36,18 +36,16 @@ GdbGroup::~GdbGroup( void)
bool bool
GdbGroup::Clear( void) GdbGroup::Clear( void)
{ {
GdbNode* pNode ;
// disalloco gli oggetti // disalloco gli oggetti
pNode = GetFirstNode() ; GdbObj* pObj ;
while ( pNode != nullptr) { pObj = GetFirstObj() ;
while ( pObj != nullptr) {
// lo rimuovo dalla lista // lo rimuovo dalla lista
pNode->Remove() ; pObj->Remove() ;
// lo disalloco // lo disalloco
delete pNode ; delete pObj ;
// passo al nuovo primo // passo al nuovo primo
pNode = GetFirstNode() ; pObj = GetFirstObj() ;
} }
return true ; return true ;
@@ -57,41 +55,44 @@ GdbGroup::Clear( void)
GdbGroup* GdbGroup*
GdbGroup::Clone( int nId, IdManager& IdMgr) const GdbGroup::Clone( int nId, IdManager& IdMgr) const
{ {
GdbGroup* pGdbGroup ;
const GdbNode* pNode ;
GdbNode* pNewNode ;
// alloco gruppo Gdb // alloco gruppo Gdb
GdbGroup* pGdbGroup ;
pGdbGroup = new(nothrow) GdbGroup ; pGdbGroup = new(nothrow) GdbGroup ;
if ( pGdbGroup == nullptr) if ( pGdbGroup == nullptr)
return nullptr ; return nullptr ;
// copio dati oggetto Gdb // copio dati oggetto Gdb
pGdbGroup->GdbObj::Copy( this) ;
// assegno nuovo Id
pGdbGroup->m_nId = nId ; pGdbGroup->m_nId = nId ;
IdMgr.UpdateMaxId( nId) ; IdMgr.UpdateMaxId( nId) ;
// copio dati gruppo
pGdbGroup->m_gfrFrame = m_gfrFrame ; pGdbGroup->m_gfrFrame = m_gfrFrame ;
// clono i nodi figli // clono gli oggetti figli
pNode = GetFirstNode() ; const GdbObj* pObj = GetFirstObj() ;
while ( pNode != nullptr) { while ( pObj != nullptr) {
// eseguo copia // eseguo copia
pNewNode = pNode->Clone( IdMgr.GetNewId(), IdMgr) ; GdbObj* pNewObj = pObj->Clone( IdMgr.GetNewId(), IdMgr) ;
if ( pNewNode == nullptr) { if ( pNewObj == nullptr) {
delete pGdbGroup ; delete pGdbGroup ;
return nullptr ; return nullptr ;
} }
// lo inserisco nella lista dei figli // lo inserisco nella lista dei figli
if ( ! pNewNode->AddTail( pGdbGroup)) { if ( ! pNewObj->AddTail( pGdbGroup)) {
delete pNewNode ; delete pNewObj ;
delete pGdbGroup ; delete pGdbGroup ;
return nullptr ; return nullptr ;
} }
// lo inserisco nella mappa dei nomi // lo inserisco nella mappa degli Id
if ( ! IdMgr.AddNode( pNewNode->m_nId, pNewNode)) if ( ! IdMgr.AddObj( pNewObj->m_nId, pNewObj)) {
delete pGdbGroup ;
return nullptr ; return nullptr ;
// passo al prossimo nodo }
pNode = pNode->GetNext() ; // passo al prossimo oggetto
pObj = pObj->GetNext() ;
} }
return pGdbGroup ; return pGdbGroup ;
@@ -107,15 +108,22 @@ GdbGroup::Save( std::ostream& osOut) const
osOut << GetKey() << endl ; osOut << GetKey() << endl ;
// identificativi // identificativi
osOut << m_nId << "@" << GetParentId() << endl ; osOut << m_nId << "@" << GetParentId() << endl ;
// dati del riferimento
m_gfrFrame.Save( osOut) ;
// lancio il salvataggio dei figli // attributi
const GdbNode* pGdbNode = GetFirstNode() ; if ( ! GdbObj::SaveAttribs( osOut))
while ( pGdbNode != nullptr) { bOk = false ;
if ( ! pGdbNode->Save( osOut))
// dati del riferimento
osOut << "G" << endl ;
if ( ! m_gfrFrame.Save( osOut))
bOk = false ;
// salvataggio dei figli
const GdbObj* pGdbObj = GetFirstObj() ;
while ( pGdbObj != nullptr) {
if ( ! pGdbObj->Save( osOut))
bOk = false ; bOk = false ;
pGdbNode = pGdbNode->GetNext() ; pGdbObj = pGdbObj->GetNext() ;
} }
return bOk ; return bOk ;
@@ -143,6 +151,24 @@ GdbGroup::Load( const string& sType, Scanner& TheScanner, int& nParentId)
// assegno l'Id del padre // assegno l'Id del padre
if ( ! FromString( vsParams[1], nParentId)) if ( ! FromString( vsParams[1], nParentId))
return false ; return false ;
// leggo la prossima linea
if ( ! TheScanner.GetLine( sLine))
return false ;
// eventuali attributi
if ( sLine == "A") {
if ( ! GdbObj::LoadAttribs( TheScanner))
return false ;
// leggo la prossima linea
if ( ! TheScanner.GetLine( sLine))
return false ;
}
// verifico inizio dati geometrici
if ( sLine != "G")
return false ;
// leggo i dati del riferimento // leggo i dati del riferimento
m_gfrFrame.Load( TheScanner) ; m_gfrFrame.Load( TheScanner) ;
@@ -154,13 +180,13 @@ bool
GdbGroup::GetLocalBBox( BBox3d& b3Loc) const GdbGroup::GetLocalBBox( BBox3d& b3Loc) const
{ {
b3Loc.Reset() ; b3Loc.Reset() ;
const GdbNode* pGdbNode = GetFirstNode() ; const GdbObj* pGdbObj = GetFirstObj() ;
while ( pGdbNode != nullptr) { while ( pGdbObj != nullptr) {
BBox3d b3B ; BBox3d b3B ;
// voglio il box come appare nel frame del gruppo, quindi passo frame identità // voglio il box come appare nel frame del gruppo, quindi passo frame identità
if ( pGdbNode->GetBBox( GLOB_FRM, b3B)) if ( pGdbObj->GetBBox( GLOB_FRM, b3B))
b3Loc.Add( b3B) ; b3Loc.Add( b3B) ;
pGdbNode = pGdbNode->GetNext() ; pGdbObj = pGdbObj->GetNext() ;
} }
return true ; return true ;
} }
@@ -171,12 +197,12 @@ GdbGroup::GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const
{ {
Frame3d frCurr = m_gfrFrame.m_frF * frRef ; Frame3d frCurr = m_gfrFrame.m_frF * frRef ;
b3Ref.Reset() ; b3Ref.Reset() ;
const GdbNode* pGdbNode = GetFirstNode() ; const GdbObj* pGdbObj = GetFirstObj() ;
while ( pGdbNode != nullptr) { while ( pGdbObj != nullptr) {
BBox3d b3B ; BBox3d b3B ;
if ( pGdbNode->GetBBox( frCurr, b3B)) if ( pGdbObj->GetBBox( frCurr, b3B))
b3Ref.Add( b3B) ; b3Ref.Add( b3B) ;
pGdbNode = pGdbNode->GetNext() ; pGdbObj = pGdbObj->GetNext() ;
} }
return true ; return true ;
} }
@@ -199,20 +225,20 @@ GdbGroup::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, dou
bool bool
GdbGroup::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) GdbGroup::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
{ {
GdbNode* pGdbNode ; GdbObj* pGdbObj ;
// parziale scalatura del riferimento (non può essere completa) // parziale scalatura del riferimento (non può essere completa)
Frame3d frFrameS = m_gfrFrame.m_frF ; Frame3d frFrameS = m_gfrFrame.m_frF ;
frFrameS.PseudoScale( frRef, dCoeffX, dCoeffY, dCoeffZ) ; frFrameS.PseudoScale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
// porto i nodi nel nuovo riferimento, senza modificarne la geometria in globale // porto gli oggetti nel nuovo riferimento, senza modificarne la geometria in globale
Frame3d frTrasf = m_gfrFrame.m_frF ; Frame3d frTrasf = m_gfrFrame.m_frF ;
frTrasf.ToLoc( frFrameS) ; frTrasf.ToLoc( frFrameS) ;
pGdbNode = GetFirstNode() ; pGdbObj = GetFirstObj() ;
while ( pGdbNode != nullptr) { while ( pGdbObj != nullptr) {
pGdbNode->ToGlob( frTrasf) ; pGdbObj->ToGlob( frTrasf) ;
pGdbNode = pGdbNode->GetNext() ; pGdbObj = pGdbObj->GetNext() ;
} }
// assegno il nuovo riferimento // assegno il nuovo riferimento
@@ -224,11 +250,11 @@ GdbGroup::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
// ciclo sui nodi // ciclo sui nodi
bool bOk = true ; bool bOk = true ;
pGdbNode = GetFirstNode() ; pGdbObj = GetFirstObj() ;
while ( pGdbNode != nullptr) { while ( pGdbObj != nullptr) {
if ( ! pGdbNode->Scale( frRefLoc, dCoeffX, dCoeffY, dCoeffZ)) if ( ! pGdbObj->Scale( frRefLoc, dCoeffX, dCoeffY, dCoeffZ))
bOk = false ; bOk = false ;
pGdbNode = pGdbNode->GetNext() ; pGdbObj = pGdbObj->GetNext() ;
} }
return bOk ; return bOk ;
@@ -238,7 +264,7 @@ GdbGroup::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
bool bool
GdbGroup::Mirror( const Point3d& ptOn, const Vector3d& vtNorm) GdbGroup::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
{ {
GdbNode* pGdbNode ; GdbObj* pGdbObj ;
// parziale mirror del riferimento (non può essere completa) // parziale mirror del riferimento (non può essere completa)
@@ -248,10 +274,10 @@ GdbGroup::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
// porto i nodi nel nuovo riferimento, senza modificarne la geometria in globale // porto i nodi nel nuovo riferimento, senza modificarne la geometria in globale
Frame3d frTrasf = m_gfrFrame.m_frF ; Frame3d frTrasf = m_gfrFrame.m_frF ;
frTrasf.ToLoc( frFrameS) ; frTrasf.ToLoc( frFrameS) ;
pGdbNode = GetFirstNode() ; pGdbObj = GetFirstObj() ;
while ( pGdbNode != nullptr) { while ( pGdbObj != nullptr) {
pGdbNode->ToGlob( frTrasf) ; pGdbObj->ToGlob( frTrasf) ;
pGdbNode = pGdbNode->GetNext() ; pGdbObj = pGdbObj->GetNext() ;
} }
// assegno il nuovo riferimento // assegno il nuovo riferimento
@@ -265,11 +291,11 @@ GdbGroup::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
// ciclo sui nodi // ciclo sui nodi
bool bOk = true ; bool bOk = true ;
pGdbNode = GetFirstNode() ; pGdbObj = GetFirstObj() ;
while ( pGdbNode != nullptr) { while ( pGdbObj != nullptr) {
if ( ! pGdbNode->Mirror( ptOnLoc, vtNormLoc)) if ( ! pGdbObj->Mirror( ptOnLoc, vtNormLoc))
bOk = false ; bOk = false ;
pGdbNode = pGdbNode->GetNext() ; pGdbObj = pGdbObj->GetNext() ;
} }
return bOk ; return bOk ;
@@ -279,13 +305,11 @@ GdbGroup::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
bool bool
GdbGroup::GetGlobFrame( Frame3d& frGlob) const GdbGroup::GetGlobFrame( Frame3d& frGlob) const
{ {
const GdbGroup* pParent ;
// assegno il proprio frame // assegno il proprio frame
frGlob = m_gfrFrame.m_frF ; frGlob = m_gfrFrame.m_frF ;
// mentre ci sono padri // mentre ci sono padri
const GdbGroup* pParent ;
pParent = GetParent() ; pParent = GetParent() ;
while ( pParent != nullptr) { while ( pParent != nullptr) {
// porto il riferimento corrente sopra il padre // porto il riferimento corrente sopra il padre
@@ -296,4 +320,3 @@ GdbGroup::GetGlobFrame( Frame3d& frGlob) const
return true ; return true ;
} }
+25 -18
View File
@@ -13,16 +13,15 @@
#pragma once #pragma once
#include <string>
#include "/EgtDev/Include/EGkGeoObj.h"
#include "GeoFrame3d.h" #include "GeoFrame3d.h"
#include "GdbNode.h" #include "GdbObj.h"
#include "/EgtDev/Include/EGkGeoObj.h"
#include <string>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class GdbGroup : public GdbNode class GdbGroup : public GdbObj
{ {
friend class GdbNode ; friend class GdbObj ;
public : public :
virtual ~GdbGroup( void) ; virtual ~GdbGroup( void) ;
@@ -46,25 +45,33 @@ class GdbGroup : public GdbNode
public : public :
GdbGroup( void) ; GdbGroup( void) ;
bool Clear( void) ; bool Clear( void) ;
void NodeCountInc( void) { ++ m_nNodeCount ; } void ObjCountInc( void)
void NodeCountDec( void) { -- m_nNodeCount ; } { ++ m_nObjCount ; }
int GetNodeCount( void) const { return m_nNodeCount ; } void ObjCountDec( void)
GdbNode* GetFirstNode( void) { return m_pFirstNode ; } { -- m_nObjCount ; }
const GdbNode* GetFirstNode( void) const { return m_pFirstNode ; } int GetObjCount( void) const
GdbNode* GetLastNode( void) { return m_pLastNode ; } { return m_nObjCount ; }
const GdbNode* GetLastNode( void) const { return m_pLastNode ; } GdbObj* GetFirstObj( void)
{ return m_pFirstObj ; }
const GdbObj* GetFirstObj( void) const
{ return m_pFirstObj ; }
GdbObj* GetLastObj( void)
{ return m_pLastObj ; }
const GdbObj* GetLastObj( void) const
{ return m_pLastObj ; }
public : public :
static const std::string& GetKey( void) { static std::string s_sKey = "A_GRP" ; return s_sKey ; } static const std::string& GetKey( void)
{ static std::string s_sKey = "A_GRP" ; return s_sKey ; }
public : public :
bool GetGlobFrame( Frame3d& frGlob) const ; bool GetGlobFrame( Frame3d& frGlob) const ;
public : public :
GeoFrame3d m_gfrFrame ; GeoFrame3d m_gfrFrame ;
private : private :
int m_nNodeCount ; int m_nObjCount ;
GdbNode* m_pFirstNode ; GdbObj* m_pFirstObj ;
GdbNode* m_pLastNode ; GdbObj* m_pLastObj ;
} ; } ;
+70 -55
View File
@@ -13,8 +13,9 @@
//--------------------------- Include ---------------------------------------- //--------------------------- Include ----------------------------------------
#include "stdafx.h" #include "stdafx.h"
#include <new>
#include "GdbIterator.h" #include "GdbIterator.h"
#include "Attribs.h"
#include <new>
using namespace std ; using namespace std ;
@@ -31,7 +32,7 @@ CreateGdbIterator( void)
GdbIterator::GdbIterator( void) GdbIterator::GdbIterator( void)
{ {
m_pGDB = nullptr ; m_pGDB = nullptr ;
m_pCurrNode = nullptr ; m_pCurrObj = nullptr ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -56,9 +57,9 @@ GdbIterator::GoTo( int nId)
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
m_pCurrNode = m_pGDB->GetGdbNode( nId) ; m_pCurrObj = m_pGDB->GetGdbObj( nId) ;
return ( m_pCurrNode != nullptr) ; return ( m_pCurrObj != nullptr) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -74,75 +75,73 @@ GdbIterator::GoToFirstInGroup( int nIdGroup)
// recupero il gruppo // recupero il gruppo
pGdbGroup = m_pGDB->GetGdbGroup( nIdGroup) ; pGdbGroup = m_pGDB->GetGdbGroup( nIdGroup) ;
if ( pGdbGroup == nullptr) { if ( pGdbGroup == nullptr) {
m_pCurrNode = nullptr ; m_pCurrObj = nullptr ;
return false ; return false ;
} }
// recupero il nodo // recupero l'oggetto
m_pCurrNode = pGdbGroup->GetFirstNode() ; m_pCurrObj = pGdbGroup->GetFirstObj() ;
return ( m_pCurrNode != nullptr) ; return ( m_pCurrObj != nullptr) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
GdbIterator::GoToNext( void) GdbIterator::GoToNext( void)
{ {
if ( m_pGDB == nullptr || m_pCurrNode == nullptr) if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ; return false ;
m_pCurrNode = m_pCurrNode->GetNext() ; m_pCurrObj = m_pCurrObj->GetNext() ;
return ( m_pCurrNode != nullptr) ; return ( m_pCurrObj != nullptr) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
GdbIterator::GoToLastInGroup( int nIdGroup) GdbIterator::GoToLastInGroup( int nIdGroup)
{ {
GdbGroup* pGdbGroup ;
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
// recupero il gruppo // recupero il gruppo
GdbGroup* pGdbGroup ;
pGdbGroup = m_pGDB->GetGdbGroup( nIdGroup) ; pGdbGroup = m_pGDB->GetGdbGroup( nIdGroup) ;
if ( pGdbGroup == nullptr) { if ( pGdbGroup == nullptr) {
m_pCurrNode = nullptr ; m_pCurrObj = nullptr ;
return false ; return false ;
} }
// recupero il nodo // recupero l'oggetto
m_pCurrNode = pGdbGroup->GetLastNode() ; m_pCurrObj = pGdbGroup->GetLastObj() ;
return ( m_pCurrNode != nullptr) ; return ( m_pCurrObj != nullptr) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
GdbIterator::GoToPrev( void) GdbIterator::GoToPrev( void)
{ {
if ( m_pGDB == nullptr || m_pCurrNode == nullptr) if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ; return false ;
m_pCurrNode = m_pCurrNode->GetPrev() ; m_pCurrObj = m_pCurrObj->GetPrev() ;
return ( m_pCurrNode != nullptr) ; return ( m_pCurrObj != nullptr) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
GdbType GdbType
GdbIterator::GetGdbType( void) const GdbIterator::GetGdbType( void) const
{ {
if ( m_pGDB == nullptr || m_pCurrNode == nullptr) if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return GDB_NONE ; return GDB_NONE ;
// se oggetto geometrico // se oggetto geometrico
if ( GetGdbObj( m_pCurrNode) != nullptr) if ( GetGdbGeo( m_pCurrObj) != nullptr)
return GDB_GEO ; return GDB_GEO ;
// se gruppo // se gruppo
else if ( GetGdbGroup( m_pCurrNode) != nullptr) else if ( GetGdbGroup( m_pCurrObj) != nullptr)
return GDB_GROUP ; return GDB_GROUP ;
// altro // altro
else else
@@ -153,31 +152,27 @@ GdbIterator::GetGdbType( void) const
IGeoObj* IGeoObj*
GdbIterator::GetGeoObj( void) GdbIterator::GetGeoObj( void)
{ {
const GdbObj* pGdbObj ; if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
if ( m_pGDB == nullptr || m_pCurrNode == nullptr)
return false ; return false ;
// recupero l'oggetto Gdb // recupero l'oggetto Gdb
if ( ( pGdbObj = GetGdbObj( m_pCurrNode)) == nullptr) const GdbGeo* pGdbGeo ;
if ( ( pGdbGeo = GetGdbGeo( m_pCurrObj)) == nullptr)
return nullptr ; return nullptr ;
// restituisco il suo contenuto geometrico // restituisco il suo contenuto geometrico
return pGdbObj->m_pGeoObj ; return pGdbGeo->m_pGeoObj ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
IGeoFrame3d* IGeoFrame3d*
GdbIterator::GetGeoFrame( void) GdbIterator::GetGeoFrame( void)
{ {
GdbGroup* pGdbGroup ; if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
if ( m_pGDB == nullptr || m_pCurrNode == nullptr)
return nullptr ; return nullptr ;
if ( ( pGdbGroup = GetGdbGroup( m_pCurrNode)) == nullptr) GdbGroup* pGdbGroup ;
if ( ( pGdbGroup = GetGdbGroup( m_pCurrObj)) == nullptr)
return nullptr ; return nullptr ;
return &( pGdbGroup->m_gfrFrame) ; return &( pGdbGroup->m_gfrFrame) ;
@@ -185,15 +180,13 @@ GdbIterator::GetGeoFrame( void)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
GdbIterator::GetGroupFrame( Frame3d& frGlob) GdbIterator::GetGroupFrame( Frame3d& frGlob) const
{ {
GdbGroup* pGdbGroup ; if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
if ( m_pGDB == nullptr || m_pCurrNode == nullptr)
return false ; return false ;
if ( ( pGdbGroup = GetGdbGroup( m_pCurrNode)) == nullptr) GdbGroup* pGdbGroup ;
if ( ( pGdbGroup = GetGdbGroup( m_pCurrObj)) == nullptr)
return false ; return false ;
// copio il riferimento // copio il riferimento
@@ -203,15 +196,13 @@ GdbIterator::GetGroupFrame( Frame3d& frGlob)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
GdbIterator::GetGroupGlobFrame( Frame3d& frGlob) GdbIterator::GetGroupGlobFrame( Frame3d& frGlob) const
{ {
GdbGroup* pGdbGroup ; if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
if ( m_pGDB == nullptr || m_pCurrNode == nullptr)
return false ; return false ;
if ( ( pGdbGroup = GetGdbGroup( m_pCurrNode)) == nullptr) GdbGroup* pGdbGroup ;
if ( ( pGdbGroup = GetGdbGroup( m_pCurrObj)) == nullptr)
return false ; return false ;
return pGdbGroup->GetGlobFrame( frGlob) ; return pGdbGroup->GetGlobFrame( frGlob) ;
@@ -219,20 +210,44 @@ GdbIterator::GetGroupGlobFrame( Frame3d& frGlob)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int int
GdbIterator::GetId( void) GdbIterator::GetId( void) const
{ {
if ( m_pGDB == nullptr || m_pCurrNode == nullptr) if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return - 1 ; return GDB_ID_NULL ;
return m_pCurrNode->m_nId ; return m_pCurrObj->m_nId ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int int
GdbIterator::GetParentId( void) GdbIterator::GetParentId( void) const
{ {
if ( m_pGDB == nullptr || m_pCurrNode == nullptr) if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return - 1 ; return GDB_ID_NULL ;
return m_pCurrNode->GetParentId() ; return m_pCurrObj->GetParentId() ;
}
//----------------------------------------------------------------------------
// Attributes
//----------------------------------------------------------------------------
bool
GdbIterator::SetColor( Color cCol)
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// assegno il colore
return m_pCurrObj->SetColor( cCol) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::GetColor( Color& cCol) const
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// recupero il colore
return m_pCurrObj->GetColor( cCol) ;
} }
+9 -7
View File
@@ -32,14 +32,16 @@ class GdbIterator : public IGdbIterator
virtual GdbType GetGdbType( void) const ; virtual GdbType GetGdbType( void) const ;
virtual IGeoObj* GetGeoObj( void) ; virtual IGeoObj* GetGeoObj( void) ;
virtual IGeoFrame3d* GetGeoFrame( void) ; virtual IGeoFrame3d* GetGeoFrame( void) ;
virtual bool GetGroupFrame( Frame3d& frGlob) ; virtual bool GetGroupFrame( Frame3d& frGlob) const ;
virtual bool GetGroupGlobFrame( Frame3d& frGlob) ; virtual bool GetGroupGlobFrame( Frame3d& frGlob) const ;
virtual int GetId( void) ; virtual int GetId( void) const ;
virtual int GetParentId( void) ; virtual int GetParentId( void) const ;
virtual bool GetGlobFrame( Frame3d& frGlob) virtual bool GetGlobFrame( Frame3d& frGlob) const
{ return m_pGDB->GetGroupGlobFrame( GetParentId(), frGlob) ; } { return m_pGDB->GetGroupGlobFrame( GetParentId(), frGlob) ; }
virtual bool SetColor( Color cCol) ;
virtual bool GetColor( Color& cCol) const ;
private : private :
GeomDB* m_pGDB ; GeomDB* m_pGDB ;
GdbNode* m_pCurrNode ; GdbObj* m_pCurrObj ;
} ; } ;
-159
View File
@@ -1,159 +0,0 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : GdbNode.cpp Data : 28.11.13 Versione : 1.4a2
// Contenuto : Implementazione della classe GdbNode.
//
//
//
// Modifiche : 28.11.13 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "GdbNode.h"
#include "GdbGroup.h"
//----------------------------------------------------------------------------
GdbNode::GdbNode( void)
: m_nId( GDB_ID_NULL), m_pNext( nullptr), m_pPrev( nullptr), m_pParent( nullptr)
{
}
//----------------------------------------------------------------------------
int
GdbNode::GetParentId( void) const
{
if ( m_pParent != nullptr)
return m_pParent->m_nId ;
else
return 0 ;
}
//----------------------------------------------------------------------------
bool
GdbNode::AddTail( GdbGroup* pParent)
{
// se il padre non è definito, errore
if ( pParent == nullptr)
return false ;
// se non ci sono figli
if ( pParent->m_pLastNode == nullptr) {
pParent->m_pLastNode = this ;
pParent->m_pFirstNode = this ;
m_pParent = pParent ;
m_pNext = nullptr ;
m_pPrev = nullptr ;
m_pParent->NodeCountInc() ;
return true ;
}
// caso standard
return InsertAfter( pParent->m_pLastNode) ;
}
//----------------------------------------------------------------------------
bool
GdbNode::AddHead( GdbGroup* pParent)
{
// se il padre non è definito, errore
if ( pParent == nullptr)
return false ;
// se non ci sono figli
if ( pParent->m_pFirstNode == nullptr) {
pParent->m_pFirstNode = this ;
pParent->m_pLastNode = this ;
m_pParent = pParent ;
m_pNext = nullptr ;
m_pPrev = nullptr ;
m_pParent->NodeCountInc() ;
return true ;
}
// caso standard
return InsertBefore( pParent->m_pFirstNode) ;
}
//----------------------------------------------------------------------------
bool
GdbNode::InsertAfter( GdbNode* pRef)
{
// se riferimento non definito, errore
if ( pRef == nullptr)
return false ;
// sistemazione puntatori di elemento inserito
m_pNext = pRef->m_pNext ;
m_pPrev = pRef ;
m_pParent = pRef->m_pParent ;
// sistemazione puntatori di elemento di riferimento
pRef->m_pNext = this ;
// sistemazione puntatori di eventuale elemento successivo
if ( m_pNext != nullptr)
m_pNext->m_pPrev = this ;
// sistemazione dell'eventuale padre
if ( m_pParent != nullptr) {
// se nuovo ultimo nodo
if ( m_pParent->m_pLastNode == pRef)
m_pParent->m_pLastNode = this ;
m_pParent->NodeCountInc() ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
GdbNode::InsertBefore( GdbNode* pRef)
{
// se riferimento non definito, errore
if ( pRef == nullptr)
return false ;
// sistemazione puntatori di elemento inserito
m_pNext = pRef ;
m_pPrev = pRef->m_pPrev ;
m_pParent = pRef->m_pParent ;
// sistemazione puntatori di elemento corrente
pRef->m_pPrev = this ;
// sistemazione puntatori di eventuale elemento precedente
if ( m_pPrev != nullptr)
m_pPrev->m_pNext = this ;
// sistemazione dell'eventuale padre
if ( m_pParent != nullptr) {
// se nuovo primo nodo
if ( m_pParent->m_pFirstNode == pRef)
m_pParent->m_pFirstNode = this ;
m_pParent->NodeCountInc() ;
}
return true ;
}
/*-------------------------------------------------------------------------*/
bool
GdbNode::Remove( void)
{
// sistemazione dell'eventuale padre
if ( m_pParent != nullptr) {
if ( m_pParent->m_pFirstNode == this)
m_pParent->m_pFirstNode = m_pNext ;
if ( m_pParent->m_pLastNode == this)
m_pParent->m_pLastNode = m_pPrev ;
m_pParent->NodeCountDec() ;
}
// sistemazione di eventuale precedente
if ( m_pPrev != nullptr)
m_pPrev->m_pNext = m_pNext ;
// sistemazione di eventuale successivo
if ( m_pNext != nullptr)
m_pNext->m_pPrev = m_pPrev ;
return true ;
}
-65
View File
@@ -1,65 +0,0 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : GdbNode.h Data : 28.11.13 Versione : 1.4a2
// Contenuto : Dichiarazione della classe GdbNode.
//
//
//
// Modifiche : 28.11.13 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include <string>
#include "/EgtDev/Include/EGkGdbConst.h"
#include "/EgtDev/Include/EGnScan.h"
#include "/EgtDev/Include/EGkBBox3d.h"
class GdbGroup ;
class IdManager ;
//----------------------------------------------------------------------------
class GdbNode
{
public :
virtual ~GdbNode( void) {}
virtual GdbNode* Clone( int nId, IdManager& IdMgr) const = 0 ;
virtual bool Save( std::ostream& osOut) const = 0 ;
virtual bool Load( const std::string& sType, Scanner& TheScanner, int& nParentId) = 0 ;
virtual bool GetLocalBBox( BBox3d& b3Loc) const = 0 ;
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const = 0 ;
virtual bool Translate( const Vector3d& vtMove) = 0 ;
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) = 0 ;
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad) = 0 ;
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) = 0 ;
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) = 0 ;
virtual bool ToGlob( const Frame3d& frRef) = 0 ;
virtual bool ToLoc( const Frame3d& frRef) = 0 ;
public :
GdbNode( void) ;
GdbNode* GetNext( void) { return m_pNext ; }
const GdbNode* GetNext( void) const { return m_pNext ; }
GdbNode* GetPrev( void) { return m_pPrev ; }
const GdbNode* GetPrev( void) const { return m_pPrev ; }
GdbGroup* GetParent( void) { return m_pParent ; }
const GdbGroup* GetParent( void) const { return m_pParent ; }
int GetParentId( void) const ;
bool AddTail( GdbGroup* pParent) ;
bool AddHead( GdbGroup* pParent) ;
bool InsertAfter( GdbNode* pRef) ;
bool InsertBefore( GdbNode* pRef) ;
bool Remove( void) ;
public :
int m_nId ;
private :
GdbNode* m_pNext ;
GdbNode* m_pPrev ;
GdbGroup* m_pParent ;
} ;
+214 -153
View File
@@ -1,12 +1,12 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// EgalTech 2013-2013 // EgalTech 2013-2013
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// File : GdbObj.cpp Data : 24.11.13 Versione : 1.3a1 // File : GdbObj.cpp Data : 05.03.14 Versione : 1.5c1
// Contenuto : Implementazione della classe CGdbObj oggetto del DB geometrico. // Contenuto : Implementazione della classe GdbObj.
// //
// //
// //
// Modifiche : 22.01.13 DS Creazione modulo. // Modifiche : 28.11.13 DS Creazione modulo.
// //
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -14,8 +14,8 @@
//--------------------------- Include ---------------------------------------- //--------------------------- Include ----------------------------------------
#include "stdafx.h" #include "stdafx.h"
#include "GdbObj.h" #include "GdbObj.h"
#include "GeoObjFactory.h" #include "GdbGroup.h"
#include "CurveAux.h" #include "Attribs.h"
#include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnStringUtils.h"
#include <new> #include <new>
@@ -23,190 +23,251 @@ using namespace std ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
GdbObj::GdbObj( void) GdbObj::GdbObj( void)
: m_nId( GDB_ID_NULL), m_pAttribs( nullptr),
m_pNext( nullptr), m_pPrev( nullptr), m_pParent( nullptr)
{ {
m_pGeoObj = nullptr ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
GdbObj::~GdbObj( void) GdbObj::~GdbObj( void)
{ {
if ( m_pGeoObj != nullptr) if ( m_pAttribs != nullptr)
delete m_pGeoObj ; delete m_pAttribs ;
m_pGeoObj = nullptr ; m_pAttribs = nullptr ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
GdbObj* bool
GdbObj::Clone( int nId, IdManager& IdMgr) const GdbObj::Copy( const GdbObj* pSou)
{ {
GdbObj* pGdbObj ; // elimino eventuali attributi pre-esistenti
if ( m_pAttribs != nullptr)
delete m_pAttribs ;
m_pAttribs = nullptr ;
// se l'oggetto sorgente non esiste
// alloco oggetto Gdb if ( pSou == nullptr) {
pGdbObj = new(nothrow) GdbObj ; m_nId = GDB_ID_NULL ;
if ( pGdbObj == nullptr) return false ;
return nullptr ;
// copio dati oggetto Gdb
pGdbObj->m_nId = nId ;
// ...
// copio oggetto Geo
pGdbObj->m_pGeoObj = m_pGeoObj->Clone() ;
if ( pGdbObj->m_pGeoObj == nullptr) {
delete pGdbObj ;
return nullptr ;
} }
return pGdbObj ; // copio Id
} m_nId = pSou->m_nId ;
//---------------------------------------------------------------------------- // copio gli attributi
GeoObjType if ( pSou->m_pAttribs != nullptr) {
GdbObj::GetType( void) const m_pAttribs = pSou->m_pAttribs->Clone() ;
{ if ( m_pAttribs == nullptr)
// non esiste l'oggetto geometrico
if ( m_pGeoObj == nullptr)
return GEO_NONE ;
return m_pGeoObj->GetType() ;
}
//----------------------------------------------------------------------------
bool
GdbObj::Save( std::ostream& osOut) const
{
// tipo entità
osOut << m_pGeoObj->GetKey() << endl ;
// nome
osOut << m_nId << "@" << GetParentId() << endl ;
// parametri geometrici
return m_pGeoObj->Save( osOut) ;
}
//----------------------------------------------------------------------------
bool
GdbObj::Load( const std::string& sType, Scanner& TheScanner, int& nParentId)
{
int nType ;
string sLine ;
STRVECTOR vsParams ;
// creo l'oggetto geometrico corrispondente
nType = GEOOBJ_KEYTOTYPE( sType) ;
m_pGeoObj = GEOOBJ_CREATE( nType) ;
if ( m_pGeoObj == nullptr)
return false ;
// leggo la prossima linea
if ( ! TheScanner.GetLine( sLine))
return false ;
// la divido in parametri
Tokenize( sLine, "@", vsParams) ;
// 2 parametri : Id e ParentId
if ( vsParams.size() != 2)
return false ;
// assegno l'identificativo
if ( ! FromString( vsParams[0], m_nId))
return false ;
// assegno l'Id del padre
if ( ! FromString( vsParams[1], nParentId))
return false ;
// parametri geometrici
return m_pGeoObj->Load( TheScanner) ;
}
//----------------------------------------------------------------------------
bool
GdbObj::GetLocalBBox( BBox3d& b3Loc) const
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->GetLocalBBox( b3Loc) ;
}
//----------------------------------------------------------------------------
bool
GdbObj::GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->GetBBox( frRef, b3Ref) ;
}
//----------------------------------------------------------------------------
bool
GdbObj::Translate( const Vector3d& vtMove)
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->Translate( vtMove) ;
}
//----------------------------------------------------------------------------
bool
GdbObj::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
}
//----------------------------------------------------------------------------
bool
GdbObj::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
{
if ( m_pGeoObj == nullptr)
return false ;
// se arco e scalatura non omogenea
if ( m_pGeoObj->GetType() == CRV_ARC &&
(fabs( dCoeffX - dCoeffY) > EPS_SMALL || fabs( dCoeffX - dCoeffZ) > EPS_SMALL)) {
// trasformo in curva di Bezier (semplice o composta)
ICurve* pCrvNew ;
if ( ! ArcToBezierCurve( GetCurve( m_pGeoObj), pCrvNew))
return false ; return false ;
// elimino l'arco e lo sostituisco con la curva di Bezier
delete m_pGeoObj ;
m_pGeoObj = pCrvNew ;
} }
// eseguo scalatura return true ;
return m_pGeoObj->Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ; }
//----------------------------------------------------------------------------
// Node
//----------------------------------------------------------------------------
int
GdbObj::GetParentId( void) const
{
if ( m_pParent != nullptr)
return m_pParent->m_nId ;
else
return GDB_ID_NULL ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
GdbObj::Mirror( const Point3d& ptOn, const Vector3d& vtNorm) GdbObj::AddTail( GdbGroup* pParent)
{ {
if ( m_pGeoObj == nullptr) // se il padre non è definito, errore
if ( pParent == nullptr)
return false ; return false ;
return m_pGeoObj->Mirror( ptOn, vtNorm) ; // se non ci sono figli
if ( pParent->m_pLastObj == nullptr) {
pParent->m_pLastObj = this ;
pParent->m_pFirstObj = this ;
m_pParent = pParent ;
m_pNext = nullptr ;
m_pPrev = nullptr ;
m_pParent->ObjCountInc() ;
return true ;
}
// caso standard
return InsertAfter( pParent->m_pLastObj) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
GdbObj::ToGlob( const Frame3d& frRef) GdbObj::AddHead( GdbGroup* pParent)
{ {
if ( m_pGeoObj == nullptr) // se il padre non è definito, errore
if ( pParent == nullptr)
return false ; return false ;
return m_pGeoObj->ToGlob( frRef) ; // se non ci sono figli
if ( pParent->m_pFirstObj == nullptr) {
pParent->m_pFirstObj = this ;
pParent->m_pLastObj = this ;
m_pParent = pParent ;
m_pNext = nullptr ;
m_pPrev = nullptr ;
m_pParent->ObjCountInc() ;
return true ;
}
// caso standard
return InsertBefore( pParent->m_pFirstObj) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
GdbObj::ToLoc( const Frame3d& frRef) GdbObj::InsertAfter( GdbObj* pRef)
{ {
if ( m_pGeoObj == nullptr) // se riferimento non definito, errore
if ( pRef == nullptr)
return false ; return false ;
return m_pGeoObj->ToLoc( frRef) ; // sistemazione puntatori di elemento inserito
m_pNext = pRef->m_pNext ;
m_pPrev = pRef ;
m_pParent = pRef->m_pParent ;
// sistemazione puntatori di elemento di riferimento
pRef->m_pNext = this ;
// sistemazione puntatori di eventuale elemento successivo
if ( m_pNext != nullptr)
m_pNext->m_pPrev = this ;
// sistemazione dell'eventuale padre
if ( m_pParent != nullptr) {
// se nuovo ultimo nodo
if ( m_pParent->m_pLastObj == pRef)
m_pParent->m_pLastObj = this ;
m_pParent->ObjCountInc() ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::InsertBefore( GdbObj* pRef)
{
// se riferimento non definito, errore
if ( pRef == nullptr)
return false ;
// sistemazione puntatori di elemento inserito
m_pNext = pRef ;
m_pPrev = pRef->m_pPrev ;
m_pParent = pRef->m_pParent ;
// sistemazione puntatori di elemento corrente
pRef->m_pPrev = this ;
// sistemazione puntatori di eventuale elemento precedente
if ( m_pPrev != nullptr)
m_pPrev->m_pNext = this ;
// sistemazione dell'eventuale padre
if ( m_pParent != nullptr) {
// se nuovo primo nodo
if ( m_pParent->m_pFirstObj == pRef)
m_pParent->m_pFirstObj = this ;
m_pParent->ObjCountInc() ;
}
return true ;
}
/*-------------------------------------------------------------------------*/
bool
GdbObj::Remove( void)
{
// sistemazione dell'eventuale padre
if ( m_pParent != nullptr) {
if ( m_pParent->m_pFirstObj == this)
m_pParent->m_pFirstObj = m_pNext ;
if ( m_pParent->m_pLastObj == this)
m_pParent->m_pLastObj = m_pPrev ;
m_pParent->ObjCountDec() ;
}
// sistemazione di eventuale precedente
if ( m_pPrev != nullptr)
m_pPrev->m_pNext = m_pNext ;
// sistemazione di eventuale successivo
if ( m_pNext != nullptr)
m_pNext->m_pPrev = m_pPrev ;
return true ;
}
//----------------------------------------------------------------------------
// Attribs
//----------------------------------------------------------------------------
bool
GdbObj::SaveAttribs( std::ostream& osOut) const
{
if ( m_pAttribs != nullptr)
return m_pAttribs->Save( osOut) ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::LoadAttribs( Scanner& TheScanner)
{
if ( GetSafeAttribs() == nullptr)
return false ;
return m_pAttribs->Load( TheScanner) ;
}
//----------------------------------------------------------------------------
Attribs*
GdbObj::GetSafeAttribs( void)
{
if ( m_pAttribs == nullptr) {
Attribs* pAttribs = new (nothrow) Attribs ;
if ( pAttribs == nullptr)
return nullptr ;
m_pAttribs = pAttribs ;
}
return m_pAttribs ;
}
//----------------------------------------------------------------------------
bool
GdbObj::SetColor( Color cCol)
{
// recupero gli attributi (se non ci sono, vengono creati)
Attribs* pAttribs = GetSafeAttribs() ;
if ( pAttribs == nullptr)
return false ;
// assegno il colore
pAttribs->SetColor( cCol) ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::GetColor( Color& cCol) const
{
// se non ci sono attributi o ci si deve riferire al padre
if ( m_pAttribs == nullptr ||
m_pAttribs->GetMaterial() == Attribs::MAT_PARENT) {
if ( GetParent() != nullptr)
return GetParent()->GetColor( cCol) ;
else
return false ;
}
// se il colore è definito
if ( m_pAttribs->GetMaterial() != Attribs::MAT_NULL) {
cCol = m_pAttribs->GetColor() ;
return true ;
}
return false ;
} }
+61 -22
View File
@@ -1,47 +1,86 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// EgalTech 2013-2013 // EgalTech 2013-2014
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// File : GdbObj.h Data : 08.04.13 Versione : 1.1c1 // File : GdbObj.h Data : 05.03.14 Versione : 1.5c1
// Contenuto : Dichiarazione della classe GdbObj. // Contenuto : Dichiarazione della classe GdbObj.
// //
// //
// //
// Modifiche : 22.01.13 DS Creazione modulo. // Modifiche : 28.11.13 DS Creazione modulo.
// //
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#pragma once #pragma once
#include "/EgtDev/Include/EGkGdbConst.h"
#include "/EgtDev/Include/EGkColor.h"
#include "/EgtDev/Include/EGnScan.h"
#include "/EgtDev/Include/EGkBBox3d.h"
#include <string> #include <string>
#include "/EgtDev/Include/EGkGeoObj.h"
#include "GdbNode.h"
class GdbGroup ;
class IdManager ;
class Attribs ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class GdbObj : public GdbNode class GdbObj
{ {
public : public :
virtual ~GdbObj( void) ; virtual ~GdbObj( void) ;
virtual GdbObj* Clone( int nId, IdManager& IdMgr) const ; virtual GdbObj* Clone( int nId, IdManager& IdMgr) const = 0 ;
virtual bool Save( std::ostream& osOut) const ; virtual bool Save( std::ostream& osOut) const = 0 ;
virtual bool Load( const std::string& sType, Scanner& TheScanner, int& nParentId) ; virtual bool Load( const std::string& sType, Scanner& TheScanner, int& nParentId) = 0 ;
virtual bool GetLocalBBox( BBox3d& b3Loc) const ; virtual bool GetLocalBBox( BBox3d& b3Loc) const = 0 ;
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const ; virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const = 0 ;
virtual bool Translate( const Vector3d& vtMove) ; virtual bool Translate( const Vector3d& vtMove) = 0 ;
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ; virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) = 0 ;
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad) = 0 ;
{ double dAngRad = dAngDeg * DEGTORAD ; virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) = 0 ;
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; } virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) = 0 ;
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ; virtual bool ToGlob( const Frame3d& frRef) = 0 ;
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ; virtual bool ToLoc( const Frame3d& frRef) = 0 ;
virtual bool ToGlob( const Frame3d& frRef) ;
virtual bool ToLoc( const Frame3d& frRef) ;
public : public :
GdbObj( void) ; GdbObj( void) ;
GeoObjType GetType( void) const ; bool Copy( const GdbObj* pSou) ;
public : public :
IGeoObj* m_pGeoObj ; bool SaveAttribs( std::ostream& osOut) const ;
bool LoadAttribs( Scanner& TheScanner) ;
Attribs* GetAttribs( void)
{ return m_pAttribs ; }
Attribs* GetSafeAttribs( void) ;
bool SetColor( Color cCol) ;
bool GetColor( Color& cCol) const ;
public :
GdbObj* GetNext( void)
{ return m_pNext ; }
const GdbObj* GetNext( void) const
{ return m_pNext ; }
GdbObj* GetPrev( void)
{ return m_pPrev ; }
const GdbObj* GetPrev( void) const
{ return m_pPrev ; }
GdbGroup* GetParent( void)
{ return m_pParent ; }
const GdbGroup* GetParent( void) const
{ return m_pParent ; }
int GetParentId( void) const ;
bool AddTail( GdbGroup* pParent) ;
bool AddHead( GdbGroup* pParent) ;
bool InsertAfter( GdbObj* pRef) ;
bool InsertBefore( GdbObj* pRef) ;
bool Remove( void) ;
public :
int m_nId ;
Attribs* m_pAttribs ;
private :
GdbObj* m_pNext ;
GdbObj* m_pPrev ;
GdbGroup* m_pParent ;
} ; } ;
+175 -117
View File
@@ -14,8 +14,9 @@
//--------------------------- Include ---------------------------------------- //--------------------------- Include ----------------------------------------
#include "stdafx.h" #include "stdafx.h"
#include "GeomDB.h" #include "GeomDB.h"
#include "GdbObj.h" #include "GdbGeo.h"
#include "DllMain.h" #include "DllMain.h"
#include "Attribs.h"
#include "/EgtDev/Include/EgnStringUtils.h" #include "/EgtDev/Include/EgnStringUtils.h"
#include "/EgtDev/Include/EgnStringConverter.h" #include "/EgtDev/Include/EgnStringConverter.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
@@ -36,6 +37,7 @@ CreateGeomDB( void)
GeomDB::GeomDB( void) GeomDB::GeomDB( void)
{ {
m_GrpRadix.m_nId = GDB_ID_ROOT ; m_GrpRadix.m_nId = GDB_ID_ROOT ;
m_GrpRadix.SetColor( Color( 0, 0, 0)) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -48,9 +50,10 @@ GeomDB::~GeomDB( void)
bool bool
GeomDB::Init( void) GeomDB::Init( void)
{ {
// imposto numero minimo buckets del map degli Id // imposto numero minimo buckets del map degli Id
m_IdManager.Init( 1024) ; m_IdManager.Init( 1024) ;
// imposto colore di default
m_GrpRadix.SetColor( Color( 0, 0, 0)) ;
return true ; return true ;
} }
@@ -93,7 +96,7 @@ GeomDB::Load( const std::string& sFileIn)
// ciclo di lettura dei nodi // ciclo di lettura dei nodi
bOk = true ; bOk = true ;
do { do {
if ( ! LoadOneNode( TheScanner, bEnd)) { if ( ! LoadOneObj( TheScanner, bEnd)) {
bOk = false ; bOk = false ;
string sOut = "GeomDbLoad : Error on line " + ToString( TheScanner.GetCurrLineNbr()) ; string sOut = "GeomDbLoad : Error on line " + ToString( TheScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEGkLogger(), sOut.c_str()) LOG_ERROR( GetEGkLogger(), sOut.c_str())
@@ -130,11 +133,11 @@ GeomDB::LoadStart( Scanner& TheScanner)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
GeomDB::LoadOneNode( Scanner& TheScanner, bool& bEnd) GeomDB::LoadOneObj( Scanner& TheScanner, bool& bEnd)
{ {
int nParentId ; int nParentId ;
string sType ; string sType ;
GdbNode* pGdbNode ; GdbObj* pGdbObj ;
// in generale non è fine file // in generale non è fine file
@@ -151,27 +154,27 @@ GeomDB::LoadOneNode( Scanner& TheScanner, bool& bEnd)
} }
// se gruppo // se gruppo
else if ( sType == GdbGroup::GetKey()) { else if ( sType == GdbGroup::GetKey()) {
pGdbNode = new( nothrow) GdbGroup ; pGdbObj = new( nothrow) GdbGroup ;
} }
// se copia TODO ("X_CPY").. // se copia TODO ("X_CPY")..
//else if ( sType == GdbCopy::GetKey) { //else if ( sType == GdbCopy::GetKey) {
// pGdbNode = new( nothrow) GdbCopy ; // pGdbObj = new( nothrow) GdbCopy ;
//} //}
// altrimenti oggetto geometrico // altrimenti oggetto geometrico
else else
pGdbNode = new( nothrow) GdbObj ; pGdbObj = new( nothrow) GdbGeo ;
// verifico il nodo GDB // verifico l'oggetto GDB
if ( pGdbNode == nullptr) if ( pGdbObj == nullptr)
return false ; return false ;
// se lettura dati e inserimento nel DB vanno bene // se lettura dati e inserimento nel DB vanno bene
if ( pGdbNode->Load( sType, TheScanner, nParentId) && if ( pGdbObj->Load( sType, TheScanner, nParentId) &&
AddToGeomDB( pGdbNode, nParentId)) AddToGeomDB( pGdbObj, nParentId))
return true ; return true ;
// altrimenti errore // altrimenti errore
else { else {
delete pGdbNode ; delete pGdbObj ;
return false ; return false ;
} }
} }
@@ -190,15 +193,15 @@ GeomDB::Save( const std::string& sFileOut) const
// intestazione // intestazione
ofSave << "START" << endl ; ofSave << "START" << endl ;
ofSave << "GeomDB,1.4a4" << endl ; ofSave << "GeomDB,1.5c1" << endl ;
// ciclo di scrittura degli oggetti // ciclo di scrittura degli oggetti
bool bOk = true ; bool bOk = true ;
const GdbNode* pGdbNode = m_GrpRadix.GetFirstNode() ; const GdbObj* pGdbObj = m_GrpRadix.GetFirstObj() ;
while ( pGdbNode != nullptr) { while ( pGdbObj != nullptr) {
// oggetto geometrico // oggetto geometrico
if ( ! pGdbNode->Save( ofSave)) if ( ! pGdbObj->Save( ofSave))
bOk = false ; bOk = false ;
pGdbNode = pGdbNode->GetNext() ; pGdbObj = pGdbObj->GetNext() ;
} }
ofSave << "END" << endl ; ofSave << "END" << endl ;
@@ -210,14 +213,14 @@ GeomDB::Save( const std::string& sFileOut) const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
GeomDB::ExistsNode( int nId) const GeomDB::ExistsObj( int nId) const
{ {
return ( (const_cast<GeomDB*>(this))->GetGdbNode(nId) != nullptr) ; return ( (const_cast<GeomDB*>(this))->GetGdbObj( nId) != nullptr) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
GdbNode* GdbObj*
GeomDB::GetGdbNode( int nId) GeomDB::GetGdbObj( int nId)
{ {
// impossibile // impossibile
if ( nId < GDB_ID_ROOT) if ( nId < GDB_ID_ROOT)
@@ -227,19 +230,19 @@ GeomDB::GetGdbNode( int nId)
return &m_GrpRadix ; return &m_GrpRadix ;
// un nodo qualubque // un nodo qualubque
else else
return m_IdManager.FindNode( nId) ; return m_IdManager.FindObj( nId) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
GeomDB::AddToGeomDB( GdbNode* pGNode, int nParentId) GeomDB::AddToGeomDB( GdbObj* pGObj, int nParentId)
{ {
// verifico validità oggetto puntato // verifico validità oggetto puntato
if ( pGNode == nullptr) if ( pGObj == nullptr)
return false ; return false ;
// verifica validità e unicità del nome // verifica validità e unicità del nome
if ( pGNode->m_nId <= GDB_ID_ROOT || ExistsNode( pGNode->m_nId)) if ( pGObj->m_nId <= GDB_ID_ROOT || ExistsObj( pGObj->m_nId))
return false ; return false ;
// cerco il padre // cerco il padre
@@ -247,14 +250,14 @@ GeomDB::AddToGeomDB( GdbNode* pGNode, int nParentId)
if ( pGroup == nullptr) if ( pGroup == nullptr)
return false ; return false ;
// inserisco in coda alla lista del padre // inserisco in coda alla lista del padre
if ( ! pGNode->AddTail( pGroup)) if ( ! pGObj->AddTail( pGroup))
return false ; return false ;
// aggiorno gestore Id // aggiorno gestore Id
m_IdManager.UpdateMaxId( pGNode->m_nId) ; m_IdManager.UpdateMaxId( pGObj->m_nId) ;
// inserisco in mappa nomi // inserisco in mappa nomi
return m_IdManager.AddNode( pGNode->m_nId, pGNode) ; return m_IdManager.AddObj( pGObj->m_nId, pGObj) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -270,7 +273,7 @@ GeomDB::AddGroup( int nId, int nParentId, const Frame3d& frFrame)
// verifico validità Id // verifico validità Id
if ( nId <= GDB_ID_ROOT) if ( nId <= GDB_ID_ROOT)
nId = m_IdManager.GetNewId() ; nId = m_IdManager.GetNewId() ;
if ( ExistsNode( nId)) if ( ExistsObj( nId))
return GDB_ID_NULL ; return GDB_ID_NULL ;
// alloco gruppo Gdb // alloco gruppo Gdb
pGdbGroup = new(nothrow) GdbGroup ; pGdbGroup = new(nothrow) GdbGroup ;
@@ -293,7 +296,7 @@ GeomDB::AddGroup( int nId, int nParentId, const Frame3d& frFrame)
int int
GeomDB::AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj) GeomDB::AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj)
{ {
GdbObj* pGdbObj ; GdbGeo* pGdbGeo ;
// assegno GeoObj a gestore puntatore con rilascio automatico // assegno GeoObj a gestore puntatore con rilascio automatico
@@ -301,22 +304,22 @@ GeomDB::AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj)
// verifico validità identificativo // verifico validità identificativo
if ( nId <= GDB_ID_ROOT) if ( nId <= GDB_ID_ROOT)
nId = m_IdManager.GetNewId() ; nId = m_IdManager.GetNewId() ;
if ( ExistsNode( nId)) if ( ExistsObj( nId))
return GDB_ID_NULL ; return GDB_ID_NULL ;
// verifico validità oggetto Geo // verifico validità oggetto Geo
if ( ! IsValid( pRPGeoObj) || ! pRPGeoObj->IsValid()) if ( ! IsValid( pRPGeoObj) || ! pRPGeoObj->IsValid())
return GDB_ID_NULL ; return GDB_ID_NULL ;
// alloco oggetto Gdb // alloco oggetto Gdb
pGdbObj = new(nothrow) GdbObj ; pGdbGeo = new(nothrow) GdbGeo ;
if ( pGdbObj == nullptr) if ( pGdbGeo == nullptr)
return GDB_ID_NULL ; return GDB_ID_NULL ;
// assegno identificativo // assegno identificativo
pGdbObj->m_nId = nId ; pGdbGeo->m_nId = nId ;
// assegno dati // assegno dati
pGdbObj->m_pGeoObj = Release( pRPGeoObj) ; pGdbGeo->m_pGeoObj = Release( pRPGeoObj) ;
// inserisco nel DB // inserisco nel DB
if ( ! AddToGeomDB( pGdbObj, nParentId)) { if ( ! AddToGeomDB( pGdbGeo, nParentId)) {
delete pGdbObj ; delete pGdbGeo ;
return GDB_ID_NULL ; return GDB_ID_NULL ;
} }
@@ -327,18 +330,18 @@ GeomDB::AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj)
GdbType GdbType
GeomDB::GetGdbType( int nId) const GeomDB::GetGdbType( int nId) const
{ {
const GdbNode* pGdbNode ; const GdbObj* pGdbObj ;
// recupero il nodo // recupero l'oggetto
if ( ( pGdbNode = (const_cast<GeomDB*> (this))->GetGdbNode( nId)) == nullptr) if ( ( pGdbObj = (const_cast<GeomDB*> (this))->GetGdbObj( nId)) == nullptr)
return GDB_NONE ; return GDB_NONE ;
// se oggetto geometrico // se oggetto geometrico
if ( ::GetGdbObj( pGdbNode) != nullptr) if ( ::GetGdbGeo( pGdbObj) != nullptr)
return GDB_GEO ; return GDB_GEO ;
// se gruppo // se gruppo
else if ( ::GetGdbGroup( pGdbNode) != nullptr) else if ( ::GetGdbGroup( pGdbObj) != nullptr)
return GDB_GROUP ; return GDB_GROUP ;
// altro // altro
else else
@@ -349,25 +352,21 @@ GeomDB::GetGdbType( int nId) const
IGeoObj* IGeoObj*
GeomDB::GetGeoObj( int nId) GeomDB::GetGeoObj( int nId)
{ {
const GdbObj* pGdbObj ;
// recupero l'oggetto Gdb // recupero l'oggetto Gdb
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr) const GdbGeo* pGdbGeo ;
if ( ( pGdbGeo = GetGdbGeo( nId)) == nullptr)
return nullptr ; return nullptr ;
// restituisco il suo contenuto geometrico // restituisco il suo contenuto geometrico
return pGdbObj->m_pGeoObj ; return pGdbGeo->m_pGeoObj ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
IGeoFrame3d* IGeoFrame3d*
GeomDB::GetGeoFrame( int nId) GeomDB::GetGeoFrame( int nId)
{ {
GdbGroup* pGdbGroup ;
// recupero il gruppo Gdb // recupero il gruppo Gdb
GdbGroup* pGdbGroup ;
if ( ( pGdbGroup = GetGdbGroup( nId)) == nullptr) if ( ( pGdbGroup = GetGdbGroup( nId)) == nullptr)
return nullptr ; return nullptr ;
@@ -404,7 +403,7 @@ GeomDB::GetGroupGlobFrame( int nId, Frame3d& frGlob) const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int int
GeomDB::GetGroupNodes( int nId) const GeomDB::GetGroupObjs( int nId) const
{ {
// recupero il gruppo Gdb // recupero il gruppo Gdb
const GdbGroup* pGdbGroup ; const GdbGroup* pGdbGroup ;
@@ -412,35 +411,35 @@ GeomDB::GetGroupNodes( int nId) const
return 0 ; return 0 ;
// restituisco il numero di nodi (figli) // restituisco il numero di nodi (figli)
return pGdbGroup->GetNodeCount() ; return pGdbGroup->GetObjCount() ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int int
GeomDB::GetParentId( int nId) const GeomDB::GetParentId( int nId) const
{ {
// recupero il nodo Gdb // recupero l'oggetto Gdb
const GdbNode* pGdbNode ; const GdbObj* pGdbObj ;
if ( ( pGdbNode = (const_cast<GeomDB*> (this))->GetGdbNode( nId)) == nullptr) if ( ( pGdbObj = (const_cast<GeomDB*> (this))->GetGdbObj( nId)) == nullptr)
return GDB_ID_NULL ; return GDB_ID_NULL ;
// restituisco l'Id del padre // restituisco l'Id del padre
return pGdbNode->GetParentId() ; return pGdbObj->GetParentId() ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
GeomDB::GetLocalBBox( int nId, BBox3d& b3Loc) const GeomDB::GetLocalBBox( int nId, BBox3d& b3Loc) const
{ {
const GdbNode* pGdbNode ; const GdbObj* pGdbObj ;
// recupero l'oggetto // recupero l'oggetto
if ( ( pGdbNode = (const_cast<GeomDB*> (this))->GetGdbNode( nId)) == nullptr) if ( ( pGdbObj = (const_cast<GeomDB*> (this))->GetGdbObj( nId)) == nullptr)
return false ; return false ;
// eseguo l'operazione // eseguo l'operazione
return pGdbNode->GetLocalBBox( b3Loc) ; return pGdbObj->GetLocalBBox( b3Loc) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -448,17 +447,17 @@ bool
GeomDB::GetGlobalBBox( int nId, BBox3d& b3Glob) const GeomDB::GetGlobalBBox( int nId, BBox3d& b3Glob) const
{ {
// recupero l'oggetto // recupero l'oggetto
const GdbNode* pGdbNode ; const GdbObj* pGdbObj ;
if ( ( pGdbNode = (const_cast<GeomDB*> (this))->GetGdbNode( nId)) == nullptr) if ( ( pGdbObj = (const_cast<GeomDB*> (this))->GetGdbObj( nId)) == nullptr)
return false ; return false ;
// recupero il riferimento globale del gruppo cui appartiene // recupero il riferimento globale del gruppo cui appartiene
Frame3d frGlob ; Frame3d frGlob ;
if ( ! GetGroupGlobFrame( pGdbNode->GetParentId(), frGlob)) if ( ! GetGroupGlobFrame( pGdbObj->GetParentId(), frGlob))
return false ; return false ;
// eseguo l'operazione // eseguo l'operazione
return pGdbNode->GetBBox( frGlob, b3Glob) ; return pGdbObj->GetBBox( frGlob, b3Glob) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -466,20 +465,20 @@ bool
GeomDB::GetRefBBox( int nId, const Frame3d& frRef, BBox3d& b3Ref) const GeomDB::GetRefBBox( int nId, const Frame3d& frRef, BBox3d& b3Ref) const
{ {
// recupero l'oggetto // recupero l'oggetto
const GdbNode* pGdbNode ; const GdbObj* pGdbObj ;
if ( ( pGdbNode = (const_cast<GeomDB*> (this))->GetGdbNode( nId)) == nullptr) if ( ( pGdbObj = (const_cast<GeomDB*> (this))->GetGdbObj( nId)) == nullptr)
return false ; return false ;
// recupero il riferimento globale del gruppo cui appartiene // recupero il riferimento globale del gruppo cui appartiene
Frame3d frGlob ; Frame3d frGlob ;
if ( ! GetGroupGlobFrame( pGdbNode->GetParentId(), frGlob)) if ( ! GetGroupGlobFrame( pGdbObj->GetParentId(), frGlob))
return false ; return false ;
// lo porto nel riferimento passato // lo porto nel riferimento passato
frGlob.ToLoc( frRef) ; frGlob.ToLoc( frRef) ;
// eseguo l'operazione // eseguo l'operazione
return pGdbNode->GetBBox( frGlob, b3Ref) ; return pGdbObj->GetBBox( frGlob, b3Ref) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -489,22 +488,22 @@ GeomDB::Copy( int nIdSou, int nIdDest, int nParentIdDest)
// verifico Id destinazione // verifico Id destinazione
if ( nIdDest <= GDB_ID_ROOT) if ( nIdDest <= GDB_ID_ROOT)
nIdDest = m_IdManager.GetNewId() ; nIdDest = m_IdManager.GetNewId() ;
if ( ExistsNode( nIdDest)) if ( ExistsObj( nIdDest))
return GDB_ID_NULL ; return GDB_ID_NULL ;
// verifico esistenza del sorgente // verifico esistenza del sorgente
GdbNode* pGdNSou ; GdbObj* pGdOSou ;
if ( ( pGdNSou = GetGdbNode( nIdSou)) == nullptr) if ( ( pGdOSou = GetGdbObj( nIdSou)) == nullptr)
return GDB_ID_NULL ; return GDB_ID_NULL ;
// eseguo la copia // eseguo la copia
GdbNode* pGdNDest ; GdbObj* pGdODest ;
if ( ( pGdNDest = pGdNSou->Clone( nIdDest, m_IdManager)) == nullptr) if ( ( pGdODest = pGdOSou->Clone( nIdDest, m_IdManager)) == nullptr)
return GDB_ID_NULL ; return GDB_ID_NULL ;
// inserisco nel DB // inserisco nel DB
if ( ! AddToGeomDB( pGdNDest, nParentIdDest)) { if ( ! AddToGeomDB( pGdODest, nParentIdDest)) {
delete pGdNDest ; delete pGdODest ;
return GDB_ID_NULL ; return GDB_ID_NULL ;
} }
@@ -518,12 +517,12 @@ GeomDB::CopyGlob( int nIdSou, int nIdDest, int nParentIdDest)
// verifico Id destinazione // verifico Id destinazione
if ( nIdDest <= GDB_ID_ROOT) if ( nIdDest <= GDB_ID_ROOT)
nIdDest = m_IdManager.GetNewId() ; nIdDest = m_IdManager.GetNewId() ;
if ( ExistsNode( nIdDest)) if ( ExistsObj( nIdDest))
return GDB_ID_NULL ; return GDB_ID_NULL ;
// verifico esistenza del sorgente // verifico esistenza del sorgente
GdbNode* pGdNSou ; GdbObj* pGdOSou ;
if ( ( pGdNSou = GetGdbNode( nIdSou)) == nullptr) if ( ( pGdOSou = GetGdbObj( nIdSou)) == nullptr)
return GDB_ID_NULL ; return GDB_ID_NULL ;
// recupero il riferimento del sorgente // recupero il riferimento del sorgente
@@ -537,19 +536,19 @@ GeomDB::CopyGlob( int nIdSou, int nIdDest, int nParentIdDest)
return false ; return false ;
// eseguo la copia // eseguo la copia
GdbNode* pGdNDest ; GdbObj* pGdODest ;
if ( ( pGdNDest = pGdNSou->Clone( nIdDest, m_IdManager)) == nullptr) if ( ( pGdODest = pGdOSou->Clone( nIdDest, m_IdManager)) == nullptr)
return GDB_ID_NULL ; return GDB_ID_NULL ;
// porto la copia da riferimento sorgente a quello destinazione // porto la copia da riferimento sorgente a quello destinazione
if ( ! AreSameFrame( frSou, frDest)) { if ( ! AreSameFrame( frSou, frDest)) {
pGdNDest->ToGlob( frSou) ; pGdODest->ToGlob( frSou) ;
pGdNDest->ToLoc( frDest) ; pGdODest->ToLoc( frDest) ;
} }
// inserisco nel DB // inserisco nel DB
if ( ! AddToGeomDB( pGdNDest, nParentIdDest)) { if ( ! AddToGeomDB( pGdODest, nParentIdDest)) {
delete pGdNDest ; delete pGdODest ;
return GDB_ID_NULL ; return GDB_ID_NULL ;
} }
@@ -560,8 +559,8 @@ GeomDB::CopyGlob( int nIdSou, int nIdDest, int nParentIdDest)
bool bool
GeomDB::Erase( int nId) GeomDB::Erase( int nId)
{ {
INTPGDBN_UMAP::const_iterator Iter ; INTPGDBO_UMAP::const_iterator Iter ;
GdbNode* pGdbNode ; GdbObj* pGdbObj ;
// non si può cancellare il gruppo radice (escludo anche Id non validi) // non si può cancellare il gruppo radice (escludo anche Id non validi)
@@ -569,18 +568,18 @@ GeomDB::Erase( int nId)
return false ; return false ;
// recupero l'oggetto // recupero l'oggetto
pGdbNode = m_IdManager.FindNode( nId) ; pGdbObj = m_IdManager.FindObj( nId) ;
if ( pGdbNode == nullptr) if ( pGdbObj == nullptr)
return false ; return false ;
// elimino da mappa dei nomi // elimino da mappa dei nomi
m_IdManager.RemoveNode( nId) ; m_IdManager.RemoveObj( nId) ;
// lo tolgo dalla lista // lo tolgo dalla lista
pGdbNode->Remove() ; pGdbObj->Remove() ;
// lo disalloco (distruttore virtuale) // lo disalloco (distruttore virtuale)
delete pGdbNode ; delete pGdbObj ;
return true ; return true ;
} }
@@ -590,11 +589,11 @@ bool
GeomDB::Translate( int nId, const Vector3d& vtMove) GeomDB::Translate( int nId, const Vector3d& vtMove)
{ {
// recupero l'oggetto // recupero l'oggetto
GdbNode* pGdbNode ; GdbObj* pGdbObj ;
if ( ( pGdbNode = GetGdbNode( nId)) == nullptr) if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ; return false ;
// eseguo la traslazione // eseguo la traslazione
return pGdbNode->Translate( vtMove) ; return pGdbObj->Translate( vtMove) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -602,8 +601,8 @@ bool
GeomDB::TranslateGlob( int nId, const Vector3d& vtMove) GeomDB::TranslateGlob( int nId, const Vector3d& vtMove)
{ {
// recupero l'oggetto // recupero l'oggetto
GdbNode* pGdbNode ; GdbObj* pGdbObj ;
if ( ( pGdbNode = GetGdbNode( nId)) == nullptr) if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ; return false ;
// recupero il riferimento in cui è immerso // recupero il riferimento in cui è immerso
Frame3d frObj ; Frame3d frObj ;
@@ -614,7 +613,7 @@ GeomDB::TranslateGlob( int nId, const Vector3d& vtMove)
if ( ! vtMoveLoc.ToLoc( frObj)) if ( ! vtMoveLoc.ToLoc( frObj))
return false ; return false ;
// eseguo la traslazione // eseguo la traslazione
return pGdbNode->Translate( vtMoveLoc) ; return pGdbObj->Translate( vtMoveLoc) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -622,11 +621,11 @@ bool
GeomDB::Rotate( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) GeomDB::Rotate( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
{ {
// recupero l'oggetto // recupero l'oggetto
GdbNode* pGdbNode ; GdbObj* pGdbObj ;
if ( ( pGdbNode = GetGdbNode( nId)) == nullptr) if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ; return false ;
// eseguo la rotazione // eseguo la rotazione
return pGdbNode->Rotate( ptAx, vtAx, dCosAng, dSinAng) ; return pGdbObj->Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -634,8 +633,8 @@ bool
GeomDB::RotateGlob( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) GeomDB::RotateGlob( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
{ {
// recupero l'oggetto // recupero l'oggetto
GdbNode* pGdbNode ; GdbObj* pGdbObj ;
if ( ( pGdbNode = GetGdbNode( nId)) == nullptr) if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ; return false ;
// recupero il riferimento in cui è immerso // recupero il riferimento in cui è immerso
Frame3d frObj ; Frame3d frObj ;
@@ -649,7 +648,7 @@ GeomDB::RotateGlob( int nId, const Point3d& ptAx, const Vector3d& vtAx, double d
if ( ! vtAxLoc.ToLoc( frObj)) if ( ! vtAxLoc.ToLoc( frObj))
return false ; return false ;
// eseguo la rotazione // eseguo la rotazione
return pGdbNode->Rotate( ptAxLoc, vtAxLoc, dCosAng, dSinAng) ; return pGdbObj->Rotate( ptAxLoc, vtAxLoc, dCosAng, dSinAng) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -657,11 +656,11 @@ bool
GeomDB::Scale( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) GeomDB::Scale( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
{ {
// recupero l'oggetto // recupero l'oggetto
GdbNode* pGdbNode ; GdbObj* pGdbObj ;
if ( ( pGdbNode = GetGdbNode( nId)) == nullptr) if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ; return false ;
// eseguo la scalatura // eseguo la scalatura
return pGdbNode->Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ; return pGdbObj->Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -669,8 +668,8 @@ bool
GeomDB::ScaleGlob( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) GeomDB::ScaleGlob( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
{ {
// recupero l'oggetto // recupero l'oggetto
GdbNode* pGdbNode ; GdbObj* pGdbObj ;
if ( ( pGdbNode = GetGdbNode( nId)) == nullptr) if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ; return false ;
// recupero il riferimento in cui è immerso // recupero il riferimento in cui è immerso
Frame3d frObj ; Frame3d frObj ;
@@ -681,7 +680,7 @@ GeomDB::ScaleGlob( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY
if ( ! frRefLoc.ToLoc( frObj)) if ( ! frRefLoc.ToLoc( frObj))
return false ; return false ;
// eseguo la scalatura // eseguo la scalatura
return pGdbNode->Scale( frRefLoc, dCoeffX, dCoeffY, dCoeffZ) ; return pGdbObj->Scale( frRefLoc, dCoeffX, dCoeffY, dCoeffZ) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -689,11 +688,11 @@ bool
GeomDB::Mirror( int nId, const Point3d& ptOn, const Vector3d& vtNorm) GeomDB::Mirror( int nId, const Point3d& ptOn, const Vector3d& vtNorm)
{ {
// recupero l'oggetto // recupero l'oggetto
GdbNode* pGdbNode ; GdbObj* pGdbObj ;
if ( ( pGdbNode = GetGdbNode( nId)) == nullptr) if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ; return false ;
// eseguo l'operazione // eseguo l'operazione
return pGdbNode->Mirror( ptOn, vtNorm) ; return pGdbObj->Mirror( ptOn, vtNorm) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -701,8 +700,8 @@ bool
GeomDB::MirrorGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm) GeomDB::MirrorGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm)
{ {
// recupero l'oggetto // recupero l'oggetto
GdbNode* pGdbNode ; GdbObj* pGdbObj ;
if ( ( pGdbNode = GetGdbNode( nId)) == nullptr) if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ; return false ;
// recupero il riferimento in cui è immerso // recupero il riferimento in cui è immerso
Frame3d frObj ; Frame3d frObj ;
@@ -716,5 +715,64 @@ GeomDB::MirrorGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm)
if ( ! vtNormLoc.ToLoc( frObj)) if ( ! vtNormLoc.ToLoc( frObj))
return false ; return false ;
// eseguo l'operazione // eseguo l'operazione
return pGdbNode->Mirror( ptOnLoc, vtNormLoc) ; return pGdbObj->Mirror( ptOnLoc, vtNormLoc) ;
}
//----------------------------------------------------------------------------
// Attributes
//----------------------------------------------------------------------------
bool
GeomDB::DumpAttributes( int nId, string& sOut, const char* szNewLine) const
{
// recupero l'oggetto
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*>(this))->GetGdbObj( nId)) == nullptr)
return false ;
// eseguo il dump
if ( pGdbObj->m_pAttribs != nullptr)
return pGdbObj->m_pAttribs->Dump( sOut, szNewLine) ;
else {
Attribs attr ;
return attr.Dump( sOut, szNewLine) ;
}
}
//----------------------------------------------------------------------------
bool
GeomDB::SetDefaultColor( Color cCol)
{
// recupero l'oggetto
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( GDB_ID_ROOT)) == nullptr)
return false ;
// assegno il colore
return pGdbObj->SetColor( cCol) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SetColor( int nId, Color cCol)
{
// recupero l'oggetto
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// assegno il colore
return pGdbObj->SetColor( cCol) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetColor( int nId, Color& cCol) const
{
// recupero l'oggetto
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*>(this))->GetGdbObj( nId)) == nullptr)
return false ;
// recupero il colore
return pGdbObj->GetColor( cCol) ;
} }
+24 -18
View File
@@ -13,7 +13,7 @@
#pragma once #pragma once
#include "GdbObj.h" #include "GdbGeo.h"
#include "GdbGroup.h" #include "GdbGroup.h"
#include "IdManager.h" #include "IdManager.h"
#include "/EgtDev/Include/EGkGeomDB.h" #include "/EgtDev/Include/EGkGeomDB.h"
@@ -34,7 +34,7 @@ class GeomDB : public IGeomDB
virtual bool Clear( void) ; virtual bool Clear( void) ;
virtual bool Load( const std::string& sFileIn) ; virtual bool Load( const std::string& sFileIn) ;
virtual bool Save( const std::string& sFileOut) const ; virtual bool Save( const std::string& sFileOut) const ;
virtual bool ExistsNode( int nId) const ; virtual bool ExistsObj( int nId) const ;
virtual int AddGroup( int nId, int nParentId, const Frame3d& frFrame) ; virtual int AddGroup( int nId, int nParentId, const Frame3d& frFrame) ;
virtual int AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj) ; virtual int AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj) ;
virtual GdbType GetGdbType( int nId) const ; virtual GdbType GetGdbType( int nId) const ;
@@ -42,7 +42,7 @@ class GeomDB : public IGeomDB
virtual IGeoFrame3d* GetGeoFrame( int nId) ; virtual IGeoFrame3d* GetGeoFrame( int nId) ;
virtual bool GetGroupFrame( int nId, Frame3d& frGrp) const ; virtual bool GetGroupFrame( int nId, Frame3d& frGrp) const ;
virtual bool GetGroupGlobFrame( int nId, Frame3d& frGlob) const ; virtual bool GetGroupGlobFrame( int nId, Frame3d& frGlob) const ;
virtual int GetGroupNodes( int nId) const ; virtual int GetGroupObjs( int nId) const ;
virtual int GetParentId( int nId) const ; virtual int GetParentId( int nId) const ;
virtual bool GetGlobFrame( int nId, Frame3d& frGlob) const virtual bool GetGlobFrame( int nId, Frame3d& frGlob) const
{ return GetGroupGlobFrame( GetParentId( nId), frGlob) ; } { return GetGroupGlobFrame( GetParentId( nId), frGlob) ; }
@@ -66,29 +66,35 @@ class GeomDB : public IGeomDB
virtual bool ScaleGlob( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ; virtual bool ScaleGlob( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
virtual bool Mirror( int nId, const Point3d& ptOn, const Vector3d& vtNorm) ; virtual bool Mirror( int nId, const Point3d& ptOn, const Vector3d& vtNorm) ;
virtual bool MirrorGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm) ; virtual bool MirrorGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm) ;
virtual bool DumpAttributes( int nId, std::string& sOut, const char* szNewLine) const ;
virtual bool SetDefaultColor( Color cCol) ;
virtual bool SetColor( int nId, Color cCol) ;
virtual bool GetColor( int nId, Color& cCol) const ;
public : public :
GeomDB( void) ; GeomDB( void) ;
private : private :
GdbNode* GetGdbNode( int nId) ; GdbObj* GetGdbObj( int nId) ;
GdbObj* GetGdbObj( int nId) { return dynamic_cast<GdbObj*>( GetGdbNode( nId)) ; } GdbGeo* GetGdbGeo( int nId)
GdbGroup* GetGdbGroup( int nId) { return dynamic_cast<GdbGroup*>( GetGdbNode( nId)) ; } { return dynamic_cast<GdbGeo*>( GetGdbObj( nId)) ; }
bool AddToGeomDB( GdbNode* pGNode, int nParentId) ; GdbGroup* GetGdbGroup( int nId)
{ return dynamic_cast<GdbGroup*>( GetGdbObj( nId)) ; }
bool AddToGeomDB( GdbObj* pGObj, int nParentId) ;
bool LoadStart( Scanner& TheScanner) ; bool LoadStart( Scanner& TheScanner) ;
bool LoadOneNode( Scanner& TheScanner, bool& bEnd) ; bool LoadOneObj( Scanner& TheScanner, bool& bEnd) ;
private : private :
GdbGroup m_GrpRadix ; // gruppo radice di tutto il DB GdbGroup m_GrpRadix ; // gruppo radice di tutto il DB
IdManager m_IdManager ; // gestore del nuovo Id IdManager m_IdManager ; // gestore del nuovo Id
} ; } ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
inline const GdbObj* GetGdbObj( const GdbNode* pGNode) inline const GdbGeo* GetGdbGeo( const GdbObj* pGObj)
{ return dynamic_cast<const GdbObj*>(pGNode) ; } { return dynamic_cast<const GdbGeo*>(pGObj) ; }
inline GdbObj* GetGdbObj( GdbNode* pGNode) inline GdbGeo* GetGdbGeo( GdbObj* pGObj)
{ return dynamic_cast<GdbObj*>(pGNode) ; } { return dynamic_cast<GdbGeo*>(pGObj) ; }
inline const GdbGroup* GetGdbGroup( const GdbNode* pGNode) inline const GdbGroup* GetGdbGroup( const GdbObj* pGObj)
{ return dynamic_cast<const GdbGroup*>(pGNode) ; } { return dynamic_cast<const GdbGroup*>(pGObj) ; }
inline GdbGroup* GetGdbGroup( GdbNode* pGNode) inline GdbGroup* GetGdbGroup( GdbObj* pGObj)
{ return dynamic_cast<GdbGroup*>(pGNode) ; } { return dynamic_cast<GdbGroup*>(pGObj) ; }
+25 -18
View File
@@ -17,30 +17,37 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
typedef std::unordered_map< int, GdbNode*> INTPGDBN_UMAP ; typedef std::unordered_map< int, GdbObj*> INTPGDBO_UMAP ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class IdManager class IdManager
{ {
public : public :
IdManager( void) { m_nMaxId = 0 ; } IdManager( void)
bool Init( int nBuckets) { m_GdbIdMap.rehash( nBuckets) ; return true ; } { m_nMaxId = 0 ; }
bool Clear( void) { m_GdbIdMap.clear() ; m_nMaxId = 0 ; return true ; } bool Init( int nBuckets)
GdbNode* FindNode( int nId) { m_GdbIdMap.rehash( nBuckets) ; return true ; }
{ INTPGDBN_UMAP::const_iterator Iter = m_GdbIdMap.find( nId) ; bool Clear( void)
if ( Iter != m_GdbIdMap.end()) { m_GdbIdMap.clear() ; m_nMaxId = 0 ; return true ; }
return Iter->second ; GdbObj* FindObj( int nId)
else { INTPGDBO_UMAP::const_iterator Iter = m_GdbIdMap.find( nId) ;
return nullptr ; } if ( Iter != m_GdbIdMap.end())
bool AddNode( int nId, GdbNode* pGNode) return Iter->second ;
{ return m_GdbIdMap.insert( std::pair< int, GdbNode*>( nId, pGNode)).second ; } else
bool RemoveNode( int nId) return nullptr ; }
{ m_GdbIdMap.erase( nId) ; return true ; } bool AddObj( int nId, GdbObj* pGObj)
int GetNewId( void) { return ++ m_nMaxId ; } { if ( nId > m_nMaxId) m_nMaxId = nId ;
int GetMaxId( void) const { return m_nMaxId ; } return m_GdbIdMap.insert( std::pair< int, GdbObj*>( nId, pGObj)).second ; }
void UpdateMaxId( int nId) { if ( nId > m_nMaxId) m_nMaxId = nId ; } bool RemoveObj( int nId)
{ m_GdbIdMap.erase( nId) ; return true ; }
int GetNewId( void)
{ return ( ++ m_nMaxId) ; }
int GetMaxId( void) const
{ return m_nMaxId ; }
void UpdateMaxId( int nId)
{ if ( nId > m_nMaxId) m_nMaxId = nId ; }
private : private :
int m_nMaxId ; int m_nMaxId ;
INTPGDBN_UMAP m_GdbIdMap ; // map basato sugli identificatori INTPGDBO_UMAP m_GdbIdMap ; // map basato sugli identificatori
} ; } ;
BIN
View File
Binary file not shown.