Files
EgtInterface/API_GdbCreateCurve.cpp
T
Dario Sassi 4e5a81c493 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).
2015-01-19 18:21:58 +00:00

1674 lines
65 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : API_GdbCreateCurve.cpp Data : 02.11.14 Versione : 1.5j7
// Contenuto : Funzioni di creazione curve del DB geometrico per API.
//
//
//
// Modifiche : 02.11.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "API.h"
#include "API_Macro.h"
#include "AuxTools.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EInConst.h"
#include "/EgtDev/Include/EgkCurveLine.h"
#include "/EgtDev/Include/EGkLinePntTgCurve.h"
#include "/EgtDev/Include/EGkLinePntPerpCurve.h"
#include "/EgtDev/Include/EGkLinePntMinDistCurve.h"
#include "/EgtDev/Include/EGkLineTgTwoCurves.h"
#include "/EgtDev/Include/EGkLinePerpTwoCurves.h"
#include "/EgtDev/Include/EGkLineTgCurvePerpCurve.h"
#include "/EgtDev/Include/EgkCurveArc.h"
#include "/EgtDev/Include/EgkCurveBezier.h"
#include "/EgtDev/Include/EgkCurveComposite.h"
#include "/EgtDev/Include/EgkChainCurves.h"
#include "/EgtDev/Include/EgkSurfTriMesh.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
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) ;
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveLine( int nParentId, const double ptIni[3], const double ptFin[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo la linea
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( ptIniL, ptFinL))
return GDB_ID_NULL ;
// assegno il versore estrusione
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)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveLineEx( int nParentId, const double ptIni[3], int nSepI, int nIdI,
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( 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, ptFinL, nIdF, ptIniL, nIdI)) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
pCrvLine->Invert() ;
}
// errore
else {
return GDB_ID_NULL ;
}
// assegno il versore estrusione
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 ;
if ( nSepI == SEP_STD && nSepF == SEP_STD)
sLua = "EgtLine(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptIni)) + "},{" +
ToString( Point3d( ptFin)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
else
sLua = "EgtLineEx(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptIni)) + "}," +
SepToString( nSepI) + "," +
ToString( nIdI) + ",{" +
ToString( Point3d( ptFin)) + "}," +
SepToString( nSepF) + "," +
ToString( nIdF) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
ICurveLine*
__stdcall CreateLinePointTgCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, const Point3d& ptFin, int nIdF)
{
// verifica preliminare Id curva
if ( nIdF == GDB_ID_NULL)
return nullptr ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest))
return nullptr ;
// recupero il riferimento della curva
Frame3d frCurve ;
if ( ! pGeomDB->GetGlobFrame( nIdF, frCurve))
return nullptr ;
// porto il punto iniziale nel riferimento della curva
Point3d ptSloc( ptIni) ;
ptSloc.LocToLoc( frDest, frCurve) ;
// porto il punto vicino al finale nel riferimento della curva
Point3d ptNloc( ptFin) ;
ptNloc.LocToLoc( frDest, frCurve) ;
// recupero la curva
const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nIdF)) ;
if ( pCurve == nullptr)
return false ;
// calcolo la retta tangente alla curva
PtrOwner<ICurveLine> pCrvLine ;
pCrvLine.Set( GetLinePointTgCurve( ptSloc, *pCurve, ptNloc)) ;
if ( IsNull( pCrvLine))
return nullptr ;
// porto la linea nel riferimento del gruppo destinazione
pCrvLine->LocToLoc( frCurve, frDest) ;
// restituisco la linea
return Release( pCrvLine) ;
}
//-------------------------------------------------------------------------------
ICurveLine*
__stdcall CreateLinePointPerpCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, const Point3d& ptFin, int nIdF)
{
// verifica preliminare Id curva
if ( nIdF == GDB_ID_NULL)
return nullptr ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest))
return nullptr ;
// recupero il riferimento della curva
Frame3d frCurve ;
if ( ! pGeomDB->GetGlobFrame( nIdF, frCurve))
return nullptr ;
// porto il punto iniziale nel riferimento della curva
Point3d ptSloc( ptIni) ;
ptSloc.LocToLoc( frDest, frCurve) ;
// porto il punto vicino al finale nel riferimento della curva
Point3d ptNloc( ptFin) ;
ptNloc.LocToLoc( frDest, frCurve) ;
// recupero la curva
const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nIdF)) ;
if ( pCurve == nullptr)
return nullptr ;
// calcolo la retta perpendicolare alla curva
PtrOwner<ICurveLine> pCrvLine ;
pCrvLine.Set( GetLinePointPerpCurve( ptSloc, *pCurve, ptNloc)) ;
if ( IsNull( pCrvLine))
return nullptr ;
// porto la linea nel riferimento del gruppo destinazione
pCrvLine->LocToLoc( frCurve, frDest) ;
// restituisco la linea
return Release( pCrvLine) ;
}
//-------------------------------------------------------------------------------
ICurveLine*
__stdcall CreateLinePointMinDistCurve( IGeomDB* pGeomDB, int nParentId,
const Point3d& ptIni, const Point3d& ptFin, int nIdF)
{
// verifica preliminare Id curva
if ( nIdF == GDB_ID_NULL)
return nullptr ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest))
return nullptr ;
// recupero il riferimento della curva
Frame3d frCurve ;
if ( ! pGeomDB->GetGlobFrame( nIdF, frCurve))
return nullptr ;
// porto il punto iniziale nel riferimento della curva
Point3d ptSloc( ptIni) ;
ptSloc.LocToLoc( frDest, frCurve) ;
// porto il punto vicino al finale nel riferimento della curva
Point3d ptNloc( ptFin) ;
ptNloc.LocToLoc( frDest, frCurve) ;
// recupero la curva
const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nIdF)) ;
if ( pCurve == nullptr)
return nullptr ;
// calcolo la retta perpendicolare alla curva
PtrOwner<ICurveLine> pCrvLine ;
pCrvLine.Set( GetLinePointMinDistCurve( ptSloc, *pCurve, ptNloc)) ;
if ( IsNull( pCrvLine))
return nullptr ;
// porto la linea nel riferimento del gruppo destinazione
pCrvLine->LocToLoc( frCurve, frDest) ;
// restituisco la linea
return Release( pCrvLine) ;
}
//-------------------------------------------------------------------------------
ICurveLine*
__stdcall 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)
return nullptr ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest))
return nullptr ;
// recupero il riferimento della prima curva
Frame3d frCrv1 ;
if ( ! pGeomDB->GetGlobFrame( nIdI, frCrv1))
return nullptr ;
// recupero la prima curva
const ICurve* pCrv1 = GetCurve( pGeomDB->GetGeoObj( nIdI)) ;
if ( pCrv1 == nullptr)
return nullptr ;
// porto il punto vicino a iniziale nel riferimento della prima curva
Point3d ptN1loc( ptIni) ;
ptN1loc.LocToLoc( frDest, frCrv1) ;
// recupero il riferimento della seconda curva
Frame3d frCrv2 ;
if ( ! pGeomDB->GetGlobFrame( nIdF, frCrv2))
return nullptr ;
// recupero la seconda curva
const ICurve* pCrv2 = GetCurve( pGeomDB->GetGeoObj( nIdF)) ;
if ( pCrv2 == nullptr)
return false ;
// porto la seconda curva nel riferimento della prima
PtrOwner<ICurve> pCrv2Loc( pCrv2->Clone()) ;
if ( IsNull( pCrv2Loc))
return nullptr ;
pCrv2Loc->LocToLoc( frCrv2, frCrv1) ;
// porto il punto vicino al finale nel riferimento della prima curva
Point3d ptN2loc( ptFin) ;
ptN2loc.LocToLoc( frDest, frCrv1) ;
// calcolo la retta tangente alle due curve
PtrOwner<ICurveLine> pCrvLine ;
pCrvLine.Set( GetLineTgTwoCurves( *pCrv1, ptN1loc, *pCrv2, ptN2loc)) ;
if ( IsNull( pCrvLine))
return nullptr ;
// porto la linea nel riferimento del gruppo destinazione
pCrvLine->LocToLoc( frCrv1, frDest) ;
// restituisco la linea
return Release( pCrvLine) ;
}
//-------------------------------------------------------------------------------
ICurveLine*
__stdcall 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)
return nullptr ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest))
return nullptr ;
// recupero il riferimento della prima curva
Frame3d frCrv1 ;
if ( ! pGeomDB->GetGlobFrame( nIdI, frCrv1))
return nullptr ;
// recupero la prima curva
const ICurve* pCrv1 = GetCurve( pGeomDB->GetGeoObj( nIdI)) ;
if ( pCrv1 == nullptr)
return nullptr ;
// porto il punto vicino a iniziale nel riferimento della prima curva
Point3d ptN1loc( ptIni) ;
ptN1loc.LocToLoc( frDest, frCrv1) ;
// recupero il riferimento della seconda curva
Frame3d frCrv2 ;
if ( ! pGeomDB->GetGlobFrame( nIdF, frCrv2))
return nullptr ;
// recupero la seconda curva
const ICurve* pCrv2 = GetCurve( pGeomDB->GetGeoObj( nIdF)) ;
if ( pCrv2 == nullptr)
return nullptr ;
// porto la seconda curva nel riferimento della prima
PtrOwner<ICurve> pCrv2Loc( pCrv2->Clone()) ;
if ( IsNull( pCrv2Loc))
return nullptr ;
pCrv2Loc->LocToLoc( frCrv2, frCrv1) ;
// porto il punto vicino al finale nel riferimento della prima curva
Point3d ptN2loc( ptFin) ;
ptN2loc.LocToLoc( frDest, frCrv1) ;
// calcolo la retta perpendicolare alle due curve
PtrOwner<ICurveLine> pCrvLine ;
pCrvLine.Set( GetLinePerpTwoCurves( *pCrv1, ptN1loc, *pCrv2, ptN2loc)) ;
if ( IsNull( pCrvLine))
return nullptr ;
// porto la linea nel riferimento del gruppo destinazione
pCrvLine->LocToLoc( frCrv1, frDest) ;
// restituisco la linea
return Release( pCrvLine) ;
}
//-------------------------------------------------------------------------------
ICurveLine*
__stdcall 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)
return nullptr ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest))
return nullptr ;
// recupero il riferimento della prima curva
Frame3d frCrv1 ;
if ( ! pGeomDB->GetGlobFrame( nIdI, frCrv1))
return nullptr ;
// recupero la prima curva
const ICurve* pCrv1 = GetCurve( pGeomDB->GetGeoObj( nIdI)) ;
if ( pCrv1 == nullptr)
return nullptr ;
// porto il punto vicino a iniziale nel riferimento della prima curva
Point3d ptN1loc( ptIni) ;
ptN1loc.LocToLoc( frDest, frCrv1) ;
// recupero il riferimento della seconda curva
Frame3d frCrv2 ;
if ( ! pGeomDB->GetGlobFrame( nIdF, frCrv2))
return nullptr ;
// recupero la seconda curva
const ICurve* pCrv2 = GetCurve( pGeomDB->GetGeoObj( nIdF)) ;
if ( pCrv2 == nullptr)
return nullptr ;
// porto la seconda curva nel riferimento della prima
PtrOwner<ICurve> pCrv2Loc( pCrv2->Clone()) ;
if ( IsNull( pCrv2Loc))
return nullptr ;
pCrv2Loc->LocToLoc( frCrv2, frCrv1) ;
// porto il punto vicino al finale nel riferimento della prima curva
Point3d ptN2loc( ptFin) ;
ptN2loc.LocToLoc( frDest, frCrv1) ;
// calcolo la retta perpendicolare alle due curve
PtrOwner<ICurveLine> pCrvLine ;
pCrvLine.Set( GetLineTgCurvePerpCurve( *pCrv1, ptN1loc, *pCrv2, ptN2loc)) ;
if ( IsNull( pCrvLine))
return nullptr ;
// porto la linea nel riferimento del gruppo destinazione
pCrvLine->LocToLoc( frCrv1, frDest) ;
// restituisco la linea
return Release( pCrvLine) ;
}
//-------------------------------------------------------------------------------
int
__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( ptIniL, vtDirL, dLen))
return GDB_ID_NULL ;
// assegno il versore estrusione
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 = "EgtLinePVL(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptIni)) + "},{" +
ToString( Vector3d( vtDir)) + "}," +
ToString( dLen) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveLineMinPointCurve( int nParentId,
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 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))
return GDB_ID_NULL ;
// recupero la curva
const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ;
if ( pCurve == nullptr)
return GDB_ID_NULL ;
// porto il punto nel riferimento della curva
Point3d ptStartC = ptStart ;
ptStartC.LocToLoc( frLoc, frCurve) ;
// calcolo il punto a minima distanza
int 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
ptEndL.LocToLoc( frCurve, frLoc) ;
// creo la linea
PtrOwner<ICurveLine> pCrvLine( CreateCurveLine()) ;
if ( IsNull( pCrvLine))
return GDB_ID_NULL ;
// setto la linea
if ( ! pCrvLine->Set( ptStartL, ptEndL))
return GDB_ID_NULL ;
// assegno il versore estrusione
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 = "EgtLineMinPointCurve(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptStart)) + "}," +
ToString( nCrvId) + "," +
ToString( dNearPar) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__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)
// creo l'arco
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( ptCenL, vtNL, dRad))
return GDB_ID_NULL ;
// assegno il versore estrusione
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 = "EgtCircle(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "},{" +
ToString( Vector3d( vtN)) + "}," +
ToString( dRad) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// 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], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo l'arco
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) ;
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) ;
}
}
// calcolo il raggio
double dRad = (( ptOnL - ptCenL) ^ vtNL).Len() ;
// setto la circonferenza
if ( ! pCrvArc->Set( ptCenL, vtNL, dRad))
return GDB_ID_NULL ;
// assegno il versore estrusione
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 = "EgtCircleCPN(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "},{" +
ToString( Point3d( ptOn)) + "},{" +
ToString( Vector3d( vtN)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__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)
// creo l'arco
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( ptP1L, ptP2L, ptP3L, true))
return GDB_ID_NULL ;
// assegno il versore estrusione
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 = "EgtCircle3P(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptP1)) + "},{" +
ToString( Point3d( ptP2)) + "},{" +
ToString( Point3d( ptP3)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveArc( int nParentId,
const double ptCen[3], const double vtN[3], double dRad,
const double vtS[3], double dAngCenDeg, double dDeltaN, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo l'arco
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( ptCenL, vtNL, dRad, vtSL, dAngCenDeg, dDeltaN))
return GDB_ID_NULL ;
// assegno il versore estrusione
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 = "EgtArc(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "},{" +
ToString( Vector3d( vtN)) + "}," +
ToString( dRad) + ",{" +
ToString( Vector3d( vtS)) + "}," +
ToString( dAngCenDeg) + "," +
ToString( dDeltaN) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// 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], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo l'arco
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) ;
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) ;
}
}
// setto l'arco
if ( ! pCrvArc->SetC2PN( ptCenL, ptStartL, ptNearEndL, vtNormL))
return GDB_ID_NULL ;
// assegno il versore estrusione
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 = "EgtArcC2PN(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptCen)) + "},{" +
ToString( Point3d( ptStart)) + "},{" +
ToString( Point3d( ptNearEnd)) + "},{" +
ToString( Vector3d( vtNorm)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__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)
// creo l'arco
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( 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)) ;
}
}
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtArc3P(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptP1)) + "},{" +
ToString( Point3d( ptP2)) + "},{" +
ToString( Point3d( ptP3)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__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)
// creo l'arco
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( 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)) ;
}
}
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtArc2PVN(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptStart)) + "},{" +
ToString( Point3d( ptEnd)) + "},{" +
ToString( Vector3d( vtDirS)) + "},{" +
ToString( Vector3d( vtNorm)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveBezier( int nParentId, int nDegree, const double ptCtrls[])
{
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) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveBezier( int nParentId, int nDegree, const PNTVECTOR& vPnt)
{
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 ;
// creo la curva di Bezier
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
if ( IsNull( pCrvBez))
return GDB_ID_NULL ;
// inizializzo la curva di Bezier
if ( ! pCrvBez->Init( nDegree, false))
return GDB_ID_NULL ;
// setto i punti di controllo
for ( int i = 0 ; i <= nDegree ; ++ i) {
if ( ! pCrvBez->SetControlPoint( i, vPnt[i]))
return GDB_ID_NULL ;
}
// se curva nulla (ovvero ridotta a punto), errore
if ( pCrvBez->IsAPoint())
return GDB_ID_NULL ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvBez)))
return GDB_ID_NULL ;
// inserisco la curva nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveBezierRational( int nParentId, int nDegree, const double ptCtrlWs[])
{
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) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveBezierRational( int nParentId, int nDegree, const PNTUVECTOR& vPntW)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// il numero dei punti deve essere pari al grado + 1
if ( vPntW.size() != nDegree + 1)
return GDB_ID_NULL ;
// creo la curva di Bezier
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
if ( IsNull( pCrvBez))
return GDB_ID_NULL ;
// inizializzo la curva di Bezier
if ( ! pCrvBez->Init( nDegree, true))
return GDB_ID_NULL ;
// setto i punti di controllo
for ( int i = 0 ; i <= nDegree ; ++ i) {
if ( ! pCrvBez->SetControlPoint( i, vPntW[i].first, vPntW[i].second))
return GDB_ID_NULL ;
}
// se curva nulla (ovvero ridotta a punto), errore
if ( pCrvBez->IsAPoint())
return GDB_ID_NULL ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvBez)))
return GDB_ID_NULL ;
// inserisco la curva nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveBezierFromArc( int nParentId, int nArcId, BOOL bErase)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo la curva di Bezier
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
if ( IsNull( pCrvBez))
return GDB_ID_NULL ;
// recupero l'arco
const ICurveArc* pCrvArc = GetCurveArc( pGeomDB->GetGeoObj( nArcId)) ;
if ( pCrvArc == nullptr)
return GDB_ID_NULL ;
// ne deduco la curva di Bezier
if ( ! pCrvBez->FromArc( *pCrvArc))
return GDB_ID_NULL ;
// recupero il riferimento dell'arco
Frame3d frSou ;
if ( ! pGeomDB->GetGlobFrame( nArcId, frSou))
return GDB_ID_NULL ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest))
return GDB_ID_NULL ;
// porto la curva di Bezier dal riferimento dell'arco a quello di inserimento
if ( ! AreSameFrame( frSou, frDest)) {
pCrvBez->ToGlob( frSou) ;
pCrvBez->ToLoc( frDest) ;
}
// se curva nulla (ovvero ridotta a punto), errore
if ( pCrvBez->IsAPoint())
return GDB_ID_NULL ;
// inserisco la curva nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) ;
if ( nId != GDB_ID_NULL) {
// se richiesto, cancello l'arco originale
if ( bErase) {
if ( ! pGeomDB->Erase( nArcId))
return GDB_ID_NULL ;
}
}
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompo( int nParentId, int nNumId, const int nIds[], BOOL bErase)
{
INTVECTOR vIds ;
vIds.reserve( nNumId) ;
for ( int i = 0 ; i < nNumId ; ++i) {
vIds.push_back( nIds[i]) ;
}
return EgtCreateCurveCompo( nParentId, vIds, ( bErase != FALSE)) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompo( int nParentId, const INTVECTOR& vIds, bool bErase)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo la curva composita
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
if ( IsNull( pCrvCompo))
return GDB_ID_NULL ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest))
return false ;
// esecuzione
INTVECTOR::const_iterator Iter ;
for ( Iter = vIds.begin() ; Iter != vIds.end() ; ++Iter) {
// recupero la curva
int nIdCrv = *Iter ;
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nIdCrv)) ;
if ( pCrv == nullptr)
return false ;
// 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 ;
}
}
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvCompo)))
return GDB_ID_NULL ;
// inserisco la curva composita nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) ;
// se ok e richiesto, cancello le curve originali
if ( nId != GDB_ID_NULL && bErase) {
for ( Iter = vIds.begin() ; Iter != vIds.end() ; ++Iter) {
if ( ! pGeomDB->Erase( *Iter))
return GDB_ID_NULL ;
}
}
return nId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoByChain( int nParentId, int nNumId, const int nIds[], const double ptNear[3], BOOL bErase)
{
INTVECTOR vIds ;
vIds.reserve( nNumId) ;
for ( int i = 0 ; i < nNumId ; ++i) {
vIds.push_back( nIds[i]) ;
}
return EgtCreateCurveCompoByChain( nParentId, vIds, ptNear, ( bErase != FALSE)) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, const Point3d& ptNear, bool bErase)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo la curva composita
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
if ( IsNull( pCrvCompo))
return GDB_ID_NULL ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest))
return GDB_ID_NULL ;
// preparo i dati per il concatenamento
double dToler = 10 * EPS_SMALL ;
ChainCurves chainC ;
chainC.Init( true, dToler, int( vIds.size())) ;
INTVECTOR::const_iterator Iter ;
for ( Iter = vIds.begin() ; Iter != vIds.end() ; ++Iter) {
// recupero la curva e il suo riferimento
ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( *Iter)) ;
if ( pCrv == nullptr)
return GDB_ID_NULL ;
Frame3d frCrv ;
if ( ! pGeomDB->GetGlobFrame( *Iter, frCrv))
return GDB_ID_NULL ;
// recupero i dati della curva necessari al concatenamento e li assegno
Point3d ptStart, ptEnd ;
Vector3d vtStart, vtEnd ;
if ( ! pCrv->GetStartPoint( ptStart) || ! pCrv->GetStartDir( vtStart) ||
! pCrv->GetEndPoint( ptEnd) || ! pCrv->GetEndDir( vtEnd))
return GDB_ID_NULL ;
ptStart.LocToLoc( frCrv, frDest) ;
vtStart.LocToLoc( frCrv, frDest) ;
ptEnd.LocToLoc( frCrv, frDest) ;
vtEnd.LocToLoc( frCrv, frDest) ;
if ( ! chainC.AddCurve( *Iter, ptStart, vtStart, ptEnd, vtEnd))
return GDB_ID_NULL ;
}
// recupero i percorsi concatenati
int nFirstId = GDB_ID_NULL ;
Point3d ptNearStart( ptNear) ;
INTVECTOR vId2s ;
while ( chainC.GetChainFromNear( ptNearStart, 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 ;
double dThick = 0 ;
// recupero le curve semplici e le inserisco nella curva composita
INTVECTOR::iterator Iter ;
for ( Iter = vId2s.begin() ; Iter != vId2s.end() ; ++Iter) {
int nId = abs( *Iter) ;
bool bInvert = ( *Iter < 0) ;
// recupero la curva e il suo riferimento
ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCrv == nullptr)
return GDB_ID_NULL ;
Frame3d frCrv ;
if ( ! pGeomDB->GetGlobFrame( nId, frCrv))
return GDB_ID_NULL ;
// copio la curva
PtrOwner<ICurve> pCopCrv( pCrv->Clone()) ;
if ( IsNull( pCopCrv))
return GDB_ID_NULL ;
// se necessario, la inverto
if ( bInvert)
pCopCrv->Invert() ;
// la sistemo per i riferimenti
pCopCrv->LocToLoc( frCrv, frDest) ;
// recupero eventuali estrusione (già nel riferimento destinazione) e spessore
if ( pCopCrv->GetExtrusion( vtExtr)) {
bExtr = true ;
double dTemp ;
if ( pCopCrv->GetThickness( dTemp) && fabs( dTemp) > fabs( dThick))
dThick = dTemp ;
}
// la aggiungo alla curva composta
if ( ! pCrvCompo->AddCurve( ::Release( pCopCrv), true, dToler))
return GDB_ID_NULL ;
}
// 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) ;
}
// aggiorno il nuovo punto vicino
pCrvCompo->GetEndPoint( ptNearStart) ;
// inserisco la curva composita nel gruppo destinazione
int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, ::Release( pCrvCompo)) ;
if ( nNewId == GDB_ID_NULL)
return GDB_ID_NULL ;
if ( nFirstId == GDB_ID_NULL)
nFirstId = nNewId ;
}
// se richiesto, cancello le curve originali
if ( bErase) {
for ( Iter = vIds.begin() ; Iter != vIds.end() ; ++Iter) {
if ( ! pGeomDB->Erase( *Iter))
return GDB_ID_NULL ;
}
}
// 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 = "EgtCurveCompoByChain(" + ToString( nParentId) + ",{" +
sIds + "},{" +
ToString( Point3d( ptNear)) + "}," +
( bErase ? "true" : "false") + ")" +
" -- Id=" + ToString( nFirstId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della prima nuova entità
return nFirstId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoFromPoints( int nParentId, int nP, const double ptPs[])
{
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) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoFromPoints( int nParentId, const PolyLine& PL)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo la curva composita
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
if ( IsNull( pCrvCompo))
return GDB_ID_NULL ;
// inserisco i segmenti che uniscono i punti
if ( ! pCrvCompo->FromPolyLine( PL))
return GDB_ID_NULL ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvCompo)))
return GDB_ID_NULL ;
// inserisco la curva composita nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoFromPointBulges( int nParentId, int nPB, const double ptPBs[])
{
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) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoFromPointBulges( int nParentId, const PolyArc& PA)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo la curva composita
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
if ( IsNull( pCrvCompo))
return GDB_ID_NULL ;
// inserisco i segmenti e gli archi che uniscono i punti
if ( ! pCrvCompo->FromPolyArc( PA))
return GDB_ID_NULL ;
// assegno il versore estrusione
if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvCompo)))
return GDB_ID_NULL ;
// inserisco la curva composita nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateCurveCompoByApprox( int nParentId, int nSouId, BOOL bArcsVsLines, double dLinTol)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero il riferimento di inserimento
Frame3d frEnt ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frEnt))
return GDB_ID_NULL ;
// eseguo l'approssimazione
PtrOwner<ICurveComposite> pCC( CreateCurveComposite()) ;
if ( IsNull( pCC))
return false ;
if ( ! bArcsVsLines) { // con linee
PolyLine PL ;
if ( ! GetPolyLineFromCurve( nSouId, frEnt, dLinTol, PL) ||
! pCC->FromPolyLine( PL))
return false ;
}
else { // con bi-archi
PolyArc PA ;
if ( ! GetPolyArcFromCurve( nSouId, frEnt, dLinTol, PA) ||
! pCC->FromPolyArc( PA))
return false ;
}
// inserisco la curva composita nel DB
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCC)) ;
}
//-------------------------------------------------------------------------------
int
__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 ;
// 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 = 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, 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)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
__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()) ;
bOk = bOk && ! IsNull( pCrvCompo) ;
// setto la curva
bOk = bOk && pCrvCompo->PolygonSide( nNumSides, ptIniL, ptFinL, vtNL) ;
// assegno il versore estrusione
bOk = bOk && pCrvCompo->SetExtrusion( vtExtrL) ;
// inserisco la curva nel DB
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 ;
}
//-------------------------------------------------------------------------------
bool
__stdcall SetExtrusionFromGridVersZ( IGeomDB* pGeomDB, int nParentId, ICurve* pCurve)
{
// verifiche sui parametri
if ( pGeomDB == nullptr || pCurve == nullptr)
return false ;
// assegno il versore estrusione a partire dal versore Z della griglia corrente
Vector3d vtExtr = pGeomDB->GetGridFrame().VersZ() ;
Frame3d frEnt ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frEnt))
return false ;
vtExtr.ToLoc( frEnt) ;
return pCurve->SetExtrusion( vtExtr) ;
}
//----------------------------------------------------------------------------
bool
__stdcall GetPolyLineFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyLine& PL)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCrv == nullptr)
return false ;
// recupero il riferimento della curva
Frame3d frCrv ;
if ( ! pGeomDB->GetGlobFrame( nId, frCrv))
return false ;
// calcolo la polilinea che approssima la curva
const double ANG_TOL_STD_DEG = 15 ;
// se i riferimenti sono uguali
if ( AreSameFrame( frCrv, frDest)) {
// ricavo l'approssimazione
if ( ! pCrv->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL))
return false ;
}
// altrimenti devo prima trasformare la curva
else {
// creo una copia della curva (da buttare alla fine)
PtrOwner<ICurve> pModCrv( pCrv->Clone()) ;
if ( IsNull( pModCrv))
return false ;
// eseguo la trasformazione
pModCrv->LocToLoc( frCrv, frDest) ;
// ricavo l'approssimazione
if ( ! pModCrv->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL))
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
__stdcall GetPolyArcFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyArc& PA)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCrv == nullptr)
return false ;
// recupero il riferimento della curva
Frame3d frCrv ;
if ( ! pGeomDB->GetGlobFrame( nId, frCrv))
return false ;
// calcolo la polilinea che approssima la curva
const double ANG_TOL_STD_DEG = 15 ;
// se i riferimenti sono uguali
if ( AreSameFrame( frCrv, frDest)) {
// ricavo l'approssimazione
if ( ! pCrv->ApproxWithArcs( dLinTol, ANG_TOL_STD_DEG, PA))
return false ;
}
// altrimenti devo prima trasformare la curva
else {
// creo una copia della curva (da buttare alla fine)
PtrOwner<ICurve> pModCrv( pCrv->Clone()) ;
if ( IsNull( pModCrv))
return false ;
// eseguo la trasformazione
pModCrv->LocToLoc( frCrv, frDest) ;
// ricavo l'approssimazione
if ( ! pModCrv->ApproxWithArcs( dLinTol, ANG_TOL_STD_DEG, PA))
return false ;
}
return true ;
}