Merge remote-tracking branch 'origin/master' into MoreBezier

This commit is contained in:
Daniele Bariletti
2024-10-04 15:34:54 +02:00
5 changed files with 373 additions and 202 deletions
+279 -158
View File
@@ -1872,9 +1872,9 @@ ExeCreateSurfBezierTria2D( int nParentId, int nSurfBzId, int nTextHeight, bool b
for ( int k = 0 ; k < (int)vTria2D.size() ; ++ k) {
PtrOwner<ISurfTriMesh> pStm( CreateSurfTriMesh()) ;
bOk = bOk && ! IsNull( pStm) ;
Point3d ptP1L = get<1>(vTria2D[k]) ;
Point3d ptP2L = get<2>(vTria2D[k]) ;
Point3d ptP3L = get<3>(vTria2D[k]) ;
Point3d ptP1L = get<1>(vTria2D[k]) ;
Point3d ptP2L = get<2>(vTria2D[k]) ;
Point3d ptP3L = get<3>(vTria2D[k]) ;
// assegno il triangolo
if ( bOk) {
pStm->Init( 3, 1, 1) ;
@@ -1922,7 +1922,8 @@ ExeCreateSurfBezierTria2D( int nParentId, int nSurfBzId, int nTextHeight, bool b
//-------------------------------------------------------------------------------
int
ExeCreateBezierSphere( int nParentId, const Point3d& ptCenter, double dR, int nRefType) {
ExeCreateBezierSphere( int nParentId, const Point3d& ptCenter, double dR, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
nParentId = AdjustId( nParentId) ;
@@ -1934,18 +1935,19 @@ ExeCreateBezierSphere( int nParentId, const Point3d& ptCenter, double dR, int nR
Point3d ptCenterLoc = GetPointLocal( pGeomDB, ptCenter, nRefType, frLoc) ;
// Creo la superficie
PtrOwner<ISurfBezier> pSurfBez( GetSurfBezierSphere( ptCenterLoc, dR)) ;
bOk = bOk && ! IsNull( pSurfBez) ;
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSurfBez)) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtCreateBezierSphere(" + IdToString( nParentId) + "," +
ToString( ptCenter) + "," +
ToString( dR) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
string sLua = "EgtSurfBzSphere(" + IdToString( nParentId) + "," +
ToString( ptCenter) + "," +
ToString( dR) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// resituisco l'identificativo dell'entit creata
// resituisco l'identificativo dell'entità creata
return nId ;
}
@@ -1957,26 +1959,27 @@ ExeCreateSurfBzByFlatContour( int nParentId, int nCrvId, double dLinTol)
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
nParentId = AdjustId( nParentId) ;
bool bOk = true ;
// recupero il riferimento locale
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// recupero la curva in locale
// recupero la curva in locale
CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ;
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
// calcolo la superficie
ISurfBezier* pSbz = ( bOk ? GetSurfBezierByFlatContour( CrvLoc, dLinTol) : nullptr) ;
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbz) : GDB_ID_NULL) ;
// calcolo la superficie
PtrOwner<ISurfBezier> pSbz( bOk ? GetSurfBezierByFlatContour( CrvLoc, dLinTol) : nullptr) ;
bOk = bOk && ! IsNull( pSbz) ;
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSurfBzByFlatContour(" + IdToString( nParentId) + "," +
ToString( nCrvId) + "," +
ToString( dLinTol) + ")" +
" -- Id=" + ToString( nNewId) ;
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
// restituisco l'identificativo della nuova entità
return nNewId ;
}
@@ -2007,17 +2010,17 @@ ExeCreateSurfBzByRegion( int nParentId, const INTVECTOR& vCrvIds, double dLinTol
}
}
// calcolo la superficie
ISurfBezier* pSbz = ( bOk ? GetSurfBezierByRegion( vCrvP, dLinTol) : nullptr) ;
bOk = bOk && ( pSbz != nullptr) ;
PtrOwner<ISurfBezier> pSbz( bOk ? GetSurfBezierByRegion( vCrvP, dLinTol) : nullptr) ;
bOk = bOk && ! IsNull( pSbz) ;
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbz) : GDB_ID_NULL) ;
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSurfBzByRegion(" + IdToString( nParentId) + ",{" +
IdListToString( vCrvIds) + "}," +
ToString( dLinTol) + ")" +
" -- Id=" + ToString( nNewId) ;
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
@@ -2033,18 +2036,18 @@ ExeCreateSurfBzByExtrusion( int nParentId, int nCrvId, const Vector3d& vtExtr, b
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
nParentId = AdjustId( nParentId) ;
bool bOk = true ;
// recupero il riferimento locale
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
//recupero il riferimento della curva
// recupero il riferimento della curva
Frame3d frCrv ;
bOk = bOk && pGeomDB->GetGlobFrame( nCrvId, frCrv) ;
// recupero la curva in locale
// recupero la curva in locale
const ICurve* pCrvOrig = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ;
PtrOwner<ICurve> pCrv( pCrvOrig->Clone()) ;
// porto in locale il vettore estrusione
// porto in locale il vettore estrusione
Vector3d vtExtrL = GetVectorLocal( pGeomDB, vtExtr, nRefType, frLoc) ;
// creo la superficie e la inserisco nel DB
// creo la superficie e la inserisco nel DB
int nFirstId = GDB_ID_NULL ;
double dAndTolStdDeg = 15 ;
Plane3d plPlane ;
@@ -2056,17 +2059,18 @@ ExeCreateSurfBzByExtrusion( int nParentId, int nCrvId, const Vector3d& vtExtr, b
dOrthoExtr = plPlane.GetVersN() * vtExtr ;
if ( ( abs( dOrthoExtr) < EPS_SMALL))
return GDB_ID_NULL ;
if( dOrthoExtr < 0)
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) ;
// creo l'estrusione della curva
PtrOwner<ISurfBezier> pSbz( bOk ? GetSurfBezierByExtrusion( pCrv, vtExtrL, false, dLinTol) : nullptr ) ;
bOk = bOk && ! IsNull( pSbz) ;
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ;
bOk = bOk && ( nNewId != GDB_ID_NULL) ;
// se richiesta chiusura agli estremi
if ( bCapEnds) {
// se richiesta chiusura agli estremi
if ( bCapEnds && bOk) {
PtrOwner<ISurfBezier> pSrfBzTop( CreateSurfBezier()) ;
pSrfBzTop->CreateByFlatContour( plApprox) ;
pSrfBzTop->Translate( vtExtrL) ;
@@ -2078,17 +2082,18 @@ ExeCreateSurfBzByExtrusion( int nParentId, int nCrvId, const Vector3d& vtExtr, b
}
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSurfBzByExtrusion(" + IdToString( nParentId) + "," +
IdToString( nCrvId) + ",{" +
ToString( vtExtr) + "}," +
( bCapEnds ? "true" : "false") + "," +
ToString( dLinTol) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nFirstId) ;
" -- Id=" + ToString( nFirstId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
// restituisco l'identificativo della nuova entità
return nFirstId ;
}
@@ -2101,10 +2106,10 @@ ExeCreateSurfBzByRegionExtrusion( int nParentId, const INTVECTOR& vCrvIds, const
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
nParentId = AdjustId( nParentId) ;
bool bOk = true ;
// recupero il riferimento locale
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// recupero le curve in locale
// recupero le curve in locale
CURVELOCALVECTOR vCrvLoc ;
vCrvLoc.reserve( vCrvIds.size()) ;
CICURVEPVECTOR vCrvP ;
@@ -2115,17 +2120,17 @@ ExeCreateSurfBzByRegionExtrusion( int nParentId, const INTVECTOR& vCrvIds, const
vCrvLoc.emplace_back( pGeomDB, nId, frLoc) ;
vCrvP.push_back( const_cast<ICurve*>( vCrvLoc.back().Get())) ;
bOk = bOk && ( vCrvLoc[i].Get() != nullptr) ;
// passo al successivo
// passo al successivo
nId = (( vCrvIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
}
}
// porto in locale il vettore estrusione
// porto in locale il vettore estrusione
Vector3d vtExtrL = GetVectorLocal( pGeomDB, vtExtr, nRefType, frLoc) ;
// creo le superfici e le inserisco nel DB
// 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
// riordino le curve in modo che la prima sia quella esterna e tutte le altre dopo
POLYLINEVECTOR vPL ;
for ( int i = 0 ; i < int( vCrvP.size()) ; ++ i) {
vPL.emplace_back() ;
@@ -2138,73 +2143,74 @@ ExeCreateSurfBzByRegionExtrusion( int nParentId, const INTVECTOR& vCrvIds, const
if ( ! CalcRegionPolyLines( vPL, vtN, vnPLIndMat, vbInvert))
return nFirstId ;
// creo una copia delle curve, orientate giuste
// 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]])
if ( vbInvert[vnPLIndMat[i][j]])
vpCrvOr.back()->Invert() ;
}
}
// controlo se il vettore di estrusione è orientato come la normale della curva più grande o no
// 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
// 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)
// 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)
if ( dOrthoExtr > EPS_SMALL)
bOrientedAsExtrusion = true ;
}
else
bCapEnds = false ;
// creo l'estrusione delle curve
// creo l'estrusione delle curve
for ( int i = 0 ; i < int( vpCrvOr.size()) ; ++ i) {
// calcolo la superficie
// calcolo la superficie
ISurfBezier* pSbz = ( bOk ? GetSurfBezierByExtrusion( vpCrvOr[i], vtExtrL, false, dLinTol) : nullptr ) ;
if( ! bOrientedAsExtrusion)
if ( ! bOrientedAsExtrusion)
pSbz->Invert() ;
// inserisco la superficie nel DB
// 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
// se richiesta chiusura agli estremi
if ( bCapEnds) {
PtrOwner<ISurfBezier> pSrfBzTop( CreateSurfBezier()) ;
pSrfBzTop->CreateByRegion( vPL) ;
pSrfBzTop->Translate( vtExtrL) ;
if( ! bOrientedAsExtrusion)
if ( ! bOrientedAsExtrusion)
pSrfBzTop->Invert() ;
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzTop)) ;
PtrOwner<ISurfBezier> pSrfBzBottom( CreateSurfBezier()) ;
pSrfBzBottom->CreateByRegion( vPL) ;
if( bOrientedAsExtrusion)
if ( bOrientedAsExtrusion)
pSrfBzBottom->Invert() ;
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzBottom)) ;
}
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSurfBzByExtrusion(" + IdToString( nParentId) + ",{" +
IdListToString( vCrvIds) + "},{" +
ToString( vtExtr) + "}," +
ToString( dLinTol) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nFirstId) ;
string sLua = "EgtSurfBzByRegionExtrusion(" + IdToString( nParentId) + ",{" +
IdListToString( vCrvIds) + "},{" +
ToString( vtExtr) + "}," +
( bCapEnds ? "true" : "false") + "," +
ToString( dLinTol) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nFirstId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
// restituisco l'identificativo della nuova entità
return nFirstId ;
}
@@ -2218,19 +2224,19 @@ ExeCreateSurfBzByScrewing( int nParentId, int nCrvId,
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
nParentId = AdjustId( nParentId) ;
bool bOk = true ;
// recupero il riferimento locale
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// recupero la curva in locale
// recupero la curva in locale
CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ;
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
// porto in locale punto e vettore asse
// porto in locale punto e vettore asse
Point3d ptAxL = GetPointLocal( pGeomDB, ptAx, nRefType, frLoc) ;
Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ;
vtAxL.Normalize() ;
// la curva che fa da sezione alla superficie è chiusa e piana ed è richiesto il capping verifico se la superficie è da invertire
// lo screwing non deve essere una semplice rivoluzione
// la curva che fa da sezione alla superficie è chiusa e piana ed è richiesto il capping verifico se la superficie è da invertire
// lo screwing non deve essere una semplice rivoluzione
bool bOrientedAsScrewing = false ;
Plane3d plPlane ;
double dArea = 0 ;
@@ -2256,17 +2262,18 @@ ExeCreateSurfBzByScrewing( int nParentId, int nCrvId,
else
bCapEnds = false ;
// calcolo la superficie
ISurfBezier* pSbz = ( bOk ? GetSurfBezierByScrewing( CrvLoc, ptAxL, vtAxL, dAngRotDeg, dMove, bCapEnds, dLinTol) : nullptr) ;
if( ! bOrientedAsScrewing && bCapEnds)
// calcolo la superficie
PtrOwner<ISurfBezier> pSbz( bOk ? GetSurfBezierByScrewing( CrvLoc, ptAxL, vtAxL, dAngRotDeg, dMove, bCapEnds, dLinTol) : nullptr) ;
bOk = bOk && ! IsNull( pSbz) ;
if ( ! bOrientedAsScrewing && bCapEnds && bOk)
pSbz->Invert() ;
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbz) : GDB_ID_NULL) ;
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ;
// se richiesto creo anche i cap
if ( bCapEnds && bOk) {
// se richiesto creo anche i cap
if ( bCapEnds && bOk) {
ISurfBezier* pSbzBase1 = GetSurfBezierByFlatContour(CrvLoc,dLinTol) ;
if( bOrientedAsScrewing)
if ( bOrientedAsScrewing)
pSbzBase1->Invert() ;
bOk = bOk && pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbzBase1) ;
ISurfBezier* pSbzBase2 = GetSurfBezierByFlatContour( CrvLoc,dLinTol) ;
@@ -2277,7 +2284,7 @@ ExeCreateSurfBzByScrewing( int nParentId, int nCrvId,
bOk = bOk && pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbzBase2) ;
}
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSurfbzByScrewing(" + IdToString( nParentId) + "," +
ToString( nCrvId) + ",{" +
@@ -2288,30 +2295,30 @@ ExeCreateSurfBzByScrewing( int nParentId, int nCrvId,
( bCapEnds ? "true" : "false") + "," +
ToString( dLinTol) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nNewId) ;
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
// restituisco l'identificativo della nuova entità
return nNewId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateSurfBzByRevolve( int nParentId, int nCrvId,
const Point3d& ptAx, const Vector3d& vtAx,
bool bCapEnds, double dLinTol, int nRefType)
const Point3d& ptAx, const Vector3d& vtAx,
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
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// recupero la curva in locale
// recupero la curva in locale
CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ;
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
// porto in locale punto e vettore asse
// porto in locale punto e vettore asse
Point3d ptAxL = GetPointLocal( pGeomDB, ptAx, nRefType, frLoc) ;
Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ;
// calcolo la superficie
@@ -2333,8 +2340,8 @@ ExeCreateSurfBzByRevolve( int nParentId, int nCrvId,
pSbz->Invert() ;
// finché non ho le SurfCompo creo qui i cap
if ( bCapEnds && ! CrvLoc->IsClosed()) {
// calcola la bbox della superficie
if ( bCapEnds && bOk) {
// calcola il bbox della superficie
BBox3d bbox3dSurf ;
int nDegU, nDegV, nSpanU, nSpanV ;
bool bTrim, bRat ;
@@ -2345,7 +2352,7 @@ ExeCreateSurfBzByRevolve( int nParentId, int nCrvId,
Point3d ptCtrl = pSbz->GetControlPoint( p, &bPointOk) ;
bbox3dSurf.Add( ptCtrl) ;
}
// recupero i loop
// recupero i loop
ICRVCOMPOPOVECTOR vCCLoop ;
pSbz->GetLoops( vCCLoop, true) ;
// controllo se i loop trovati sono validi
@@ -2360,8 +2367,8 @@ ExeCreateSurfBzByRevolve( int nParentId, int nCrvId,
return GDB_ID_NULL ;
if( ! IsNull(vCCLoop[3]) && ! vCCLoop[3]->IsValid() && ! bEndOnAx)
return GDB_ID_NULL ;
// il getLoops per superfici non trimmate restituisce 1 elemento per ogni lato dello spazio parametrico.
// in questo caso la superficie è chiusa lungo il parametro V, quindi i lati 0 e 2 saranno null.
// il getLoops per superfici non trimmate restituisce 1 elemento per ogni lato dello spazio parametrico.
// in questo caso la superficie è chiusa lungo il parametro V, quindi i lati 0 e 2 saranno null.
double dAngTolDeg = 5 ;
PolyLine plEdge1 ;
if( bValidLoop1)
@@ -2409,16 +2416,16 @@ ExeCreateSurfBzByRevolve( int nParentId, int nCrvId,
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSurfbzByScrewing(" + IdToString( nParentId) + "," +
ToString( nCrvId) + ",{" +
ToString( ptAx) + "},{" +
ToString( vtAx) + "}," +
( bCapEnds ? "true" : "false") + "," +
ToString( dLinTol) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nNewId) ;
string sLua = "EgtSurfBzByRevolve(" + IdToString( nParentId) + "," +
ToString( nCrvId) + ",{" +
ToString( ptAx) + "},{" +
ToString( vtAx) + "}," +
( bCapEnds ? "true" : "false") + "," +
ToString( dLinTol) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
@@ -2433,71 +2440,66 @@ ExeCreateSurfBzRuled( int nParentId, int nCrvId1, int nCrvId2, int nRuledType, b
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
nParentId = AdjustId( nParentId) ;
bool bOk = true ;
// recupero il riferimento locale
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// recupero le curve in locale
// recupero le curve in locale
CurveLocal CrvLoc1( pGeomDB, nCrvId1, frLoc) ;
bOk = bOk && ( CrvLoc1.Get() != nullptr) ;
CurveLocal CrvLoc2( pGeomDB, nCrvId2, frLoc) ;
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
Vector3d vtRuling ;
if ( CrvLoc1->IsClosed() && CrvLoc2->IsClosed()) {
// calcolo la superficie
PtrOwner<ISurfBezier> pSbz( bOk ? GetSurfBezierRuled( CrvLoc1, CrvLoc2, nRuledType, dLinTol) : nullptr) ;
bOk = bOk && ! IsNull( pSbz) ;
// verifiche per orientamento se con tappi
bool bWithCaps = false ;
bool bStdOrient = true ;
Plane3d plPlane1, plPlane2 ;
double dArea1, dArea2 ;
if ( bOk && bCapEnds &&
CrvLoc1->IsClosed() && CrvLoc2->IsClosed() && CrvLoc1->GetArea( plPlane1, dArea1) && CrvLoc2->GetArea( plPlane2, dArea2)) {
bWithCaps = true ;
Point3d ptStart1 ; CrvLoc1->GetStartPoint( ptStart1) ;
Point3d ptStart2 ; CrvLoc2->GetStartPoint( ptStart2) ;
vtRuling = ptStart2 - ptStart1 ;
double dAngTolDeg = 15 ;
PolyLine plApprox ; CrvLoc1->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plApprox) ;
Plane3d plPlane ;
double dArea ;
plApprox.IsClosedAndFlat( plPlane, dArea) ;
double dOrtho = plPlane.GetVersN() * vtRuling ;
if( dOrtho < 0)
Vector3d vtRuling = ptStart2 - ptStart1 ;
bStdOrient = ( vtRuling * plPlane1.GetVersN() > 0) ;
if ( ! bStdOrient)
pSbz->Invert() ;
}
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbz) : GDB_ID_NULL) ;
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( 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) ;
Plane3d plPlane1 ; double dArea1 ;
pl1.IsClosedAndFlat( plPlane1, dArea1) ;
if( plPlane1.GetVersN() * vtRuling > 0)
pSbzFlat1->Invert() ;
// 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) ;
Plane3d plPlane2 ; double dArea2 ;
pl2.IsClosedAndFlat( plPlane2, dArea2) ;
if( plPlane2.GetVersN() * vtRuling < 0)
pSbzFlat2->Invert() ;
// inserisco la superficie nel DB
bOk = bOk && pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbzFlat2)) ;
}
// se richiesto inserisco anche il cap
if ( bOk && bWithCaps) {
// 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) ;
if ( bStdOrient)
pSbzFlat1->Invert() ;
// 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) ;
if ( ! bStdOrient)
pSbzFlat2->Invert() ;
// inserisco la superficie nel DB
bOk = bOk && pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbzFlat2)) ;
}
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSurfbzByScrewing(" + IdToString( nParentId) + "," +
ToString( nCrvId1) + "," +
ToString( nCrvId2) + "," +
ToString( nRuledType) + "," +
ToString( dLinTol) + ")" +
" -- Id=" + ToString( nNewId) ;
string sLua = "EgtSurfBzRuled(" + IdToString( nParentId) + "," +
ToString( nCrvId1) + "," +
ToString( nCrvId2) + "," +
ToString( nRuledType) + "," +
( bCapEnds ? "true" : "false") + "," +
ToString( dLinTol) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
@@ -2512,10 +2514,10 @@ ExeCreateSurfBzSkinned( int nParentId, const INTVECTOR& vCrvIds, bool bCapEnds,
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
nParentId = AdjustId( nParentId) ;
bool bOk = true ;
// recupero il riferimento locale
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// recupero le curve in locale
// recupero le curve in locale
CURVELOCALVECTOR vCrvLoc ;
vCrvLoc.reserve( vCrvIds.size()) ;
CICURVEPVECTOR vCrvP ;
@@ -2527,20 +2529,139 @@ ExeCreateSurfBzSkinned( int nParentId, const INTVECTOR& vCrvIds, bool bCapEnds,
bOk = bOk && ( vCrvLoc[i].Get() != nullptr) ;
}
// calcolo la superficie
PtrOwner<ISurfBezier> pSbz( bOk ? GetSurfBezierSkinned( vCrvP, dLinTol) : nullptr ) ;
bOk = bOk && ! IsNull( pSbz) ;
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSurfBzSkinned(" + IdToString( nParentId) + ",{" +
IdListToString( vCrvIds) + "}," +
( bCapEnds ? "true" : "false") + "," +
ToString( dLinTol) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nNewId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateSurfBzSwept( int nParentId, int nSectId, int nGuideId, const Vector3d& vtAx,
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
CurveLocal CrvSect( pGeomDB, nSectId, frLoc) ;
CurveLocal CrvGuide( pGeomDB, nGuideId, frLoc) ;
// porto in locale vettore asse
Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ;
PolyLine plGuide ;
double dAngTolDeg = 15 ;
CrvGuide->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plGuide) ;
Plane3d plPlane ;
bool bFlatGuide = plGuide.IsFlat( plPlane) ;
// calcolo la superficie
ISurfBezier* pSbz = ( bOk ? GetSurfBezierSkinned( vCrvP, dLinTol) : nullptr ) ;
PtrOwner<ISurfBezier> pSbz( CreateSurfBezier()) ;
if( bFlatGuide)
pSbz.Set( bOk ? GetSurfBezierSweptInPlane( CrvSect, CrvGuide, vtAxL, bCapEnds, dLinTol) : nullptr ) ;
else
pSbz.Set( bOk ? GetSurfBezierSwept3d( CrvSect, CrvGuide, vtAxL, bCapEnds, dLinTol) : nullptr ) ;
// se richiesto il capping verifico che la superficie abbia il gisto orientamento
bool bOrientedAsGuide = false ;
ICRVCOMPOPOVECTOR vCCLoop ;
if( bCapEnds) {
// controlo se il vettore di start della guida è orientato come la normale della curva o no
Vector3d vtStart ; CrvGuide->GetStartDir( vtStart) ;
Plane3d plPlane ;
double dArea ;
double dOrthoGuide = 0 ;
// verifico che la curva sia chiusa e piatta
PolyLine PL ;
CrvSect->ApproxWithLines(dLinTol, dAngTolDeg, ICurve::APL_STD, PL) ;
if ( PL.IsClosedAndFlat(plPlane, dArea, dLinTol)) {
dOrthoGuide = plPlane.GetVersN() * vtStart ;
// controllo che ci sia una componente dell'estrusione perpendicolare al piano della curva
if( abs( dOrthoGuide) < EPS_SMALL)
return GDB_ID_NULL ;
// recupero i loop
pSbz->GetLoops( vCCLoop, true) ;
// se necessario inverto la superficie
if( dOrthoGuide > EPS_SMALL)
bOrientedAsGuide = true ;
else
pSbz->Invert() ;
}
else
bCapEnds = false ;
}
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbz) : GDB_ID_NULL) ;
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ;
// se richiesto aggiungo anche i cap
if ( bCapEnds) {
// controllo se i loop trovati sono validi
bool bValidLoop0 = false ;
bool bValidLoop2 = false ;
if( ! IsNull(vCCLoop[0]) && vCCLoop[0]->IsValid())
bValidLoop0 = true ;
if( ! IsNull(vCCLoop[2]) && vCCLoop[2]->IsValid())
bValidLoop2 = true ;
if( ! IsNull(vCCLoop[0]) && ! vCCLoop[0]->IsValid())
return GDB_ID_NULL ;
if( ! IsNull(vCCLoop[2]) && ! vCCLoop[2]->IsValid())
return GDB_ID_NULL ;
// il getLoops per superfici non trimmate restituisce 1 elemento per ogni lato dello spazio parametrico.
// in questo caso la superficie è chiusa lungo il parametro V, quindi i lati 1 e 3 saranno null.
double dAngTolDeg = 5 ;
PolyLine plEdge0 ;
if( bValidLoop0)
vCCLoop[0]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge0) ;
PolyLine plEdge2 ;
if( bValidLoop2)
vCCLoop[2]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge2) ;
PtrOwner<ISurfBezier> pSrfBezStart( CreateSurfBezier()) ;
pSrfBezStart->CreateByFlatContour( plEdge2) ;
// se necessario inverto
if( bOrientedAsGuide) // edge 2, che è la prima riga della matrice dei punti di controllo è orientato nello stesso verso della curva di sezione
pSrfBezStart->Invert() ;
// aggiungo al database
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBezStart)) ;
PtrOwner<ISurfBezier> pSrfBezEnd( CreateSurfBezier()) ;
pSrfBezEnd->CreateByFlatContour( plEdge0) ;
// se necessario inverto
if( bOrientedAsGuide) // edge 0, che è l'ultima riga della matrice dei punti di controllo è orientato in verso opposto alla curva di sezione
pSrfBezEnd->Invert() ;
// aggiungo al database
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBezEnd)) ;
}
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSurfbzByScrewing(" + IdToString( nParentId) + ",{" +
IdListToString( vCrvIds) + "}," +
string sLua = "EgtSurfbzByScrewing(" + IdToString( nParentId) + "," +
IdToString( nSectId) + "," +
IdToString( nGuideId) + "," +
ToString( dLinTol) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
// restituisco l'identificativo della nuova entità
return nNewId ;
}
+85 -35
View File
@@ -876,7 +876,7 @@ ExeTrimExtendCurveByLen( int nId, double dLen, const Point3d& ptNear, int nRefTy
bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ;
// porto in locale il punto
Point3d ptNearL = GetPointLocal( pGeomDB, ptNear, nRefType, frLoc) ;
// cerco l'estremo più vicino al punto passato
// cerco l'estremo più vicino al punto passato
bool bStart ;
if ( bOk && pCurve->GetNearestExtremityToPoint( ptNearL, bStart)) {
if ( bStart) {
@@ -971,7 +971,7 @@ MyTrimCurveWithRegion( int nCrvId, int nRegId, bool bInVsOut, bool bOn, int& nCo
// passo alla successiva divisione
bFound = inOk.GetNext( dParS, dParE) ;
}
// cancello l'ultima copia (se non c'erano intervalli validi è l'originale)
// cancello l'ultima copia (se non c'erano intervalli validi è l'originale)
pGeomDB->Erase( nCurrId) ;
return nFirstId ;
}
@@ -1016,7 +1016,7 @@ MyTrimFlatCurveWithBox( int nCrvId, const Frame3d& frBox, const Vector3d& vtDiag
Plane3d plPlane ;
if ( ! pCrv->IsFlat( plPlane, false, 10 * EPS_SMALL))
return GDB_ID_NULL ;
// porto in locale alla curva il riferimento del box (il vettore è già in locale a questo stesso riferimento)
// porto in locale alla curva il riferimento del box (il vettore è già in locale a questo stesso riferimento)
Frame3d frBoxL = GetFrameLocal( pGeomDB, frBox, nRefType, frCrv) ;
// determino la parte di piano (poligono) compresa nel box (applicando le opportune trasformazioni di riferimento)
plPlane.ToLoc( frBoxL) ;
@@ -1080,7 +1080,7 @@ MyTrimFlatCurveWithBox( int nCrvId, const Frame3d& frBox, const Vector3d& vtDiag
// passo alla successiva divisione
bFound = inOk.GetNext( dParS, dParE) ;
}
// cancello l'ultima copia (se non c'erano intervalli validi è l'originale)
// cancello l'ultima copia (se non c'erano intervalli validi è l'originale)
pGeomDB->Erase( nCurrId) ;
return nFirstId ;
}
@@ -1118,7 +1118,7 @@ ExeSplitCurve( int nId, int nParts)
// recupero la curva
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pCurve != nullptr) ;
// il numero di parti non può essere inferiore a 1
// il numero di parti non può essere inferiore a 1
nParts = max( nParts, 1) ;
// lunghezza totale della curva
double dLenTot = 0 ;
@@ -1179,7 +1179,7 @@ ExeSplitCurveAtPoint( int nId, const Point3d& ptOn, int nRefType)
int nFlag ;
if ( ! dstPC.GetParamAtMinDistPoint( 0, dU, nFlag) || nFlag != MDPCI_NORMAL)
bOk = false ;
// se sull'inizio, provo se c'è una soluzione successiva
// se sull'inizio, provo se c'è una soluzione successiva
if ( bOk && dU < EPS_PARAM)
dstPC.GetParamAtMinDistPoint( 1, dU, nFlag) ;
}
@@ -1196,7 +1196,7 @@ ExeSplitCurveAtPoint( int nId, const Point3d& ptOn, int nRefType)
if ( bOk && dCutLen > EPS_SMALL && dLen - dCutLen > EPS_SMALL)
bIsInside = true ;
}
// se il punto di taglio è interno, devo realmente tagliare
// se il punto di taglio è interno, devo realmente tagliare
int nNewId = GDB_ID_NULL ;
if ( bIsInside) {
// copio la curva
@@ -1243,7 +1243,7 @@ ExeSplitCurveAtParam( int nId, double dParam)
if ( bOk && dCutLen > EPS_SMALL && dLen - dCutLen > EPS_SMALL)
bIsInside = true ;
}
// se il punto di taglio è interno, devo realmente tagliare
// se il punto di taglio è interno, devo realmente tagliare
int nNewId = GDB_ID_NULL ;
if ( bIsInside) {
// copio la curva
@@ -1465,7 +1465,7 @@ ExeGetCurveLinearConvexHullXY( int nId, double dLinTol, int nRefType)
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
// restituisco l'identificativo della nuova entità
return nNewId ;
}
@@ -1562,7 +1562,7 @@ MyModifyArcRadiusEx( IGeomDB* pGeomDB, int nId, double dRad)
// se angolo al centro maggiore o uguale ad un giro o estremi coincidenti, conservo il centro
if ( abs( pArc->GetAngCenter()) >= ANG_FULL - EPS_ANG_ZERO || dPlaneDist < 2 * EPS_SMALL)
return MyModifyArcRadius( pGeomDB, nId, dRad) ;
// mantengo i punti estremi (pertanto il nuovo raggio non può essere inferiore a metà della loro distanza nel piano)
// mantengo i punti estremi (pertanto il nuovo raggio non può essere inferiore a metà della loro distanza nel piano)
if ( dRad < dPlaneDist / 2 - EPS_ZERO)
return false ;
// creo arco con gli stessi estremi, con identica normale e con nuovo raggio
@@ -1765,7 +1765,7 @@ ExeAddCurveCompoCurve( int nId, int nAddCrvId, bool bEraseOrig, bool bEndVsStart
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
// restituisco l'identificativo della nuova entità
return bOk ;
}
@@ -1979,7 +1979,7 @@ ExeGetCurveCompoJointCount( int nId)
ICurveComposite* pCompo = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ;
if ( pCompo == nullptr)
return 0 ;
// calcolo il numero di giunzioni (se chiusa è uguale al numero delle curve altrimenti -1)
// calcolo il numero di giunzioni (se chiusa è uguale al numero delle curve altrimenti -1)
if ( pCompo->IsClosed())
return pCompo->GetCurveCount() ;
else
@@ -2430,7 +2430,7 @@ MyProjectCurveOnSurfTmExt( int nCurveId, int nSurfTmId, int nGuideId, int nDestG
Frame3d frStm ;
if ( ! pGeomDB->GetGlobFrame( nSurfTmId, frStm))
return false ;
// recupero l'entità guida (punto, curva o superficie) e il suo riferimento
// recupero l'entità guida (punto, curva o superficie) e il suo riferimento
const IGeoPoint3d* pGdePnt = nullptr ;
const ICurve* pGdeCrv = nullptr ;
const ISurfTriMesh* pGdeStm = nullptr ;
@@ -2455,7 +2455,7 @@ MyProjectCurveOnSurfTmExt( int nCurveId, int nSurfTmId, int nGuideId, int nDestG
CurveLocal CrvLoc( pCrv, frCrv, frStm) ;
if ( CrvLoc.Get() == nullptr)
return false ;
// eseguo l'opportuna proiezione dopo aver portato l'entità guida nel riferimento della superficie
// eseguo l'opportuna proiezione dopo aver portato l'entità guida nel riferimento della superficie
PNT5AXVECTOR vPt5ax ;
if ( pGdePnt != nullptr) {
PtrOwner<IGeoPoint3d> pGdeLoc( pGdePnt->Clone()) ;
@@ -2654,7 +2654,7 @@ MyProjectCurveOnSurfBzExt( int nCurveId, int nSurfBzId, int nGuideId, int nDestG
Frame3d frSbz ;
if ( ! pGeomDB->GetGlobFrame( nSurfBzId, frSbz))
return false ;
// recupero l'entità guida (punto, curva o superficie) e il suo riferimento
// recupero l'entità guida (punto, curva o superficie) e il suo riferimento
const IGeoPoint3d* pGdePnt = nullptr ;
const ICurve* pGdeCrv = nullptr ;
const ISurfTriMesh* pGdeStm = nullptr ;
@@ -2679,7 +2679,7 @@ MyProjectCurveOnSurfBzExt( int nCurveId, int nSurfBzId, int nGuideId, int nDestG
CurveLocal CrvLoc( pCrv, frCrv, frSbz) ;
if ( CrvLoc.Get() == nullptr)
return false ;
// eseguo l'opportuna proiezione dopo aver portato l'entità guida nel riferimento della superficie
// eseguo l'opportuna proiezione dopo aver portato l'entità guida nel riferimento della superficie
PNT5AXVECTOR vPt5ax ;
if ( pGdePnt != nullptr) {
PtrOwner<IGeoPoint3d> pGdeLoc( pGdePnt->Clone()) ;
@@ -2763,17 +2763,17 @@ ExeProjectCurveOnSurfBzExt( int nCurveId, int nSurfBzId, int nGuideId, int nDest
//----------------------------------------------------------------------------
int
ExeCurveGetVoronoi( int nId, int nDestGrpId, int nBound, int* pnCount)
ExeCurveGetVoronoi( const INTVECTOR& vIds, int nDestGrpId, int nBound, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCrv == nullptr)
return GDB_ID_NULL ;
// recupero il riferimento della curva
if ( vIds.empty())
return false ;
// recupero il riferimento della prima curva che sarà utilizzato da Voronoi
Frame3d frCrv ;
if ( ! pGeomDB->GetGlobFrame( nId, frCrv))
if ( ! pGeomDB->GetGlobFrame( vIds[0], frCrv))
return GDB_ID_NULL ;
// recupero il riferimento di destinazione
Frame3d frDest ;
@@ -2782,7 +2782,32 @@ ExeCurveGetVoronoi( int nId, int nDestGrpId, int nBound, int* pnCount)
// Calcolo diagramma di Voronoi
ICURVEPOVECTOR vCrv ;
CalcCurveVoronoiDiagram( *pCrv, vCrv, nBound) ;
if ( int( vIds.size()) == 1) {
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( vIds[0])) ;
if ( pCrv == nullptr)
return GDB_ID_NULL ;
// calcolo
CalcCurveVoronoiDiagram( *pCrv, vCrv, nBound) ;
}
else {
// recupero le curve e le porto in locale al frame della prima curva
CICURVEPVECTOR vOrigCrvs ;
for ( int i = 0 ; i < int( vIds.size()) ; i ++) {
CurveLocal CrvLoc( pGeomDB, vIds[i], frCrv) ;
if ( CrvLoc.Get() == nullptr) {
for ( auto pCrv : vOrigCrvs)
delete( pCrv) ;
return GDB_ID_NULL ;
}
vOrigCrvs.emplace_back( CrvLoc->Clone()) ;
}
// calcolo
CalcCurvesVoronoiDiagram( vOrigCrvs, vCrv, nBound) ;
// libero la memoria
for ( auto pCrv : vOrigCrvs)
delete( pCrv) ;
}
// inserisco i risultati nel DB geometrico
int nFirstId = GDB_ID_NULL ;
@@ -2799,7 +2824,7 @@ ExeCurveGetVoronoi( int nId, int nDestGrpId, int nBound, int* pnCount)
ExeSetModified() ;
if ( IsCmdLog()) {
string sLua = "EgtCurveGetVoronoi(" + ToString( nId) + "," +
string sLua = "EgtCurveGetVoronoi(" + ToString( vIds[0]) + "," +
ToString( nDestGrpId) + ")" +
" FirstId=" + ToString( nFirstId) + " nCurveCount=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
@@ -2813,26 +2838,51 @@ ExeCurveGetVoronoi( int nId, int nDestGrpId, int nBound, int* pnCount)
//----------------------------------------------------------------------------
int
ExeCurveGetMedialAxis( int nId, int nDestGrpId, int nSide, int* pnCount)
ExeCurveGetMedialAxis( const INTVECTOR& vIds, int nDestGrpId, int nSide, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCrv == nullptr)
return GDB_ID_NULL ;
// recupero il riferimento della curva
if ( vIds.empty())
return false ;
// recupero il riferimento della prima curva che sarà utilizzato da Voronoi
Frame3d frCrv ;
if ( ! pGeomDB->GetGlobFrame( nId, frCrv))
if ( ! pGeomDB->GetGlobFrame( vIds[0], frCrv))
return GDB_ID_NULL ;
// recupero il riferimento di destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest))
return GDB_ID_NULL ;
return GDB_ID_NULL ;
// Calcolo il Medial Axis
ICURVEPOVECTOR vCrv ;
CalcCurveMedialAxis( *pCrv, vCrv, nSide) ;
if ( int( vIds.size()) == 1) {
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( vIds[0])) ;
if ( pCrv == nullptr)
return GDB_ID_NULL ;
// calcolo
CalcCurveMedialAxis( *pCrv, vCrv, nSide) ;
}
else {
// recupero le curve e le porto in locale al frame della prima curva
CICURVEPVECTOR vOrigCrvs ;
for ( int i = 0 ; i < int( vIds.size()) ; i ++) {
CurveLocal CrvLoc( pGeomDB, vIds[i], frCrv) ;
if ( CrvLoc.Get() == nullptr) {
for ( auto pCrv : vOrigCrvs)
delete( pCrv) ;
return GDB_ID_NULL ;
}
vOrigCrvs.emplace_back( CrvLoc->Clone()) ;
}
// calcolo
CalcCurvesMedialAxis( vOrigCrvs, vCrv, nSide) ;
// libero la memoria
for ( auto pCrv : vOrigCrvs)
delete( pCrv) ;
}
// inserisco i risultati nel DB geometrico
int nFirstId = GDB_ID_NULL ;
@@ -2849,7 +2899,7 @@ ExeCurveGetMedialAxis( int nId, int nDestGrpId, int nSide, int* pnCount)
ExeSetModified() ;
if ( IsCmdLog()) {
string sLua = "EgtCurveMedialAxisAdv(" + ToString( nId) + "," +
string sLua = "EgtCurveMedialAxisAdv(" + ToString( vIds[0]) + "," +
ToString( nSide) + "," +
ToString( nDestGrpId) + ")" +
" FirstId=" + ToString( nFirstId) + " nCurveCount=" + ToString( nCount) ;
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -1205,7 +1205,7 @@ LuaCreateSurfBzRuled( lua_State* L)
LuaCheckParam( L, 4, nRuledType)
bool bCapEnds = false ;
int nPar = 5 ;
if( LuaGetParam( L, nPar, bCapEnds))
if ( LuaGetParam( L, nPar, bCapEnds))
++ nPar ;
double dLinTol = LIN_TOL_SRF ;
LuaGetParam( L, nPar, dLinTol) ;
+8 -8
View File
@@ -1093,9 +1093,9 @@ LuaProjectCurveOnSurfBzExt( lua_State* L)
static int
LuaCurveGetVoronoi( lua_State* L)
{
// 2 o 3 parametri : Id, nDestGrpId [, nBound]
int nId ;
LuaCheckParam( L, 1, nId)
// 2 o 3 parametri : Id/s, nDestGrpId [, nBound]
INTVECTOR vIds ;
LuaCheckParam( L, 1, vIds)
int nDestGrpId ;
LuaCheckParam( L, 2, nDestGrpId)
int nBound = 3 ; // VORONOI_STD_BOUND
@@ -1103,7 +1103,7 @@ LuaCurveGetVoronoi( lua_State* L)
LuaClearStack( L) ;
// eseguo
int nCount = 0 ;
int nNewId = ExeCurveGetVoronoi( nId, nDestGrpId, nBound, &nCount) ;
int nNewId = ExeCurveGetVoronoi( vIds, nDestGrpId, nBound, &nCount) ;
if ( nNewId != GDB_ID_NULL)
LuaSetParam( L, nNewId) ;
else
@@ -1117,9 +1117,9 @@ LuaCurveGetVoronoi( lua_State* L)
static int
LuaCurveMedialAxisAdv( lua_State* L)
{
// 2 o 3 parametri : Id, nDestGrpId [, nSide]
int nId ;
LuaCheckParam( L, 1, nId)
// 2 o 3 parametri : Id/s, nDestGrpId [, nSide]
INTVECTOR vIds ;
LuaCheckParam( L, 1, vIds)
int nDestGrpId ;
LuaCheckParam( L, 2, nDestGrpId)
int nSide = 1 ; // WMAT_LEFT
@@ -1127,7 +1127,7 @@ LuaCurveMedialAxisAdv( lua_State* L)
LuaClearStack( L) ;
// eseguo
int nCount = 0 ;
int nNewId = ExeCurveGetMedialAxis( nId, nDestGrpId, nSide, &nCount) ;
int nNewId = ExeCurveGetMedialAxis( vIds, nDestGrpId, nSide, &nCount) ;
if ( nNewId != GDB_ID_NULL)
LuaSetParam( L, nNewId) ;
else