EgtGeomKernel 1.5f4 :

- aggiunto punto base a GeoVector3d
- aggiunta creazione linea Pt+TgArc e Tg2Arcs
- aggiunta creazione arco Cen+TgArc e PDi + TgArc
- aggiunta a tutte le curve funzione IsPointOn
- aggiunta CurveLine e CurveArc la funzione Offset
- ottimizzata rotazione Vector3d attorno ad assi canonici
- corretta emissione Group e Frame in OutTsc.
This commit is contained in:
Dario Sassi
2014-06-14 18:03:04 +00:00
parent e9d45f84df
commit 26c2ad702a
21 changed files with 1537 additions and 209 deletions
+523 -160
View File
@@ -26,7 +26,10 @@
#include "/EgtDev/Include/EgkGeoVector3d.h"
#include "/EgtDev/Include/EgkGeoFrame3d.h"
#include "/EgtDev/Include/EgkCurveLine.h"
#include "/EgtDev/Include/EgkLinePntTgCurve.h"
#include "/EgtDev/Include/EgkLineTgTwoArcs.h"
#include "/EgtDev/Include/EgkCurveArc.h"
#include "/EgtDev/Include/EgkArcXxTgArc.h"
#include "/EgtDev/Include/EgkCurveBezier.h"
#include "/EgtDev/Include/EgkCurveComposite.h"
#include "/EgtDev/Include/EgkDistPointCurve.h"
@@ -66,6 +69,8 @@ GdbExecutor::GdbExecutor( void)
m_ExecMgr.Insert( "FRAME", &GdbExecutor::ExecuteFrame) ;
m_ExecMgr.Insert( "CL", &GdbExecutor::ExecuteCurveLine) ;
m_ExecMgr.Insert( "CURVELINE", &GdbExecutor::ExecuteCurveLine) ;
m_ExecMgr.Insert( "CI", &GdbExecutor::ExecuteCurveCircle) ;
m_ExecMgr.Insert( "CURVECIRCLE", &GdbExecutor::ExecuteCurveCircle) ;
m_ExecMgr.Insert( "CA", &GdbExecutor::ExecuteCurveArc) ;
m_ExecMgr.Insert( "CURVEARC", &GdbExecutor::ExecuteCurveArc) ;
m_ExecMgr.Insert( "CB", &GdbExecutor::ExecuteCurveBez) ;
@@ -233,7 +238,7 @@ GdbExecutor::ExecuteGroup( const string& sCmd2, const STRVECTOR& vsParams)
bool
GdbExecutor::ExecutePoint( const string& sCmd2, const STRVECTOR& vsParams)
{
// analisi ed esecuzione dei comandi
// definizione diretta
if ( sCmd2 == "" || sCmd2 == "MAKE") {
Point3d Pnt ;
// 3 parametri : Id, IdParent e punto
@@ -253,6 +258,30 @@ GdbExecutor::ExecutePoint( const string& sCmd2, const STRVECTOR& vsParams)
pGPnt->Set( Pnt) ;
return AddGeoObj( vsParams[0], vsParams[1], pGPnt) ;
}
// definizione come somma di un punto e un vettore
else if ( sCmd2 == "S" || sCmd2 == "SUM") {
// 4 : Id, IdParent, ptP, vtV
if ( vsParams.size() != 4)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frPnt ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frPnt))
return false ;
// recupero il punto
Point3d ptP ;
if ( ! GetPointParam( vsParams[2], frPnt, ptP))
return false ;
// recupero il vettore
Vector3d vtV ;
if ( ! GetVectorParam( vsParams[3], frPnt, vtV))
return false ;
// creo il punto
IGeoPoint3d* pGPnt = CreateGeoPoint3d() ;
if ( pGPnt == nullptr)
return false ;
pGPnt->Set( ptP+ vtV) ;
return AddGeoObj( vsParams[0], vsParams[1], pGPnt) ;
}
return false ;
}
@@ -263,94 +292,144 @@ GdbExecutor::ExecuteVector( const string& sCmd2, const STRVECTOR& vsParams)
{
// definizione diretta
if ( sCmd2 == "" || sCmd2 == "MAKE") {
Vector3d Vect ;
// 3 o 4 parametri : Id, IdParent, Vettore [, ScaleFactor]
if ( vsParams.size() != 3 && vsParams.size() != 4)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frVect ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
return false ;
// recupero i tre componenti
if ( ! GetVectorParam( vsParams[2], frVect, Vect))
return false ;
// recupero l'eventuale fattore di scala
double dScale = 1 ;
if ( vsParams.size() == 4 && ! FromString( vsParams[3], dScale))
return false ;
// creo il vettore
IGeoVector3d* pGVect = CreateGeoVector3d() ;
if ( pGVect == nullptr)
return false ;
pGVect->Set( Vect * dScale) ;
return AddGeoObj( vsParams[0], vsParams[1], pGVect) ;
return VectorMake( vsParams) ;
}
// definizione come differenza di due punti
else if ( sCmd2 == "D" || sCmd2 == "DIFF") {
// 4 o 5 parametri : Id, IdParent, ptP1, ptP2 [, bNorm]
if ( vsParams.size() != 4 && vsParams.size() != 5)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frVect ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
return false ;
// recupero il primo punto
Point3d ptP1 ;
if ( ! GetPointParam( vsParams[2], frVect, ptP1))
return false ;
// recupero il secondo punto
Point3d ptP2 ;
if ( ! GetPointParam( vsParams[3], frVect, ptP2))
return false ;
// flag di normalizzazione
bool bNorm = false ;
if ( vsParams.size() >= 5)
bNorm = ( vsParams[4] == "N") ;
// creo il vettore
IGeoVector3d* pGVect = CreateGeoVector3d() ;
if ( pGVect == nullptr)
return false ;
Vector3d vtV = ptP2 - ptP1 ;
if ( bNorm)
vtV.Normalize() ;
pGVect->Set( vtV) ;
return AddGeoObj( vsParams[0], vsParams[1], pGVect) ;
return VectorDifference( vsParams) ;
}
// definizione come prodotto vettoriale di due vettori
else if ( sCmd2 == "CP" || sCmd2 == "CROSSPROD") {
// 4 o 5 parametri : Id, IdParent, vtV1, vtV2 [, bNorm]
if ( vsParams.size() != 4 && vsParams.size() != 5)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frVect ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
return false ;
// recupero il primo vettore
Vector3d vtV1 ;
if ( ! GetVectorParam( vsParams[2], frVect, vtV1))
return false ;
// recupero il secondo vettore
Vector3d vtV2 ;
if ( ! GetVectorParam( vsParams[3], frVect, vtV2))
return false ;
// flag di normalizzazione
bool bNorm = false ;
if ( vsParams.size() >= 5)
bNorm = ( vsParams[4] == "N") ;
// creo il vettore
IGeoVector3d* pGVect = CreateGeoVector3d() ;
if ( pGVect == nullptr)
return false ;
Vector3d vtCross = vtV1 ^ vtV2 ;
if ( bNorm)
vtCross.Normalize() ;
pGVect->Set( vtCross) ;
return AddGeoObj( vsParams[0], vsParams[1], pGVect) ;
return VectorCrossProduct( vsParams) ;
}
// impostazione del punto di base
else if ( sCmd2 == "B" || sCmd2 == "BASE") {
return VectorModifyBase( vsParams) ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::VectorMake( const STRVECTOR& vsParams)
{
// 3 o 4 parametri : Id, IdParent, Vettore [, ScaleFactor]
if ( vsParams.size() != 3 && vsParams.size() != 4)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frVect ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
return false ;
// recupero i tre componenti
Vector3d Vect ;
if ( ! GetVectorParam( vsParams[2], frVect, Vect))
return false ;
// recupero l'eventuale fattore di scala
double dScale = 1 ;
if ( vsParams.size() == 4 && ! FromString( vsParams[3], dScale))
return false ;
// creo il vettore
IGeoVector3d* pGVect = CreateGeoVector3d() ;
if ( pGVect == nullptr)
return false ;
pGVect->Set( Vect * dScale) ;
return AddGeoObj( vsParams[0], vsParams[1], pGVect) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::VectorDifference( const STRVECTOR& vsParams)
{
// 4 o 5 parametri : Id, IdParent, ptP1, ptP2 [, bNorm]
if ( vsParams.size() != 4 && vsParams.size() != 5)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frVect ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
return false ;
// recupero il primo punto
Point3d ptP1 ;
if ( ! GetPointParam( vsParams[2], frVect, ptP1))
return false ;
// recupero il secondo punto
Point3d ptP2 ;
if ( ! GetPointParam( vsParams[3], frVect, ptP2))
return false ;
// flag di normalizzazione
bool bNorm = false ;
if ( vsParams.size() >= 5)
bNorm = ( vsParams[4] == "N") ;
// creo il vettore
IGeoVector3d* pGVect = CreateGeoVector3d() ;
if ( pGVect == nullptr)
return false ;
Vector3d vtV = ptP2 - ptP1 ;
if ( bNorm)
vtV.Normalize() ;
pGVect->Set( vtV) ;
return AddGeoObj( vsParams[0], vsParams[1], pGVect) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::VectorCrossProduct( const STRVECTOR& vsParams)
{
// 4 o 5 parametri : Id, IdParent, vtV1, vtV2 [, bNorm]
if ( vsParams.size() != 4 && vsParams.size() != 5)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frVect ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
return false ;
// recupero il primo vettore
Vector3d vtV1 ;
if ( ! GetVectorParam( vsParams[2], frVect, vtV1))
return false ;
// recupero il secondo vettore
Vector3d vtV2 ;
if ( ! GetVectorParam( vsParams[3], frVect, vtV2))
return false ;
// flag di normalizzazione
bool bNorm = false ;
if ( vsParams.size() >= 5)
bNorm = ( vsParams[4] == "N") ;
// creo il vettore
IGeoVector3d* pGVect = CreateGeoVector3d() ;
if ( pGVect == nullptr)
return false ;
Vector3d vtCross = vtV1 ^ vtV2 ;
if ( bNorm)
vtCross.Normalize() ;
pGVect->Set( vtCross) ;
return AddGeoObj( vsParams[0], vsParams[1], pGVect) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::VectorModifyBase( const STRVECTOR& vsParams)
{
// 2 parametri : Id, ptBase
if ( vsParams.size() != 2)
return false ;
// indice dell'oggetto
int nId = GetIdParam( vsParams[0]) ;
// recupero il riferimento in cui è immerso
Frame3d frVect ;
if ( ! m_pGDB->GetGlobFrame( nId, frVect))
return false ;
// recupero il punto di base
Point3d ptBase ;
if ( ! GetPointParam( vsParams[1], frVect, ptBase))
return false ;
// recupero l'oggetto
IGeoVector3d* pGVect = GetGeoVector3d( m_pGDB->GetGeoObj( nId)) ;
if ( pGVect == nullptr)
return false ;
// imposto il nuovo punto di base
return pGVect->ChangeBase( ptBase) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteFrame( const string& sCmd2, const STRVECTOR& vsParams)
@@ -436,6 +515,12 @@ GdbExecutor::ExecuteCurveLine( const string& sCmd2, const STRVECTOR& vsParams)
// creazione linea da : ptStart, dDirAngDeg, dLen
else if ( sCmd2 == "DL" || sCmd2 == "DirLength")
return CurveLineDirLength( vsParams) ;
// creazione linea da punto tangente a curva
else if ( sCmd2 == "PTGC" || sCmd2 == "POINTTGCURVE")
return CurveLinePointTgCurve( vsParams) ;
// creazione linea tangente a 2 archi
else if ( sCmd2 == "TG2A" || sCmd2 == "TG2ARCS")
return CurveLineTgTwoArcs( vsParams) ;
// creazione linea di minima distanza tra punto e curva
else if ( sCmd2 == "MPC" || sCmd2 == "MINPOINTCURVE")
return CurveLineMinPointCurve( vsParams) ;
@@ -542,6 +627,115 @@ GdbExecutor::CurveLineDirLength( const STRVECTOR& vsParams)
return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvLine)) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveLinePointTgCurve( const STRVECTOR& vsParams)
{
// 5 parametri : Id, IdParent, ptP, IdCrv, ptNear
if ( vsParams.size() != 5)
return false ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
return false ;
// recupero il punto
Point3d ptStart ;
if ( ! GetPointParam( vsParams[2], frDest, ptStart))
return false ;
// recupero l'identificativo della curva
int nId ;
if ( ( nId = GetIdParam( vsParams[3])) == CMD_ID_ERROR)
return false ;
// recupero il riferimento della curva
Frame3d frCurve ;
if ( ! m_pGDB->GetGlobFrame( nId, frCurve))
return false ;
// recupero la curva
const ICurve* pCurve = GetCurve( m_pGDB->GetGeoObj( nId)) ;
if ( pCurve == nullptr)
return false ;
// porto il punto nel riferimento della curva
Point3d ptSloc = ptStart ;
ptSloc.LocToLoc( frDest, frCurve) ;
// recupero il punto vicino
Point3d ptNear ;
if ( ! GetPointParam( vsParams[4], frDest, ptNear))
return false ;
Point3d ptNloc = ptNear ;
ptNloc.LocToLoc( frDest, frCurve) ;
// calcolo la retta tangente alla curva
ICurveLine* pCrvLine = GetLinePointTgCurve( ptSloc, *pCurve, ptNloc) ;
if ( pCrvLine == nullptr)
return false ;
// porto la linea nel riferimento del gruppo destinazione
pCrvLine->LocToLoc( frCurve, frDest) ;
// inserisco la linea nel DB
return AddGeoObj( vsParams[0], vsParams[1], pCrvLine) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveLineTgTwoArcs( const STRVECTOR& vsParams)
{
// 6 parametri : Id, IdParent, IdArc1, ptNear1, IdArc2, ptNear2
if ( vsParams.size() != 6)
return false ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
return false ;
// recupero l'identificativo del primo arco
int nId1 ;
if ( ( nId1 = GetIdParam( vsParams[2])) == CMD_ID_ERROR)
return false ;
// recupero il riferimento del primo arco
Frame3d frArc1 ;
if ( ! m_pGDB->GetGlobFrame( nId1, frArc1))
return false ;
// recupero il primo arco
const ICurveArc* pArc1 = GetCurveArc( m_pGDB->GetGeoObj( nId1)) ;
if ( pArc1 == nullptr)
return false ;
// recupero il primo punto vicino e lo porto nel riferimento del primo arco
Point3d ptNear1 ;
if ( ! GetPointParam( vsParams[3], frDest, ptNear1))
return false ;
Point3d ptN1loc = ptNear1 ;
ptN1loc.LocToLoc( frDest, frArc1) ;
// recupero l'identificativo del secondo arco
int nId2 ;
if ( ( nId2 = GetIdParam( vsParams[4])) == CMD_ID_ERROR)
return false ;
// recupero il riferimento del secondo arco
Frame3d frArc2 ;
if ( ! m_pGDB->GetGlobFrame( nId2, frArc2))
return false ;
// recupero il secondo arco
const ICurveArc* pArc2 = GetCurveArc( m_pGDB->GetGeoObj( nId2)) ;
if ( pArc2 == nullptr)
return false ;
// porto il secondo arco nel riferimento del primo
PtrOwner<ICurveArc> pArc2Loc( CreateCurveArc()) ;
if ( ! IsValid( pArc2Loc))
return false ;
pArc2Loc->Copy( pArc2) ;
pArc2Loc->LocToLoc( frArc2, frArc1) ;
// recupero il secondo punto vicino e lo porto nel riferimento del primo arco
Point3d ptNear2 ;
if ( ! GetPointParam( vsParams[5], frDest, ptNear2))
return false ;
Point3d ptN2loc = ptNear2 ;
ptN2loc.LocToLoc( frDest, frArc1) ;
// calcolo la retta tangente ai due archi
ICurveLine* pCrvLine = GetLineTgTwoArcs( *pArc1, ptN1loc, *pArc2, ptN2loc) ;
if ( pCrvLine == nullptr)
return false ;
// porto la linea nel riferimento del gruppo destinazione
pCrvLine->LocToLoc( frArc1, frDest) ;
// inserisco la linea nel DB
return AddGeoObj( vsParams[0], vsParams[1], pCrvLine) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveLineMinPointCurve( const STRVECTOR& vsParams)
@@ -595,6 +789,27 @@ GdbExecutor::CurveLineMinPointCurve( const STRVECTOR& vsParams)
return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvLine)) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteCurveCircle( const string& sCmd2, const STRVECTOR& vsParams)
{
// creo circonferenza generica
if ( sCmd2 == "" || sCmd2 == "MAKE")
return CurveCircleMake( vsParams) ;
// creo circonferenza nel piano XY
else if ( sCmd2 == "XY" || sCmd2 == "PLANEXY")
return CurveCirclePlaneXY( vsParams) ;
// creo circonferenza passante per 3 punti
else if ( sCmd2 == "3P")
return CurveArcCircle3P( vsParams, true) ;
// creo circonferenza dato centro e tangente ad un arco
else if ( sCmd2 == "CTGA")
return CurveCircleCenterTgArc( vsParams) ;
// altrimenti errore
else
return false ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteCurveArc( const string& sCmd2, const STRVECTOR& vsParams)
@@ -602,18 +817,12 @@ GdbExecutor::ExecuteCurveArc( const string& sCmd2, const STRVECTOR& vsParams)
// creo arco generico
if ( sCmd2 == "" || sCmd2 == "MAKE")
return CurveArcMake( vsParams) ;
// creo circonferenza
else if ( sCmd2 == "C" || sCmd2 == "CIRCLE")
return CurveArcCircle( vsParams) ;
// creo arco nel piano XY
else if ( sCmd2 == "XY" || sCmd2 == "PLANEXY")
return CurveArcPlaneXY( vsParams) ;
// creo circonferenza nel piano XY
else if ( sCmd2 == "CXY" || sCmd2 == "CIRCLEXY")
return CurveArcCircleXY( vsParams) ;
// creo arco o circonferenza passante per 3 punti
else if ( sCmd2 == "3P" || sCmd2 == "C3P")
return CurveArc3P( vsParams, ( sCmd2 == "C3P")) ;
else if ( sCmd2 == "3P")
return CurveArcCircle3P( vsParams, false) ;
// creo arco per 2 punti e direzione iniziale
else if ( sCmd2 == "2PDI")
return CurveArc2PDi( vsParams) ;
@@ -623,6 +832,12 @@ GdbExecutor::ExecuteCurveArc( const string& sCmd2, const STRVECTOR& vsParams)
// creo arco dato centro, per primo punto e vicino al secondo
else if ( sCmd2 == "C2P")
return CurveArcC2P( vsParams) ;
// creo arco dato centro, tangente ad un arco e punto vicino alla fine
else if ( sCmd2 == "CTGAP")
return CurveArcCenterTgArcP( vsParams) ;
// creo arco dato punto e direzione iniziali e tangente ad altro arco
else if ( sCmd2 == "PDTGA")
return CurveArcPDiTgArc( vsParams) ;
// inversione della normale
else if ( sCmd2 == "INVN" || sCmd2 == "INVERTNORMAL")
return CurveArcInvertNormal( vsParams) ;
@@ -643,6 +858,70 @@ GdbExecutor::ExecuteCurveArc( const string& sCmd2, const STRVECTOR& vsParams)
return false ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveCircleMake( const STRVECTOR& vsParams)
{
// 5 parametri
if ( vsParams.size() != 5)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frRef ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
return false ;
// centro
Point3d ptCen ;
if ( ! GetPointParam( vsParams[2], frRef, ptCen))
return false ;
// versore ortogonale al piano della circonferenza
Vector3d vtN ;
if ( ! GetVectorParam( vsParams[3], frRef, vtN))
return false ;
// raggio
double dRad ;
if ( ! GetLengthParam( vsParams[4], dRad))
return false ;
// creo l'arco
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( ! IsValid( pCrvArc))
return false ;
// setto l'arco
if ( ! pCrvArc->Set( ptCen, vtN, dRad))
return false ;
// inserisco l'arco nel DB
return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvArc)) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveCirclePlaneXY( const STRVECTOR& vsParams)
{
// 4 parametri
if ( vsParams.size() != 4)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frRef ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
return false ;
// centro
Point3d ptCen ;
if ( ! GetPointParam( vsParams[2], frRef, ptCen))
return false ;
// raggio
double dRad ;
if ( ! GetLengthParam( vsParams[3], dRad))
return false ;
// creo l'arco
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( ! IsValid( pCrvArc))
return false ;
// setto l'arco
if ( ! pCrvArc->SetXY( ptCen, dRad))
return false ;
// inserisco l'arco nel DB
return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvArc)) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveArcMake( const STRVECTOR& vsParams)
@@ -733,71 +1012,7 @@ GdbExecutor::CurveArcPlaneXY( const STRVECTOR& vsParams)
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveArcCircle( const STRVECTOR& vsParams)
{
// 5 parametri
if ( vsParams.size() != 5)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frRef ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
return false ;
// centro
Point3d ptCen ;
if ( ! GetPointParam( vsParams[2], frRef, ptCen))
return false ;
// versore ortogonale al piano della circonferenza
Vector3d vtN ;
if ( ! GetVectorParam( vsParams[3], frRef, vtN))
return false ;
// raggio
double dRad ;
if ( ! GetLengthParam( vsParams[4], dRad))
return false ;
// creo l'arco
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( ! IsValid( pCrvArc))
return false ;
// setto l'arco
if ( ! pCrvArc->Set( ptCen, vtN, dRad))
return false ;
// inserisco l'arco nel DB
return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvArc)) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveArcCircleXY( const STRVECTOR& vsParams)
{
// 4 parametri
if ( vsParams.size() != 4)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frRef ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
return false ;
// centro
Point3d ptCen ;
if ( ! GetPointParam( vsParams[2], frRef, ptCen))
return false ;
// raggio
double dRad ;
if ( ! GetLengthParam( vsParams[3], dRad))
return false ;
// creo l'arco
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( ! IsValid( pCrvArc))
return false ;
// setto l'arco
if ( ! pCrvArc->SetXY( ptCen, dRad))
return false ;
// inserisco l'arco nel DB
return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvArc)) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveArc3P( const STRVECTOR& vsParams, bool bCirc)
GdbExecutor::CurveArcCircle3P( const STRVECTOR& vsParams, bool bCirc)
{
// 5 parametri : Id, ParentId, ptP0, ptP1, ptP2
if ( vsParams.size() != 5)
@@ -852,15 +1067,12 @@ GdbExecutor::CurveArc2PDi( const STRVECTOR& vsParams)
double dDirI ;
if ( ! GetDirParam( vsParams[4], frRef, dDirI))
return false ;
// creo l'arco
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( ! IsValid( pCrvArc))
return false ;
// setto l'arco
if ( ! pCrvArc->Set2PD( ptPi, ptPf, dDirI))
// calcolo l'arco (in casi particolari può essere una retta)
ICurve* pCurve = GetArc2PD( ptPi, ptPf, dDirI) ;
if ( pCurve == nullptr)
return false ;
// inserisco l'arco nel DB
return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvArc)) ;
return AddGeoObj( vsParams[0], vsParams[1], pCurve) ;
}
//----------------------------------------------------------------------------
@@ -935,6 +1147,154 @@ GdbExecutor::CurveArcC2P( const STRVECTOR& vsParams)
return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvArc)) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveCircleCenterTgArc( const STRVECTOR& vsParams)
{
// 5 parametri : Id, ParentId, ptCen, IdArc, ptNear
if ( vsParams.size() != 5)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frDest ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
return false ;
// centro
Point3d ptCen ;
if ( ! GetPointParam( vsParams[2], frDest, ptCen))
return false ;
// recupero l'identificativo dell'arco di tangenza
int nId ;
if ( ( nId = GetIdParam( vsParams[3])) == CMD_ID_ERROR)
return false ;
// recupero il riferimento dell'arco di tangenza
Frame3d frTgArc ;
if ( ! m_pGDB->GetGlobFrame( nId, frTgArc))
return false ;
// recupero l'arco di tangenza
const ICurveArc* pTgArc = GetCurveArc( m_pGDB->GetGeoObj( nId)) ;
if ( pTgArc == nullptr)
return false ;
// porto il centro nel riferimento dell'arco di tangenza
Point3d ptCloc = ptCen ;
ptCloc.LocToLoc( frDest, frTgArc) ;
// recupero il punto vicino
Point3d ptNear ;
if ( ! GetPointParam( vsParams[4], frDest, ptNear))
return false ;
Point3d ptNloc = ptNear ;
ptNloc.LocToLoc( frDest, frTgArc) ;
// calcolo la circonferenza tangente all'arco
ICurveArc* pNewArc = GetCircleCenTgArc( ptCloc, *pTgArc, ptNloc) ;
if ( pNewArc == nullptr)
return false ;
// porto il nuovo arco nel riferimento del gruppo destinazione
pNewArc->LocToLoc( frTgArc, frDest) ;
// inserisco la linea nel DB
return AddGeoObj( vsParams[0], vsParams[1], pNewArc) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveArcCenterTgArcP( const STRVECTOR& vsParams)
{
// 6 parametri : Id, ParentId, ptCen, IdArc, ptNearTg, ptNearEnd
if ( vsParams.size() != 6)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frDest ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
return false ;
// centro
Point3d ptCen ;
if ( ! GetPointParam( vsParams[2], frDest, ptCen))
return false ;
// recupero l'identificativo dell'arco di tangenza
int nId ;
if ( ( nId = GetIdParam( vsParams[3])) == CMD_ID_ERROR)
return false ;
// recupero il riferimento dell'arco di tangenza
Frame3d frTgArc ;
if ( ! m_pGDB->GetGlobFrame( nId, frTgArc))
return false ;
// recupero l'arco di tangenza
const ICurveArc* pTgArc = GetCurveArc( m_pGDB->GetGeoObj( nId)) ;
if ( pTgArc == nullptr)
return false ;
// porto il centro nel riferimento dell'arco di tangenza
Point3d ptCloc = ptCen ;
ptCloc.LocToLoc( frDest, frTgArc) ;
// recupero il punto vicino alla tg
Point3d ptNear ;
if ( ! GetPointParam( vsParams[4], frDest, ptNear))
return false ;
Point3d ptNtloc = ptNear ;
ptNtloc.LocToLoc( frDest, frTgArc) ;
// recupero il punto vicino alla fine
Point3d ptNearEnd ;
if ( ! GetPointParam( vsParams[5], frDest, ptNear))
return false ;
Point3d ptNeloc = ptNear ;
ptNeloc.LocToLoc( frDest, frTgArc) ;
// calcolo la circonferenza tangente all'arco
ICurveArc* pNewArc = GetArcCenTgArcPnt( ptCloc, *pTgArc, ptNtloc, ptNeloc) ;
if ( pNewArc == nullptr)
return false ;
// porto il nuovo arco nel riferimento del gruppo destinazione
pNewArc->LocToLoc( frTgArc, frDest) ;
// inserisco la linea nel DB
return AddGeoObj( vsParams[0], vsParams[1], pNewArc) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveArcPDiTgArc( const STRVECTOR& vsParams)
{
// 6 parametri : Id, ParentId, ptStart, dirStart, IdArc, ptNear
if ( vsParams.size() != 6)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frDest ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
return false ;
// punto iniziale
Point3d ptStart ;
if ( ! GetPointParam( vsParams[2], frDest, ptStart))
return false ;
// direzione iniziale
double dDirI ;
if ( ! GetDirParam( vsParams[3], frDest, dDirI))
return false ;
// recupero l'identificativo dell'arco di tangenza
int nId ;
if ( ( nId = GetIdParam( vsParams[4])) == CMD_ID_ERROR)
return false ;
// recupero il riferimento dell'arco di tangenza
Frame3d frTgArc ;
if ( ! m_pGDB->GetGlobFrame( nId, frTgArc))
return false ;
// recupero l'arco di tangenza
const ICurveArc* pTgArc = GetCurveArc( m_pGDB->GetGeoObj( nId)) ;
if ( pTgArc == nullptr)
return false ;
// porto il punto di inizio nel riferimento dell'arco di tangenza
Point3d ptSloc = ptStart ;
ptSloc.LocToLoc( frDest, frTgArc) ;
// recupero il punto vicino alla tg
Point3d ptNear ;
if ( ! GetPointParam( vsParams[5], frDest, ptNear))
return false ;
Point3d ptNtloc = ptNear ;
ptNtloc.LocToLoc( frDest, frTgArc) ;
// calcolo l'arco (in casi particolari può essere una linea)
ICurve* pCurve = GetArcPntDirTgArc( ptSloc, dDirI, *pTgArc, ptNtloc) ;
if ( pCurve == nullptr)
return false ;
// porto il nuovo arco nel riferimento del gruppo destinazione
pCurve->LocToLoc( frTgArc, frDest) ;
// inserisco la linea nel DB
return AddGeoObj( vsParams[0], vsParams[1], pCurve) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveArcInvertNormal( const STRVECTOR& vsParams)
@@ -2158,7 +2518,7 @@ GdbExecutor::AddGeoObj( const string& sId, const string& sIdParent, IGeoObj* pGe
// creo il gruppo
int nId = GetIdParam( sId, true) ;
int nIdNew = m_pGDB->AddGeoObj( nId, GetIdParam( sIdParent), pGeoObj) ;
// se IdDest da calcolare, può essere una variabili a cui cambiare il valore
// se nId da calcolare, può essere una variabile a cui cambiare il valore
if ( nId == GDB_ID_NULL)
m_pParser->SetVariable( sId, nIdNew) ;
@@ -3972,8 +4332,11 @@ GdbExecutor::ExecuteOutTsc( const string& sCmd2, const STRVECTOR& vsParams)
// 1 parametro
if ( vsParams.size() != 1)
return false ;
// eventuale conversione di token nel nome file
string sFile = vsParams[0] ;
m_pParser->DirReplace( sFile) ;
// apro il file e scrivo intestazione
return m_OutTsc.Open( vsParams[0]) ;
return m_OutTsc.Open( sFile) ;
}
// chiudo il file di uscita Tsc
else if ( sCmd2 == "CLOSE") {