From 0b8a267b7b6c667278392e5e6c64fbdfb02c4e80 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 26 Jan 2015 07:49:18 +0000 Subject: [PATCH] EgtGeomKernel 1.6a4 : - DistPointLine correnta per versore non normalizzato - aggiunta GetGeoType a GeomDB e a GdbIterator - in lettura NGE binari aggiunta protezione da contemporanea scrittura - in PolyLine aggiunta funzione per inserimento punti onde raggiungere massima distanza - aggiunto oggetto VolZmap per virtual milling (per ora vuoto) - nuova versione file NGE 1009. --- DistPointLine.cpp | 23 +++- DistPointLine.h | 3 +- EgtGeomKernel.rc | Bin 11710 -> 11710 bytes EgtGeomKernel.vcxproj | 3 + EgtGeomKernel.vcxproj.filters | 9 ++ GdbIterator.cpp | 12 ++ GdbIterator.h | 1 + GeomDB.cpp | 15 +++ GeomDB.h | 1 + NgeConst.h | 14 ++- NgeKeyW.h | 2 + NgeReader.cpp | 2 +- PolyLine.cpp | 45 ++++++++ SurfTriMesh.h | 2 +- VolZmap.cpp | 209 ++++++++++++++++++++++++++++++++++ VolZmap.h | 84 ++++++++++++++ 16 files changed, 410 insertions(+), 15 deletions(-) create mode 100644 VolZmap.cpp create mode 100644 VolZmap.h diff --git a/DistPointLine.cpp b/DistPointLine.cpp index f4eec46..f7bea33 100644 --- a/DistPointLine.cpp +++ b/DistPointLine.cpp @@ -20,11 +20,11 @@ DistPointLine::DistPointLine( const Point3d& ptP, const ICurveLine& crvLine, bool bIsSegment) { - // distanza non calcolata - m_dSqDist = - 1 ; - - if ( &crvLine == nullptr || ! crvLine.IsValid()) + if ( &crvLine == nullptr || ! crvLine.IsValid()) { + // distanza non calcolata + m_dSqDist = - 1 ; return ; + } double dLen ; Vector3d vtDir ; @@ -38,12 +38,23 @@ DistPointLine::DistPointLine( const Point3d& ptP, { double dLen ; Vector3d vtDir ; - - DirDist( ptIni, ptFin, vtDir, dLen) ; Calculate( ptP, ptIni, vtDir, dLen, bIsSegment) ; } +//---------------------------------------------------------------------------- +DistPointLine::DistPointLine( const Point3d& ptP, + const Point3d& ptIni, const Vector3d& vtDir, double dLen, bool bIsSegment) +{ + Vector3d vtDirNorm = vtDir ; + if ( dLen > EPS_SMALL && ! vtDirNorm.Normalize( EPS_ZERO)) { + // distanza non calcolata + m_dSqDist = - 1 ; + return ; + } + Calculate( ptP, ptIni, vtDirNorm, dLen, bIsSegment) ; +} + //---------------------------------------------------------------------------- void DistPointLine::Calculate( const Point3d& ptP, diff --git a/DistPointLine.h b/DistPointLine.h index 15a6c92..17de608 100644 --- a/DistPointLine.h +++ b/DistPointLine.h @@ -28,8 +28,7 @@ class DistPointLine DistPointLine( const Point3d& ptP, const Point3d& ptIni, const Point3d& ptFin, bool bIsSegment = true) ; DistPointLine( const Point3d& ptP, - const Point3d& ptIni, const Vector3d& vtDir, double dLen, bool bIsSegment = true) - { Calculate( ptP, ptIni, vtDir, dLen, bIsSegment) ; } + const Point3d& ptIni, const Vector3d& vtDir, double dLen, bool bIsSegment = true) ; public : bool GetSqDist( double& dSqDist) ; diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 7a4ae7984a16f28eba13cf4467b7daec1a58ee38..cc4a0c79bc1d27a8f9debc775547e65344109b2b 100644 GIT binary patch delta 94 zcmdlNy)SyhFE&P#&A-_cnHfzcD{|{@_Trkr0u;H;XNwSVW8B;$>;>dw2zN+>g;Df- LFmBFL4&ed-WjGrO delta 94 zcmdlNy)SyhFE&Qw&A-_cnHh~ID{|{@_Trkr0u;H;XNwSVW8B;$>;>dw2zN+>g;Df- LFmBFL4&ed-W11TR diff --git a/EgtGeomKernel.vcxproj b/EgtGeomKernel.vcxproj index 9155e90..7e39517 100644 --- a/EgtGeomKernel.vcxproj +++ b/EgtGeomKernel.vcxproj @@ -320,6 +320,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -369,6 +370,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -432,6 +434,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtGeomKernel.vcxproj.filters b/EgtGeomKernel.vcxproj.filters index 69294ec..2afba14 100644 --- a/EgtGeomKernel.vcxproj.filters +++ b/EgtGeomKernel.vcxproj.filters @@ -246,6 +246,9 @@ File di origine\Geo + + File di origine\Geo + @@ -578,6 +581,12 @@ File di intestazione\Include + + File di intestazione + + + File di intestazione\Include + diff --git a/GdbIterator.cpp b/GdbIterator.cpp index 407a21c..b5d7288 100644 --- a/GdbIterator.cpp +++ b/GdbIterator.cpp @@ -244,6 +244,18 @@ GdbIterator::GetGdbType( void) const return GDB_TY_NONE ; } +//---------------------------------------------------------------------------- +int +GdbIterator::GetGeoType( void) const +{ + if ( m_pGDB == nullptr || m_pCurrObj == nullptr) + return GEO_NONE ; + if ( GetGdbGeo( m_pCurrObj) != nullptr) + return GetGdbGeo( m_pCurrObj)->GetType() ; + else + return GEO_NONE ; +} + //---------------------------------------------------------------------------- IGeoObj* GdbIterator::GetGeoObj( void) diff --git a/GdbIterator.h b/GdbIterator.h index 104f8fa..5920336 100644 --- a/GdbIterator.h +++ b/GdbIterator.h @@ -35,6 +35,7 @@ class GdbIterator : public IGdbIterator virtual bool EraseAndGoToPrev( void) ; virtual int GetGdbType( void) const ; + virtual int GetGeoType( void) const ; virtual IGeoObj* GetGeoObj( void) ; virtual const IGeoObj* GetGeoObj( void) const ; virtual Frame3d* GetGroupFrame( void) ; diff --git a/GeomDB.cpp b/GeomDB.cpp index 076398f..cd90dc4 100644 --- a/GeomDB.cpp +++ b/GeomDB.cpp @@ -622,6 +622,21 @@ GeomDB::GetGdbType( int nId) const return GDB_TY_NONE ; } +//---------------------------------------------------------------------------- +int +GeomDB::GetGeoType( int nId) const +{ + // recupero l'oggetto + const GdbObj* pGdbObj = GetGdbObj( nId) ; + if ( pGdbObj == nullptr) + return GEO_NONE ; + // se oggetto geometrico + if ( ::GetGdbGeo( pGdbObj) != nullptr) + return ::GetGdbGeo( pGdbObj)->GetType() ; + else + return GEO_NONE ; +} + //---------------------------------------------------------------------------- IGeoObj* GeomDB::GetGeoObj( int nId) diff --git a/GeomDB.h b/GeomDB.h index 3d51333..5955b4c 100644 --- a/GeomDB.h +++ b/GeomDB.h @@ -50,6 +50,7 @@ class GeomDB : public IGeomDB virtual int GetLastGroupInGroup( int nIdGroup) const ; virtual int GetPrevGroup( int nId) const ; virtual int GetGdbType( int nId) const ; + virtual int GetGeoType( int nId) const ; virtual IGeoObj* GetGeoObj( int nId) ; virtual const IGeoObj* GetGeoObj( int nId) const ; virtual Frame3d* GetGroupFrame( int nId) ; diff --git a/NgeConst.h b/NgeConst.h index 08206b8..ab8ce4b 100644 --- a/NgeConst.h +++ b/NgeConst.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- -// EgalTech 2014-2014 +// EgalTech 2014-2015 //---------------------------------------------------------------------------- -// File : NgeConst.h Data : 28.05.14 Versione : 1.5e10 +// File : NgeConst.h Data : 22.01.15 Versione : 1.6a4 // Contenuto : Costanti per file Nge. // // @@ -9,6 +9,7 @@ // Modifiche : 12.04.14 DS Creazione modulo. // 28.05.14 DS 1.5.7 -> aggiunto aggetto Testo. // 23.08.14 DS 1007 -> versione con 1 solo int e cambiato nome GDB in "EgtGeomDB". +// 21.01.15 DS 1009 -> Aggiunto ZMAP, cambiato Id di TEXT. // //---------------------------------------------------------------------------- @@ -26,7 +27,9 @@ const int NGE_VER_1007 = 1007 ; // 1007 : nuovo versioning con unico valore const int NGE_VER_1008 = 1008 ; // 1008 : aggiunge vtExtr e dThick a tutte le curve -const int NGE_VER_LAST = NGE_VER_1008 ; +const int NGE_VER_1009 = 1009 ; +// 1009 : aggiunto solido ZMAP e cambiato Id di TEXT +const int NGE_VER_LAST = NGE_VER_1009 ; // Indici KeyWord const int NGE_START = 0 ; const int NGE_END = 1 ; @@ -45,5 +48,6 @@ const int NGE_C_ARC = 13 ; const int NGE_C_BEZ = 14 ; const int NGE_C_CMP = 15 ; const int NGE_S_TRM = 16 ; -const int NGE_E_TXT = 17 ; -const int NGE_LAST_ID = 17 ; // ultimo valore +const int NGE_V_ZMP = 17 ; +const int NGE_E_TXT = 18 ; +const int NGE_LAST_ID = 18 ; // ultimo valore diff --git a/NgeKeyW.h b/NgeKeyW.h index 701bf28..3206505 100644 --- a/NgeKeyW.h +++ b/NgeKeyW.h @@ -37,6 +37,7 @@ const std::string NgeAscKeyW[] = { "START", // NGE_START "C_BEZ", // NGE_C_BEZ "C_CMP", // NGE_C_CMP "S_TRM", // NGE_S_TRM + "V_ZMP", // NGE_V_ZMP "E_TXT"} ; // NGE_E_TXT //---------------------------------------------------------------------------- @@ -64,4 +65,5 @@ const int NgeBinKeyW[] = { NGEB_GEN_BASE + 0x0F0F, // NGE_START NGEB_GEO_BASE + CRV_BEZ, // NGE_C_BEZ NGEB_GEO_BASE + CRV_COMPO, // NGE_C_CMP NGEB_GEO_BASE + SRF_TRIMESH, // NGE_S_TRM + NGEB_GEO_BASE + VOL_ZMAP, // NGE_V_ZMP NGEB_GEO_BASE + EXT_TEXT} ; // NGE_E_TXT \ No newline at end of file diff --git a/NgeReader.cpp b/NgeReader.cpp index 8c8cb20..271b689 100644 --- a/NgeReader.cpp +++ b/NgeReader.cpp @@ -34,7 +34,7 @@ NgeReader::Init( const std::string& sFileIn) break ; case NGE_BINARY : m_bBinary = true ; - m_InFile.open( stringtoW( sFileIn), ios::in | ios::binary) ; + m_InFile.open( stringtoW( sFileIn), ios::in | ios::binary, _SH_DENYWR) ; return ( ! m_InFile.fail()) ; break ; } diff --git a/PolyLine.cpp b/PolyLine.cpp index 2974f15..3846f76 100644 --- a/PolyLine.cpp +++ b/PolyLine.cpp @@ -610,3 +610,48 @@ PolyLine::GetMaxDistanceFromLine( double& dMaxDist, const Point3d& ptAx, return true ; } + +//---------------------------------------------------------------------------- +bool +PolyLine::AdjustForMaxSegmentLen( double& dMaxLen) +{ + PNTULIST::iterator iter = m_lUPoints.begin() ; + // se non ci sono punti, esco subito + if ( iter == m_lUPoints.end()) + return false ; + // imposto il primo punto come precedente + double dUprec = iter->second ; + Point3d ptPprec = iter->first ; + // passo al secondo + ++ iter ; + // ciclo sui punti + try { + while ( iter != m_lUPoints.end()) { + // recupero dati correnti + double dUcurr = iter->second ; + Point3d ptPcurr = iter->first ; + // verifico lunghezza segmento dal precedente + double dSqLen = SqDist( ptPprec, ptPcurr) ; + if ( dSqLen > dMaxLen * dMaxLen) { + double dLen = sqrt( dSqLen) ; + // determino il numero di divisioni + int nStep = int( dLen / dMaxLen + 0.999) ; + // inserisco i punti necessari + for ( int i = 1 ; i < nStep ; ++ i) { + double dCoeff = double( i) / nStep ; + m_lUPoints.insert( iter, POINTU( Media( ptPprec, ptPcurr, dCoeff), + (( 1 - dCoeff) * dUprec + dCoeff * dUcurr))) ; + } + } + // passo al successivo + dUprec = dUcurr ; + ptPprec = ptPcurr ; + ++ iter ; + } + } + catch (...) { + return false ; + } + + return true ; +} \ No newline at end of file diff --git a/SurfTriMesh.h b/SurfTriMesh.h index 55f755a..c8c6129 100644 --- a/SurfTriMesh.h +++ b/SurfTriMesh.h @@ -2,7 +2,7 @@ // EgalTech 2014-2014 //---------------------------------------------------------------------------- // File : SurfTriMesh.h Data : 26.03.14 Versione : 1.5c9 -// Contenuto : Dichiarazione della classe Superfici TriMesh. +// Contenuto : Dichiarazione della classe Superficie TriMesh. // // // diff --git a/VolZmap.cpp b/VolZmap.cpp new file mode 100644 index 0000000..203b43d --- /dev/null +++ b/VolZmap.cpp @@ -0,0 +1,209 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : VolZmap.cpp Data : 22.01.15 Versione : 1.6a4 +// Contenuto : Implementazione della classe Volume Zmap. +// +// +// +// Modifiche : 22.01.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "VolZmap.h" +#include "GeoObjFactory.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +GEOOBJ_REGISTER( VOL_ZMAP, NGE_V_ZMP, VolZmap) ; + +//---------------------------------------------------------------------------- +VolZmap::VolZmap( void) + : m_nStatus( TO_VERIFY), m_nTempProp() +{ +} + +//---------------------------------------------------------------------------- +VolZmap::~VolZmap( void) +{ +} + +//---------------------------------------------------------------------------- +VolZmap* +VolZmap::Clone( void) const +{ + // alloco oggetto + VolZmap* pVzm = new(nothrow) VolZmap ; + if ( pVzm != nullptr) { + if ( ! pVzm->CopyFrom( *this)) { + delete pVzm ; + return nullptr ; + } + } + + return pVzm ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::CopyFrom( const IGeoObj* pGObjSrc) +{ + const VolZmap* pVzm = dynamic_cast( pGObjSrc) ; + if ( pVzm == nullptr) + return false ; + return CopyFrom( *pVzm) ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::CopyFrom( const VolZmap& vzmSrc) +{ + return false ; +} + +//---------------------------------------------------------------------------- +GeoObjType +VolZmap::GetType( void) const +{ + return static_cast( GEOOBJ_GETTYPE( VolZmap)) ; +} + +//---------------------------------------------------------------------------- +const string& +VolZmap::GetTitle( void) const +{ + static const string sTitle = "Zmap" ; + return sTitle ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::Dump( string& sOut, const char* szNewLine) const +{ + return false ; +} + +//---------------------------------------------------------------------------- +int +VolZmap::GetNgeId( void) const +{ + return GEOOBJ_GETNGEID( VolZmap) ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::Save( NgeWriter& ngeOut) const +{ + return false ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::Load( NgeReader& ngeIn) +{ + return false ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::GetLocalBBox( BBox3d& b3Loc, int nFlag) const +{ + // verifico lo stato + if ( m_nStatus != OK) + return false ; + return false ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const +{ + // verifico lo stato + if ( m_nStatus != OK) + return false ; + return false ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::Translate( const Vector3d& vtMove) +{ + // verifico lo stato + if ( m_nStatus != OK) + return false ; + return false ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) +{ + // verifico lo stato + if ( m_nStatus != OK) + return false ; + return false ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) +{ + // verifico lo stato + if ( m_nStatus != OK) + return false ; + return false ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::Mirror( const Point3d& ptOn, const Vector3d& vtNorm) +{ + // verifico lo stato + if ( m_nStatus != OK) + return false ; + return false ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) +{ + // verifico lo stato + if ( m_nStatus != OK) + return false ; + return false ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::ToGlob( const Frame3d& frRef) +{ + // verifico lo stato + if ( m_nStatus != OK) + return false ; + return false ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::ToLoc( const Frame3d& frRef) +{ + // verifico lo stato + if ( m_nStatus != OK) + return false ; + return false ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::LocToLoc( const Frame3d& frOri, const Frame3d& frDest) +{ + // verifico lo stato + if ( m_nStatus != OK) + return false ; + return false ; +} diff --git a/VolZmap.h b/VolZmap.h new file mode 100644 index 0000000..191e45c --- /dev/null +++ b/VolZmap.h @@ -0,0 +1,84 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : VolZmap.h Data : 22.01.15 Versione : 1.6a4 +// Contenuto : Dichiarazione della classe Volume Zmap. +// +// +// +// Modifiche : 22.01.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "ObjGraphicsMgr.h" +#include "DllMain.h" +#include "GeoObjRW.h" +#include "/EgtDev/Include/EGkVolZmap.h" + + +//---------------------------------------------------------------------------- +class VolZmap : public IVolZmap, public IGeoObjRW +{ + public : // IGeoObj + virtual ~VolZmap( void) ; + virtual VolZmap* Clone( void) const ; + virtual GeoObjType GetType( void) const ; + virtual bool IsValid( void) const + { return ( m_nStatus == OK) ; } + virtual const std::string& GetTitle( void) const ; + virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ; + virtual bool GetLocalBBox( BBox3d& b3Loc, int nFlag = BBF_STANDARD) const ; + virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag = BBF_STANDARD) const ; + virtual bool Translate( const Vector3d& vtMove) ; + 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 Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ; + virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ; + virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ; + virtual bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ; + virtual bool ToGlob( const Frame3d& frRef) ; + virtual bool ToLoc( const Frame3d& frRef) ; + virtual bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) ; + virtual void SetObjGraphics( IObjGraphics* pOGr) + { m_OGrMgr.SetObjGraphics( pOGr) ; } + virtual IObjGraphics* GetObjGraphics( void) + { return m_OGrMgr.GetObjGraphics() ; } + virtual const IObjGraphics* GetObjGraphics( void) const + { return m_OGrMgr.GetObjGraphics() ; } + virtual void SetTempProp( int nProp) + { m_nTempProp = nProp ; } + virtual int GetTempProp( void) + { return m_nTempProp ; } + + public : // IVolZmap + virtual bool CopyFrom( const IGeoObj* pGObjSrc) ; + + public : // IGeoObjRW + virtual int GetNgeId( void) const ; + virtual bool Save( NgeWriter& ngeOut) const ; + virtual bool Load( NgeReader& ngeIn) ; + + public : + VolZmap( void) ; + VolZmap( const VolZmap& stSrc) + { if ( ! CopyFrom( stSrc)) + LOG_ERROR( GetEGkLogger(), "VolZmap : copy constructor error") } + VolZmap& operator =( const VolZmap& stSrc) + { if ( ! CopyFrom( stSrc)) + LOG_ERROR( GetEGkLogger(), "VolZmap : copy error") + return *this ; } + private : + bool CopyFrom( const VolZmap& clSrc) ; + + private : + enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ; + + private : + ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto + Status m_nStatus ; // stato + int m_nTempProp ; // proprietà temporanea +} ;