EgtInterface 1.6d1 :
- aggiunte funzioni API e lua per creazione solidi standard - aggiunta funzione API e lua per grezzo - modificata creazione superficie rigata per gestire caso punto con curva.
This commit is contained in:
+271
-11
@@ -19,14 +19,233 @@
|
||||
#include "GeoTools.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EInConst.h"
|
||||
#include "/EgtDev/Include/EGkStmStandard.h"
|
||||
#include "/EgtDev/Include/EGkStmFromCurves.h"
|
||||
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
|
||||
#include "/EgtDev/Include/EgkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EgkCurveLocal.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTmBox( int nParentId, const double ptIni[3], const double ptCross[3],
|
||||
const double ptDir[3], double dHeight, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
|
||||
return GDB_ID_NULL ;
|
||||
// porto in locale i punti, i versori e il versore estrusione
|
||||
Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ;
|
||||
Point3d ptCrossL = GetPointLocal( pGeomDB, ptCross, nRefType, frLoc) ;
|
||||
Point3d ptDirL = GetPointLocal( pGeomDB, ptDir, nRefType, frLoc) ;
|
||||
// ne ricavo un riferimento intrinseco
|
||||
Frame3d frBox ;
|
||||
bOk = bOk && frBox.Set( ptIniL, ptDirL, ptCrossL) ;
|
||||
// ricavo le dimensioni della base
|
||||
Point3d ptCrossI = ptCrossL ;
|
||||
ptCrossI.ToLoc( frBox) ;
|
||||
double dWidth = ptCrossI.x ;
|
||||
double dLen = ptCrossI.y ;
|
||||
// creo il box nel suo riferimento intrinseco
|
||||
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshBox( fabs( dWidth), dLen, dHeight)) ;
|
||||
bOk = bOk && ! IsNull( pSTM) ;
|
||||
// eventuale traslazione per larghezza negativa
|
||||
if ( dWidth < 0)
|
||||
pSTM->Translate( Vector3d( dWidth, 0, 0)) ;
|
||||
// porto il box nel riferimento locale
|
||||
bOk = bOk && pSTM->ToGlob( frBox) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfTmBox(" + ToString( nParentId) + ",{" +
|
||||
ToString( Point3d( ptIni)) + "},{" +
|
||||
ToString( Point3d( ptCross)) + "},{" +
|
||||
ToString( Point3d( ptDir)) + "}," +
|
||||
ToString( dHeight) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTmPyramid( int nParentId, const double ptIni[3], const double ptCross[3],
|
||||
const double ptDir[3], double dHeight, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
|
||||
return GDB_ID_NULL ;
|
||||
// porto in locale i punti, i versori e il versore estrusione
|
||||
Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ;
|
||||
Point3d ptCrossL = GetPointLocal( pGeomDB, ptCross, nRefType, frLoc) ;
|
||||
Point3d ptDirL = GetPointLocal( pGeomDB, ptDir, nRefType, frLoc) ;
|
||||
// ne ricavo un riferimento intrinseco
|
||||
Frame3d frBox ;
|
||||
bOk = bOk && frBox.Set( ptIniL, ptDirL, ptCrossL) ;
|
||||
// ricavo le dimensioni della base
|
||||
Point3d ptCrossI = ptCrossL ;
|
||||
ptCrossI.ToLoc( frBox) ;
|
||||
double dWidth = ptCrossI.x ;
|
||||
double dLen = ptCrossI.y ;
|
||||
// creo la piramide nel suo riferimento intrinseco
|
||||
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshPyramid( fabs( dWidth), dLen, dHeight)) ;
|
||||
bOk = bOk && ! IsNull( pSTM) ;
|
||||
// eventuale traslazione per larghezza negativa
|
||||
if ( dWidth < 0)
|
||||
pSTM->Translate( Vector3d( dWidth, 0, 0)) ;
|
||||
// porto la piramide nel riferimento locale
|
||||
bOk = bOk && pSTM->ToGlob( frBox) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfTmPyramid(" + ToString( nParentId) + ",{" +
|
||||
ToString( Point3d( ptIni)) + "},{" +
|
||||
ToString( Point3d( ptCross)) + "},{" +
|
||||
ToString( Point3d( ptDir)) + "}," +
|
||||
ToString( dHeight) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTmCylinder( int nParentId, const double ptOrig[3], const double vtN[3],
|
||||
double dRad, double dHeight, double dLinTol, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// porto in locale il punto e il versore
|
||||
Point3d ptOrigL = GetPointLocal( pGeomDB, ptOrig, nRefType, frLoc) ;
|
||||
Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ;
|
||||
// calcolo riferimento OCS a partire da questo punto e versore
|
||||
Frame3d frCyl ;
|
||||
bOk = bOk && frCyl.Set( ptOrigL, vtNL) ;
|
||||
// creo il cilindro nel suo riferimento intrinseco
|
||||
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshCylinder( dRad, dHeight, dLinTol)) ;
|
||||
bOk = bOk && ! IsNull( pSTM) ;
|
||||
// porto il cilindro nel riferimento locale
|
||||
bOk = bOk && pSTM->ToGlob( frCyl) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfTmCylinder(" + ToString( nParentId) + ",{" +
|
||||
ToString( Point3d( ptOrig)) + "},{" +
|
||||
ToString( Vector3d( vtN)) + "}," +
|
||||
ToString( dRad) + "," +
|
||||
ToString( dHeight) + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTmCone( int nParentId, const double ptOrig[3], const double vtN[3],
|
||||
double dRad, double dHeight, double dLinTol, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// porto in locale il punto e il versore
|
||||
Point3d ptOrigL = GetPointLocal( pGeomDB, ptOrig, nRefType, frLoc) ;
|
||||
Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ;
|
||||
// calcolo riferimento OCS a partire da questo punto e versore
|
||||
Frame3d frCyl ;
|
||||
bOk = bOk && frCyl.Set( ptOrigL, vtNL) ;
|
||||
// creo il cono nel suo riferimento intrinseco
|
||||
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshCone( dRad, dHeight, dLinTol)) ;
|
||||
bOk = bOk && ! IsNull( pSTM) ;
|
||||
// porto il cono nel riferimento locale
|
||||
bOk = bOk && pSTM->ToGlob( frCyl) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfTmCone(" + ToString( nParentId) + ",{" +
|
||||
ToString( Point3d( ptOrig)) + "},{" +
|
||||
ToString( Vector3d( vtN)) + "}," +
|
||||
ToString( dRad) + "," +
|
||||
ToString( dHeight) + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTmSphere( int nParentId, const double ptOrig[3],
|
||||
double dRad, double dLinTol, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// porto in locale il punto
|
||||
Point3d ptOrigL = GetPointLocal( pGeomDB, ptOrig, nRefType, frLoc) ;
|
||||
// creo la sfera
|
||||
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshSphere( dRad, dLinTol)) ;
|
||||
bOk = bOk && ! IsNull( pSTM) ;
|
||||
// porto la sfera nella sua origine
|
||||
bOk = bOk && pSTM->Translate( ptOrig - ORIG) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfTmSphere(" + ToString( nParentId) + ",{" +
|
||||
ToString( Point3d( ptOrig)) + "}," +
|
||||
ToString( dRad) + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTmByFlatContour( int nParentId, int nCrvId, double dLinTol)
|
||||
@@ -320,7 +539,7 @@ __stdcall EgtCreateSurfTmByScrewing( int nParentId, int nCrvId,
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTmRuled( int nParentId, int nCrvId1, int nCrvId2, double dLinTol)
|
||||
__stdcall EgtCreateSurfTmRuled( int nParentId, int nPtOrCrvId1, int nPtOrCrvId2, double dLinTol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
@@ -328,22 +547,63 @@ __stdcall EgtCreateSurfTmRuled( int nParentId, int nCrvId1, int nCrvId2, double
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// recupero la prima curva in locale
|
||||
CurveLocal CrvLoc1( pGeomDB, nCrvId1, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc1.Get() != nullptr) ;
|
||||
// recupero la seconda curva in locale
|
||||
CurveLocal CrvLoc2( pGeomDB, nCrvId2, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc2.Get() != nullptr) ;
|
||||
// calcolo la superficie
|
||||
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshRuled( CrvLoc1.Get(), CrvLoc2.Get(), dLinTol) : nullptr) ;
|
||||
// creo la superficie trimesh
|
||||
ISurfTriMesh* pSTM = nullptr ;
|
||||
// se la prima entità è un punto e la seconda una curva
|
||||
if ( pGeomDB->GetGeoType( nPtOrCrvId1) == GEO_PNT3D &&
|
||||
( pGeomDB->GetGeoType( nPtOrCrvId2) & GEO_CURVE) != 0) {
|
||||
// recupero il punto in locale
|
||||
// recupero riferimento del punto
|
||||
Frame3d frPnt ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nPtOrCrvId1, frPnt) ;
|
||||
// porto il punto in locale
|
||||
Point3d ptP = GetGeoPoint3d( pGeomDB->GetGeoObj( nPtOrCrvId1))->GetPoint() ;
|
||||
bOk = bOk && ptP.LocToLoc( frPnt, frLoc) ;
|
||||
// recupero la curva in locale
|
||||
CurveLocal CrvLoc( pGeomDB, nPtOrCrvId2, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
|
||||
// calcolo la superficie
|
||||
pSTM = ( bOk ? GetSurfTriMeshRuled( ptP, CrvLoc.Get(), dLinTol) : nullptr) ;
|
||||
}
|
||||
// se la prima entità è una curva e la seconda un punto
|
||||
else if ( ( pGeomDB->GetGeoType( nPtOrCrvId1) & GEO_CURVE) != 0 &&
|
||||
pGeomDB->GetGeoType( nPtOrCrvId2) == GEO_PNT3D) {
|
||||
// recupero la curva in locale
|
||||
CurveLocal CrvLoc( pGeomDB, nPtOrCrvId1, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
|
||||
// recupero il punto in locale
|
||||
// recupero riferimento del punto
|
||||
Frame3d frPnt ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nPtOrCrvId2, frPnt) ;
|
||||
// porto il punto in locale
|
||||
Point3d ptP = GetGeoPoint3d( pGeomDB->GetGeoObj( nPtOrCrvId2))->GetPoint() ;
|
||||
bOk = bOk && ptP.LocToLoc( frPnt, frLoc) ;
|
||||
// calcolo la superficie
|
||||
pSTM = ( bOk ? GetSurfTriMeshRuled( ptP, CrvLoc.Get(), dLinTol) : nullptr) ;
|
||||
}
|
||||
// se entrambe curve
|
||||
else if ( ( pGeomDB->GetGeoType( nPtOrCrvId1) & GEO_CURVE) != 0 &&
|
||||
( pGeomDB->GetGeoType( nPtOrCrvId2) & GEO_CURVE) != 0) {
|
||||
// recupero la prima curva in locale
|
||||
CurveLocal CrvLoc1( pGeomDB, nPtOrCrvId1, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc1.Get() != nullptr) ;
|
||||
// recupero la seconda curva in locale
|
||||
CurveLocal CrvLoc2( pGeomDB, nPtOrCrvId2, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc2.Get() != nullptr) ;
|
||||
// calcolo la superficie
|
||||
pSTM = ( bOk ? GetSurfTriMeshRuled( CrvLoc1.Get(), CrvLoc2.Get(), dLinTol) : nullptr) ;
|
||||
}
|
||||
// altrimenti errore
|
||||
else
|
||||
bOk = false ;
|
||||
// inserisco la superficie trimesh nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ;
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfTmRuled(" + ToString( nParentId) + "," +
|
||||
ToString( nCrvId1) + "," +
|
||||
ToString( nCrvId2) + "," +
|
||||
ToString( nPtOrCrvId1) + "," +
|
||||
ToString( nPtOrCrvId2) + "," +
|
||||
ToString( dLinTol) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
|
||||
Reference in New Issue
Block a user