EgtGeomKernel 1.5a1 : Aggiunta prima versione distanza punto Curva di Bezier.

Ora si esporta la generica classe distanza punto curva.
This commit is contained in:
Dario Sassi
2014-01-05 09:47:43 +00:00
parent b4f2770eb8
commit 2216a87ab4
15 changed files with 580 additions and 91 deletions
+35 -60
View File
@@ -25,13 +25,13 @@
#include "/EgtDev/Include/EgkCurveArc.h"
#include "/EgtDev/Include/EgkCurveBezier.h"
#include "/EgtDev/Include/EgkCurveComposite.h"
#include "/EgtDev/Include/EgkDistPointLine.h"
#include "/EgtDev/Include/EgkDistPointArc.h"
#include "/EgtDev/Include/EgkDistPointCurve.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
//----------------------------------------------------------------------------
static const int ID_NO = -2 ;
static const int ID_ERROR = -3 ;
//----------------------------------------------------------------------------
@@ -45,6 +45,9 @@ CreateGdbExecutor( void)
GdbExecutor::GdbExecutor( void)
{
m_pGDB = nullptr ;
// alias predefiniti
m_NameMap.insert( pair< string, int>( "$ROOT", GDB_ID_ROOT)) ;
m_NameMap.insert( pair< string, int>( "$NN", ID_NO)) ;
}
//----------------------------------------------------------------------------
@@ -77,12 +80,10 @@ GdbExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR&
sOut += *theConstIter ;
}
sOut += "]" ;
LOG_DBG_INFO( GetEGkLogger(), sOut.c_str()) ;
LOG_DBG_INFO( GetEGkLogger(), sOut.c_str())
// esecuzione comando
if ( sCmd1 == "ALIAS")
return ExecuteAlias( sCmd2, vsParams) ;
else if ( sCmd1 == "GR" || sCmd1 == "GROUP")
if ( sCmd1 == "GR" || sCmd1 == "GROUP")
return ExecuteGroup( sCmd2, vsParams) ;
else if ( sCmd1 == "P" || sCmd1 == "POINT")
return ExecutePoint( sCmd2, vsParams) ;
@@ -124,26 +125,6 @@ GdbExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR&
return false ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteAlias( const string& sCmd2, const STRVECTOR& vsParams)
{
// analisi ed esecuzione dei comandi
if ( sCmd2 == "") {
int nId ;
// 2 parametri : stringa alias e Id
if ( vsParams.size() != 2)
return false ;
// recupero Id
if ( ! FromString( vsParams[1], nId))
return false ;
// inserisco le stringhe in coda alla lista
return m_AliasMap.insert( pair< string, int>( vsParams[0], nId)).second ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteGroup( const string& sCmd2, const STRVECTOR& vsParams)
@@ -187,11 +168,11 @@ GdbExecutor::ExecuteGroup( const string& sCmd2, const STRVECTOR& vsParams)
return false ;
// creo il gruppo
int nIdDest = GetIdParam( vsParams[0]) ;
int nIdDest = GetIdParam( vsParams[0], true) ;
int nIdNew = m_pGDB->AddGroup( nIdDest, GetIdParam( vsParams[1]), frFrame) ;
// se IdDest da calcolare e indicato da Alias, ne cambio il valore
if ( nIdDest == GDB_ID_NULL && m_AliasMap.find( vsParams[0]) != m_AliasMap.end())
m_AliasMap[vsParams[0]] = nIdNew ;
if ( nIdDest == GDB_ID_NULL && m_NameMap.find( vsParams[0]) != m_NameMap.end())
m_NameMap[vsParams[0]] = nIdNew ;
return ( nIdNew != GDB_ID_NULL) ;
}
@@ -338,25 +319,9 @@ GdbExecutor::ExecuteCurveLine( const string& sCmd2, const STRVECTOR& vsParams)
ptSloc.LocToLoc( frPoint, frCurve) ;
// calcolo il punto a minima distanza
Point3d ptEnd ;
switch ( pCurve->GetType()) {
case CRV_LINE :
{ DistPointLine dstPtLn( ptSloc, *GetCurveLine( pCurve)) ;
if ( ! dstPtLn.GetPointMinDist( ptEnd))
return false ;
} break ;
case CRV_ARC :
{ DistPointArc dstPtArc( ptSloc, *GetCurveArc( pCurve)) ;
if ( ! dstPtArc.GetPointMinDist( ptEnd))
return false ;
} break ;
//case CRV_BEZ :
// return PutCurveBez( *GetCurveBezier( pCurve), nFlag) ;
//case CRV_COMPO :
// return PutCurveCompo( *GetCurveComposite( pCurve), nFlag) ;
default :
DistPointCurve dstPtCurve( ptSloc, *pCurve) ;
if ( ! dstPtCurve.GetPointMinDist( ptEnd))
return false ;
break ;
}
// porto il punto finale nel riferimento di creazione
ptEnd.LocToLoc( frCurve, frPoint) ;
// setto la linea
@@ -623,28 +588,38 @@ bool
GdbExecutor::AddGeoObj( const string& sId, const string& sIdParent, IGeoObj* pGeoObj)
{
// creo il gruppo
int nId = GetIdParam( sId) ;
int nId = GetIdParam( sId, true) ;
int nIdNew = m_pGDB->AddGeoObj( nId, GetIdParam( sIdParent), pGeoObj) ;
// se IdDest da calcolare e indicato da Alias, ne cambio il valore
if ( nId == GDB_ID_NULL && m_AliasMap.find( sId) != m_AliasMap.end())
m_AliasMap[sId] = nIdNew ;
if ( nId == GDB_ID_NULL && m_NameMap.find( sId) != m_NameMap.end())
m_NameMap[sId] = nIdNew ;
return ( nIdNew != GDB_ID_NULL) ;
}
//----------------------------------------------------------------------------
int
GdbExecutor::GetIdParam( const std::string& sParam)
GdbExecutor::GetIdParam( const std::string& sParam, bool bNewAllowed)
{
int nVal ;
AliasMap::iterator Iter ;
NameMap::iterator Iter ;
// sostituisco eventuali Alias
Iter = m_AliasMap.find( sParam) ;
if ( Iter != m_AliasMap.end())
return Iter->second ;
// converto in identificatore numerico
// se nome di identificatore numerico
if ( sParam[0] == '$') {
// se già presente nella lista dei nomi, ne restituisco il valore
Iter = m_NameMap.find( sParam) ;
if ( Iter != m_NameMap.end())
return Iter->second ;
// se ammessa nuova definizione, provo ad inserirlo
else if ( bNewAllowed &&
m_NameMap.insert( pair< string, int>( sParam, GDB_ID_NULL)).second)
return GDB_ID_NULL ;
// altrimenti errore
else
return ID_ERROR ;
}
// se identificatore numerico
else if ( FromString( sParam, nVal))
return nVal ;
// altrimenti errore
@@ -772,11 +747,11 @@ GdbExecutor::ExecuteCopy( const STRVECTOR& vsParams)
if ( vsParams.size() != 3)
return false ;
// esecuzione copia
int nIdDest = GetIdParam( vsParams[1]) ;
int nIdDest = GetIdParam( vsParams[1], true) ;
int nIdNew = m_pGDB->Copy( GetIdParam( vsParams[0]), nIdDest, GetIdParam( vsParams[2])) ;
// se IdDest da calcolare e indicato da Alias, ne cambio il valore
if ( nIdDest == GDB_ID_NULL && m_AliasMap.find( vsParams[1]) != m_AliasMap.end())
m_AliasMap[vsParams[1]] = nIdNew ;
if ( nIdDest == GDB_ID_NULL && m_NameMap.find( vsParams[1]) != m_NameMap.end())
m_NameMap[vsParams[1]] = nIdNew ;
return ( nIdNew != GDB_ID_NULL) ;
}