EgtInterface 1.6b1 :
- gestione estrusione con facce di chiusura - gestione rivoluzione con facce di chiusura - razionalizzazione passaggio a locale.
This commit is contained in:
+84
-83
@@ -16,11 +16,12 @@
|
||||
#include "API.h"
|
||||
#include "API_Macro.h"
|
||||
#include "AuxTools.h"
|
||||
#include "GeoTools.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EInConst.h"
|
||||
#include "/EgtDev/Include/EgkCurve.h"
|
||||
#include "/EgtDev/Include/EgkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkStmFromCurves.h"
|
||||
#include "/EgtDev/Include/EgkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgkCurveLocal.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
@@ -32,20 +33,16 @@ __stdcall EgtCreateSurfTriMeshByContour( int nParentId, int nCrvId, double dLinT
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frDest ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest))
|
||||
bOk = false ;
|
||||
// calcolo la polilinea che approssima la curva
|
||||
PolyLine PL ;
|
||||
if ( ! GetPolyLineFromCurve( nCrvId, frDest, dLinTol, PL))
|
||||
bOk = false ;
|
||||
// creo e setto la superficie trimesh
|
||||
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
|
||||
if ( IsNull( pSTM) || ! pSTM->CreateByFlatContour( PL))
|
||||
bOk = false ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// recupero la curva in locale
|
||||
CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
|
||||
// calcolo la superficie
|
||||
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByContour( *CrvLoc.Get(), dLinTol) : nullptr) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ;
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
@@ -62,36 +59,30 @@ __stdcall EgtCreateSurfTriMeshByContour( int nParentId, int nCrvId, double dLinT
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTriMeshByExtrusion( int nParentId, int nCrvId, const double vtExtr[3],
|
||||
double dLinTol, int nRefType)
|
||||
BOOL bCapEnds, double dLinTol, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// porto in locale il vettore estrusione
|
||||
Vector3d vtExtrL( vtExtr) ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
if ( nRefType == RTY_GLOB) {
|
||||
vtExtrL.ToLoc( frLoc) ;
|
||||
}
|
||||
else if ( nRefType == RTY_GRID) {
|
||||
vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
|
||||
}
|
||||
// calcolo la polilinea che approssima la curva
|
||||
PolyLine PL ;
|
||||
bOk = bOk && GetPolyLineFromCurve( nCrvId, frLoc, dLinTol, PL) ;
|
||||
// creo e setto la superficie trimesh
|
||||
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
|
||||
bOk = bOk && ! IsNull( pSTM) ;
|
||||
bOk = bOk && pSTM->CreateByExtrusion( PL, vtExtrL) ;
|
||||
// recupero la curva in locale
|
||||
CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
|
||||
// porto in locale il vettore estrusione
|
||||
Vector3d vtExtrL = GetVectorLocal( pGeomDB, vtExtr, nRefType, frLoc) ;
|
||||
// calcolo la superficie
|
||||
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByExtrusion( *CrvLoc.Get(), vtExtrL, ( bCapEnds != FALSE), dLinTol) : nullptr) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
|
||||
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 = "EgtSurfTmByExtrusion(" + ToString( nParentId) + "," +
|
||||
ToString( nCrvId) + ",{" +
|
||||
ToString( Vector3d( vtExtr)) + "}," +
|
||||
( bCapEnds ? "true" : "false") + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
@@ -101,6 +92,45 @@ __stdcall EgtCreateSurfTriMeshByExtrusion( int nParentId, int nCrvId, const doub
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTriMeshByRevolve( int nParentId, int nCrvId,
|
||||
const double ptAx[3], const double vtAx[3],
|
||||
BOOL bCapEnds, 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) ;
|
||||
// recupero la curva in locale
|
||||
CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
|
||||
// porto in locale punto e vettore asse
|
||||
Point3d ptAxL = GetPointLocal( pGeomDB, ptAx, nRefType, frLoc) ;
|
||||
Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ;
|
||||
// calcolo la superficie
|
||||
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByRevolve( *CrvLoc.Get(), ptAxL, vtAxL, ( bCapEnds != FALSE), dLinTol) : nullptr) ;
|
||||
// inserisco la superficie 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 = "EgtSurfTmByRevolve(" + ToString( nParentId) + "," +
|
||||
ToString( nCrvId) + ",{" +
|
||||
ToString( Point3d( ptAx)) + "},{" +
|
||||
ToString( Vector3d( vtAx)) + "}," +
|
||||
( bCapEnds ? "true" : "false") + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTriMeshByScrewing( int nParentId, int nCrvId,
|
||||
@@ -110,43 +140,19 @@ __stdcall EgtCreateSurfTriMeshByScrewing( int nParentId, int nCrvId,
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// porto in locale punto e vettore asse
|
||||
Point3d ptAxL( ptAx) ;
|
||||
Vector3d vtAxL( vtAx) ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
if ( nRefType == RTY_GLOB) {
|
||||
ptAxL.ToLoc( frLoc) ;
|
||||
vtAxL.ToLoc( frLoc) ;
|
||||
}
|
||||
else if ( nRefType == RTY_GRID) {
|
||||
ptAxL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
|
||||
vtAxL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
|
||||
}
|
||||
// limite minimo su tolleranza
|
||||
dLinTol = max( dLinTol, EPS_SMALL) ;
|
||||
// calcolo la polilinea che approssima la curva
|
||||
PolyLine PL ;
|
||||
bOk = bOk && GetPolyLineFromCurve( nCrvId, frLoc, dLinTol, PL) ;
|
||||
// calcolo lo step di rotazione
|
||||
double dMaxRad = 0 ;
|
||||
bOk = bOk && PL.GetMaxDistanceFromLine( dMaxRad, ptAxL, vtAxL, 1, false) ;
|
||||
if ( dMaxRad < EPS_SMALL) {
|
||||
bOk = false ;
|
||||
dMaxRad = EPS_SMALL ;
|
||||
}
|
||||
double dStepRotDeg = sqrt( 8 * dLinTol / dMaxRad) * RADTODEG ;
|
||||
// se superficie rototraslata, necessari limiti sulla lunghezza dei segmenti
|
||||
if ( fabs( dAngRotDeg) > EPS_ANG_SMALL && fabs( dMove) > EPS_SMALL){
|
||||
double dLenMax = 2 * fabs( dMove * dStepRotDeg / dAngRotDeg) ;
|
||||
bOk = bOk && PL.AdjustForMaxSegmentLen( dLenMax) ;
|
||||
}
|
||||
// creo e setto la superficie trimesh
|
||||
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
|
||||
bOk = bOk && ! IsNull( pSTM) ;
|
||||
bOk = bOk && pSTM->CreateByScrewing( PL, ptAxL, vtAxL, dAngRotDeg, dStepRotDeg, dMove) ;
|
||||
// recupero la curva in locale
|
||||
CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
|
||||
// porto in locale punto e vettore asse
|
||||
Point3d ptAxL = GetPointLocal( pGeomDB, ptAx, nRefType, frLoc) ;
|
||||
Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ;
|
||||
// calcolo la superficie
|
||||
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByScrewing( *CrvLoc.Get(), ptAxL, vtAxL, dAngRotDeg, dMove, dLinTol) : nullptr) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ;
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
@@ -172,24 +178,19 @@ __stdcall EgtCreateSurfTriMeshRuled( int nParentId, int nCrvId1, int nCrvId2, do
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frDest ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest))
|
||||
bOk = false ;
|
||||
// calcolo la polilinea che approssima la prima curva
|
||||
PolyLine PL1 ;
|
||||
if ( ! GetPolyLineFromCurve( nCrvId1, frDest, dLinTol, PL1))
|
||||
bOk = false ;
|
||||
// calcolo la polilinea che approssima la seconda curva
|
||||
PolyLine PL2 ;
|
||||
if ( ! GetPolyLineFromCurve( nCrvId2, frDest, dLinTol, PL2))
|
||||
bOk = false ;
|
||||
// creo la superficie trimesh e costruisco la rigata tra le due curve
|
||||
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
|
||||
if ( IsNull( pSTM) || ! pSTM->CreateByTwoCurves( PL1, PL2))
|
||||
bOk = false ;
|
||||
// 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) ;
|
||||
// inserisco la superficie trimesh nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ;
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
|
||||
Reference in New Issue
Block a user