From 84bf96b243daa32e0fd1d02c10e1e0b731f74028 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 8 Dec 2015 10:15:53 +0000 Subject: [PATCH] EgtGeomKernel 1.6l1 : - versione preliminare di VolZmap - piccola correzione a calcolo Box locale di curve. --- CurveArc.cpp | 7 ++ CurveBezier.cpp | 7 ++ CurveComposite.cpp | 9 +- CurveLine.cpp | 8 ++ EgtGeomKernel.rc | Bin 11734 -> 11718 bytes GdbExecutor.cpp | 41 +++++++++ GdbExecutor.h | 1 + VolZmap.cpp | 223 +++++++++++++++++++++++++++++++++++++++++++-- VolZmap.h | 15 +++ 9 files changed, 300 insertions(+), 11 deletions(-) diff --git a/CurveArc.cpp b/CurveArc.cpp index d7ba2ff..9df7d03 100644 --- a/CurveArc.cpp +++ b/CurveArc.cpp @@ -651,6 +651,13 @@ CurveArc::GetLocalBBox( BBox3d& b3Loc, int nFlag) const Point3d ptPos ; while ( aAppr.GetPoint( dU, ptPos)) b3Loc.Add( ptPos) ; + // se c'è estrusione, devo tenerne conto + if ( ! m_VtExtr.IsSmall() && fabs( m_dThick) > EPS_SMALL) { + Point3d ptMinExtr = b3Loc.GetMin() + m_VtExtr * m_dThick ; + Point3d ptMaxExtr = b3Loc.GetMax() + m_VtExtr * m_dThick ; + b3Loc.Add( ptMinExtr) ; + b3Loc.Add( ptMaxExtr) ; + } return true ; } diff --git a/CurveBezier.cpp b/CurveBezier.cpp index e915ddb..78cded3 100644 --- a/CurveBezier.cpp +++ b/CurveBezier.cpp @@ -504,6 +504,13 @@ CurveBezier::GetLocalBBox( BBox3d& b3Loc, int nFlag) const b3Loc.Add( ptTemp) ; } } + // se c'è estrusione, devo tenerne conto + if ( ! m_VtExtr.IsSmall() && fabs( m_dThick) > EPS_SMALL) { + Point3d ptMinExtr = b3Loc.GetMin() + m_VtExtr * m_dThick ; + Point3d ptMaxExtr = b3Loc.GetMax() + m_VtExtr * m_dThick ; + b3Loc.Add( ptMinExtr) ; + b3Loc.Add( ptMaxExtr) ; + } return true ; } diff --git a/CurveComposite.cpp b/CurveComposite.cpp index f11b788..f293018 100644 --- a/CurveComposite.cpp +++ b/CurveComposite.cpp @@ -713,6 +713,13 @@ CurveComposite::GetLocalBBox( BBox3d& b3Loc, int nFlag) const // passo alla curva successiva pCrvSmpl = GetNextCurve() ; } + // se c'è estrusione, devo tenerne conto (curve componenti sempre con vtExtr e dThick nulli) + if ( ! m_VtExtr.IsSmall() && fabs( m_dThick) > EPS_SMALL) { + Point3d ptMinExtr = b3Loc.GetMin() + m_VtExtr * m_dThick ; + Point3d ptMaxExtr = b3Loc.GetMax() + m_VtExtr * m_dThick ; + b3Loc.Add( ptMinExtr) ; + b3Loc.Add( ptMaxExtr) ; + } return true ; } @@ -740,7 +747,7 @@ CurveComposite::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const // passo alla curva successiva pCrvSmpl = GetNextCurve() ; } - // se c'è estrusione, devo tenerne conto + // se c'è estrusione, devo tenerne conto (curve componenti sempre con vtExtr e dThick nulli) if ( ! m_VtExtr.IsSmall() && fabs( m_dThick) > EPS_SMALL) { Vector3d vtFrExtr = m_VtExtr ; vtFrExtr.ToGlob( frRef) ; diff --git a/CurveLine.cpp b/CurveLine.cpp index d2daecd..bce05b9 100644 --- a/CurveLine.cpp +++ b/CurveLine.cpp @@ -210,6 +210,14 @@ CurveLine::GetLocalBBox( BBox3d& b3Loc, int nFlag) const return false ; // assegno il box in locale b3Loc.Set( m_PtStart, m_PtEnd) ; + // se c'è estrusione, devo tenerne conto + if ( ! m_VtExtr.IsSmall() && fabs( m_dThick) > EPS_SMALL) { + Point3d ptMinExtr = b3Loc.GetMin() + m_VtExtr * m_dThick ; + Point3d ptMaxExtr = b3Loc.GetMax() + m_VtExtr * m_dThick ; + b3Loc.Add( ptMinExtr) ; + b3Loc.Add( ptMaxExtr) ; + } + return true ; } diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index fd67435f47a69a5eb626599be38e9e8b3a43d74c..56c14be4eba70ff9b4efeb5724d8f794464ab7bb 100644 GIT binary patch delta 126 zcmcZ>eJpyz4>ndK1|0^&&HvftnVEAK3@1AZ>TV9;>SKY6pJ$r9O)>{b&W&;N3}Fvu Uyb5MXBPl>J*@JO&lX3_b0A@)fDgXcg delta 158 zcmX>WeJy&!4>oo~1|0@N27}G_`OY&an9?7>VxNuM-|5}bBGetGroupGlobFrame( GetIdParam( vsParams[1]), frRef)) + return false ; + // recupero punto iniziale + Point3d ptO ; + if ( ! GetPointParam( vsParams[2], frRef, ptO)) + return false ; + // recupero precisione + double dPrec ; + if ( ! FromString( vsParams[3], dPrec)) + return false ; + // recupero LunghezzaX + double dLengthX ; + if ( ! FromString( vsParams[4], dLengthX)) + return false ; + // recupero LunghezzaY + double dLengthY ; + if ( ! FromString( vsParams[5], dLengthY)) + return false ; + // recupero LunghezzaZ + double dLengthZ ; + if ( ! FromString( vsParams[6], dLengthZ)) + return false ; + + PtrOwner pZprova( new VolZmap) ; + pZprova->CreateMap( ptO, dPrec, dLengthX, dLengthY, dLengthZ); + + // inserisco nel DB + return AddGeoObj(vsParams[0], vsParams[1], Release( pZprova)) ; +} + //---------------------------------------------------------------------------- bool GdbExecutor::ExecuteText( const string& sCmd2, const STRVECTOR& vsParams) diff --git a/GdbExecutor.h b/GdbExecutor.h index 4f4772c..4860c1a 100644 --- a/GdbExecutor.h +++ b/GdbExecutor.h @@ -113,6 +113,7 @@ class GdbExecutor : public IGdbExecutor bool SurfTriMeshChangeSmoothAng( const STRVECTOR& vsParams) ; bool SurfTriMeshDoCompacting( const STRVECTOR& vsParams) ; bool SurfTriMeshDoSewing( const STRVECTOR& vsParams) ; + bool ExecuteVolZmap(const std::string& sCmd2, const STRVECTOR& vsParams); bool ExecuteText( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool TextSimple( const STRVECTOR& vsParams) ; bool TextComplete( const STRVECTOR& vsParams) ; diff --git a/VolZmap.cpp b/VolZmap.cpp index e7efa67..3d35962 100644 --- a/VolZmap.cpp +++ b/VolZmap.cpp @@ -15,6 +15,8 @@ #include "stdafx.h" #include "VolZmap.h" #include "GeoObjFactory.h" +#include "NgeWriter.h" +#include "NgeReader.h" using namespace std ; @@ -22,9 +24,13 @@ using namespace std ; GEOOBJ_REGISTER( VOL_ZMAP, NGE_V_ZMP, VolZmap) ; //---------------------------------------------------------------------------- -VolZmap::VolZmap( void) +VolZmap::VolZmap(void) : m_nStatus( TO_VERIFY), m_nTempProp() { + m_dStep = 0 ; + m_nNx = 0 ; + m_nNy = 0 ; + m_nDim = 0 ; } //---------------------------------------------------------------------------- @@ -62,7 +68,18 @@ VolZmap::CopyFrom( const IGeoObj* pGObjSrc) bool VolZmap::CopyFrom( const VolZmap& vzmSrc) { - return false ; + if ( &vzmSrc == this) + return true ; + m_OGrMgr.Reset() ; + m_LocalFrame = vzmSrc.m_LocalFrame ; + m_dStep = vzmSrc.m_dStep ; + m_nDim = vzmSrc.m_nDim ; + m_nNx = vzmSrc.m_nNx ; + m_nNy = vzmSrc.m_nNy ; + m_ZValues = vzmSrc.m_ZValues ; + m_nStatus = vzmSrc.m_nStatus ; + m_nTempProp = vzmSrc.m_nTempProp ; + return true ; } //---------------------------------------------------------------------------- @@ -98,14 +115,94 @@ VolZmap::GetNgeId( void) const bool VolZmap::Save( NgeWriter& ngeOut) const { - return false ; + // parametri di scrittura: sistema di riferimento, minimo incremento, numero di passi + // in direzione x e y, e per ogni casella, numero di valori e valori + if ( ! ngeOut.WriteFrame( m_LocalFrame, ";", true)) + return false ; + if ( ! ngeOut.WriteDouble( m_dStep, ",", false)) + return false ; + if ( ! ngeOut.WriteInt( m_nNx, ",", false)) + return false ; + if ( ! ngeOut.WriteInt( m_nNy, ";", true)) + return false ; + // ciclo sui dexel + for ( unsigned int i = 0 ; i < m_nDim ; ++ i) { + // numero di estremi + int nDim = int( m_ZValues[i].size()) ; + if ( ! ngeOut.WriteInt( nDim, ",", false)) + return false ; + // se dexel nullo + if ( nDim == 0) { + // scrivo un valore dummy + if ( ! ngeOut.WriteDouble( 0, ";", true)) + return false ; + } + // altrimenti + else { + for ( unsigned int k = 0 ; k < m_ZValues[i].size() ; ++ k) { + bool bEndL = ( k == m_ZValues[i].size() - 1) ; + if ( ! ngeOut.WriteDouble( m_ZValues[i][k], ( bEndL ? ";" : ","), bEndL)) + return false ; + } + } + } + + return true ; } - -//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- bool VolZmap::Load( NgeReader& ngeIn) { - return false ; + m_nStatus = TO_VERIFY ; + // parametri di lettura: sistema di riferimento, minimo incremento, numero di passi + // in direzione x e y, e per ogni casella, numero di valori e valori + if ( ! ngeIn.ReadFrame( m_LocalFrame, ";", true)) + return false ; + if ( ! ngeIn.ReadDouble( m_dStep, ",", false)) + return false ; + int nTemp ; + if ( ! ngeIn.ReadInt( nTemp, ",", false)) + return false ; + m_nNx = nTemp ; + if ( ! ngeIn.ReadInt( nTemp, ";", true)) + return false ; + m_nNy = nTemp ; + + // dimensione del vettore di dexel + m_nDim = m_nNx * m_nNy ; + m_ZValues.resize(m_nDim) ; + + // ciclo sui dexel + for ( unsigned int i = 0 ; i < m_nDim ; ++ i) { + // leggo il numero di estremi nel dexel + if ( ! ngeIn.ReadInt( nTemp, ",", false)) + return false ; + // devono essere pari + if ( ( nTemp % 2) != 0) + return false ; + // se dexel nullo + if ( nTemp == 0) { + // leggo un valore dummy + double dDummy ; + if ( ! ngeIn.ReadDouble( dDummy, ",", true)) + return false ; + } + // altrimenti + else { + // dimensiono l'array + m_ZValues[i].resize(nTemp) ; + // leggo i valori + for ( unsigned int k = 0 ; k < m_ZValues[i].size() ; ++ k) { + bool bEndL = ( k == m_ZValues[i].size() - 1) ; + if ( ! ngeIn.ReadDouble( m_ZValues[i][k], ( bEndL ? ";" : ","), bEndL)) + return false ; + } + } + } + + m_nStatus = OK ; + return true ; } //---------------------------------------------------------------------------- @@ -115,7 +212,25 @@ VolZmap::GetLocalBBox( BBox3d& b3Loc, int nFlag) const // verifico lo stato if ( m_nStatus != OK) return false ; - return false ; + // reset box + b3Loc.Reset() ; + // ciclo sui dexel + double dY = 0.5 * m_dStep ; + for ( size_t i = 0 ; i < m_nNy ; ++ i) { + double dX = 0.5 * m_dStep ; + for ( size_t j = 0 ; j < m_nNx ; ++ j) { + size_t nPos = j + i * m_nNx ; + if ( m_ZValues[nPos].size() > 0) { + Point3d ptP = m_LocalFrame.Orig() + dX * m_LocalFrame.VersX() + dY * m_LocalFrame.VersY() ; + b3Loc.Add( ptP + m_ZValues[nPos][0] * m_LocalFrame.VersZ()) ; + b3Loc.Add( ptP + m_ZValues[nPos][m_ZValues[nPos].size()-1] * m_LocalFrame.VersZ()) ; + } + dX += m_dStep ; + } + dY += m_dStep ; + } + + return true ; } //---------------------------------------------------------------------------- @@ -125,7 +240,28 @@ VolZmap::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const // verifico lo stato if ( m_nStatus != OK) return false ; - return false ; + // reset box + b3Ref.Reset() ; + // trasformo il riferimento locale tramite quello passato + Frame3d frUse = m_LocalFrame ; + frUse.ToGlob( frRef) ; + // ciclo sui dexel + double dY = 0.5 * m_dStep ; + for ( size_t i = 0 ; i < m_nNy ; ++ i) { + double dX = 0.5 * m_dStep ; + for ( size_t j = 0 ; j < m_nNx ; ++ j) { + size_t nPos = j + i * m_nNx ; + if ( m_ZValues[nPos].size() > 0) { + Point3d ptP = frUse.Orig() + dX * frUse.VersX() + dY * frUse.VersY() ; + b3Ref.Add( ptP + m_ZValues[nPos][0] * frUse.VersZ()) ; + b3Ref.Add( ptP + m_ZValues[nPos][m_ZValues[nPos].size()-1] * frUse.VersZ()) ; + } + dX += m_dStep ; + } + dY += m_dStep ; + } + + return true ; } //---------------------------------------------------------------------------- @@ -135,7 +271,11 @@ VolZmap::Translate( const Vector3d& vtMove) // verifico lo stato if ( m_nStatus != OK) return false ; - return false ; + // imposto ricalcolo della grafica + m_OGrMgr.Reset() ; + // traslo il riferimento + m_LocalFrame.Translate( vtMove) ; + return true ; } //---------------------------------------------------------------------------- @@ -145,7 +285,10 @@ VolZmap::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, doub // verifico lo stato if ( m_nStatus != OK) return false ; - return false ; + // imposto ricalcolo della grafica + m_OGrMgr.Reset() ; + // ruoto il riferimento + return m_LocalFrame.Rotate( ptAx, vtAx, dCosAng, dSinAng) ; } //---------------------------------------------------------------------------- @@ -207,3 +350,63 @@ VolZmap::LocToLoc( const Frame3d& frOri, const Frame3d& frDest) return false ; return false ; } + +//---------------------------------------------------------------------------- +bool +VolZmap::CreateMap( const Point3d& ptO, double dPrec, double dLengthX, double dLengthY, double dLengthZ) +{ + // Controlli sui parametri + if ( dPrec < EPS_SMALL || dLengthX < EPS_SMALL || dLengthY < EPS_SMALL || dLengthZ < EPS_SMALL) + return false ; + + m_LocalFrame.Set( ptO, X_AX, Y_AX, Z_AX) ; + + m_dStep = dPrec ; + + m_nNx = static_cast ( ceil( dLengthX / m_dStep)) ; + m_nNy = static_cast ( ceil( dLengthY / m_dStep)) ; + + m_nDim = m_nNx * m_nNy ; + + m_ZValues.resize( m_nDim) ; + + for ( int i = 0 ; i < int( m_nDim) ; i++) { + m_ZValues[i].resize(2) ;///? + + m_ZValues[i][0] = 0 ; + m_ZValues[i][1] = dLengthZ ; + } + + m_nStatus = OK ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::GetDexelLines( int nDir, int nPos1, int nPos2, POLYLINELIST& lstPL) const +{ + // pulisco la lista + lstPL.clear() ; + // per ora solo perpendicolari a XY (1) + if ( nDir != 1) + return false ; + // verifiche sugli indici + if ( nPos1 < 0 || nPos1 >= int( m_nNx) || nPos2 < 0 || nPos2 >= int( m_nNy)) + return false ; + int nPos = nPos1 + nPos2 * m_nNx ; + if ( nPos < 0 || nPos >= int( m_ZValues.size())) + return false ; + // calcolo coordinate punto + double dX = m_dStep * ( 0.5 + nPos1) ; + double dY = m_dStep * ( 0.5 + nPos2) ; + Point3d ptP = m_LocalFrame.Orig() + dX * m_LocalFrame.VersX() + dY * m_LocalFrame.VersY() ; + // creo le polilinee + for ( int i = 1 ; i < int( m_ZValues[nPos].size()) ; i += 2) { + // aggiungo polilinea a lista + lstPL.emplace_back() ; + // inserisco punti estremi + lstPL.back().AddUPoint( 0, ptP + m_ZValues[nPos][i-1] * m_LocalFrame.VersZ()) ; + lstPL.back().AddUPoint( 1, ptP + m_ZValues[nPos][i] * m_LocalFrame.VersZ()) ; + } + return true ; +} diff --git a/VolZmap.h b/VolZmap.h index ef18058..1aa6595 100644 --- a/VolZmap.h +++ b/VolZmap.h @@ -17,6 +17,9 @@ #include "DllMain.h" #include "GeoObjRW.h" #include "/EgtDev/Include/EGkVolZmap.h" +#include "/EgtDev/Include/EGkPoint3d.h" + +#include //---------------------------------------------------------------------------- @@ -56,6 +59,8 @@ class VolZmap : public IVolZmap, public IGeoObjRW public : // IVolZmap virtual bool CopyFrom( const IGeoObj* pGObjSrc) ; + bool CreateMap( const Point3d& ptO, double dPrec, double dLengthX, double dLengthY, double dLengthZ) ; + virtual bool GetDexelLines( int nDir, int nPos1, int nPos2, POLYLINELIST& lstPL) const ; public : // IGeoObjRW virtual int GetNgeId( void) const ; @@ -71,6 +76,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW { if ( ! CopyFrom( stSrc)) LOG_ERROR( GetEGkLogger(), "VolZmap : copy error") return *this ; } + private : bool CopyFrom( const VolZmap& clSrc) ; @@ -81,4 +87,13 @@ class VolZmap : public IVolZmap, public IGeoObjRW ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto Status m_nStatus ; // stato int m_nTempProp ; // proprietà temporanea + + double m_dStep ; + unsigned int m_nDim ; + unsigned int m_nNx ; + unsigned int m_nNy ; + Frame3d m_LocalFrame ; + + + std::vector > m_ZValues ; } ;