EgtGeomKernel 1.5g4 :

- aggiunto calcolo Biarchi da condizioni tipo Hermite
- aggiunta AngleInSpan
- migliorata gestione riferimento di gruppi
- corrette trasformazioni GeoVector3d per punto base.
This commit is contained in:
Dario Sassi
2014-08-02 21:17:42 +00:00
parent 5d17eb9617
commit d6756c5054
16 changed files with 411 additions and 143 deletions
+159 -30
View File
@@ -20,8 +20,6 @@
#include "GeomDB.h"
#include "DllMain.h"
#include "/EgtDev/Include/EgkStringUtils3d.h"
#include "/EgtDev/Include/EgnStringConverter.h"
#include "/EgtDev/Include/EgnCmdParser.h"
#include "/EgtDev/Include/EgkGeoPoint3d.h"
#include "/EgtDev/Include/EgkGeoVector3d.h"
#include "/EgtDev/Include/EgkGeoFrame3d.h"
@@ -35,10 +33,13 @@
#include "/EgtDev/Include/EgkDistPointCurve.h"
#include "/EgtDev/Include/EgkIntersCurveCurve.h"
#include "/EgtDev/Include/EgkChainCurves.h"
#include "/EgtDev/Include/EgkBiArcs.h"
#include "/EgtDev/Include/EgkSurfTriMesh.h"
#include "/EgtDev/Include/EgkExtText.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
#include "/EgtDev/Include/EgnStringConverter.h"
#include "/EgtDev/Include/EgnCmdParser.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
@@ -303,6 +304,10 @@ GdbExecutor::ExecuteVector( const string& sCmd2, const STRVECTOR& vsParams)
if ( sCmd2 == "" || sCmd2 == "MAKE") {
return VectorMake( vsParams) ;
}
// definizione sferica
else if ( sCmd2 == "SPHE" || sCmd2 == "FROMSPHERICAL") {
return VectorFromSpherical( vsParams) ;
}
// definizione come differenza di due punti
else if ( sCmd2 == "D" || sCmd2 == "DIFF") {
return VectorDifference( vsParams) ;
@@ -346,6 +351,39 @@ GdbExecutor::VectorMake( const STRVECTOR& vsParams)
return AddGeoObj( vsParams[0], vsParams[1], pGVect) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::VectorFromSpherical( const STRVECTOR& vsParams)
{
// 5 parametri : Id, IdParent, dLen, dAngVertDeg, dAngOrizzDeg
if ( vsParams.size() != 5)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frVect ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
return false ;
// recupero la lunghezza
double dLen ;
if ( ! GetLengthParam( vsParams[2], dLen))
return false ;
// recupero l'angolo in verticale (non c'è metodo generale)
double dAngVertDeg ;
if ( ! FromString( vsParams[3], dAngVertDeg))
return false ;
// recupero l'angolo in orizzontale
double dAngOrizzDeg ;
if ( ! GetDirParam( vsParams[4], frVect, dAngOrizzDeg))
return false ;
// creo il vettore
IGeoVector3d* pGVect = CreateGeoVector3d() ;
if ( pGVect == nullptr)
return false ;
Vector3d vtV ;
vtV.FromSpherical( dLen, dAngVertDeg, dAngOrizzDeg) ;
pGVect->Set( vtV) ;
return AddGeoObj( vsParams[0], vsParams[1], pGVect) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::VectorDifference( const STRVECTOR& vsParams)
@@ -1541,6 +1579,9 @@ GdbExecutor::ExecuteCurveCompo( const string& sCmd2, const STRVECTOR& vsParams)
// creazione come poligono dato il lato
else if ( sCmd2 == "POLYGSIDE" || sCmd2 == "FROMPOLYGONSIDE")
return CurveCompoFromPolygon( vsParams, POLYG_SIDE) ;
// creazione come biarco
else if ( sCmd2 == "BIARC" || sCmd2 == "FROMBIARC")
return CurveCompoFromBiarc( vsParams) ;
// modifica per aggiunta di una curva alla fine
else if ( sCmd2 == "AEC" || sCmd2 == "ADDENDCURVE")
return CurveCompoAddCurve( vsParams, true) ;
@@ -1787,10 +1828,49 @@ GdbExecutor::CurveCompoFromPolygon( const STRVECTOR& vsParams, int nType)
return false ;
break ;
}
// inserisco la linea nel DB
// inserisco la curva composita nel DB
return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvCompo)) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveCompoFromBiarc( const STRVECTOR& vsParams)
{
// 6 o 7 parametri : Id, IdParent, ptP1, Dir1, ptP2, Dir2 [, Par]
if ( vsParams.size() != 6 && vsParams.size() != 7)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frRef ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
return false ;
// recupero punto P1
Point3d ptP1 ;
if ( ! GetPointParam( vsParams[2], frRef, ptP1))
return false ;
// recupero direzione Dir1
double dDir1 ;
if ( ! GetDirParam( vsParams[3], frRef, dDir1))
return false ;
// recupero punto P2
Point3d ptP2 ;
if ( ! GetPointParam( vsParams[4], frRef, ptP2))
return false ;
// recupero direzione Dir2
double dDir2 ;
if ( ! GetDirParam( vsParams[5], frRef, dDir2))
return false ;
// setto o recupero parametro
double dPar = 0.5 ;
if ( vsParams.size() >= 7 && ! FromString( vsParams[6], dPar))
return false ;
// costruisco il biarco
PtrOwner<ICurve> pBiArc( GetBiArc( ptP1, dDir1, ptP2, dDir2, dPar)) ;
if ( ! ::IsValid( pBiArc))
return false ;
// inserisco la curva nel DB
return AddGeoObj( vsParams[0], vsParams[1], Release( pBiArc)) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveCompoAddCurve( const STRVECTOR& vsParams, bool bEndOrStart)
@@ -2445,7 +2525,7 @@ GdbExecutor::TextSimple( const STRVECTOR& vsParams)
return false ;
// recupero il testo
string sText ;
if ( ! GetTextParam( vsParams[2], sText))
if ( ! GetStringParam( vsParams[2], sText))
return false ;
// recupero il punto di inserimento
Point3d ptP ;
@@ -2483,7 +2563,7 @@ GdbExecutor::TextComplete( const STRVECTOR& vsParams)
return false ;
// recupero il testo
string sText ;
if ( ! GetTextParam( vsParams[2], sText))
if ( ! GetStringParam( vsParams[2], sText))
return false ;
// recupero il punto di inserimento
Point3d ptP ;
@@ -2554,7 +2634,7 @@ GdbExecutor::TextModifyText( const STRVECTOR& vsParams)
return false ;
// recupero il testo
string sText ;
if ( ! GetTextParam( vsParams[1], sText))
if ( ! GetStringParam( vsParams[1], sText))
return false ;
// recupero il testo
IExtText* pTXT = GetExtText( m_pGDB->GetGeoObj( GetIdParam( vsParams[0]))) ;
@@ -2573,7 +2653,7 @@ GdbExecutor::TextChangeFont( const STRVECTOR& vsParams)
return false ;
// recupero il nome del font
string sFont ;
if ( ! GetTextParam( vsParams[1], sFont))
if ( ! GetStringParam( vsParams[1], sFont))
return false ;
// recupero il testo
IExtText* pTXT = GetExtText( m_pGDB->GetGeoObj( GetIdParam( vsParams[0]))) ;
@@ -2782,17 +2862,17 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
if ( ! m_pGDB->GetGlobFrame( nIdEnt, frEnt))
return false ;
// se gruppo
const IGeoFrame3d* pGF ;
if ( ( pGF = m_pGDB->GetGeoFrame( nIdEnt)) != nullptr) {
const Frame3d* pGrpF ;
if ( ( pGrpF = m_pGDB->GetGroupFrame( nIdEnt)) != nullptr) {
switch ( cType) {
case 'X' : // versore X
vtV = pGF->GetFrame().VersX() ;
vtV = pGrpF->VersX() ;
return vtV.LocToLoc( frEnt, frVect) ;
case 'Y' : // versore Y
vtV = pGF->GetFrame().VersY() ;
vtV = pGrpF->VersY() ;
return vtV.LocToLoc( frEnt, frVect) ;
case 'Z' : // versore Z
vtV = pGF->GetFrame().VersZ() ;
vtV = pGrpF->VersZ() ;
return vtV.LocToLoc( frEnt, frVect) ;
default :
return false ;
@@ -2966,11 +3046,11 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
if ( ! m_pGDB->GetGlobFrame( nIdEnt, frEnt))
return false ;
// se gruppo
const IGeoFrame3d* pGF ;
if ( ( pGF = m_pGDB->GetGeoFrame( nIdEnt)) != nullptr) {
const Frame3d* pGrpF ;
if ( ( pGrpF = m_pGDB->GetGroupFrame( nIdEnt)) != nullptr) {
switch ( cType) {
case 'O' : // origine
ptP = pGF->GetFrame().Orig() ;
ptP = pGrpF->Orig() ;
return ptP.LocToLoc( frEnt, frPnt) ;
default :
return false ;
@@ -3059,6 +3139,16 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
}
}
}
// se vettore
else if ( pGObj->GetType() == GEO_VECT3D) {
// recupero il geo-vettore
const IGeoVector3d* pGV = GetGeoVector3d( pGObj) ;
switch ( cType) {
case 'B' : // base
ptP = pGV->GetBase() ;
return ptP.LocToLoc( frEnt, frPnt) ;
}
}
// se frame
else if ( pGObj->GetType() == GEO_FRAME3D) {
// recupero il frame
@@ -3383,6 +3473,21 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
//case 'I' :
}
}
// altrimenti, se vettore
else if ( pGObj->GetType() == GEO_VECT3D) {
// recupero il vettore
const IGeoVector3d* pGVect = GetGeoVector3d( pGObj) ;
Vector3d vtDir = pGVect->GetVector() ;
vtDir.LocToLoc( frEnt, frDir) ;
vtDir.ToSpherical( nullptr, nullptr, &dDir) ;
// se esiste un secondo parametro è un offset di rotazione
if ( vsParams.size() >= 2) {
double dOffsetDeg = 0 ;
FromString( vsParams[1], dOffsetDeg) ;
dDir += dOffsetDeg ;
}
return true ;
}
return false ;
}
// altrimenti valore numerico
@@ -3466,17 +3571,25 @@ GdbExecutor::GetFrameParam( const string& sParam, const Frame3d& frRef, Frame3d&
}
// altrimenti nome di gruppo o di frame già nel DB
else {
// identificativo
int nIdEnt = GetIdParam( sParam) ;
const IGeoFrame3d* pFr ;
if ( ( pFr = m_pGDB->GetGeoFrame( nIdEnt)) == nullptr &&
( pFr = GetGeoFrame3d( m_pGDB->GetGeoObj( nIdEnt))) == nullptr)
return false ;
frF = pFr->GetFrame() ;
// recupero il riferimento del frame
// recupero il riferimento in cui è immerso
Frame3d frEnt ;
if ( ! m_pGDB->GetGlobFrame( nIdEnt, frEnt))
return false ;
return frF.LocToLoc( frEnt, frRef) ;
// se gruppo
if ( m_pGDB->GetGroupFrame( nIdEnt, frF)) {
return frF.LocToLoc( frEnt, frRef) ;
}
// altrimenti entità geometrica
else {
// verifico se riferimento
const IGeoFrame3d* pFr ;
if ( ( pFr = GetGeoFrame3d( m_pGDB->GetGeoObj( nIdEnt))) == nullptr)
return false ;
frF = pFr->GetFrame() ;
return frF.LocToLoc( frEnt, frRef) ;
}
}
}
@@ -3530,9 +3643,9 @@ GdbExecutor::GetColorParam( const string& sParam, bool& bByParent, Color& cCol)
//----------------------------------------------------------------------------
bool
GdbExecutor::GetTextParam( const string& sParam, string& sText)
GdbExecutor::GetStringParam( const string& sParam, string& sString)
{
return m_pParser->GetTextParam( sParam, sText) ;
return m_pParser->GetStringParam( sParam, sString) ;
}
//----------------------------------------------------------------------------
@@ -3813,10 +3926,14 @@ GdbExecutor::ExecuteName( const string& sCmd2, const STRVECTOR& vsParams)
INTVECTOR vnNames ;
if ( ! GetNamesParam( vsParams[0], vnNames))
return false ;
// recupero il nome
string sName ;
if ( ! GetStringParam( vsParams[1], sName))
return false ;
// eseguo assegnazione nome
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( ! m_pGDB->SetName( *Iter, vsParams[1]))
if ( ! m_pGDB->SetName( *Iter, sName))
return false ;
}
return true ;
@@ -3855,10 +3972,18 @@ GdbExecutor::ExecuteInfo( const string& sCmd2, const STRVECTOR& vsParams)
INTVECTOR vnNames ;
if ( ! GetNamesParam( vsParams[0], vnNames))
return false ;
// recupero Key
string sKey ;
if ( ! GetStringParam( vsParams[1], sKey))
return false ;
// recupero Info
string sInfo ;
if ( ! GetStringParam( vsParams[2], sInfo))
return false ;
// eseguo assegnazione Info di data Key
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( ! m_pGDB->SetInfo( *Iter, vsParams[1], vsParams[2]))
if ( ! m_pGDB->SetInfo( *Iter, sKey, sInfo))
return false ;
}
return true ;
@@ -3872,10 +3997,14 @@ GdbExecutor::ExecuteInfo( const string& sCmd2, const STRVECTOR& vsParams)
INTVECTOR vnNames ;
if ( ! GetNamesParam( vsParams[0], vnNames))
return false ;
// recupero Key
string sKey ;
if ( ! GetStringParam( vsParams[1], sKey))
return false ;
// eseguo rimozione nome Info di data Key
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( ! m_pGDB->RemoveInfo( *Iter, vsParams[1]))
if ( ! m_pGDB->RemoveInfo( *Iter, sKey))
return false ;
}
return true ;
@@ -4588,7 +4717,7 @@ GdbExecutor::CurveCopyBySplitClass( const STRVECTOR& vsParams)
if ( ! m_pGDB->GetGlobFrame( nIdCloCrv, frCloCrv))
return false ;
// se i riferimenti sono diversi, porto la seconda curva nel riferimento della prima
PtrOwner<ICurve> crvTrans( nullptr) ;
PtrOwner<ICurve> crvTrans ;
if ( ! AreSameFrame( frCrv, frCloCrv)) {
crvTrans.Set( pCloCrv->Clone()) ;
if ( ! ::IsValid( crvTrans))
@@ -4848,7 +4977,7 @@ GdbExecutor::ExecuteOutTextIcci( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! m_pGDB->GetGlobFrame( nIdEnt2, frEnt2))
return false ;
// se i riferimenti sono diversi, porto la seconda entità nel riferimento della prima
PtrOwner<ICurve> crvTrans( nullptr) ;
PtrOwner<ICurve> crvTrans ;
if ( ! AreSameFrame( frEnt1, frEnt2)) {
crvTrans.Set( pCrv2->Clone()) ;
if ( ! ::IsValid( crvTrans))