EgtExecutor :
- correzioni a CreateSurfBzByExtrusion - aggiunta della CreateSurfBzByRegionExtrusion.
This commit is contained in:
+166
-59
@@ -2025,7 +2025,7 @@ ExeCreateSurfBzByRegion( int nParentId, const INTVECTOR& vCrvIds, double dLinTol
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBzByExtrusion( int nParentId, const INTVECTOR& vCrvIds, const Vector3d& vtExtr, bool bCapEnds,
|
||||
ExeCreateSurfBzByExtrusion( int nParentId, int nCrvId, const Vector3d& vtExtr, bool bCapEnds,
|
||||
double dLinTol, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
@@ -2035,6 +2035,74 @@ ExeCreateSurfBzByExtrusion( int nParentId, const INTVECTOR& vCrvIds, const Vecto
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
//recupero il riferimento della curva
|
||||
Frame3d frCrv ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nCrvId, frCrv) ;
|
||||
// recupero la curva in locale
|
||||
const ICurve* pCrvOrig = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ;
|
||||
PtrOwner<ICurve> pCrv( pCrvOrig->Clone()) ;
|
||||
// porto in locale il vettore estrusione
|
||||
Vector3d vtExtrL = GetVectorLocal( pGeomDB, vtExtr, nRefType, frLoc) ;
|
||||
// creo la superficie e la inserisco nel DB
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
double dAndTolStdDeg = 15 ;
|
||||
Plane3d plPlane ;
|
||||
double dArea ;
|
||||
PolyLine plApprox ;
|
||||
pCrv->ApproxWithLines( dLinTol, dAndTolStdDeg, ICurve::APL_STD, plApprox) ;
|
||||
double dOrthoExtr = 0 ;
|
||||
if ( bCapEnds && plApprox.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL)){
|
||||
dOrthoExtr = plPlane.GetVersN() * vtExtr ;
|
||||
if ( ( abs( dOrthoExtr) < EPS_SMALL))
|
||||
return GDB_ID_NULL ;
|
||||
if( dOrthoExtr < 0)
|
||||
pCrv->Invert() ;
|
||||
}
|
||||
// creo l'estrusione della curva
|
||||
ISurfBezier* pSbz = ( bOk ? GetSurfBezierByExtrusion( pCrv, vtExtrL, false, dLinTol) : nullptr ) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbz) : GDB_ID_NULL) ;
|
||||
bOk = bOk && ( nNewId != GDB_ID_NULL) ;
|
||||
|
||||
// se richiesta chiusura agli estremi
|
||||
if ( bCapEnds) {
|
||||
PtrOwner<ISurfBezier> pSrfBzTop( CreateSurfBezier()) ;
|
||||
pSrfBzTop->CreateByFlatContour( plApprox) ;
|
||||
pSrfBzTop->Translate( vtExtrL) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzTop)) ;
|
||||
PtrOwner<ISurfBezier> pSrfBzBottom( CreateSurfBezier()) ;
|
||||
pSrfBzBottom->CreateByFlatContour( plApprox) ;
|
||||
pSrfBzBottom->Invert() ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzBottom)) ;
|
||||
}
|
||||
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBzByExtrusion(" + IdToString( nParentId) + "," +
|
||||
IdToString( nCrvId) + ",{" +
|
||||
ToString( vtExtr) + "}," +
|
||||
ToString( dLinTol) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nFirstId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBzByRegionExtrusion( int nParentId, const INTVECTOR& vCrvIds, const Vector3d& vtExtr, bool bCapEnds,
|
||||
double dLinTol, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// recupero le curve in locale
|
||||
CURVELOCALVECTOR vCrvLoc ;
|
||||
vCrvLoc.reserve( vCrvIds.size()) ;
|
||||
@@ -2055,72 +2123,74 @@ ExeCreateSurfBzByExtrusion( int nParentId, const INTVECTOR& vCrvIds, const Vecto
|
||||
// creo le superfici e le inserisco nel DB
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
double dAndTolStdDeg = 15 ;
|
||||
|
||||
// riordino le curve in modo che la prima sia quella esterna e tutte le altre dopo
|
||||
POLYLINEVECTOR vPLOrd ;
|
||||
POLYLINEVECTOR vPL ;
|
||||
for ( int i = 0 ; i < int( vCrvP.size()) ; ++ i) {
|
||||
Plane3d plPlane ;
|
||||
double dArea ;
|
||||
PolyLine plApprox ;
|
||||
vCrvP[i]->ApproxWithLines( dLinTol, dAndTolStdDeg, ICurve::APL_STD, plApprox) ;
|
||||
plApprox.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL) ;
|
||||
PtrOwner<ICurve> pCrvToExtrude( vCrvP[i]->Clone()) ;
|
||||
if( plPlane.GetVersN() * vtExtrL < 0)
|
||||
pCrvToExtrude->Invert() ;
|
||||
vPL.emplace_back() ;
|
||||
if ( ! vCrvP[i]->ApproxWithLines( dLinTol, dAndTolStdDeg, ICurve::APL_SPECIAL, vPL.back()))
|
||||
return false ;
|
||||
}
|
||||
Vector3d vtN ;
|
||||
INTMATRIX vnPLIndMat ;
|
||||
BOOLVECTOR vbInvert ;
|
||||
if ( ! CalcRegionPolyLines( vPL, vPLOrd, vtN, vnPLIndMat, vbInvert))
|
||||
return nFirstId ;
|
||||
|
||||
// creo una copia delle curve, orientate giuste
|
||||
ICURVEPOVECTOR vpCrvOr ;
|
||||
for (int i = 0 ; i < int( vnPLIndMat.size()) ; ++i) {
|
||||
for ( int j = 0 ; j< int( vnPLIndMat[i].size()) ; ++j) {
|
||||
vpCrvOr.emplace_back( vCrvP[vnPLIndMat[i][j]]->Clone()) ;
|
||||
if( vbInvert[vnPLIndMat[i][j]])
|
||||
vpCrvOr.back()->Invert() ;
|
||||
}
|
||||
}
|
||||
|
||||
// controlo se il vettore di estrusione è orientato come la normale della curva più grande o no
|
||||
bool bOrientedAsExtrusion = false ;
|
||||
Plane3d plPlane ;
|
||||
double dArea ;
|
||||
double dOrthoExtr = 0 ;
|
||||
// verifico che la curva sia chiusa e piatta
|
||||
if ( vPL[0].IsClosedAndFlat(plPlane, dArea, dLinTol)) {
|
||||
dOrthoExtr = plPlane.GetVersN() * vtExtr ;
|
||||
// controllo che ci sia una componente dell'estrusione perpendicolare al piano della curva
|
||||
if( abs( dOrthoExtr) < EPS_SMALL)
|
||||
return GDB_ID_NULL ;
|
||||
if( dOrthoExtr > EPS_SMALL)
|
||||
bOrientedAsExtrusion = true ;
|
||||
}
|
||||
else
|
||||
bCapEnds = false ;
|
||||
|
||||
// creo l'estrusione delle curve
|
||||
for ( int i = 0 ; i < int( vpCrvOr.size()) ; ++ i) {
|
||||
// calcolo la superficie
|
||||
ISurfBezier* pSbz = ( bOk ? GetSurfBezierByExtrusion( pCrvToExtrude, vtExtrL, false, dLinTol) : nullptr) ;
|
||||
ISurfBezier* pSbz = ( bOk ? GetSurfBezierByExtrusion( vpCrvOr[i], vtExtrL, false, dLinTol) : nullptr ) ;
|
||||
if( ! bOrientedAsExtrusion)
|
||||
pSbz->Invert() ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbz) : GDB_ID_NULL) ;
|
||||
bOk = bOk && ( nNewId != GDB_ID_NULL) ;
|
||||
if ( bOk && nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nNewId ;
|
||||
}
|
||||
|
||||
// se richiesta chiusura agli estremi
|
||||
if ( bCapEnds) {
|
||||
// verifico che la curva sia chiusa e piatta
|
||||
Plane3d plPlane ;
|
||||
double dArea ;
|
||||
PolyLine plApprox ;
|
||||
vCrvP[0]->ApproxWithLines( dLinTol, dAndTolStdDeg, ICurve::APL_STD, plApprox) ;
|
||||
if ( plApprox.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL)) {
|
||||
// componente dell'estrusione perpendicolare al piano della curva
|
||||
double dOrthoExtr = plPlane.GetVersN() * vtExtr ;
|
||||
if ( ( abs( dOrthoExtr) > EPS_SMALL)) {
|
||||
if( vCrvIds.size() == 1) {
|
||||
PtrOwner<ISurfBezier> pSrfBzTop( CreateSurfBezier()) ;
|
||||
pSrfBzTop->CreateByFlatContour( plApprox) ;
|
||||
pSrfBzTop->Translate( vtExtrL) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzTop)) ;
|
||||
PtrOwner<ISurfBezier> pSrfBzBottom( CreateSurfBezier()) ;
|
||||
pSrfBzBottom->CreateByFlatContour( plApprox) ;
|
||||
pSrfBzBottom->Invert() ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzBottom)) ;
|
||||
}
|
||||
else {
|
||||
// riordino le curve in modo che la prima sia quella esterna e tutte le altre dopo
|
||||
POLYLINEVECTOR vPLOrd ;
|
||||
POLYLINEVECTOR vPL ;
|
||||
for ( int i = 0 ; i < int( vCrvP.size()) ; ++ i) {
|
||||
if ( ! vCrvP[i]->ApproxWithLines( dLinTol, dAndTolStdDeg, ICurve::APL_SPECIAL, vPL[i]))
|
||||
return false ;
|
||||
}
|
||||
Vector3d vtN ;
|
||||
INTMATRIX vnPLIndMat ;
|
||||
if ( ! CalcRegionPolyLines( vPL, vPLOrd, vtN, vnPLIndMat))
|
||||
return nFirstId ;
|
||||
// se componente estrusione negativa, inverto tutti i percorsi
|
||||
if ( dOrthoExtr < 0) {
|
||||
for ( int i = 0 ; i < int( vPL.size()) ; ++ i)
|
||||
vPL[i].Invert() ;
|
||||
}
|
||||
PtrOwner<ISurfBezier> pSrfBzTop( CreateSurfBezier()) ;
|
||||
pSrfBzTop->CreateByRegion( vPL) ;
|
||||
pSrfBzTop->Translate( vtExtrL) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzTop)) ;
|
||||
PtrOwner<ISurfBezier> pSrfBzBottom( CreateSurfBezier()) ;
|
||||
pSrfBzBottom->CreateByRegion( vPL) ;
|
||||
pSrfBzBottom->Invert() ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzBottom)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
PtrOwner<ISurfBezier> pSrfBzTop( CreateSurfBezier()) ;
|
||||
pSrfBzTop->CreateByRegion( vPL) ;
|
||||
pSrfBzTop->Translate( vtExtrL) ;
|
||||
if( ! bOrientedAsExtrusion)
|
||||
pSrfBzTop->Invert() ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzTop)) ;
|
||||
PtrOwner<ISurfBezier> pSrfBzBottom( CreateSurfBezier()) ;
|
||||
pSrfBzBottom->CreateByRegion( vPL) ;
|
||||
if( bOrientedAsExtrusion)
|
||||
pSrfBzBottom->Invert() ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzBottom)) ;
|
||||
}
|
||||
|
||||
ExeSetModified() ;
|
||||
@@ -2161,6 +2231,15 @@ ExeCreateSurfBzByScrewing( int nParentId, int nCrvId,
|
||||
ISurfBezier* pSbz = ( bOk ? GetSurfBezierByScrewing( CrvLoc, ptAxL, vtAxL, dAngRotDeg, dMove, bCapEnds, dLinTol) : nullptr) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbz) : GDB_ID_NULL) ;
|
||||
|
||||
// se richiesto creo anche i cap
|
||||
if ( bCapEnds && bOk) {
|
||||
// la curva che fa da sezione alla superficie deve essere chiusa e piana
|
||||
// lo screwing non deve essere una semplice rivoluzione
|
||||
Plane3d plPlane ;
|
||||
if ( CrvLoc->IsClosed() && CrvLoc->IsFlat( plPlane) && abs(abs(dAngRotDeg) - ANG_FULL) < EPS_SMALL && abs( dMove) < EPS_SMALL) {
|
||||
}
|
||||
}
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
@@ -2269,7 +2348,7 @@ ExeCreateSurfBzByRevolve( int nParentId, int nCrvId,
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBzRuled( int nParentId, int nCrvId1, int nCrvId2, int nRuledType, double dLinTol)
|
||||
ExeCreateSurfBzRuled( int nParentId, int nCrvId1, int nCrvId2, int nRuledType, bool bCapEnds, double dLinTol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
@@ -2285,8 +2364,36 @@ ExeCreateSurfBzRuled( int nParentId, int nCrvId1, int nCrvId2, int nRuledType, d
|
||||
bOk = bOk && ( CrvLoc2.Get() != nullptr) ;
|
||||
// calcolo la superficie
|
||||
ISurfBezier* pSbz = ( bOk ? GetSurfBezierRuled( CrvLoc1, CrvLoc2, nRuledType, dLinTol) : nullptr) ;
|
||||
// se le curve sono chiuse e la superficie guarda all'interno del "cilindro" allora inverto la superficie
|
||||
if ( CrvLoc1->IsClosed() && CrvLoc2->IsClosed()) {
|
||||
Point3d ptStart1 ; CrvLoc1->GetStartPoint( ptStart1) ;
|
||||
Point3d ptStart2 ; CrvLoc2->GetStartPoint( ptStart2) ;
|
||||
Vector3d vtRuling = ptStart2 - ptStart1 ;
|
||||
Plane3d plApprox ;
|
||||
}
|
||||
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbz) : GDB_ID_NULL) ;
|
||||
|
||||
// se richiesto inserisco anche il cap
|
||||
if ( bCapEnds && bOk) {
|
||||
Plane3d plPlane1, plPlane2 ;
|
||||
if ( CrvLoc1->IsClosed() && CrvLoc1->IsFlat( plPlane1) && CrvLoc2->IsClosed() && CrvLoc2->IsFlat( plPlane2)) {
|
||||
// costruisco la superficie dalla curva 1
|
||||
PtrOwner<ISurfBezier> pSbzFlat1( CreateSurfBezier()) ;
|
||||
double dAngTolDeg = 5 ;
|
||||
PolyLine pl1 ; CrvLoc1->ApproxWithLines(dLinTol, dAngTolDeg, ICurve::APL_STD, pl1) ;
|
||||
pSbzFlat1->CreateByFlatContour( pl1) ;
|
||||
// inserisco la superficie nel DB
|
||||
bOk = bOk && pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbzFlat1)) ;
|
||||
// costruisco la superficie dalla curva 2
|
||||
PtrOwner<ISurfBezier> pSbzFlat2( CreateSurfBezier()) ;
|
||||
PolyLine pl2 ; CrvLoc2->ApproxWithLines(dLinTol, dAngTolDeg, ICurve::APL_STD, pl2) ;
|
||||
pSbzFlat2->CreateByFlatContour( pl2) ;
|
||||
// inserisco la superficie nel DB
|
||||
bOk = bOk && pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbzFlat2)) ;
|
||||
}
|
||||
}
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
@@ -2304,7 +2411,7 @@ ExeCreateSurfBzRuled( int nParentId, int nCrvId1, int nCrvId2, int nRuledType, d
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBzSkinned( int nParentId, const INTVECTOR& vCrvIds, double dLinTol)
|
||||
ExeCreateSurfBzSkinned( int nParentId, const INTVECTOR& vCrvIds, bool bCapEnds, double dLinTol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
|
||||
Reference in New Issue
Block a user