EgtInterface 1.6a4 :

- completamento modifiche per registrazione comandi in lua e per gestione RefType e RefId.
This commit is contained in:
Dario Sassi
2015-01-26 07:53:04 +00:00
parent 4e5a81c493
commit a45c3fca8a
25 changed files with 1574 additions and 1254 deletions
+345 -152
View File
@@ -37,19 +37,21 @@
using namespace std ;
//-------------------------------------------------------------------------------
static ICurveLine* __stdcall CreateLinePointTgCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, const Point3d& ptFin, int nIdF) ;
static ICurveLine* __stdcall CreateLinePointPerpCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, const Point3d& ptFin, int nIdF) ;
static ICurveLine* __stdcall CreateLinePointMinDistCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, const Point3d& ptFin, int nIdF) ;
static ICurveLine* __stdcall CreateLineTgTwoCurves( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF) ;
static ICurveLine* __stdcall CreateLinePerpTwoCurves( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF) ;
static ICurveLine* __stdcall CreateLineTgCurvePerpCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF) ;
static bool __stdcall SetExtrusionFromGridVersZ( IGeomDB* pGeomDB, int nParentId, ICurve* pCurve) ;
static ICurveLine* CreateLinePointTgCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, const Point3d& ptFin, int nIdF) ;
static ICurveLine* CreateLinePointPerpCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, const Point3d& ptFin, int nIdF) ;
static ICurveLine* CreateLinePointMinDistCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, const Point3d& ptFin, int nIdF) ;
static ICurveLine* CreateLineTgTwoCurves( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF) ;
static ICurveLine* CreateLinePerpTwoCurves( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF) ;
static ICurveLine* CreateLineTgCurvePerpCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF) ;
static bool SetExtrusionFromGridVersZ( IGeomDB* pGeomDB, int nParentId, ICurve* pCurve) ;
static Vector3d CalcExtrusion( IGeomDB* pGeomDB, int nParentId, int nRefType) ;
//-------------------------------------------------------------------------------
int
@@ -238,8 +240,8 @@ __stdcall EgtCreateCurveLineEx( int nParentId, const double ptIni[3], int nSepI,
//-------------------------------------------------------------------------------
ICurveLine*
__stdcall CreateLinePointTgCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, const Point3d& ptFin, int nIdF)
CreateLinePointTgCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, const Point3d& ptFin, int nIdF)
{
// verifica preliminare Id curva
if ( nIdF == GDB_ID_NULL)
@@ -275,8 +277,8 @@ __stdcall CreateLinePointTgCurve( IGeomDB* pGeomDB, int nParentId,
//-------------------------------------------------------------------------------
ICurveLine*
__stdcall CreateLinePointPerpCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, const Point3d& ptFin, int nIdF)
CreateLinePointPerpCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, const Point3d& ptFin, int nIdF)
{
// verifica preliminare Id curva
if ( nIdF == GDB_ID_NULL)
@@ -312,8 +314,8 @@ __stdcall CreateLinePointPerpCurve( IGeomDB* pGeomDB, int nParentId,
//-------------------------------------------------------------------------------
ICurveLine*
__stdcall CreateLinePointMinDistCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, const Point3d& ptFin, int nIdF)
CreateLinePointMinDistCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, const Point3d& ptFin, int nIdF)
{
// verifica preliminare Id curva
if ( nIdF == GDB_ID_NULL)
@@ -349,8 +351,8 @@ __stdcall CreateLinePointMinDistCurve( IGeomDB* pGeomDB, int nParentId,
//-------------------------------------------------------------------------------
ICurveLine*
__stdcall CreateLineTgTwoCurves( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF)
CreateLineTgTwoCurves( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF)
{
// verifica preliminare Id curve
if ( nIdF == GDB_ID_NULL || nIdI == GDB_ID_NULL)
@@ -399,8 +401,8 @@ __stdcall CreateLineTgTwoCurves( IGeomDB* pGeomDB, int nParentId,
//-------------------------------------------------------------------------------
ICurveLine*
__stdcall CreateLinePerpTwoCurves( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF)
CreateLinePerpTwoCurves( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF)
{
// verifica preliminare Id curve
if ( nIdI == GDB_ID_NULL || nIdF == GDB_ID_NULL)
@@ -449,8 +451,8 @@ __stdcall CreateLinePerpTwoCurves( IGeomDB* pGeomDB, int nParentId,
//-------------------------------------------------------------------------------
ICurveLine*
__stdcall CreateLineTgCurvePerpCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF)
CreateLineTgCurvePerpCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF)
{
// verifica preliminare Id curve
if ( nIdI == GDB_ID_NULL || nIdF == GDB_ID_NULL)
@@ -1029,88 +1031,144 @@ __stdcall EgtCreateCurveArc2PVN( int nParentId, const double ptStart[3], const d
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveBezier( int nParentId, int nDegree, const double ptCtrls[])
__stdcall EgtCreateCurveBezier( int nParentId, int nDegree, const double ptCtrls[], int nRefType)
{
PNTVECTOR vPnt ;
vPnt.reserve( nDegree + 1) ;
for ( int i = 0 ; i <= nDegree ; ++i) {
vPnt.push_back( Point3d( ptCtrls[3*i], ptCtrls[3*i+1], ptCtrls[3*i+2])) ;
}
return EgtCreateCurveBezier( nParentId, nDegree, vPnt) ;
return EgtCreateCurveBezier( nParentId, nDegree, vPnt, nRefType) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveBezier( int nParentId, int nDegree, const PNTVECTOR& vPnt)
EgtCreateCurveBezier( int nParentId, int nDegree, const PNTVECTOR& vPnt, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// il numero dei punti deve essere pari al grado + 1
if ( vPnt.size() != nDegree + 1)
return GDB_ID_NULL ;
bool bOk = true ;
// il numero dei punti deve essere pari al grado + 1
bOk = bOk && ( vPnt.size() == nDegree + 1) ;
// recupero il riferimento di immersione della curva
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// creo la curva di Bezier
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
if ( IsNull( pCrvBez))
return GDB_ID_NULL ;
bOk = bOk && ! IsNull( pCrvBez) ;
// inizializzo la curva di Bezier
if ( ! pCrvBez->Init( nDegree, false))
return GDB_ID_NULL ;
bOk = bOk && pCrvBez->Init( nDegree, false) ;
// setto i punti di controllo
for ( int i = 0 ; i <= nDegree ; ++ i) {
if ( ! pCrvBez->SetControlPoint( i, vPnt[i]))
return GDB_ID_NULL ;
for ( int i = 0 ; i <= nDegree && bOk ; ++ i) {
// eventuale trasformazione del punto nel riferimento locale
Point3d ptCtrl = vPnt[i] ;
if ( nRefType == RTY_GLOB)
ptCtrl.ToLoc( frLoc) ;
else if ( nRefType == RTY_GRID)
ptCtrl.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
// inserimento del punto di controllo
if ( ! pCrvBez->SetControlPoint( i, ptCtrl))
bOk = false ;
}
// se curva nulla (ovvero ridotta a punto), errore
if ( pCrvBez->IsAPoint())
return GDB_ID_NULL ;
bOk = bOk && ! pCrvBez->IsAPoint() ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvBez)))
return GDB_ID_NULL ;
Vector3d vtExtrL = Z_AX ;
if ( nRefType == RTY_GLOB)
vtExtrL.ToLoc( frLoc) ;
else if ( nRefType == RTY_GRID)
vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
pCrvBez->SetExtrusion( vtExtrL) ;
// inserisco la curva nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) ;
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) : GDB_ID_NULL) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sPC ;
for ( size_t i = 0 ; i < vPnt.size() ; ++ i) {
if ( i > 0)
sPC += "," ;
sPC += "{" + ToString( vPnt[i]) + "}" ;
}
string sLua = "EgtCurveBezier(" + ToString( nParentId) + "," +
ToString( nDegree) + ",{" +
sPC + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveBezierRational( int nParentId, int nDegree, const double ptCtrlWs[])
__stdcall EgtCreateCurveBezierRational( int nParentId, int nDegree, const double ptCtrlWs[], int nRefType)
{
PNTUVECTOR vPntW ;
vPntW.reserve( nDegree + 1) ;
for ( int i = 0 ; i <= nDegree ; ++i) {
vPntW.push_back( make_pair( Point3d( ptCtrlWs[4*i], ptCtrlWs[4*i+1], ptCtrlWs[4*i+2]), ptCtrlWs[4*i+3])) ;
}
return EgtCreateCurveBezierRational( nParentId, nDegree, vPntW) ;
return EgtCreateCurveBezierRational( nParentId, nDegree, vPntW, nRefType) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveBezierRational( int nParentId, int nDegree, const PNTUVECTOR& vPntW)
EgtCreateCurveBezierRational( int nParentId, int nDegree, const PNTUVECTOR& vPntW, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// il numero dei punti deve essere pari al grado + 1
if ( vPntW.size() != nDegree + 1)
return GDB_ID_NULL ;
bOk = bOk && ( vPntW.size() == nDegree + 1) ;
// recupero il riferimento di immersione della curva
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// creo la curva di Bezier
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
if ( IsNull( pCrvBez))
return GDB_ID_NULL ;
bOk = bOk && ! IsNull( pCrvBez) ;
// inizializzo la curva di Bezier
if ( ! pCrvBez->Init( nDegree, true))
return GDB_ID_NULL ;
bOk = bOk && pCrvBez->Init( nDegree, true) ;
// setto i punti di controllo
for ( int i = 0 ; i <= nDegree ; ++ i) {
if ( ! pCrvBez->SetControlPoint( i, vPntW[i].first, vPntW[i].second))
for ( int i = 0 ; i <= nDegree && bOk ; ++ i) {
// eventuale trasformazione del punto nel riferimento locale
Point3d ptCtrl = vPntW[i].first ;
if ( nRefType == RTY_GLOB)
ptCtrl.ToLoc( frLoc) ;
else if ( nRefType == RTY_GRID)
ptCtrl.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
// inserimento del punto di controllo con peso
if ( ! pCrvBez->SetControlPoint( i, ptCtrl, vPntW[i].second))
return GDB_ID_NULL ;
}
// se curva nulla (ovvero ridotta a punto), errore
if ( pCrvBez->IsAPoint())
return GDB_ID_NULL ;
bOk = bOk && ! pCrvBez->IsAPoint() ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvBez)))
return GDB_ID_NULL ;
Vector3d vtExtrL = Z_AX ;
if ( nRefType == RTY_GLOB)
vtExtrL.ToLoc( frLoc) ;
else if ( nRefType == RTY_GRID)
vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
pCrvBez->SetExtrusion( vtExtrL) ;
// inserisco la curva nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) ;
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) : GDB_ID_NULL) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sPC ;
for ( size_t i = 0 ; i < vPntW.size() ; ++ i) {
if ( i > 0)
sPC += "," ;
sPC += "{" + ToString( vPntW[i].first, vPntW[i].second) + "}" ;
}
string sLua = "EgtCurveBezierRat(" + ToString( nParentId) + "," +
ToString( nDegree) + ",{" +
sPC + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
@@ -1119,35 +1177,30 @@ __stdcall EgtCreateCurveBezierFromArc( int nParentId, int nArcId, BOOL bErase)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// creo la curva di Bezier
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
if ( IsNull( pCrvBez))
return GDB_ID_NULL ;
bOk = bOk && ! IsNull( pCrvBez) ;
// recupero l'arco
const ICurveArc* pCrvArc = GetCurveArc( pGeomDB->GetGeoObj( nArcId)) ;
if ( pCrvArc == nullptr)
return GDB_ID_NULL ;
bOk = bOk && ( pCrvArc != nullptr) ;
// ne deduco la curva di Bezier
if ( ! pCrvBez->FromArc( *pCrvArc))
return GDB_ID_NULL ;
bOk = bOk && pCrvBez->FromArc( *pCrvArc) ;
// recupero il riferimento dell'arco
Frame3d frSou ;
if ( ! pGeomDB->GetGlobFrame( nArcId, frSou))
return GDB_ID_NULL ;
bOk = bOk && pGeomDB->GetGlobFrame( nArcId, frSou) ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest))
return GDB_ID_NULL ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frDest) ;
// porto la curva di Bezier dal riferimento dell'arco a quello di inserimento
if ( ! AreSameFrame( frSou, frDest)) {
if ( bOk && ! AreSameFrame( frSou, frDest)) {
pCrvBez->ToGlob( frSou) ;
pCrvBez->ToLoc( frDest) ;
}
// se curva nulla (ovvero ridotta a punto), errore
if ( pCrvBez->IsAPoint())
return GDB_ID_NULL ;
bOk = bOk && ! pCrvBez->IsAPoint() ;
// inserisco la curva nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) ;
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) : GDB_ID_NULL) ;
if ( nId != GDB_ID_NULL) {
// se richiesto, cancello l'arco originale
if ( bErase) {
@@ -1155,6 +1208,15 @@ __stdcall EgtCreateCurveBezierFromArc( int nParentId, int nArcId, BOOL bErase)
return GDB_ID_NULL ;
}
}
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtCurveBezierFromArc(" + ToString( nParentId) + "," +
ToString( nArcId) + "," +
( bErase ? "true" : "false") + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
@@ -1171,8 +1233,8 @@ __stdcall EgtCreateCurveCompo( int nParentId, int nNumId, const int nIds[], BOOL
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompo( int nParentId, const INTVECTOR& vIds, bool bErase)
static int
MyCreateCurveCompo( int nParentId, const INTVECTOR& vIds, bool bErase)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
@@ -1183,7 +1245,10 @@ __stdcall EgtCreateCurveCompo( int nParentId, const INTVECTOR& vIds, bool bErase
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest))
return false ;
return GDB_ID_NULL ;
// estrusione e spessore
Vector3d vtExtr = CalcExtrusion( pGeomDB, nParentId, RTY_GRID) ;
double dThick = 0 ;
// esecuzione
INTVECTOR::const_iterator Iter ;
for ( Iter = vIds.begin() ; Iter != vIds.end() ; ++Iter) {
@@ -1191,33 +1256,33 @@ __stdcall EgtCreateCurveCompo( int nParentId, const INTVECTOR& vIds, bool bErase
int nIdCrv = *Iter ;
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nIdCrv)) ;
if ( pCrv == nullptr)
return false ;
return GDB_ID_NULL ;
// recupero il riferimento della curva
Frame3d frSou ;
if ( ! pGeomDB->GetGlobFrame( nIdCrv, frSou))
return false ;
// se i riferimenti sono uguali
if ( AreSameFrame( frSou, frDest)) {
// aggiungo direttamente questa curva
if ( ! pCrvCompo->AddCurve( *pCrv))
return false ;
}
// altrimenti devo prima trasformare la curva
else {
// creo una copia della curva
PtrOwner<ICurve> pModCrv( pCrv->Clone()) ;
if ( IsNull( pModCrv))
return false ;
// eseguo la trasformazione
pModCrv->LocToLoc( frSou, frDest) ;
// aggiungo la curva modificata
if ( ! pCrvCompo->AddCurve( Release( pModCrv)))
return false ;
return GDB_ID_NULL ;
// creo una copia della curva
PtrOwner<ICurve> pCopCrv( pCrv->Clone()) ;
if ( IsNull( pCopCrv))
return GDB_ID_NULL ;
// se i riferimenti sono diversi, eseguo la trasformazione
if ( ! AreSameFrame( frSou, frDest))
pCopCrv->LocToLoc( frSou, frDest) ;
// recupero eventuali estrusione (già nel riferimento destinazione) e spessore
Vector3d vtTemp ;
if ( pCopCrv->GetExtrusion( vtTemp)) {
vtExtr = vtTemp ;
double dTemp ;
if ( pCopCrv->GetThickness( dTemp) && fabs( dTemp) > fabs( dThick))
dThick = dTemp ;
}
// aggiungo alla composita
if ( ! pCrvCompo->AddCurve( Release( pCopCrv)))
return GDB_ID_NULL ;
}
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvCompo)))
return GDB_ID_NULL ;
// imposto estrusione e spessore
pCrvCompo->SetExtrusion( vtExtr) ;
pCrvCompo->SetThickness( dThick) ;
// inserisco la curva composita nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) ;
// se ok e richiesto, cancello le curve originali
@@ -1227,24 +1292,51 @@ __stdcall EgtCreateCurveCompo( int nParentId, const INTVECTOR& vIds, bool bErase
return GDB_ID_NULL ;
}
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoByChain( int nParentId, int nNumId, const int nIds[], const double ptNear[3], BOOL bErase)
EgtCreateCurveCompo( int nParentId, const INTVECTOR& vIds, bool bErase)
{
// eseguo
int nId = MyCreateCurveCompo( nParentId, vIds, bErase) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sIds ;
for ( size_t i = 0 ; i < vIds.size() ; ++ i) {
if ( i > 0)
sIds += "," ;
sIds += ToString( vIds[i]) ;
}
string sLua = "EgtCurveCompo(" + ToString( nParentId) + ",{" +
sIds + "}," +
( bErase ? "true" : "false") + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoByChain( int nParentId, int nNumId, const int nIds[],
const double ptNear[3], BOOL bErase, int nRefType)
{
INTVECTOR vIds ;
vIds.reserve( nNumId) ;
for ( int i = 0 ; i < nNumId ; ++i) {
vIds.push_back( nIds[i]) ;
}
return EgtCreateCurveCompoByChain( nParentId, vIds, ptNear, ( bErase != FALSE)) ;
return EgtCreateCurveCompoByChain( nParentId, vIds, ptNear, ( bErase != FALSE), nRefType) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, const Point3d& ptNear, bool bErase)
static int
MyCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds,
const Point3d& ptNear, bool bErase, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
@@ -1284,16 +1376,19 @@ __stdcall EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, cons
}
// recupero i percorsi concatenati
int nFirstId = GDB_ID_NULL ;
Point3d ptNearStart( ptNear) ;
Point3d ptNearL( ptNear) ;
if ( nRefType == RTY_GLOB)
ptNearL.ToLoc( frDest) ;
else if ( nRefType == RTY_GRID)
ptNearL.LocToLoc( pGeomDB->GetGridFrame(), frDest) ;
INTVECTOR vId2s ;
while ( chainC.GetChainFromNear( ptNearStart, vId2s)) {
while ( chainC.GetChainFromNear( ptNearL, vId2s)) {
// creo una curva composita
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
if ( IsNull( pCrvCompo))
return GDB_ID_NULL ;
// eventuali estrusione e spessore
bool bExtr = false ;
Vector3d vtExtr ;
// estrusione e spessore
Vector3d vtExtr = CalcExtrusion( pGeomDB, nParentId, nRefType) ;
double dThick = 0 ;
// recupero le curve semplici e le inserisco nella curva composita
INTVECTOR::iterator Iter ;
@@ -1317,8 +1412,9 @@ __stdcall EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, cons
// la sistemo per i riferimenti
pCopCrv->LocToLoc( frCrv, frDest) ;
// recupero eventuali estrusione (già nel riferimento destinazione) e spessore
if ( pCopCrv->GetExtrusion( vtExtr)) {
bExtr = true ;
Vector3d vtTemp ;
if ( pCopCrv->GetExtrusion( vtTemp)) {
vtExtr = vtTemp ;
double dTemp ;
if ( pCopCrv->GetThickness( dTemp) && fabs( dTemp) > fabs( dThick))
dThick = dTemp ;
@@ -1330,13 +1426,11 @@ __stdcall EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, cons
// se non sono state inserite curve, vado oltre
if ( pCrvCompo->GetCurveNumber() == 0)
continue ;
// se necessario, imposto estrusione e spessore
if ( bExtr) {
pCrvCompo->SetExtrusion( vtExtr) ;
pCrvCompo->SetThickness( dThick) ;
}
// imposto estrusione e spessore
pCrvCompo->SetExtrusion( vtExtr) ;
pCrvCompo->SetThickness( dThick) ;
// aggiorno il nuovo punto vicino
pCrvCompo->GetEndPoint( ptNearStart) ;
pCrvCompo->GetEndPoint( ptNearL) ;
// inserisco la curva composita nel gruppo destinazione
int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, ::Release( pCrvCompo)) ;
if ( nNewId == GDB_ID_NULL)
@@ -1351,6 +1445,17 @@ __stdcall EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, cons
return GDB_ID_NULL ;
}
}
// restituisco l'identificativo della prima nuova entità
return nFirstId ;
}
//-------------------------------------------------------------------------------
int
EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds,
const Point3d& ptNear, bool bErase, int nRefType)
{
// eseguo
int nFirstId = MyCreateCurveCompoByChain( nParentId, vIds, ptNear, bErase, nRefType) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sIds ;
@@ -1361,8 +1466,9 @@ __stdcall EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, cons
}
string sLua = "EgtCurveCompoByChain(" + ToString( nParentId) + ",{" +
sIds + "},{" +
ToString( Point3d( ptNear)) + "}," +
( bErase ? "true" : "false") + ")" +
ToString( ptNear) + "}," +
( bErase ? "true" : "false") + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nFirstId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -1372,64 +1478,109 @@ __stdcall EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, cons
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoFromPoints( int nParentId, int nP, const double ptPs[])
__stdcall EgtCreateCurveCompoFromPoints( int nParentId, int nP, const double ptPs[], int nRefType)
{
PolyLine PL ;
for ( int i = 0 ; i < nP ; ++i) {
PL.AddUPoint( 0, Point3d( ptPs[3*i], ptPs[3*i+1], ptPs[3*i+2])) ;
}
return EgtCreateCurveCompoFromPoints( nParentId, PL) ;
return EgtCreateCurveCompoFromPoints( nParentId, PL, nRefType) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoFromPoints( int nParentId, const PolyLine& PL)
EgtCreateCurveCompoFromPoints( int nParentId, const PolyLine& PL, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frDest) ;
// creo la curva composita
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
if ( IsNull( pCrvCompo))
return GDB_ID_NULL ;
bOk = bOk && ! IsNull( pCrvCompo) ;
// inserisco i segmenti che uniscono i punti
if ( ! pCrvCompo->FromPolyLine( PL))
return GDB_ID_NULL ;
bOk = bOk && pCrvCompo->FromPolyLine( PL) ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvCompo)))
return GDB_ID_NULL ;
bOk = bOk && pCrvCompo->SetExtrusion( Z_AX) ;
// eventuale trasformazione per riferimento di espressione dei punti
if ( bOk && nRefType == RTY_GLOB)
pCrvCompo->ToLoc( frDest) ;
else if ( bOk && nRefType == RTY_GRID)
pCrvCompo->LocToLoc( pGeomDB->GetGridFrame(), frDest) ;
// inserisco la curva composita nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) ;
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) : GDB_ID_NULL) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sPnt ;
Point3d ptP ;
if ( PL.GetFirstPoint( ptP))
sPnt += "{" + ToString( ptP) + "}" ;
while ( PL.GetNextPoint( ptP))
sPnt += ",{" + ToString( ptP) + "}" ;
string sLua = "EgtCurveCompoFromPoints(" + ToString( nParentId) + ",{" +
sPnt + "},{" +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoFromPointBulges( int nParentId, int nPB, const double ptPBs[])
__stdcall EgtCreateCurveCompoFromPointBulges( int nParentId, int nPB, const double ptPBs[], int nRefType)
{
PolyArc PA ;
for ( int i = 0 ; i < nPB ; ++i) {
PA.AddUPoint( 0, Point3d( ptPBs[4*i], ptPBs[4*i+1], ptPBs[4*i+2]), ptPBs[4*i+3]) ;
}
return EgtCreateCurveCompoFromPointBulges( nParentId, PA) ;
return EgtCreateCurveCompoFromPointBulges( nParentId, PA, nRefType) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoFromPointBulges( int nParentId, const PolyArc& PA)
EgtCreateCurveCompoFromPointBulges( int nParentId, const PolyArc& PA, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frDest) ;
// creo la curva composita
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
if ( IsNull( pCrvCompo))
return GDB_ID_NULL ;
bOk = bOk && ! IsNull( pCrvCompo) ;
// inserisco i segmenti e gli archi che uniscono i punti
if ( ! pCrvCompo->FromPolyArc( PA))
return GDB_ID_NULL ;
bOk = bOk && pCrvCompo->FromPolyArc( PA) ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvCompo)))
return GDB_ID_NULL ;
bOk = bOk && pCrvCompo->SetExtrusion( Z_AX) ;
// eventuale trasformazione per riferimento di espressione dei punti
if ( bOk && nRefType == RTY_GLOB)
pCrvCompo->ToLoc( frDest) ;
else if ( bOk && nRefType == RTY_GRID)
pCrvCompo->LocToLoc( pGeomDB->GetGridFrame(), frDest) ;
// inserisco la curva composita nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) ;
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) : GDB_ID_NULL) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sPnt ;
double dB ;
Point3d ptP ;
if ( PA.GetFirstPoint( ptP, dB))
sPnt += "{" + ToString( ptP) + "," + ToString( dB) + "}" ;
while ( PA.GetNextPoint( ptP, dB))
sPnt += ",{" + ToString( ptP) + "," + ToString( dB) + "}" ;
string sLua = "EgtCurveCompoFromPointBulges(" + ToString( nParentId) + ",{" +
sPnt + "},{" +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
@@ -1438,28 +1589,50 @@ __stdcall EgtCreateCurveCompoByApprox( int nParentId, int nSouId, BOOL bArcsVsLi
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// recupero il riferimento di inserimento
Frame3d frEnt ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frEnt))
return GDB_ID_NULL ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frEnt) ;
// eseguo l'approssimazione
PtrOwner<ICurveComposite> pCC( CreateCurveComposite()) ;
if ( IsNull( pCC))
return false ;
bOk = bOk && ! IsNull( pCC) ;
if ( ! bArcsVsLines) { // con linee
PolyLine PL ;
if ( ! GetPolyLineFromCurve( nSouId, frEnt, dLinTol, PL) ||
! pCC->FromPolyLine( PL))
return false ;
bOk = bOk && GetPolyLineFromCurve( nSouId, frEnt, dLinTol, PL) && pCC->FromPolyLine( PL) ;
}
else { // con bi-archi
PolyArc PA ;
if ( ! GetPolyArcFromCurve( nSouId, frEnt, dLinTol, PA) ||
! pCC->FromPolyArc( PA))
return false ;
bOk = bOk && GetPolyArcFromCurve( nSouId, frEnt, dLinTol, PA) && pCC->FromPolyArc( PA) ;
}
// copio estrusione e spessore della curva sorgente
const ICurve* pSouCrv = GetCurve( pGeomDB->GetGeoObj( nSouId)) ;
if ( bOk && pSouCrv != nullptr) {
// recupero estrusione e spessore
Vector3d vtExtr ;
pSouCrv->GetExtrusion( vtExtr) ;
double dThick ;
pSouCrv->GetThickness( dThick) ;
// sistemo per eventuale cambio di riferimento
Frame3d frSou ;
bOk = bOk && pGeomDB->GetGlobFrame( nSouId, frSou) ;
vtExtr.LocToLoc( frSou, frEnt) ;
// assegno
pCC->SetExtrusion( vtExtr) ;
pCC->SetThickness( dThick) ;
}
// inserisco la curva composita nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCC)) ;
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCC)) : GDB_ID_NULL) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtCurveCompoByApprox(" + ToString( nParentId) + "," +
ToString( nSouId) + "," +
( bArcsVsLines ? "ARCS" : "LINES") +
ToString( dLinTol) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
@@ -1507,7 +1680,7 @@ __stdcall EgtCreateRectangle3P( int nParentId, const double ptIni[3],
PL.AddUPoint( 3, Point3d( ptCrossL) - vtLatoX) ;
PL.AddUPoint( 4, ptIniL) ;
// creo la curva e la inserisco nel GDB
nId = EgtCreateCurveCompoFromPoints( nParentId, PL) ;
nId = EgtCreateCurveCompoFromPoints( nParentId, PL, RTY_LOC) ;
// ne sistemo il vettore estrusione
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCurve != nullptr)
@@ -1582,9 +1755,29 @@ __stdcall EgtCreatePolygonFromSide( int nParentId, int nNumSides, const double p
return nId ;
}
//-------------------------------------------------------------------------------
Vector3d
CalcExtrusion( IGeomDB* pGeomDB, int nParentId, int nRefType)
{
// verifica sul parametro
if ( pGeomDB == nullptr)
return Z_AX ;
// riferimento dell'entità
Frame3d frEnt ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frEnt))
return false ;
// versore estrusione
Vector3d vtExtr = Z_AX ;
if ( nRefType == RTY_GLOB)
vtExtr.ToLoc( frEnt) ;
else if ( nRefType == RTY_GRID)
vtExtr.LocToLoc( pGeomDB->GetGridFrame(), frEnt) ;
return vtExtr ;
}
//-------------------------------------------------------------------------------
bool
__stdcall SetExtrusionFromGridVersZ( IGeomDB* pGeomDB, int nParentId, ICurve* pCurve)
SetExtrusionFromGridVersZ( IGeomDB* pGeomDB, int nParentId, ICurve* pCurve)
{
// verifiche sui parametri
if ( pGeomDB == nullptr || pCurve == nullptr)
@@ -1600,7 +1793,7 @@ __stdcall SetExtrusionFromGridVersZ( IGeomDB* pGeomDB, int nParentId, ICurve* pC
//----------------------------------------------------------------------------
bool
__stdcall GetPolyLineFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyLine& PL)
GetPolyLineFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyLine& PL)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
@@ -1637,7 +1830,7 @@ __stdcall GetPolyLineFromCurve( int nId, const Frame3d& frDest, double dLinTol,
//----------------------------------------------------------------------------
bool
__stdcall GetPolyArcFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyArc& PA)
GetPolyArcFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyArc& PA)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)