339777e202
- aggiunta EgtTrimExtendCurveByLen - aggiunta EgtOffsetCurve - aggiunte EgtCurveLength e EgtCurveLengthAtPoint - aggiunta EgtGetPointFromSelect.
757 lines
22 KiB
C++
757 lines
22 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2014
|
|
//----------------------------------------------------------------------------
|
|
// File : API_GeoSnap.cpp Data : 02.10.14 Versione : 1.5i5
|
|
// Contenuto : Funzioni di snap ad oggetti del DB geometrico per API.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 02.10.14 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "API.h"
|
|
#include "API_Macro.h"
|
|
#include "/EgtDev/Include/EInAPI.h"
|
|
#include "/EgtDev/Include/EgkGeoPoint3d.h"
|
|
#include "/EgtDev/Include/EgkGeoVector3d.h"
|
|
#include "/EgtDev/Include/EgkCurve.h"
|
|
#include "/EgtDev/Include/EgkCurveArc.h"
|
|
#include "/EgtDev/Include/EgkExtText.h"
|
|
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
|
#include "/EgtDev/Include/EgkIntersCurveCurve.h"
|
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtStartPoint( int nId, double ptP[3])
|
|
{
|
|
// recupero il punto
|
|
Point3d ptStart ;
|
|
if ( ! EgtStartPoint( nId, ptStart))
|
|
return FALSE ;
|
|
// ritorno il punto
|
|
VEC_FROM_3D( ptP, ptStart)
|
|
return TRUE ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtStartPoint( int nId, Point3d& ptP)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// se non è entità geometrica
|
|
const IGeoObj* pGObj ;
|
|
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
|
return false ;
|
|
// se punto
|
|
if ( pGObj->GetType() == GEO_PNT3D) {
|
|
// recupero il geo-punto
|
|
const IGeoPoint3d* pGP = GetGeoPoint3d( pGObj) ;
|
|
// assegno il punto
|
|
ptP = pGP->GetPoint() ;
|
|
return true ;
|
|
}
|
|
// se vettore
|
|
else if ( pGObj->GetType() == GEO_VECT3D) {
|
|
// recupero il geo-vettore
|
|
const IGeoVector3d* pGV = GetGeoVector3d( pGObj) ;
|
|
// assegno il punto
|
|
ptP = pGV->GetBase() ;
|
|
return true ;
|
|
}
|
|
// se frame
|
|
else if ( pGObj->GetType() == GEO_FRAME3D) {
|
|
// recupero il frame
|
|
const IGeoFrame3d* pGF = GetGeoFrame3d( pGObj) ;
|
|
// assegno il punto
|
|
ptP = pGF->GetFrame().Orig() ;
|
|
return true ;
|
|
}
|
|
// se curva
|
|
else if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
|
// recupero la curva
|
|
const ICurve* pCrv = GetCurve( pGObj) ;
|
|
// assegno il punto
|
|
return pCrv->GetStartPoint( ptP) ;
|
|
}
|
|
// se testo
|
|
else if ( pGObj->GetType() == EXT_TEXT) {
|
|
// recupero il testo
|
|
const IExtText* pTxt = GetExtText( pGObj) ;
|
|
// assegno il punto
|
|
return pTxt->GetStartPoint( ptP) ;
|
|
}
|
|
return false ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtEndPoint( int nId, double ptP[3])
|
|
{
|
|
// recupero il punto
|
|
Point3d ptEnd ;
|
|
if ( ! EgtEndPoint( nId, ptEnd))
|
|
return FALSE ;
|
|
// ritorno il punto
|
|
VEC_FROM_3D( ptP, ptEnd)
|
|
return TRUE ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtEndPoint( int nId, Point3d& ptP)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// se non è entità geometrica
|
|
const IGeoObj* pGObj ;
|
|
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
|
return false ;
|
|
// se curva
|
|
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
|
// recupero la curva
|
|
const ICurve* pCrv = GetCurve( pGObj) ;
|
|
return pCrv->GetEndPoint( ptP) ;
|
|
}
|
|
// se testo
|
|
else if ( pGObj->GetType() == EXT_TEXT) {
|
|
// recupero il testo
|
|
const IExtText* pTxt = GetExtText( pGObj) ;
|
|
return pTxt->GetEndPoint( ptP) ;
|
|
}
|
|
return false ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtMidPoint( int nId, double ptP[3])
|
|
{
|
|
// recupero il punto
|
|
Point3d ptMid ;
|
|
if ( ! EgtMidPoint( nId, ptMid))
|
|
return FALSE ;
|
|
// ritorno il punto
|
|
VEC_FROM_3D( ptP, ptMid)
|
|
return TRUE ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtMidPoint( int nId, Point3d& ptP)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// se non è entità geometrica
|
|
const IGeoObj* pGObj ;
|
|
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
|
return false ;
|
|
// se curva
|
|
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
|
// recupero la curva
|
|
const ICurve* pCrv = GetCurve( pGObj) ;
|
|
// assegno il punto
|
|
return pCrv->GetMidPoint( ptP) ;
|
|
}
|
|
// se testo
|
|
else if ( pGObj->GetType() == EXT_TEXT) {
|
|
// recupero il testo
|
|
const IExtText* pTxt = GetExtText( pGObj) ;
|
|
// assegno il punto
|
|
return pTxt->GetMidPoint( ptP) ;
|
|
}
|
|
return false ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtCenterPoint( int nId, double ptP[3])
|
|
{
|
|
// recupero il punto
|
|
Point3d ptCent ;
|
|
if ( ! EgtCenterPoint( nId, ptCent))
|
|
return FALSE ;
|
|
// ritorno il punto
|
|
VEC_FROM_3D( ptP, ptCent)
|
|
return TRUE ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtCenterPoint( int nId, Point3d& ptP)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// se non è entità geometrica
|
|
const IGeoObj* pGObj ;
|
|
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
|
return false ;
|
|
// se curva
|
|
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
|
// recupero la curva
|
|
const ICurve* pCrv = GetCurve( pGObj) ;
|
|
// assegno il punto
|
|
return pCrv->GetCenterPoint( ptP) ;
|
|
}
|
|
// se testo
|
|
else if ( pGObj->GetType() == EXT_TEXT) {
|
|
// recupero il testo
|
|
const IExtText* pTxt = GetExtText( pGObj) ;
|
|
// assegno il punto
|
|
return pTxt->GetCenterPoint( ptP) ;
|
|
}
|
|
return false ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtAtParamPoint( int nId, double dU, double ptP[3])
|
|
{
|
|
// recupero il punto
|
|
Point3d ptAtPar ;
|
|
if ( ! EgtAtParamPoint( nId, dU, ptAtPar))
|
|
return FALSE ;
|
|
// ritorno il punto
|
|
VEC_FROM_3D( ptP, ptAtPar)
|
|
return TRUE ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtAtParamPoint( int nId, double dU, Point3d& ptP)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// se non è entità geometrica
|
|
const IGeoObj* pGObj ;
|
|
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
|
return false ;
|
|
// se curva
|
|
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
|
// recupero la curva
|
|
const ICurve* pCrv = GetCurve( pGObj) ;
|
|
return pCrv->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP) ;
|
|
}
|
|
return false ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtIntersectionPoint( int nId1, int nId2, const double ptNear[3], double ptP[3])
|
|
{
|
|
// recupero il punto
|
|
Point3d ptInt ;
|
|
if ( ! EgtIntersectionPoint( nId1, nId2, ptNear, ptInt))
|
|
return FALSE ;
|
|
// ritorno il punto
|
|
VEC_FROM_3D( ptP, ptInt)
|
|
return TRUE ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtIntersectionPoint( int nId1, int nId2, const Point3d& ptNear, Point3d& ptP)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// devono essere entità geometriche
|
|
const IGeoObj* pGObj1 ;
|
|
if ( ( pGObj1 = pGeomDB->GetGeoObj( nId1)) == nullptr)
|
|
return false ;
|
|
const IGeoObj* pGObj2 ;
|
|
if ( ( pGObj2 = pGeomDB->GetGeoObj( nId2)) == nullptr)
|
|
return false ;
|
|
// se curve
|
|
if ( ( pGObj1->GetType() & GEO_CURVE) != 0 && ( pGObj2->GetType() & GEO_CURVE) != 0) {
|
|
// recupero le curve
|
|
const ICurve* pCrv1 = GetCurve( pGObj1) ;
|
|
const ICurve* pCrv2 = GetCurve( pGObj2) ;
|
|
// recupero i riferimenti in cui sono immerse
|
|
Frame3d frEnt1 ;
|
|
if ( ! pGeomDB->GetGlobFrame( nId1, frEnt1))
|
|
return false ;
|
|
Frame3d frEnt2 ;
|
|
if ( ! pGeomDB->GetGlobFrame( nId2, frEnt2))
|
|
return false ;
|
|
// se il riferimento della seconda curva è diverso da quello della prima entità, devo trasformarla
|
|
PtrOwner<ICurve> crvTrans( nullptr) ;
|
|
if ( ! AreSameFrame( frEnt1, frEnt2)) {
|
|
crvTrans.Set( pCrv2->Clone()) ;
|
|
if ( IsNull( crvTrans))
|
|
return false ;
|
|
crvTrans->LocToLoc( frEnt2, frEnt1) ;
|
|
pCrv2 = ::Get( crvTrans) ;
|
|
}
|
|
// porto il punto vicino nel riferimento della prima curva
|
|
Point3d ptNearLoc( ptNear) ;
|
|
ptNearLoc.ToLoc( frEnt1) ;
|
|
// calcolo il punto di intersezione sulla prima curva più vicino al punto di riferimento
|
|
IntersCurveCurve intCC( *pCrv1, *pCrv2, true) ;
|
|
return intCC.GetIntersPointNearTo( 0, ptNearLoc, ptP) ;
|
|
}
|
|
return false ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtStartVector( int nId, double vtV[3])
|
|
{
|
|
// recupero il vettore
|
|
Vector3d vtStart ;
|
|
if ( ! EgtStartVector( nId, vtStart))
|
|
return FALSE ;
|
|
// ritorno il vettore
|
|
VEC_FROM_3D( vtV, vtStart)
|
|
return TRUE ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtStartVector( int nId, Vector3d& vtV)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// se non è entità geometrica
|
|
const IGeoObj* pGObj ;
|
|
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
|
return false ;
|
|
// se vettore
|
|
if ( pGObj->GetType() == GEO_VECT3D) {
|
|
// recupero il geo-vettore
|
|
const IGeoVector3d* pGV = GetGeoVector3d( pGObj) ;
|
|
// assegno il vettore
|
|
vtV = pGV->GetVector() ;
|
|
return true ;
|
|
}
|
|
// se curva
|
|
else if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
|
// recupero la curva
|
|
const ICurve* pCrv = GetCurve( pGObj) ;
|
|
// assegno il vettore
|
|
return pCrv->GetStartDir( vtV) ;
|
|
}
|
|
// se testo
|
|
else if ( pGObj->GetType() == EXT_TEXT) {
|
|
// recupero il testo
|
|
const IExtText* pTxt = GetExtText( pGObj) ;
|
|
// assegno il vettore
|
|
vtV = pTxt->GetDirVersor() ;
|
|
return true ;
|
|
}
|
|
return false ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtEndVector( int nId, double vtV[3])
|
|
{
|
|
// recupero il vettore
|
|
Vector3d vtEnd ;
|
|
if ( ! EgtEndVector( nId, vtEnd))
|
|
return FALSE ;
|
|
// ritorno il vettore
|
|
VEC_FROM_3D( vtV, vtEnd)
|
|
return TRUE ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtEndVector( int nId, Vector3d& vtV)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// se non è entità geometrica
|
|
const IGeoObj* pGObj ;
|
|
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
|
return false ;
|
|
// se curva
|
|
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
|
// recupero la curva
|
|
const ICurve* pCrv = GetCurve( pGObj) ;
|
|
// assegno il vettore
|
|
return pCrv->GetEndDir( vtV) ;
|
|
}
|
|
return false ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtMidVector( int nId, double vtV[3])
|
|
{
|
|
// recupero il vettore
|
|
Vector3d vtMid ;
|
|
if ( ! EgtMidVector( nId, vtMid))
|
|
return FALSE ;
|
|
// ritorno il vettore
|
|
VEC_FROM_3D( vtV, vtMid)
|
|
return TRUE ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtMidVector( int nId, Vector3d& vtV)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// se non è entità geometrica
|
|
const IGeoObj* pGObj ;
|
|
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
|
return false ;
|
|
// se curva
|
|
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
|
// recupero la curva
|
|
const ICurve* pCrv = GetCurve( pGObj) ;
|
|
// assegno il vettore
|
|
return pCrv->GetMidDir( vtV) ;
|
|
}
|
|
return false ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtAtParamVector( int nId, double dU, int nSide, double vtV[3])
|
|
{
|
|
// recupero il vettore
|
|
Vector3d vtAtPar ;
|
|
if ( ! EgtAtParamVector( nId, dU, nSide, vtAtPar))
|
|
return FALSE ;
|
|
// ritorno il vettore
|
|
VEC_FROM_3D( vtV, vtAtPar)
|
|
return TRUE ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtAtParamVector( int nId, double dU, int nSide, Vector3d& vtV)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// se non è entità geometrica
|
|
const IGeoObj* pGObj ;
|
|
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
|
return false ;
|
|
// se curva
|
|
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
|
// recupero la curva
|
|
const ICurve* pCrv = GetCurve( pGObj) ;
|
|
// assegno il lato di approccio
|
|
ICurve::Side nSide = ICurve::FROM_MINUS ;
|
|
if ( nSide >0)
|
|
nSide = ICurve::FROM_PLUS ;
|
|
// recupero la direzione
|
|
Point3d ptP ;
|
|
return pCrv->GetPointTang( dU, nSide, ptP, vtV) ;
|
|
}
|
|
return false ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtFrame( int nId, double ptOrig[3], double vtX[3], double vtY[3], double vtZ[3])
|
|
{
|
|
// recupero il frame
|
|
Frame3d frFrame ;
|
|
if ( ! EgtFrame( nId, frFrame))
|
|
return FALSE ;
|
|
// assegno l'origine
|
|
VEC_FROM_3D( ptOrig, frFrame.Orig())
|
|
// assegno il versore X
|
|
VEC_FROM_3D( vtX, frFrame.VersX())
|
|
// assegno il versore Y
|
|
VEC_FROM_3D( vtY, frFrame.VersY())
|
|
// assegno il versore Z
|
|
VEC_FROM_3D( vtZ, frFrame.VersZ())
|
|
return TRUE ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtFrame( int nId, Frame3d& frFrame)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// se gruppo
|
|
if ( pGeomDB->GetGroupFrame( nId, frFrame))
|
|
return true ;
|
|
// se geo frame
|
|
const IGeoObj* pGObj ;
|
|
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) != nullptr &&
|
|
pGObj->GetType() == GEO_FRAME3D) {
|
|
frFrame = GetGeoFrame3d( pGObj)->GetFrame() ;
|
|
return true ;
|
|
}
|
|
// altrimenti errore
|
|
return false ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtCurveLength( int nId, double* pdLen)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// verifico il parametro
|
|
if ( pdLen == nullptr)
|
|
return FALSE ;
|
|
// recupero la curva
|
|
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
|
if ( pCurve == nullptr)
|
|
return FALSE ;
|
|
// recupero la lunghezza
|
|
return ( pCurve->GetLength( *pdLen) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtCurveLengthAtPoint( int nId, double ptOn[3], double* pdLen)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// verifico il parametro
|
|
if ( pdLen == nullptr)
|
|
return FALSE ;
|
|
// recupero la curva
|
|
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
|
if ( pCurve == nullptr)
|
|
return FALSE ;
|
|
// determino la posizione parametrica del punto sulla curva (con tolleranza)
|
|
int nFlag ;
|
|
double dU ;
|
|
if ( ! DistPointCurve( ptOn, *pCurve).GetParamAtMinDistPoint( 0, dU, nFlag) || nFlag != MDPCI_NORMAL)
|
|
return FALSE ;
|
|
// recupero la lunghezza alla posizione parametrica
|
|
return ( pCurve->GetLengthAtParam( dU, *pdLen) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtCurveExtrusion( int nId, double vtExtr[3])
|
|
{
|
|
// recupero il vettore estrusione
|
|
Vector3d vtTmp ;
|
|
if ( ! EgtCurveExtrusion( nId, vtTmp))
|
|
return FALSE ;
|
|
// lo assegno
|
|
VEC_FROM_3D( vtExtr, vtTmp)
|
|
return TRUE ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtCurveExtrusion( int nId, Vector3d& vtExtr)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// recupero la curva
|
|
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
|
if ( pCurve == nullptr)
|
|
return false ;
|
|
// ne ricavo il vettore estrusione
|
|
return pCurve->GetExtrusion( vtExtr) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtCurveThickness( int nId, double* pdThick)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// verifico il parametro
|
|
if ( pdThick == nullptr)
|
|
return FALSE ;
|
|
// recupero la curva
|
|
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
|
if ( pCurve == nullptr)
|
|
return FALSE ;
|
|
// recupero lo spessore
|
|
return ( pCurve->GetThickness( *pdThick) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtCurveArcNormVersor( int nId, double vtNorm[3])
|
|
{
|
|
// recupero il vettore normale
|
|
Vector3d vtTmp ;
|
|
if ( ! EgtCurveArcNormVersor( nId, vtTmp))
|
|
return FALSE ;
|
|
// lo assegno
|
|
VEC_FROM_3D( vtNorm, vtTmp)
|
|
return TRUE ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtCurveArcNormVersor( int nId, Vector3d& vtNorm)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// recupero l'arco
|
|
ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ;
|
|
if ( pArc == nullptr)
|
|
return false ;
|
|
// recupero la normale
|
|
vtNorm = pArc->GetNormVersor() ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtExtTextNormVersor( int nId, double vtNorm[3])
|
|
{
|
|
// recupero il vettore normale
|
|
Vector3d vtTmp ;
|
|
if ( ! EgtExtTextNormVersor( nId, vtTmp))
|
|
return FALSE ;
|
|
// lo assegno
|
|
VEC_FROM_3D( vtNorm, vtTmp)
|
|
return TRUE ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtExtTextNormVersor( int nId, Vector3d& vtNorm)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// recupero il testo
|
|
const IExtText* pTxt = GetExtText( pGeomDB->GetGeoObj( nId)) ;
|
|
if ( pTxt == nullptr)
|
|
return false ;
|
|
// recupero la normale
|
|
vtNorm = pTxt->GetNormVersor() ;
|
|
return true ;
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
// Geo Transforms
|
|
//-------------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtPointToIdGlob( double ptP[3], int nId)
|
|
{
|
|
// trasformo il punto
|
|
Point3d ptTmp( ptP) ;
|
|
if ( ! EgtPointToIdGlob( ptTmp, nId))
|
|
return FALSE ;
|
|
// ritorno il punto
|
|
VEC_FROM_3D( ptP, ptTmp)
|
|
return TRUE ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtPointToIdGlob( Point3d& ptP, int nId)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// recupero il riferimento
|
|
// se gruppo -> il suo proprio espresso in globale
|
|
// se oggetto -> quello del gruppo cui appartiene in globale
|
|
Frame3d frRef ;
|
|
if ( ! pGeomDB->GetGroupGlobFrame( nId, frRef) &&
|
|
! pGeomDB->GetGlobFrame( nId, frRef))
|
|
return false ;
|
|
// eseguo la trasformazione
|
|
ptP.ToGlob( frRef) ;
|
|
return true ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtPointToIdLoc( double ptP[3], int nId)
|
|
{
|
|
// trasformo il punto
|
|
Point3d ptTmp( ptP) ;
|
|
if ( ! EgtPointToIdLoc( ptTmp, nId))
|
|
return FALSE ;
|
|
// ritorno il punto
|
|
VEC_FROM_3D( ptP, ptTmp)
|
|
return TRUE ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtPointToIdLoc( Point3d& ptP, int nId)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// recupero il riferimento
|
|
// se gruppo -> il suo proprio espresso in globale
|
|
// se oggetto -> quello del gruppo cui appartiene in globale
|
|
Frame3d frRef ;
|
|
if ( ! pGeomDB->GetGroupGlobFrame( nId, frRef) &&
|
|
! pGeomDB->GetGlobFrame( nId, frRef))
|
|
return false ;
|
|
// eseguo la trasformazione
|
|
ptP.ToLoc( frRef) ;
|
|
return true ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtVectorToIdGlob( double vtV[3], int nId)
|
|
{
|
|
// trasformo il vettore
|
|
Vector3d vtTmp( vtV) ;
|
|
if ( ! EgtVectorToIdGlob( vtTmp, nId))
|
|
return FALSE ;
|
|
// ritorno il punto
|
|
VEC_FROM_3D( vtV, vtTmp)
|
|
return TRUE ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtVectorToIdGlob( Vector3d& vtV, int nId)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// recupero il riferimento
|
|
// se gruppo -> il suo proprio espresso in globale
|
|
// se oggetto -> quello del gruppo cui appartiene in globale
|
|
Frame3d frRef ;
|
|
if ( ! pGeomDB->GetGroupGlobFrame( nId, frRef) &&
|
|
! pGeomDB->GetGlobFrame( nId, frRef))
|
|
return false ;
|
|
// eseguo la trasformazione
|
|
vtV.ToGlob( frRef) ;
|
|
return true ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtVectorToIdLoc( double vtV[3], int nId)
|
|
{
|
|
// trasformo il vettore
|
|
Vector3d vtTmp( vtV) ;
|
|
if ( ! EgtVectorToIdLoc( vtTmp, nId))
|
|
return FALSE ;
|
|
// ritorno il punto
|
|
VEC_FROM_3D( vtV, vtTmp)
|
|
return TRUE ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
bool
|
|
__stdcall EgtVectorToIdLoc( Vector3d& vtV, int nId)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// recupero il riferimento
|
|
// se gruppo -> il suo proprio espresso in globale
|
|
// se oggetto -> quello del gruppo cui appartiene in globale
|
|
Frame3d frRef ;
|
|
if ( ! pGeomDB->GetGroupGlobFrame( nId, frRef) &&
|
|
! pGeomDB->GetGlobFrame( nId, frRef))
|
|
return false ;
|
|
// eseguo la trasformazione
|
|
vtV.ToLoc( frRef) ;
|
|
return true ;
|
|
}
|