EgtInterface 1.6c2 :

- esplosione curva di Bezier ora dà composita di archi e rette
- aggiunte funzioni per creazione circonferenze e archi con tangenze.
This commit is contained in:
Dario Sassi
2015-03-16 07:41:34 +00:00
parent 2d04a08827
commit 4fe226fd74
4 changed files with 348 additions and 100 deletions
+242 -88
View File
@@ -27,6 +27,10 @@
#include "/EgtDev/Include/EGkLinePerpTwoCurves.h"
#include "/EgtDev/Include/EGkLineTgCurvePerpCurve.h"
#include "/EgtDev/Include/EgkCurveArc.h"
#include "/EgtDev/Include/EgkCircleCenTgCurve.h"
#include "/EgtDev/Include/EgkArcSpecial.h"
#include "/EgtDev/Include/EgkArcPntDirTgCurve.h"
#include "/EgtDev/Include/EgkArcCenTgCurvePnt.h"
#include "/EgtDev/Include/EgkCurveBezier.h"
#include "/EgtDev/Include/EgkCurveComposite.h"
#include "/EgtDev/Include/EgkChainCurves.h"
@@ -104,8 +108,7 @@ __stdcall EgtCreateCurveLineEx( int nParentId, const double ptIni[3], int nSepI,
PtrOwner<ICurveLine> pCrvLine ;
// recupero il riferimento locale
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
return GDB_ID_NULL ;
bool bOk = pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// porto in locale i punti e il versore estrusione
Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ;
Point3d ptFinL = GetPointLocal( pGeomDB, ptFin, nRefType, frLoc) ;
@@ -113,86 +116,74 @@ __stdcall EgtCreateCurveLineEx( int nParentId, const double ptIni[3], int nSepI,
// 1 - se punti entrambi definiti
if ( nSepI == SEP_STD && nSepF == SEP_STD) {
pCrvLine.Set( CreateCurveLine()) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
if ( ! pCrvLine->Set( ptIniL, ptFinL))
return GDB_ID_NULL ;
bOk = bOk && ! IsNull( pCrvLine) ;
bOk = bOk && pCrvLine->Set( ptIniL, ptFinL) ;
}
// 2 - se primo punto definito e secondo a minima distanza
else if ( nSepI == SEP_STD && nSepF == SEP_MINDIST) {
pCrvLine.Set( CreateLinePointMinDistCurve( pGeomDB, nParentId, ptIniL, ptFinL, nIdF)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
bOk = bOk && ! IsNull( pCrvLine) ;
}
// 3 - se primo punto a minima distanza e secondo definito
else if ( nSepI == SEP_MINDIST && nSepF == SEP_STD) {
pCrvLine.Set( CreateLinePointMinDistCurve( pGeomDB, nParentId, ptFinL, ptIniL, nIdI)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
pCrvLine->Invert() ;
bOk = bOk && ! IsNull( pCrvLine) ;
bOk = bOk && pCrvLine->Invert() ;
}
// 4 - se primo punto definito e secondo tangente
else if ( nSepI == SEP_STD && nSepF == SEP_TG) {
pCrvLine.Set( CreateLinePointTgCurve( pGeomDB, nParentId, ptIniL, ptFinL, nIdF)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
bOk = bOk && ! IsNull( pCrvLine) ;
}
// 5 - se primo punto tangente e secondo definito
else if ( nSepI == SEP_TG && nSepF == SEP_STD) {
// costruisco la curva al contrario e poi la inverto
pCrvLine.Set( CreateLinePointTgCurve( pGeomDB, nParentId, ptFinL, ptIniL, nIdI)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
pCrvLine->Invert() ;
bOk = bOk && ! IsNull( pCrvLine) ;
bOk = bOk && pCrvLine->Invert() ;
}
// 6 - se entrambi i punti tangenti
else if ( nSepI == SEP_TG && nSepF == SEP_TG) {
pCrvLine.Set( CreateLineTgTwoCurves( pGeomDB, nParentId, ptIniL, nIdI, ptFinL, nIdF)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
bOk = bOk && ! IsNull( pCrvLine) ;
}
// 7 - se primo punto definito e secondo perpendicolare
else if ( nSepI == SEP_STD && nSepF == SEP_PERP) {
pCrvLine.Set( CreateLinePointPerpCurve( pGeomDB, nParentId, ptIniL, ptFinL, nIdF)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
bOk = bOk && ! IsNull( pCrvLine) ;
}
// 8 - se primo punto perpendicolare e secondo definito
else if ( nSepI == SEP_PERP && nSepF == SEP_STD) {
// costruisco la curva al contrario e poi la inverto
pCrvLine.Set( CreateLinePointPerpCurve( pGeomDB, nParentId, ptFinL, ptIniL, nIdI)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
pCrvLine->Invert() ;
bOk = bOk && ! IsNull( pCrvLine) ;
bOk = bOk && pCrvLine->Invert() ;
}
// 9 - se entrambi i punti perpendicolari
else if ( nSepI == SEP_PERP && nSepF == SEP_PERP) {
pCrvLine.Set( CreateLinePerpTwoCurves( pGeomDB, nParentId, ptIniL, nIdI, ptFinL, nIdF)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
bOk = bOk && ! IsNull( pCrvLine) ;
}
// 10 - se primo punto tangente e secondo perpendicolare
else if ( nSepI == SEP_TG && nSepF == SEP_PERP) {
pCrvLine.Set( CreateLineTgCurvePerpCurve( pGeomDB, nParentId, ptIniL, nIdI, ptFinL, nIdF)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
bOk = bOk && ! IsNull( pCrvLine) ;
}
// 11 - se primo punto perpendicolare e secondo tangente
else if ( nSepI == SEP_PERP && nSepF == SEP_TG) {
// costruisco la curva al contrario e poi la inverto
pCrvLine.Set( CreateLineTgCurvePerpCurve( pGeomDB, nParentId, ptFinL, nIdF, ptIniL, nIdI)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
pCrvLine->Invert() ;
bOk = bOk && ! IsNull( pCrvLine) ;
bOk = bOk && pCrvLine->Invert() ;
}
// errore
else {
return GDB_ID_NULL ;
bOk = false ;
}
// assegno il versore estrusione
pCrvLine->SetExtrusion( vtExtrL) ;
bOk = bOk && pCrvLine->SetExtrusion( vtExtrL) ;
// inserisco la linea nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) : GDB_ID_NULL) ;
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
@@ -630,12 +621,10 @@ __stdcall EgtCreateCurveCircleCPN( int nParentId, const double ptCen[3],
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo l'arco
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( IsNull( pCrvArc))
return GDB_ID_NULL ;
bool bOk = ! IsNull( pCrvArc) ;
// recupero il riferimento locale
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
return GDB_ID_NULL ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// porto in locale i punti e i versori
Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frLoc) ;
Point3d ptOnL = GetPointLocal( pGeomDB, ptOn, nRefType, frLoc) ;
@@ -644,12 +633,11 @@ __stdcall EgtCreateCurveCircleCPN( int nParentId, const double ptCen[3],
// calcolo il raggio
double dRad = (( ptOnL - ptCenL) ^ vtNL).Len() ;
// setto la circonferenza
if ( ! pCrvArc->Set( ptCenL, vtNL, dRad))
return GDB_ID_NULL ;
bOk = bOk && pCrvArc->Set( ptCenL, vtNL, dRad) ;
// assegno il versore estrusione
pCrvArc->SetExtrusion( vtExtrL) ;
bOk = bOk && pCrvArc->SetExtrusion( vtExtrL) ;
// inserisco l'arco nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) : GDB_ID_NULL) ;
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
@@ -665,6 +653,65 @@ __stdcall EgtCreateCurveCircleCPN( int nParentId, const double ptCen[3],
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCircleCPNEx( int nParentId, const double ptCen[3],
const double ptOn[3], int nSepO, int nIdO, const double vtN[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo l'arco
PtrOwner<ICurveArc> pCrvArc ;
bool bOk = true ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// porto in locale i punti e i versori
Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frLoc) ;
Point3d ptOnL = GetPointLocal( pGeomDB, ptOn, nRefType, frLoc) ;
Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ;
Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ;
// se punto standard
if ( nSepO == SEP_STD) {
pCrvArc.Set( CreateCurveArc()) ;
bOk = bOk && ! IsNull( pCrvArc) ;
// calcolo il raggio
double dRad = (( ptOnL - ptCenL) ^ vtNL).Len() ;
// setto la circonferenza
bOk = bOk && pCrvArc->Set( ptCenL, vtNL, dRad) ;
}
// se punto di tangenza, determino il vero punto di passaggio
else if ( nSepO == SEP_TG) {
// recupero la curva di tangenza in locale
CurveLocal CrvTgLoc( pGeomDB, nIdO, frLoc) ;
// calcolo la circonferenza tangente a questa curva
pCrvArc.Set( GetCircleCenTgCurve( ptCenL, vtNL, *CrvTgLoc.Get(), ptOnL)) ;
bOk = bOk && ! IsNull( pCrvArc) ;
}
// altrimenti errore
else
bOk = false ;
// assegno il versore estrusione
bOk = bOk && pCrvArc->SetExtrusion( vtExtrL) ;
// inserisco l'arco nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) : GDB_ID_NULL) ;
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtCircleCPNEx(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "},{" +
ToString( Point3d( ptOn)) + "}," +
SepToString( nSepO) + "," +
ToString( nIdO) + ",{" +
ToString( Vector3d( vtN)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nNewId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCircle3P( int nParentId, const double ptP1[3],
@@ -797,6 +844,67 @@ __stdcall EgtCreateCurveArcC2PN( int nParentId, const double ptCen[3], const dou
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveArcC2PNEx( int nParentId, const double ptCen[3],
const double ptStart[3], int nSepS, int nIdS,
const double ptNearEnd[3], const double vtNorm[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo l'arco
PtrOwner<ICurveArc> pCrvArc ;
bool bOk = true ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// porto in locale i punti, i versori e il versore estrusione
Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frLoc) ;
Point3d ptStartL = GetPointLocal( pGeomDB, ptStart, nRefType, frLoc) ;
Point3d ptNearEndL = GetPointLocal( pGeomDB, ptNearEnd, nRefType, frLoc) ;
Vector3d vtNormL = GetVectorLocal( pGeomDB, vtNorm, nRefType, frLoc) ;
Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ;
// se punto standard
if ( nSepS == SEP_STD) {
pCrvArc.Set( CreateCurveArc()) ;
bOk = bOk && ! IsNull( pCrvArc) ;
// setto l'arco
if ( ! pCrvArc->SetC2PN( ptCenL, ptStartL, ptNearEndL, vtNormL))
return GDB_ID_NULL ;
}
// se punto di tangenza, determino il vero punto di passaggio
else if ( nSepS == SEP_TG) {
// recupero la curva di tangenza in locale
CurveLocal CrvTgLoc( pGeomDB, nIdS, frLoc) ;
// calcolo l'arco tangente a questa curva
pCrvArc.Set( GetArcCenTgCurvePnt( ptCenL, *CrvTgLoc.Get(), ptStartL, ptNearEndL, vtNormL)) ;
bOk = bOk && ! IsNull( pCrvArc) ;
}
// altrimenti errore
else
bOk = false ;
// assegno il versore estrusione
bOk = bOk && pCrvArc->SetExtrusion( vtExtrL) ;
// inserisco l'arco nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) : GDB_ID_NULL) ;
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtArcC2PNEx(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "},{" +
ToString( Point3d( ptStart)) + "},{" +
SepToString( nSepS) + "," +
ToString( nIdS) + ",{" +
ToString( Point3d( ptNearEnd)) + "},{" +
ToString( Vector3d( vtNorm)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nNewId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveArc3P( int nParentId, const double ptP1[3],
@@ -805,37 +913,23 @@ __stdcall EgtCreateCurveArc3P( int nParentId, const double ptP1[3],
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo l'arco
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( IsNull( pCrvArc))
return GDB_ID_NULL ;
PtrOwner<ICurve> pCrv ;
bool bOk = true ;
// recupero il riferimento locale
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
return GDB_ID_NULL ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// porto in locale i punti e il versore estrusione
Point3d ptP1L = GetPointLocal( pGeomDB, ptP1, nRefType, frLoc) ;
Point3d ptP2L = GetPointLocal( pGeomDB, ptP2, nRefType, frLoc) ;
Point3d ptP3L = GetPointLocal( pGeomDB, ptP3, nRefType, frLoc) ;
Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ;
int nId = GDB_ID_NULL ;
// setto l'arco
if ( pCrvArc->Set3P( ptP1L, ptP2L, ptP3L, false)) {
// assegno il versore estrusione
pCrvArc->SetExtrusion( vtExtrL) ;
// inserisco l'arco nel DB
nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
}
// se risulta essere una retta
else if ( ( ptP2L - ptP1L) * ( ptP3L - ptP2L) > EPS_ZERO) {
// creo e setto la retta
PtrOwner<ICurveLine> pCrvLine( CreateCurveLine()) ;
if ( ! IsNull( pCrvLine) && pCrvLine->Set( ptP1L, ptP3L)) {
// assegno il versore estrusione
pCrvLine->SetExtrusion( vtExtrL) ;
// inserisco la retta nel DB
nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
}
}
pCrv.Set( GetArc3P( ptP1L, ptP2L, ptP3L, false)) ;
bOk = bOk && ! ( IsNull( pCrv)) ;
// assegno il versore estrusione
bOk = bOk && pCrv->SetExtrusion( vtExtrL) ;
// inserisco l'arco nel DB
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrv)) : GDB_ID_NULL) ;
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
@@ -858,39 +952,25 @@ __stdcall EgtCreateCurveArc2PVN( int nParentId, const double ptStart[3], const d
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo l'arco
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( IsNull( pCrvArc))
return GDB_ID_NULL ;
// creo l'arco (in casi particolari retta)
PtrOwner<ICurve> pCrv ;
bool bOk = true ;
// recupero il riferimento locale
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
return GDB_ID_NULL ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// porto in locale i punti, i versori e il versore estrusione
Point3d ptStartL = GetPointLocal( pGeomDB, ptStart, nRefType, frLoc) ;
Point3d ptEndL = GetPointLocal( pGeomDB, ptEnd, nRefType, frLoc) ;
Vector3d vtDirSL = GetVectorLocal( pGeomDB, vtDirS, nRefType, frLoc) ;
Vector3d vtNormL = GetVectorLocal( pGeomDB, vtNorm, nRefType, frLoc) ;
Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ;
int nId = GDB_ID_NULL ;
// setto l'arco
if ( pCrvArc->Set2PVN( ptStartL, ptEndL, vtDirSL, vtNormL)) {
// assegno il versore estrusione
pCrvArc->SetExtrusion( vtExtrL) ;
// inserisco l'arco nel DB
nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
}
// se risulta essere una retta
else if ( ( ptEndL - ptStartL) * vtDirSL > EPS_ZERO) {
// creo e setto la retta
PtrOwner<ICurveLine> pCrvLine( CreateCurveLine()) ;
if ( ! IsNull( pCrvLine) && pCrvLine->Set( ptStartL, ptEndL)) {
// assegno il versore estrusione
pCrvLine->SetExtrusion( vtExtrL) ;
// inserisco la retta nel DB
nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
}
}
pCrv.Set( GetArc2PVN( ptStartL, ptEndL, vtDirSL, vtNormL)) ;
bOk = bOk && ! IsNull( pCrv) ;
// assegno il versore estrusione
bOk = bOk && pCrv->SetExtrusion( vtExtrL) ;
// inserisco l'arco nel DB
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrv)) : GDB_ID_NULL) ;
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
@@ -907,6 +987,80 @@ __stdcall EgtCreateCurveArc2PVN( int nParentId, const double ptStart[3], const d
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveArc2PVNEx( int nParentId, const double ptStart[3],
const double ptEnd[3], int nSep, int nId,
const double vtDirS[3], const double vtNorm[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo la curva ( in casi particolari potrebbe essere una retta)
PtrOwner<ICurve> pCrv ;
bool bOk = true ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// porto in locale i punti, i versori e il versore estrusione
Point3d ptStartL = GetPointLocal( pGeomDB, ptStart, nRefType, frLoc) ;
Point3d ptEndL = GetPointLocal( pGeomDB, ptEnd, nRefType, frLoc) ;
Vector3d vtDirSL = GetVectorLocal( pGeomDB, vtDirS, nRefType, frLoc) ;
Vector3d vtNormL = GetVectorLocal( pGeomDB, vtNorm, nRefType, frLoc) ;
Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ;
// se punto standard
if ( nSep == SEP_STD) {
// creo l'arco
pCrv.Set( CreateCurveArc()) ;
bOk = bOk && ! IsNull( pCrv) ;
if ( bOk) {
// imposto l'arco
if ( (dynamic_cast<ICurveArc*>(Get(pCrv)))->Set2PVN( ptStartL, ptEndL, vtDirSL, vtNormL))
;
// non riuscito, provo se risulta essere una retta
else if ( ( ptEndL - ptStartL) * vtDirSL > EPS_ZERO) {
// creo e setto la retta
pCrv.Set( CreateCurveLine()) ;
bOk = bOk && ! IsNull( pCrv) ;
bOk = bOk && (dynamic_cast<ICurveLine*>(Get(pCrv)))->Set( ptStartL, ptEndL) ;
}
// impossibile
else
bOk = false ;
}
}
// se punto di tangenza, determino il vero punto di passaggio
else if ( nSep == SEP_TG) {
// recupero la curva di tangenza in locale
CurveLocal CrvTgLoc( pGeomDB, nId, frLoc) ;
// calcolo l'arco tangente a questa curva
pCrv.Set( GetArcPntDirTgCurve( ptStartL, vtDirSL, *CrvTgLoc.Get(), ptEndL, vtNormL)) ;
bOk = bOk && ! IsNull( pCrv) ;
}
// altrimenti errore
else
bOk = false ;
// assegno il versore estrusione
bOk = bOk && pCrv->SetExtrusion( vtExtrL) ;
// inserisco l'arco nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrv)) : GDB_ID_NULL) ;
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtArc2PVNEx(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptStart)) + "},{" +
ToString( Point3d( ptEnd)) + "}," +
SepToString( nSep) + "," +
ToString( nId) + ",{" +
ToString( Vector3d( vtDirS)) + "},{" +
ToString( Vector3d( vtNorm)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nNewId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveBezier( int nParentId, int nDegree, const double ptCtrls[], int nRefType)
+7 -11
View File
@@ -762,17 +762,13 @@ __stdcall EgtExplodeCurveBezier( int nId, BOOL bArcsVsLines, double dLinTol)
}
else
bOk = false ;
// inserisco le curve elementari nel DB
ICurve* pCrv ;
while ( bOk && ( pCrv = pCC->RemoveFirstOrLastCurve( false)) != nullptr) {
// inserisco la curva nello stesso gruppo e nello stesso posto del GeomDB
int nCrvId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, pCrv) ;
if ( nCrvId == GDB_ID_NULL)
bOk = false ;
// copio gli attributi
if ( ! pGeomDB->CopyAttributes( nId, nCrvId))
bOk = false ;
}
// inserisco la curva composita nello spesso posto del GeomDB
int nCrvId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, Release( pCC)) ;
if ( nCrvId == GDB_ID_NULL)
bOk = false ;
// copio gli attributi
if ( ! pGeomDB->CopyAttributes( nId, nCrvId))
bOk = false ;
// elimino la curva di Bezier
bOk = bOk && pGeomDB->Erase( nId) ;
EgtSetModified() ;
BIN
View File
Binary file not shown.
+99 -1
View File
@@ -188,6 +188,36 @@ LuaCreateCurveCircleCPN( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateCurveCircleCPNEx( lua_State* L)
{
// 6 o 7 parametri : ParentId, PtCen, PtOn, sSepO, nIdO, VtN [, sRefType]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
Point3d ptCen ;
LuaCheckParam( L, 2, ptCen)
Point3d ptOn ;
LuaCheckParam( L, 3, ptOn)
string sSepO ;
LuaCheckParam( L, 4, sSepO)
int nIdO ;
LuaCheckParam( L, 5, nIdO)
Vector3d vtN ;
LuaCheckParam( L, 6, vtN)
int nRefType = RTY_DEFAULT ;
LuaGetRefType( L, 7, nRefType) ;
LuaClearStack( L) ;
// creo l'arco
int nId = EgtCreateCurveCircleCPNEx( nParentId, ptCen.v, ptOn.v, StringToSep( sSepO), nIdO, vtN.v, nRefType) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateCurveCircle3P( lua_State* L)
@@ -250,7 +280,7 @@ LuaCreateCurveArc( lua_State* L)
static int
LuaCreateCurveArcC2PN( lua_State* L)
{
// 5 o 6 parametri : ParentId, PtCen, PtStart, PtNearEnd, VtNorm [, sRefType]
// 5 o 6 parametri : ParentId, PtCen, PtStart, PtNearEnd, VtNorm [, sRefType]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
Point3d ptCen ;
@@ -274,6 +304,38 @@ LuaCreateCurveArcC2PN( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateCurveArcC2PNEx( lua_State* L)
{
// 7 o 8 parametri : ParentId, PtCen, PtStart, sSepS, nIdS, PtNearEnd, VtNorm [, sRefType]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
Point3d ptCen ;
LuaCheckParam( L, 2, ptCen)
Point3d ptStart ;
LuaCheckParam( L, 3, ptStart)
string sSepS ;
LuaCheckParam( L, 4, sSepS)
int nIdS ;
LuaCheckParam( L, 5, nIdS)
Point3d ptNearEnd ;
LuaCheckParam( L, 6, ptNearEnd)
Vector3d vtNorm ;
LuaCheckParam( L, 7, vtNorm)
int nRefType = RTY_DEFAULT ;
LuaGetRefType( L, 8, nRefType) ;
LuaClearStack( L) ;
// creo l'arco
int nId = EgtCreateCurveArcC2PNEx( nParentId, ptCen.v, ptStart.v, StringToSep( sSepS), nIdS, ptNearEnd.v, vtNorm.v, nRefType) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateCurveArc3P( lua_State* L)
@@ -328,6 +390,39 @@ LuaCreateCurveArc2PVN( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateCurveArc2PVNEx( lua_State* L)
{
// 7 o 8 parametri : ParentId, PtStart, PtEnd, sSepE, nIdE, VtDirS, VtNorm [, sRefType]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
Point3d ptStart ;
LuaCheckParam( L, 2, ptStart)
Point3d ptEnd ;
LuaCheckParam( L, 3, ptEnd)
string sSepE ;
LuaCheckParam( L, 4, sSepE)
int nIdE ;
LuaCheckParam( L, 5, nIdE)
Vector3d vtDirS ;
LuaCheckParam( L, 4, vtDirS)
Vector3d vtNorm ;
LuaCheckParam( L, 5, vtNorm)
int nRefType = RTY_DEFAULT ;
LuaGetRefType( L, 6, nRefType) ;
LuaClearStack( L) ;
// creo l'arco
int nId = EgtCreateCurveArc2PVNEx( nParentId, ptStart.v, ptEnd.v, StringToSep( sSepE), nIdE,
vtDirS.v, vtNorm.v, nRefType) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateCurveBezier( lua_State* L)
@@ -652,11 +747,14 @@ LuaInstallGdbCreateCurve( lua_State* L)
lua_register( L, "EgtLineMinPointCurve", LuaCreateCurveLineMinPointCurve) ;
lua_register( L, "EgtCircle", LuaCreateCurveCircle) ;
lua_register( L, "EgtCircleCPN", LuaCreateCurveCircleCPN) ;
lua_register( L, "EgtCircleCPNEx", LuaCreateCurveCircleCPNEx) ;
lua_register( L, "EgtCircle3P", LuaCreateCurveCircle3P) ;
lua_register( L, "EgtArc", LuaCreateCurveArc) ;
lua_register( L, "EgtArcC2PN", LuaCreateCurveArcC2PN) ;
lua_register( L, "EgtArcC2PNEx", LuaCreateCurveArcC2PNEx) ;
lua_register( L, "EgtArc3P", LuaCreateCurveArc3P) ;
lua_register( L, "EgtArc2PVN", LuaCreateCurveArc2PVN) ;
lua_register( L, "EgtArc2PVNEx", LuaCreateCurveArc2PVNEx) ;
lua_register( L, "EgtCurveBezier", LuaCreateCurveBezier) ;
lua_register( L, "EgtCurveBezierRat", LuaCreateCurveBezierRational) ;
lua_register( L, "EgtCurveBezierFromArc", LuaCreateCurveBezierFromArc) ;