EgtInterface 1.6b6 :
- aggiornamenti vari - introdotto comando per merge (cucitura) di superfici - migliorata gestione oggetti selezionati in comandi.
This commit is contained in:
+213
-6
@@ -21,6 +21,8 @@
|
||||
#include "/EgtDev/Include/EgkCurve.h"
|
||||
#include "/EgtDev/Include/EgkCurveArc.h"
|
||||
#include "/EgtDev/Include/EgkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EgkSurf.h"
|
||||
#include "/EgtDev/Include/EgkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EgkExtText.h"
|
||||
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgkIntersCurveCurve.h"
|
||||
@@ -55,6 +57,34 @@ TrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP)
|
||||
return ptP.LocToLoc( frSou, frDest) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
InvTrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP)
|
||||
{
|
||||
// se non va trasformato, esco
|
||||
if ( nRefId == nId)
|
||||
return true ;
|
||||
// recupero il riferimento in cui va espresso il punto (quello dell'entità a cui va riferito)
|
||||
Frame3d frSou ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId, frSou))
|
||||
return false ;
|
||||
// se viene da globale, trasformo ed esco
|
||||
if ( nRefId == GDB_ID_ROOT)
|
||||
return ptP.ToLoc( frSou) ;
|
||||
// recupero il riferimento da cui proviene
|
||||
Frame3d frDest ;
|
||||
if ( nRefId == GDB_ID_GRID)
|
||||
frDest = pGeomDB->GetGridFrame() ;
|
||||
else {
|
||||
// nRefId può essere un gruppo o una entità
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) &&
|
||||
! pGeomDB->GetGlobFrame( nRefId, frDest))
|
||||
return false ;
|
||||
}
|
||||
// eseguo la trasformazione inversa
|
||||
return ptP.LocToLoc( frDest, frSou) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
TrasformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV)
|
||||
@@ -341,6 +371,14 @@ EgtCentroid( int nId, int nRefId, Point3d& ptP)
|
||||
if ( pCrv == nullptr || ! pCrv->GetCentroid( ptP))
|
||||
return false ;
|
||||
}
|
||||
// se superficie
|
||||
else if ( ( pGObj->GetType() & GEO_SURF) != 0) {
|
||||
// recupero la superficie
|
||||
const ISurf* pSrf = GetSurf( pGObj) ;
|
||||
// assegno il punto
|
||||
if ( pSrf == nullptr || ! pSrf->GetCentroid( ptP))
|
||||
return false ;
|
||||
}
|
||||
// se testo
|
||||
else if ( pGObj->GetType() == EXT_TEXT) {
|
||||
// recupero il testo
|
||||
@@ -414,12 +452,16 @@ EgtNearPoint( int nId, const Point3d& ptNear, int nRefId, Point3d& ptP)
|
||||
const IGeoObj* pGObj = pGeomDB->GetGeoObj( nId) ;
|
||||
if ( pGObj == nullptr)
|
||||
return false ;
|
||||
// porto il punto near nel riferimento dell'entità
|
||||
Point3d ptNearL = ptNear ;
|
||||
if ( ! InvTrasformPoint( pGeomDB, nId, nRefId, ptNearL))
|
||||
return false ;
|
||||
// se curva
|
||||
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGObj) ;
|
||||
// calcolo il punto della curva più vicino al punto di riferimento
|
||||
DistPointCurve dstPC( ptNear, *pCrv) ;
|
||||
DistPointCurve dstPC( ptNearL, *pCrv) ;
|
||||
int nFlag ;
|
||||
if ( ! dstPC.GetMinDistPoint( 0, ptP, nFlag))
|
||||
return false ;
|
||||
@@ -477,12 +519,13 @@ EgtIntersectionPoint( int nId1, int nId2, const Point3d& ptNear, int nRefId, Poi
|
||||
crvTrans->LocToLoc( frEnt2, frEnt1) ;
|
||||
pCrv2 = ::Get( crvTrans) ;
|
||||
}
|
||||
// porto il punto vicino nel riferimento della prima curva
|
||||
Point3d ptNearLoc( ptNear) ;
|
||||
ptNearLoc.ToLoc( frEnt1) ;
|
||||
// porto il punto Near nel riferimento della prima entità
|
||||
Point3d ptNearL = ptNear ;
|
||||
if ( ! InvTrasformPoint( pGeomDB, nId1, nRefId, ptNearL))
|
||||
return false ;
|
||||
// calcolo il punto di intersezione sulla prima curva più vicino al punto di riferimento
|
||||
IntersCurveCurve intCC( *pCrv1, *pCrv2, true) ;
|
||||
if ( ! intCC.GetIntersPointNearTo( 0, ptNearLoc, ptP))
|
||||
if ( ! intCC.GetIntersPointNearTo( 0, ptNearL, ptP))
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
@@ -880,7 +923,7 @@ EgtCurveArcNormVersor( int nId, int nRefId, Vector3d& vtNorm)
|
||||
BOOL
|
||||
__stdcall EgtCurveCompoCenter( int nId, int nSimpCrv, int nRefId, double ptCen[3])
|
||||
{
|
||||
// recupero il vettore normale
|
||||
// recupero il centro
|
||||
Point3d ptTmp ;
|
||||
if ( ! EgtCurveCompoCenter( nId, nSimpCrv, nRefId, ptTmp))
|
||||
return FALSE ;
|
||||
@@ -910,6 +953,170 @@ EgtCurveCompoCenter( int nId, int nSimpCrv, int nRefId, Point3d& ptCen)
|
||||
return TrasformPoint( pGeomDB, nId, nRefId, ptCen) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtSurfTmFacetNbr( int nId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, 0)
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return 0 ;
|
||||
// recupero il numero delle facce
|
||||
return pStm->GetFacetNum() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtSurfTmFacetFromTria( int nId, int nT)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, SVT_NULL)
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return SVT_NULL ;
|
||||
// recupero il numero della faccia da quello di un suo triangolo
|
||||
return pStm->GetFacetFromTria( nT) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSurfTmFacetNearestEndPoint( int nId, int nFacet, const double ptNear[3], int nRefId,
|
||||
double ptEnd[3], double vtNorm[3])
|
||||
{
|
||||
// recupero il punto e la normale
|
||||
Point3d ptTmp ;
|
||||
Vector3d vtN ;
|
||||
if ( ! EgtSurfTmFacetNearestEndPoint( nId, nFacet, ptNear, nRefId, ptTmp, vtN))
|
||||
return FALSE ;
|
||||
// li assegno
|
||||
VEC_FROM_3D( ptEnd, ptTmp)
|
||||
VEC_FROM_3D( vtNorm, vtN)
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtSurfTmFacetNearestEndPoint( int nId, int nFacet, const Point3d& ptNear, int nRefId, Point3d& ptEnd, Vector3d& vtN)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// porto il punto Near nel riferimento dell'entità
|
||||
Point3d ptNearL = ptNear ;
|
||||
if ( ! InvTrasformPoint( pGeomDB, nId, nRefId, ptNearL))
|
||||
return false ;
|
||||
// recupero il punto End più vicino della faccia
|
||||
if ( ! pStm->GetFacetNearestEndPoint( nFacet, ptNearL, ptEnd, vtN))
|
||||
return false ;
|
||||
// gestione trasformazioni ( eventuali)
|
||||
return TrasformPoint( pGeomDB, nId, nRefId, ptEnd) && TrasformVector( pGeomDB, nId, nRefId, vtN) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtSurfTmFacetNearestMidPoint( int nId, int nFacet, const Point3d& ptNear, int nRefId, Point3d& ptMid, Vector3d& vtN)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// porto il punto Near nel riferimento dell'entità
|
||||
Point3d ptNearL = ptNear ;
|
||||
if ( ! InvTrasformPoint( pGeomDB, nId, nRefId, ptNearL))
|
||||
return false ;
|
||||
// recupero il punto Mid più vicino della faccia
|
||||
if ( ! pStm->GetFacetNearestMidPoint( nFacet, ptNearL, ptMid, vtN))
|
||||
return false ;
|
||||
// gestione trasformazioni ( eventuali)
|
||||
return TrasformPoint( pGeomDB, nId, nRefId, ptMid) && TrasformVector( pGeomDB, nId, nRefId, vtN) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSurfTmFacetNearestMidPoint( int nId, int nFacet, const double ptNear[3], int nRefId,
|
||||
double ptMid[3], double vtNorm[3])
|
||||
{
|
||||
// recupero il punto e la normale
|
||||
Point3d ptTmp ;
|
||||
Vector3d vtN ;
|
||||
if ( ! EgtSurfTmFacetNearestMidPoint( nId, nFacet, ptNear, nRefId, ptTmp, vtN))
|
||||
return FALSE ;
|
||||
// li assegno
|
||||
VEC_FROM_3D( ptMid, ptTmp)
|
||||
VEC_FROM_3D( vtNorm, vtN)
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSurfTmFacetCenter( int nId, int nFacet, int nRefId, double ptCen[3], double vtNorm[3])
|
||||
{
|
||||
// recupero il centro e la normale
|
||||
Point3d ptTmp ;
|
||||
Vector3d vtN ;
|
||||
if ( ! EgtSurfTmFacetCenter( nId, nFacet, nRefId, ptTmp, vtN))
|
||||
return FALSE ;
|
||||
// li assegno
|
||||
VEC_FROM_3D( ptCen, ptTmp)
|
||||
VEC_FROM_3D( vtNorm, vtN)
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtSurfTmFacetCenter( int nId, int nFacet, int nRefId, Point3d& ptCen, Vector3d& vtN)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// recupero il centro della faccia
|
||||
if ( ! pStm->GetFacetCenter( nFacet, ptCen, vtN))
|
||||
return false ;
|
||||
// gestione trasformazioni ( eventuali)
|
||||
return TrasformPoint( pGeomDB, nId, nRefId, ptCen) && TrasformVector( pGeomDB, nId, nRefId, vtN) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSurfTmFacetNormVersor( int nId, int nFacet, int nRefId, double vtNorm[3])
|
||||
{
|
||||
// recupero il vettore normale
|
||||
Vector3d vtTmp ;
|
||||
if ( ! EgtSurfTmFacetNormVersor( nId, nFacet, nRefId, vtTmp))
|
||||
return FALSE ;
|
||||
// lo assegno
|
||||
VEC_FROM_3D( vtNorm, vtTmp)
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtSurfTmFacetNormVersor( int nId, int nFacet, int nRefId, Vector3d& vtNorm)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// recupero il centro della faccia
|
||||
if ( ! pStm->GetFacetNormal( nFacet, vtNorm))
|
||||
return false ;
|
||||
// gestione trasformazione ( eventuale)
|
||||
return TrasformVector( pGeomDB, nId, nRefId, vtNorm) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtExtTextNormVersor( int nId, int nRefId, double vtNorm[3])
|
||||
|
||||
Reference in New Issue
Block a user