EgtInterface 1.6a3 :

- modifiche varie per gestire GLOB, LOC e GRID sui dati geometrici
- aggiornamenti e miglirie varie
- eliminate alcune funzioni lua ormai obsolete (ArcXY e CircleXY).
This commit is contained in:
Dario Sassi
2015-01-19 18:21:58 +00:00
parent e23999b6a3
commit 4e5a81c493
19 changed files with 945 additions and 415 deletions
+409 -191
View File
@@ -53,7 +53,7 @@ static bool __stdcall SetExtrusionFromGridVersZ( IGeomDB* pGeomDB, int nParentId
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveLine( int nParentId, const double ptIni[3], const double ptFin[3])
__stdcall EgtCreateCurveLine( int nParentId, const double ptIni[3], const double ptFin[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
@@ -61,19 +61,38 @@ __stdcall EgtCreateCurveLine( int nParentId, const double ptIni[3], const double
PtrOwner<ICurveLine> pCrvLine( CreateCurveLine()) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
// porto in locale i punti e il versore estrusione
Point3d ptIniL( ptIni) ;
Point3d ptFinL( ptFin) ;
Vector3d vtExtrL = Z_AX ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
return GDB_ID_NULL ;
if ( nRefType == RTY_GLOB) {
ptIniL.ToLoc( frLoc) ;
ptFinL.ToLoc( frLoc) ;
vtExtrL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptIniL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
ptFinL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
// setto la linea
if ( ! pCrvLine->Set( ptIni, ptFin))
if ( ! pCrvLine->Set( ptIniL, ptFinL))
return GDB_ID_NULL ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvLine)))
return GDB_ID_NULL ;
pCrvLine->SetExtrusion( vtExtrL) ;
// inserisco la linea nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtLine(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptIni)) + "},{" +
ToString( Point3d( ptFin)) + "})" +
ToString( Point3d( ptFin)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -84,83 +103,102 @@ __stdcall EgtCreateCurveLine( int nParentId, const double ptIni[3], const double
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveLineEx( int nParentId, const double ptIni[3], int nSepI, int nIdI,
const double ptFin[3], int nSepF, int nIdF)
const double ptFin[3], int nSepF, int nIdF, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// puntatore alla linea
PtrOwner<ICurveLine> pCrvLine ;
// porto in locale i punti e il versore estrusione
Point3d ptIniL( ptIni) ;
Point3d ptFinL( ptFin) ;
Vector3d vtExtrL = Z_AX ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
return GDB_ID_NULL ;
if ( nRefType == RTY_GLOB) {
ptIniL.ToLoc( frLoc) ;
ptFinL.ToLoc( frLoc) ;
vtExtrL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptIniL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
ptFinL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
// 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( ptIni, ptFin))
if ( ! pCrvLine->Set( ptIniL, ptFinL))
return GDB_ID_NULL ;
}
// 2 - se primo punto definito e secondo a minima distanza
else if ( nSepI == SEP_STD && nSepF == SEP_MINDIST) {
pCrvLine.Set( CreateLinePointMinDistCurve( pGeomDB, nParentId, ptIni, ptFin, nIdF)) ;
pCrvLine.Set( CreateLinePointMinDistCurve( pGeomDB, nParentId, ptIniL, ptFinL, nIdF)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
}
// 3 - se primo punto a minima distanza e secondo definito
else if ( nSepI == SEP_MINDIST && nSepF == SEP_STD) {
pCrvLine.Set( CreateLinePointMinDistCurve( pGeomDB, nParentId, ptFin, ptIni, nIdI)) ;
pCrvLine.Set( CreateLinePointMinDistCurve( pGeomDB, nParentId, ptFinL, ptIniL, nIdI)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
pCrvLine->Invert() ;
}
// 4 - se primo punto definito e secondo tangente
else if ( nSepI == SEP_STD && nSepF == SEP_TG) {
pCrvLine.Set( CreateLinePointTgCurve( pGeomDB, nParentId, ptIni, ptFin, nIdF)) ;
pCrvLine.Set( CreateLinePointTgCurve( pGeomDB, nParentId, ptIniL, ptFinL, nIdF)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
}
// 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, ptFin, ptIni, nIdI)) ;
pCrvLine.Set( CreateLinePointTgCurve( pGeomDB, nParentId, ptFinL, ptIniL, nIdI)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
pCrvLine->Invert() ;
}
// 6 - se entrambi i punti tangenti
else if ( nSepI == SEP_TG && nSepF == SEP_TG) {
pCrvLine.Set( CreateLineTgTwoCurves( pGeomDB, nParentId, ptIni, nIdI, ptFin, nIdF)) ;
pCrvLine.Set( CreateLineTgTwoCurves( pGeomDB, nParentId, ptIniL, nIdI, ptFinL, nIdF)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
}
// 7 - se primo punto definito e secondo perpendicolare
else if ( nSepI == SEP_STD && nSepF == SEP_PERP) {
pCrvLine.Set( CreateLinePointPerpCurve( pGeomDB, nParentId, ptIni, ptFin, nIdF)) ;
pCrvLine.Set( CreateLinePointPerpCurve( pGeomDB, nParentId, ptIniL, ptFinL, nIdF)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
}
// 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, ptFin, ptIni, nIdI)) ;
pCrvLine.Set( CreateLinePointPerpCurve( pGeomDB, nParentId, ptFinL, ptIniL, nIdI)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
pCrvLine->Invert() ;
}
// 9 - se entrambi i punti perpendicolari
else if ( nSepI == SEP_PERP && nSepF == SEP_PERP) {
pCrvLine.Set( CreateLinePerpTwoCurves( pGeomDB, nParentId, ptIni, nIdI, ptFin, nIdF)) ;
pCrvLine.Set( CreateLinePerpTwoCurves( pGeomDB, nParentId, ptIniL, nIdI, ptFinL, nIdF)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
}
// 10 - se primo punto tangente e secondo perpendicolare
else if ( nSepI == SEP_TG && nSepF == SEP_PERP) {
pCrvLine.Set( CreateLineTgCurvePerpCurve( pGeomDB, nParentId, ptIni, nIdI, ptFin, nIdF)) ;
pCrvLine.Set( CreateLineTgCurvePerpCurve( pGeomDB, nParentId, ptIniL, nIdI, ptFinL, nIdF)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
}
// 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, ptFin, nIdF, ptIni, nIdI)) ;
pCrvLine.Set( CreateLineTgCurvePerpCurve( pGeomDB, nParentId, ptFinL, nIdF, ptIniL, nIdI)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
pCrvLine->Invert() ;
@@ -170,8 +208,7 @@ __stdcall EgtCreateCurveLineEx( int nParentId, const double ptIni[3], int nSepI,
return GDB_ID_NULL ;
}
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvLine)))
return GDB_ID_NULL ;
pCrvLine->SetExtrusion( vtExtrL) ;
// inserisco la linea nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
// se richiesto, salvo il comando Lua equivalente
@@ -180,7 +217,8 @@ __stdcall EgtCreateCurveLineEx( int nParentId, const double ptIni[3], int nSepI,
if ( nSepI == SEP_STD && nSepF == SEP_STD)
sLua = "EgtLine(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptIni)) + "},{" +
ToString( Point3d( ptFin)) + "})" +
ToString( Point3d( ptFin)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
else
sLua = "EgtLineEx(" + ToString( nParentId) + ",{" +
@@ -189,7 +227,8 @@ __stdcall EgtCreateCurveLineEx( int nParentId, const double ptIni[3], int nSepI,
ToString( nIdI) + ",{" +
ToString( Point3d( ptFin)) + "}," +
SepToString( nSepF) + "," +
ToString( nIdF) + ")" +
ToString( nIdF) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -460,20 +499,39 @@ __stdcall CreateLineTgCurvePerpCurve( IGeomDB* pGeomDB, int nParentId,
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveLinePVL( int nParentId, const double ptIni[3], const double vtDir[3], double dLen)
__stdcall EgtCreateCurveLinePVL( int nParentId, const double ptIni[3],
const double vtDir[3], double dLen, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// porto in locale i punti e il versore estrusione
Point3d ptIniL( ptIni) ;
Vector3d vtDirL( vtDir) ;
Vector3d vtExtrL = Z_AX ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
return GDB_ID_NULL ;
if ( nRefType == RTY_GLOB) {
ptIniL.ToLoc( frLoc) ;
vtDirL.ToLoc( frLoc) ;
vtExtrL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptIniL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtDirL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
// creo la linea
PtrOwner<ICurveLine> pCrvLine( CreateCurveLine()) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
// setto la linea
if ( ! pCrvLine->SetPVL( ptIni, vtDir, dLen))
if ( ! pCrvLine->SetPVL( ptIniL, vtDirL, dLen))
return GDB_ID_NULL ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvLine)))
return GDB_ID_NULL ;
pCrvLine->SetExtrusion( vtExtrL) ;
// inserisco la linea nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
// se richiesto, salvo il comando Lua equivalente
@@ -481,7 +539,8 @@ __stdcall EgtCreateCurveLinePVL( int nParentId, const double ptIni[3], const dou
string sLua = "EgtLinePVL(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptIni)) + "},{" +
ToString( Vector3d( vtDir)) + "}," +
ToString( dLen) + ")" +
ToString( dLen) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -492,14 +551,25 @@ __stdcall EgtCreateCurveLinePVL( int nParentId, const double ptIni[3], const dou
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveLineMinPointCurve( int nParentId,
const double ptStart[3], int nCrvId, double dNearPar)
const double ptStart[3], int nCrvId, double dNearPar, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero il riferimento del gruppo destinazione
Frame3d frPoint ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frPoint))
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
return GDB_ID_NULL ;
// porto in locale il punto e il versore estrusione
Point3d ptStartL( ptStart) ;
Vector3d vtExtrL = Z_AX ;
if ( nRefType == RTY_GLOB) {
ptStartL.ToLoc( frLoc) ;
vtExtrL.ToLoc( frLoc) ;
}
else if ( nRefType == RTY_GRID) {
ptStartL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
// recupero il riferimento della curva
Frame3d frCurve ;
if ( ! pGeomDB->GetGlobFrame( nCrvId, frCurve))
@@ -509,26 +579,25 @@ __stdcall EgtCreateCurveLineMinPointCurve( int nParentId,
if ( pCurve == nullptr)
return GDB_ID_NULL ;
// porto il punto nel riferimento della curva
Point3d ptSloc = ptStart ;
ptSloc.LocToLoc( frPoint, frCurve) ;
Point3d ptStartC = ptStart ;
ptStartC.LocToLoc( frLoc, frCurve) ;
// calcolo il punto a minima distanza
int nFlag ;
Point3d ptEnd ;
DistPointCurve dstPtCurve( ptSloc, *pCurve) ;
if ( ! dstPtCurve.GetMinDistPoint( dNearPar, ptEnd, nFlag))
Point3d ptEndL ;
DistPointCurve dstPtCurve( ptStartC, *pCurve) ;
if ( ! dstPtCurve.GetMinDistPoint( dNearPar, ptEndL, nFlag))
return GDB_ID_NULL ;
// porto il punto finale nel riferimento di creazione
ptEnd.LocToLoc( frCurve, frPoint) ;
ptEndL.LocToLoc( frCurve, frLoc) ;
// creo la linea
PtrOwner<ICurveLine> pCrvLine( CreateCurveLine()) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
// setto la linea
if ( ! pCrvLine->Set( ptStart, ptEnd))
if ( ! pCrvLine->Set( ptStartL, ptEndL))
return GDB_ID_NULL ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvLine)))
return GDB_ID_NULL ;
pCrvLine->SetExtrusion( vtExtrL) ;
// inserisco la linea nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
// se richiesto, salvo il comando Lua equivalente
@@ -536,7 +605,8 @@ __stdcall EgtCreateCurveLineMinPointCurve( int nParentId,
string sLua = "EgtLineMinPointCurve(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptStart)) + "}," +
ToString( nCrvId) + "," +
ToString( dNearPar) + ")" +
ToString( dNearPar) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -546,8 +616,8 @@ __stdcall EgtCreateCurveLineMinPointCurve( int nParentId,
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCircle( int nParentId,
const double ptCen[3], const double vtN[3], double dRad)
__stdcall EgtCreateCurveCircle( int nParentId, const double ptCen[3],
const double vtN[3], double dRad, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
@@ -555,27 +625,39 @@ __stdcall EgtCreateCurveCircle( int nParentId,
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( IsNull( pCrvArc))
return GDB_ID_NULL ;
// porto in locale il centro, la normale e il versore estrusione
Point3d ptCenL( ptCen) ;
Vector3d vtNL( vtN) ;
Vector3d vtExtrL = Z_AX ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
return GDB_ID_NULL ;
if ( nRefType == RTY_GLOB) {
ptCenL.ToLoc( frLoc) ;
vtNL.ToLoc( frLoc) ;
vtExtrL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptCenL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtNL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
// setto la circonferenza
if ( ! pCrvArc->Set( ptCen, vtN, dRad))
if ( ! pCrvArc->Set( ptCenL, vtNL, dRad))
return GDB_ID_NULL ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
pCrvArc->SetExtrusion( vtExtrL) ;
// inserisco l'arco nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua ;
if ( Vector3d( vtN).IsZplus())
sLua = "EgtCircleXY(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "}," +
ToString( dRad) + ")" +
" -- Id=" + ToString( nId) ;
else
sLua = "EgtCircle(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "},{" +
ToString( Vector3d( vtN)) + "}," +
ToString( dRad) + ")" +
string sLua = "EgtCircle(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "},{" +
ToString( Vector3d( vtN)) + "}," +
ToString( dRad) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -585,8 +667,8 @@ __stdcall EgtCreateCurveCircle( int nParentId,
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCircleXY( int nParentId,
const double ptCen[3], double dRad)
__stdcall EgtCreateCurveCircleCPN( int nParentId, const double ptCen[3],
const double ptOn[3], const double vtN[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
@@ -594,45 +676,35 @@ __stdcall EgtCreateCurveCircleXY( int nParentId,
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( IsNull( pCrvArc))
return GDB_ID_NULL ;
// setto la circonferenza
if ( ! pCrvArc->SetXY( ptCen, dRad))
return GDB_ID_NULL ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
// inserisco l'arco nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtCircleXY(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "}," +
ToString( dRad) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
// porto in locale i punti, i versori e il versore estrusione
Point3d ptCenL( ptCen) ;
Point3d ptOnL( ptOn) ;
Vector3d vtNL( vtN) ;
Vector3d vtExtrL = Z_AX ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
return GDB_ID_NULL ;
if ( nRefType == RTY_GLOB) {
ptCenL.ToLoc( frLoc) ;
ptOnL.ToLoc( frLoc) ;
vtNL.ToLoc( frLoc) ;
vtExtrL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptCenL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
ptOnL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtNL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCircleCPN( int nParentId,
const double ptCen[3], const double ptOn[3], const double vtN[3])
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo l'arco
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( IsNull( pCrvArc))
return GDB_ID_NULL ;
// calcolo il raggio
double dRad = (( Point3d( ptOn) - Point3d( ptCen)) ^ Vector3d( vtN)).Len() ;
double dRad = (( ptOnL - ptCenL) ^ vtNL).Len() ;
// setto la circonferenza
if ( ! pCrvArc->Set( ptCen, vtN, dRad))
if ( ! pCrvArc->Set( ptCenL, vtNL, dRad))
return GDB_ID_NULL ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
pCrvArc->SetExtrusion( vtExtrL) ;
// inserisco l'arco nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
// se richiesto, salvo il comando Lua equivalente
@@ -640,7 +712,8 @@ __stdcall EgtCreateCurveCircleCPN( int nParentId,
string sLua = "EgtCircleCPN(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "},{" +
ToString( Point3d( ptOn)) + "},{" +
ToString( Vector3d( vtN)) + "})" +
ToString( Vector3d( vtN)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -650,8 +723,8 @@ __stdcall EgtCreateCurveCircleCPN( int nParentId,
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCircle3P( int nParentId,
const double ptP1[3], const double ptP2[3], const double ptP3[3])
__stdcall EgtCreateCurveCircle3P( int nParentId, const double ptP1[3],
const double ptP2[3], const double ptP3[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
@@ -659,12 +732,33 @@ __stdcall EgtCreateCurveCircle3P( int nParentId,
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( IsNull( pCrvArc))
return GDB_ID_NULL ;
// porto in locale i punti e il versore estrusione
Point3d ptP1L( ptP1) ;
Point3d ptP2L( ptP2) ;
Point3d ptP3L( ptP3) ;
Vector3d vtExtrL = Z_AX ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
return GDB_ID_NULL ;
if ( nRefType == RTY_GLOB) {
ptP1L.ToLoc( frLoc) ;
ptP2L.ToLoc( frLoc) ;
ptP3L.ToLoc( frLoc) ;
vtExtrL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptP1L.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
ptP2L.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
ptP3L.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
// setto l'arco
if ( ! pCrvArc->Set3P( ptP1, ptP2, ptP3, true))
if ( ! pCrvArc->Set3P( ptP1L, ptP2L, ptP3L, true))
return GDB_ID_NULL ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
pCrvArc->SetExtrusion( vtExtrL) ;
// inserisco l'arco nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
// se richiesto, salvo il comando Lua equivalente
@@ -672,7 +766,8 @@ __stdcall EgtCreateCurveCircle3P( int nParentId,
string sLua = "EgtCircle3P(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptP1)) + "},{" +
ToString( Point3d( ptP2)) + "},{" +
ToString( Point3d( ptP3)) + "})" +
ToString( Point3d( ptP3)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -684,7 +779,7 @@ __stdcall EgtCreateCurveCircle3P( int nParentId,
int
__stdcall EgtCreateCurveArc( int nParentId,
const double ptCen[3], const double vtN[3], double dRad,
const double vtS[3], double dAngCenDeg, double dDeltaN)
const double vtS[3], double dAngCenDeg, double dDeltaN, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
@@ -692,12 +787,33 @@ __stdcall EgtCreateCurveArc( int nParentId,
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( IsNull( pCrvArc))
return GDB_ID_NULL ;
// porto in locale i punti, i versori e il versore estrusione
Point3d ptCenL( ptCen) ;
Vector3d vtNL( vtN) ;
Vector3d vtSL( vtS) ;
Vector3d vtExtrL = Z_AX ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
return GDB_ID_NULL ;
if ( nRefType == RTY_GLOB) {
ptCenL.ToLoc( frLoc) ;
vtNL.ToLoc( frLoc) ;
vtSL.ToLoc( frLoc) ;
vtExtrL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptCenL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtNL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtSL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
// setto l'arco
if ( ! pCrvArc->Set( ptCen, vtN, dRad, vtS, dAngCenDeg, dDeltaN))
if ( ! pCrvArc->Set( ptCenL, vtNL, dRad, vtSL, dAngCenDeg, dDeltaN))
return GDB_ID_NULL ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
pCrvArc->SetExtrusion( vtExtrL) ;
// inserisco l'arco nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
// se richiesto, salvo il comando Lua equivalente
@@ -708,7 +824,8 @@ __stdcall EgtCreateCurveArc( int nParentId,
ToString( dRad) + ",{" +
ToString( Vector3d( vtS)) + "}," +
ToString( dAngCenDeg) + "," +
ToString( dDeltaN) + ")" +
ToString( dDeltaN) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -718,9 +835,8 @@ __stdcall EgtCreateCurveArc( int nParentId,
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveArcXY( int nParentId,
const double ptCen[3], double dRad,
double dAngStartDeg, double dAngCenDeg, double dDeltaZ)
__stdcall EgtCreateCurveArcC2PN( int nParentId, const double ptCen[3], const double ptStart[3],
const double ptNearEnd[3], const double vtNorm[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
@@ -728,46 +844,36 @@ __stdcall EgtCreateCurveArcXY( int nParentId,
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( IsNull( pCrvArc))
return GDB_ID_NULL ;
// setto l'arco
if ( ! pCrvArc->SetXY( ptCen, dRad, dAngStartDeg, dAngCenDeg, dDeltaZ))
return GDB_ID_NULL ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
// inserisco l'arco nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtArc(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "}," +
ToString( dRad) + "," +
ToString( dAngStartDeg) + "," +
ToString( dAngCenDeg) + "," +
ToString( dDeltaZ) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
// porto in locale i punti, i versori e il versore estrusione
Point3d ptCenL( ptCen) ;
Point3d ptStartL( ptStart) ;
Point3d ptNearEndL( ptNearEnd) ;
Vector3d vtNormL( vtNorm) ;
Vector3d vtExtrL = Z_AX ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
return GDB_ID_NULL ;
if ( nRefType == RTY_GLOB) {
ptCenL.ToLoc( frLoc) ;
ptStartL.ToLoc( frLoc) ;
ptNearEndL.ToLoc( frLoc) ;
vtNormL.ToLoc( frLoc) ;
vtExtrL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptCenL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
ptStartL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
ptNearEndL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtNormL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveArcC2PN( int nParentId,
const double ptCen[3], const double ptStart[3], const double ptNearEnd[3], const double vtNorm[3])
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo l'arco
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( IsNull( pCrvArc))
return GDB_ID_NULL ;
// setto l'arco
if ( ! pCrvArc->SetC2PN( ptCen, ptStart, ptNearEnd, vtNorm))
if ( ! pCrvArc->SetC2PN( ptCenL, ptStartL, ptNearEndL, vtNormL))
return GDB_ID_NULL ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
pCrvArc->SetExtrusion( vtExtrL) ;
// inserisco l'arco nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
// se richiesto, salvo il comando Lua equivalente
@@ -776,7 +882,8 @@ __stdcall EgtCreateCurveArcC2PN( int nParentId,
ToString( Point3d( ptCen)) + "},{" +
ToString( Point3d( ptStart)) + "},{" +
ToString( Point3d( ptNearEnd)) + "},{" +
ToString( Vector3d( vtNorm)) + "})" +
ToString( Vector3d( vtNorm)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -786,8 +893,8 @@ __stdcall EgtCreateCurveArcC2PN( int nParentId,
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveArc3P( int nParentId,
const double ptP1[3], const double ptP2[3], const double ptP3[3])
__stdcall EgtCreateCurveArc3P( int nParentId, const double ptP1[3],
const double ptP2[3], const double ptP3[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
@@ -795,29 +902,54 @@ __stdcall EgtCreateCurveArc3P( int nParentId,
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( IsNull( pCrvArc))
return GDB_ID_NULL ;
// porto in locale i punti e il versore estrusione
Point3d ptP1L( ptP1) ;
Point3d ptP2L( ptP2) ;
Point3d ptP3L( ptP3) ;
Vector3d vtExtrL = Z_AX ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
return GDB_ID_NULL ;
if ( nRefType == RTY_GLOB) {
ptP1L.ToLoc( frLoc) ;
ptP2L.ToLoc( frLoc) ;
ptP3L.ToLoc( frLoc) ;
vtExtrL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptP1L.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
ptP2L.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
ptP3L.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
int nId = GDB_ID_NULL ;
// setto l'arco
if ( pCrvArc->Set3P( ptP1, ptP2, ptP3, false)) {
if ( pCrvArc->Set3P( ptP1L, ptP2L, ptP3L, false)) {
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
pCrvArc->SetExtrusion( vtExtrL) ;
// inserisco l'arco nel DB
nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
}
// se risulta essere una retta
else if ( ( Point3d( ptP2) - Point3d( ptP1)) * ( Point3d( ptP3) - Point3d( ptP2)) > EPS_ZERO) {
bool bOldCmdLog = IsCmdLog() ;
EgtDisableCommandLogger() ;
nId = EgtCreateCurveLine( nParentId, ptP1, ptP3) ;
if ( bOldCmdLog)
EgtEnableCommandLogger() ;
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)) ;
}
}
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtArc3P(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptP1)) + "},{" +
ToString( Point3d( ptP2)) + "},{" +
ToString( Point3d( ptP3)) + "})" +
ToString( Point3d( ptP3)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -827,8 +959,8 @@ __stdcall EgtCreateCurveArc3P( int nParentId,
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveArc2PVN( int nParentId,
const double ptStart[3], const double ptEnd[3], const double vtDirS[3], const double vtNorm[3])
__stdcall EgtCreateCurveArc2PVN( int nParentId, const double ptStart[3], const double ptEnd[3],
const double vtDirS[3], const double vtNorm[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
@@ -836,22 +968,49 @@ __stdcall EgtCreateCurveArc2PVN( int nParentId,
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
if ( IsNull( pCrvArc))
return GDB_ID_NULL ;
// porto in locale i punti, i versori e il versore estrusione
Point3d ptStartL( ptStart) ;
Point3d ptEndL( ptEnd) ;
Vector3d vtDirSL( vtDirS) ;
Vector3d vtNormL( vtNorm) ;
Vector3d vtExtrL = Z_AX ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
return GDB_ID_NULL ;
if ( nRefType == RTY_GLOB) {
ptStartL.ToLoc( frLoc) ;
ptEndL.ToLoc( frLoc) ;
vtDirSL.ToLoc( frLoc) ;
vtNormL.ToLoc( frLoc) ;
vtExtrL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptStartL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
ptEndL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtDirSL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtNormL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
int nId = GDB_ID_NULL ;
// setto l'arco
if ( pCrvArc->Set2PVN( ptStart, ptEnd, vtDirS, vtNorm)) {
if ( pCrvArc->Set2PVN( ptStartL, ptEndL, vtDirSL, vtNormL)) {
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc)))
return GDB_ID_NULL ;
pCrvArc->SetExtrusion( vtExtrL) ;
// inserisco l'arco nel DB
nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
}
// se risulta essere una retta
else if ( ( Point3d( ptEnd) - Point3d( ptStart)) * Vector3d( vtDirS) > EPS_ZERO) {
bool bOldCmdLog = IsCmdLog() ;
EgtDisableCommandLogger() ;
nId = EgtCreateCurveLine( nParentId, ptStart, ptEnd) ;
if ( bOldCmdLog)
EgtEnableCommandLogger() ;
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)) ;
}
}
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
@@ -859,7 +1018,8 @@ __stdcall EgtCreateCurveArc2PVN( int nParentId,
ToString( Point3d( ptStart)) + "},{" +
ToString( Point3d( ptEnd)) + "},{" +
ToString( Vector3d( vtDirS)) + "},{" +
ToString( Vector3d( vtNorm)) + "})" +
ToString( Vector3d( vtNorm)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -1304,38 +1464,62 @@ __stdcall EgtCreateCurveCompoByApprox( int nParentId, int nSouId, BOOL bArcsVsLi
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateRectangle3P( int nParentId,
const double ptIni[3], const double ptCross[3], const double ptDir[3])
__stdcall EgtCreateRectangle3P( int nParentId, const double ptIni[3],
const double ptCross[3], const double ptDir[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// recupero il riferimento di inserimento
Frame3d frEnt ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frEnt))
bOk = false ;
// porto in locale i punti, i versori e il versore estrusione
Point3d ptIniL( ptIni) ;
Point3d ptCrossL( ptCross) ;
Point3d ptDirL( ptDir) ;
Vector3d vtExtrL = Z_AX ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
if ( bOk) {
if ( nRefType == RTY_GLOB) {
ptIniL.ToLoc( frLoc) ;
ptCrossL.ToLoc( frLoc) ;
ptDirL.ToLoc( frLoc) ;
vtExtrL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptIniL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
ptCrossL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
ptDirL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
}
// calcolo il lato X
Vector3d vtDirX = Point3d( ptDir) - Point3d( ptIni) ;
bOk = vtDirX.Normalize() ;
Vector3d vtLatoX = bOk ? (( Point3d( ptCross) - Point3d( ptIni)) * vtDirX) * vtDirX : V_NULL ;
Vector3d vtDirX = ptDirL - ptIniL ;
bOk = bOk && vtDirX.Normalize() ;
Vector3d vtLatoX = bOk ? (( ptCrossL - ptIniL) * vtDirX) * vtDirX : V_NULL ;
// creo la polilinea con i punti
int nId = GDB_ID_NULL ;
if ( bOk) {
PolyLine PL ;
PL.AddUPoint( 0, ptIni) ;
PL.AddUPoint( 1, Point3d( ptIni) + vtLatoX) ;
PL.AddUPoint( 2, ptCross) ;
PL.AddUPoint( 3, Point3d( ptCross) - vtLatoX) ;
PL.AddUPoint( 4, ptIni) ;
PL.AddUPoint( 0, ptIniL) ;
PL.AddUPoint( 1, Point3d( ptIniL) + vtLatoX) ;
PL.AddUPoint( 2, ptCrossL) ;
PL.AddUPoint( 3, Point3d( ptCrossL) - vtLatoX) ;
PL.AddUPoint( 4, ptIniL) ;
// creo la curva e la inserisco nel GDB
nId = EgtCreateCurveCompoFromPoints( nParentId, PL) ;
// ne sistemo il vettore estrusione
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCurve != nullptr)
pCurve->SetExtrusion( vtExtrL) ;
}
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtRectangle3P(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptIni)) + "},{" +
ToString( Point3d( ptCross)) + "},{" +
ToString( Point3d( ptDir)) + "})" +
ToString( Point3d( ptDir)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -1345,23 +1529,57 @@ __stdcall EgtCreateRectangle3P( int nParentId,
//-------------------------------------------------------------------------------
int
__stdcall EgtCreatePolygonFromSide( int nParentId, int nNumSides,
const double ptIni[3], const double ptFin[3])
__stdcall EgtCreatePolygonFromSide( int nParentId, int nNumSides, const double ptIni[3],
const double ptFin[3], const double vtN[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// porto in locale i punti, la normale e il versore estrusione
Point3d ptIniL( ptIni) ;
Point3d ptFinL( ptFin) ;
Vector3d vtNL( vtN) ;
Vector3d vtExtrL = Z_AX ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
if ( bOk) {
if ( nRefType == RTY_GLOB) {
ptIniL.ToLoc( frLoc) ;
ptFinL.ToLoc( frLoc) ;
vtNL.ToLoc( frLoc) ;
vtExtrL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptIniL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
ptFinL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtNL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
}
// creo la curva composita
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
if ( IsNull( pCrvCompo))
return GDB_ID_NULL ;
bOk = bOk && ! IsNull( pCrvCompo) ;
// setto la curva
if ( ! pCrvCompo->PolygonSide( nNumSides, ptIni, ptFin))
return GDB_ID_NULL ;
bOk = bOk && pCrvCompo->PolygonSide( nNumSides, ptIniL, ptFinL, vtNL) ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvCompo)))
return GDB_ID_NULL ;
bOk = bOk && pCrvCompo->SetExtrusion( vtExtrL) ;
// inserisco la curva 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 sLua = "EgtPolygonFromSide(" + ToString( nParentId) + "," +
ToString( nNumSides) + ",{" +
ToString( Point3d( ptIni)) + "},{" +
ToString( Point3d( ptFin)) + "},{" +
ToString( Vector3d( vtN)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------