Compare commits
101 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a4b66af304 | |||
| 0a5d655bfc | |||
| 6393817f41 | |||
| f871bfedc9 | |||
| e38b065357 | |||
| 704a977475 | |||
| 51fb1f4993 | |||
| dbb751a441 | |||
| 6a4b4feff5 | |||
| 6f1f3441ea | |||
| b955b12f38 | |||
| 9286ab6535 | |||
| ffe3d44cac | |||
| dd23b848ac | |||
| 33cca03698 | |||
| d4d14dd866 | |||
| d6f0fdac50 | |||
| 080605510c | |||
| 1a7b789ef3 | |||
| cc4183a677 | |||
| c2bae56656 | |||
| 38a5c0cbb3 | |||
| 81a8eb698e | |||
| ee4bb7d7c4 | |||
| 8b0d5bddbf | |||
| ba75033f0a | |||
| eb2b90c6f2 | |||
| 3b5c34cb05 | |||
| 2fe22a62c2 | |||
| ff6307fcca | |||
| c6e80a0b6a | |||
| b957cc75be | |||
| fc18539472 | |||
| de7229aee7 | |||
| 53e66032a0 | |||
| 2fc6c30c8f | |||
| f05c5f1261 | |||
| 6af5591cf6 | |||
| 41cbe862e5 | |||
| 057b8273e2 | |||
| 6421c12408 | |||
| 0aca5aeb07 | |||
| bdbd3583b8 | |||
| 626d5b0e51 | |||
| 0bffa0039c | |||
| 9819c8cee8 | |||
| 53ab676750 | |||
| afa4872c97 | |||
| bf56d53faf | |||
| f03adb9206 | |||
| 529fa2e4a0 | |||
| 6df1b90e95 | |||
| 9cba0e6d15 | |||
| f16de3a20c | |||
| 8cfa41d09f | |||
| b59b501366 | |||
| 504bb50b13 | |||
| 969f1266e7 | |||
| fa680b7799 | |||
| e185c85d5e | |||
| acb0a5bd5e | |||
| 62ce576d4d | |||
| 161d3d9b17 | |||
| d88baa070f | |||
| 2b087dde51 | |||
| 7894a8fdc8 | |||
| 0f14e8335a | |||
| 7edf4bced8 | |||
| 4a5639780b | |||
| 0a21a582be | |||
| 0e663c02c4 | |||
| 21afe8165c | |||
| 0247fe5e7c | |||
| 50bad83fba | |||
| 9c93d6c2f3 | |||
| 4d9a50cf94 | |||
| bbdaac5d8d | |||
| 0417c43bcf | |||
| 15585b8f11 | |||
| 59755ec8a5 | |||
| b16dd260d8 | |||
| d37a5a37b7 | |||
| 79dfb4ae87 | |||
| 8b75b6e4c3 | |||
| bcaad08b61 | |||
| cbdeffd93a | |||
| 0ce477a3e7 | |||
| 44eb4d1834 | |||
| 2e26b73208 | |||
| de3fa3201e | |||
| f068aafbb5 | |||
| daedb07135 | |||
| 702e1e446d | |||
| ea87db1ae1 | |||
| b65800843a | |||
| e4c5d8645d | |||
| 85b06c29b4 | |||
| 5254d0c5ca | |||
| 9d038142a8 | |||
| c5573e438b | |||
| 8c7a0ac026 |
+152
-109
@@ -311,7 +311,6 @@ TestEdgesClosedPolyLines( POLYLINEVECTOR& vPL, const CAvToolSurfTm& cavTstm, int
|
||||
const Frame3d& frGrid, double dDimZ, double dLevel, double dStep, double dAngTol,
|
||||
bool bAdvCorners)
|
||||
{
|
||||
|
||||
// se non ho polylinee, allora esco
|
||||
if ( vPL.empty())
|
||||
return true ;
|
||||
@@ -341,10 +340,45 @@ TestEdgesClosedPolyLines( POLYLINEVECTOR& vPL, const CAvToolSurfTm& cavTstm, int
|
||||
if ( ! CalcRegionPolyLines( vPL, vtN, mIndMat, vbInv))
|
||||
return false ;
|
||||
|
||||
#if ENABLE_SHARPED_EDGES_DEBUG
|
||||
vector<vector<IGeoObj*>> vvpGObj ; vvpGObj.resize( 7) ;
|
||||
vector<vector<Color>> vvCol ; vvCol.resize( 7) ;
|
||||
// ombra del tool
|
||||
PtrOwner<ICurveArc> pCrvToolShape( CreateCurveArc()) ;
|
||||
pCrvToolShape->Set( ORIG, Z_AX, cavTstm.GetToolRadius()) ;
|
||||
// 1° gruppo, griglia di punti
|
||||
for ( int j = 0 ; j <= nStepY ; ++ j) {
|
||||
for ( int i = 0 ; i <= nStepX ; ++ i) {
|
||||
Point3d ptP = Point3d( i * dStep, j * dStep, dDimZ) ;
|
||||
PtrOwner<IGeoPoint3d> myPtGrid( CreateGeoPoint3d()) ;
|
||||
myPtGrid->Set( ptP) ;
|
||||
vvpGObj[0].emplace_back( static_cast<IGeoObj*>( Release( myPtGrid))) ;
|
||||
vvCol[0].emplace_back( BLUE) ;
|
||||
}
|
||||
}
|
||||
// 2° gruppo, superfici
|
||||
CISURFTMPVECTOR myStmVector = cavTstm.GetvStm() ;
|
||||
for ( int i = 0 ; i < int( myStmVector.size()) ; ++ i) {
|
||||
PtrOwner<ISurfTriMesh> pMyStm( CloneSurfTriMesh( myStmVector[i])) ;
|
||||
if ( ! IsNull( pMyStm)) {
|
||||
pMyStm->ToLoc( frGrid) ;
|
||||
vvpGObj[1].emplace_back( static_cast<IGeoObj*>( Release( pMyStm))) ;
|
||||
vvCol[1].emplace_back( Color( 0., 1., 0., .5)) ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// vettore delle polyline visitate ( viste però come curve composite)
|
||||
ICRVCOMPOPOVECTOR vPL_AsCompo ; vPL_AsCompo.reserve( vPL.size()) ;
|
||||
|
||||
// scorro i Chunk della matrice di interi, quindi le righe
|
||||
for ( int nChunk = 0 ; nChunk < int( mIndMat.size()) ; ++ nChunk) {
|
||||
// scorro le PolyLinee presenti nel Chunk
|
||||
for ( int nPol = 0 ; nPol < int( vPL.size()) ; ++ nPol) {
|
||||
for ( int nLoop = 0 ; nLoop < int( mIndMat[nChunk].size()) ; ++ nLoop) {
|
||||
// recupero l'indice della PolyLine di riferimento
|
||||
int nPol = mIndMat[nChunk][nLoop] ;
|
||||
if ( nPol < 0 || nPol >= int( vPL.size()))
|
||||
return false ;
|
||||
// essendo chiusa, se presenti meno di 4 punti, non faccio nulla
|
||||
int nPts = vPL[nPol].GetPointNbr() ;
|
||||
if ( nPts < 4)
|
||||
@@ -380,33 +414,6 @@ TestEdgesClosedPolyLines( POLYLINEVECTOR& vPL, const CAvToolSurfTm& cavTstm, int
|
||||
vAdvPt.emplace_back( make_pair( myPt, PointType::VALID)) ;
|
||||
|
||||
#if ENABLE_SHARPED_EDGES_DEBUG
|
||||
vector<vector<IGeoObj*>> vvpGObj ; vvpGObj.resize( 7) ;
|
||||
vector<vector<Color>> vvCol ; vvCol.resize( 7) ;
|
||||
// ombra del tool
|
||||
PtrOwner<ICurveArc> pCrvToolShape( CreateCurveArc()) ;
|
||||
pCrvToolShape->Set( ORIG, Z_AX, cavTstm.GetToolRadius()) ;
|
||||
// 1° gruppo, griglia di punti
|
||||
for ( int j = 0 ; j <= nStepY ; ++ j) {
|
||||
for ( int i = 0 ; i <= nStepX ; ++ i) {
|
||||
Point3d ptP = Point3d( i * dStep, j * dStep, dDimZ) ;
|
||||
PtrOwner<IGeoPoint3d> myPtGrid( CreateGeoPoint3d()) ;
|
||||
myPtGrid->Set( ptP) ;
|
||||
vvpGObj[0].emplace_back( static_cast<IGeoObj*>( Release( myPtGrid))) ;
|
||||
vvCol[0].emplace_back( BLUE) ;
|
||||
break ;
|
||||
}
|
||||
break ;
|
||||
}
|
||||
// 2° gruppo, superfici
|
||||
CISURFTMPVECTOR myStmVector = cavTstm.GetvStm() ;
|
||||
for ( int i = 0 ; i < int( myStmVector.size()) ; ++ i) {
|
||||
PtrOwner<ISurfTriMesh> pMyStm( CloneSurfTriMesh( myStmVector[i])) ;
|
||||
if ( ! IsNull( pMyStm)) {
|
||||
pMyStm->ToLoc( frGrid) ;
|
||||
vvpGObj[1].emplace_back( static_cast<IGeoObj*>( Release( pMyStm))) ;
|
||||
vvCol[1].emplace_back( Color( 0., 1., 0., .5)) ;
|
||||
}
|
||||
}
|
||||
// 3° gruppo, punti della PolyLine
|
||||
for ( int i = 0 ; i < int( vAdvPt.size()) ; ++ i) {
|
||||
PtrOwner<IGeoPoint3d> myPt( CreateGeoPoint3d()) ;
|
||||
@@ -416,23 +423,23 @@ TestEdgesClosedPolyLines( POLYLINEVECTOR& vPL, const CAvToolSurfTm& cavTstm, int
|
||||
}
|
||||
#endif
|
||||
|
||||
// modifico la posizione dei punti
|
||||
if ( ! ModifyPolyLineToSharped( vAdvPt, cavTstm, frGrid, dAngTol, dStep, dSegLen))
|
||||
return false ;
|
||||
// modifico la posizione dei punti
|
||||
if ( ! ModifyPolyLineToSharped( vAdvPt, cavTstm, frGrid, dAngTol, dStep, dSegLen))
|
||||
return false ;
|
||||
|
||||
// ricostrusico la polyLine
|
||||
vPL[nPol].Clear() ;
|
||||
// ricostrusico la polyLine a partire da una vuota
|
||||
PolyLine PL_New ;
|
||||
double dPar = -1 ;
|
||||
for ( int j = 0 ; j < int( vAdvPt.size()) ; ++ j) {
|
||||
// se punto valido o sharped di angolo interno, lo aggiungo
|
||||
if ( j == 0 || j == int( vAdvPt.size() - 1) ||
|
||||
vAdvPt[j].second == PointType::VALID || vAdvPt[j].second == PointType::SHARPED_INT)
|
||||
vPL[nPol].AddUPoint( ++ dPar, vAdvPt[j].first) ;
|
||||
PL_New.AddUPoint( ++ dPar, vAdvPt[j].first) ;
|
||||
// se è un punto sharped di un angolo esterno
|
||||
else if ( vAdvPt[j].second == PointType::SHARPED_EXT) {
|
||||
// se non richiesto il calcolo avanzato del punto a minima distanza dallo spigolo, aggiungo il punto
|
||||
if ( ! bAdvCorners)
|
||||
vPL[nPol].AddUPoint( ++ dPar, vAdvPt[j].first) ;
|
||||
PL_New.AddUPoint( ++ dPar, vAdvPt[j].first) ;
|
||||
else {
|
||||
// ricavo il punto a minima distanza dal materiale mediante metodo di bisezione
|
||||
Vector3d vtPrev = ( vAdvPt[j-1].first - vAdvPt[j].first) ;
|
||||
@@ -463,51 +470,29 @@ TestEdgesClosedPolyLines( POLYLINEVECTOR& vPL, const CAvToolSurfTm& cavTstm, int
|
||||
DistPointLine distPtLSucc( ptTest, vAdvPt[j].first, vAdvPt[j+1].first) ;
|
||||
distPtLPrev.GetMinDistPoint( ptMinDistA) ;
|
||||
distPtLSucc.GetMinDistPoint( ptMinDistB) ;
|
||||
vPL[nPol].AddUPoint( ++ dPar, ptMinDistA) ;
|
||||
vPL[nPol].AddUPoint( ++ dPar, ptTest) ;
|
||||
vPL[nPol].AddUPoint( ++ dPar, ptMinDistB) ;
|
||||
}
|
||||
PL_New.AddUPoint( ++ dPar, ptMinDistA) ;
|
||||
PL_New.AddUPoint( ++ dPar, ptTest) ;
|
||||
PL_New.AddUPoint( ++ dPar, ptMinDistB) ;
|
||||
|
||||
#if ENABLE_SHARPED_EDGES_DEBUG
|
||||
// 5° gruppo, punti minDist A e B e ptMid
|
||||
/*PtrOwner<IGeoPoint3d> myPtA( CreateGeoPoint3d()) ;
|
||||
myPtA->Set( ptMinDistA) ;
|
||||
vvpGObj[4].emplace_back( static_cast<IGeoObj*>( Release( myPtA))) ;
|
||||
vvCol[4].emplace_back( BROWN) ;
|
||||
PtrOwner<IGeoPoint3d> myPtB( CreateGeoPoint3d()) ;
|
||||
myPtB->Set( ptMinDistB) ;
|
||||
vvpGObj[4].emplace_back( static_cast<IGeoObj*>( Release( myPtB))) ;
|
||||
vvCol[4].emplace_back( BROWN) ;
|
||||
PtrOwner<IGeoPoint3d> myPtMid( CreateGeoPoint3d()) ;
|
||||
myPtMid->Set( ptTest) ;
|
||||
vvpGObj[4].emplace_back( static_cast<IGeoObj*>( Release( myPtMid))) ;
|
||||
vvCol[4].emplace_back( BROWN) ;*/
|
||||
#endif
|
||||
#if ENABLE_SHARPED_EDGES_DEBUG
|
||||
// 5° gruppo, punti minDist A e B e ptMid
|
||||
PtrOwner<IGeoPoint3d> myPtA( CreateGeoPoint3d()) ;
|
||||
myPtA->Set( ptMinDistA) ;
|
||||
vvpGObj[4].emplace_back( static_cast<IGeoObj*>( Release( myPtA))) ;
|
||||
vvCol[4].emplace_back( BROWN) ;
|
||||
PtrOwner<IGeoPoint3d> myPtB( CreateGeoPoint3d()) ;
|
||||
myPtB->Set( ptMinDistB) ;
|
||||
vvpGObj[4].emplace_back( static_cast<IGeoObj*>( Release( myPtB))) ;
|
||||
vvCol[4].emplace_back( BROWN) ;
|
||||
PtrOwner<IGeoPoint3d> myPtMid( CreateGeoPoint3d()) ;
|
||||
myPtMid->Set( ptTest) ;
|
||||
vvpGObj[4].emplace_back( static_cast<IGeoObj*>( Release( myPtMid))) ;
|
||||
vvCol[4].emplace_back( BROWN) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// riposiziono la polyLine
|
||||
#if ENABLE_SHARPED_EDGES_DEBUG
|
||||
// 6° gruppo, curve composita derivante dalla polyline
|
||||
PtrOwner<ICurveComposite> pCrvCompoPoly( CreateCurveComposite()) ;
|
||||
pCrvCompoPoly->FromPolyLine( vPL[nPol]) ;
|
||||
//pCrvCompoPoly->SetExtrusion( frGrid.VersZ()) ;
|
||||
vvpGObj[5].emplace_back( static_cast<IGeoObj*>( CloneCurveComposite( pCrvCompoPoly))) ;
|
||||
vvCol[5].emplace_back( RED) ;
|
||||
// 7° gruppo, controOffset
|
||||
OffsetCurve offsCrv ;
|
||||
offsCrv.Make( pCrvCompoPoly, - ( cavTstm.GetToolRadius() - 2 * EPS_SMALL), ICurve::OFF_EXTEND) ;
|
||||
pCrvCompoPoly.Set( ConvertCurveToComposite( offsCrv.GetLongerCurve())) ;
|
||||
vvpGObj[6].emplace_back( static_cast<IGeoObj*>( Release( pCrvCompoPoly))) ;
|
||||
vvCol[6].emplace_back( WHITE) ;
|
||||
string myName = Sharped_Edges_Debug_File_Name +
|
||||
to_string( nChunk) + "_" +
|
||||
to_string( nPol) + "_" +
|
||||
to_string( dLevel) + "_" +
|
||||
to_string( dAngTol) + ".nge" ;
|
||||
SaveGeoObj( vvpGObj, vvCol, myName) ;
|
||||
#endif
|
||||
|
||||
// se la polyLinea si autointerseca, allora non la modifico ( essendo a distanza R dalla
|
||||
// trimesh rischio di evere Chunk distinti uniti in un unico Chunk
|
||||
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
@@ -515,11 +500,53 @@ TestEdgesClosedPolyLines( POLYLINEVECTOR& vPL, const CAvToolSurfTm& cavTstm, int
|
||||
return false ;
|
||||
pCompo->FromPolyLine( vPL[nPol]) ;
|
||||
SelfIntersCurve SIC( *pCompo) ;
|
||||
if ( SIC.GetCrossOrOverlapIntersCount() > 0)
|
||||
continue ;
|
||||
bool bDiscard = ( SIC.GetCrossOrOverlapIntersCount() > 0) ;
|
||||
if ( ! bDiscard) {
|
||||
// se la polyLine interseca una delle PolyLine precedenti, non la modifico
|
||||
for ( auto& pCompoPL_Prev : vPL_AsCompo) {
|
||||
IntersCurveCurve ICC( *pCompo, *pCompoPL_Prev) ;
|
||||
if ( ICC.GetCrossOrOverlapIntersCount() > 0) {
|
||||
bDiscard = true ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// se nuova approssimazione da conservare, memorizzo i risultati
|
||||
if ( ! bDiscard) {
|
||||
vPL[nPol] = PL_New ;
|
||||
vPL_AsCompo.emplace_back( Release( pCompo)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_SHARPED_EDGES_DEBUG
|
||||
ICURVEPVECTOR vpCrv ; vpCrv.reserve( vPL.size()) ;
|
||||
for ( const auto& PL : vPL) {
|
||||
// 6° gruppo, curve composita derivante dalla polyline
|
||||
PtrOwner<ICurveComposite> pCrvCompoPoly( CreateCurveComposite()) ;
|
||||
pCrvCompoPoly->FromPolyLine( PL) ;
|
||||
vvpGObj[5].emplace_back( static_cast<IGeoObj*>( CloneCurveComposite( pCrvCompoPoly))) ;
|
||||
vvCol[5].emplace_back( RED) ;
|
||||
vpCrv.emplace_back( Release( pCrvCompoPoly)) ;
|
||||
}
|
||||
// 7° gruppo, controOffset
|
||||
ICURVEPOVECTOR vCrvCompoOffs ;
|
||||
if ( ! CalcOffsetCurves( vpCrv, vCrvCompoOffs, - ( cavTstm.GetToolRadius() - 2 * EPS_SMALL), ICurve::OFF_EXTEND)) {
|
||||
for ( auto& pCrv : vpCrv) { delete( pCrv) ; pCrv = nullptr ;}
|
||||
return false ;
|
||||
}
|
||||
for ( auto& pCrv : vpCrv) { delete( pCrv) ; pCrv = nullptr ;}
|
||||
for ( const auto& pCvrOffs : vCrvCompoOffs) {
|
||||
vvpGObj[6].emplace_back( static_cast<IGeoObj*>( CloneCurveComposite( pCvrOffs))) ;
|
||||
vvCol[6].emplace_back( WHITE) ;
|
||||
}
|
||||
string myName = Sharped_Edges_Debug_File_Name +
|
||||
to_string( dLevel) + "_" +
|
||||
to_string( dAngTol) + ".nge" ;
|
||||
SaveGeoObj( vvpGObj, vvCol, myName) ;
|
||||
#endif
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -785,21 +812,31 @@ MarchingSquares( const DBLVECTOR& vdGrid, int nStepX, int nStepY, double dStep,
|
||||
if ( TestEdgesClosedPolyLines( vPL_Sharped, cavTstm, nStepX, nStepY, frGrid, dDimZ, dLevel, dStep, ANG_TOL_STD_DEG, false))
|
||||
swap( vPL_Sharped, vPL) ;
|
||||
|
||||
// se vettore di PolyLine vuoto, non faccio nulla
|
||||
if ( vPL.empty())
|
||||
return true ;
|
||||
|
||||
// se non ho impostato un utensile, devo effettuare un contro-offset
|
||||
if ( ! bTool) {
|
||||
POLYLINEVECTOR vPL_Offs ;
|
||||
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
|
||||
CurveComposite crvCompo ;
|
||||
if ( ! crvCompo.FromPolyLine( vPL[i]))
|
||||
return false ;
|
||||
OffsetCurve offsCompo ;
|
||||
offsCompo.Make( &crvCompo, - ( dRad - 2 * EPS_SMALL), ICurve::OFF_EXTEND) ;
|
||||
PtrOwner<ICurve> pCrvOffset( offsCompo.GetLongerCurve()) ;
|
||||
while ( ! IsNull( pCrvOffset)) {
|
||||
ICURVEPOVECTOR vpOwCrv ; vpOwCrv.reserve( vPL.size()) ;
|
||||
ICURVEPVECTOR vpCrv ; vpCrv.reserve( vPL.size()) ;
|
||||
for ( const auto& PL : vPL) {
|
||||
PtrOwner<ICurveComposite> pCrvCompoPoly( CreateCurveComposite()) ;
|
||||
pCrvCompoPoly->FromPolyLine( PL) ;
|
||||
vpOwCrv.emplace_back( Release( pCrvCompoPoly)) ;
|
||||
vpCrv.emplace_back( vpOwCrv.back()) ;
|
||||
}
|
||||
// calcolo l'Offset
|
||||
ICURVEPOVECTOR vpCrvOffs ;
|
||||
if ( ! CalcOffsetCurves( vpCrv, vpCrvOffs, - ( dRad - 2 * EPS_SMALL), ICurve::OFF_EXTEND))
|
||||
return false ;
|
||||
// resituisco le PolyLine
|
||||
POLYLINEVECTOR vPL_Offs ; vPL_Offs.reserve( vpCrvOffs.size()) ;
|
||||
for ( auto& pCrv : vpCrvOffs) {
|
||||
if ( pCrv != nullptr && pCrv->IsValid()) {
|
||||
PolyLine myPolyLine ;
|
||||
pCrvOffset->ApproxWithLines( 10 * EPS_SMALL, ANG_TOL_STD_DEG, ICurve::APL_STD, myPolyLine) ;
|
||||
pCrv->ApproxWithLines( 10 * EPS_SMALL, ANG_TOL_STD_DEG, ICurve::APL_STD, myPolyLine) ;
|
||||
vPL_Offs.emplace_back( myPolyLine) ;
|
||||
pCrvOffset.Set( offsCompo.GetLongerCurve()) ;
|
||||
}
|
||||
}
|
||||
swap( vPL_Offs, vPL) ;
|
||||
@@ -976,28 +1013,13 @@ CAvParSilhouettesSurfTm::Prepare( void)
|
||||
return false ;
|
||||
b3All.Add( b3Surf) ;
|
||||
}
|
||||
|
||||
// calcolo dati della griglia
|
||||
const double EXTRA_XY = ( m_bTool ? m_dRad + 2 : 1.5 * m_dTol) ;
|
||||
// espansione in Z del Box
|
||||
const double EXTRA_Z = 10 * m_dTol + ( m_dMaxDepth > EPS_SMALL ? max( 0., m_dMaxDepth - b3All.GetDimZ()) : 0) ;
|
||||
b3All.Expand( EXTRA_XY, EXTRA_XY, EXTRA_Z) ;
|
||||
m_nStepX = int( ceil( b3All.GetDimX() / m_dTol)) ;
|
||||
m_nStepY = int( ceil( b3All.GetDimY() / m_dTol)) ;
|
||||
m_frGrid.ChangeOrig( GetToGlob( b3All.GetMin(), m_frGrid)) ;
|
||||
b3All.Expand( 0., 0., EXTRA_Z) ;
|
||||
m_dDimZ = b3All.GetDimZ() ;
|
||||
m_dLevelOffs = - b3All.GetMin().z ;
|
||||
|
||||
// calcolo dei punti della griglia (sul top del cilindro)
|
||||
PNTUVECTOR vPntM( ( m_nStepX + 1) * ( m_nStepY + 1)) ;
|
||||
for ( int j = 0 ; j <= m_nStepY ; ++ j) {
|
||||
for ( int i = 0 ; i <= m_nStepX ; ++ i) {
|
||||
int nInd = i + j * ( m_nStepX + 1) ;
|
||||
Point3d ptP = GetToGlob( Point3d( i * m_dTol, j * m_dTol, m_dDimZ), m_frGrid) ;
|
||||
vPntM[nInd] = { ptP, 0.} ;
|
||||
}
|
||||
}
|
||||
|
||||
// esecuzione della verifica
|
||||
// set utensile corrente per calcolo delle collisioni
|
||||
double dExtraXY = m_dRad ;
|
||||
if ( m_dSideAng < EPS_ANG_SMALL)
|
||||
m_cavTstm.SetStdTool( m_dDimZ + m_dOffsR, m_dRad + m_dOffsR, m_dCornRad + m_dOffsR) ;
|
||||
else {
|
||||
@@ -1015,8 +1037,29 @@ CAvParSilhouettesSurfTm::Prepare( void)
|
||||
|
||||
double dStemRad = m_dRad + dDeltaRad ;
|
||||
double dTipRad = m_dRad ;
|
||||
dExtraXY = dStemRad ;
|
||||
m_cavTstm.SetAdvTool( m_dDimZ + m_dOffsR, dStemRad + m_dOffsR, m_dMaxMat, dTipRad + m_dOffsR, m_dCornRad + m_dOffsR) ;
|
||||
}
|
||||
|
||||
// calcolo dati della griglia
|
||||
const double EXTRA_XY = ( m_bTool ? dExtraXY + 2. : 1.5 * m_dTol) ;
|
||||
b3All.Expand( EXTRA_XY, EXTRA_XY, 0.) ;
|
||||
m_frGrid.ChangeOrig( GetToGlob( b3All.GetMin(), m_frGrid)) ;
|
||||
m_dLevelOffs = - b3All.GetMin().z ;
|
||||
m_nStepX = int( ceil( b3All.GetDimX() / m_dTol)) ;
|
||||
m_nStepY = int( ceil( b3All.GetDimY() / m_dTol)) ;
|
||||
|
||||
// calcolo dei punti della griglia (sul top del cilindro)
|
||||
PNTUVECTOR vPntM( ( m_nStepX + 1) * ( m_nStepY + 1)) ;
|
||||
for ( int j = 0 ; j <= m_nStepY ; ++ j) {
|
||||
for ( int i = 0 ; i <= m_nStepX ; ++ i) {
|
||||
int nInd = i + j * ( m_nStepX + 1) ;
|
||||
Point3d ptP = GetToGlob( Point3d( i * m_dTol, j * m_dTol, m_dDimZ), m_frGrid) ;
|
||||
vPntM[nInd] = { ptP, 0.} ;
|
||||
}
|
||||
}
|
||||
|
||||
// esecuzione verifica della collisione
|
||||
if ( m_vpStm.empty() || ! m_cavTstm.SetSurfTm( *( m_vpStm[0])))
|
||||
return false ;
|
||||
for ( int k = 1 ; k < int( m_vpStm.size()) ; ++ k)
|
||||
|
||||
+1434
-1098
File diff suppressed because it is too large
Load Diff
+89
-11
@@ -513,8 +513,13 @@ CurveToBezierCurve( const ICurve* pCrv, int nDeg, bool bMakeRatOrNot)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurveBezier*
|
||||
LineToBezierCurve( const ICurveLine* pCrvLine, int nDeg, bool bMakeRatOrNot)
|
||||
LineToBezierCurve( const ICurve* pCrv, int nDeg, bool bMakeRatOrNot)
|
||||
{
|
||||
// verifico sia una linea
|
||||
const CurveLine* pCrvLine = GetBasicCurveLine( pCrv) ;
|
||||
if ( pCrvLine == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
PtrOwner<ICurveBezier> pCrvBezier( CreateCurveBezier()) ;
|
||||
// rendo tutte le curve di grado 2 e razionali così posso convertire anche archi e avere tutte curve dello stesso grado e razionali
|
||||
pCrvBezier->Init( nDeg, true) ;
|
||||
@@ -560,7 +565,7 @@ ArcToBezierCurve( const ICurve* pCrv, int nDeg, bool bMakeRatOrNot)
|
||||
nParts = max( nParts, 2) ;
|
||||
for ( int i = 0 ; i < nParts ; ++ i) {
|
||||
// copio l'arco originale
|
||||
CurveArc cArc = *pArc ;
|
||||
CurveArc cArc = *GetBasicCurveArc(pArc->Clone()) ;
|
||||
// lo limito alla parte di interesse
|
||||
cArc.TrimStartEndAtParam( i / double( nParts), ( i + 1) / double( nParts)) ;
|
||||
// creo la curva di Bezier equivalente
|
||||
@@ -584,8 +589,13 @@ ArcToBezierCurve( const ICurve* pCrv, int nDeg, bool bMakeRatOrNot)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
CompositeToBezierCurve( const ICurveComposite* pCC, int nDeg, bool bMakeRatOrNot)
|
||||
CompositeToBezierCurve( const ICurve* pCrv, int nDeg, bool bMakeRatOrNot)
|
||||
{
|
||||
// verifico sia una composita
|
||||
const CurveComposite* pCC = GetBasicCurveComposite( pCrv) ;
|
||||
if ( pCC == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
// converto tutte le curve in bezier razionali di grado 2
|
||||
PtrOwner<ICurveComposite> pCCBezier( CreateCurveComposite()) ;
|
||||
for ( int i = 0 ; i < int( pCC->GetCurveCount()) ; ++i) {
|
||||
@@ -620,10 +630,15 @@ CompositeToBezierCurve( const ICurveComposite* pCC, int nDeg, bool bMakeRatOrNot
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
EditBezierCurve( const ICurveBezier* pCrvBezier, int nDeg, bool bMakeRatOrNot, double dTol)
|
||||
EditBezierCurve( const ICurve* pCrv, int nDeg, bool bMakeRatOrNot, double dTol)
|
||||
{
|
||||
// se nDeg == -1 allora viene mantenuto il grado della curva originale
|
||||
|
||||
// verifico sia una bezier
|
||||
const CurveBezier* pCrvBezier = GetBasicCurveBezier( pCrv) ;
|
||||
if ( pCrvBezier == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
if( nDeg == 2 || nDeg == 1)
|
||||
return nullptr ;
|
||||
|
||||
@@ -889,8 +904,13 @@ BezierDecreaseDegree(const ICurveBezier* pCrvBezier, double dTol)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
ApproxBezierWithCubics(const ICurveBezier* pCrvBezier, double dTol)
|
||||
ApproxBezierWithCubics(const ICurve* pCrv, double dTol)
|
||||
{
|
||||
// verifico sia una bezier
|
||||
const CurveBezier* pCrvBezier = GetBasicCurveBezier( pCrv) ;
|
||||
if ( pCrvBezier == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
// cerco di stimare quanti cambi di concavità ho
|
||||
// tiro una linea tra il primo punto di controllo e l'ultimo e poi scorro gli altri punti di controllo
|
||||
// controllando quante volte salto da un lato all'altro della linea
|
||||
@@ -1012,8 +1032,13 @@ ApproxBezierWithCubics(const ICurveBezier* pCrvBezier, double dTol)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurveBezier*
|
||||
ApproxCurveBezierWithSingleCubic( const ICurveBezier* pCrvBez)
|
||||
ApproxCurveBezierWithSingleCubic( const ICurve* pCrv)
|
||||
{
|
||||
// verifico sia una bezier
|
||||
const CurveBezier* pCrvBez = GetBasicCurveBezier( pCrv) ;
|
||||
if ( pCrvBez == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
Point3d ptStart, ptEnd ;
|
||||
pCrvBez->GetStartPoint( ptStart) ;
|
||||
pCrvBez->GetEndPoint( ptEnd) ;
|
||||
@@ -1042,8 +1067,13 @@ ApproxCurveBezierWithSingleCubic( const ICurveBezier* pCrvBez)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurveBezier*
|
||||
ApproxArcCurveBezierWithSingleCubic( const ICurveBezier* pCrvBez, const Point3d& ptCen)
|
||||
ApproxArcCurveBezierWithSingleCubic( const ICurve* pCrv, const Point3d& ptCen)
|
||||
{
|
||||
// verifico sia una bezier
|
||||
const CurveBezier* pCrvBez = GetBasicCurveBezier( pCrv) ;
|
||||
if ( pCrvBez == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
// converto una curva di bezier che definisce un arco perfetto di circonferenza
|
||||
// dato il centro( della circonferenza), inizio e fine
|
||||
// N.B. : per archi con angolo al centro < 90
|
||||
@@ -1086,7 +1116,9 @@ ApproxArcCurveBezierWithSingleCubic( const ICurveBezier* pCrvBez, const Point3d&
|
||||
ICurve*
|
||||
ApproxCurveWithBezier( const ICurve*, double dTol)
|
||||
{
|
||||
// interpolazione di punti con una curva bezier
|
||||
// campiono punti lungo la curva e poi li interpolo
|
||||
|
||||
// oppure faccio la fat curve e poi calcolo una bezier che stia all'interno di quella regione
|
||||
|
||||
PtrOwner<ICurveComposite> pCC( CreateBasicCurveComposite()) ;
|
||||
return Release( pCC) ;
|
||||
@@ -1262,7 +1294,7 @@ CurveToNoArcsCurve( const ICurve* pCrv)
|
||||
return nullptr ;
|
||||
// se arco, devo trasformarlo in curva di Bezier (semplice o composta)
|
||||
if ( pCrv->GetType() == CRV_ARC) {
|
||||
return ArcToBezierCurve( pCrv) ;
|
||||
return ArcToBezierCurve( GetCurveArc(pCrv)) ;
|
||||
}
|
||||
// se curva composita, devo trasformarla in composita senza archi
|
||||
else if ( pCrv->GetType() == CRV_COMPO) {
|
||||
@@ -2043,13 +2075,14 @@ CalcCurvesMedialAxis( const CICURVEPVECTOR& vCrvC, ICURVEPOVECTOR& vCrvs, int nS
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CalcCurveFatCurve( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, double dRadius, bool bSquareEnds, bool bSquareMids)
|
||||
CalcCurveFatCurve( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, double dRadius, bool bSquareEnds, bool bSquareMids,
|
||||
bool bMergeOnlySameProps)
|
||||
{
|
||||
Voronoi* pVoronoiObj = GetCurveVoronoi( crvC) ;
|
||||
if ( pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
|
||||
return pVoronoiObj->CalcFatCurve( vCrvs, dRadius, bSquareEnds, bSquareMids) ;
|
||||
return pVoronoiObj->CalcFatCurve( vCrvs, dRadius, bSquareEnds, bSquareMids, bMergeOnlySameProps) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -2086,6 +2119,51 @@ CalcCurveSingleCurvesOffset( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, double d
|
||||
return pVoronoiObj->CalcSingleCurvesOffset( vCrvs, dOffs) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool CalcOffsetCurves( const ICURVEPVECTOR& vpCrvs, ICURVEPOVECTOR& vCrvs, double dOffs, int nType)
|
||||
{
|
||||
// creo oggetto Voronoi con le curve passate
|
||||
PtrOwner<Voronoi> pVoronoiObj( new( std::nothrow) Voronoi()) ;
|
||||
if ( pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
for ( int i = 0 ; i < int( vpCrvs.size()) ; i ++) {
|
||||
if ( ! pVoronoiObj->AddCurve( vpCrvs[i]))
|
||||
return false ;
|
||||
}
|
||||
|
||||
return pVoronoiObj->CalcOffset( vCrvs, dOffs, nType) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool CalcFatOffsetCurves( const ICURVEPVECTOR& vpCrvs, ICURVEPOVECTOR& vCrvs, double dOffs,
|
||||
bool bSquareEnds, bool bSquareMids, bool bMergeOnlySameProps)
|
||||
{
|
||||
// controllo validità delle curve
|
||||
for ( auto& pCrv : vpCrvs) {
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
}
|
||||
// se offset nullo restituisco direttamente le curve
|
||||
if ( abs( dOffs) < EPS_SMALL) {
|
||||
for ( auto& pCrv : vpCrvs) {
|
||||
if ( ! vCrvs.emplace_back( pCrv->Clone()))
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
// creo oggetto Voronoi con le curve passate
|
||||
PtrOwner<Voronoi> pVoronoiObj( new( std::nothrow) Voronoi()) ;
|
||||
if ( pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
for ( int i = 0 ; i < int( vpCrvs.size()) ; i ++) {
|
||||
if ( ! pVoronoiObj->AddCurve( vpCrvs[i]))
|
||||
return false ;
|
||||
}
|
||||
|
||||
return pVoronoiObj->CalcFatCurve( vCrvs, dOffs, bSquareEnds, bSquareMids, bMergeOnlySameProps) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
ResetCurveVoronoi( const ICurve& crvC)
|
||||
|
||||
+1
-1
@@ -33,5 +33,5 @@ bool CurveGetArea( const ICurve& crvC, Plane3d& plPlane, double& dArea) ;
|
||||
bool CurveDump( const ICurve& crvC, std::string& sOut, bool bMM, const char* szNewLine) ;
|
||||
bool CopyExtrusion( const ICurve* pSouCrv, ICurve* pDestCrv) ;
|
||||
bool CopyThickness( const ICurve* pSouCrv, ICurve* pDestCrv) ;
|
||||
ICurveBezier* ApproxCurveBezierWithSingleCubic( const ICurveBezier* pCrvBez) ;
|
||||
ICurveBezier* ApproxCurveBezierWithSingleCubic( const ICurve* pCrv) ;
|
||||
Voronoi* GetCurveVoronoi( const ICurve& crvC) ;
|
||||
|
||||
@@ -2383,3 +2383,11 @@ CurveBezier::IsALine( void) const
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
PNTVECTOR
|
||||
CurveBezier::GetAllControlPoints( void) const
|
||||
{
|
||||
PNTVECTOR vPntCtrl = m_vPtCtrl ;
|
||||
return vPntCtrl ;
|
||||
}
|
||||
@@ -153,6 +153,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
bool MakeRationalStandardForm( void) override ;
|
||||
bool MakeNonRational( double dTol) override ;
|
||||
bool IsALine( void) const override ;
|
||||
PNTVECTOR GetAllControlPoints( void) const ; // non aggiunta in interfaccia
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
|
||||
+5
-2
@@ -502,8 +502,9 @@ CurveByApprox::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAng
|
||||
m_vPrevDer[nI].ToSpherical( nullptr, nullptr, &dDir1Deg) ;
|
||||
// costruisco un biarco sulla polilinea (secondo metodo di Z. Sir)
|
||||
pCrv.Set( GetBiArc( ptP0, dDir0Deg, ptP1, dDir1Deg, PL, dMaxDist, dLinTol)) ;
|
||||
// forzo la spezzatura della curva
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
dMaxDist = 2 * dLinTol ;
|
||||
}
|
||||
// se la polilinea è formata da 2 punti
|
||||
else if ( PL.GetPointNbr() == 2) {
|
||||
@@ -524,13 +525,15 @@ CurveByApprox::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAng
|
||||
|
||||
// se raggiunto il massimo livello di recursione, forzo l'accettazione del biarco
|
||||
if ( nLev >= MAX_LEV) {
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
dMaxDist = 0 ;
|
||||
// segnalo situazione per debug
|
||||
if ( GetEGkDebugLev() >= 5)
|
||||
LOG_DBG_ERR( GetEGkLogger(), "ERROR : Exceeded recursions")
|
||||
}
|
||||
|
||||
// se lunghezza abbastanza picccola, forzo l'accettazione della curva
|
||||
// se lunghezza abbastanza piccola, forzo l'accettazione della curva
|
||||
double dLen ;
|
||||
if ( PL.GetApproxLength( dLen) && dLen < 10 * EPS_SMALL)
|
||||
dMaxDist = 0 ;
|
||||
|
||||
+57
-29
@@ -192,7 +192,7 @@ CurveComposite::AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart, double dLinT
|
||||
return false ;
|
||||
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK && ! ( m_CrvSmplS.empty() && m_nStatus == TO_VERIFY))
|
||||
if ( m_nStatus != OK && ! ( m_CrvSmplS.empty() && ( m_nStatus == TO_VERIFY || m_nStatus == IS_A_POINT)))
|
||||
return false ;
|
||||
|
||||
// controllo la tolleranza
|
||||
@@ -224,8 +224,11 @@ CurveComposite::AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart, double dLinT
|
||||
// lunghezza della curva originale
|
||||
double dOldLen ; pCrv->GetLength( dOldLen) ;
|
||||
// eseguo modifica
|
||||
if ( ! pCrv->ModifyStart( ptEnd))
|
||||
return false ;
|
||||
if ( ! pCrv->ModifyStart( ptEnd)) {
|
||||
CurveLine crvLine ;
|
||||
if ( ! crvLine.Set( ptEnd, ptCrvEnd) || ! pCrv.Set( crvLine.Clone()))
|
||||
return false ;
|
||||
}
|
||||
// verifico che la lunghezza non sia variata troppo
|
||||
double dNewLen ; pCrv->GetLength( dNewLen) ;
|
||||
if ( abs( dNewLen - dOldLen) > 10 * dLinTol)
|
||||
@@ -246,8 +249,11 @@ CurveComposite::AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart, double dLinT
|
||||
// lunghezza della curva originale
|
||||
double dOldLen ; pCrv->GetLength( dOldLen) ;
|
||||
// eseguo modifica
|
||||
if ( ! pCrv->ModifyEnd( ptStart))
|
||||
return false ;
|
||||
if ( ! pCrv->ModifyEnd( ptStart)) {
|
||||
CurveLine crvLine ;
|
||||
if ( ! crvLine.Set( ptCrvStart, ptStart) || ! pCrv.Set( crvLine.Clone()))
|
||||
return false ;
|
||||
}
|
||||
// verifico che la lunghezza non sia variata troppo
|
||||
double dNewLen ; pCrv->GetLength( dNewLen) ;
|
||||
if ( abs( dNewLen - dOldLen) > 10 * dLinTol)
|
||||
@@ -1778,10 +1784,11 @@ bool
|
||||
CurveComposite::AddPoint( const Point3d& ptStart)
|
||||
{
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != TO_VERIFY)
|
||||
if ( m_nStatus != TO_VERIFY && m_nStatus != IS_A_POINT)
|
||||
return false ;
|
||||
// assegno il punto
|
||||
// assegno il punto e setto lo stato
|
||||
m_ptStart = ptStart ;
|
||||
m_nStatus = IS_A_POINT ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -1825,7 +1832,7 @@ bool
|
||||
CurveComposite::AddLine( const Point3d& ptNew, bool bEndOrStart)
|
||||
{
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK && m_nStatus != TO_VERIFY)
|
||||
if ( m_nStatus != OK && m_nStatus != IS_A_POINT)
|
||||
return false ;
|
||||
// costruisco la linea
|
||||
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
||||
@@ -3168,11 +3175,26 @@ MergeTwoCurves( ICurve* pCrvP, ICurve* pCrvC, double& dCurrLinTol, double dCosAn
|
||||
// se precedente molto corta
|
||||
double dLenP ;
|
||||
if ( pCrvP->GetLength( dLenP) && dLenP < dCurrLinTol) {
|
||||
// se abbastanza allineata alla successiva
|
||||
// se abbastanza allineata alla successiva
|
||||
Vector3d vtDirP, vtDirC ;
|
||||
if ( pCrvP->GetEndDir( vtDirP) && pCrvC->GetStartDir( vtDirC) && ( vtDirP * vtDirC) >= dCosAngTol) {
|
||||
Point3d ptStart ;
|
||||
return ( pCrvP->GetStartPoint( ptStart) && pCrvC->ModifyStart( ptStart) ? -1 : 0) ;
|
||||
bool bModifStart = ( pCrvC->GetType() != CRV_ARC) ;
|
||||
if ( ! bModifStart) {
|
||||
/* nel caso in cui la curva corrente sia un arco, bisogna controllare che la somma tra
|
||||
l'angolo al centro e l'angolo sotteso dalla curva precedente non superi l'angolo giro; in
|
||||
caso positivo, la modifica del punto inziale dell'arco ( curva corrente) rimoverebbe
|
||||
tutti gli angoli superiori a 360deg [curve a ricciolo per regioni non svuotate in Pocketing] */
|
||||
Point3d ptS ; pCrvP->GetStartPoint( ptS) ;
|
||||
Point3d ptE ; pCrvC->GetStartPoint( ptE) ;
|
||||
const ICurveArc* pArcC = GetBasicCurveArc( pCrvC) ;
|
||||
double dAngRef = ( Dist( ptS, ptE) / pArcC->GetRadius()) * RADTODEG ;
|
||||
bModifStart = ( abs( pArcC->GetAngCenter()) + dAngRef < ANG_FULL - 10 * EPS_ANG_SMALL) ;
|
||||
|
||||
}
|
||||
if ( bModifStart) {
|
||||
Point3d ptStart ;
|
||||
return ( pCrvP->GetStartPoint( ptStart) && pCrvC->ModifyStart( ptStart) ? -1 : 0) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// se corrente molto corta
|
||||
@@ -3181,10 +3203,24 @@ MergeTwoCurves( ICurve* pCrvP, ICurve* pCrvC, double& dCurrLinTol, double dCosAn
|
||||
// se abbastanza allineata alla precedente
|
||||
Vector3d vtDirP, vtDirC ;
|
||||
if ( pCrvP->GetEndDir( vtDirP) && pCrvC->GetStartDir( vtDirC) && ( vtDirP * vtDirC) >= dCosAngTol) {
|
||||
Point3d ptEnd ;
|
||||
return ( pCrvC->GetEndPoint( ptEnd) && pCrvP->ModifyEnd( ptEnd) ? 1 : 0) ;
|
||||
bool bModifEnd = ( pCrvP->GetType() != CRV_ARC) ;
|
||||
if ( ! bModifEnd) {
|
||||
/* nel caso in cui la curva predecente sia un arco, bisogna controllare che la somma tra
|
||||
l'angolo al centro e l'angolo sotteso dalla curva corrente non superi l'angolo giro; in
|
||||
caso positivo, la modifica del punto finale dell'arco ( curva precedente) rimoverebbe
|
||||
tutti gli angoli superiori a 360deg [curve a ricciolo per regioni non svuotate in Pocketing] */
|
||||
Point3d ptS ; pCrvP->GetEndPoint( ptS) ;
|
||||
Point3d ptE ; pCrvC->GetEndPoint( ptE) ;
|
||||
const CurveArc* pArcP = GetBasicCurveArc( pCrvP) ;
|
||||
double dAngRef = ( Dist( ptS, ptE) / pArcP->GetRadius()) * RADTODEG ;
|
||||
bModifEnd = ( abs( pArcP->GetAngCenter()) + dAngRef < ANG_FULL - 10. * EPS_ANG_SMALL) ;
|
||||
}
|
||||
if ( bModifEnd) {
|
||||
Point3d ptEnd ;
|
||||
return ( pCrvC->GetEndPoint( ptEnd) && pCrvP->ModifyEnd( ptEnd) ? 1 : 0) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// coefficiente deduzione tolleranza
|
||||
const double COEFF_TOL = 0.7 ;
|
||||
// se entrambe rette
|
||||
@@ -3264,11 +3300,12 @@ MergeTwoCurves( ICurve* pCrvP, ICurve* pCrvC, double& dCurrLinTol, double dCosAn
|
||||
if ( ! bPlaneArcs) {
|
||||
ptP1.Scale( frRef, 1, 1, 0) ;
|
||||
ptP2.Scale( frRef, 1, 1, 0) ;
|
||||
ptP3.Scale( frRef, 1, 1, 0) ;
|
||||
ptP3.Scale( frRef, 1, 1, 0) ;
|
||||
ptC1Fin.Scale( frRef, 1, 1, 0) ;
|
||||
}
|
||||
|
||||
// verifico se circonferenza completa
|
||||
bool bCirc = ( AreSamePointApprox( ptP1, ptP3)) ;
|
||||
bool bCirc = ( AreSamePointEpsilon( ptP1, ptP3, dCurrLinTol)) ;
|
||||
if ( bCirc) {
|
||||
pArcC->GetMidPoint( ptP3) ;
|
||||
if ( ! bPlaneArcs)
|
||||
@@ -3277,6 +3314,10 @@ MergeTwoCurves( ICurve* pCrvP, ICurve* pCrvC, double& dCurrLinTol, double dCosAn
|
||||
|
||||
CurveArc NewArc ;
|
||||
if ( NewArc.Set3P( ptP1, ptP2, ptP3, bCirc)) {
|
||||
// se vicino a circonferenza arco per 3 punti potrebbe non dare il risultato desiderato quindi faccio controllo su raggio e centro
|
||||
if ( Dist( NewArc.GetCenter(), ptC1Fin) > 2 * dCurrLinTol || abs( NewArc.GetRadius() - pArcP->GetRadius()) > 2 * dCurrLinTol)
|
||||
return 0 ;
|
||||
|
||||
// verifico normale al piano dell'arco
|
||||
if ( NewArc.GetNormVersor() * pArcC->GetNormVersor() < 0)
|
||||
NewArc.InvertN() ;
|
||||
@@ -3794,19 +3835,6 @@ CurveComposite::ResetVoronoiObject() const
|
||||
m_pVoronoiObj = nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::FromPoint(Point3d& ptStart)
|
||||
{
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != TO_VERIFY)
|
||||
return false ;
|
||||
// assegno il punto e setto lo stato
|
||||
m_ptStart = ptStart ;
|
||||
m_nStatus = IS_A_POINT ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::GetOnlyPoint(Point3d& ptStart) const
|
||||
|
||||
+1
-2
@@ -177,8 +177,7 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
bool GetCurveTempProp( int nCrv, int& nProp, int nPropInd = 0) const override ;
|
||||
bool SetCurveTempParam( int nCrv, double dParam, int nParamInd = 0) override ;
|
||||
bool GetCurveTempParam( int nCrv, double& dParam, int nParamInd = 0) const override ;
|
||||
bool FromPoint( Point3d& ptStart) override ; // funzione per settare la curva ad un unico punto
|
||||
bool GetOnlyPoint( Point3d& ptStart) const override ; // funzione per recuperare l'unico punto da cui è composta la curva ( degenere)
|
||||
bool GetOnlyPoint( Point3d& ptStart) const override ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
|
||||
+17
-6
@@ -152,7 +152,7 @@ DistPointCurve::GetMinDistPoint( double dNearParam, Point3d& ptMinDist, int& nFl
|
||||
}
|
||||
}
|
||||
|
||||
// cerco punto discreto più vicino (anche estremi di zone continue)
|
||||
// cerco punto discreto più vicino (anche estremi di zone continue)
|
||||
double dParam ;
|
||||
for ( int i = 0 ; i < (int) m_Info.size() ; ++ i) {
|
||||
if ( i == 0 ||
|
||||
@@ -197,7 +197,7 @@ DistPointCurve::GetParamAtMinDistPoint( double dNearParam, double& dParam, int&
|
||||
}
|
||||
}
|
||||
|
||||
// cerco punto discreto più vicino (anche estremi di zone continue)
|
||||
// cerco punto discreto più vicino (anche estremi di zone continue)
|
||||
for ( int i = 0 ; i < (int) m_Info.size() ; ++ i) {
|
||||
if ( i == 0 ||
|
||||
abs( m_Info[i].dPar - dNearParam) < abs( dParam - dNearParam)) {
|
||||
@@ -232,9 +232,20 @@ DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide
|
||||
Vector3d vtTg = 0.5 * ( vtPreTg + vtPostTg) ;
|
||||
// se tangenti opposte, si deve ricalcolare spostandosi un poco
|
||||
if ( ! vtTg.Normalize()) {
|
||||
double dDeltaU = 1000 * EPS_PARAM ;
|
||||
if ( ! m_pCurve->GetPointTang( m_Info[nInd].dPar - dDeltaU, ICurve::FROM_MINUS, ptQ, vtPreTg) ||
|
||||
! m_pCurve->GetPointTang( m_Info[nInd].dPar + dDeltaU, ICurve::FROM_PLUS, ptQ, vtPostTg))
|
||||
double dDeltaU = 1000 * EPS_PARAM ;
|
||||
double dParPre = m_Info[nInd].dPar - dDeltaU ;
|
||||
double dParPost = m_Info[nInd].dPar + dDeltaU ;
|
||||
// verifico se il parametro deve essere modificato per adattarsi a curva chiusa
|
||||
if ( m_pCurve->IsClosed()) {
|
||||
double dParS, dParE ;
|
||||
m_pCurve->GetDomain( dParS, dParE) ;
|
||||
if ( dParPre < dParS)
|
||||
dParPre = dParE - dDeltaU ;
|
||||
if ( dParPost > dParE)
|
||||
dParPost = dParS + dDeltaU ;
|
||||
}
|
||||
if ( ! m_pCurve->GetPointTang( dParPre, ICurve::FROM_MINUS, ptQ, vtPreTg) ||
|
||||
! m_pCurve->GetPointTang( dParPost, ICurve::FROM_PLUS, ptQ, vtPostTg))
|
||||
return false ;
|
||||
vtTg = 0.5 * ( vtPreTg + vtPostTg) ;
|
||||
if ( ! vtTg.Normalize( EPS_ZERO))
|
||||
@@ -264,7 +275,7 @@ DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, i
|
||||
if ( m_dDist < 0 || m_Info.empty())
|
||||
return false ;
|
||||
|
||||
// cerco punto discreto più vicino (anche estremi di zone continue)
|
||||
// cerco punto discreto più vicino (anche estremi di zone continue)
|
||||
int nInd ;
|
||||
double dParam ;
|
||||
for ( int i = 0 ; i < (int) m_Info.size() ; ++ i) {
|
||||
|
||||
Binary file not shown.
@@ -320,6 +320,8 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="IntersLineVolZmap.cpp" />
|
||||
<ClCompile Include="IntersPlaneVolZmap.cpp" />
|
||||
<ClCompile Include="IntersLineSurfBez.cpp" />
|
||||
<ClCompile Include="SurfTriMeshOffset.cpp" />
|
||||
<ClCompile Include="VolZmapOffset.cpp" />
|
||||
<ClCompile Include="PolygonElevation.cpp" />
|
||||
<ClCompile Include="Quaternion.cpp" />
|
||||
<ClCompile Include="RotationMinimizingFrame.cpp" />
|
||||
@@ -343,6 +345,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="..\Include\EGkRotationMinimizingFrame.h" />
|
||||
<ClInclude Include="..\Include\EGkRotationXplaneFrame.h" />
|
||||
<ClInclude Include="..\Include\EGkSubtractProjectedFacesOnStmFace.h" />
|
||||
<ClInclude Include="..\Include\EGkSurfTriMeshAux.h" />
|
||||
<ClInclude Include="CAvSilhouetteSurfTm.h" />
|
||||
<ClInclude Include="CDeBoxTria.h" />
|
||||
<ClInclude Include="CDeCapsTria.h" />
|
||||
|
||||
@@ -546,6 +546,12 @@
|
||||
<ClCompile Include="DistPointSurfFr.cpp">
|
||||
<Filter>File di origine\GeoDist</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="VolZmapOffset.cpp">
|
||||
<Filter>File di origine\Geo</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SurfTriMeshOffset.cpp">
|
||||
<Filter>File di origine\GeoOffset</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h">
|
||||
@@ -1226,6 +1232,9 @@
|
||||
<ClInclude Include="CAvSilhouetteSurfTm.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkSurfTriMeshAux.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtGeomKernel.rc">
|
||||
|
||||
+149
-25
@@ -16,9 +16,17 @@
|
||||
#include "CurveArc.h"
|
||||
#include "CurveLine.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EGkChainCurves.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool IsFillet( const ICurve* pCrv, double dDist) ;
|
||||
static bool ModifyFillet( ICurve* pCrv, double dDist, int nType, ICurveComposite& ccAux) ;
|
||||
static bool AdjustIntersections( ICRVCOMPOPVECTOR& CrvList) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IdentifyFillets( ICurveComposite* pCrvCo, double dDist)
|
||||
@@ -52,36 +60,76 @@ IsFillet( const ICurve* pCrv, double dDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
AdjustCurveFillets( ICurveComposite* pCrvCo, double dDist, int nType)
|
||||
AdjustCurveFillets( ICURVEPOVECTOR& vOffset, double dDist, int nType)
|
||||
{
|
||||
ICURVEPLIST CrvLst ;
|
||||
PtrOwner<ICurve> pCrv( pCrvCo->RemoveFirstOrLastCurve( false)) ;
|
||||
while ( ! IsNull( pCrv)) {
|
||||
// se identificato come fillet lo trasformo in smusso o estensione
|
||||
if ( pCrv->GetTempParam() > EPS_SMALL) {
|
||||
CurveComposite ccTemp ;
|
||||
ModifyFillet( pCrv, dDist, nType, ccTemp) ;
|
||||
// metto in lista le curve risultanti
|
||||
if ( ccTemp.GetCurveCount() > 0) {
|
||||
PtrOwner<ICurve> pCrv2( ccTemp.RemoveFirstOrLastCurve( false)) ;
|
||||
while ( ! IsNull( pCrv2)) {
|
||||
CrvLst.push_back( Release( pCrv2)) ;
|
||||
pCrv2.Set( ccTemp.RemoveFirstOrLastCurve( false)) ;
|
||||
}
|
||||
if ( vOffset.empty())
|
||||
return true ;
|
||||
|
||||
// suddivido le curve di offset individuando i fillet e isolandoli dagli altri tratti
|
||||
ICRVCOMPOPVECTOR vCrvs ;
|
||||
for ( int i = 0 ; i < int( vOffset.size()) ; i ++) {
|
||||
CurveComposite* pCompo = GetBasicCurveComposite( vOffset[i]) ;
|
||||
if ( pCompo == nullptr)
|
||||
return false ;
|
||||
bool bNewCrv = true ;
|
||||
PtrOwner<ICurve> pCrv( pCompo->RemoveFirstOrLastCurve(false)) ;
|
||||
while ( ! IsNull( pCrv)) {
|
||||
if ( pCrv->GetTempParam() > EPS_SMALL) {
|
||||
// se fillet calcolo il nuovo raccordo
|
||||
CurveComposite* ccTemp = CreateBasicCurveComposite() ;
|
||||
ModifyFillet( pCrv, dDist, nType, *ccTemp) ;
|
||||
// assegno temp param per identificarlo nei conti successivi
|
||||
ccTemp->SetTempParam( 1) ;
|
||||
vCrvs.push_back( ccTemp) ;
|
||||
bNewCrv = true ;
|
||||
}
|
||||
else {
|
||||
// aggiungo la curva
|
||||
if ( bNewCrv) {
|
||||
bNewCrv = false ;
|
||||
CurveComposite* pCompo = ConvertCurveToBasicComposite( Release( pCrv)) ;
|
||||
if ( pCompo == nullptr)
|
||||
return false ;
|
||||
vCrvs.push_back( pCompo) ;
|
||||
}
|
||||
else
|
||||
vCrvs.back()->AddCurve( Release( pCrv)) ;
|
||||
}
|
||||
// passo alla curva successiva
|
||||
pCrv.Set( pCompo->RemoveFirstOrLastCurve( false)) ;
|
||||
}
|
||||
// altrimenti salvo in lista
|
||||
else
|
||||
CrvLst.push_back( Release( pCrv)) ;
|
||||
// passo alla curva successiva
|
||||
pCrv.Set( pCrvCo->RemoveFirstOrLastCurve( false)) ;
|
||||
}
|
||||
// rimetto le curve nella composita
|
||||
for ( auto pCrv : CrvLst) {
|
||||
pCrvCo->AddCurve( pCrv) ;
|
||||
vOffset.clear() ;
|
||||
|
||||
// gestione delle intersezioni
|
||||
if ( ! AdjustIntersections( vCrvs))
|
||||
return false ;
|
||||
|
||||
// concateno i tratti ottenuti
|
||||
ChainCurves ChainCrv ;
|
||||
ChainCrv.Init( false, 2 * EPS_SMALL, vCrvs.size()) ;
|
||||
for ( int i = 0 ; i < int( vCrvs.size()); ++ i) {
|
||||
Point3d ptS, ptE ;
|
||||
Vector3d vtS, vtE ;
|
||||
vCrvs[i]->GetStartPoint( ptS) ;
|
||||
vCrvs[i]->GetEndPoint( ptE) ;
|
||||
vCrvs[i]->GetStartDir( vtS) ;
|
||||
vCrvs[i]->GetEndDir( vtE) ;
|
||||
ChainCrv.AddCurve( i + 1, ptS, vtS, ptE, vtE) ;
|
||||
}
|
||||
// recupero i concatenamenti
|
||||
Point3d ptRef ; vCrvs[0]->GetStartPoint( ptRef) ;
|
||||
INTVECTOR vIds ;
|
||||
while ( ChainCrv.GetChainFromNear( ptRef, false, vIds)) {
|
||||
PtrOwner<CurveComposite> pCompo( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCompo))
|
||||
return false ;
|
||||
for ( auto i : vIds)
|
||||
pCompo->AddCurve( vCrvs[i-1]) ;
|
||||
pCompo->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG) ;
|
||||
pCompo->GetEndPoint( ptRef) ;
|
||||
vOffset.emplace_back( Release( pCompo)) ;
|
||||
}
|
||||
// unisco tratti allineati
|
||||
pCrvCo->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -175,3 +223,79 @@ ModifyFillet( ICurve* pCrv, double dDist, int nType, ICurveComposite& ccAux)
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
AdjustIntersections( ICRVCOMPOPVECTOR& vCrvs)
|
||||
{
|
||||
// sistema le curve nel vettore vCrvs eliminando le parti coinvolte nelle intersezioni
|
||||
|
||||
vector<Intervals> vIntervals( vCrvs.size()) ;
|
||||
INTVECTOR vFillets ;
|
||||
for ( int i = 0 ; i < int( vCrvs.size()) ; i ++) {
|
||||
// salvo i parametri della curva
|
||||
double dParS, dParE ;
|
||||
vCrvs[i]->GetDomain( dParS, dParE) ;
|
||||
vIntervals[i].Set( dParS, dParE) ;
|
||||
// verifico se raccordo
|
||||
if ( vCrvs[i]->GetTempParam() > EPS_SMALL)
|
||||
vFillets.emplace_back( i) ;
|
||||
}
|
||||
|
||||
// verifico se i raccordi intersecano le altre curve
|
||||
bool bInters = false ;
|
||||
for ( int i = 0 ; i < int( vFillets.size()) ; i ++) {
|
||||
int nIdx = vFillets[i] ;
|
||||
for ( int j = 0 ; j < int( vCrvs.size()) ; j ++) {
|
||||
if ( j == nIdx)
|
||||
continue ;
|
||||
|
||||
IntersCurveCurve intCC( *vCrvs[nIdx], *vCrvs[j]) ;
|
||||
int nCnt = intCC.GetIntersCount() ;
|
||||
if ( nCnt > 1) {
|
||||
// aggiorno gli intervalli della curva sottraendo la parte coinvolta dall'intersezione
|
||||
for ( int k = 0 ; k < nCnt - 1 ; k = k+2) {
|
||||
IntCrvCrvInfo iccInfo1, iccInfo2 ;
|
||||
intCC.GetIntCrvCrvInfo( k, iccInfo1) ;
|
||||
// verifico non sia intersezione nell'estremo iniziale o sovrapposizione
|
||||
if ( iccInfo1.IciA[0].dU < EPS_SMALL || iccInfo1.bOverlap) {
|
||||
k-- ;
|
||||
continue ;
|
||||
}
|
||||
intCC.GetIntCrvCrvInfo( k+1, iccInfo2) ;
|
||||
|
||||
vIntervals[nIdx].Subtract( iccInfo1.IciA[0].dU, iccInfo2.IciA[0].dU) ;
|
||||
vIntervals[j].Subtract( iccInfo1.IciB[0].dU, iccInfo2.IciB[0].dU) ;
|
||||
bInters = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! bInters)
|
||||
return true ;
|
||||
|
||||
// aggiorno le curve eliminando i tratti coinvolti nelle intersezioni
|
||||
for ( int i = 0 ; i < int( vIntervals.size()) ; i++) {
|
||||
if ( vIntervals[i].GetCount() > 1) {
|
||||
PtrOwner<CurveComposite> pCompo( CloneBasicCurveComposite( vCrvs[i])) ;
|
||||
if ( IsNull( pCompo))
|
||||
return false ;
|
||||
double dParS, dParE ;
|
||||
vIntervals[i].GetFirst( dParS, dParE) ;
|
||||
vCrvs[i]->TrimStartEndAtParam( dParS, dParE) ;
|
||||
while ( vIntervals[i].GetNext( dParS, dParE)) {
|
||||
CurveComposite* pCrv = ConvertCurveToBasicComposite( pCompo->CopyParamRange( dParS, dParE)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
vCrvs.emplace_back( pCrv) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
double dParS, dParE ;
|
||||
vIntervals[i].GetFirst( dParS, dParE) ;
|
||||
vCrvs[i]->TrimStartEndAtParam( dParS, dParE) ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
+1
-3
@@ -16,6 +16,4 @@
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool IdentifyFillets( ICurveComposite* pCrvCo, double dDist) ;
|
||||
bool IsFillet( const ICurve* pCrv, double dDist) ;
|
||||
bool AdjustCurveFillets( ICurveComposite* pCrvCo, double dDist, int nType) ;
|
||||
bool ModifyFillet( ICurve* pCrv, double dDist, int nType, ICurveComposite& ccAux) ;
|
||||
bool AdjustCurveFillets( ICURVEPOVECTOR& vCrvs, double dDist, int nType) ;
|
||||
+13
-5
@@ -674,12 +674,20 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
}
|
||||
|
||||
// nono passo : se con smusso o estensione, sostituisco i fillet con questi
|
||||
// NB questa parte non è gestita in modo efficiente perchè dovrebbe essere sempre disabilitata.
|
||||
// Le funzioni sono state ottimizzate per lavorare con voronoi
|
||||
if ( ( nType & ICurve::OFF_CHAMFER) != 0 || ( nType & ICurve::OFF_EXTEND) != 0) {
|
||||
for ( auto iIter = m_CrvLst.begin() ; iIter != m_CrvLst.end() ; ++ iIter) {
|
||||
CurveComposite* pCrvCo = GetBasicCurveComposite( *iIter) ;
|
||||
IdentifyFillets( pCrvCo, dDist) ;
|
||||
AdjustCurveFillets( pCrvCo, dDist, nType) ;
|
||||
}
|
||||
ICURVEPOVECTOR vCrvs ;
|
||||
vCrvs.reserve( m_CrvLst.size()) ;
|
||||
for ( auto pCrv : m_CrvLst) {
|
||||
IdentifyFillets( GetCurveComposite( pCrv), dDist) ;
|
||||
vCrvs.emplace_back( pCrv) ;
|
||||
}
|
||||
if ( ! AdjustCurveFillets( vCrvs, dDist, nType))
|
||||
return false ;
|
||||
m_CrvLst.clear() ;
|
||||
for ( int j = 0 ; j < int( vCrvs.size()) ; j ++)
|
||||
m_CrvLst.emplace_back( Release( vCrvs[j])) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,12 +150,18 @@ PolygonElevationInClosedSurfTm( const Polygon3d& pgFacet, const ISurfTriMesh& Cl
|
||||
Vector3d vtN = pgFacet.GetVersN() ;
|
||||
PolyLine PL = pgFacet.GetPolyLine() ;
|
||||
|
||||
// calcolo elevazione massima del contorno della faccia
|
||||
// calcolo elevazione massima del contorno della faccia e nel suo centro
|
||||
const double RAY_LEN = 100000 ;
|
||||
dElev = 0 ;
|
||||
PNTVECTOR vptP ; vptP.reserve( PL.GetPointNbr()) ;
|
||||
Point3d ptP ;
|
||||
bool bFound = PL.GetFirstPoint( ptP) ;
|
||||
while ( bFound) {
|
||||
vptP.push_back( ptP) ;
|
||||
bFound = PL.GetNextPoint( ptP, true) ;
|
||||
}
|
||||
vptP.push_back( ptCen) ;
|
||||
for ( const Point3d& ptP : vptP) {
|
||||
ILSIVECTOR vInters ;
|
||||
IntersLineSurfTm( ptP, vtN, RAY_LEN, CldStm, vInters, true) ;
|
||||
for ( int i = 0 ; i < int( vInters.size()) ; ++ i) {
|
||||
@@ -171,7 +177,6 @@ PolygonElevationInClosedSurfTm( const Polygon3d& pgFacet, const ISurfTriMesh& Cl
|
||||
else if ( Inters.nILTT == ILTT_SEGM || Inters.nILTT == ILTT_SEGM_ON_EDGE)
|
||||
dElev = max( dElev, Inters.dU2) ;
|
||||
}
|
||||
bFound = PL.GetNextPoint( ptP, true) ;
|
||||
}
|
||||
// calcolo elevazione massima degli eventuali spigoli (e vertici) della superficie chiusa dalla parte positiva della faccia e che cadono in essa
|
||||
int nEdgeCnt = CldStm.GetEdgeCount() ;
|
||||
|
||||
+5
-5
@@ -19,10 +19,10 @@
|
||||
void
|
||||
PolygonPlane::AddPoint( const Point3d& ptP)
|
||||
{
|
||||
// se è il primo punto (parto da -1 perchè verrà contato alla chiusura)
|
||||
// se è il primo punto (parto da -1 perchè verrà contato alla chiusura)
|
||||
if ( m_nPntNbr == -1) {
|
||||
// inizializzazioni
|
||||
m_dLenN = 0 ;
|
||||
m_dLenN = -1 ;
|
||||
m_vtN = V_NULL ;
|
||||
m_ptMid = ORIG ;
|
||||
m_dSXy = 0 ; m_dSXz = 0 ;
|
||||
@@ -60,16 +60,16 @@ PolygonPlane::AddPoint( const Point3d& ptP)
|
||||
bool
|
||||
PolygonPlane::Finalize( void)
|
||||
{
|
||||
// almeno 3 punti (il triangolo è il poligono con minimo numero di lati)
|
||||
// almeno 3 punti (il triangolo è il poligono con minimo numero di lati)
|
||||
if ( m_nPntNbr + 1 < 3)
|
||||
return false ;
|
||||
// se il poligono non è stato chiuso, aggiungo calcolo per ultimo lato
|
||||
// se il poligono non è stato chiuso, aggiungo calcolo per ultimo lato
|
||||
if ( ! AreSamePointExact( m_ptFirst, m_ptLast)) {
|
||||
// aggiungo il primo punto per far eseguire i conti sul lato di chiusura
|
||||
AddPoint( m_ptFirst) ;
|
||||
}
|
||||
// se non effettuato, eseguo il calcolo finale
|
||||
if ( m_dLenN < EPS_SMALL) {
|
||||
if ( m_dLenN < 0) {
|
||||
// lunghezza della normale (doppio dell'area del poligono)
|
||||
m_dLenN = m_vtN.Len() ;
|
||||
if ( m_dLenN < SQ_EPS_SMALL)
|
||||
|
||||
+299
-191
@@ -29,8 +29,6 @@ using namespace std ;
|
||||
//----------------------------------------------------------------------------
|
||||
// Angolo limite tra normale al triangolo e direzione di proiezione 89°
|
||||
const double COS_ANG_LIM = 0.0175 ;
|
||||
// Massimo numero di triangoli per raffinare ricerca su spigoli
|
||||
const int MAX_FACET_FOR_CORNER = 1000 ;
|
||||
// Angolo massimo tra normali per effettuare bisezione su spigolo
|
||||
const double COS_ANG_MAX_CORNER = 0.8660 ;
|
||||
// Tipologia di punto
|
||||
@@ -156,30 +154,52 @@ RemovePointsInExcess( PNT5AXVECTOR& vPt5ax, double dLinTol, double dMaxSegmLen,
|
||||
return true ;
|
||||
}
|
||||
|
||||
typedef std::vector<IntersParLinesSurfTm*> INTPARLINESTMPVECTOR ; // vettore di oggetti intersezione massiva rette parallele SurfTM
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
ProjectPointOnSurf( const Point3d& ptP, const SurfTriMesh& stmSurf, const Frame3d& frRefLine, const IntersParLinesSurfTm& intPLSTM,
|
||||
ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const Frame3d& frRefLine, const INTPARLINESTMPVECTOR& vpIntPLSTM,
|
||||
double dPar, Point5ax& Pt5ax)
|
||||
{
|
||||
// intersezione retta di proiezione con superficie
|
||||
// intersezione retta di proiezione con superfici (conservo l'intersezione più alta)
|
||||
Point3d ptL = GetToLoc( ptP, frRefLine) ;
|
||||
ILSIVECTOR vIntRes ;
|
||||
intPLSTM.GetInters( ptL, 1, vIntRes, false) ;
|
||||
// cerco la prima intersezione valida a partire dall'ultima (è la più alta)
|
||||
int nI = int( vIntRes.size()) - 1 ;
|
||||
while ( nI >= 0 && abs( vIntRes[nI].dCosDN) < COS_ANG_LIM)
|
||||
--nI ;
|
||||
int nInd = -1 ;
|
||||
IntLinStmInfo IntRes ;
|
||||
for ( int i = 0 ; i < int( vpIntPLSTM.size()) ; ++ i) {
|
||||
ILSIVECTOR vIntRes ;
|
||||
if ( vpIntPLSTM[i]->GetInters( ptL, 1, vIntRes, false)) {
|
||||
// cerco la prima intersezione valida a partire dall'ultima (è la più alta)
|
||||
int nI = int( vIntRes.size()) - 1 ;
|
||||
while ( nI >= 0 && abs( vIntRes[nI].dCosDN) < COS_ANG_LIM)
|
||||
--nI ;
|
||||
// se trovata
|
||||
if ( nI >= 0) {
|
||||
if ( nInd < 0) {
|
||||
IntRes = vIntRes[nI] ;
|
||||
nInd = i ;
|
||||
}
|
||||
else {
|
||||
double dUref = (( IntRes.nILTT == ILTT_SEGM || IntRes.nILTT == ILTT_SEGM_ON_EDGE) ? IntRes.dU2 : IntRes.dU) ;
|
||||
double dU = (( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE) ? vIntRes[nI].dU2 : vIntRes[nI].dU) ;
|
||||
if ( dU > dUref) {
|
||||
IntRes = vIntRes[nI] ;
|
||||
nInd = i ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// se trovata
|
||||
if ( nI >= 0) {
|
||||
if ( nInd >= 0) {
|
||||
// calcolo il punto
|
||||
Point3d ptInt ;
|
||||
if ( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE)
|
||||
ptInt = vIntRes[nI].ptI2 ;
|
||||
if ( IntRes.nILTT == ILTT_SEGM || IntRes.nILTT == ILTT_SEGM_ON_EDGE)
|
||||
ptInt = IntRes.ptI2 ;
|
||||
else
|
||||
ptInt = vIntRes[nI].ptI ;
|
||||
ptInt = IntRes.ptI ;
|
||||
// calcolo la normale (si calcola smooth, in caso di errore si prende quella del triangolo)
|
||||
Triangle3dEx trTria ;
|
||||
if ( ! stmSurf.GetTriangle( vIntRes[nI].nT, trTria))
|
||||
if ( ! vpStm[nInd]->GetTriangle( IntRes.nT, trTria))
|
||||
return false ;
|
||||
Vector3d vtN ;
|
||||
if ( ! CalcNormal( ptInt, trTria, vtN))
|
||||
@@ -198,26 +218,30 @@ ProjectPointOnSurf( const Point3d& ptP, const SurfTriMesh& stmSurf, const Frame3
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ProjectCurveOnSurf( const ICurve& crCrv, const ISurf& sfSurf, const Vector3d& vtDir,
|
||||
ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const Vector3d& vtDir,
|
||||
double dLinTol, double dMaxSegmLen, bool bSharpEdges, PNT5AXVECTOR& vPt5ax)
|
||||
{
|
||||
// sistemazioni per tipo di superficie
|
||||
const SurfTriMesh* pSurfTm = nullptr ;
|
||||
switch ( sfSurf.GetType()) {
|
||||
case SRF_TRIMESH :
|
||||
pSurfTm = GetBasicSurfTriMesh( &sfSurf) ;
|
||||
break ;
|
||||
case SRF_BEZIER :
|
||||
pSurfTm = GetBasicSurfBezier( &sfSurf)->GetAuxSurf() ;
|
||||
break ;
|
||||
case SRF_FLATRGN :
|
||||
pSurfTm = GetBasicSurfFlatRegion( &sfSurf)->GetAuxSurf() ;
|
||||
break ;
|
||||
default :
|
||||
break ;
|
||||
CISRFTMPVECTOR vpSurfTm ;
|
||||
for ( int i = 0 ; i < int( vpSurf.size()) ; ++ i) {
|
||||
const SurfTriMesh* pSurfTm = nullptr ;
|
||||
switch ( vpSurf[i]->GetType()) {
|
||||
case SRF_TRIMESH :
|
||||
pSurfTm = GetBasicSurfTriMesh( vpSurf[i]) ;
|
||||
break ;
|
||||
case SRF_BEZIER :
|
||||
pSurfTm = GetBasicSurfBezier( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
case SRF_FLATRGN :
|
||||
pSurfTm = GetBasicSurfFlatRegion( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
default :
|
||||
break ;
|
||||
}
|
||||
if ( pSurfTm == nullptr)
|
||||
return false ;
|
||||
vpSurfTm.emplace_back( pSurfTm) ;
|
||||
}
|
||||
if ( pSurfTm == nullptr)
|
||||
return false ;
|
||||
|
||||
// controllo le tolleranze
|
||||
dLinTol = max( dLinTol, LIN_TOL_MIN) ;
|
||||
@@ -230,11 +254,20 @@ ProjectCurveOnSurf( const ICurve& crCrv, const ISurf& sfSurf, const Vector3d& vt
|
||||
if ( ! PL.AdjustForMaxSegmentLen( MAX_SEG_LEN))
|
||||
return false ;
|
||||
|
||||
// Oggetto per calcolo massivo intersezioni tra linee di proiezione e superficie
|
||||
// Oggetti per calcolo massivo intersezioni tra linee di proiezione e superfici
|
||||
Frame3d frRefLine ;
|
||||
if ( ! frRefLine.Set( ORIG, vtDir))
|
||||
return false ;
|
||||
IntersParLinesSurfTm intPLSTM( frRefLine, *pSurfTm) ;
|
||||
INTPARLINESTMPVECTOR vpIntPLSTM ; vpIntPLSTM.reserve( vpSurfTm.size()) ;
|
||||
for ( int i = 0 ; i < int( vpSurfTm.size()) ; ++ i) {
|
||||
IntersParLinesSurfTm* pIntPLSTM = new IntersParLinesSurfTm( frRefLine, *vpSurfTm[i]) ;
|
||||
if ( pIntPLSTM == nullptr) {
|
||||
for ( int j = 0 ; j < int( vpIntPLSTM.size()) ; ++ j)
|
||||
delete vpIntPLSTM[j] ;
|
||||
return false ;
|
||||
}
|
||||
vpIntPLSTM.emplace_back( pIntPLSTM) ;
|
||||
}
|
||||
|
||||
// Pulisco e riservo spazio nel vettore dei punti risultanti
|
||||
vPt5ax.clear() ;
|
||||
@@ -247,12 +280,16 @@ ProjectCurveOnSurf( const ICurve& crCrv, const ISurf& sfSurf, const Vector3d& vt
|
||||
while ( bFound) {
|
||||
// se trovo proiezione, la salvo
|
||||
Point5ax Pt5ax ;
|
||||
if ( ProjectPointOnSurf( ptP, *pSurfTm, frRefLine, intPLSTM, dPar, Pt5ax))
|
||||
if ( ProjectPointOnSurf( ptP, vpSurfTm, frRefLine, vpIntPLSTM, dPar, Pt5ax))
|
||||
vPt5ax.emplace_back( Pt5ax) ;
|
||||
// passo al successivo
|
||||
bFound = PL.GetNextUPoint( &dPar, &ptP) ;
|
||||
}
|
||||
|
||||
// Libero oggetti per calcolo massivo
|
||||
for ( int i = 0 ; i < int( vpIntPLSTM.size()) ; ++ i)
|
||||
delete vpIntPLSTM[i] ;
|
||||
|
||||
// se richiesto, inserimento punti intermedi in presenza di spigoli
|
||||
if ( bSharpEdges) {
|
||||
for ( int i = 1 ; i < int( vPt5ax.size()) ; ++ i) {
|
||||
@@ -325,72 +362,96 @@ ProjectCurveOnSurf( const ICurve& crCrv, const ISurf& sfSurf, const Vector3d& vt
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
ProjectPointOnSurf( const Point3d& ptP, const SurfTriMesh& stmSurf, const IGeoPoint3d& gpRef, double dPar, Point5ax& Pt5ax)
|
||||
ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const IGeoPoint3d& gpRef, double dPar, Point5ax& Pt5ax)
|
||||
{
|
||||
// punto di riferimento
|
||||
Point3d ptMin = gpRef.GetPoint() ;
|
||||
// intersezione della retta di minima distanza con la superficie
|
||||
// intersezione della retta di minima distanza con le superfici
|
||||
Vector3d vtLine = ptP - ptMin ;
|
||||
double dLineLen = vtLine.Len() ;
|
||||
if ( dLineLen > EPS_SMALL) {
|
||||
vtLine /= dLineLen ;
|
||||
ILSIVECTOR vIntRes ;
|
||||
if ( IntersLineSurfTm( ptP, vtLine, dLineLen, stmSurf, vIntRes, false)) {
|
||||
// cerco la prima intersezione valida a partire dall'ultima (è la più alta)
|
||||
int nI = int( vIntRes.size()) - 1 ;
|
||||
while ( nI >= 0 && abs( vIntRes[nI].dCosDN) < COS_ANG_LIM)
|
||||
--nI ;
|
||||
// se trovata
|
||||
if ( nI >= 0) {
|
||||
// calcolo il punto
|
||||
Point3d ptInt ;
|
||||
if ( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE)
|
||||
ptInt = vIntRes[nI].ptI2 ;
|
||||
else
|
||||
ptInt = vIntRes[nI].ptI ;
|
||||
// calcolo la normale (si calcola smooth, in caso di errore si prende quella del triangolo)
|
||||
Triangle3dEx trTria ;
|
||||
if ( ! stmSurf.GetTriangle( vIntRes[nI].nT, trTria))
|
||||
return false ;
|
||||
Vector3d vtN ;
|
||||
if ( ! CalcNormal( ptInt, trTria, vtN))
|
||||
vtN = trTria.GetN() ;
|
||||
// assegno valori al punto 5assi
|
||||
Pt5ax.ptP = ptInt ;
|
||||
Pt5ax.vtDir1 = vtN ;
|
||||
Pt5ax.vtDir2 = vtLine ;
|
||||
Pt5ax.dPar = dPar ;
|
||||
Pt5ax.nFlag = P5AX_STD ;
|
||||
// ritorno con successo
|
||||
return true ;
|
||||
// conservo l'intersezione più alta
|
||||
int nInd = -1 ;
|
||||
IntLinStmInfo IntRes ;
|
||||
for ( int i = 0 ; i < int( vpStm.size()) ; ++ i) {
|
||||
ILSIVECTOR vIntRes ;
|
||||
if ( IntersLineSurfTm( ptP, vtLine, dLineLen, *vpStm[i], vIntRes, false)) {
|
||||
// cerco la prima intersezione valida a partire dall'ultima (è la più alta)
|
||||
int nI = int( vIntRes.size()) - 1 ;
|
||||
while ( nI >= 0 && abs( vIntRes[nI].dCosDN) < COS_ANG_LIM)
|
||||
--nI ;
|
||||
// se trovata
|
||||
if ( nI >= 0) {
|
||||
if ( nInd < 0) {
|
||||
IntRes = vIntRes[nI] ;
|
||||
nInd = i ;
|
||||
}
|
||||
else {
|
||||
double dUref = (( IntRes.nILTT == ILTT_SEGM || IntRes.nILTT == ILTT_SEGM_ON_EDGE) ? IntRes.dU2 : IntRes.dU) ;
|
||||
double dU = (( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE) ? vIntRes[nI].dU2 : vIntRes[nI].dU) ;
|
||||
if ( dU > dUref) {
|
||||
IntRes = vIntRes[nI] ;
|
||||
nInd = i ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// se trovata
|
||||
if ( nInd >= 0) {
|
||||
// calcolo il punto
|
||||
Point3d ptInt ;
|
||||
if ( IntRes.nILTT == ILTT_SEGM || IntRes.nILTT == ILTT_SEGM_ON_EDGE)
|
||||
ptInt = IntRes.ptI2 ;
|
||||
else
|
||||
ptInt = IntRes.ptI ;
|
||||
// calcolo la normale (si calcola smooth, in caso di errore si prende quella del triangolo)
|
||||
Triangle3dEx trTria ;
|
||||
if ( ! vpStm[nInd]->GetTriangle( IntRes.nT, trTria))
|
||||
return false ;
|
||||
Vector3d vtN ;
|
||||
if ( ! CalcNormal( ptInt, trTria, vtN))
|
||||
vtN = trTria.GetN() ;
|
||||
// assegno valori al punto 5assi
|
||||
Pt5ax.ptP = ptInt ;
|
||||
Pt5ax.vtDir1 = vtN ;
|
||||
Pt5ax.vtDir2 = vtLine ;
|
||||
Pt5ax.dPar = dPar ;
|
||||
Pt5ax.nFlag = P5AX_STD ;
|
||||
// ritorno con successo
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ProjectCurveOnSurf( const ICurve& crCrv, const ISurf& sfSurf, const IGeoPoint3d& gpRef,
|
||||
ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const IGeoPoint3d& gpRef,
|
||||
double dLinTol, double dMaxSegmLen, bool bSharpEdges, PNT5AXVECTOR& vPt5ax)
|
||||
{
|
||||
// sistemazioni per tipo di superficie
|
||||
const SurfTriMesh* pSurfTm = nullptr ;
|
||||
switch ( sfSurf.GetType()) {
|
||||
case SRF_TRIMESH :
|
||||
pSurfTm = GetBasicSurfTriMesh( &sfSurf) ;
|
||||
break ;
|
||||
case SRF_BEZIER :
|
||||
pSurfTm = GetBasicSurfBezier( &sfSurf)->GetAuxSurf() ;
|
||||
break ;
|
||||
case SRF_FLATRGN :
|
||||
pSurfTm = GetBasicSurfFlatRegion( &sfSurf)->GetAuxSurf() ;
|
||||
break ;
|
||||
default :
|
||||
break ;
|
||||
CISRFTMPVECTOR vpSurfTm ;
|
||||
for ( int i = 0 ; i < int( vpSurf.size()) ; ++ i) {
|
||||
const SurfTriMesh* pSurfTm = nullptr ;
|
||||
switch ( vpSurf[i]->GetType()) {
|
||||
case SRF_TRIMESH :
|
||||
pSurfTm = GetBasicSurfTriMesh( vpSurf[i]) ;
|
||||
break ;
|
||||
case SRF_BEZIER :
|
||||
pSurfTm = GetBasicSurfBezier( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
case SRF_FLATRGN :
|
||||
pSurfTm = GetBasicSurfFlatRegion( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
default :
|
||||
break ;
|
||||
}
|
||||
if ( pSurfTm == nullptr)
|
||||
return false ;
|
||||
vpSurfTm.emplace_back( pSurfTm) ;
|
||||
}
|
||||
if ( pSurfTm == nullptr)
|
||||
return false ;
|
||||
|
||||
// controllo le tolleranze
|
||||
dLinTol = max( dLinTol, LIN_TOL_MIN) ;
|
||||
@@ -415,14 +476,14 @@ ProjectCurveOnSurf( const ICurve& crCrv, const ISurf& sfSurf, const IGeoPoint3d&
|
||||
while ( bFound) {
|
||||
// se trovo proiezione, la salvo
|
||||
Point5ax Pt5ax ;
|
||||
if ( ProjectPointOnSurf( ptP, *pSurfTm, gpRef, dPar, Pt5ax))
|
||||
if ( ProjectPointOnSurf( ptP, vpSurfTm, gpRef, dPar, Pt5ax))
|
||||
vPt5ax.emplace_back( Pt5ax) ;
|
||||
// passo al successivo
|
||||
bFound = PL.GetNextUPoint( &dPar, &ptP) ;
|
||||
}
|
||||
|
||||
// se superfici con non troppi triangoli, inserimento punti intermedi in presenza di spigoli
|
||||
if ( pSurfTm->GetFacetCount() < MAX_FACET_FOR_CORNER) {
|
||||
// se richiesto, inserimento punti intermedi in presenza di spigoli
|
||||
if ( bSharpEdges) {
|
||||
for ( int i = 1 ; i < int( vPt5ax.size()) ; ++ i) {
|
||||
// precedente
|
||||
int j = i - 1 ;
|
||||
@@ -434,7 +495,7 @@ ProjectCurveOnSurf( const ICurve& crCrv, const ISurf& sfSurf, const IGeoPoint3d&
|
||||
double dMid = ( vPt5ax[i].dPar + vPt5ax[j].dPar) / 2 ;
|
||||
// se trovo proiezione, la salvo
|
||||
Point5ax Pt5ax ;
|
||||
if ( ProjectPointOnSurf( ptMid, *pSurfTm, gpRef, dMid, Pt5ax)) {
|
||||
if ( ProjectPointOnSurf( ptMid, vpSurfTm, gpRef, dMid, Pt5ax)) {
|
||||
vPt5ax.insert( vPt5ax.begin() + i, Pt5ax) ;
|
||||
-- i ;
|
||||
}
|
||||
@@ -450,49 +511,69 @@ ProjectCurveOnSurf( const ICurve& crCrv, const ISurf& sfSurf, const IGeoPoint3d&
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
ProjectPointOnSurf( const Point3d& ptP, const SurfTriMesh& stmSurf, const ICurve& crRef, double dPar, Point5ax& Pt5ax)
|
||||
ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const ICurve& crRef, double dPar, Point5ax& Pt5ax)
|
||||
{
|
||||
// punto a minima distanza
|
||||
DistPointCurve dPC( ptP, crRef) ;
|
||||
Point3d ptMin ;
|
||||
int nFlag ;
|
||||
if ( dPC.GetMinDistPoint( 0, ptMin, nFlag)) {
|
||||
// intersezione della retta di minima distanza con la superficie
|
||||
// intersezione della retta di minima distanza con le superfici
|
||||
Vector3d vtLine = ptP - ptMin ;
|
||||
double dLineLen = vtLine.Len() ;
|
||||
if ( dLineLen > EPS_SMALL) {
|
||||
vtLine /= dLineLen ;
|
||||
ILSIVECTOR vIntRes ;
|
||||
if ( IntersLineSurfTm( ptP, vtLine, dLineLen, stmSurf, vIntRes, false)) {
|
||||
// cerco la prima intersezione valida a partire dall'ultima (è la più alta)
|
||||
int nI = int( vIntRes.size()) - 1 ;
|
||||
while ( nI >= 0 && abs( vIntRes[nI].dCosDN) < COS_ANG_LIM)
|
||||
--nI ;
|
||||
// se trovata
|
||||
if ( nI >= 0) {
|
||||
// calcolo il punto
|
||||
Point3d ptInt ;
|
||||
if ( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE)
|
||||
ptInt = vIntRes[nI].ptI2 ;
|
||||
else
|
||||
ptInt = vIntRes[nI].ptI ;
|
||||
// calcolo la normale (si calcola smooth, in caso di errore si prende quella del triangolo)
|
||||
Triangle3dEx trTria ;
|
||||
if ( ! stmSurf.GetTriangle( vIntRes[nI].nT, trTria))
|
||||
return false ;
|
||||
Vector3d vtN ;
|
||||
if ( ! CalcNormal( ptInt, trTria, vtN))
|
||||
vtN = trTria.GetN() ;
|
||||
// assegno valori al punto 5assi
|
||||
Pt5ax.ptP = ptInt ;
|
||||
Pt5ax.vtDir1 = vtN ;
|
||||
Pt5ax.vtDir2 = vtLine ;
|
||||
Pt5ax.dPar = dPar ;
|
||||
Pt5ax.nFlag = P5AX_STD ;
|
||||
// ritorno con successo
|
||||
return true ;
|
||||
// conservo l'intersezione più alta
|
||||
int nInd = -1 ;
|
||||
IntLinStmInfo IntRes ;
|
||||
for ( int i = 0 ; i < int( vpStm.size()) ; ++ i) {
|
||||
ILSIVECTOR vIntRes ;
|
||||
if ( IntersLineSurfTm( ptP, vtLine, dLineLen, *vpStm[i], vIntRes, false)) {
|
||||
// cerco la prima intersezione valida a partire dall'ultima (è la più alta)
|
||||
int nI = int( vIntRes.size()) - 1 ;
|
||||
while ( nI >= 0 && abs( vIntRes[nI].dCosDN) < COS_ANG_LIM)
|
||||
--nI ;
|
||||
// se trovata
|
||||
if ( nI >= 0) {
|
||||
if ( nInd < 0) {
|
||||
IntRes = vIntRes[nI] ;
|
||||
nInd = i ;
|
||||
}
|
||||
else {
|
||||
double dUref = (( IntRes.nILTT == ILTT_SEGM || IntRes.nILTT == ILTT_SEGM_ON_EDGE) ? IntRes.dU2 : IntRes.dU) ;
|
||||
double dU = (( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE) ? vIntRes[nI].dU2 : vIntRes[nI].dU) ;
|
||||
if ( dU > dUref) {
|
||||
IntRes = vIntRes[nI] ;
|
||||
nInd = i ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// se trovata
|
||||
if ( nInd >= 0) {
|
||||
// assegno il punto
|
||||
Point3d ptInt ;
|
||||
if ( IntRes.nILTT == ILTT_SEGM || IntRes.nILTT == ILTT_SEGM_ON_EDGE)
|
||||
ptInt = IntRes.ptI2 ;
|
||||
else
|
||||
ptInt = IntRes.ptI ;
|
||||
// calcolo la normale (si calcola smooth, in caso di errore si prende quella del triangolo)
|
||||
Triangle3dEx trTria ;
|
||||
if ( ! vpStm[nInd]->GetTriangle( IntRes.nT, trTria))
|
||||
return false ;
|
||||
Vector3d vtN ;
|
||||
if ( ! CalcNormal( ptInt, trTria, vtN))
|
||||
vtN = trTria.GetN() ;
|
||||
// assegno valori al punto 5assi
|
||||
Pt5ax.ptP = ptInt ;
|
||||
Pt5ax.vtDir1 = vtN ;
|
||||
Pt5ax.vtDir2 = vtLine ;
|
||||
Pt5ax.dPar = dPar ;
|
||||
Pt5ax.nFlag = P5AX_STD ;
|
||||
// ritorno con successo
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false ;
|
||||
@@ -500,26 +581,30 @@ ProjectPointOnSurf( const Point3d& ptP, const SurfTriMesh& stmSurf, const ICurve
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ProjectCurveOnSurf( const ICurve& crCrv, const ISurf& sfSurf, const ICurve& crRef,
|
||||
ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const ICurve& crRef,
|
||||
double dLinTol, double dMaxSegmLen, bool bSharpEdges, PNT5AXVECTOR& vPt5ax)
|
||||
{
|
||||
// Sistemazioni per tipo di superficie
|
||||
const SurfTriMesh* pSurfTm = nullptr ;
|
||||
switch ( sfSurf.GetType()) {
|
||||
case SRF_TRIMESH :
|
||||
pSurfTm = GetBasicSurfTriMesh( &sfSurf) ;
|
||||
break ;
|
||||
case SRF_BEZIER :
|
||||
pSurfTm = GetBasicSurfBezier( &sfSurf)->GetAuxSurf() ;
|
||||
break ;
|
||||
case SRF_FLATRGN :
|
||||
pSurfTm = GetBasicSurfFlatRegion( &sfSurf)->GetAuxSurf() ;
|
||||
break ;
|
||||
default :
|
||||
break ;
|
||||
CISRFTMPVECTOR vpSurfTm ;
|
||||
for ( int i = 0 ; i < int( vpSurf.size()) ; ++ i) {
|
||||
const SurfTriMesh* pSurfTm = nullptr ;
|
||||
switch ( vpSurf[i]->GetType()) {
|
||||
case SRF_TRIMESH :
|
||||
pSurfTm = GetBasicSurfTriMesh( vpSurf[i]) ;
|
||||
break ;
|
||||
case SRF_BEZIER :
|
||||
pSurfTm = GetBasicSurfBezier( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
case SRF_FLATRGN :
|
||||
pSurfTm = GetBasicSurfFlatRegion( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
default :
|
||||
break ;
|
||||
}
|
||||
if ( pSurfTm == nullptr)
|
||||
return false ;
|
||||
vpSurfTm.emplace_back( pSurfTm) ;
|
||||
}
|
||||
if ( pSurfTm == nullptr)
|
||||
return false ;
|
||||
|
||||
// Controllo le tolleranze
|
||||
dLinTol = max( dLinTol, LIN_TOL_MIN) ;
|
||||
@@ -544,7 +629,7 @@ ProjectCurveOnSurf( const ICurve& crCrv, const ISurf& sfSurf, const ICurve& crRe
|
||||
while ( bFound) {
|
||||
// se trovo proiezione, la salvo
|
||||
Point5ax Pt5ax ;
|
||||
if ( ProjectPointOnSurf( ptP, *pSurfTm, crRef, dPar, Pt5ax))
|
||||
if ( ProjectPointOnSurf( ptP, vpSurfTm, crRef, dPar, Pt5ax))
|
||||
vPt5ax.emplace_back( Pt5ax) ;
|
||||
// passo al successivo
|
||||
bFound = PL.GetNextUPoint( &dPar, &ptP) ;
|
||||
@@ -622,7 +707,7 @@ ProjectCurveOnSurf( const ICurve& crCrv, const ISurf& sfSurf, const ICurve& crRe
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
ProjectPointOnSurf( const Point3d& ptP, const SurfTriMesh& stmSurf, const SurfTriMesh& stmRef, double dPar, Point5ax& Pt5ax)
|
||||
ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const SurfTriMesh& stmRef, double dPar, Point5ax& Pt5ax)
|
||||
{
|
||||
// punto sulla superficie guida a minima distanza
|
||||
DistPointSurfTm dPS( ptP, stmRef) ;
|
||||
@@ -643,71 +728,94 @@ ProjectPointOnSurf( const Point3d& ptP, const SurfTriMesh& stmSurf, const SurfTr
|
||||
vtLine = trGuide.GetN() ;
|
||||
dLineLen = 100 ;
|
||||
}
|
||||
// intersezione della retta con la superficie
|
||||
ILSIVECTOR vIntRes ;
|
||||
if ( IntersLineSurfTm( ptP, vtLine, dLineLen, stmSurf, vIntRes, false)) {
|
||||
// cerco la prima intersezione valida a partire dall'ultima (è la più alta)
|
||||
int nI = int( vIntRes.size()) - 1 ;
|
||||
while ( nI >= 0 && abs( vIntRes[nI].dCosDN) < COS_ANG_LIM)
|
||||
--nI ;
|
||||
// se trovata
|
||||
if ( nI >= 0) {
|
||||
// calcolo il punto
|
||||
Point3d ptInt ;
|
||||
if ( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE)
|
||||
ptInt = vIntRes[nI].ptI2 ;
|
||||
else
|
||||
ptInt = vIntRes[nI].ptI ;
|
||||
// calcolo la normale (si calcola smooth, in caso di errore si prende quella del triangolo)
|
||||
Triangle3dEx trTria ;
|
||||
if ( ! stmSurf.GetTriangle( vIntRes[nI].nT, trTria))
|
||||
return false ;
|
||||
Vector3d vtN ;
|
||||
if ( ! CalcNormal( ptMin, trTria, vtN))
|
||||
vtN = trTria.GetN() ;
|
||||
// calcolo la normale della superficie guida
|
||||
Triangle3dEx trGuide ;
|
||||
if ( ! stmRef.GetTriangle( nTriaMin, trGuide))
|
||||
return false ;
|
||||
Vector3d vtN2 ;
|
||||
if ( ! CalcNormal( ptMin, trGuide, vtN2))
|
||||
vtN2 = trGuide.GetN() ;
|
||||
// assegno valori al punto 5assi
|
||||
Pt5ax.ptP = ptInt ;
|
||||
Pt5ax.vtDir1 = vtN ;
|
||||
Pt5ax.vtDir2 = vtN2 ;
|
||||
Pt5ax.dPar = dPar ;
|
||||
Pt5ax.nFlag = P5AX_STD ;
|
||||
// ritorno con successo
|
||||
return true ;
|
||||
// intersezione della retta con le superfici (conservo l'intersezione più alta)
|
||||
int nInd = -1 ;
|
||||
IntLinStmInfo IntRes ;
|
||||
for ( int i = 0 ; i < int( vpStm.size()) ; ++ i) {
|
||||
ILSIVECTOR vIntRes ;
|
||||
if ( IntersLineSurfTm( ptP, vtLine, dLineLen, *vpStm[i], vIntRes, false)) {
|
||||
// cerco la prima intersezione valida a partire dall'ultima (è la più alta)
|
||||
int nI = int( vIntRes.size()) - 1 ;
|
||||
while ( nI >= 0 && abs( vIntRes[nI].dCosDN) < COS_ANG_LIM)
|
||||
--nI ;
|
||||
// se trovata
|
||||
if ( nI >= 0) {
|
||||
if ( nInd < 0) {
|
||||
IntRes = vIntRes[nI] ;
|
||||
nInd = i ;
|
||||
}
|
||||
else {
|
||||
double dUref = (( IntRes.nILTT == ILTT_SEGM || IntRes.nILTT == ILTT_SEGM_ON_EDGE) ? IntRes.dU2 : IntRes.dU) ;
|
||||
double dU = (( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE) ? vIntRes[nI].dU2 : vIntRes[nI].dU) ;
|
||||
if ( dU > dUref) {
|
||||
IntRes = vIntRes[nI] ;
|
||||
nInd = i ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// se trovata
|
||||
if ( nInd >= 0) {
|
||||
// calcolo il punto
|
||||
Point3d ptInt ;
|
||||
if ( IntRes.nILTT == ILTT_SEGM || IntRes.nILTT == ILTT_SEGM_ON_EDGE)
|
||||
ptInt = IntRes.ptI2 ;
|
||||
else
|
||||
ptInt = IntRes.ptI ;
|
||||
// calcolo la normale (si calcola smooth, in caso di errore si prende quella del triangolo)
|
||||
Triangle3dEx trTria ;
|
||||
if ( ! vpStm[nInd]->GetTriangle( IntRes.nT, trTria))
|
||||
return false ;
|
||||
Vector3d vtN ;
|
||||
if ( ! CalcNormal( ptMin, trTria, vtN))
|
||||
vtN = trTria.GetN() ;
|
||||
// calcolo la normale della superficie guida
|
||||
Triangle3dEx trGuide ;
|
||||
if ( ! stmRef.GetTriangle( nTriaMin, trGuide))
|
||||
return false ;
|
||||
Vector3d vtN2 ;
|
||||
if ( ! CalcNormal( ptMin, trGuide, vtN2))
|
||||
vtN2 = trGuide.GetN() ;
|
||||
// assegno valori al punto 5assi
|
||||
Pt5ax.ptP = ptInt ;
|
||||
Pt5ax.vtDir1 = vtN ;
|
||||
Pt5ax.vtDir2 = vtN2 ;
|
||||
Pt5ax.dPar = dPar ;
|
||||
Pt5ax.nFlag = P5AX_STD ;
|
||||
// ritorno con successo
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ProjectCurveOnSurf( const ICurve& crCrv, const ISurf& sfSurf, const ISurf& sfRef,
|
||||
ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const ISurf& sfRef,
|
||||
double dLinTol, double dMaxSegmLen, bool bSharpEdges, PNT5AXVECTOR& vPt5ax)
|
||||
{
|
||||
// sistemazioni per tipo di superficie
|
||||
const SurfTriMesh* pSurfTm = nullptr ;
|
||||
switch ( sfSurf.GetType()) {
|
||||
case SRF_TRIMESH :
|
||||
pSurfTm = GetBasicSurfTriMesh( &sfSurf) ;
|
||||
break ;
|
||||
case SRF_BEZIER :
|
||||
pSurfTm = GetBasicSurfBezier( &sfSurf)->GetAuxSurf() ;
|
||||
break ;
|
||||
case SRF_FLATRGN :
|
||||
pSurfTm = GetBasicSurfFlatRegion( &sfSurf)->GetAuxSurf() ;
|
||||
break ;
|
||||
default :
|
||||
break ;
|
||||
CISRFTMPVECTOR vpSurfTm ;
|
||||
for ( int i = 0 ; i < int( vpSurf.size()) ; ++ i) {
|
||||
const SurfTriMesh* pSurfTm = nullptr ;
|
||||
switch ( vpSurf[i]->GetType()) {
|
||||
case SRF_TRIMESH :
|
||||
pSurfTm = GetBasicSurfTriMesh( vpSurf[i]) ;
|
||||
break ;
|
||||
case SRF_BEZIER :
|
||||
pSurfTm = GetBasicSurfBezier( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
case SRF_FLATRGN :
|
||||
pSurfTm = GetBasicSurfFlatRegion( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
default :
|
||||
break ;
|
||||
}
|
||||
if ( pSurfTm == nullptr)
|
||||
return false ;
|
||||
vpSurfTm.emplace_back( pSurfTm) ;
|
||||
}
|
||||
if ( pSurfTm == nullptr)
|
||||
return false ;
|
||||
|
||||
// sistemazioni per tipo di superficie di riferimento
|
||||
const SurfTriMesh* pRefTm = nullptr ;
|
||||
@@ -750,14 +858,14 @@ ProjectCurveOnSurf( const ICurve& crCrv, const ISurf& sfSurf, const ISurf& sfRef
|
||||
while ( bFound) {
|
||||
// se trovo proiezione, la salvo
|
||||
Point5ax Pt5ax ;
|
||||
if ( ProjectPointOnSurf( ptP, *pSurfTm, *pRefTm, dPar, Pt5ax))
|
||||
if ( ProjectPointOnSurf( ptP, vpSurfTm, *pRefTm, dPar, Pt5ax))
|
||||
vPt5ax.emplace_back( Pt5ax) ;
|
||||
// passo al successivo
|
||||
bFound = PL.GetNextUPoint( &dPar, &ptP) ;
|
||||
}
|
||||
|
||||
// se superfici con non troppi triangoli, inserimento punti intermedi in presenza di spigoli
|
||||
if ( pSurfTm->GetFacetCount() < MAX_FACET_FOR_CORNER) {
|
||||
// se richiesto, inserimento punti intermedi in presenza di spigoli
|
||||
if ( bSharpEdges) {
|
||||
for ( int i = 1 ; i < int( vPt5ax.size()) ; ++ i) {
|
||||
// precedente
|
||||
int j = i - 1 ;
|
||||
@@ -769,7 +877,7 @@ ProjectCurveOnSurf( const ICurve& crCrv, const ISurf& sfSurf, const ISurf& sfRef
|
||||
double dMid = ( vPt5ax[i].dPar + vPt5ax[j].dPar) / 2 ;
|
||||
// se trovo proiezione, la salvo
|
||||
Point5ax Pt5ax ;
|
||||
if ( ProjectPointOnSurf( ptMid, *pSurfTm, *pRefTm, dMid, Pt5ax)) {
|
||||
if ( ProjectPointOnSurf( ptMid, vpSurfTm, *pRefTm, dMid, Pt5ax)) {
|
||||
vPt5ax.insert( vPt5ax.begin() + i, Pt5ax) ;
|
||||
-- i ;
|
||||
}
|
||||
|
||||
+32
-667
@@ -95,56 +95,17 @@ ISurfBezier*
|
||||
GetSurfBezierByExtrusion( const ICurve* pCurve, const Vector3d& vtExtr,
|
||||
bool bCapEnds, double dLinTol)
|
||||
{
|
||||
// verifica parametri
|
||||
// verifica parametri
|
||||
if ( pCurve == nullptr || &vtExtr == nullptr)
|
||||
return nullptr ;
|
||||
// calcolo la polilinea che approssima la curva
|
||||
PolyLine PL ;
|
||||
if ( ! pCurve->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
|
||||
return nullptr ;
|
||||
//// se richiesta chiusura agli estremi
|
||||
//bool bDoCapEnds = false ;
|
||||
//if ( bCapEnds) {
|
||||
// // verifico che la curva sia chiusa e piatta
|
||||
// Plane3d plPlane ;
|
||||
// double dArea ;
|
||||
// if ( PL.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL)) {
|
||||
// // componente dell'estrusione perpendicolare al piano della curva
|
||||
// double dOrthoExtr = plPlane.GetVersN() * vtExtr ;
|
||||
// if ( ( abs( dOrthoExtr) > EPS_SMALL)) {
|
||||
// bDoCapEnds = true ;
|
||||
// // se negativa, inverto il senso del contorno
|
||||
// if ( dOrthoExtr < 0)
|
||||
// PL.Invert() ;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
PtrOwner<const ICurve> pBezierForm( CurveToBezierCurve( pCurve)) ;
|
||||
// creo e setto la superficie trimesh
|
||||
// creo e setto la superficie di Bezier
|
||||
PtrOwner<SurfBezier> pSbz( CreateBasicSurfBezier()) ;
|
||||
if ( IsNull( pSbz) || ! pSbz->CreateByExtrusion( pBezierForm, vtExtr))
|
||||
return nullptr ;
|
||||
|
||||
//// se da fare, metto i tappi sulle estremità
|
||||
//if ( bDoCapEnds) {
|
||||
// // creo la prima superficie di estremità
|
||||
// SurfTriMesh STM1 ;
|
||||
// if ( ! STM1.CreateByFlatContour( PL))
|
||||
// return nullptr ;
|
||||
// // la copio
|
||||
// SurfTriMesh STM2 = STM1 ;
|
||||
// // inverto la prima superficie
|
||||
// STM1.Invert() ;
|
||||
// // traslo la seconda
|
||||
// STM2.Translate( vtExtr) ;
|
||||
|
||||
// ////// SurfCompo?
|
||||
// //// le unisco alla superficie del fianco
|
||||
// //if ( ! pSbz->DoSewing( STM1) || ! pSTM->DoSewing( STM2))
|
||||
// // return nullptr ;
|
||||
//}
|
||||
// restituisco la superficie
|
||||
// restituisco la superficie
|
||||
return Release( pSbz) ;
|
||||
}
|
||||
|
||||
@@ -201,45 +162,6 @@ GetSurfBezierByRevolve( const ICurve* pCurve, const Point3d& ptAx, const Vector3
|
||||
return nullptr ;
|
||||
// limite minimo su tolleranza
|
||||
dLinTol = max( dLinTol, EPS_SMALL) ;
|
||||
//// calcolo la polilinea che approssima la curva
|
||||
//PolyLine PL ;
|
||||
//if ( ! pCurve->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
|
||||
// return nullptr ;
|
||||
|
||||
//// se richiesta chiusura degli estremi
|
||||
//if ( bCapEnds && ! PL.IsClosed()) { // serve la SURFCOMPO
|
||||
// Vector3d vtAxN = vtAx ;
|
||||
// vtAxN.Normalize() ;
|
||||
// double dPosIni = 0, dPosFin = 0 ;
|
||||
// Point3d ptP ;
|
||||
// // proietto l'ultimo punto sull'asse di rotazione
|
||||
// if ( PL.GetLastPoint( ptP)) {
|
||||
// dPosFin = ( ptP - ptAx) * vtAxN ;
|
||||
// Point3d ptPOnAx = ptAx + dPosFin * vtAxN ;
|
||||
// // se non giace sull'asse, aggiungo il punto proiettato
|
||||
// if ( ! AreSamePointApprox( ptP, ptPOnAx)) {
|
||||
// double dU ;
|
||||
// PL.GetLastU( dU) ;
|
||||
// PL.AddUPoint( ( dU + 1), ptPOnAx) ;
|
||||
// }
|
||||
// }
|
||||
// // inverto la polilinea
|
||||
// PL.Invert() ;
|
||||
// // proietto l'ultimo punto (era il primo) sull'asse di rotazione
|
||||
// if ( PL.GetLastPoint( ptP)) {
|
||||
// dPosIni = ( ptP - ptAx) * vtAxN ;
|
||||
// Point3d ptPOnAx = ptAx + dPosIni * vtAxN ;
|
||||
// // se non giace sull'asse, aggiungo il punto proiettato
|
||||
// if ( ! AreSamePointApprox( ptP, ptPOnAx)) {
|
||||
// double dU ;
|
||||
// PL.GetLastU( dU) ;
|
||||
// PL.AddUPoint( ( dU + 1), ptPOnAx) ;
|
||||
// }
|
||||
// }
|
||||
// // decido se reinvertire la polilinea
|
||||
// if ( dPosFin > dPosIni)
|
||||
// PL.Invert() ;
|
||||
//}
|
||||
|
||||
// creo e setto la superficie trimesh
|
||||
PtrOwner<SurfBezier> pSbz( CreateBasicSurfBezier()) ;
|
||||
@@ -259,392 +181,31 @@ ISurfBezier*
|
||||
GetSurfBezierByScrewing( const ICurve* pCurve, const Point3d& ptAx, const Vector3d& vtAx,
|
||||
double dAngRotDeg, double dMove, bool bCapEnds, double dLinTol)
|
||||
{
|
||||
// verifica parametri
|
||||
// verifica parametri
|
||||
if ( pCurve == nullptr || &ptAx == nullptr || &vtAx == nullptr)
|
||||
return nullptr ;
|
||||
// limite minimo su tolleranza
|
||||
// limite minimo su tolleranza
|
||||
dLinTol = max( dLinTol, EPS_SMALL) ;
|
||||
// calcolo la polilinea che approssima la curva
|
||||
PolyLine PL ;
|
||||
if ( ! pCurve->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
|
||||
return nullptr ;
|
||||
|
||||
// creo e setto la superficie bezier
|
||||
// creo e setto la superficie bezier
|
||||
PtrOwner<SurfBezier> pSbz( CreateBasicSurfBezier()) ;
|
||||
if ( IsNull( pSbz) || ! pSbz->CreateByScrewing( pCurve, ptAx, vtAx, dAngRotDeg, dMove))
|
||||
return nullptr ;
|
||||
//// se richiesti caps /// richiede la SurfCompo
|
||||
//if ( bCapEnds) {
|
||||
// // determino se la sezione è chiusa e piatta
|
||||
// Plane3d plPlane ; double dArea ;
|
||||
// bool bSectClosedFlat = PL.IsClosedAndFlat( plPlane, dArea, 10 * EPS_SMALL) ;
|
||||
// // determino non sia una semplice rivoluzione
|
||||
// bool bRevolved = ( abs( abs( dAngRotDeg) - ANG_FULL) < EPS_ANG_SMALL && abs( dMove) < EPS_SMALL) ;
|
||||
// // se sezione chiusa e piatta e non rivoluzione, posso aggiungere i tappi
|
||||
// if ( bSectClosedFlat && ! bRevolved) {
|
||||
// // aggiungo il cap sull'inizio
|
||||
// PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSci) || ! pSci->CreateByFlatContour( PL))
|
||||
// return nullptr ;
|
||||
// pSTM->DoSewing( *pSci) ;
|
||||
// // aggiungo il cap sulla fine
|
||||
// Vector3d vtMove = vtAx ;
|
||||
// vtMove.Normalize() ;
|
||||
// vtMove *= dMove ;
|
||||
// PL.Translate( vtMove) ;
|
||||
// PL.Rotate( ptAx, vtAx, dAngRotDeg) ;
|
||||
// PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSce) || ! pSce->CreateByFlatContour( PL))
|
||||
// return nullptr ;
|
||||
// pSce->Invert() ;
|
||||
// pSTM->DoSewing( *pSce) ;
|
||||
// }
|
||||
//}
|
||||
// se superficie risultante chiusa, verifico che la normale sia verso l'esterno
|
||||
|
||||
// se superficie risultante chiusa, verifico che la normale sia verso l'esterno
|
||||
double dVol ;
|
||||
if ( pSbz->GetVolume( dVol) && dVol < 0)
|
||||
pSbz->Invert() ;
|
||||
|
||||
// restituisco la superficie
|
||||
// restituisco la superficie
|
||||
return Release( pSbz) ;
|
||||
}
|
||||
//
|
||||
////-------------------------------------------------------------------------------
|
||||
//static ISurfBezier*
|
||||
//GetSurfBezierSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide, int nCapType, double dLinTol) // DA SISTEMARE - ancora copia della versione stm, cambia solo il nome della funzione//////////////////////
|
||||
//{
|
||||
// // verifico che la linea guida sia piana
|
||||
// Plane3d plGuide ;
|
||||
// if ( ! pGuide->IsFlat( plGuide, false, 10 * EPS_SMALL))
|
||||
// return nullptr ;
|
||||
// Vector3d vtNorm = plGuide.GetVersN() ;
|
||||
// // determino se la guida è chiusa
|
||||
// bool bGuideClosed = pGuide->IsClosed() ;
|
||||
// // curve di offset
|
||||
// OffsetCurve OffsCrvR ;
|
||||
// if ( ! OffsCrvR.Make( pGuide, dDimH / 2, ICurve::OFF_FILLET) || OffsCrvR.GetCurveCount() == 0)
|
||||
// return nullptr ;
|
||||
// PtrOwner<ICurve> pCrvR( OffsCrvR.GetLongerCurve()) ;
|
||||
// if ( IsNull( pCrvR))
|
||||
// return nullptr ;
|
||||
// OffsetCurve OffsCrvL ;
|
||||
// if ( ! OffsCrvL.Make( pGuide, -dDimH / 2, ICurve::OFF_FILLET) || OffsCrvL.GetCurveCount() == 0)
|
||||
// return nullptr ;
|
||||
// PtrOwner<ICurve> pCrvL( OffsCrvL.GetLongerCurve()) ;
|
||||
// if ( IsNull( pCrvL))
|
||||
// return nullptr ;
|
||||
// // costruisco le parti di superficie
|
||||
// PtrOwner<ISurfTriMesh> pSrfTop( GetSurfTriMeshRuled( pCrvR, pCrvL, ISurfTriMesh::RLT_MINDIST, dLinTol)) ;
|
||||
// if ( IsNull( pSrfTop))
|
||||
// return nullptr ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfBot( pSrfTop->Clone()) ;
|
||||
// if ( IsNull( pSrfBot))
|
||||
// return nullptr ;
|
||||
// pSrfBot->Translate( -dDimV * vtNorm) ;
|
||||
// pSrfBot->Invert() ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfRgt( GetSurfTriMeshByExtrusion( pCrvR, -dDimV * vtNorm, false, dLinTol)) ;
|
||||
// if ( IsNull( pSrfRgt))
|
||||
// return nullptr ;
|
||||
// pSrfRgt->Invert() ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfLft( GetSurfTriMeshByExtrusion( pCrvL, -dDimV * vtNorm, false, dLinTol)) ;
|
||||
// if ( IsNull( pSrfLft))
|
||||
// return nullptr ;
|
||||
// // unisco le parti
|
||||
// PtrOwner<ISurfTriMesh> pSTM( Release( pSrfTop)) ;
|
||||
// pSTM->DoSewing( *pSrfRgt) ;
|
||||
// pSTM->DoSewing( *pSrfLft) ;
|
||||
// pSTM->DoSewing( *pSrfBot) ;
|
||||
// // salvo tolleranza lineare usata e imposto angolo per smooth
|
||||
// pSTM->SetLinearTolerance( dLinTol) ;
|
||||
// pSTM->SetSmoothAngle( 20) ;
|
||||
// // se guida aperta e tappi piatti
|
||||
// if ( ! bGuideClosed && nCapType == RSCAP_FLAT) {
|
||||
// // verifico che le due estremità siano chiuse e piatte
|
||||
// POLYLINEVECTOR vPL ;
|
||||
// if ( ! pSTM->GetLoops( vPL) || vPL.size() != 2)
|
||||
// return nullptr ;
|
||||
// Plane3d plEnds ; double dArea ;
|
||||
// if ( ! vPL[0].IsClosedAndFlat( plEnds, dArea, 100 * EPS_SMALL))
|
||||
// return nullptr ;
|
||||
// if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 100 * EPS_SMALL))
|
||||
// return nullptr ;
|
||||
// // aggiungo il cap sull'inizio
|
||||
// PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSci) || ! pSci->CreateByFlatContour( vPL[0]))
|
||||
// return nullptr ;
|
||||
// pSci->Invert() ;
|
||||
// pSTM->DoSewing( *pSci) ;
|
||||
// // aggiungo il cap sulla fine
|
||||
// PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSce) || ! pSce->CreateByFlatContour( vPL[1]))
|
||||
// return nullptr ;
|
||||
// pSce->Invert() ;
|
||||
// pSTM->DoSewing( *pSce) ;
|
||||
// }
|
||||
// // se altrimenti guida aperta e tappi arrotondati
|
||||
// if ( ! bGuideClosed && ( nCapType == RSCAP_ROUND || nCapType == RSCAP_BEVEL)) {
|
||||
// // step di rotazione per rispettare la tolleranza
|
||||
// double dStepRotDeg = ( nCapType == RSCAP_BEVEL ? ANG_STRAIGHT / 4 : sqrt( 8 * dLinTol / dDimH) * RADTODEG) ;
|
||||
// // aggiungo il cap sull'inizio
|
||||
// Point3d ptStart ;
|
||||
// pGuide->GetStartPoint( ptStart) ;
|
||||
// Vector3d vtStart ;
|
||||
// pGuide->GetStartDir( vtStart) ;
|
||||
// vtStart.Rotate( vtNorm, 0, 1) ;
|
||||
// PolyLine PLStart ;
|
||||
// PLStart.AddUPoint( 0, ptStart) ;
|
||||
// PLStart.AddUPoint( 1, ptStart + dDimH / 2 * vtStart) ;
|
||||
// PLStart.AddUPoint( 2, ptStart + dDimH / 2 * vtStart - dDimV * vtNorm) ;
|
||||
// PLStart.AddUPoint( 3, ptStart - dDimV * vtNorm) ;
|
||||
// PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSci) || ! pSci->CreateByScrewing( PLStart, ptStart, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||
// return nullptr ;
|
||||
// pSci->Invert() ;
|
||||
// pSTM->DoSewing( *pSci) ;
|
||||
// // aggiungo il cap sulla fine
|
||||
// Point3d ptEnd ;
|
||||
// pGuide->GetEndPoint( ptEnd) ;
|
||||
// Vector3d vtEnd ;
|
||||
// pGuide->GetEndDir( vtEnd) ;
|
||||
// vtEnd.Rotate( vtNorm, 0, -1) ;
|
||||
// PolyLine PLEnd ;
|
||||
// PLEnd.AddUPoint( 0, ptEnd) ;
|
||||
// PLEnd.AddUPoint( 1, ptEnd + dDimH / 2 * vtEnd) ;
|
||||
// PLEnd.AddUPoint( 2, ptEnd + dDimH / 2 * vtEnd - dDimV * vtNorm) ;
|
||||
// PLEnd.AddUPoint( 3, ptEnd - dDimV * vtNorm) ;
|
||||
// PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSce) || ! pSce->CreateByScrewing( PLEnd, ptEnd, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||
// return nullptr ;
|
||||
// pSce->Invert() ;
|
||||
// pSTM->DoSewing( *pSce) ;
|
||||
// }
|
||||
// // restituisco la superficie
|
||||
// return Release( pSTM) ;
|
||||
//}
|
||||
//
|
||||
////-------------------------------------------------------------------------------
|
||||
//static ISurfBezier*
|
||||
//GetSurfBezierBeveledRectSwept( double dDimH, double dDimV, double dBevelH, double dBevelV, const ICurve* pGuide, int nCapType, double dLinTol) // DA SISTEMARE - ancora copia della versione stm, cambia solo il nome della funzione//////////////////////
|
||||
//{
|
||||
// // metodo di calcolo impostato da USE_VORONOI
|
||||
//
|
||||
// // verifico che la linea guida sia piana
|
||||
// Plane3d plGuide ;
|
||||
// if ( ! pGuide->IsFlat( plGuide, false, 10 * EPS_SMALL))
|
||||
// return nullptr ;
|
||||
// // assegno la normale del piano
|
||||
// Vector3d vtNorm = plGuide.GetVersN() ;
|
||||
// // determino il punto centrale della sezione
|
||||
// Point3d ptCen ;
|
||||
// pGuide->GetStartPoint( ptCen) ;
|
||||
// ptCen -= dDimV / 2 * vtNorm ;
|
||||
// // determino se la guida è chiusa
|
||||
// bool bGuideClosed = pGuide->IsClosed() ;
|
||||
// // curve di offset
|
||||
// const int NUM_OFFS = 4 ;
|
||||
// OffsetCurve vOffsCrv[NUM_OFFS] ;
|
||||
// double vDist[NUM_OFFS] = { dDimH / 2 - dBevelH, -dDimH / 2 + dBevelH, dDimH / 2, -dDimH / 2} ;
|
||||
// bool bOk = true ;
|
||||
// if ( ! USE_VORONOI) {
|
||||
// future<bool> vRes[NUM_OFFS] ;
|
||||
// for ( int i = 0 ; i < NUM_OFFS ; ++ i)
|
||||
// vRes[i] = async( launch::async, &OffsetCurve::Make, &vOffsCrv[i], pGuide, vDist[i], ICurve::OFF_FILLET) ;
|
||||
// bool bOk = true ;
|
||||
// int nFin = 0 ;
|
||||
// while ( nFin < NUM_OFFS) {
|
||||
// for ( int i = 0 ; i < NUM_OFFS ; ++ i) {
|
||||
// if ( vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) {
|
||||
// bOk = vRes[i].get() && bOk ;
|
||||
// ++ nFin ;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// // se Voronoi non è possibile calcolare gli offset di una stessa curva in parallelo
|
||||
// for ( int i = 0 ; i < NUM_OFFS && bOk ; ++ i)
|
||||
// bOk = vOffsCrv[i].Make( pGuide, vDist[i], ICurve::OFF_FILLET) ;
|
||||
// }
|
||||
//
|
||||
// if ( ! bOk ||
|
||||
// vOffsCrv[0].GetCurveCount() == 0 || vOffsCrv[1].GetCurveCount() == 0 ||
|
||||
// vOffsCrv[2].GetCurveCount() == 0 || vOffsCrv[3].GetCurveCount() == 0)
|
||||
// return nullptr ;
|
||||
// PtrOwner<ICurve> pCrvR( vOffsCrv[0].GetLongerCurve()) ;
|
||||
// if ( IsNull( pCrvR))
|
||||
// return nullptr ;
|
||||
// PtrOwner<ICurve> pCrvL( vOffsCrv[1].GetLongerCurve()) ;
|
||||
// if ( IsNull( pCrvL))
|
||||
// return nullptr ;
|
||||
// PtrOwner<ICurve> pCrvRb( vOffsCrv[2].GetLongerCurve()) ;
|
||||
// if ( IsNull( pCrvRb))
|
||||
// return nullptr ;
|
||||
// pCrvRb->Translate( - dBevelV * vtNorm) ;
|
||||
// PtrOwner<ICurve> pCrvLb( vOffsCrv[3].GetLongerCurve()) ;
|
||||
// if ( IsNull( pCrvLb))
|
||||
// return nullptr ;
|
||||
// pCrvLb->Translate( - dBevelV * vtNorm) ;
|
||||
// // costruisco le parti di superficie
|
||||
// PtrOwner<ISurfTriMesh> pSrfTop( GetSurfTriMeshRuled( pCrvR, pCrvL, ISurfTriMesh::RLT_MINDIST, dLinTol)) ;
|
||||
// if ( IsNull( pSrfTop))
|
||||
// return nullptr ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfBot( pSrfTop->Clone()) ;
|
||||
// if ( IsNull( pSrfBot))
|
||||
// return nullptr ;
|
||||
// pSrfBot->Translate( -dDimV * vtNorm) ;
|
||||
// pSrfBot->Invert() ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfTopR( GetSurfTriMeshRuled( pCrvRb, pCrvR, ISurfTriMesh::RLT_MINDIST, dLinTol)) ;
|
||||
// if ( IsNull( pSrfTopR))
|
||||
// return nullptr ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfBotR( pSrfTopR->Clone()) ;
|
||||
// if ( IsNull( pSrfBotR))
|
||||
// return nullptr ;
|
||||
// pSrfBotR->Mirror( ptCen, vtNorm) ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfTopL( GetSurfTriMeshRuled( pCrvL, pCrvLb, ISurfTriMesh::RLT_MINDIST, dLinTol)) ;
|
||||
// if ( IsNull( pSrfTopL))
|
||||
// return nullptr ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfBotL( pSrfTopL->Clone()) ;
|
||||
// if ( IsNull( pSrfBotL))
|
||||
// return nullptr ;
|
||||
// pSrfBotL->Mirror( ptCen, vtNorm) ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfRgt( GetSurfTriMeshByExtrusion( pCrvRb, ( -dDimV + 2 * dBevelV) * vtNorm, false, dLinTol)) ;
|
||||
// if ( IsNull( pSrfRgt))
|
||||
// return nullptr ;
|
||||
// pSrfRgt->Invert() ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfLft( GetSurfTriMeshByExtrusion( pCrvLb, ( -dDimV + 2 * dBevelV) * vtNorm, false, dLinTol)) ;
|
||||
// if ( IsNull( pSrfLft))
|
||||
// return nullptr ;
|
||||
// // unisco le parti
|
||||
// int nBuckets = max( 4 * ( pSrfRgt->GetVertexSize() + pSrfLft->GetVertexSize()), 1000) ;
|
||||
// StmFromTriangleSoup stmSoup ;
|
||||
// if ( ! stmSoup.Start( nBuckets))
|
||||
// return nullptr ;
|
||||
// stmSoup.AddSurfTriMesh( *pSrfTop) ;
|
||||
// stmSoup.AddSurfTriMesh( *pSrfTopR) ;
|
||||
// stmSoup.AddSurfTriMesh( *pSrfTopL) ;
|
||||
// stmSoup.AddSurfTriMesh( *pSrfRgt) ;
|
||||
// stmSoup.AddSurfTriMesh( *pSrfLft) ;
|
||||
// stmSoup.AddSurfTriMesh( *pSrfBotR) ;
|
||||
// stmSoup.AddSurfTriMesh( *pSrfBotL) ;
|
||||
// stmSoup.AddSurfTriMesh( *pSrfBot) ;
|
||||
// PtrOwner<ISurfTriMesh> pSTM ;
|
||||
// // se guida aperta e tappi piatti
|
||||
// if ( ! bGuideClosed && nCapType == RSCAP_FLAT) {
|
||||
// // completo unione e recupero la superficie risultante
|
||||
// if ( ! stmSoup.End())
|
||||
// return nullptr ;
|
||||
// pSTM.Set( stmSoup.GetSurf()) ;
|
||||
// // preparo seconda zuppa di triangoli per inserire i tappi
|
||||
// StmFromTriangleSoup stmCapSoup ;
|
||||
// if ( ! stmCapSoup.Start( nBuckets))
|
||||
// return nullptr ;
|
||||
// // verifico che le due estremità siano chiuse e piatte
|
||||
// POLYLINEVECTOR vPL ;
|
||||
// if ( ! pSTM->GetLoops( vPL) || vPL.size() != 2)
|
||||
// return nullptr ;
|
||||
// Plane3d plEnds ; double dArea ;
|
||||
// if ( ! vPL[0].IsClosedAndFlat( plEnds, dArea, 50 * EPS_SMALL))
|
||||
// return nullptr ;
|
||||
// if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 50 * EPS_SMALL))
|
||||
// return nullptr ;
|
||||
// // calcolo il cap sull'inizio
|
||||
// PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSci) || ! pSci->CreateByFlatContour( vPL[0]))
|
||||
// return nullptr ;
|
||||
// pSci->Invert() ;
|
||||
// // calcolo il cap sulla fine
|
||||
// PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSce) || ! pSce->CreateByFlatContour( vPL[1]))
|
||||
// return nullptr ;
|
||||
// pSce->Invert() ;
|
||||
// // cucio i tappi all'estrusione
|
||||
// if ( ! pSTM->DoSewing( *pSci) || ! pSTM->DoSewing( *pSce))
|
||||
// return nullptr ;
|
||||
// }
|
||||
// // se altrimenti guida aperta e tappi arrotondati
|
||||
// else if ( ! bGuideClosed && ( nCapType == RSCAP_ROUND || nCapType == RSCAP_BEVEL)) {
|
||||
// // step di rotazione per rispettare il tipo o la tolleranza
|
||||
// double dStepRotDeg = ( nCapType == RSCAP_BEVEL ? ANG_STRAIGHT / 4 : sqrt( 8 * dLinTol / dDimH) * RADTODEG) ;
|
||||
// // aggiungo il cap sull'inizio
|
||||
// Point3d ptStart ;
|
||||
// pGuide->GetStartPoint( ptStart) ;
|
||||
// Vector3d vtStart ;
|
||||
// pGuide->GetStartDir( vtStart) ;
|
||||
// vtStart.Rotate( vtNorm, 0, 1) ;
|
||||
// PolyLine PLStart ;
|
||||
// PLStart.AddUPoint( 0, ptStart) ;
|
||||
// PLStart.AddUPoint( 1, ptStart + ( dDimH / 2 - dBevelH) * vtStart) ;
|
||||
// PLStart.AddUPoint( 2, ptStart + dDimH / 2 * vtStart - dBevelV * vtNorm) ;
|
||||
// PLStart.AddUPoint( 3, ptStart + dDimH / 2 * vtStart - ( dDimV - dBevelV) * vtNorm) ;
|
||||
// PLStart.AddUPoint( 4, ptStart + ( dDimH / 2 - dBevelH) * vtStart - dDimV * vtNorm) ;
|
||||
// PLStart.AddUPoint( 5, ptStart - dDimV * vtNorm) ;
|
||||
// PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSci) || ! pSci->CreateByScrewing( PLStart, ptStart, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||
// return nullptr ;
|
||||
// pSci->Invert() ;
|
||||
// stmSoup.AddSurfTriMesh( *pSci) ;
|
||||
// // aggiungo il cap sulla fine
|
||||
// Point3d ptEnd ;
|
||||
// pGuide->GetEndPoint( ptEnd) ;
|
||||
// Vector3d vtEnd ;
|
||||
// pGuide->GetEndDir( vtEnd) ;
|
||||
// vtEnd.Rotate( vtNorm, 0, -1) ;
|
||||
// PolyLine PLEnd ;
|
||||
// PLEnd.AddUPoint( 0, ptEnd) ;
|
||||
// PLEnd.AddUPoint( 1, ptEnd + ( dDimH / 2 - dBevelH) * vtEnd) ;
|
||||
// PLEnd.AddUPoint( 2, ptEnd + dDimH / 2 * vtEnd - dBevelV * vtNorm) ;
|
||||
// PLEnd.AddUPoint( 3, ptEnd + dDimH / 2 * vtEnd - ( dDimV - dBevelV) * vtNorm) ;
|
||||
// PLEnd.AddUPoint( 4, ptEnd + ( dDimH / 2 - dBevelH) * vtEnd - dDimV * vtNorm) ;
|
||||
// PLEnd.AddUPoint( 5, ptEnd - dDimV * vtNorm) ;
|
||||
// PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSce) || ! pSce->CreateByScrewing( PLEnd, ptEnd, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||
// return nullptr ;
|
||||
// pSce->Invert() ;
|
||||
// stmSoup.AddSurfTriMesh( *pSce) ;
|
||||
// // completo unione e recupero la superficie risultante
|
||||
// if ( ! stmSoup.End())
|
||||
// return nullptr ;
|
||||
// pSTM.Set( stmSoup.GetSurf()) ;
|
||||
// }
|
||||
// else {
|
||||
// // completo unione e recupero la superficie risultante
|
||||
// if ( ! stmSoup.End())
|
||||
// return nullptr ;
|
||||
// pSTM.Set( stmSoup.GetSurf()) ;
|
||||
// }
|
||||
// // salvo tolleranza lineare usata e imposto angolo per smooth
|
||||
// pSTM->SetLinearTolerance( dLinTol) ;
|
||||
// pSTM->SetSmoothAngle( 20) ;
|
||||
// // restituisco la superficie
|
||||
// return Release( pSTM) ;
|
||||
//}
|
||||
//
|
||||
////-------------------------------------------------------------------------------
|
||||
//ISurfBezier*
|
||||
//GetSurfBezierRectSwept( double dDimH, double dDimV, double dBevelH, double dBevelV, const ICurve* pGuide, int nCapType, double dLinTol) // DA SISTEMARE - ancora copia della versione stm, cambia solo il nome della funzione//////////////////////
|
||||
//{
|
||||
// // verifica parametri
|
||||
// if ( pGuide == nullptr || dBevelH > 0.4 * dDimH || dBevelV > 0.4 * dDimV)
|
||||
// return nullptr ;
|
||||
// // determino se sezione squadrata o con smusso
|
||||
// bool bSharp = ( dBevelH < 100 * EPS_SMALL || dBevelV < 100 * EPS_SMALL) ;
|
||||
// // eseguo
|
||||
// if ( bSharp)
|
||||
// return GetSurfBezierSharpRectSwept( dDimH, dDimV, pGuide, nCapType, dLinTol) ;
|
||||
// else
|
||||
// return GetSurfBezierBeveledRectSwept( dDimH, dDimV, dBevelH, dBevelV, pGuide, nCapType, dLinTol) ;
|
||||
//}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
ISurfBezier*
|
||||
GetSurfBezierSweptInPlane( const ICurve* pSect, const ICurve* pGuide, const Vector3d& vtNorm, bool bCapEnds, double dLinTol)
|
||||
{
|
||||
//// determino se la sezione è chiusa
|
||||
//bool bSectClosed = pSect->IsClosed() ;
|
||||
//// determino se la guida è chiusa
|
||||
//bool bGuideClosed = pGuide->IsClosed() ;
|
||||
|
||||
// riferimento all'inizio della linea guida
|
||||
// riferimento all'inizio della linea guida
|
||||
Frame3d frStart ;
|
||||
Point3d ptStart ;
|
||||
pGuide->GetStartPoint( ptStart) ;
|
||||
@@ -654,7 +215,7 @@ GetSurfBezierSweptInPlane( const ICurve* pSect, const ICurve* pGuide, const Vect
|
||||
|
||||
// capisco se la guida è una linea spezzata o una curva
|
||||
bool bGuideIsPolyLine = false ;
|
||||
switch( pGuide->GetType()) {
|
||||
switch ( pGuide->GetType()) {
|
||||
case CRV_COMPO : {
|
||||
bGuideIsPolyLine = true ;
|
||||
const ICurveComposite* pCC = GetCurveComposite( pGuide) ;
|
||||
@@ -925,14 +486,10 @@ GetSurfBezierSweptInPlane( const ICurve* pSect, const ICurve* pGuide, const Vect
|
||||
ISurfBezier*
|
||||
GetSurfBezierSwept3d( const ICurve* pSect, const ICurve* pGuide, const Vector3d& vtAx, bool bCapEnds, double dLinTol) // DA SISTEMARE - ancora copia della versione stm, cambia solo il nome della funzione//////////////////////
|
||||
{
|
||||
//// determino se la sezione è chiusa
|
||||
//bool bSectClosed = pSect->IsClosed() ;
|
||||
//// determino se la guida è chiusa
|
||||
//bool bGuideClosed = pGuide->IsClosed() ;
|
||||
// determino algoritmo da usare per calcolare i riferimenti lungo la curva
|
||||
// determino algoritmo da usare per calcolare i riferimenti lungo la curva
|
||||
bool bRMF = vtAx.IsSmall() ;
|
||||
|
||||
// riferimento all'inizio della linea guida
|
||||
// riferimento all'inizio della linea guida
|
||||
Point3d ptStart ;
|
||||
pGuide->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ;
|
||||
@@ -952,7 +509,7 @@ GetSurfBezierSwept3d( const ICurve* pSect, const ICurve* pGuide, const Vector3d&
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
// capisco se la guida è una linea spezzata o una curva
|
||||
// capisco se la guida è una linea spezzata o una curva
|
||||
bool bGuideIsPolyLine = false ;
|
||||
switch( pGuide->GetType()) {
|
||||
case CRV_COMPO : {
|
||||
@@ -960,7 +517,7 @@ GetSurfBezierSwept3d( const ICurve* pSect, const ICurve* pGuide, const Vector3d&
|
||||
const ICurveComposite* pCC = GetCurveComposite( pGuide) ;
|
||||
for ( int i = 0 ; i < pCC->GetCurveCount() && bGuideIsPolyLine ; ++i) {
|
||||
const ICurve* pCrv = pCC->GetCurve( i) ;
|
||||
if( pCrv->GetType() != CRV_LINE) {
|
||||
if ( pCrv->GetType() != CRV_LINE) {
|
||||
if ( pCrv->GetType() == CRV_BEZIER) {
|
||||
const ICurveBezier* pCrvBez = GetCurveBezier( pCrv) ;
|
||||
bGuideIsPolyLine = pCrvBez->IsALine() ;
|
||||
@@ -988,18 +545,18 @@ GetSurfBezierSwept3d( const ICurve* pSect, const ICurve* pGuide, const Vector3d&
|
||||
int nSpanV = 0 ;
|
||||
PtrOwner<ICurveComposite> pCrvV( CreateCurveComposite()) ;
|
||||
if ( bGuideIsPolyLine) {
|
||||
if( pGuide->GetType() == CRV_LINE)
|
||||
if ( pGuide->GetType() == CRV_LINE)
|
||||
nSpanV = 1 ;
|
||||
else if ( pGuide->GetType() == CRV_COMPO)
|
||||
nSpanV = GetCurveComposite( pGuide)->GetCurveCount() ;
|
||||
}
|
||||
else {
|
||||
//converto in bezier la guida ( grado 3, non razionale)
|
||||
// converto in bezier la guida ( grado 3, non razionale)
|
||||
if ( pGuide->GetType() != CRV_BEZIER)
|
||||
pCrvV->AddCurve( CurveToBezierCurve( pGuide, 3, false)) ;
|
||||
else {
|
||||
const ICurveBezier* pGuideBez = GetCurveBezier( pGuide) ;
|
||||
if( ! pGuideBez->IsRational())
|
||||
if ( ! pGuideBez->IsRational())
|
||||
pCrvV->AddCurve( pGuide->Clone()) ;
|
||||
else
|
||||
pCrvV->AddCurve( EditBezierCurve( pGuideBez, 3, false)) ;
|
||||
@@ -1009,7 +566,7 @@ GetSurfBezierSwept3d( const ICurve* pSect, const ICurve* pGuide, const Vector3d&
|
||||
nSpanV = pCrvV->GetCurveCount() ;
|
||||
}
|
||||
|
||||
// converto in bezier la sezione ( grado 3, non razionale)
|
||||
// converto in bezier la sezione ( grado 3, non razionale)
|
||||
PtrOwner<ICurveComposite> pCrvU( CreateCurveComposite()) ;
|
||||
if ( pSect->GetType() != CRV_BEZIER)
|
||||
pCrvU->AddCurve( CurveToBezierCurve( pSect, 3, false)) ;
|
||||
@@ -1023,46 +580,44 @@ GetSurfBezierSwept3d( const ICurve* pSect, const ICurve* pGuide, const Vector3d&
|
||||
if ( IsNull( pCrvU) || ! pCrvU->IsValid())
|
||||
return nullptr ;
|
||||
|
||||
// calcolo il vettore di Frames campionati lungo la guida mediante la tolleranza definita
|
||||
// calcolo il vettore di Frames campionati lungo la guida mediante la tolleranza definita
|
||||
FRAME3DVECTOR vFrames ;
|
||||
if ( bRMF) {
|
||||
RotationMinimizingFrame RMF ;
|
||||
if( bGuideIsPolyLine) {
|
||||
if ( bGuideIsPolyLine) {
|
||||
if ( ! RMF.Set( pGuide, frStart) ||
|
||||
! RMF.GetFramesBySplit( nSpanV, vFrames) || vFrames.empty())
|
||||
! RMF.GetFramesBySplit( nSpanV, vFrames) || vFrames.empty())
|
||||
return nullptr ;
|
||||
}
|
||||
else {
|
||||
if ( ! RMF.Set( pGuide, frStart) ||
|
||||
! RMF.GetFramesByTolerance( dLinTol, vFrames) || vFrames.empty())
|
||||
! RMF.GetFramesByTolerance( dLinTol, vFrames) || vFrames.empty())
|
||||
return nullptr ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
RotationXplaneFrame RXF ;
|
||||
if( bGuideIsPolyLine) {
|
||||
if ( bGuideIsPolyLine) {
|
||||
if ( ! RXF.Set( pGuide, vtAx, frStart.VersX()) ||
|
||||
! RXF.GetFramesBySplit( nSpanV, vFrames) || vFrames.empty())
|
||||
! RXF.GetFramesBySplit( nSpanV, vFrames) || vFrames.empty())
|
||||
return nullptr ;
|
||||
}
|
||||
else {
|
||||
if ( ! RXF.Set( pGuide, vtAx, frStart.VersX()) ||
|
||||
! RXF.GetFramesByTolerance( dLinTol, vFrames) || vFrames.empty())
|
||||
! RXF.GetFramesByTolerance( dLinTol, vFrames) || vFrames.empty())
|
||||
return nullptr ;
|
||||
}
|
||||
}
|
||||
|
||||
//// per ogni Frame calcolato, la sezione va roto-traslata lungo la guida
|
||||
// per ogni Frame calcolato, la sezione va roto-traslata lungo la guida
|
||||
int nSpanU = int( pCrvU->GetCurveCount()) ;
|
||||
int nDegU = 9 ; // debug
|
||||
|
||||
|
||||
int nDegV = 3 ;
|
||||
if ( bGuideIsPolyLine){
|
||||
nDegV = 1 ;
|
||||
// superficie swept
|
||||
PtrOwner<ISurfBezier> pSurfBez( CreateSurfBezier()) ;
|
||||
pSurfBez->Init( nDegU,nDegV, nSpanU, nSpanV, bRat) ;
|
||||
pSurfBez->Init( nDegU, nDegV, nSpanU, nSpanV, bRat) ;
|
||||
pCrvU->ToLoc( frStart) ;
|
||||
for ( int f = 0 ; f < int( vFrames.size()) ; ++f) {
|
||||
PtrOwner<ICurveComposite> pNewSect( pCrvU->Clone()) ;
|
||||
@@ -1125,191 +680,6 @@ GetSurfBezierSwept3d( const ICurve* pSect, const ICurve* pGuide, const Vector3d&
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
////-------------------------------------------------------------------------------
|
||||
//ISurfBezier*
|
||||
//GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, const Vector3d& vtAx,
|
||||
// bool bCapEnds, double dLinTol) // DA SISTEMARE - ancora copia della versione stm, cambia solo il nome della funzione//////////////////////
|
||||
//{
|
||||
// // verifica parametri
|
||||
// if ( pSect == nullptr || pGuide == nullptr)
|
||||
// return nullptr ;
|
||||
//
|
||||
// bool bIsLine = false ;
|
||||
// if ( pGuide->GetType() == CRV_LINE)
|
||||
// bIsLine = true ;
|
||||
// else {
|
||||
// const CurveComposite* pCompo = GetBasicCurveComposite( pGuide) ;
|
||||
// Point3d ptStart, ptEnd ;
|
||||
// if ( pCompo != nullptr && pCompo->IsALine( 10 * EPS_SMALL, ptStart, ptEnd))
|
||||
// bIsLine = true ;
|
||||
// }
|
||||
// // se la guida è piana
|
||||
// Plane3d plGuide ;
|
||||
// if ( pGuide->IsFlat( plGuide, bIsLine, 10 * EPS_SMALL))
|
||||
// return GetSurfBezierSweptInPlane( pSect, pGuide, plGuide.GetVersN(), bCapEnds, dLinTol) ;
|
||||
//
|
||||
// // altrimenti swept 3d
|
||||
// return GetSurfBezierSwept3d( pSect, pGuide, vtAx, bCapEnds, dLinTol) ;
|
||||
//}
|
||||
//
|
||||
////-------------------------------------------------------------------------------
|
||||
//ISurfBezier*
|
||||
//GetSurfBezierSwept( const ISurfFlatRegion* pSfrSect, const ICurve* pGuide, const Vector3d& vtAx,
|
||||
// bool bCapEnds, double dLinTol) // DA SISTEMARE - ancora copia della versione stm, cambia solo il nome della funzione//////////////////////
|
||||
//{
|
||||
// // verifica dei parametri
|
||||
// if ( pSfrSect == nullptr || pGuide == nullptr)
|
||||
// return nullptr ;
|
||||
//
|
||||
// // predispongo collettore superfici componenti
|
||||
// StmFromTriangleSoup StmSoup ;
|
||||
// StmSoup.Start() ;
|
||||
//
|
||||
// // per ogni loop della superficie, creo una Swept
|
||||
// for ( int nC = 0 ; nC < pSfrSect->GetChunkCount() ; ++ nC) {
|
||||
// for ( int nL = 0 ; nL < pSfrSect->GetLoopCount( nC) ; ++ nL) {
|
||||
// // recupero il loop
|
||||
// PtrOwner<ICurve> pCrvLoop( pSfrSect->GetLoop( nC, nL)) ;
|
||||
// if ( IsNull( pCrvLoop) || ! pCrvLoop->IsValid())
|
||||
// return nullptr ;
|
||||
// // creo la Trimesh Swept
|
||||
// PtrOwner<ISurfTriMesh> pStmLoopSwept( GetSurfTriMeshSwept( pCrvLoop, pGuide, vtAx, false, dLinTol)) ;
|
||||
// if ( IsNull( pStmLoopSwept) || ! pStmLoopSwept->IsValid())
|
||||
// return nullptr ;
|
||||
// // aggiungo la Swept ricavata al risultato finale ( come triangoli )
|
||||
// StmSoup.AddSurfTriMesh( *pStmLoopSwept) ;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Recupero la superficie
|
||||
// if ( ! StmSoup.End())
|
||||
// return nullptr ;
|
||||
// PtrOwner<ISurfTriMesh> pStmSwept( StmSoup.GetSurf()) ;
|
||||
// if ( IsNull( pStmSwept))
|
||||
// return nullptr ;
|
||||
//
|
||||
// // se rischiesta chiusura...
|
||||
// // Controllo solo che la guida non sia chiusa, la sezione derivando da una Flatregion è sempre chiusa
|
||||
// if ( bCapEnds && ! pGuide->IsClosed()) {
|
||||
// // recupero i loop all'inizio (dalla regione e apportunamente approssimati)
|
||||
// POLYLINEVECTOR vPLi ;
|
||||
// for ( int nC = 0 ; nC < pSfrSect->GetChunkCount() ; ++ nC) {
|
||||
// for ( int nL = 0 ; nL < pSfrSect->GetLoopCount( nC) ; ++ nL) {
|
||||
// vPLi.emplace_back() ;
|
||||
// if ( ! pSfrSect->ApproxLoopWithLines( nC, nL, dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, vPLi.back()))
|
||||
// return nullptr ;
|
||||
// }
|
||||
// }
|
||||
// // creo il cap sull'inizio e lo attacco alla swept ( è già in posizione giusta)
|
||||
// PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
|
||||
// if ( ! pSci->CreateByRegion( vPLi))
|
||||
// return nullptr ;
|
||||
// pStmSwept->DoSewing( *pSci) ;
|
||||
// // recupero i loops alla fine
|
||||
// POLYLINEVECTOR vPLe ;
|
||||
// if ( ! pStmSwept->GetLoops( vPLe))
|
||||
// return nullptr ;
|
||||
// // creo la superficie alla fine e la attacco
|
||||
// PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
|
||||
// if ( ! pSce->CreateByRegion( vPLe))
|
||||
// return nullptr ;
|
||||
// // attacco la superficie finale alla swept
|
||||
// pSce->Invert() ;
|
||||
// pStmSwept->DoSewing( *pSce) ;
|
||||
// }
|
||||
// // se superficie risultante chiusa, verifico che la normale sia verso l'esterno
|
||||
// double dVol ;
|
||||
// if ( pStmSwept->GetVolume( dVol) && dVol < 0)
|
||||
// pStmSwept->Invert() ;
|
||||
//
|
||||
// return Release( pStmSwept) ;
|
||||
//}
|
||||
//
|
||||
////-------------------------------------------------------------------------------
|
||||
//ISurfBezier*
|
||||
//GetSurfBezierTransSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, double dLinTol) // DA SISTEMARE - ancora copia della versione stm, cambia solo il nome della funzione//////////////////////
|
||||
//{
|
||||
// // verifica parametri
|
||||
// if ( pSect == nullptr || pGuide == nullptr)
|
||||
// return nullptr ;
|
||||
// // determino se la sezione è chiusa
|
||||
// bool bSectClosed = pSect->IsClosed() ;
|
||||
// // punto iniziale della sezione e vettore a inizio guida
|
||||
// Point3d ptStart ;
|
||||
// if ( ! pSect->GetStartPoint( ptStart))
|
||||
// return nullptr ;
|
||||
// Point3d ptGuide ;
|
||||
// if ( ! pGuide->GetStartPoint( ptGuide))
|
||||
// return nullptr ;
|
||||
// Vector3d vtDelta = ptStart - ptGuide ;
|
||||
// // calcolo la polilinea che approssima la guida
|
||||
// PolyLine PLG ;
|
||||
// if ( ! pGuide->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PLG))
|
||||
// return nullptr ;
|
||||
// // determino se la guida è chiusa
|
||||
// bool bGuideClosed = PLG.IsClosed() ;
|
||||
// // calcolo la superficie
|
||||
// PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSTM))
|
||||
// return nullptr ;
|
||||
// // salvo tolleranza lineare usata
|
||||
// pSTM->SetLinearTolerance( dLinTol) ;
|
||||
// // superficie swept
|
||||
// PtrOwner<ICurve> pPrevCrv ;
|
||||
// Point3d ptP ;
|
||||
// bool bPoint = PLG.GetFirstPoint( ptP) ;
|
||||
// while ( bPoint) {
|
||||
// // nuova curva
|
||||
// PtrOwner<ICurve> pCurrCrv( pSect->Clone()) ;
|
||||
// if ( IsNull( pCurrCrv))
|
||||
// return nullptr ;
|
||||
// pCurrCrv->Translate( ptP - ptStart + vtDelta) ;
|
||||
// // se esiste la curva precedente, costruisco la rigata (di tipo minima distanza)
|
||||
// if ( ! IsNull( pPrevCrv)) {
|
||||
// PtrOwner<ISurfTriMesh> pSr( GetSurfTriMeshRuled( pPrevCrv, pCurrCrv, ISurfTriMesh::RLT_ISOPAR, dLinTol)) ;
|
||||
// if ( IsNull( pSr))
|
||||
// return nullptr ;
|
||||
// pSTM->DoSewing( *pSr) ;
|
||||
// }
|
||||
// // salvo la curva come prossima precedente
|
||||
// pPrevCrv.Set( pCurrCrv) ;
|
||||
// // prossimo punto
|
||||
// bPoint = PLG.GetNextPoint( ptP) ;
|
||||
// }
|
||||
// // se richiesti caps e sezione chiusa e guida aperta
|
||||
// if ( bCapEnds && bSectClosed && ! bGuideClosed) {
|
||||
// // calcolo la polilinea che approssima la sezione
|
||||
// PolyLine PLS ;
|
||||
// if ( ! pSect->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PLS))
|
||||
// return nullptr ;
|
||||
// // verifico che la sezione sia chiusa e piatta
|
||||
// Plane3d plSect ; double dArea ;
|
||||
// if ( PLS.IsClosedAndFlat( plSect, dArea, 100 * EPS_SMALL)) {
|
||||
// // aggiungo il cap sull'inizio
|
||||
// PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSci) || ! pSci->CreateByFlatContour( PLS))
|
||||
// return nullptr ;
|
||||
// pSci->Invert() ;
|
||||
// Point3d ptGi ; PLG.GetFirstPoint( ptGi) ;
|
||||
// pSci->Translate( ptGi - ptStart + vtDelta) ;
|
||||
// pSTM->DoSewing( *pSci) ;
|
||||
// // aggiungo il cap sulla fine
|
||||
// PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSce) || ! pSce->CreateByFlatContour( PLS))
|
||||
// return nullptr ;
|
||||
// Point3d ptGe ; PLG.GetLastPoint( ptGe) ;
|
||||
// pSce->Translate( ptGe - ptStart + vtDelta) ;
|
||||
// pSTM->DoSewing( *pSce) ;
|
||||
// }
|
||||
// }
|
||||
// // se superficie risultante chiusa, verifico che la normale sia verso l'esterno
|
||||
// double dVol ;
|
||||
// if ( pSTM->GetVolume( dVol) && dVol < 0)
|
||||
// pSTM->Invert() ;
|
||||
// // restituisco la superficie
|
||||
// return Release( pSTM) ;
|
||||
//}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
ISurfBezier*
|
||||
GetSurfBezierRuled( const Point3d& ptP, const ICurve* pCurve, double dLinTol)
|
||||
@@ -1317,16 +687,12 @@ GetSurfBezierRuled( const Point3d& ptP, const ICurve* pCurve, double dLinTol)
|
||||
// verifica parametri
|
||||
if ( &ptP == nullptr || pCurve == nullptr)
|
||||
return nullptr ;
|
||||
//// calcolo la polilinea che approssima la curva
|
||||
//PolyLine PL ;
|
||||
//if ( ! pCurve->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
|
||||
// return nullptr ;
|
||||
|
||||
// creo e setto la superficie trimesh
|
||||
PtrOwner<SurfBezier> pSbz( CreateBasicSurfBezier()) ;
|
||||
if ( IsNull( pSbz) || ! pSbz->CreateByPointCurve( ptP, pCurve))
|
||||
return nullptr ;
|
||||
//// salvo tolleranza lineare usata
|
||||
//pSbz->SetLinearTolerance( dLinTol) ;
|
||||
|
||||
// restituisco la superficie
|
||||
return Release( pSbz) ;
|
||||
}
|
||||
@@ -1362,8 +728,7 @@ GetSurfBezierRuled( const ICurve* pCurve1, const ICurve* pCurve2, int nType, dou
|
||||
PtrOwner<SurfBezier> pSbz( CreateBasicSurfBezier()) ;
|
||||
if ( IsNull( pSbz) || ! pSbz->CreateByTwoCurves( pCC1, pCC2, nType))
|
||||
return nullptr ;
|
||||
//// salvo tolleranza lineare usata
|
||||
//pSbz->SetLinearTolerance( dLinTol) ;
|
||||
|
||||
// restituisco la superficie
|
||||
return Release( pSbz) ;
|
||||
}
|
||||
@@ -1404,4 +769,4 @@ GetSurfBezierSkinned( const CICURVEPVECTOR& vCrv, double dLinTol)
|
||||
return nullptr ;
|
||||
// restituisco la superficie
|
||||
return Release( pSbz) ;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -115,7 +115,8 @@ GetSurfFlatRegionDisk( double dRadius)
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
ISurfFlatRegion*
|
||||
GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, bool bSquareMids, double dOffsLinTol)
|
||||
GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, bool bSquareMids, double dOffsLinTol,
|
||||
bool bMergeOnlySameProps)
|
||||
{
|
||||
// metodo di calcolo impostato da USE_VORONOI
|
||||
|
||||
@@ -330,7 +331,7 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b
|
||||
else {
|
||||
// calcolo la fat curve con Voronoi
|
||||
ICURVEPOVECTOR vFatCurves ;
|
||||
if ( ! CalcCurveFatCurve( *pCurve, vFatCurves, dRadius, bSquareEnds, bSquareMids))
|
||||
if ( ! CalcCurveFatCurve( *pCurve, vFatCurves, dRadius, bSquareEnds, bSquareMids, bMergeOnlySameProps))
|
||||
return nullptr ;
|
||||
|
||||
// costruisco la superficie a partire dalle curve
|
||||
|
||||
+233
-146
@@ -18,6 +18,7 @@
|
||||
#include "NgeWriter.h"
|
||||
#include "NgeReader.h"
|
||||
#include "Bernstein.h"
|
||||
#include "CurveArc.h"
|
||||
#include "CurveBezier.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "Tree.h"
|
||||
@@ -40,7 +41,6 @@
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Extern/Eigen/Dense"
|
||||
#include "/EgtDev/Include/EGkGeoObjSave.h"
|
||||
|
||||
|
||||
using namespace std ;
|
||||
@@ -300,6 +300,62 @@ SurfBezier::GetArea( double& dArea) const
|
||||
return m_pSTM->GetArea( dArea) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfBezier::IsClosed( void) const
|
||||
{
|
||||
// altrimenti verifico a mano
|
||||
if ( m_nSpanU == 1 || m_nSpanV == 1)
|
||||
return false ;
|
||||
|
||||
// controllo la prima riga con l'ultima
|
||||
m_bClosedV = true ;
|
||||
for ( int i = 0 ; i < m_nDegU * m_nSpanU + 1 && m_bClosedV ; ++i)
|
||||
m_bClosedV = AreSamePointApprox( m_vPtCtrl[GetInd( i, 0)], m_vPtCtrl[ GetInd(i, m_nDegV * m_nSpanV)]) ;
|
||||
|
||||
// controllo la prima colonna con l'ultima
|
||||
m_bClosedU = true ;
|
||||
for ( int j = 0 ; j < m_nDegV * m_nSpanV + 1 && m_bClosedU ; ++j)
|
||||
m_bClosedU = AreSamePointApprox( m_vPtCtrl[GetInd(0,j)], m_vPtCtrl[GetInd(m_nDegU * m_nSpanU,j)]) ;
|
||||
|
||||
// se ho la chiusura su entrambi i parametri ho la chiusura "in stile toro"
|
||||
if( m_bClosedU && m_bClosedV)
|
||||
return true ;
|
||||
|
||||
//verifico se ci sono dei poli che chiudono la superficie, per vedere se ho la chiusura "in stile sfera, da polo a polo" ( classica superficie di rivoluzione)
|
||||
CalcPoles() ;
|
||||
// chiusa in U e con poli sugli altri 2 lati
|
||||
if( m_bClosedU && ! m_bClosedV && m_vbPole[0] && m_vbPole[2])
|
||||
return true ;
|
||||
// chiusa in V e con poli sugli altri due lati
|
||||
if( m_bClosedV && ! m_bClosedU && m_vbPole[1] && m_vbPole[3])
|
||||
return true ;
|
||||
|
||||
// se ho due lati opposti che sono dei poli e sono anche coincidenti allora la superficie potrebbe essere chiusa "in stile sfera a saccoccia"
|
||||
if ( m_vbPole[0] && m_vbPole[2] && AreSamePointApprox( m_vPtCtrl[GetInd(0,0)], m_vPtCtrl[GetInd(m_nDegU * m_nSpanU, m_nDegV * m_nSpanV)]) ) {
|
||||
bool bV0BackAndForth = true ;
|
||||
bool bV1BackAndForth = true ;
|
||||
for ( int i = 0 ; i < (m_nDegV * m_nSpanV + 1) / 2 && bV0BackAndForth && bV1BackAndForth; ++i) {
|
||||
bV0BackAndForth = AreSamePointApprox( m_vPtCtrl[GetInd(0,i)], m_vPtCtrl[GetInd(0,m_nDegV * m_nSpanV - i)]) ;
|
||||
bV1BackAndForth = AreSamePointApprox( m_vPtCtrl[GetInd(m_nDegU * m_nSpanU,i)], m_vPtCtrl[GetInd(m_nDegU * m_nSpanU,m_nDegV * m_nSpanV - i)]) ;
|
||||
}
|
||||
if ( bV0BackAndForth && bV1BackAndForth)
|
||||
return true ;
|
||||
}
|
||||
if ( m_vbPole[1] && m_vbPole[3] && AreSamePointApprox( m_vPtCtrl[GetInd(0,0)], m_vPtCtrl[GetInd(m_nDegU * m_nSpanU, m_nDegV * m_nSpanV)]) ) {
|
||||
bool bU0BackAndForth = true ;
|
||||
bool bU1BackAndForth = true ;
|
||||
for ( int i = 0 ; i < (m_nDegU * m_nSpanU + 1) / 2 && bU0BackAndForth && bU1BackAndForth; ++i) {
|
||||
bU0BackAndForth = AreSamePointApprox( m_vPtCtrl[GetInd( i,0)], m_vPtCtrl[GetInd( m_nDegU * m_nSpanU - i, 0)]) ;
|
||||
bU1BackAndForth = AreSamePointApprox( m_vPtCtrl[GetInd( i, m_nDegV * m_nSpanV)], m_vPtCtrl[GetInd( m_nDegU * m_nSpanU - i, m_nDegV * m_nSpanV)]) ;
|
||||
}
|
||||
if ( bU0BackAndForth && bU1BackAndForth)
|
||||
return true ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfBezier::GetCentroid( Point3d& ptCen) const
|
||||
@@ -813,15 +869,21 @@ SurfBezier::Dump( string& sOut, bool bMM, const char* szNewLine) const
|
||||
double dArea ;
|
||||
GetArea( dArea) ;
|
||||
sOut += "Area=" + ToString( GetAreaInUiUnits( dArea, bMM),1) + szNewLine ;
|
||||
// altri dati per superficie chiusa
|
||||
if ( IsClosed()) {
|
||||
double dVolume ;
|
||||
GetVolume( dVolume) ;
|
||||
sOut += "Closed Volume=" + ToString( GetVolumeInUiUnits( dVolume, bMM), 1) + szNewLine ;
|
||||
}
|
||||
// parametri : flag razionale
|
||||
sOut += ( m_bRat ? "Rat" : "Int") ;
|
||||
// flag trimmata
|
||||
// flag trimmata
|
||||
sOut += ( m_bTrimmed ? " Trim " : " Full") ;
|
||||
// gradi in U e V
|
||||
// gradi in U e V
|
||||
sOut += " DegU=" + ToString( m_nDegU) + " DegV=" + ToString( m_nDegV) ;
|
||||
// pezze in U e V
|
||||
// pezze in U e V
|
||||
sOut += " SpanU=" + ToString( m_nSpanU) + " SpanV=" + ToString( m_nSpanV) + szNewLine ;
|
||||
// ciclo sui punti di controllo ( con pesi se razionale)
|
||||
// ciclo sui punti di controllo ( con pesi se razionale)
|
||||
for ( int i = 0 ; i < GetDim() ; ++ i) {
|
||||
sOut += "PC(" + ToString( GetInUiUnits( m_vPtCtrl[i], bMM), 3) ;
|
||||
if ( m_bRat)
|
||||
@@ -2098,6 +2160,10 @@ SurfBezier::IncreaseUV( double& dUV, double dxy, bool bUOrV, double* dUVCopy, bo
|
||||
bool
|
||||
SurfBezier::UnprojectCurveFromStm( const ICurveComposite* pCC, ICRVCOMPOPVECTOR& vpCC, const Plane3d* pPlCut) const
|
||||
{
|
||||
// calcolo la superficie se non già calcolata
|
||||
if ( m_pSTMRefined == nullptr)
|
||||
GetAuxSurfRefined() ;
|
||||
|
||||
// se necessario calcolo i poli
|
||||
if ( m_vbPole.empty())
|
||||
CalcPoles() ;
|
||||
@@ -2727,6 +2793,10 @@ SurfBezier::UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, in
|
||||
bool
|
||||
SurfBezier::UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, int nIL, const Point3d& ptIPrevOrNext, bool* bThroughEdge) const
|
||||
{
|
||||
// calcolo la superficie se non già calcolata
|
||||
if ( m_pSTMRefined == nullptr)
|
||||
GetAuxSurfRefined() ;
|
||||
|
||||
ptSP = ORIG ;
|
||||
if ( bThroughEdge != nullptr)
|
||||
*bThroughEdge = false ;
|
||||
@@ -3051,6 +3121,10 @@ SurfBezier::UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, in
|
||||
bool
|
||||
SurfBezier::UnprojectPoint( const Point3d& pt3D, Point3d& ptParam, const Point3d& ptIPrev, bool* bThroughEdge, const Plane3d* pPlCut) const
|
||||
{
|
||||
// calcolo la superficie se non già calcolata
|
||||
if ( m_pSTMRefined == nullptr)
|
||||
GetAuxSurfRefined() ;
|
||||
|
||||
// se necessario calcolo i poli
|
||||
if ( m_vbPole.empty())
|
||||
CalcPoles() ;
|
||||
@@ -3867,14 +3941,14 @@ SurfBezier::CreateByExtrusion( const ICurve* pCrv, const Vector3d& vtExtr, bool
|
||||
return false ;
|
||||
// se composita verifico che curve siano con lo stesso grado e uniformi come tipo
|
||||
|
||||
PtrOwner<ICurveComposite> pCC( CreateCurveComposite()) ;
|
||||
pCC->AddCurve( pCrv->Clone()) ;
|
||||
CurveComposite CC ;
|
||||
CC.AddCurve( pCrv->Clone()) ;
|
||||
bool bRat = false ;
|
||||
int nDegU = 1 ;
|
||||
for ( int i = 0 ; i < pCC->GetCurveCount() ; ++i) {
|
||||
if ( pCC->GetCurve( i)->GetType() != CRV_BEZIER)
|
||||
for ( int i = 0 ; i < CC.GetCurveCount() ; ++i) {
|
||||
if ( CC.GetCurve( i)->GetType() != CRV_BEZIER)
|
||||
return false ;
|
||||
const ICurveBezier* pCrvBez = static_cast<const ICurveBezier*>( pCC->GetCurve( i)) ;
|
||||
const ICurveBezier* pCrvBez = GetCurveBezier( CC.GetCurve( i)) ;
|
||||
if ( i == 0 ) {
|
||||
bRat = pCrvBez->IsRational() ;
|
||||
nDegU = pCrvBez->GetDegree() ;
|
||||
@@ -3888,12 +3962,12 @@ SurfBezier::CreateByExtrusion( const ICurve* pCrv, const Vector3d& vtExtr, bool
|
||||
// riempio la matrice dei punti di controllo
|
||||
// parto dalla curva che sto estrudendo e mi alzo progressivamente seguendo il vettore vtExtr
|
||||
int nDegV = bDeg3orDeg2 ? 3 : 2 ;
|
||||
int nSpanU = pCC->GetCurveCount() ;
|
||||
int nSpanU = CC.GetCurveCount() ;
|
||||
int nSpanV = 1 ;
|
||||
Init(nDegU, nDegV, nSpanU, nSpanV, bRat) ;
|
||||
|
||||
for ( int k = 0 ; k < nSpanU ; ++k) {
|
||||
const ICurveBezier* pCrvBezier = static_cast<const ICurveBezier*>( pCC->GetCurve( k)) ;
|
||||
const ICurveBezier* pCrvBezier = GetCurveBezier( CC.GetCurve( k)) ;
|
||||
for ( int i = 0 ; i < nDegU + 1 ; ++i) {
|
||||
if ( k != 0 && i == 0)
|
||||
continue ;
|
||||
@@ -3938,32 +4012,38 @@ SurfBezier::CreateByExtrusion( const ICurve* pCrv, const Vector3d& vtExtr, bool
|
||||
bool
|
||||
SurfBezier::CreateByScrewing( const ICurve* pCurve, const Point3d& ptAx, const Vector3d& vtAx, double dAngRotDeg, double dMove)
|
||||
{
|
||||
// verifico che l'asse di rotazione sia non nullo
|
||||
// verifico validità curva
|
||||
if ( pCurve == nullptr || ! pCurve->IsValid())
|
||||
return false ;
|
||||
// verifico che l'asse di rotazione sia non nullo
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
// verifico se solo rivoluzione
|
||||
bool bOnlyRev = ( abs( dMove) < EPS_SMALL) ;
|
||||
// verifico che l'angolo di rotazione sia significativo e, se solo rivoluzione, non superi un giro
|
||||
// verifico che l'angolo di rotazione sia significativo
|
||||
if ( abs( dAngRotDeg) < EPS_ANG_SMALL)
|
||||
return false ;
|
||||
// verifico se solo rivoluzione
|
||||
bool bOnlyRev = ( abs( dMove) < EPS_SMALL) ;
|
||||
// se solo rivoluzione, limito la rotazione entro un giro
|
||||
if ( bOnlyRev && abs( dAngRotDeg) > ANG_FULL)
|
||||
dAngRotDeg = _copysign( ANG_FULL, dAngRotDeg) ;
|
||||
|
||||
// se sto facendo una rivoluzione e la curva è piana faccio un controllo
|
||||
// se la curva attraversa l'asse allora mi fermo
|
||||
// se sto facendo una rivoluzione e la curva è piana, controllo che la curva non attraversi l'asse
|
||||
if ( abs( dMove) < EPS_SMALL ) {
|
||||
Plane3d plPlane ;
|
||||
if ( pCurve->IsFlat(plPlane, false, EPS_SMALL) ) {
|
||||
PtrOwner<ICurveLine> pAx( CreateCurveLine()) ;
|
||||
pAx->Set( ptAx - vtAx * 5e5, ptAx + vtAx * 5e5) ;
|
||||
IntersCurveCurve icc( *pCurve, *pAx) ;
|
||||
if ( pCurve->IsFlat( plPlane, false, 10 * EPS_SMALL)) {
|
||||
BBox3d b3Crv ;
|
||||
pCurve->GetLocalBBox( b3Crv) ;
|
||||
double dAxLen = b3Crv.MaxDistFromPoint( ptAx) ;
|
||||
CurveLine crvAx ;
|
||||
crvAx.Set( ptAx - dAxLen * vtAx, ptAx + dAxLen * vtAx) ;
|
||||
IntersCurveCurve icc( *pCurve, crvAx) ;
|
||||
Point3d ptStart ; pCurve->GetStartPoint( ptStart) ;
|
||||
Point3d ptEnd ; pCurve->GetStartPoint( ptEnd) ;
|
||||
for ( int i = 0 ; i < int(icc.GetIntersCount()) ; ++i) {
|
||||
Point3d ptEnd ; pCurve->GetEndPoint( ptEnd) ;
|
||||
for ( int i = 0 ; i < icc.GetIntersCount() ; ++i) {
|
||||
IntCrvCrvInfo iccInfo ;
|
||||
icc.GetIntCrvCrvInfo( i, iccInfo) ;
|
||||
//controllo che sia una vera intersezione in 3D, sennò passo alla successiva
|
||||
if( ! AreSamePointApprox( iccInfo.IciA[0].ptI, iccInfo.IciB[0].ptI))
|
||||
// controllo che sia una vera intersezione in 3D, altrimenti passo alla successiva
|
||||
if ( ! AreSamePointApprox( iccInfo.IciA[0].ptI, iccInfo.IciB[0].ptI))
|
||||
continue ;
|
||||
// se è il punto di inizio o di fine va bene e procedo
|
||||
if ( AreSamePointApprox( ptStart, iccInfo.IciA[0].ptI) || AreSamePointApprox( ptEnd, iccInfo.IciA[0].ptI))
|
||||
@@ -3975,41 +4055,41 @@ SurfBezier::CreateByScrewing( const ICurve* pCurve, const Point3d& ptAx, const V
|
||||
}
|
||||
}
|
||||
|
||||
// converto in bezier la curva iniziale
|
||||
PtrOwner<ICurveComposite> pCrvU ( CreateCurveComposite()) ;
|
||||
// se la curva è già una bezier singola la tengo, sennò la converto
|
||||
// converto in bezier la curva iniziale
|
||||
CurveComposite CrvU ;
|
||||
// se la curva è già una bezier singola la tengo, sennò la converto
|
||||
if ( pCurve->GetType() != CRV_BEZIER)
|
||||
pCrvU->AddCurve( CurveToBezierCurve( pCurve, 3, true)) ;
|
||||
CrvU.AddCurve( CurveToBezierCurve( pCurve, 3, true)) ;
|
||||
else {
|
||||
if( GetCurveBezier(pCurve)->IsRational())
|
||||
pCrvU->AddCurve( pCurve->Clone()) ;
|
||||
if ( GetCurveBezier(pCurve)->IsRational())
|
||||
CrvU.AddCurve( pCurve->Clone()) ;
|
||||
else {
|
||||
ICurveBezier* pCrvCopy = GetCurveBezier( pCurve->Clone()) ;
|
||||
pCrvCopy->MakeRational() ;
|
||||
pCrvU->AddCurve( pCrvCopy) ;
|
||||
CrvU.AddCurve( pCrvCopy) ;
|
||||
}
|
||||
}
|
||||
if ( IsNull( pCrvU) || ! pCrvU->IsValid())
|
||||
if ( ! CrvU.IsValid())
|
||||
return false ;
|
||||
int nSpanU = int( pCrvU->GetCurveCount()) ;
|
||||
int nDegU = ( GetCurveBezier( pCrvU->GetCurve(0)))->GetDegree() ;
|
||||
int nSpanU = int( CrvU.GetCurveCount()) ;
|
||||
int nDegU = ( GetCurveBezier( CrvU.GetCurve(0)))->GetDegree() ;
|
||||
|
||||
// creo la spirale su cui far la rail della curva ( in questo caso sarà la curva di bezier che delimita il bordo sinistro dello spazio parametrico tra il punto P00 e il punto P01)
|
||||
PtrOwner<ICurveComposite> pCrvV ( CreateCurveComposite()) ;
|
||||
// devo trovare un punto che NON stia sull'asse per poter costruire una spirale e sapere quante span in V avrò
|
||||
// creo la spirale su cui fare la rail della curva ( in questo caso sarà la curva di bezier che delimita il bordo sinistro dello spazio parametrico tra il punto P00 e il punto P01)
|
||||
CurveComposite CrvVSpiral ;
|
||||
// devo trovare un punto che NON stia sull'asse per poter costruire una spirale e sapere quante span in V avrò
|
||||
DBLVECTOR vdSpiralW ;
|
||||
bool bFound = false ;
|
||||
for ( int j = 0 ; j < nSpanU && ! bFound ; ++j) {
|
||||
const ICurveBezier* pSubCrvBezU = GetCurveBezier( pCrvU->GetCurve( j)) ;
|
||||
const ICurveBezier* pSubCrvBezU = GetCurveBezier( CrvU.GetCurve( j)) ;
|
||||
for ( int i = 0 ; i < nDegU + 1 && ! bFound ; ++i) {
|
||||
Point3d ptCtrlU = pSubCrvBezU->GetControlPoint( i) ;
|
||||
DistPointLine dpl( ptCtrlU, ptAx, vtAx, 1, false) ;
|
||||
if ( ! dpl.IsSmall()) {
|
||||
PtrOwner<ICurveArc> pSpiral( CreateCurveArc()) ;
|
||||
pSpiral->SetCPAN( ptAx, ptCtrlU, dAngRotDeg, dMove, vtAx) ;
|
||||
// converto in bezier la spirale
|
||||
pCrvV->AddCurve( ArcToBezierCurve( pSpiral,3 , true)) ;
|
||||
const ICurveBezier* pFirstBez = GetCurveBezier( pCrvV->GetCurve( 0)) ;
|
||||
CurveArc crvSpiral ;
|
||||
crvSpiral.SetCPAN( ptAx, ptCtrlU, dAngRotDeg, dMove, vtAx) ;
|
||||
// converto in bezier la spirale
|
||||
CrvVSpiral.AddCurve( ArcToBezierCurve( &crvSpiral, 3 , true)) ;
|
||||
const ICurveBezier* pFirstBez = GetCurveBezier( CrvVSpiral.GetCurve( 0)) ;
|
||||
int nDeg = pFirstBez->GetDegree() ;
|
||||
for ( int k = 0 ; k < nDeg + 1 ; ++k)
|
||||
vdSpiralW.push_back( pFirstBez->GetControlWeight( k)) ;
|
||||
@@ -4020,72 +4100,71 @@ SurfBezier::CreateByScrewing( const ICurve* pCurve, const Point3d& ptAx, const V
|
||||
if ( ! bFound)
|
||||
return false ;
|
||||
|
||||
if ( IsNull( pCrvV) || ! pCrvV->IsValid())
|
||||
if ( ! CrvVSpiral.IsValid())
|
||||
return false ;
|
||||
int nSpanV = int( pCrvV->GetCurveCount()) ;
|
||||
int nDegV = ( GetCurveBezier( pCrvV->GetCurve(0)))->GetDegree() ;
|
||||
// inizializzo la superficie
|
||||
bool bRat = true ; // perché nella direzione del parametro V ho sicuramente delle razioniali
|
||||
int nSpanV = CrvVSpiral.GetCurveCount() ;
|
||||
int nDegV = GetCurveBezier( CrvVSpiral.GetCurve(0))->GetDegree() ;
|
||||
// inizializzo la superficie (deve essere razionale)
|
||||
bool bRat = true ;
|
||||
Init( nDegU, nDegV, nSpanU, nSpanV, bRat) ;
|
||||
|
||||
|
||||
// per ogni punto di controllo della curva di base creo la spirale che rappresenta la screw di quel punto
|
||||
// scorro le sottocurve della curva di base
|
||||
// per ogni punto di controllo della curva di base creo la spirale che rappresenta la screw di quel punto
|
||||
// scorro le sottocurve della curva di base
|
||||
for ( int k = 0 ; k < nSpanU ; ++k ) {
|
||||
const ICurveBezier* pSubCrvBezU = GetCurveBezier( pCrvU->GetCurve( k)) ;
|
||||
//scorro i punti di controllo
|
||||
const ICurveBezier* pSubCrvBezU = GetCurveBezier( CrvU.GetCurve( k)) ;
|
||||
// scorro i punti di controllo
|
||||
for ( int i = 0 ; i < nDegU + 1 ; ++i) {
|
||||
if ( k != 0 && i == 0)
|
||||
continue ;
|
||||
Point3d ptCtrlU = pSubCrvBezU->GetControlPoint( i) ;
|
||||
double dWU = pSubCrvBezU->GetControlWeight( i) ;
|
||||
|
||||
PtrOwner<ICurveComposite> pCrvV( CreateCurveComposite()) ;
|
||||
// verifico se il punto di controllo sta sull'asse
|
||||
// in tal caso anziché una spirale creo semplicemente una linea lungo l'asse
|
||||
CurveComposite CrvV ;
|
||||
// verifico se il punto di controllo sta sull'asse
|
||||
// in tal caso anziché una spirale creo semplicemente una linea lungo l'asse
|
||||
DistPointLine dpl( ptCtrlU, ptAx, vtAx, 1, false) ;
|
||||
if ( ! dpl.IsSmall()) {
|
||||
// creo la spirale e la converto in bezier
|
||||
PtrOwner<ICurveArc> pSpiral( CreateCurveArc()) ;
|
||||
pSpiral->SetCPAN( ptAx, ptCtrlU, dAngRotDeg, dMove, vtAx) ;
|
||||
ICurve* pSpiralBezier( ArcToBezierCurve( pSpiral)) ; // converto in curva bezier di grado 3 perché l'arco è una spirale
|
||||
pCrvV->AddCurve( pSpiralBezier) ;
|
||||
// creo la spirale e la converto in bezier
|
||||
CurveArc CrvSpiral ;
|
||||
CrvSpiral.SetCPAN( ptAx, ptCtrlU, dAngRotDeg, dMove, vtAx) ;
|
||||
ICurve* pSpiralBezier( ArcToBezierCurve( &CrvSpiral)) ; // converto in curva bezier di grado 3 perché l'arco è una spirale
|
||||
CrvV.AddCurve( pSpiralBezier) ;
|
||||
}
|
||||
else if ( abs( dMove) > EPS_SMALL){
|
||||
// creo un segmento in forma bezier con il giusto numero di span
|
||||
PtrOwner<ICurveLine> pCL( CreateBasicCurveLine()) ;
|
||||
pCL->Set( ptCtrlU, ptCtrlU + vtAx * dMove) ;
|
||||
// creo un segmento in forma bezier con il giusto numero di span
|
||||
CurveLine CL ;
|
||||
CL.Set( ptCtrlU, ptCtrlU + vtAx * dMove) ;
|
||||
double dStep = 1. / nSpanV ;
|
||||
for ( int j = 0 ; j < nSpanV ; ++j) {
|
||||
PtrOwner<ICurveLine> pCLSingleSpan( GetCurveLine( pCL->CopyParamRange( j * dStep, ( j + 1) * dStep))) ;
|
||||
PtrOwner<ICurveLine> pCLSingleSpan( GetCurveLine( CL.CopyParamRange( j * dStep, ( j + 1) * dStep))) ;
|
||||
PtrOwner<ICurveBezier> pCrvBezForm( LineToBezierCurve( pCLSingleSpan, 3, true)) ;
|
||||
// prima di aggiungere le curve alla composito setto i pesi
|
||||
// prima di aggiungere le curve alla composito setto i pesi
|
||||
for ( int z = 0 ; z < pCrvBezForm->GetDegree() + 1 ; ++z)
|
||||
pCrvBezForm->SetControlWeight( z, vdSpiralW[z]) ;
|
||||
pCrvV->AddCurve( Release( pCrvBezForm)) ;
|
||||
CrvV.AddCurve( Release( pCrvBezForm)) ;
|
||||
}
|
||||
}
|
||||
// se sto facendo una rivoluzione ( dMove == 0) e ho un punto di controllo sull'asse allora ho un polo
|
||||
// devo aggiungere sempre lo stesso punto per tutta la riga della matrice dei punti di controllo, con i pesi giusti
|
||||
// se sto facendo una rivoluzione ( dMove == 0) e ho un punto di controllo sull'asse allora ho un polo
|
||||
// devo aggiungere sempre lo stesso punto per tutta la riga della matrice dei punti di controllo, con i pesi giusti
|
||||
else {
|
||||
PtrOwner<ICurveBezier> pCrvBezier( CreateCurveBezier()) ;
|
||||
pCrvBezier->Init( nDegV, bRat) ;
|
||||
CurveBezier CrvBezier ;
|
||||
CrvBezier.Init( nDegV, bRat) ;
|
||||
for ( int z = 0 ; z < nDegV + 1 ; ++z) {
|
||||
pCrvBezier->SetControlPoint( z, ptCtrlU, vdSpiralW[z]) ;
|
||||
CrvBezier.SetControlPoint( z, ptCtrlU, vdSpiralW[z]) ;
|
||||
}
|
||||
for ( int j = 0 ; j < nSpanV ; ++j)
|
||||
pCrvV->AddCurve( pCrvBezier->Clone()) ;
|
||||
CrvV.AddCurve( CrvBezier.Clone()) ;
|
||||
}
|
||||
|
||||
if( ! pCrvV->IsValid())
|
||||
if ( ! CrvV.IsValid())
|
||||
return false ;
|
||||
|
||||
// aggiungo i punti di controllo
|
||||
// scorro le sottocurve della spirale
|
||||
// aggiungo i punti di controllo
|
||||
// scorro le sottocurve della spirale
|
||||
for ( int j = 0 ; j < nSpanV ; ++j) {
|
||||
const ICurveBezier* pSubCrvBezV = GetCurveBezier( pCrvV->GetCurve( j)) ;
|
||||
// scorro i punti di controllo
|
||||
for( int z = 0 ; z < nDegV + 1 ; ++z) {
|
||||
const ICurveBezier* pSubCrvBezV = GetCurveBezier( CrvV.GetCurve( j)) ;
|
||||
// scorro i punti di controllo
|
||||
for ( int z = 0 ; z < nDegV + 1 ; ++z) {
|
||||
double dWV = pSubCrvBezV->GetControlWeight( z) ;
|
||||
Point3d ptCtrlV = pSubCrvBezV->GetControlPoint( z) ;
|
||||
SetControlPoint( nDegU * k + i, nDegV * j + z, ptCtrlV, dWU * dWV) ;
|
||||
@@ -4102,18 +4181,18 @@ bool
|
||||
SurfBezier::CreateByPointCurve( const Point3d& pt, const ICurve* pCurve)
|
||||
{
|
||||
// converto in bezier la curva iniziale
|
||||
PtrOwner<ICurveComposite> pCrvU ( CreateCurveComposite()) ;
|
||||
CurveComposite CrvU ;
|
||||
// se la curva è già una bezier singola la tengo, sennò la converto
|
||||
if ( pCurve->GetType() != CRV_BEZIER)
|
||||
pCrvU->AddCurve( CurveToBezierCurve( pCurve)) ;
|
||||
CrvU.AddCurve( CurveToBezierCurve( pCurve)) ;
|
||||
else
|
||||
pCrvU->AddCurve( pCurve->Clone()) ;
|
||||
if ( IsNull( pCrvU) || ! pCrvU->IsValid())
|
||||
CrvU.AddCurve( pCurve->Clone()) ;
|
||||
if ( ! CrvU.IsValid())
|
||||
return false ;
|
||||
// recupero span e grado nel parametro U
|
||||
int nSpanU = int( pCrvU->GetCurveCount()) ;
|
||||
int nDegU = ( GetCurveBezier( pCrvU->GetCurve(0)))->GetDegree() ;
|
||||
bool bRat = (GetCurveBezier( pCrvU->GetCurve(0)))->IsRational() ;
|
||||
int nSpanU = int( CrvU.GetCurveCount()) ;
|
||||
int nDegU = ( GetCurveBezier( CrvU.GetCurve(0)))->GetDegree() ;
|
||||
bool bRat = (GetCurveBezier( CrvU.GetCurve(0)))->IsRational() ;
|
||||
// in V decido che la funzione è una patch di grado 1
|
||||
int nSpanV = 1 ;
|
||||
int nDegV = 1 ;
|
||||
@@ -4121,7 +4200,7 @@ SurfBezier::CreateByPointCurve( const Point3d& pt, const ICurve* pCurve)
|
||||
Init( nDegU, nDegV, nSpanU, nSpanV, bRat) ;
|
||||
// scorro le patch nel parametro U
|
||||
for ( int k = 0 ; k < nSpanU ; ++k) {
|
||||
const ICurveBezier* pSubCrvU = GetCurveBezier( pCrvU->GetCurve( k)) ;
|
||||
const ICurveBezier* pSubCrvU = GetCurveBezier( CrvU.GetCurve( k)) ;
|
||||
// scorro i punti di controllo in U
|
||||
for ( int i = 0 ; i < nDegU + 1 ; ++i ) {
|
||||
|
||||
@@ -4145,7 +4224,7 @@ bool
|
||||
SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int nRuledType)
|
||||
{
|
||||
// converto in bezier la curva iniziale
|
||||
PtrOwner<ICurveComposite> pCrvU0 ( CreateCurveComposite()) ;
|
||||
CurveComposite CrvU0 ;
|
||||
// se la curva è già una bezier singola la tengo, sennò la converto
|
||||
if ( pCurve0->GetType() != CRV_BEZIER) {
|
||||
// se è una compo controllo che siano già tutte bezier
|
||||
@@ -4162,20 +4241,20 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
else
|
||||
bAlreadyBez = false ;
|
||||
if ( ! bAlreadyBez)
|
||||
pCrvU0->AddCurve( CurveToBezierCurve( pCurve0)) ;
|
||||
CrvU0.AddCurve( CurveToBezierCurve( pCurve0)) ;
|
||||
else
|
||||
pCrvU0->AddCurve( pCurve0->Clone()) ;
|
||||
CrvU0.AddCurve( pCurve0->Clone()) ;
|
||||
}
|
||||
else
|
||||
pCrvU0->AddCurve( pCurve0->Clone()) ;
|
||||
if ( IsNull( pCrvU0) || ! pCrvU0->IsValid())
|
||||
CrvU0.AddCurve( pCurve0->Clone()) ;
|
||||
if ( ! CrvU0.IsValid())
|
||||
return false ;
|
||||
// recupero span e grado nel parametro U
|
||||
int nSpanU0 = int( pCrvU0->GetCurveCount()) ;
|
||||
int nDegU0 = ( GetCurveBezier( pCrvU0->GetCurve(0)))->GetDegree() ;
|
||||
bool bRat0 = (GetCurveBezier( pCrvU0->GetCurve(0)))->IsRational() ;
|
||||
int nSpanU0 = int( CrvU0.GetCurveCount()) ;
|
||||
int nDegU0 = ( GetCurveBezier( CrvU0.GetCurve(0)))->GetDegree() ;
|
||||
bool bRat0 = (GetCurveBezier( CrvU0.GetCurve(0)))->IsRational() ;
|
||||
// se la curva è già una bezier singola la tengo, sennò la converto
|
||||
PtrOwner<ICurveComposite> pCrvU1 ( CreateCurveComposite()) ;
|
||||
CurveComposite CrvU1 ;
|
||||
// se la curva è già una bezier singola la tengo, sennò la converto
|
||||
if ( pCurve1->GetType() != CRV_BEZIER) {
|
||||
// se è una compo controllo che siano già tutte bezier
|
||||
@@ -4192,16 +4271,16 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
else
|
||||
bAlreadyBez = false ;
|
||||
if ( ! bAlreadyBez)
|
||||
pCrvU1->AddCurve( CurveToBezierCurve( pCurve1)) ;
|
||||
CrvU1.AddCurve( CurveToBezierCurve( pCurve1)) ;
|
||||
else
|
||||
pCrvU1->AddCurve( pCurve1->Clone()) ;
|
||||
CrvU1.AddCurve( pCurve1->Clone()) ;
|
||||
}
|
||||
else
|
||||
pCrvU1->AddCurve( pCurve1->Clone()) ;
|
||||
CrvU1.AddCurve( pCurve1->Clone()) ;
|
||||
// recupero span e grado nel parametro U
|
||||
int nSpanU1 = int( pCrvU1->GetCurveCount()) ;
|
||||
int nDegU1 = ( GetCurveBezier( pCrvU1->GetCurve(0)))->GetDegree() ;
|
||||
bool bRat1 = (GetCurveBezier( pCrvU1->GetCurve(0)))->IsRational() ;
|
||||
int nSpanU1 = int( CrvU1.GetCurveCount()) ;
|
||||
int nDegU1 = ( GetCurveBezier( CrvU1.GetCurve(0)))->GetDegree() ;
|
||||
bool bRat1 = (GetCurveBezier( CrvU1.GetCurve(0)))->IsRational() ;
|
||||
//// se non ho lo stesso numero di span nelle due curve devo capire come gestire il caso.
|
||||
//// per il momento non implementato
|
||||
//if ( nSpanU0 != nSpanU1)
|
||||
@@ -4209,40 +4288,40 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
// se le due curve hanno grado diverso allora aumento il grado di quella con grado inferiore
|
||||
if ( nDegU0 != nDegU1) {
|
||||
while ( nDegU0 < nDegU1) {
|
||||
ICurveComposite* pCC( CreateCurveComposite()) ;
|
||||
CurveComposite CC ;
|
||||
for( int k = 0 ; k < nSpanU0 ; ++k)
|
||||
pCC->AddCurve( BezierIncreaseDegree( GetCurveBezier( pCrvU0->GetCurve( k)))) ;
|
||||
CC.AddCurve( BezierIncreaseDegree( GetCurveBezier( CrvU0.GetCurve( k)))) ;
|
||||
++nDegU0 ;
|
||||
pCrvU0.Set( pCC) ;
|
||||
CrvU0 = CC ;
|
||||
}
|
||||
while ( nDegU0 > nDegU1) {
|
||||
ICurveComposite* pCC( CreateCurveComposite()) ;
|
||||
CurveComposite CC ;
|
||||
for( int k = 0 ; k < nSpanU0 ; ++k)
|
||||
pCC->AddCurve( BezierIncreaseDegree( GetCurveBezier( pCrvU1->GetCurve( k)))) ;
|
||||
CC.AddCurve( BezierIncreaseDegree( GetCurveBezier( CrvU1.GetCurve( k)))) ;
|
||||
++nDegU1 ;
|
||||
pCrvU1.Set( pCC) ;
|
||||
CrvU1 = CC ;
|
||||
}
|
||||
}
|
||||
// omogenizzo la razionalità
|
||||
if ( bRat0 != bRat1) {
|
||||
if ( ! bRat0) {
|
||||
ICurveComposite* pCC( CreateCurveComposite()) ;
|
||||
CurveComposite CC ;
|
||||
for ( int k = 0 ; k < nSpanU0 ; ++k) {
|
||||
ICurveBezier* pCrvBez = GetCurveBezier( pCrvU0->GetCurve( k)->Clone()) ;
|
||||
ICurveBezier* pCrvBez = GetCurveBezier( CrvU0.GetCurve( k)->Clone()) ;
|
||||
pCrvBez->MakeRational() ;
|
||||
pCC->AddCurve( pCrvBez) ;
|
||||
CC.AddCurve( pCrvBez) ;
|
||||
}
|
||||
pCrvU0.Set( pCC) ;
|
||||
CrvU0 = CC ;
|
||||
bRat0 = true ;
|
||||
}
|
||||
if ( ! bRat1) {
|
||||
ICurveComposite* pCC( CreateCurveComposite()) ;
|
||||
CurveComposite CC ;
|
||||
for ( int k = 0 ; k < nSpanU1 ; ++k) {
|
||||
ICurveBezier* pCrvBez = GetCurveBezier( pCrvU1->GetCurve( k)->Clone()) ;
|
||||
ICurveBezier* pCrvBez = GetCurveBezier( CrvU1.GetCurve( k)->Clone()) ;
|
||||
pCrvBez->MakeRational() ;
|
||||
pCC->AddCurve( pCrvBez) ;
|
||||
CC.AddCurve( pCrvBez) ;
|
||||
}
|
||||
pCrvU1.Set( pCC) ;
|
||||
CrvU1 = CC ;
|
||||
bRat1 = true ;
|
||||
}
|
||||
}
|
||||
@@ -4283,7 +4362,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
int nCount0 = 0 ;
|
||||
DBLVECTOR vdW0 ;
|
||||
for ( int k = 0 ; k < nSpanU0 ; ++k ) {
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( k)) ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( k)) ;
|
||||
for ( int i = 0 ; i < nDegU + 1 ; ++i ) {
|
||||
if( i != nDegU && !( i == 0 && k == 0))
|
||||
continue ;
|
||||
@@ -4298,7 +4377,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
int nCount1 = 0 ;
|
||||
DBLVECTOR vdW1 ;
|
||||
for ( int k = 0 ; k < nSpanU1 ; ++k ) {
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( k)) ;
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( CrvU1.GetCurve( k)) ;
|
||||
for ( int i = 0 ; i < nDegU1 + 1 ; ++i ) {
|
||||
if( i != nDegU && !( i == 0 && k == 0))
|
||||
continue ;
|
||||
@@ -4325,7 +4404,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
int nSecondRowInd = nDegU * nSpanU + 1 ;
|
||||
|
||||
// se sono chiuse devo controllare che gli start siano il più allineati possibile, se non lo sono cambio gli start
|
||||
ChangeStartForClosed( plU0, plU1, pCrvU0, pCrvU1) ;
|
||||
ChangeStartForClosed( plU0, plU1, &CrvU0, &CrvU1) ;
|
||||
|
||||
// se sto usando la ISOPARM o la MINDIST semplice allora collego più span di una curva allo stesso punto
|
||||
if ( nRuledType == RLT_B_MINDIST) {
|
||||
@@ -4366,7 +4445,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
nIndMatchNext = vPnt0Match[i+1].second ;
|
||||
const ICurveBezier* pSubCrv0 ;
|
||||
if ( nIndMatch == nIndMatchNext) {
|
||||
pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( i)) ;
|
||||
pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( i)) ;
|
||||
for ( int j = nCount0 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
if ( ! bRat0)
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( j)) ;
|
||||
@@ -4376,7 +4455,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
++ nCount0 ;
|
||||
// ripeto l'ultimo punto aggiunto alla riga U1 della superificie
|
||||
int nInd = nIndMatch > 0 ? nIndMatch - 1 : 0 ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU1->GetCurve( nInd)) ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( CrvU1.GetCurve( nInd)) ;
|
||||
for ( int j = nCount1 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
int nPoint = nCount1 == 0 ? 0 : nDegU ;
|
||||
if ( ! bRat0)
|
||||
@@ -4396,7 +4475,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
|
||||
if( bSubCurveAddedFirst) {
|
||||
// aggiungo una sottocurva dalla curva U0
|
||||
pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( i)) ;
|
||||
pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( i)) ;
|
||||
for ( int j = nCount0 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
if ( ! bRat0)
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( j)) ;
|
||||
@@ -4408,7 +4487,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
|
||||
// ripeto l'ultimo punto aggiunto per il numero di curve balzate - 1 della curva U1
|
||||
for( int k = 0 ; k < nIndMatchNext - nIndMatch - 1 ; ++k) {
|
||||
pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( i != 0 ? i - 1 : i)) ;
|
||||
pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( i != 0 ? i - 1 : i)) ;
|
||||
for ( int j = nCount0 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
int nPoint = i == 0 && ! bSubCurveAddedFirst ? 0 : nDegU ;
|
||||
if ( ! bRat0)
|
||||
@@ -4420,7 +4499,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
}
|
||||
// se non l'ho già aggiunta prima aggiungo una sottocurva della U0
|
||||
if( ! bSubCurveAddedFirst) {
|
||||
pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( i)) ;
|
||||
pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( i)) ;
|
||||
for ( int j = nCount0 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
if ( ! bRat0)
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( j)) ;
|
||||
@@ -4433,7 +4512,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
|
||||
// aggiungo tutte le sottocurve che ho balzato della curva U1
|
||||
for( int k = 0 ; k < nIndMatchNext - nIndMatch ; ++k) {
|
||||
pSubCrv0 = GetCurveBezier( pCrvU1->GetCurve( nIndMatch + k)) ;
|
||||
pSubCrv0 = GetCurveBezier( CrvU1.GetCurve( nIndMatch + k)) ;
|
||||
for ( int j = nCount1 == 0 ? 0 : 1 ; j < nLastPoint ; ++j ) {
|
||||
if ( ! bRat)
|
||||
SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv0->GetControlPoint( j)) ;
|
||||
@@ -4448,7 +4527,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
//controllo se ho aggiunto tutti i punti della curva U1
|
||||
if ( vPnt0Match.back().second != nSpanU1) {
|
||||
// riaggiungo l'ultimo punto della U0
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( nSpanU0 - 1)) ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( nSpanU0 - 1)) ;
|
||||
int nPoint = nDegU ;
|
||||
while( nCount0 < nSpanU) {
|
||||
for ( int j = 1 ; j < nLastPoint ; ++j) {
|
||||
@@ -4463,7 +4542,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
// aggiungo le restanti sottocurve della curva U1
|
||||
int nCrv1 = vPnt0Match.back().second ;
|
||||
while( nCrv1 < nSpanU1) {
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( nCrv1)) ;
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( CrvU1.GetCurve( nCrv1)) ;
|
||||
for ( int j = 1 ; j < nLastPoint ; ++j) {
|
||||
if ( ! bRat1)
|
||||
SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv1->GetControlPoint( j)) ;
|
||||
@@ -4478,8 +4557,8 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
else if ( nRuledType == RLT_B_ISOPAR) {
|
||||
// inizializzo la superficie
|
||||
Init( nDegU, nDegV, nSpanU, nSpanV, bRat) ;
|
||||
Point3d ptP0Start ; pCrvU0->GetStartPoint( ptP0Start) ;
|
||||
Point3d ptP1Start ; pCrvU1->GetStartPoint( ptP1Start) ;
|
||||
Point3d ptP0Start ; CrvU0.GetStartPoint( ptP0Start) ;
|
||||
Point3d ptP1Start ; CrvU1.GetStartPoint( ptP1Start) ;
|
||||
// setto i primi due punti delle righe
|
||||
nCount0 = 0 ; // sottocurva su pCrvU0
|
||||
if ( ! bRat)
|
||||
@@ -4509,7 +4588,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
if ( nLong == 0) {
|
||||
// aggiungo la curva sulla prima riga
|
||||
for ( int i = 1 ; i < nLastPoint ; ++i) {
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( nCount0)) ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( nCount0)) ;
|
||||
Point3d ptCtrl = pSubCrv0->GetControlPoint( i) ;
|
||||
if ( ! bRat)
|
||||
SetControlPoint( nCount * nDegU + i, ptCtrl) ;
|
||||
@@ -4523,7 +4602,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
// o end point se ho già aggiunto tutte le curve
|
||||
int nInd = nCount1 < nSpanU1 ? 0 : nDegU ;
|
||||
int nSubCrv = nCount1 < nSpanU1 ? nCount1 : nSpanU1 - 1 ;
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( nSubCrv)) ;
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( CrvU1.GetCurve( nSubCrv)) ;
|
||||
Point3d ptCtrl = pSubCrv1->GetControlPoint( nInd) ;
|
||||
for ( int i = 1 ; i < nLastPoint ; ++i) {
|
||||
if ( ! bRat)
|
||||
@@ -4537,7 +4616,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
else {
|
||||
// aggiungo la curva sulla seconda riga
|
||||
for ( int i = 1 ; i < nLastPoint ; ++i) {
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( nCount1)) ;
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( CrvU1.GetCurve( nCount1)) ;
|
||||
Point3d ptCtrl = pSubCrv1->GetControlPoint( i) ;
|
||||
if ( ! bRat)
|
||||
SetControlPoint( nSecondRowInd + nCount * nDegU + i, ptCtrl) ;
|
||||
@@ -4551,7 +4630,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
// o end point se ho già aggiunto tutte le curve
|
||||
int nInd = nCount0 < nSpanU0 ? 0 : nDegU ;
|
||||
int nSubCrv = nCount0 < nSpanU0 ? nCount0 : nSpanU0 - 1 ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( nSubCrv)) ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( nSubCrv)) ;
|
||||
Point3d ptCtrl = pSubCrv0->GetControlPoint( nInd) ;
|
||||
for ( int i = 1 ; i < nLastPoint ; ++i) {
|
||||
if ( ! bRat)
|
||||
@@ -4567,7 +4646,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
else {
|
||||
// aggiungo la curva sulla prima riga
|
||||
for ( int i = 1 ; i < nLastPoint ; ++i) {
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( nCount0)) ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( nCount0)) ;
|
||||
Point3d ptCtrl = pSubCrv0->GetControlPoint( i) ;
|
||||
if ( ! bRat)
|
||||
SetControlPoint( nCount * nDegU + i, ptCtrl) ;
|
||||
@@ -4579,7 +4658,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
++ nCount0 ;
|
||||
// aggiungo la curva sulla seconda riga
|
||||
for ( int i = 1 ; i < nLastPoint ; ++i) {
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( nCount1)) ;
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( CrvU1.GetCurve( nCount1)) ;
|
||||
Point3d ptCtrl = pSubCrv1->GetControlPoint( i) ;
|
||||
if ( ! bRat)
|
||||
SetControlPoint( nSecondRowInd + nCount * nDegU + i, ptCtrl) ;
|
||||
@@ -4601,7 +4680,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
Point3d ptP1 ; plU1.GetFirstPoint( ptP1) ;
|
||||
vector<pair<Point3d,double>> vMatch1 ;
|
||||
while ( plU1.GetNextPoint( ptP1, true)) {
|
||||
DistPointCurve dpc( ptP1, *pCrvU0, false) ;
|
||||
DistPointCurve dpc( ptP1, CrvU0, false) ;
|
||||
int nFlag = 0 ;
|
||||
double dParam ; dpc.GetParamAtMinDistPoint( 0, dParam, nFlag) ;
|
||||
Point3d ptJoint ; dpc.GetMinDistPoint( 0, ptJoint, nFlag) ;
|
||||
@@ -4623,7 +4702,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
fill( vbRep0.begin(), vbRep0.end(), false) ;
|
||||
while ( plU0.GetNextPoint( ptP0, true)) {
|
||||
// devo salvarmi se matcho più punti con lo start o l'end della curva totale
|
||||
DistPointCurve dpc( ptP0, *pCrvU1, false) ;
|
||||
DistPointCurve dpc( ptP0, CrvU1, false) ;
|
||||
int nFlag = 0 ;
|
||||
double dParam ; dpc.GetParamAtMinDistPoint( 0, dParam, nFlag) ;
|
||||
Point3d ptJoint ; dpc.GetMinDistPoint( 0, ptJoint, nFlag) ;
|
||||
@@ -4697,7 +4776,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
BOOLVECTOR vbRep1( plU1.GetPointNbr() - 1) ;
|
||||
fill( vbRep1.begin(), vbRep1.end(), false) ;
|
||||
while ( plU1.GetNextPoint( ptP1, true)) {
|
||||
DistPointCurve dpc( ptP1, *pCrvU0, false) ;
|
||||
DistPointCurve dpc( ptP1, CrvU0, false) ;
|
||||
int nFlag = 0 ;
|
||||
double dParam ; dpc.GetParamAtMinDistPoint( 0, dParam, nFlag) ;
|
||||
Point3d ptJoint ; dpc.GetMinDistPoint( 0, ptJoint, nFlag) ;
|
||||
@@ -4773,7 +4852,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
dSplit = nSplit + ( dSplit - nSplit) / (vdSplit0[z+1] - nSplit);
|
||||
}
|
||||
nUnit = nSplit ;
|
||||
pCrvU1->AddJoint( dSplit) ;
|
||||
CrvU1.AddJoint( dSplit) ;
|
||||
switch( vnAddedOrNextIsRep0[z]) {
|
||||
case 0 : if( vbRep1[nSplit])
|
||||
++ nRep1 ;
|
||||
@@ -4798,7 +4877,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
dSplit = nSplit + ( dSplit - nSplit) / (vdSplit1[z+1] - nSplit);
|
||||
}
|
||||
nUnit = nSplit ;
|
||||
pCrvU0->AddJoint( dSplit) ;
|
||||
CrvU0.AddJoint( dSplit) ;
|
||||
switch( vnAddedOrNextIsRep1[z]) {
|
||||
case 0 : if( vbRep0[nSplit])
|
||||
++ nRep0 ;
|
||||
@@ -4813,8 +4892,8 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
}
|
||||
}
|
||||
|
||||
nSpanU0 = pCrvU0->GetCurveCount() ;
|
||||
nSpanU1 = pCrvU1->GetCurveCount() ;
|
||||
nSpanU0 = CrvU0.GetCurveCount() ;
|
||||
nSpanU1 = CrvU1.GetCurveCount() ;
|
||||
//aggiusto i vettori delle ripetizioni in modo in modo che non arrivino mai ad essere contemporaneamente true
|
||||
int nAddedSpan = 0 ;
|
||||
int nCrv0 = 0 ;
|
||||
@@ -4880,7 +4959,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
}
|
||||
bool bRep0 = vbRep0[nCrv0] ;
|
||||
bool bRep1 = vbRep1[nCrv1] ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( nCrv0)) ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( nCrv0)) ;
|
||||
for( int i = nAddedSpan == 0 ? 0 : 1 ; i < nLastPoint ; ++ i) {
|
||||
int nInd = i ;
|
||||
// se ho una ripetizione allora riaggiungo l'ultimo punto. Se sono ancora alla curva 0 invece devo aggiungere lo start della curva U0
|
||||
@@ -4893,7 +4972,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
}
|
||||
if ( ! bRep1)
|
||||
++ nCrv0 ;
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( nCrv1)) ;
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( CrvU1.GetCurve( nCrv1)) ;
|
||||
for( int i = nAddedSpan == 0 ? 0 : 1 ; i < nLastPoint ; ++ i) {
|
||||
int nInd = i ;
|
||||
// se ho una ripetizione allora riaggiungo l'ultimo punto. Se sono ancora alla curva 0 invece devo aggiungere lo start della curva U0
|
||||
@@ -5273,3 +5352,11 @@ SurfBezier::CreateBySetOfCurves( const ICURVEPOVECTOR& vCrvBez, bool bReduceToDe
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
PNTVECTOR
|
||||
SurfBezier::GetAllControlPoints( void) const
|
||||
{
|
||||
PNTVECTOR vPntCtrl = m_vPtCtrl ;
|
||||
return vPntCtrl ;
|
||||
}
|
||||
|
||||
+23
-24
@@ -22,7 +22,6 @@
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
#include "/EgtDev/Include/EGkGeoCollection.h"
|
||||
|
||||
using namespace std ;
|
||||
class Tree ;
|
||||
|
||||
struct PairHashIntInt {
|
||||
@@ -77,8 +76,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
public : // ISurf
|
||||
bool IsSimple( void) const override
|
||||
{ return true ; }
|
||||
bool IsClosed( void) const override
|
||||
{ return false ; }
|
||||
bool IsClosed( void) const override ;
|
||||
bool GetArea( double& dArea) const override ;
|
||||
bool GetVolume( double& dVolume) const override
|
||||
{ if ( &dVolume == nullptr)
|
||||
@@ -158,6 +156,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
bool CreateByPointCurve( const Point3d& pt, const ICurve* pCurve) override ;
|
||||
bool CreateByTwoCurves( const ICurve* pCurve1, const ICurve* pCurve2, int nType) override ;
|
||||
bool CreateBySetOfCurves( const ICURVEPOVECTOR& vCrvBez, bool bReduceToDeg3) override ;
|
||||
PNTVECTOR GetAllControlPoints( void) const ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
@@ -169,7 +168,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
|
||||
public :
|
||||
SurfBezier( void) ;
|
||||
SurfBezier( const SurfBezier& sbSrc)
|
||||
SurfBezier( const SurfBezier& sbSrc) : m_pSTM( nullptr), m_pSTMRefined( nullptr), m_pTrimReg(nullptr)
|
||||
{ if ( ! CopyFrom( sbSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "SurfBezier : copy constructor error") }
|
||||
SurfBezier& operator =( const SurfBezier& sbSrc)
|
||||
@@ -221,27 +220,27 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
bool GetBernstein( double dU, int nDegU, DBLVECTOR& vBernU) const ;
|
||||
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
mutable SurfTriMesh* m_pSTM ; // superficie trimesh ausiliaria per la visualizzazione
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
mutable SurfTriMesh* m_pSTM ; // superficie trimesh ausiliaria per la visualizzazione
|
||||
mutable SurfTriMesh* m_pSTMRefined ; // superficie trimesh ausiliaria raffinata per i calcoli
|
||||
Status m_nStatus ; // stato
|
||||
int m_nDegU ; // grado in U
|
||||
int m_nDegV ; // grado in V
|
||||
int m_nSpanU ; // numero di pezze in U
|
||||
int m_nSpanV ; // numero di pezze in V
|
||||
bool m_bRat ; // flag di razionale/polinomiale
|
||||
bool m_bTrimmed ; // flag per presenza regione di trim
|
||||
mutable bool m_bClosedU ; // flag che indica se la superficie è chiusa lungo il parametro U
|
||||
mutable bool m_bClosedV ; // flag che indica se la superficie è chiusa lungo il parametro V
|
||||
mutable BOOLVECTOR m_vbPole ; // vettore di flag che indicano se i lati sono collassati in dei poli
|
||||
PNTVECTOR m_vPtCtrl ; // vettore dei punti di controllo
|
||||
DBLVECTOR m_vWeCtrl ; // vettore dei pesi di controllo
|
||||
SurfFlatRegion* m_pTrimReg ; // eventuale regione di trim
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
mutable vector<ICRVCOMPOPOVECTOR> m_mCCEdge ;// vettore dei vettori che contengono le curve compo degli edge della superficie nello spazio 3D
|
||||
mutable ICRVCOMPOPOVECTOR m_vCCLoop ; // vettore dei loop della superficie trimmata
|
||||
mutable int m_nIsPlanar ; // enum che indica se la superficie è piana ( -1, non è stato calcolato)
|
||||
Status m_nStatus ; // stato
|
||||
int m_nDegU ; // grado in U
|
||||
int m_nDegV ; // grado in V
|
||||
int m_nSpanU ; // numero di pezze in U
|
||||
int m_nSpanV ; // numero di pezze in V
|
||||
bool m_bRat ; // flag di razionale/polinomiale
|
||||
bool m_bTrimmed ; // flag per presenza regione di trim
|
||||
mutable bool m_bClosedU ; // flag che indica se la superficie è chiusa lungo il parametro U
|
||||
mutable bool m_bClosedV ; // flag che indica se la superficie è chiusa lungo il parametro V
|
||||
mutable BOOLVECTOR m_vbPole ; // vettore di flag che indicano se i lati sono collassati in dei poli
|
||||
PNTVECTOR m_vPtCtrl ; // vettore dei punti di controllo
|
||||
DBLVECTOR m_vWeCtrl ; // vettore dei pesi di controllo
|
||||
SurfFlatRegion* m_pTrimReg ; // eventuale regione di trim
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
mutable std::vector<ICRVCOMPOPOVECTOR> m_mCCEdge ; // vettore dei vettori che contengono le curve compo degli edge della superficie nello spazio 3D
|
||||
mutable ICRVCOMPOPOVECTOR m_vCCLoop ; // vettore dei loop della superficie trimmata
|
||||
mutable int m_nIsPlanar ; // enum che indica se la superficie è piana ( -1, non è stato calcolato)
|
||||
mutable DBLVECTOR m_vBernU ;
|
||||
mutable PNTVECTOR m_ptTemp ;
|
||||
mutable DBLVECTOR m_vBernV ;
|
||||
|
||||
+214
-36
@@ -234,9 +234,13 @@ SurfTriMesh::AddTriangle( const int nIdVert[3], int nTFlag)
|
||||
m_vPart.clear() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
ResetHashGrids3d() ;
|
||||
if ( ! vtN.Normalize( EPS_ZERO))
|
||||
return SVT_DEL ;
|
||||
// inserisco il triangolo
|
||||
try { m_vTria.emplace_back( nIdVert, nTFlag) ;}
|
||||
catch(...) { return SVT_NULL ;}
|
||||
// aggiorno la sua normale
|
||||
m_vTria.back().vtN = vtN ;
|
||||
// aggiorno massimo TFlag
|
||||
m_nMaxTFlag = max( m_nMaxTFlag, nTFlag) ;
|
||||
// ne determino l'indice
|
||||
@@ -1220,16 +1224,17 @@ SurfTriMesh::GetSilhouette( const Plane3d& plPlane, double dTol, POLYLINEVECTOR&
|
||||
// se rimasto qualcosa
|
||||
if ( pgTria.GetSideCount() > 0) {
|
||||
// lo proietto sul piano e creo la regione
|
||||
pgTria.Scale( frOCS, 1, 1, 0) ;
|
||||
PtrOwner<SurfFlatRegion> pSfrTria( GetBasicSurfFlatRegion( GetSurfFlatRegionFromPolyLine( pgTria.GetPolyLine()))) ;
|
||||
if ( ! IsNull( pSfrTria)) {
|
||||
if ( bAllTria && Tria.GetN() * vtVers < 0)
|
||||
pSfrTria->Invert() ;
|
||||
pSfrTria->Offset( dTol, ICurve::OFF_FILLET) ;
|
||||
if ( IsNull( pSfr))
|
||||
pSfr.Set( pSfrTria) ;
|
||||
else
|
||||
pSfr->Add( *pSfrTria) ;
|
||||
if ( pgTria.Scale( frOCS, 1, 1, 0)) {
|
||||
PtrOwner<SurfFlatRegion> pSfrTria( GetBasicSurfFlatRegion( GetSurfFlatRegionFromPolyLine( pgTria.GetPolyLine()))) ;
|
||||
if ( ! IsNull( pSfrTria)) {
|
||||
if ( bAllTria && Tria.GetN() * vtVers < 0)
|
||||
pSfrTria->Invert() ;
|
||||
pSfrTria->Offset( dTol, ICurve::OFF_FILLET) ;
|
||||
if ( IsNull( pSfr))
|
||||
pSfr.Set( pSfrTria) ;
|
||||
else
|
||||
pSfr->Add( *pSfrTria) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1687,11 +1692,13 @@ SurfTriMesh::AdjustVertices( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::AdjustAdjacencies( void)
|
||||
SurfTriMesh::AdjustAdjacencies( bool AdjustVert)
|
||||
{
|
||||
// sistemo le relazioni tra triangoli e vertici
|
||||
if ( ! AdjustVertices())
|
||||
return false ;
|
||||
if ( AdjustVert) {
|
||||
if ( ! AdjustVertices())
|
||||
return false ;
|
||||
}
|
||||
// matrice di incidenza vertici-triangoli
|
||||
INTMATRIX mVertTria( GetVertexSize()) ;
|
||||
for ( int i = 0 ; i < GetTriangleSize() ; ++ i) {
|
||||
@@ -1874,7 +1881,7 @@ SurfTriMesh::TestSealing( void)
|
||||
m_vTria[i].nIdAdjac[1] == SVT_NULL ||
|
||||
m_vTria[i].nIdAdjac[2] == SVT_NULL) {
|
||||
bClosed = false ;
|
||||
break ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1936,7 +1943,7 @@ SurfTriMesh::PackVertices( void)
|
||||
++ nFirstFree ;
|
||||
}
|
||||
else
|
||||
vVId.push_back( nId) ;
|
||||
vVId.push_back( nId) ;
|
||||
}
|
||||
else {
|
||||
if ( nFirstFree == SVT_NULL)
|
||||
@@ -3043,7 +3050,7 @@ SurfTriMesh::AddBiTriangle( const int nIdVert[4])
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::DoCompacting( double dTol)
|
||||
{
|
||||
{
|
||||
// imposto ricalcolo
|
||||
m_nStatus = ERR ;
|
||||
m_OGrMgr.Reset() ;
|
||||
@@ -3084,6 +3091,7 @@ SurfTriMesh::DoCompacting( double dTol)
|
||||
int nVIdSize = int( vVId.size()) ;
|
||||
|
||||
// sistemo gli indici dei vertici nei triangoli
|
||||
INTVECTOR vInvalidIds ;
|
||||
for ( int nId = 0 ; nId < GetTriangleSize() ; ++ nId) {
|
||||
// salto i triangoli cancellati
|
||||
if ( m_vTria[nId].nIdVert[0] == SVT_DEL)
|
||||
@@ -3100,15 +3108,51 @@ SurfTriMesh::DoCompacting( double dTol)
|
||||
// aggiorno il triangolo
|
||||
m_vTria[nId].nIdVert[0] = vVId[vOId[0]] ;
|
||||
m_vTria[nId].nIdVert[1] = vVId[vOId[1]] ;
|
||||
m_vTria[nId].nIdVert[2] = vVId[vOId[2]] ;
|
||||
// se due vertici coincidono o la normale non è calcolabile, cancello il triangolo
|
||||
if ( m_vTria[nId].nIdVert[0] == m_vTria[nId].nIdVert[1] ||
|
||||
m_vTria[nId].nIdVert[0] == m_vTria[nId].nIdVert[2] ||
|
||||
m_vTria[nId].nIdVert[1] == m_vTria[nId].nIdVert[2] ||
|
||||
! CalcTriangleNormal( nId))
|
||||
RemoveTriangle( nId) ;
|
||||
m_vTria[nId].nIdVert[2] = vVId[vOId[2]] ;
|
||||
|
||||
// verifico se triangolo da rimuovere per vertici coincidenti
|
||||
bool bRemove = false ;
|
||||
int nTAdj1 = SVT_NULL, nTAdj2 = SVT_NULL ;
|
||||
if ( m_vTria[nId].nIdVert[0] == m_vTria[nId].nIdVert[1]) {
|
||||
nTAdj1 = m_vTria[nId].nIdAdjac[1] ;
|
||||
nTAdj2 = m_vTria[nId].nIdAdjac[2] ;
|
||||
bRemove = true ;
|
||||
}
|
||||
else if ( m_vTria[nId].nIdVert[0] == m_vTria[nId].nIdVert[2]) {
|
||||
nTAdj1 = m_vTria[nId].nIdAdjac[0] ;
|
||||
nTAdj2 = m_vTria[nId].nIdAdjac[1] ;
|
||||
bRemove = true ;
|
||||
}
|
||||
else if ( m_vTria[nId].nIdVert[1] == m_vTria[nId].nIdVert[2]) {
|
||||
nTAdj1 = m_vTria[nId].nIdAdjac[0] ;
|
||||
nTAdj2 = m_vTria[nId].nIdAdjac[2] ;
|
||||
bRemove = true ;
|
||||
}
|
||||
if ( bRemove) {
|
||||
// sistemo le contro adiacenze
|
||||
if ( nTAdj1 != SVT_NULL) {
|
||||
for ( int j = 0 ; j < 3 ; ++ j)
|
||||
if ( m_vTria[nTAdj1].nIdAdjac[j] == nId)
|
||||
m_vTria[nTAdj1].nIdAdjac[j] = nTAdj2 ;
|
||||
}
|
||||
if ( nTAdj2 != SVT_NULL) {
|
||||
for ( int j = 0 ; j < 3 ; ++ j)
|
||||
if ( m_vTria[nTAdj2].nIdAdjac[j] == nId)
|
||||
m_vTria[nTAdj2].nIdAdjac[j] = nTAdj1 ;
|
||||
}
|
||||
// rimuovo il triangolo
|
||||
RemoveTriangle( nId) ;
|
||||
}
|
||||
|
||||
// verifico se il triangolo va rimosso per normale non calcolabile
|
||||
else if ( ! CalcTriangleNormal( nId))
|
||||
vInvalidIds.emplace_back( nId) ;
|
||||
}
|
||||
|
||||
// elimino triangoli invalidi ( con gestione speciale per evitare T-junctions)
|
||||
if ( ! vInvalidIds.empty())
|
||||
RemoveInvalidTriangles( vInvalidIds) ;
|
||||
|
||||
// compatto il vettore dei vertici
|
||||
if ( ! PackVertices())
|
||||
return false ;
|
||||
@@ -3345,22 +3389,23 @@ SurfTriMesh::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double
|
||||
bMirror = ( bMirror ? ( dCoeffY > 0) : ( dCoeffY < 0)) ;
|
||||
bMirror = ( bMirror ? ( dCoeffZ > 0) : ( dCoeffZ < 0)) ;
|
||||
|
||||
// aggiorno le facce
|
||||
for ( int i = 0 ; i < GetTriangleSize() ; ++ i) {
|
||||
if ( m_vTria[i].nIdVert[0] != SVT_DEL) {
|
||||
// se c'è mirror, devo invertire la faccia
|
||||
if ( bMirror)
|
||||
InvertTriangle( i) ;
|
||||
// aggiorno la normale
|
||||
if ( ! CalcTriangleNormal( i)) {
|
||||
// elimino il triangolo
|
||||
RemoveTriangle( i) ;
|
||||
}
|
||||
}
|
||||
// se c'è mirror, devo invertire le facce
|
||||
if ( bMirror) {
|
||||
for ( int i = 0 ; i < GetTriangleSize() ; ++ i)
|
||||
if ( m_vTria[i].nIdVert[0] != SVT_DEL)
|
||||
InvertTriangle( i) ;
|
||||
}
|
||||
|
||||
// rimuovo i triangoli resi invalidi dalla scalatura
|
||||
bool bOk = DoCompacting() ;
|
||||
|
||||
return DoCompacting() ;
|
||||
// rimuovo i triangoli doppi
|
||||
bool bModified = false ;
|
||||
bOk = bOk && RemoveDoubleTriangles( bModified) ;
|
||||
if ( bModified)
|
||||
bOk = bOk && ( AdjustVertices() && DoCompacting()) ;
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -3984,6 +4029,56 @@ SurfTriMesh::CloneShell( int nShell) const
|
||||
return Release( pSurfTM) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::GetPartLocalBBox( int nP, BBox3d& b3Loc) const
|
||||
{
|
||||
// verifico esistenza della parte
|
||||
if ( nP < 0 || nP >= GetPartCount())
|
||||
return false ;
|
||||
|
||||
// assegno il box in locale
|
||||
b3Loc.Reset() ;
|
||||
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
|
||||
// recupero il vettore delle Shell della parte corrente
|
||||
const auto& vShell = m_vPart[nP].vShell ;
|
||||
// scorro i triangoli validi contenuti nella Shell
|
||||
if ( m_vTria[i].nIdVert[0] != SVT_DEL &&
|
||||
find( vShell.begin(), vShell.end(), m_vTria[i].nShell) != vShell.end()) {
|
||||
// ciclo sui tre vertici
|
||||
for ( int j = 0 ; j < 3 ; ++ j)
|
||||
b3Loc.Add( m_vVert[m_vTria[i].nIdVert[j]].ptP) ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::GetPartBBox( int nP, const Frame3d& frRef, BBox3d& b3Ref) const
|
||||
{
|
||||
// verifico esistenza della parte
|
||||
if ( nP < 0 || nP >= GetPartCount())
|
||||
return false ;
|
||||
|
||||
// assegno il box in locale
|
||||
b3Ref.Reset() ;
|
||||
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
|
||||
// recupero il vettore delle Shell della parte corrente
|
||||
const auto& vShell = m_vPart[nP].vShell ;
|
||||
// scorro i triangoli validi contenuti nella Shell
|
||||
if ( m_vTria[i].nIdVert[0] != SVT_DEL &&
|
||||
find( vShell.begin(), vShell.end(), m_vTria[i].nShell) != vShell.end()) {
|
||||
// ciclo sui tre vertici
|
||||
for ( int j = 0 ; j < 3 ; ++ j)
|
||||
b3Ref.Add( GetToGlob( m_vVert[m_vTria[i].nIdVert[j]].ptP, frRef)) ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
SurfTriMesh::GetPartCount( void) const
|
||||
@@ -4322,3 +4417,86 @@ SurfTriMesh::SetTempInt( int nId, int nTempInt) const
|
||||
m_vTria[nId].nTemp = nTempInt ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::AddTriaFromZMap( const TRIA3DEXVECTOR& vTria, PointGrid3d& VertGrid, double dVertexTol)
|
||||
{
|
||||
// scorro i triangoli
|
||||
for ( const Triangle3dEx& Tria : vTria) {
|
||||
// ciclo sui tre vertici
|
||||
int nIdV[3]{} ;
|
||||
for ( int nV = 0 ; nV < 3 ; ++ nV) {
|
||||
// verifico se vertice già presente
|
||||
int nId ;
|
||||
if ( ! VertGrid.Find( Tria.GetP( nV), dVertexTol, nId)) {
|
||||
// se non presente, lo aggiugo
|
||||
nIdV[nV] = AddVertex( Tria.GetP( nV)) ;
|
||||
if ( nIdV[nV] == SVT_NULL)
|
||||
return false ;
|
||||
VertGrid.InsertPoint( Tria.GetP( nV), nIdV[nV]) ;
|
||||
}
|
||||
else
|
||||
nIdV[nV] = nId ;
|
||||
}
|
||||
// se i vertici sono tutti diversi tra loro, inserisco il triangolo
|
||||
if ( nIdV[0] != nIdV[1] && nIdV[0] != nIdV[2] && nIdV[1] != nIdV[2]) {
|
||||
int nT = AddTriangle( nIdV, Tria.GetGrade()) ;
|
||||
if ( nT != SVT_NULL && nT != SVT_DEL) {
|
||||
// associo relazione vertice-triangolo
|
||||
for ( int i = 0 ; i < 3 ; ++ i)
|
||||
m_vVert[nIdV[i]].nIdTria = nT ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::AdjustTopologyFromZMap( void)
|
||||
{
|
||||
// cancello tutti i vertici che puntano a triangoli cancellati
|
||||
bool bPack = false ;
|
||||
for ( int i = 0 ; i < GetVertexSize() ; ++ i) {
|
||||
if ( m_vVert[i].nIdTria == SVT_NULL) {
|
||||
m_vVert[i].nIdTria = SVT_DEL ;
|
||||
bPack = true ;
|
||||
}
|
||||
}
|
||||
if ( bPack)
|
||||
PackVertices() ;
|
||||
m_nStatus = SurfTriMesh::OK ;
|
||||
|
||||
// calcolo le adiacenze
|
||||
if ( ! AdjustAdjacencies())
|
||||
return false ;
|
||||
|
||||
// verifico l'orientamento ( TODO -- Da migliorare...)
|
||||
// Ora per funzionare è necessario che il ciclo sui triangoli parta da un triangolo orientato
|
||||
// correttamente e che i triangoli invertiti siano "circondati" da triangoli tutti orientati correttamente
|
||||
if ( ! AdjustOrientations())
|
||||
return false ;
|
||||
|
||||
// calcolo le facce
|
||||
if ( ! VerifyFaceting())
|
||||
return false ;
|
||||
|
||||
// rimozione delle TJunction
|
||||
bool bModified = false ;
|
||||
if ( ! RemoveTJunctions( bModified, SQ_EPS_SMALL))
|
||||
return false ;
|
||||
if ( bModified) {
|
||||
if ( ! AdjustVertices() || ! DoCompacting())
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
TestSealing() ;
|
||||
|
||||
// semplifico le facce ( anche più piccola)
|
||||
if ( ! SimplifyFacets( MAX_EDGE_LEN_STD, false, 5. * EPS_SMALL))
|
||||
LOG_ERROR( GetEGkLogger(), "Error in SimplifyFacets of Stm::AdjustTopologyFromZMap")
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
+19
-5
@@ -18,6 +18,7 @@
|
||||
#include "GeoObjRW.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkHashGrids3d.h"
|
||||
#include "/EgtDev/Include/EGkPointGrid3d.h"
|
||||
#include <deque>
|
||||
#include <set>
|
||||
|
||||
@@ -327,7 +328,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
bool Intersect( const ISurfTriMesh& Other) override ;
|
||||
bool Subtract( const ISurfTriMesh& Other) override ;
|
||||
bool GetSurfClassification( const ISurfTriMesh& ClassifierSurf,
|
||||
INTVECTOR& vTriaIn, INTVECTOR& vTriaOut, INTVECTOR& vTriaOnP, INTVECTOR& vTriaOnM, INTVECTOR& vTriaIndef) override ;
|
||||
INTVECTOR& vTriaIn, INTVECTOR& vTriaOut, INTVECTOR& vTriaOnP, INTVECTOR& vTriaOnM, INTVECTOR& vTriaIndef) override ;
|
||||
bool CutWithOtherSurf( const ISurfTriMesh& CutterSurf, bool bInVsOut, bool bSaveOnEq) override ;
|
||||
bool Repair( double dMaxEdgeLen = MAX_EDGE_LEN_STD) override ;
|
||||
bool GetAllTriaOverlapBox( const BBox3d& b3Box, INTVECTOR& vT) const override ;
|
||||
@@ -336,6 +337,8 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
bool GetShellArea( int nShell, double& dArea) const override ;
|
||||
bool RemoveShell( int nShell) override ;
|
||||
SurfTriMesh* CloneShell( int nShell) const override ;
|
||||
bool GetPartLocalBBox( int nP, BBox3d& b3Loc) const override ;
|
||||
bool GetPartBBox( int nP, const Frame3d& frRef, BBox3d& b3Ref) const override ;
|
||||
int GetPartCount( void) const override ;
|
||||
bool RemovePart( int nPart) override ;
|
||||
bool GetPartArea( int nPart, double& dArea) const override ;
|
||||
@@ -373,6 +376,8 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
bool GetTempInt( int nId, int& nTempInt) const ;
|
||||
bool ResetTempInts( void) const ;
|
||||
bool SetTempInt( int nId, int nTempInt) const ;
|
||||
bool AddTriaFromZMap( const TRIA3DEXVECTOR& vTria, PointGrid3d& VertGrid, double dVertexTol = 2 * EPS_SMALL) ;
|
||||
bool AdjustTopologyFromZMap( void) ;
|
||||
|
||||
private :
|
||||
typedef std::vector<StmVert> VERTVECTOR ;
|
||||
@@ -388,7 +393,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
bool CopyFrom( const SurfTriMesh& clSrc) ;
|
||||
bool Validate( bool bCorrect = false) ;
|
||||
bool AdjustVertices( void) ;
|
||||
bool AdjustAdjacencies( void) ;
|
||||
bool AdjustAdjacencies( bool AdjustVert = true) ;
|
||||
bool AdjustOrientations( void) ;
|
||||
bool AdjustTriaOrientation( TRINTDEQUE& S3iQ) ;
|
||||
bool TestSealing( void) ;
|
||||
@@ -433,14 +438,16 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
bool IntersectTriMeshTriangle( SurfTriMesh& Other) ;
|
||||
bool IdentifyShells( void) const ;
|
||||
bool RemoveDoubleTriangles( bool& bModified) ;
|
||||
bool RemoveTJunctions( bool& bModified) ;
|
||||
bool RemoveTJunctions( bool& bModified, double dMinSqDist = SQ_EPS_TRIA_H) ;
|
||||
bool FlipTriangles( int nTA, int nTB) ;
|
||||
bool SimplifyFacets( double dMaxEdgeLen = MAX_EDGE_LEN_STD, bool bForced = true) ;
|
||||
bool SimplifyFacets( double dMaxEdgeLen = MAX_EDGE_LEN_STD, bool bForced = true, double dTolAlign = 50 * EPS_SMALL) ;
|
||||
bool AddChainToChain( const Chain& ChainToAdd, PNTVECTOR& OrigChain) ;
|
||||
bool DistPointFacet( const Point3d& ptP, const POLYLINEVECTOR& vPolyVec, double& dPointFacetDist) ;
|
||||
bool ChangeStart( const Point3d& ptNewStart, PNTVECTOR& Loop) ;
|
||||
bool SplitAtPoint( const Point3d& ptStop, const PNTVECTOR& Loop, PNTVECTOR& Loop1, PNTVECTOR& Loop2) ;
|
||||
|
||||
bool AdjustLoop( PNTULIST& PointList, double dMaxEdgeLen, double dTolAlign, bool& bModif) const ;
|
||||
bool RemoveInvalidTriangles( const INTVECTOR& vIds) ;
|
||||
bool FindAdjacentOnLongerEdge( int nT, int& nEdge, int& nAdjTrg) const ;
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
@@ -483,3 +490,10 @@ inline SurfTriMesh* GetBasicSurfTriMesh( IGeoObj* pGObj)
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != SRF_TRIMESH)
|
||||
return nullptr ;
|
||||
return ( static_cast<SurfTriMesh*>( pGObj)) ; }
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Raccolte di puntatori a SurfTriMesh
|
||||
typedef std::vector<const SurfTriMesh*> CISRFTMPVECTOR ; // vettore di puntatori a const SurfTriMesh
|
||||
typedef std::vector<SurfTriMesh*> ISRFTMPVECTOR ; // vettore di puntatori a SurfTriMesh
|
||||
typedef std::list<SurfTriMesh*> ISRFTMPLIST ; // lista di puntatori a SurfTriMesh
|
||||
typedef std::vector<PtrOwner<SurfTriMesh>> ISRFTMPOVECTOR ; // vettore di puntatori esclusivi a SurfTriMesh
|
||||
|
||||
+42
-83
@@ -502,9 +502,7 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
|
||||
}
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// Creo il loop chiuso padre di tutti, il perimetro del triangolo. Questo viene diviso in sotto-loop
|
||||
// chiusi mediante quelli aperti. I loop chiusi trovati precedentemente sono interni a uno dei
|
||||
// sotto-loop chiusi di cui è formato il perimetro.
|
||||
@@ -704,16 +702,18 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
|
||||
}
|
||||
}
|
||||
}
|
||||
// Elimino loop interni non validi
|
||||
bool bDouble = true ;
|
||||
// Verifico se i loop interni sono validi
|
||||
bool bAllInvalid = true ;
|
||||
for ( int nInnLoop = 0 ; nInnLoop < int( vInnerLoop.size()) ; ++ nInnLoop) {
|
||||
if ( cvClosedChain[vInnerLoop[nInnLoop]].size() > 2) {
|
||||
bDouble = false ;
|
||||
// se chain formata da tre segmenti significa che si tratta di due linee sovrapposte ( il terzo tratto è quello aggiunto
|
||||
// per forzare la chiusura)
|
||||
if ( cvClosedChain[vInnerLoop[nInnLoop]].size() > 3) {
|
||||
bAllInvalid = false ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( vInnerLoop.empty() || bDouble) {
|
||||
if ( vInnerLoop.empty() || bAllInvalid) {
|
||||
// Eseguo triangolazione
|
||||
PNTVECTOR vPt ;
|
||||
INTVECTOR vTr ;
|
||||
@@ -753,63 +753,20 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
|
||||
vPolygons.emplace_back( CurLoop) ;
|
||||
}
|
||||
|
||||
// poligono
|
||||
Polygon3d pgPol ;
|
||||
pgPol.FromPolyLine( vPolygons[1]) ;
|
||||
|
||||
// controllo direzioni delle normali
|
||||
bool bCodirectedNormals = trTria.GetN() * pgPol.GetVersN() > 0. ;
|
||||
|
||||
// Aggiungo al loop esterno i punti dei loop interni che si trovano su di esso
|
||||
PNTULIST& ExternLoopList = vPolygons[0].GetUPointList() ;
|
||||
// Ciclo sui segmenti del loop esterno
|
||||
auto itSt = ExternLoopList.begin() ;
|
||||
auto itEn = itSt ;
|
||||
++ itEn ;
|
||||
for ( ; itSt != ExternLoopList.end() && itEn != ExternLoopList.end() ; ++ itSt, ++ itEn) {
|
||||
// Estremi del segmento corrente del loop esterno e scorrispondente vettore
|
||||
Point3d ptSt = itSt->first ;
|
||||
Point3d ptEn = itEn->first ;
|
||||
Vector3d vtSeg = ptEn - ptSt ;
|
||||
double dSegLen = vtSeg.Len() ;
|
||||
vtSeg /= dSegLen ;
|
||||
// Vettore dei punti dei loop interni che stanno sul segmento del loop esterno
|
||||
PNTUVECTOR vPointWithOrder ;
|
||||
// Ciclo sui loop interni
|
||||
for ( int nInnPoly = 1 ; nInnPoly < int( vPolygons.size()) ; ++ nInnPoly) {
|
||||
// Ciclo sui punti dei loop interni
|
||||
Point3d ptInnPoint ;
|
||||
bool bIsFirst = true ;
|
||||
bool bContinue = vPolygons[nInnPoly].GetFirstPoint( ptInnPoint) ;
|
||||
while ( bContinue) {
|
||||
DistPointLine DistCalculator( ptInnPoint, ptSt, ptEn) ;
|
||||
double dDist ;
|
||||
DistCalculator.GetDist( dDist) ;
|
||||
double dLongPos = ( ptInnPoint - ptSt) * vtSeg ;
|
||||
if ( dDist < EPS_SMALL && dLongPos > 0. && dLongPos < dSegLen) {
|
||||
POINTU NewPointU ;
|
||||
NewPointU.first = ptInnPoint ;
|
||||
NewPointU.second = dLongPos ;
|
||||
if ( ! bIsFirst)
|
||||
vPointWithOrder.emplace_back( NewPointU) ;
|
||||
}
|
||||
bIsFirst = false ;
|
||||
bContinue = vPolygons[nInnPoly].GetNextPoint( ptInnPoint) ;
|
||||
}
|
||||
}
|
||||
// Riordino i punti interni sul segmento esterno in funzione della distanza dall'origine di esso
|
||||
for ( int nPi = 0 ; nPi < int( vPointWithOrder.size()) - 1 ; ++ nPi) {
|
||||
for ( int nPj = nPi + 1 ; nPj < int( vPointWithOrder.size()) ; ++ nPj) {
|
||||
if ( vPointWithOrder[nPi].second > vPointWithOrder[nPj].second) {
|
||||
swap( vPointWithOrder[nPi], vPointWithOrder[nPj]) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Aggiungo i punti al loop esterno
|
||||
for ( int nPi = 0 ; nPi < int( vPointWithOrder.size()) ; ++ nPi) {
|
||||
itSt = ExternLoopList.emplace( itEn, vPointWithOrder[nPi]) ;
|
||||
}
|
||||
// controllo la direzione della normale del triangolo con quella del poligono di area maggiore
|
||||
// ( per gestire eventuali inscatolamenti)
|
||||
Vector3d vtPoly = V_NULL ;
|
||||
double dMaxArea = -1 ;
|
||||
for ( int i = 1 ; i < int( vPolygons.size()) ; i ++) {
|
||||
Plane3d plPoly ;
|
||||
double dAreaPoly ;
|
||||
vPolygons[i].IsClosedAndFlat( plPoly, dAreaPoly) ;
|
||||
if ( dAreaPoly > dMaxArea) {
|
||||
vtPoly = plPoly.GetVersN() ;
|
||||
dMaxArea = dAreaPoly ;
|
||||
}
|
||||
}
|
||||
bool bCodirectedNormals = trTria.GetN() * vtPoly > 0. ;
|
||||
|
||||
PNTVECTOR vPt ;
|
||||
INTVECTOR vTr ;
|
||||
@@ -836,6 +793,7 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
|
||||
}
|
||||
|
||||
// Divido i loop che si autointercettano
|
||||
// TO DO : da verificare. Questa porzione di codice non dovrebbe andare prima della triangolazione?
|
||||
int nInitialLoopNum = int( vPolygons.size()) ;
|
||||
for ( int nL = 1 ; nL < nInitialLoopNum ; ++ nL) {
|
||||
// Lista dei punti della PolyLine Loop corrente
|
||||
@@ -883,11 +841,11 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
|
||||
itSt2 = LoopPointList.emplace( itEn2, vAddingPointWithOrder[nPi]) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Spezzo i loop autointersecantesi
|
||||
POLYLINEVECTOR vAuxPolygons ;
|
||||
vAuxPolygons.emplace_back( vPolygons[nL]) ;
|
||||
|
||||
|
||||
bool bSplitted = true ;
|
||||
while ( bSplitted) {
|
||||
bSplitted = false ;
|
||||
@@ -956,16 +914,13 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
|
||||
vPolygons.erase( vPolygons.begin() + i) ;
|
||||
else
|
||||
++ i ;
|
||||
|
||||
}
|
||||
|
||||
bool bCordirectedNormals_intLoop = bCodirectedNormals ;
|
||||
// eventuale inversione della prima curva ( che determina il verso della triangolazione) per averla orientata
|
||||
// come il triangolo
|
||||
if ( ! vPolygons.empty()) {
|
||||
Polygon3d pgPol ;
|
||||
pgPol.FromPolyLine( vPolygons[0]) ;
|
||||
// controllo direzioni delle normali
|
||||
bCordirectedNormals_intLoop = trTria.GetN() * pgPol.GetVersN() > 0. ;
|
||||
if ( ! bCordirectedNormals_intLoop)
|
||||
if ( trTria.GetN() * pgPol.GetVersN() < 0.)
|
||||
vPolygons[0].Invert() ;
|
||||
}
|
||||
|
||||
@@ -981,7 +936,7 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
|
||||
Surf.m_vTria[nNewTriaNum].nETempFlag[0] = 0 ;
|
||||
Surf.m_vTria[nNewTriaNum].nETempFlag[1] = 0 ;
|
||||
Surf.m_vTria[nNewTriaNum].nETempFlag[2] = 0 ;
|
||||
if ( bCordirectedNormals_intLoop)
|
||||
if ( bCodirectedNormals)
|
||||
Surf.m_vTria[nNewTriaNum].nTempShell = 1 ;
|
||||
else
|
||||
Surf.m_vTria[nNewTriaNum].nTempShell = -1 ;
|
||||
@@ -1123,7 +1078,7 @@ SurfTriMesh::AmbiguosTriangleManager( TRIA3DVECTORMAP& Ambiguos, SurfTriMesh& Su
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
|
||||
{
|
||||
{
|
||||
bool bModif = false ;
|
||||
SurfTriMesh& SurfB = Other ;
|
||||
|
||||
@@ -1176,7 +1131,7 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
|
||||
INTVECTOR vNearTria ;
|
||||
SurfB.GetAllTriaOverlapBox( b3dTriaA, vNearTria) ;
|
||||
|
||||
// I scorro tutti i triangoli di B che intersecano il box di A
|
||||
// Scorro tutti i triangoli di B che intersecano il box di A
|
||||
for ( int nTB = 0 ; nTB < int( vNearTria.size()) ; ++ nTB) {
|
||||
|
||||
// Se il triangolo B non è valido, continuo
|
||||
@@ -1365,7 +1320,7 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
|
||||
// Triangoli sovrapposti
|
||||
if ( bContinue) {
|
||||
int nTriaNum2A = GetTriangleSize() ;
|
||||
// Resetto e ricalcolo la HashGrid della superficie B
|
||||
// Resetto e ricalcolo la HashGrid della superficie B
|
||||
SurfB.ResetHashGrids3d() ;
|
||||
for ( int nTA = 0 ; nTA < nTriaNum2A ; ++ nTA) {
|
||||
// Se il triangolo A non è valido, continuo
|
||||
@@ -1375,15 +1330,19 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
|
||||
// Box del triangolo A
|
||||
BBox3d b3dTriaA ;
|
||||
trTriaA.GetLocalBBox( b3dTriaA) ;
|
||||
// Recupero i triangoli di B che interferiscono col box del triangolo di A
|
||||
// Recupero i triangoli di B che interferiscono col box del triangolo di A
|
||||
INTVECTOR vNearTria ;
|
||||
SurfB.GetAllTriaOverlapBox( b3dTriaA, vNearTria) ;
|
||||
for ( int nTB = 0 ; nTB < int( vNearTria.size()) ; ++ nTB) {
|
||||
// Se il triangolo B non è valido, continuo
|
||||
// Se il triangolo B non è valido, continuo
|
||||
Triangle3d trTriaB ;
|
||||
if ( ! SurfB.GetTriangle( vNearTria[nTB], trTriaB) || ! trTriaB.Validate( true))
|
||||
continue ;
|
||||
// Se i triangoli sono sovrapposti
|
||||
// Se sono già stati classificati entrambi come sovrapposti continuo
|
||||
if ( abs( m_vTria[nTA].nTempShell) == 2 && abs( SurfB.m_vTria[vNearTria[nTB]].nTempShell) == 2)
|
||||
continue ;
|
||||
|
||||
// Se i triangoli sono sovrapposti
|
||||
TRIA3DVECTOR vTriaAB ;
|
||||
Point3d ptTempA, ptTempB ;
|
||||
int nIntTypeAB = IntersTriaTria( trTriaA, trTriaB, ptTempA, ptTempB, vTriaAB) ;
|
||||
@@ -1475,7 +1434,7 @@ SurfTriMesh::Add( const ISurfTriMesh& Other)
|
||||
// tengo una copia di B ( la superficie B viene modificata durante la ritriangolazione )
|
||||
SurfTriMesh SurfA_cl ;
|
||||
SurfA_cl.CopyFrom( this) ;
|
||||
|
||||
|
||||
// ritriangolo le due superfici mediante ogni intersezione Triangolo-Triangolo
|
||||
IntersectTriMeshTriangle( SurfB) ;
|
||||
|
||||
@@ -1625,12 +1584,12 @@ SurfTriMesh::Intersect( const ISurfTriMesh& Other)
|
||||
AddTriangle( nNewVert, m_nMaxTFlag) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// sistemazioni varie
|
||||
bool bOk = ( AdjustVertices() && DoCompacting()) ;
|
||||
bool bModified = false ;
|
||||
bOk = bOk && RemoveDoubleTriangles( bModified) ;
|
||||
if ( bModified)
|
||||
bOk = bOk && RemoveDoubleTriangles( bModified) ;
|
||||
if ( bModified)
|
||||
bOk = bOk && ( AdjustVertices() && DoCompacting()) ;
|
||||
bOk = bOk && RemoveTJunctions( bModified) ;
|
||||
if ( bModified)
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2025
|
||||
//----------------------------------------------------------------------------
|
||||
// File : SurfTriMeshOffset.cpp Data : 07.07.25 Versione : 2.7g1
|
||||
// Contenuto : Implementazione funzione per Offset di Superfici TriMesh.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 10.06.25 RE Creazione modulo.
|
||||
// 10.06.25 RE Offset di superfici chiuse.
|
||||
// 04.07.25 RE Thickening Offset di superfici generiche.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "VolZmap.h"
|
||||
#include "\EgtDev\Include\EGkSurfTriMeshAux.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static ISurfTriMesh*
|
||||
SumStm( const CISURFTMPVECTOR& vStm)
|
||||
{
|
||||
// se vettore vuoto, non faccio nulla
|
||||
if ( vStm.empty())
|
||||
return nullptr ;
|
||||
// definisco la superficie somma tra tutte ( la prima deve essere valida)
|
||||
PtrOwner<ISurfTriMesh> pStmAdd( CreateSurfTriMesh()) ;
|
||||
if ( IsNull( pStmAdd))
|
||||
return nullptr ;
|
||||
// scorro le superfici
|
||||
for ( const ISurfTriMesh* pStm : vStm) {
|
||||
if ( pStm == nullptr || ! pStm->IsValid() || pStm->GetTriangleCount() == 0)
|
||||
continue ;
|
||||
if ( ! pStmAdd->IsValid() || pStmAdd->GetTriangleCount() == 0) {
|
||||
if ( ! pStmAdd->CopyFrom( pStm))
|
||||
return nullptr ;
|
||||
}
|
||||
else
|
||||
pStmAdd->Add( *pStm) ;
|
||||
}
|
||||
// restituisco la superficie ottenuta
|
||||
return ( Release( pStmAdd)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Funzione che crea l'Offset di una superficie TriMesh
|
||||
//----------------------------------------------------------------------------
|
||||
ISurfTriMesh*
|
||||
CreateSurfTriMeshOffset( const ISurfTriMesh* pStm, double dOffs, double dPrec, int nType)
|
||||
{
|
||||
return ( CreateSurfTriMeshesOffset( { pStm}, dOffs, dPrec, nType)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Funzione che crea il Fat Offset di una superficie TriMesh
|
||||
//----------------------------------------------------------------------------
|
||||
ISurfTriMesh*
|
||||
CreateSurfTriMeshThickeningOffset( const ISurfTriMesh* pStm, double dOffs, double dPrec, int nType)
|
||||
{
|
||||
return ( CreateSurfTriMeshesThickeningOffset( { pStm}, dOffs, dPrec, nType)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Funzione che crea l'Offset di un insieme di superfici
|
||||
//----------------------------------------------------------------------------
|
||||
ISurfTriMesh*
|
||||
CreateSurfTriMeshesOffset( const CISURFTMPVECTOR& vStm, double dOffs, double dPrec, int nType)
|
||||
{
|
||||
// se vettore delle superfici vuoto, non faccio nulla
|
||||
if ( vStm.empty())
|
||||
return nullptr ;
|
||||
// controllo sul valore di tolleranza lineare
|
||||
double dMyPrec = max( dPrec, 100 * EPS_SMALL) ;
|
||||
// --- NB. ( Il valore di Offset deve essere maggiore di 10 * EPS_SMALL in valore assoluto)
|
||||
// Nel caso sia minore, restituisco semplicemente la somma delle superfici
|
||||
// ( questo valore serve per rimanere coerente con l'Offset delle curve)
|
||||
if ( abs( dOffs) < 10 * EPS_SMALL)
|
||||
return SumStm( vStm) ;
|
||||
|
||||
// creo lo Zmap associato alle superfici TriMesh
|
||||
PtrOwner<IVolZmap> pVolZmap( CreateVolZmap()) ;
|
||||
if ( IsNull( pVolZmap) || ! pVolZmap->CreateFromTriMeshOffset( vStm, dOffs, dMyPrec, nType))
|
||||
return nullptr ;
|
||||
|
||||
// restituisco la superficie TriMesh
|
||||
return ( pVolZmap->GetSurfTriMesh()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//* Funzione che crea il Fat Offset di un insieme di superfici
|
||||
//----------------------------------------------------------------------------
|
||||
ISurfTriMesh*
|
||||
CreateSurfTriMeshesThickeningOffset( const CISURFTMPVECTOR& vStm, double dOffs, double dPrec, int nType)
|
||||
{
|
||||
// se vettore delle superfici vuoto, non faccio nulla
|
||||
if ( vStm.empty())
|
||||
return nullptr ;
|
||||
// controllo sul valore di tolleranza lineare
|
||||
double dMyPrec = max( dPrec, 100 * EPS_SMALL) ;
|
||||
// --- NB. ( Il valore di Offset deve essere maggiore di 10 * EPS_SMALL in valore assoluto)
|
||||
// Nel caso sia minore, restituisco semplicemente la somma delle superfici
|
||||
// ( questo valore serve per rimanere coerente con l'Offset delle curve)
|
||||
if ( abs( dOffs) < 10 * EPS_SMALL)
|
||||
return SumStm( vStm) ;
|
||||
|
||||
// creo lo Zmap associato alle superfici TriMesh
|
||||
PtrOwner<IVolZmap> pVolZmap( CreateVolZmap()) ;
|
||||
if ( IsNull( pVolZmap) || ! pVolZmap->CreateFromTriMeshThickeningOffset( vStm, dOffs, dMyPrec, nType))
|
||||
return nullptr ;
|
||||
|
||||
// restituisco la superficie TriMesh
|
||||
return ( pVolZmap->GetSurfTriMesh()) ;
|
||||
}
|
||||
+204
-31
@@ -17,7 +17,6 @@
|
||||
#include "Triangulate.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkDistLineLine.h"
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -35,6 +34,7 @@ SurfTriMesh::RemoveDoubleTriangles( bool& bModified)
|
||||
// recupero i vertici dei triangoli
|
||||
int nIdV[3] ;
|
||||
GetTriangle( nT, nIdV) ;
|
||||
bool bToRemove = false ;
|
||||
// ciclo sui triangoli adiacenti
|
||||
for ( int nE = 0 ; nE < 3 ; ++ nE) {
|
||||
// recupero triangolo adiacente, se non esiste passo al successivo
|
||||
@@ -53,10 +53,14 @@ SurfTriMesh::RemoveDoubleTriangles( bool& bModified)
|
||||
}
|
||||
}
|
||||
if ( nCoinc == 3) {
|
||||
RemoveTriangle( nAdjT) ;
|
||||
// se i vertici coincidono rimuovo entrambi i triangoli
|
||||
bToRemove = true ;
|
||||
bModified = true ;
|
||||
RemoveTriangle( nAdjT) ;
|
||||
}
|
||||
}
|
||||
if ( bToRemove)
|
||||
RemoveTriangle( nT) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -86,8 +90,8 @@ SurfTriMesh::FlipTriangles( int nTA, int nTB)
|
||||
// Recupero i vertici del triangolo A
|
||||
Point3d ptSegSt, ptSegEn, ptVertA ;
|
||||
if ( ! GetVertex( m_vTria[nTA].nIdVert[nEdgeA], ptSegSt) ||
|
||||
! GetVertex( m_vTria[nTA].nIdVert[( nEdgeA + 1) % 3], ptSegEn) ||
|
||||
! GetVertex( m_vTria[nTA].nIdVert[( nEdgeA + 2) % 3], ptVertA))
|
||||
! GetVertex( m_vTria[nTA].nIdVert[( nEdgeA + 1) % 3], ptSegEn) ||
|
||||
! GetVertex( m_vTria[nTA].nIdVert[( nEdgeA + 2) % 3], ptVertA))
|
||||
return false ;
|
||||
// Recupero il vertice opposto del triangolo B
|
||||
Point3d ptVertB ;
|
||||
@@ -98,23 +102,43 @@ SurfTriMesh::FlipTriangles( int nTA, int nTB)
|
||||
if ( ! DiagDist.IsSmall())
|
||||
return false ;
|
||||
double dPos1, dPos2 ;
|
||||
if ( ! DiagDist.GetPositionsAtMinDistPoints( dPos1, dPos2) ||
|
||||
dPos1 < EPS_SMALL || dPos1 > ( ptSegEn - ptSegSt).Len() - EPS_SMALL ||
|
||||
dPos2 < EPS_SMALL || dPos2 > ( ptVertB - ptVertA).Len() - EPS_SMALL)
|
||||
return false ;
|
||||
if ( ! DiagDist.GetPositionsAtMinDistPoints( dPos1, dPos2))
|
||||
return false ;
|
||||
if ( dPos1 < - EPS_SMALL || dPos1 > ( ptSegEn - ptSegSt).Len() + EPS_SMALL ||
|
||||
dPos2 < - EPS_SMALL || dPos2 > ( ptVertB - ptVertA).Len() + EPS_SMALL)
|
||||
return false ;
|
||||
|
||||
// Eseguo il flipping
|
||||
m_vTria[nTA].nIdVert[nEdgeA] = m_vTria[nTB].nIdVert[( nEdgeB + 2) % 3] ;
|
||||
m_vTria[nTB].nIdVert[nEdgeB] = m_vTria[nTA].nIdVert[( nEdgeA + 2) % 3] ;
|
||||
m_vTria[nTA].nIdAdjac[nEdgeA] = m_vTria[nTB].nIdAdjac[( nEdgeB + 2) % 3] ;
|
||||
m_vTria[nTA].nIdAdjac[( nEdgeA + 2) % 3] = nTB ;
|
||||
m_vTria[nTB].nIdAdjac[nEdgeB] = m_vTria[nTA].nIdAdjac[( nEdgeA + 2) % 3] ;
|
||||
m_vTria[nTA].nIdAdjac[( nEdgeA + 2) % 3] = nTB ;
|
||||
m_vTria[nTB].nIdAdjac[( nEdgeB + 2) % 3] = nTA ;
|
||||
|
||||
// sistemo anche le contro-adiacenze
|
||||
int nTC = m_vTria[nTA].nIdAdjac[nEdgeA] ;
|
||||
if ( nTC != SVT_NULL) {
|
||||
for ( int i = 0 ; i < 3 ; i++)
|
||||
if ( m_vTria[nTC].nIdAdjac[i] == nTB) {
|
||||
m_vTria[nTC].nIdAdjac[i] = nTA ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
int nTD = m_vTria[nTB].nIdAdjac[nEdgeB] ;
|
||||
if ( nTD != SVT_NULL) {
|
||||
for ( int i = 0 ; i < 3 ; i++)
|
||||
if ( m_vTria[nTD].nIdAdjac[i] == nTA) {
|
||||
m_vTria[nTD].nIdAdjac[i] = nTB ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::RemoveTJunctions( bool& bModified)
|
||||
SurfTriMesh::RemoveTJunctions( bool& bModified, double dMinSqDist)
|
||||
{
|
||||
bModified = false ;
|
||||
|
||||
@@ -123,6 +147,11 @@ SurfTriMesh::RemoveTJunctions( bool& bModified)
|
||||
|
||||
// Ciclo sui triangoli della superficie per determinare gli altri vertici sul loro perimetro
|
||||
for ( int nT = 0 ; nT < int( m_vTria.size()) ; ++ nT) {
|
||||
// se adiacenze tutte valide, passo al successivo
|
||||
if ( m_vTria[nT].nIdAdjac[0] != SVT_DEL && m_vTria[nT].nIdAdjac[0] != SVT_NULL &&
|
||||
m_vTria[nT].nIdAdjac[1] != SVT_DEL && m_vTria[nT].nIdAdjac[1] != SVT_NULL &&
|
||||
m_vTria[nT].nIdAdjac[2] != SVT_DEL && m_vTria[nT].nIdAdjac[2] != SVT_NULL)
|
||||
continue ;
|
||||
// Se il triangolo non è valido, passo al successivo
|
||||
Triangle3d trTria ;
|
||||
if ( ! GetTriangle( nT, trTria) || ! trTria.Validate( true))
|
||||
@@ -150,6 +179,8 @@ SurfTriMesh::RemoveTJunctions( bool& bModified)
|
||||
if ( dSegLen < EPS_SMALL)
|
||||
continue ;
|
||||
vtSeg /= dSegLen ;
|
||||
int nV1 = m_vTria[nT].nIdVert[nSeg] ;
|
||||
int nV2 = m_vTria[nT].nIdVert[Next( nSeg)] ;
|
||||
// Ciclo sui triangoli vicini
|
||||
for ( int nI = 0 ; nI < int( vNearTria.size()) ; ++ nI) {
|
||||
// Salto il triangolo se è quello di riferimento
|
||||
@@ -157,13 +188,16 @@ SurfTriMesh::RemoveTJunctions( bool& bModified)
|
||||
continue ;
|
||||
// Cerco i vertici che stanno sul lato del triangolo
|
||||
for ( int nVert = 0 ; nVert < 3 ; ++ nVert) {
|
||||
int nCurrVert = m_vTria[vNearTria[nI]].nIdVert[nVert] ;
|
||||
if ( nCurrVert == nV1 || nCurrVert == nV2)
|
||||
continue ;
|
||||
Point3d ptVert ;
|
||||
if ( ! GetVertex( m_vTria[vNearTria[nI]].nIdVert[nVert], ptVert))
|
||||
continue ;
|
||||
double dProj = ( ptVert - ptSegSt) * vtSeg ;
|
||||
double dOrt = ( ( ptVert - ptSegSt) - dProj * vtSeg).SqLen() ;
|
||||
if ( dProj > EPS_SMALL && dProj < dSegLen - EPS_SMALL && dOrt < SQ_EPS_TRIA_H)
|
||||
vVertOtl.emplace_back( m_vTria[vNearTria[nI]].nIdVert[nVert]) ;
|
||||
double dOrt = ( ( ptVert - ptSegSt) - dProj * vtSeg).SqLen() ;
|
||||
if ( dProj > EPS_SMALL && dProj < dSegLen - EPS_SMALL && dOrt < dMinSqDist)
|
||||
vVertOtl.emplace_back( m_vTria[vNearTria[nI]].nIdVert[nVert]) ;
|
||||
}
|
||||
}
|
||||
// Riordino i vertici sul segmento
|
||||
@@ -307,16 +341,42 @@ ChooseGoodStartPoint( PNTULIST& PointList)
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
AdjustLoop( PNTULIST& PointList, double dMaxEdgeLen, bool& bModif)
|
||||
// -------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::AdjustLoop( PNTULIST& PointList, double dMaxEdgeLen, double dTolAlign, bool& bModif) const
|
||||
{
|
||||
// vettore dei loop della faccia adiacente
|
||||
POLYLINEVECTOR LoopVec ;
|
||||
// Ciclo sui punti del loop
|
||||
auto itLast = PointList.begin() ;
|
||||
for ( auto it = next( itLast) ; it != PointList.end() ; ++ it) {
|
||||
|
||||
// Se dal punto corrente inizia un segmento adiacente a un'altra faccia
|
||||
if ( itLast->second != it->second) {
|
||||
|
||||
// bisogna fermarsi per analizzare il tratto corrente alla ricerca di punti allineati se dal punto corrente
|
||||
// inizia un tratto adiacente ad un'altra faccia oppure se il punto corrente non verrà eliminato dal loop
|
||||
// della faccia adiacente
|
||||
|
||||
bool bAnalyze = ( itLast->second != it->second) ;
|
||||
if ( bAnalyze)
|
||||
LoopVec.clear() ;
|
||||
if ( ! bAnalyze && itLast->second != - 1) {
|
||||
if ( LoopVec.empty())
|
||||
GetFacetLoops( int( itLast->second), LoopVec) ;
|
||||
for ( int i = 0 ; i < int( LoopVec.size()) && ! bAnalyze ; i ++) {
|
||||
const PNTULIST& PointListAdj = LoopVec[i].GetUPointList() ;
|
||||
int nSamePoints = 0 ;
|
||||
for ( auto itAdj = PointListAdj.begin() ; itAdj != prev( PointListAdj.end()) ; ++ itAdj) {
|
||||
// cerco il punto corrente sul loop della faccia adiacente
|
||||
if ( AreSamePointApprox( it->first, itAdj->first))
|
||||
++ nSamePoints ;
|
||||
if ( ( nSamePoints == 1 && int( PointListAdj.size()) <= 4) || nSamePoints > 1) {
|
||||
bAnalyze = true ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( bAnalyze) {
|
||||
// Raccolgo i punti in una polyline
|
||||
PolyLine PL ;
|
||||
int nPar = -1 ;
|
||||
@@ -326,7 +386,7 @@ AdjustLoop( PNTULIST& PointList, double dMaxEdgeLen, bool& bModif)
|
||||
}
|
||||
PL.AddUPoint( ++nPar, it->first) ;
|
||||
// Provo ad eliminare i punti allineati
|
||||
PL.RemoveAlignedPoints( 50 * EPS_SMALL) ;
|
||||
PL.RemoveAlignedPoints( dTolAlign) ;
|
||||
if ( PL.GetPointNbr() < nPar + 1) {
|
||||
// rimuovo dalla lista dei punti gli eliminati (salto gli estremi)
|
||||
int nUCurr = 1 ;
|
||||
@@ -418,7 +478,7 @@ AdjustLoop( PNTULIST& PointList, double dMaxEdgeLen, bool& bModif)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::SimplifyFacets( double dMaxEdgeLen, bool bForced)
|
||||
SurfTriMesh::SimplifyFacets( double dMaxEdgeLen, bool bForced, double dTolAlign)
|
||||
{
|
||||
// La trimesh deve essere valida
|
||||
if ( ! IsValid())
|
||||
@@ -433,8 +493,8 @@ SurfTriMesh::SimplifyFacets( double dMaxEdgeLen, bool bForced)
|
||||
// Ciclo sulle facce della mesh per trovare quelle da ritriangolare
|
||||
unordered_map< int, pair< PNTVECTOR, INTVECTOR>> FacetMap ;
|
||||
for ( int nF = 0 ; nF < nFacetCnt ; ++ nF) {
|
||||
|
||||
// Recupero i loop della faccia (il parametro indica la faccia adiacente)
|
||||
|
||||
// Recupero i loop della faccia ( il parametro indica la faccia adiacente)
|
||||
POLYLINEVECTOR LoopVec ;
|
||||
GetFacetLoops( nF, LoopVec) ;
|
||||
|
||||
@@ -445,13 +505,17 @@ SurfTriMesh::SimplifyFacets( double dMaxEdgeLen, bool bForced)
|
||||
// Lista dei punti del loop
|
||||
PNTULIST& PointList = LoopVec[nL].GetUPointList() ;
|
||||
|
||||
// Se il loop è un triangolo, non va modificato
|
||||
if ( int( PointList.size()) <= 4)
|
||||
continue ;
|
||||
|
||||
// Mi assicuro che il punto iniziale/finale non sia all'interno di un possibile segmento
|
||||
if ( ! ChooseGoodStartPoint( PointList))
|
||||
continue ;
|
||||
|
||||
// Sistemo il loop
|
||||
bool bModif = false ;
|
||||
if ( ! AdjustLoop( PointList, dMaxEdgeLen, bModif))
|
||||
if ( ! AdjustLoop( PointList, dMaxEdgeLen, dTolAlign, bModif))
|
||||
return false ;
|
||||
if ( bModif)
|
||||
bToRetriangulate = true ;
|
||||
@@ -479,9 +543,8 @@ SurfTriMesh::SimplifyFacets( double dMaxEdgeLen, bool bForced)
|
||||
// Eseguo la ritriangolazione della faccia
|
||||
PNTVECTOR vPt ;
|
||||
INTVECTOR vTr ;
|
||||
if ( Triangulate().Make( LoopVec, vPt, vTr)) {
|
||||
if ( Triangulate().Make( LoopVec, vPt, vTr) && ! vTr.empty())
|
||||
FacetMap.emplace( nF, make_pair( vPt, vTr)) ;
|
||||
}
|
||||
// Se non riesco a triangolare anche solo questa faccia, interrompo tutto
|
||||
else
|
||||
return false ;
|
||||
@@ -502,17 +565,17 @@ SurfTriMesh::SimplifyFacets( double dMaxEdgeLen, bool bForced)
|
||||
// Cancello i triangoli
|
||||
for ( int nT : vDelTria)
|
||||
RemoveTriangle( nT) ;
|
||||
|
||||
|
||||
// Applico le nuove triangolazioni delle facce
|
||||
for ( auto itF = FacetMap.begin() ; itF != FacetMap.end() ; ++ itF) {
|
||||
const PNTVECTOR& vPt = itF->second.first ;
|
||||
const INTVECTOR& vTr = itF->second.second ;
|
||||
// Inserisco i nuovi triangoli
|
||||
// Inserisco i nuovi triangoli
|
||||
bool bFirstTria = true ;
|
||||
for ( int n = 0 ; n < int( vTr.size()) - 2 ; n += 3) {
|
||||
int nNewId[3] = { AddVertex( vPt[vTr[n]]),
|
||||
AddVertex( vPt[vTr[n + 1]]),
|
||||
AddVertex( vPt[vTr[n + 2]])} ;
|
||||
AddVertex( vPt[vTr[n + 1]]),
|
||||
AddVertex( vPt[vTr[n + 2]])} ;
|
||||
auto itCol = ColorMap.find( itF->first) ;
|
||||
int nTFlag = ( itCol != ColorMap.end() ? itCol->second : 0) ;
|
||||
int nNewTriaId = AddTriangle( nNewId, nTFlag) ;
|
||||
@@ -525,7 +588,7 @@ SurfTriMesh::SimplifyFacets( double dMaxEdgeLen, bool bForced)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// dichiaro necessità ricalcolo della grafica e di hashgrids3d
|
||||
m_OGrMgr.Reset() ;
|
||||
ResetHashGrids3d() ;
|
||||
@@ -722,3 +785,113 @@ SurfTriMesh::SplitAtPoint( const Point3d& ptStop, const PNTVECTOR& Loop, PNTVECT
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::FindAdjacentOnLongerEdge( int nT, int& nEdge, int& nAdjTrg) const
|
||||
{
|
||||
// recupero il lato più lungo del triangolo
|
||||
double dLen0 = SqDist( m_vVert[m_vTria[nT].nIdVert[0]].ptP, m_vVert[m_vTria[nT].nIdVert[1]].ptP) ;
|
||||
double dLen1 = SqDist( m_vVert[m_vTria[nT].nIdVert[1]].ptP, m_vVert[m_vTria[nT].nIdVert[2]].ptP) ;
|
||||
double dLen2 = SqDist( m_vVert[m_vTria[nT].nIdVert[2]].ptP, m_vVert[m_vTria[nT].nIdVert[0]].ptP) ;
|
||||
nEdge = -1 ;
|
||||
if ( dLen0 > dLen1 && dLen0 > dLen2)
|
||||
nEdge = 0 ;
|
||||
else if ( dLen1 > dLen2)
|
||||
nEdge = 1 ;
|
||||
else
|
||||
nEdge = 2 ;
|
||||
|
||||
// recupero il triangolo adiacente sul lato più lungo
|
||||
nAdjTrg = m_vTria[nT].nIdAdjac[nEdge] ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::RemoveInvalidTriangles( const INTVECTOR& vIds)
|
||||
{
|
||||
// al momento gestito solo per trimesh con adiacenze definite, eventualmente da estendere.
|
||||
// Analoga a RemoveFistInvalidTrg in Triangulate.cpp
|
||||
// TO DO da capire e gestire casi in cui flip lascia triangoli invalidi
|
||||
|
||||
unordered_map<int, bool> InvalidMap ;
|
||||
for ( auto nId : vIds)
|
||||
InvalidMap[nId] = true ;
|
||||
|
||||
for ( int i = 0 ; i < int( vIds.size()) ; i++) {
|
||||
|
||||
int nTA = vIds[i] ;
|
||||
if ( ! InvalidMap[nTA])
|
||||
continue ;
|
||||
|
||||
// recupero il triangolo adiacente sul suo lato più lungo
|
||||
int nTB, nEdgeA ;
|
||||
FindAdjacentOnLongerEdge( nTA, nEdgeA, nTB) ;
|
||||
|
||||
// se adiacente è nullo posso rimuovere tranquillamente il triangolo senza creare TJunctions
|
||||
if ( nTB == SVT_NULL) {
|
||||
RemoveTriangle( nTA) ;
|
||||
continue ;
|
||||
}
|
||||
// se adiacente è valido posso fare il flip per rendere valido nTA
|
||||
else if ( ! InvalidMap[nTB]) {
|
||||
FlipTriangles( nTA, nTB) ;
|
||||
InvalidMap[nTA] = false ;
|
||||
}
|
||||
// se adiacente è invalido creo una catena da risolvere non appena si trova un triangolo valido
|
||||
else {
|
||||
INTVECTOR vChain = {nTA} ;
|
||||
INTVECTOR vChainEdges = {nEdgeA} ;
|
||||
int nTCurr = nTB ;
|
||||
|
||||
while ( nTCurr != SVT_NULL && InvalidMap[nTCurr]) {
|
||||
|
||||
// calcolo il successivo
|
||||
int nTOther, nEdgeCurr ;
|
||||
FindAdjacentOnLongerEdge( nTCurr, nEdgeCurr, nTOther) ;
|
||||
|
||||
if ( nTOther == vChain.back()) {
|
||||
// se ho trovato un'adiacenza ambigua ( ovvero due triangoli invalidi adiacenti sui loro lati più lunghi)
|
||||
// flip dei due triangoli per modificare il lato più lungo e togliere adiacenza ambigua
|
||||
FlipTriangles( nTCurr, nTOther) ;
|
||||
if ( vChain.size() > 1) {
|
||||
vChain.pop_back() ;
|
||||
vChainEdges.pop_back() ;
|
||||
// individuo il nuovo adiacente all'ultimo triangolo della catena dopo aver fatto flip
|
||||
nTOther = m_vTria[vChain.back()].nIdAdjac[vChainEdges.back()] ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
vChain.emplace_back( nTCurr) ;
|
||||
vChainEdges.emplace_back( nEdgeCurr) ;
|
||||
}
|
||||
// aggiorno per iterazione successiva
|
||||
nTCurr = nTOther ;
|
||||
}
|
||||
|
||||
// se la catena termina su triangolo nullo, posso rimuovere tutti i triangoli della catena
|
||||
if ( nTCurr == SVT_NULL) {
|
||||
for ( int k = 0 ; k < int( vChain.size()) ; k++) {
|
||||
RemoveTriangle( vChain[k]) ;
|
||||
InvalidMap[vChain[k]] = false ;
|
||||
}
|
||||
}
|
||||
// se catena termina su un triangolo valido, applico il flip a cascata a partire dall'ultimo triangolo invalido trovato
|
||||
else {
|
||||
FlipTriangles( vChain.back(), nTCurr) ;
|
||||
InvalidMap[vChain.back()] = false ;
|
||||
for ( int i = int( vChain.size()) - 2 ; i >= 0 ; i--) {
|
||||
int nTA = vChain[i] ;
|
||||
if ( ! InvalidMap[nTA])
|
||||
continue ;
|
||||
// eseguo il flip con il triangolo adiacente sul suo lato più lungo
|
||||
int nTOther = m_vTria[nTA].nIdAdjac[vChainEdges[i]] ;
|
||||
FlipTriangles( nTA, nTOther) ;
|
||||
InvalidMap[nTA] = false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -2101,7 +2101,7 @@ Tree::UpdateSplitLoop( ICurveComposite* pCC, Point3d& pt)
|
||||
// potrei avere una compo vuota o con solo un punto
|
||||
// se non riesco ad aggiungere una linea allora era una compo vuota
|
||||
if ( ! pCC->GetOnlyPoint( ptLast)) {
|
||||
pCC->FromPoint( pt) ;
|
||||
pCC->AddPoint( pt) ;
|
||||
ptLast = pt ;
|
||||
}
|
||||
else {
|
||||
@@ -4139,7 +4139,7 @@ Tree::GetEdges3D( vector<ICRVCOMPOPOVECTOR>& mCCEdges, POLYLINEVECTOR& vPolygons
|
||||
pt3d = ORIG ; GetPoint( cNeigh.GetBottomLeft().x, cNeigh.GetTopRight().y, pt3d) ;
|
||||
mCCEdges.back().back()->AddLine( pt3d) ;
|
||||
if ( ! mCCEdges.back().back()->IsValid())
|
||||
mCCEdges.back().back()->FromPoint( pt3d) ;
|
||||
mCCEdges.back().back()->AddPoint( pt3d) ;
|
||||
}
|
||||
else if ( i == 1 ) {
|
||||
while ( ! AreSamePointXYApprox(pt, cNeigh.GetTopLeft()) && plCell.GetNextPoint( pt)) {
|
||||
@@ -4155,7 +4155,7 @@ Tree::GetEdges3D( vector<ICRVCOMPOPOVECTOR>& mCCEdges, POLYLINEVECTOR& vPolygons
|
||||
pt3d = ORIG ; GetPoint( cNeigh.GetBottomLeft().x, cNeigh.GetBottomLeft().y, pt3d) ;
|
||||
mCCEdges.back().back()->AddLine( pt3d) ;
|
||||
if ( ! mCCEdges.back().back()->IsValid())
|
||||
mCCEdges.back().back()->FromPoint( pt3d) ;
|
||||
mCCEdges.back().back()->AddPoint( pt3d) ;
|
||||
}
|
||||
else if ( i == 2) {
|
||||
while ( ! AreSamePointXYApprox(pt, cNeigh.GetBottomLeft()) && plCell.GetNextPoint( pt)) {
|
||||
@@ -4171,7 +4171,7 @@ Tree::GetEdges3D( vector<ICRVCOMPOPOVECTOR>& mCCEdges, POLYLINEVECTOR& vPolygons
|
||||
pt3d = ORIG ; GetPoint( cNeigh.GetTopRight().x, cNeigh.GetBottomLeft().y, pt3d) ;
|
||||
mCCEdges.back().back()->AddLine( pt3d) ;
|
||||
if ( ! mCCEdges.back().back()->IsValid())
|
||||
mCCEdges.back().back()->FromPoint( pt3d) ;
|
||||
mCCEdges.back().back()->AddPoint( pt3d) ;
|
||||
}
|
||||
else if ( i == 3) {
|
||||
while ( ! AreSamePointXYApprox(pt, cNeigh.GetBottomRight()) && plCell.GetNextPoint( pt)) {
|
||||
@@ -4187,7 +4187,7 @@ Tree::GetEdges3D( vector<ICRVCOMPOPOVECTOR>& mCCEdges, POLYLINEVECTOR& vPolygons
|
||||
pt3d = ORIG ; GetPoint( cNeigh.GetTopRight().x, cNeigh.GetTopRight().y, pt3d) ;
|
||||
mCCEdges.back().back()->AddLine( pt3d) ;
|
||||
if ( ! mCCEdges.back().back()->IsValid())
|
||||
mCCEdges.back().back()->FromPoint( pt3d) ;
|
||||
mCCEdges.back().back()->AddPoint( pt3d) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4212,7 +4212,7 @@ Tree::GetEdges3D( vector<ICRVCOMPOPOVECTOR>& mCCEdges, POLYLINEVECTOR& vPolygons
|
||||
pCC3D->AddLine( pt3D) ;
|
||||
}
|
||||
if ( ! pCC3D->IsValid())
|
||||
pCC3D->FromPoint( pt3D) ;
|
||||
pCC3D->AddPoint( pt3D) ;
|
||||
// qui devo fare dei controlli prima di aggiungere questa polyline?
|
||||
mCCEdges[i].emplace_back( Release(pCC3D)) ;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <utility>
|
||||
|
||||
struct PairHashInt64 {
|
||||
size_t operator()(const pair<int64_t, int64_t>& key) const {
|
||||
size_t operator()(const std::pair<int64_t, int64_t>& key) const {
|
||||
size_t h1 = std::hash<int64_t>{}(key.first) ;
|
||||
size_t h2 = std::hash<int64_t>{}(key.second) ;
|
||||
return h1 ^ (h2 << 1); // Combine hashes
|
||||
@@ -252,12 +252,12 @@ class Tree
|
||||
bool BuildTree( double dLinTol = LIN_TOL_STD, double dSideMin = 1, double dSideMax = INFINITO) ; // dSideMax è il massimo per la dimensione maggiore di un triangolo della trimesh
|
||||
// dSideMin è lunghezza minima del lato di una cella nello spazio reale
|
||||
bool BuildTree_test( double dLinTol = LIN_TOL_STD, double dSideMin = 1, double dSideMax = INFINITO) ;
|
||||
bool GetPolygons( POLYLINEMATRIX& vvPolygons, POLYLINEMATRIX& vvPolygons3d, vector<ICRVCOMPOPOVECTOR>& vCCEdges3D, ICRVCOMPOPOVECTOR& vCCLoops) ;
|
||||
bool GetPolygons( POLYLINEMATRIX& vvPolygons, POLYLINEMATRIX& vvPolygons3d, std::vector<ICRVCOMPOPOVECTOR>& vCCEdges3D, ICRVCOMPOPOVECTOR& vCCLoops) ;
|
||||
bool GetPolygonsBasic( POLYLINEVECTOR& vPolygons, POLYLINEVECTOR& vPolygonsCorrected, POLYLINEVECTOR& vPolygons3d) ; // restituisce il poligono corrispondente ad ogni cella foglia dell'albero
|
||||
// ad ogni poligono sono stati aggiunti tutti i vertici dei vicini posizionati sui suoi lati
|
||||
// ad alcuni poligoni potrebbero venire tolti dei punti per evitare errori dovuti ad eventuali poli sui bordi del parametrico
|
||||
bool GetLeaves ( std::vector<Cell>& vLeaves) const ; // restituisce gli indici delle foglie nell'albero
|
||||
bool GetEdges3D ( vector<ICRVCOMPOPOVECTOR>& mCCEdge, POLYLINEVECTOR& vPolygons) ; // restituisce gli edge 3D come polyline
|
||||
bool GetEdges3D ( std::vector<ICRVCOMPOPOVECTOR>& mCCEdge, POLYLINEVECTOR& vPolygons) ; // restituisce gli edge 3D come polyline
|
||||
bool GetSplitLoops( ICRVCOMPOPOVECTOR& vCCLoopSplit) const // funzione che restituisce i loop splitatti ai confini delle celle
|
||||
{ for ( int i = 0 ; i < int( m_vCCLoop2D.size()); ++i) vCCLoopSplit.emplace_back( m_vCCLoop2D[i]->Clone()) ; return true ; };
|
||||
void SetTestMode( void) { m_bTestMode = true ;} ; // attivando la test mode, per la costruzione dell'albero viene usata la funzione BuiltTree_test e viene corretta di conseguenza la FindCell
|
||||
@@ -312,8 +312,8 @@ class Tree
|
||||
const SurfBezier* m_pSrfBz ; // superficie di bezier
|
||||
DBLVECTOR m_vDim ; // distanze tra i vertici della superficie di bezier in 3d in ordine antiorario a partire da ptP00
|
||||
bool m_bTrimmed ; // superficie trimmata
|
||||
unordered_map<int,int> m_mChunk ; // mappa in cui vengono salvati chunk di appartenza per ogni loop di trim
|
||||
vector<tuple<PolyLine,bool>> m_vPlApprox ; // vettore contenente le approssimazioni dei loop // il bool indica se la curva è CCW
|
||||
std::unordered_map<int,int> m_mChunk ; // mappa in cui vengono salvati chunk di appartenza per ogni loop di trim
|
||||
std::vector<std::tuple<PolyLine,bool>> m_vPlApprox ; // vettore contenente le approssimazioni dei loop // il bool indica se la curva è CCW
|
||||
bool m_bBilinear ; // superficie bilineare
|
||||
bool m_bMulti ; // superficie multi-patch
|
||||
bool m_bClosedU ; // superficie chiusa lungo il parametro U
|
||||
@@ -324,11 +324,11 @@ class Tree
|
||||
int m_nDegV ; // grado della superficie nel parametro V
|
||||
int m_nSpanU ; // numero di span lungo il parametro U
|
||||
int m_nSpanV ; // numero di span lungo il parametro V
|
||||
unordered_map<int,Cell> m_mTree ; // mappa che contiene tutti i nodi e le foglie dell'albero. -2 è puntatore Null e -1 è root
|
||||
mutable unordered_map<pair<int64_t, int64_t>,Point3d, PairHashInt64> m_mPt3d ; // mappa che contiene tutti i punti 3d della superficie calcolati (la chiave sono le coordinate, moltiplicate per 2^24 e trasformate in int)
|
||||
std::unordered_map<int,Cell> m_mTree ; // mappa che contiene tutti i nodi e le foglie dell'albero. -2 è puntatore Null e -1 è root
|
||||
mutable std::unordered_map<std::pair<int64_t, int64_t>,Point3d, PairHashInt64> m_mPt3d ; // mappa che contiene tutti i punti 3d della superficie calcolati (la chiave sono le coordinate, moltiplicate per 2^24 e trasformate in int)
|
||||
INTVECTOR m_vnLeaves ; // vettore delle foglie
|
||||
INTVECTOR m_vnParents ; // vettore delle celle ottenute dalla divisione preliminare in singole patch
|
||||
bool m_bTestMode ; // bool che indica se la test mode è attiva
|
||||
ICRVCOMPOPOVECTOR m_vCCLoop2D ; // vettore che contiene le CurveCompo che rappresentano i loop di trim tenendo conto della divisione in celle
|
||||
vector<pair<BIPNTVECTOR, ChainCurves>> m_vCEdge2D ; // vettore che le chain che rappresentano ciò che resta degli edge originali, tenendo conto dei trim.
|
||||
std::vector<std::pair<BIPNTVECTOR, ChainCurves>> m_vCEdge2D ; // vettore che le chain che rappresentano ciò che resta degli edge originali, tenendo conto dei trim.
|
||||
} ;
|
||||
+53
-34
@@ -818,7 +818,7 @@ Triangulate::TestTriangle( const PNTVECTOR& vPt, const INTVECTOR& vPol,
|
||||
}
|
||||
}
|
||||
// If vertex k is inside the ear triangle, then this is not an ear
|
||||
else if ( TestPointInTriangle( vPt[vPol[k]], vPt[vPol[vPrev[i]]], vPt[vPol[i]], vPt[vPol[vNext[i]]])) {
|
||||
else if ( TestPointInOrOnTriangle( vPt[vPol[k]], vPt[vPol[vPrev[i]]], vPt[vPol[i]], vPt[vPol[vNext[i]]])) {
|
||||
bIsEar = false ;
|
||||
break ;
|
||||
}
|
||||
@@ -978,6 +978,28 @@ Triangulate::TestPointInTriangle( const Point3d& ptP, const Point3d& ptA, const
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// test if point p is inside or on the border of triangle (a, b, c)
|
||||
bool
|
||||
Triangulate::TestPointInOrOnTriangle( const Point3d& ptP, const Point3d& ptA, const Point3d& ptB, const Point3d& ptC)
|
||||
{
|
||||
// If P is on a vertex is considered inside
|
||||
if ( AreSamePoint( ptP, ptA))
|
||||
return true ;
|
||||
if ( AreSamePoint( ptP, ptB))
|
||||
return true ;
|
||||
if ( AreSamePoint( ptP, ptC))
|
||||
return true ;
|
||||
// If P is on the right of at least one edge is outside
|
||||
if ( TriangleIsCCW( ptA, ptP, ptB, EPS_SMALL))
|
||||
return false ;
|
||||
if ( TriangleIsCCW( ptB, ptP, ptC, EPS_SMALL))
|
||||
return false ;
|
||||
if ( TriangleIsCCW( ptC, ptP, ptA, EPS_SMALL))
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Triangulate::SortInternalLoops( const POLYLINEVECTOR& vPL, INTVECTOR& vOrd)
|
||||
@@ -1385,6 +1407,7 @@ RemoveFistInvalidTrg( PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
// I triangoli cap se eliminati danno origine a T-junctions, quindi devono essere gestiti opportunamente con dei flip.
|
||||
// I triangoli needle se eliminati non sono problematici, ma i loro vertici coincidenti vanno gestiti opportunamente nel
|
||||
// calcolo delle adiacenze dei triangoli cap.
|
||||
// TO DO da capire e gestire casi in cui flip lascia triangoli invalidi
|
||||
|
||||
int nTria = int( vTr.size()) / 3 ;
|
||||
INTVECTOR vCapTria ;
|
||||
@@ -1482,46 +1505,40 @@ RemoveFistInvalidTrg( PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
INTVECTOR vChain, vChainEdges ;
|
||||
vChain.emplace_back( nTA) ;
|
||||
vChainEdges.emplace_back( nEA) ;
|
||||
|
||||
while ( nTB != -1 && ! vbIsValidTria[nTB]) {
|
||||
// aggiungo alla catena
|
||||
vChain.emplace_back( nTB) ;
|
||||
int nTCurr = nTB ;
|
||||
int nEOther ;
|
||||
while ( nTCurr != -1 && ! vbIsValidTria[nTCurr]) {
|
||||
|
||||
// calcolo il successivo
|
||||
nTA = nTB ;
|
||||
FindAdjacentOnLongerEdge( vPt, vTr, nTA, nEA, nTB, nEB) ;
|
||||
vChainEdges.emplace_back( nEA) ;
|
||||
int nTOther, nECurr ;
|
||||
FindAdjacentOnLongerEdge( vPt, vTr, nTCurr, nECurr, nTOther, nEOther) ;
|
||||
|
||||
// verifico di non aver trovato un'adiacenza ambigua ( ovvero due triangoli invalidi adiacenti sui loro lati più lunghi)
|
||||
// e quindi di non essere entrato in un loop
|
||||
if ( nTB == vChain[vChain.size()-2]) {
|
||||
if ( nTOther == vChain.back()) {
|
||||
// se ho trovato un'adiacenza ambigua ( ovvero due triangoli invalidi adiacenti sui loro lati più lunghi)
|
||||
// flip dei due triangoli per modificare il lato più lungo e togliere adiacenza ambigua
|
||||
FlipTrg( vTr, nTA, nTB, nEA, nEB) ;
|
||||
// aggiorno per iterazione successiva
|
||||
if ( vChain.size() == 2) {
|
||||
FlipTrg( vTr, nTCurr, nTOther, nECurr, nEOther) ;
|
||||
if ( vChain.size() > 1) {
|
||||
vChain.pop_back() ;
|
||||
vChainEdges.pop_back() ;
|
||||
FindAdjacentOnLongerEdge( vPt, vTr, vChain.back(), nEA, nTB, nEB) ;
|
||||
vChainEdges[0] = nEA ;
|
||||
// individuo il nuovo adiacente all'ultimo triangolo della catena tra i due appena flippati
|
||||
TestAdjacentOnEdge( vTr, vChain.back(), vChainEdges.back(), nTCurr, nTOther, nTB, nEB) ;
|
||||
nTOther = nTB ;
|
||||
}
|
||||
else {
|
||||
// elimino gli ultimi due triangoli che sono appena stati flippati e ricalcolo adiacenza del triangolo
|
||||
// precedente
|
||||
vChain.pop_back() ;
|
||||
vChain.pop_back() ;
|
||||
vChainEdges.pop_back() ;
|
||||
vChainEdges.pop_back() ;
|
||||
int nTTest1 = nTA ;
|
||||
int nTTest2 = nTB ;
|
||||
TestAdjacentOnEdge( vTr, vChain.back(), vChainEdges.back(), nTTest1, nTTest2, nTB, nEB) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
vChain.emplace_back( nTCurr) ;
|
||||
vChainEdges.emplace_back( nECurr) ;
|
||||
}
|
||||
// aggiorno per iterazione successiva
|
||||
nTCurr = nTOther ;
|
||||
}
|
||||
|
||||
// se la catena termina su triangolo nullo, annullo tutti i triangoli della catena
|
||||
if ( nTB == -1) {
|
||||
if ( nTCurr == -1) {
|
||||
bRemovedTrg = true ;
|
||||
for ( int k = 0 ; k < int( vChain.size()) ; k++) {
|
||||
if ( vbIsValidTria[vChain[k]])
|
||||
continue ;
|
||||
vTr[3*vChain[k]] = -1 ;
|
||||
vTr[3*vChain[k] + 1] = -1 ;
|
||||
vTr[3*vChain[k] + 2] = -1 ;
|
||||
@@ -1530,14 +1547,16 @@ RemoveFistInvalidTrg( PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
}
|
||||
// se catena termina su un triangolo valido, applico il flip a cascata a partire dall'ultimo triangolo invalido
|
||||
else {
|
||||
FlipTrg( vTr, vChain.back(), nTB, vChainEdges.back(), nEB) ;
|
||||
FlipTrg( vTr, vChain.back(), nTCurr, vChainEdges.back(), nEOther) ;
|
||||
vbIsValidTria[vChain.back()] = true ;
|
||||
int nTrgTest1 = vChain.back() ;
|
||||
int nTrgTest2 = nTB ;
|
||||
for ( int i = int( vChain.size()-2) ; i >= 0 ; i--) {
|
||||
int nTrgTest2 = nTCurr ;
|
||||
for ( int j = int( vChain.size()-2) ; j >= 0 ; j--) {
|
||||
// triangolo corrente
|
||||
int nTA = vChain[i] ;
|
||||
int nEA = vChainEdges[i] ;
|
||||
int nTA = vChain[j] ;
|
||||
if ( vbIsValidTria[nTA])
|
||||
continue ;
|
||||
int nEA = vChainEdges[j] ;
|
||||
// devo trovare il nuovo adiacente dopo il flip dei successivi nella catena
|
||||
TestAdjacentOnEdge( vTr, nTA, nEA, nTrgTest1, nTrgTest2, nTB, nEB) ;
|
||||
// flip per rendere valido il triangolo corrente
|
||||
@@ -1608,7 +1627,7 @@ MakeByFist( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
vPt.reserve( fist.c_vertex.num_vertices) ;
|
||||
for ( int i = 0 ; i < fist.c_vertex.num_vertices ; i ++)
|
||||
vPt.emplace_back( fist.c_vertex.vertices[i].x, fist.c_vertex.vertices[i].y, fist.c_vertex.vertices[i].z) ;
|
||||
|
||||
|
||||
// recupero i triangoli da fist
|
||||
vTr.reserve( 3 * fist.c_vertex.num_triangles) ;
|
||||
for ( int i = 0 ; i < fist.c_vertex.num_triangles ; i ++) {
|
||||
|
||||
@@ -45,6 +45,7 @@ class Triangulate
|
||||
bool TriangleIsCCW( const Point3d& ptA, const Point3d& ptB, const Point3d& ptC, double dToler = 0.1 * EPS_SMALL) ;
|
||||
bool TestIntersection( const Point3d& ptA1, const Point3d& ptA2, const Point3d& ptB1, const Point3d& ptB2) ;
|
||||
bool TestPointInTriangle( const Point3d& ptP, const Point3d& ptA, const Point3d& ptB, const Point3d& ptC) ;
|
||||
bool TestPointInOrOnTriangle( const Point3d& ptP, const Point3d& ptA, const Point3d& ptB, const Point3d& ptC) ;
|
||||
bool SortInternalLoops( const POLYLINEVECTOR& vPL, INTVECTOR& vOrd) ;
|
||||
bool GetPntVectorFromPolyline( const PolyLine& PL, bool bXmaxStart, PNTVECTOR& vPi) ;
|
||||
bool GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& nI) ;
|
||||
|
||||
+103
-15
@@ -1520,14 +1520,14 @@ VolZmap::AddSurfTm( const ISurfTriMesh* pStm)
|
||||
|
||||
// ciclo sulle griglie
|
||||
bool bCompleted = true ;
|
||||
for ( int g = 0 ; g < m_nMapNum ; ++ g) {
|
||||
for ( int nG = 0 ; nG < m_nMapNum ; ++ nG) {
|
||||
// definisco dei sistemi di riferimento ausiliari
|
||||
Frame3d frMapFrame ;
|
||||
if ( g == 0)
|
||||
if ( nG == 0)
|
||||
frMapFrame = m_MapFrame ;
|
||||
else if ( g == 1)
|
||||
else if ( nG == 1)
|
||||
frMapFrame.Set( m_MapFrame.Orig(), Y_AX, Z_AX, X_AX) ;
|
||||
else if ( g == 2)
|
||||
else if ( nG == 2)
|
||||
frMapFrame.Set( m_MapFrame.Orig(), Z_AX, X_AX, Y_AX) ;
|
||||
|
||||
// oggetto per calcolo massivo intersezioni
|
||||
@@ -1538,33 +1538,121 @@ VolZmap::AddSurfTm( const ISurfTriMesh* pStm)
|
||||
vector<future<bool>> vRes ;
|
||||
vRes.resize( nThreadMax) ;
|
||||
// se dimensione griglia in X maggiore di dimensione Y
|
||||
if ( m_nNx[g] > m_nNy[g]) {
|
||||
int nDexNum = m_nNx[g] / nThreadMax ;
|
||||
int nRemainder = m_nNx[g] % nThreadMax ;
|
||||
if ( m_nNx[nG] > m_nNy[nG]) {
|
||||
int nDexNum = m_nNx[nG] / nThreadMax ;
|
||||
int nRemainder = m_nNx[nG] % nThreadMax ;
|
||||
int nInfI = 0 ;
|
||||
int nSupI = 0 ;
|
||||
// aggiungo le parti interessate alla mappa
|
||||
for ( int nThread = 0 ; nThread < nThreadMax ; ++ nThread) {
|
||||
nInfI = nSupI ;
|
||||
nSupI = nInfI + ( nThread < nRemainder ? nDexNum + 1 : nDexNum) ;
|
||||
vRes[nThread] = async( launch::async, &VolZmap::AddMapPart, this, g,
|
||||
nInfI, nSupI, 0, m_nNy[g], ref( vtLen), ref( m_MapFrame.Orig()),
|
||||
ref( *pStm), ref( intPLSTM)) ;
|
||||
vRes[nThread] = async( launch::async, &VolZmap::AddMapPart, this, nG,
|
||||
nInfI, nSupI, 0, m_nNy[nG], ref( vtLen), ref( m_MapFrame.Orig()),
|
||||
ref( *pStm), ref( intPLSTM)) ;
|
||||
}
|
||||
}
|
||||
// se dimensione griglia in Y maggiore di dimensione X
|
||||
else {
|
||||
int nDexNum = m_nNy[g] / nThreadMax ;
|
||||
int nRemainder = m_nNy[g] % nThreadMax ;
|
||||
int nDexNum = m_nNy[nG] / nThreadMax ;
|
||||
int nRemainder = m_nNy[nG] % nThreadMax ;
|
||||
int nInfJ = 0 ;
|
||||
int nSupJ = 0 ;
|
||||
// aggiungo le parti interessate alla mappa
|
||||
for ( int nThread = 0 ; nThread < nThreadMax ; ++ nThread) {
|
||||
nInfJ = nSupJ ;
|
||||
nSupJ = nInfJ + ( nThread < nRemainder ? nDexNum + 1 : nDexNum) ;
|
||||
vRes[nThread] = async( launch::async, &VolZmap::AddMapPart, this, g,
|
||||
0, m_nNx[g], nInfJ, nSupJ, ref( vtLen), ref( m_MapFrame.Orig()),
|
||||
ref( *pStm), ref( intPLSTM)) ;
|
||||
vRes[nThread] = async( launch::async, &VolZmap::AddMapPart, this, nG,
|
||||
0, m_nNx[nG], nInfJ, nSupJ, ref( vtLen), ref( m_MapFrame.Orig()),
|
||||
ref( *pStm), ref( intPLSTM)) ;
|
||||
}
|
||||
}
|
||||
|
||||
// ciclo per attendere che tutti gli async abbiano terminato.
|
||||
int nTerminated = 0 ;
|
||||
while ( nTerminated < nThreadMax) {
|
||||
for ( int nL = 0 ; nL < nThreadMax ; ++ nL) {
|
||||
// async terminato
|
||||
if ( vRes[nL].valid() && vRes[nL].wait_for( chrono::microseconds{ 1}) == future_status::ready) {
|
||||
++ nTerminated ;
|
||||
bCompleted = bCompleted && vRes[nL].get() ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! bCompleted)
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::SubtractSurfTm( const ISurfTriMesh* pStm)
|
||||
{
|
||||
// controllo sulla superficie
|
||||
double dVol ;
|
||||
if ( pStm == nullptr || ! pStm->IsValid() || ! pStm->IsClosed() ||
|
||||
! pStm->GetVolume( dVol) || dVol < 0)
|
||||
return false ;
|
||||
|
||||
// controllo se il Box3d della superficie si interseca con il Box3d dello Zmap corrente
|
||||
BBox3d BBox_stm, BBox_curr ;
|
||||
if ( ! pStm->GetLocalBBox( BBox_stm) || ! GetLocalBBox( BBox_curr))
|
||||
return false ;
|
||||
BBox3d BBox_inters ;
|
||||
if ( BBox_stm.FindIntersection( BBox_curr, BBox_inters) && BBox_inters.IsEmpty())
|
||||
return true ; // se non ci sono intersezioni, la superficie non influenza lo Zmap
|
||||
Vector3d vtLen = BBox_curr.GetMax() - BBox_curr.GetMin() ; // dimensione massima dello spillone
|
||||
|
||||
// ciclo sulle griglie
|
||||
bool bCompleted = true ;
|
||||
for ( int nG = 0 ; nG < m_nMapNum ; ++ nG) {
|
||||
// definisco dei sistemi di riferimento ausiliari
|
||||
Frame3d frMapFrame ;
|
||||
if ( nG == 0)
|
||||
frMapFrame = m_MapFrame ;
|
||||
else if ( nG == 1)
|
||||
frMapFrame.Set( m_MapFrame.Orig(), Y_AX, Z_AX, X_AX) ;
|
||||
else if ( nG == 2)
|
||||
frMapFrame.Set( m_MapFrame.Orig(), Z_AX, X_AX, Y_AX) ;
|
||||
|
||||
// oggetto per calcolo massivo intersezioni
|
||||
IntersParLinesSurfTm intPLSTM( frMapFrame, *pStm) ;
|
||||
|
||||
// numero massimo di thread
|
||||
int nThreadMax = max( 1, int( thread::hardware_concurrency()) - 1) ;
|
||||
vector<future<bool>> vRes ;
|
||||
vRes.resize( nThreadMax) ;
|
||||
// se dimensione griglia in X maggiore di dimensione Y
|
||||
if ( m_nNx[nG] > m_nNy[nG]) {
|
||||
int nDexNum = m_nNx[nG] / nThreadMax ;
|
||||
int nRemainder = m_nNx[nG] % nThreadMax ;
|
||||
int nInfI = 0 ;
|
||||
int nSupI = 0 ;
|
||||
// aggiungo le parti interessate alla mappa
|
||||
for ( int nThread = 0 ; nThread < nThreadMax ; ++ nThread) {
|
||||
nInfI = nSupI ;
|
||||
nSupI = nInfI + ( nThread < nRemainder ? nDexNum + 1 : nDexNum) ;
|
||||
vRes[nThread] = async( launch::async, &VolZmap::SubtractMapPart, this, nG,
|
||||
nInfI, nSupI, 0, m_nNy[nG], ref( vtLen), ref( m_MapFrame.Orig()),
|
||||
ref( *pStm), ref( intPLSTM)) ;
|
||||
}
|
||||
}
|
||||
// se dimensione griglia in Y maggiore di dimensione X
|
||||
else {
|
||||
int nDexNum = m_nNy[nG] / nThreadMax ;
|
||||
int nRemainder = m_nNy[nG] % nThreadMax ;
|
||||
int nInfJ = 0 ;
|
||||
int nSupJ = 0 ;
|
||||
// aggiungo le parti interessate alla mappa
|
||||
for ( int nThread = 0 ; nThread < nThreadMax ; ++ nThread) {
|
||||
nInfJ = nSupJ ;
|
||||
nSupJ = nInfJ + ( nThread < nRemainder ? nDexNum + 1 : nDexNum) ;
|
||||
vRes[nThread] = async( launch::async, &VolZmap::SubtractMapPart, this, nG,
|
||||
0, m_nNx[nG], nInfJ, nSupJ, ref( vtLen), ref( m_MapFrame.Orig()),
|
||||
ref( *pStm), ref( intPLSTM)) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,15 +16,23 @@
|
||||
#include "ObjGraphicsMgr.h"
|
||||
#include "GeoObjRW.h"
|
||||
#include "Tool.h"
|
||||
#include "SurfBezier.h"
|
||||
#include "/EgtDev/Include/EGkVolZmap.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineVolZmap.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include <unordered_map>
|
||||
#include <stack>
|
||||
#include <mutex>
|
||||
#include <atomic>
|
||||
#include <tuple>
|
||||
|
||||
typedef std::pair<Point3d, Vector3d> PNTVEC3D ;
|
||||
typedef std::vector<PNTVEC3D> PNTVEC3DVECTOR ; // vettore di intersezioni punto, vettore, tipo superficie
|
||||
|
||||
// ------------------------- FORWARD -------------------------------------------------------------
|
||||
class IntersParLinesSurfTm ;
|
||||
class BBox3d ;
|
||||
class Frame3d ;
|
||||
|
||||
// ------------------------- STRUTTURE -----------------------------------------------------------
|
||||
struct AppliedVector {
|
||||
@@ -33,6 +41,55 @@ struct AppliedVector {
|
||||
int nPropIndex ;
|
||||
} ;
|
||||
|
||||
struct MachInfo {
|
||||
int n5AxisType ;
|
||||
int nSub ;
|
||||
int nStepCnt ;
|
||||
double dSide ;
|
||||
Vector3d vtDirTipStartEx ;
|
||||
Vector3d vtDirTipEndEx ;
|
||||
Vector3d vtDirTopStartEx ;
|
||||
Vector3d vtDirTopEndEx ;
|
||||
VCT3DVECTOR vvtTipStartAux ;
|
||||
VCT3DVECTOR vvtTipEndAux ;
|
||||
VCT3DVECTOR vvtTopStartAux ;
|
||||
VCT3DVECTOR vvtTopEndAux ;
|
||||
Vector3d vtDirTip ;
|
||||
Vector3d vtDirTop ;
|
||||
MachInfo( int n5AxisType_, int nSub_, int nStepCnt_, double dSide_, Vector3d vtDirTipStartEx_, Vector3d vtDirTipEndEx_, Vector3d vtDirTopStartEx_, Vector3d vtDirTopEndEx_,
|
||||
VCT3DVECTOR vvtTipStartAux_, VCT3DVECTOR vvtTipEndAux_, VCT3DVECTOR vvtTopStartAux_, VCT3DVECTOR vvtTopEndAux_, Vector3d vtDirTip_, Vector3d vtDirTop_) :
|
||||
n5AxisType( n5AxisType_), nSub( nSub_), nStepCnt( nStepCnt_), dSide( dSide_), vtDirTipStartEx( vtDirTipStartEx_), vtDirTipEndEx( vtDirTipEndEx_), vtDirTopStartEx( vtDirTopStartEx_), vtDirTopEndEx( vtDirTopEndEx_),
|
||||
vvtTipStartAux( vvtTipStartAux_), vvtTipEndAux( vvtTipEndAux_), vvtTopStartAux( vvtTopStartAux_), vvtTopEndAux( vvtTopEndAux_), vtDirTip( vtDirTip_), vtDirTop( vtDirTop_) {}
|
||||
};
|
||||
|
||||
struct ToolInfo {
|
||||
double dHeight ;
|
||||
double dMaxRad ;
|
||||
double dMinRad ;
|
||||
double dTan ;
|
||||
double dMaxH ;
|
||||
double dMinH ;
|
||||
double dMaxRadApprox ;
|
||||
double dMinRadApprox ;
|
||||
BBox3d bbStartCyl ;
|
||||
BBox3d bbEndCyl ;
|
||||
Frame3d frToolStart ;
|
||||
Frame3d frToolEnd ;
|
||||
//Vector3d vtDirTip ;
|
||||
//Vector3d vtDirTop ;
|
||||
ToolInfo( double dHeight_, double dMaxRad_, double dMinRad_, double dTan_, double dMaxH_, double dMinH_, double dMaxRadApprox_, double dMinRadApprox_,
|
||||
BBox3d bbStartCyl_, BBox3d bbEndCyl_, Frame3d frToolStart_, Frame3d frToolEnd_) :
|
||||
dHeight ( dHeight_), dMaxRad( dMaxRad_), dMinRad( dMinRad_), dTan( dTan_), dMaxH( dMaxH_), dMinH( dMinH_), dMaxRadApprox( dMaxRadApprox_), dMinRadApprox( dMinRadApprox_),
|
||||
bbStartCyl( bbStartCyl_), bbEndCyl( bbEndCyl_), frToolStart( frToolStart_), frToolEnd( frToolEnd_) {}
|
||||
};
|
||||
|
||||
struct SurfBezForInters {
|
||||
SurfBezier sBez ;
|
||||
BBox3d bbSurf ;
|
||||
double A1, A2, B1, B2, C1, C2 ;
|
||||
Vector3d d ;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
{
|
||||
@@ -80,10 +137,13 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
bool Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, double dStep, bool bTriDex) override ;
|
||||
bool CreateEmpty( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, double dStep, bool bTriDex) override ;
|
||||
bool CreateFromFlatRegion( const ISurfFlatRegion& Surf, double dDimZ, double dStep, bool bTriDex) override ;
|
||||
bool CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex) override ;
|
||||
bool CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex, double dExtraBox = 0.) override ;
|
||||
bool CreateFromTriMeshOffset( const CISURFTMPVECTOR& vSurf, double dOffs, double dTol, int nType = STMOFF_FILLET) override ;
|
||||
bool CreateFromTriMeshThickeningOffset( const CISURFTMPVECTOR& vSurf, double dOffs, double dTol, int nType = STMOFF_FILLET) override ;
|
||||
int GetBlockCount( void) const override ;
|
||||
int GetBlockUpdatingCounter( int nBlock) const override ;
|
||||
bool GetBlockTriangles( int nBlock, TRIA3DEXVECTOR& vTria) const override ;
|
||||
ISurfTriMesh* GetSurfTriMesh( void) const override ;
|
||||
bool GetEdges( ICURVEPOVECTOR& vpCurve) const override ;
|
||||
bool GetVolume( double& dVol) const override ;
|
||||
bool IsTriDexel( void) const override
|
||||
@@ -93,7 +153,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
{ return m_nDexVoxRatio ; }
|
||||
bool ChangeResolution( int nDexVoxRatio) override ;
|
||||
void SetShowEdges( bool bShow) override
|
||||
{ m_bShowEdges = bShow ; // qui è necessario far ricreare la grafica
|
||||
{ m_bShowEdges = bShow ; // qui � necessario far ricreare la grafica
|
||||
m_OGrMgr.Clear() ; }
|
||||
bool GetShowEdges( void) const override
|
||||
{ return m_bShowEdges ; }
|
||||
@@ -144,6 +204,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
bool RemovePart( int nPart) override ;
|
||||
int GetPartMinDistFromPoint( const Point3d& ptP) const override ;
|
||||
bool AddSurfTm( const ISurfTriMesh* pStm) override ;
|
||||
bool SubtractSurfTm( const ISurfTriMesh* pStm) override ;
|
||||
bool MakeUniform( double dToler) override ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
@@ -258,9 +319,12 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
bool MillingTranslationStep( const Point3d& ptPs, const Point3d& ptPe, const Vector3d& vtD, const Vector3d& vtA) ;
|
||||
bool MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& vtAs,
|
||||
const Point3d& ptPe, const Vector3d& vtDe, const Vector3d& vtAe) ;
|
||||
bool SelectGeneralMotion( int nGrid, const PNTVECTOR& ptPs, const PNTVECTOR& ptPe, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int n5AxisType) ;
|
||||
bool SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtL, const Vector3d& vtAL) ;
|
||||
bool InitializePointsAndVectors( const Point3d& ptPs, const Point3d& ptPe, const Vector3d& vtDs, const Vector3d& vtAs,
|
||||
Point3d ptLs[3], Point3d ptLe[3], Vector3d vtLs[3], Vector3d vtALs[3]) ;
|
||||
bool InitializeAuxPoints( Point3d ptTop1s[3], Point3d ptTop1e[3], Point3d ptTop2s[3], Point3d ptTop2e[3],
|
||||
Point3d ptBottom1s[3], Point3d ptBottom1e[3], Point3d ptBottom2s[3], Point3d ptBottom2e[3]) ;
|
||||
// SOTTRAZIONI
|
||||
// UTENSILI
|
||||
// Asse di simmetria parallelo a Z
|
||||
@@ -288,11 +352,16 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
bool Conus_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) ;
|
||||
bool Conus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) ;
|
||||
bool Mrt_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) ;
|
||||
bool Mrt_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) ; // E' in realtà un Perp
|
||||
bool Mrt_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) ; // E' in realt� un Perp
|
||||
bool Chs_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) ;
|
||||
bool Chs_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) ; // E' in realtà un Perp
|
||||
bool Chs_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) ; // E' in realt� un Perp
|
||||
bool GenTool_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) ;
|
||||
bool GenTool_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) ;
|
||||
// lavorazioni a 5 assi
|
||||
bool GenTool_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, int n5AxisType = VolZmap::Move5Axis::ACROSS) ;
|
||||
bool Cyl_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, double dHeightCorr = 0, int n5AxisType = VolZmap::Move5Axis::ACROSS) ;
|
||||
bool CylBall_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, int n5AxisType = VolZmap::Move5Axis::ACROSS) ;
|
||||
bool Conus_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, int n5AxisType = VolZmap::Move5Axis::ACROSS) ;
|
||||
|
||||
// COMPONENTI
|
||||
// Asse di simmetria diretto come l'asse Z
|
||||
@@ -311,7 +380,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum) ;
|
||||
bool CompPar_ZMilling( int nGrid, double dLenX, double dLenY, double dLenZ,
|
||||
const Point3d& ptS, const Point3d& ptE,
|
||||
const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) ; // E' in realtà MillingPerp
|
||||
const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) ; // E' in realt� MillingPerp
|
||||
// Asse di simmetria con orientazione generica
|
||||
bool CompCyl_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir,
|
||||
double dHei, double dRad, bool bTapB, bool bTapT, int nToolNum) ;
|
||||
@@ -327,7 +396,15 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum) ;
|
||||
bool CompPar_Milling( int nGrid, double dLenX, double dLenY, double dLenZ,
|
||||
const Point3d& ptS, const Point3d& ptE,
|
||||
const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) ; // E' in realtà MillingPerp
|
||||
const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) ; // E' in realtà MillingPerp
|
||||
// lavorazioni a 5 assi
|
||||
bool Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe,
|
||||
double dHeight, double dMaxRad, double dMinRad, int nToolNum, int n5AxisType) ;
|
||||
bool CompCyl_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe,
|
||||
double dHeight, double dRadius, int nToolNum,int n5AxisType) ;
|
||||
bool CompConus_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtToolDirS, const VCT3DVECTOR& vtToolDirE, double dHei, double dMaxRad, double dMinRad,
|
||||
bool bTapB, bool bTapT,const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum, int n5AxisType) ;
|
||||
|
||||
// Generica traslazione sfera
|
||||
bool CompBall_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, double dRad, int nToolNum) ;
|
||||
// Additivi
|
||||
@@ -341,7 +418,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
// BBox per utensili e solidi semplici con movimenti di traslazione
|
||||
inline bool TestToolBBox( int nGrid, const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtV,
|
||||
int& nStI, int& nStJ, int& nEnI, int& nEnJ) ;
|
||||
inline bool TestCompoBBox( int nGrid, const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtV,
|
||||
inline bool TestCompoBBox( int nGrid, const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtV, const Vector3d& vtV2,
|
||||
double dRad, double dTipRad, double dHei,
|
||||
int& nStI, int& nStJ, int& nEnI, int& nEnJ) ;
|
||||
inline bool TestParaBBox( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtD, const Vector3d& vtA,
|
||||
@@ -372,6 +449,8 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
bool IntersLineTruncatedPyramid( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
const Frame3d& frTruncPyramFrame, double dSegMin, double dSegMax, double dHeight,
|
||||
Point3d& ptInt1, Vector3d& vtN1, Point3d& ptInt2, Vector3d& vtN2) const ;
|
||||
bool IntersToolLine( const Point3d& ptLineStart, const Vector3d& vtLineDir, const MachInfo& mi, const ToolInfo& ti,
|
||||
const std::vector<SurfBezForInters>& vSurfBez,PNTVEC3DVECTOR& vInters, INTVECTOR& vSurfInters) const ;
|
||||
bool TestIntersPlaneZmapBBox( const Plane3d& plPlane) const ;
|
||||
// Voxel: esistenza e passaggio da N a ijk per i voxel
|
||||
bool IsValidVoxel( int nN) const ;
|
||||
@@ -432,17 +511,55 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
const ISurfTriMesh& Surf, IntersParLinesSurfTm& intPLSTM) ;
|
||||
bool AddMapPart( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, const Vector3d& vtLen, const Point3d& ptMapOrig,
|
||||
const ISurfTriMesh& Surf, IntersParLinesSurfTm& intPLSTM) ;
|
||||
bool SubtractMapPart( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, const Vector3d& vtLen, const Point3d& ptMapOrig,
|
||||
const ISurfTriMesh& Surf, IntersParLinesSurfTm& intPLSTM) ;
|
||||
// Funzioni per Offset di superfici
|
||||
bool InitVolZMapOffs( const CISURFTMPVECTOR& vSurf, double dOffs, double dTol) ;
|
||||
bool InitVolZMapThickeningOffs( const CISURFTMPVECTOR& vSurf, double dOffs, double dTol) ;
|
||||
bool UpdateVolZMapByOpenSurfFilletOffset( const ISurfTriMesh* Surf, double dOffs, double dTol) ;
|
||||
bool UpdateVolZMapByClosedSurfFilletOffset( const ISurfTriMesh* Surf, double dOffs, double dTol) ;
|
||||
bool UpdateVolZMapBySurfThickeningFilletOffset( const ISurfTriMesh* Surf, double dOffs, double dTol) ;
|
||||
bool CreateOffsSphereOnVertex( const Point3d& ptV, double dOffs, int nGrid, int nVertexType = 0) ;
|
||||
bool CreateOffsCylinderOnEdge( const Point3d& ptP1, const Point3d& ptP2, double dOffs, int nGrid, int nVertexType = 0) ;
|
||||
bool SubtractIntervalsForOffset( int nGrid, int nI, int nJ,
|
||||
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax,
|
||||
int nToolNum, bool bSkipSwap = false) ;
|
||||
bool AddIntervalsForOffset( int nGrid, int nI, int nJ,
|
||||
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax,
|
||||
int nToolNum, bool bSkipSwap = false) ;
|
||||
public :
|
||||
// ------------------------- ENUM ----------------------------------------------------------------
|
||||
enum MillingPhase {
|
||||
COUNT_START_VOL = 0 ,
|
||||
ONLY_LATERAL_SURF = 1 ,
|
||||
COUNT_END_VOL = 2 ,
|
||||
COUNT_START_END = 3
|
||||
} ;
|
||||
|
||||
enum Move5Axis{
|
||||
ALONG_CONVEX = 0 ,
|
||||
ALONG_CONCAVE = 1 ,
|
||||
ACROSS = 2 ,
|
||||
NO_BASE_INTERS = 3
|
||||
} ;
|
||||
|
||||
enum CuttingSurface {
|
||||
NONE = -1,
|
||||
TOOL = 0 ,
|
||||
BZ = 1 ,
|
||||
LATERAL = 2
|
||||
} ;
|
||||
|
||||
private :
|
||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
||||
enum Shape { GENERIC = 0, BOX = 1, EXTRUSION = 2} ;
|
||||
enum Shape { GENERIC = 0, BOX = 1, EXTRUSION = 2, OFFSET = 3} ;
|
||||
static const int N_MAPS = 3 ;
|
||||
static const int N_VOXBLOCK = 32 ;
|
||||
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp[2] ; // vettore propriet� temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
bool m_bShowEdges ; // flag di visualizzazione spigoli vivi
|
||||
Frame3d m_MapFrame ; // riferimento intrinseco dello Zmap
|
||||
@@ -476,8 +593,8 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
mutable BOOLVECTOR m_BlockToUpdate ;
|
||||
mutable INTVECTOR m_BlockUpdatingCounter ;
|
||||
|
||||
int m_nConnectedCompoCount ; // Se == - 1 il numero di componenti non è noto
|
||||
// Se >= 0 è il numero di componenti connesse
|
||||
int m_nConnectedCompoCount ; // Se == - 1 il numero di componenti non � noto
|
||||
// Se >= 0 � il numero di componenti connesse
|
||||
|
||||
mutable std::vector<VoxelContainer> m_InterBlockVox ;
|
||||
mutable SharpTriaMatrix m_InterBlockOriginalSharpTria ;
|
||||
|
||||
+116
-20
@@ -17,6 +17,7 @@
|
||||
#include "CurveLine.h"
|
||||
#include "VolZmap.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkStmFromCurves.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include <future>
|
||||
@@ -597,6 +598,7 @@ VolZmap::CreateMapPart( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, co
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::AddMapPart( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, const Vector3d& vtLen, const Point3d& ptMapOrig,
|
||||
const ISurfTriMesh& Surf, IntersParLinesSurfTm& intPLSTM)
|
||||
@@ -691,7 +693,100 @@ VolZmap::AddMapPart( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex)
|
||||
VolZmap::SubtractMapPart( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, const Vector3d& vtLen, const Point3d& ptMapOrig,
|
||||
const ISurfTriMesh& Surf, IntersParLinesSurfTm& intPLSTM)
|
||||
{
|
||||
// controllo sui parametri
|
||||
if ( nMap < 0 || nMap > 2 ||
|
||||
nInfI < 0 || nInfI > m_nNx[nMap] ||
|
||||
nSupI < 0 || nSupI > m_nNx[nMap] ||
|
||||
nInfJ < 0 || nInfJ > m_nNy[nMap] ||
|
||||
nSupJ < 0 || nSupJ > m_nNy[nMap])
|
||||
return false ;
|
||||
|
||||
// determinazione e ridimensionamento dei dexel interni alla trimesh
|
||||
for ( int i = nInfI ; i < nSupI ; ++ i) {
|
||||
for ( int j = nInfJ ; j < nSupJ ; ++ j) {
|
||||
|
||||
// definisco la retta da intersecare con la trimesh
|
||||
double dX = ( i + 0.5) * m_dStep ;
|
||||
double dY = ( j + 0.5) * m_dStep ;
|
||||
Point3d ptP0( dX, dY, 0) ;
|
||||
|
||||
// intersezioni della retta con la TriMesh
|
||||
ILSIVECTOR IntersectionResults ;
|
||||
intPLSTM.GetInters( ptP0, vtLen.v[(nMap+2)%3], IntersectionResults) ;
|
||||
|
||||
// rimuovo le intersezioni in eccesso
|
||||
for ( int nI = 0 ; nI < int( IntersectionResults.size()) - 3 ; ++ nI) {
|
||||
int nJ = nI + 1 ; // prima successiva
|
||||
int nK = nJ + 1 ; // seconda successiva
|
||||
int nT = nK + 1 ; // terza successiva
|
||||
// determino i segni delle 4 intersezioni tra la linea e il trangolo della TriMesh
|
||||
int nSgnI = IntersectionResults[nI].dCosDN > EPS_SMALL ? 1 : IntersectionResults[nI].dCosDN > -EPS_SMALL ? 0 : - 1 ;
|
||||
int nSgnJ = IntersectionResults[nJ].dCosDN > EPS_SMALL ? 1 : IntersectionResults[nJ].dCosDN > -EPS_SMALL ? 0 : - 1 ;
|
||||
int nSgnK = IntersectionResults[nK].dCosDN > EPS_SMALL ? 1 : IntersectionResults[nK].dCosDN > -EPS_SMALL ? 0 : - 1 ;
|
||||
int nSgnT = IntersectionResults[nT].dCosDN > EPS_SMALL ? 1 : IntersectionResults[nT].dCosDN > -EPS_SMALL ? 0 : - 1 ;
|
||||
// parametri dell'intersezione sulla linea
|
||||
double dUJ = IntersectionResults[nJ].dU ;
|
||||
double dUK = IntersectionResults[nK].dU ;
|
||||
// controllo coerenza con segni...
|
||||
if ( nSgnI != 0 && nSgnI == nSgnJ &&
|
||||
nSgnK != 0 && nSgnK == nSgnT &&
|
||||
nSgnI == - nSgnT &&
|
||||
abs( dUJ - dUK) < EPS_SMALL) {
|
||||
// ... ed elimino le intersezioni in eccesso...
|
||||
IntersectionResults.erase( IntersectionResults.begin() + nK) ;
|
||||
IntersectionResults.erase( IntersectionResults.begin() + nJ) ;
|
||||
}
|
||||
}
|
||||
|
||||
int nInt = int( IntersectionResults.size()) ; // numero di intersezioni valide
|
||||
bool bInside = false ; // Flag entrata/uscita per tratto di retta
|
||||
Point3d ptIn ; Vector3d vtInN ;
|
||||
|
||||
// per ogni intersezione valida trovata...
|
||||
for ( int k = 0 ; k < nInt ; ++ k) {
|
||||
// ricavo il tipo di intersezione
|
||||
int nIntType = IntersectionResults[k].nILTT ;
|
||||
// se c'è intersezione
|
||||
if ( nIntType != ILTT_NO) {
|
||||
// ricavo il cos tra i vettori ( normale del triangolo e tangente alla retta)
|
||||
double dCos = IntersectionResults[k].dCosDN ;
|
||||
|
||||
// se entro nella superficie trimesh...
|
||||
if ( dCos < - EPS_SMALL) {
|
||||
ptIn = IntersectionResults[k].ptI ; // punto di intersezione
|
||||
int nT = IntersectionResults[k].nT ; // triangolo di interesse
|
||||
int nF = Surf.GetFacetFromTria( nT) ; // faccia di interesse
|
||||
Surf.GetFacetNormal( nF, vtInN) ;
|
||||
bInside = true ; // entrata
|
||||
}
|
||||
// ...se esco dalla superficie trimesh ( prima sono per forza entrato)
|
||||
else if ( dCos > EPS_SMALL && bInside) {
|
||||
Point3d ptOut = IntersectionResults[k].ptI ; // punto di intersezione
|
||||
int nT = IntersectionResults[k].nT ; // triangolo di interesse
|
||||
int nF = Surf.GetFacetFromTria( nT) ; // faccia di interesse
|
||||
Vector3d vtOutN ; Surf.GetFacetNormal( nF, vtOutN) ; // vettore d'uscita
|
||||
|
||||
// Aggiungo un tratto al dexel
|
||||
SubtractIntervals( nMap, i, j,
|
||||
ptIn.v[(nMap+2)%3] - ptMapOrig.v[(nMap+2)%3],
|
||||
ptOut.v[(nMap+2)%3] - ptMapOrig.v[(nMap+2)%3],
|
||||
- vtInN, - vtOutN, 0, true) ;
|
||||
bInside = false ; // uscita
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex, double dExtraBox)
|
||||
{
|
||||
// Se la superficie non è chiusa oppure orientata al contrario non ha senso continuare
|
||||
double dVol ;
|
||||
@@ -704,14 +799,15 @@ VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex
|
||||
// Determino il bounding box della TriMesh
|
||||
BBox3d SurfBBox ;
|
||||
Surf.GetLocalBBox( SurfBBox) ;
|
||||
|
||||
// Determino i punti estremi del bounding box
|
||||
Point3d ptMapOrig, ptMapEnd ;
|
||||
SurfBBox.GetMinMax( ptMapOrig, ptMapEnd) ;
|
||||
|
||||
// Il dexel se parte da un triangolo della trimesh può non trovare l'intersezione,
|
||||
// quindi espandiamo il bounding box per ovviare al problema.
|
||||
SurfBBox.Expand( 100 * EPS_SMALL, 100 * EPS_SMALL, 100 * EPS_SMALL) ;
|
||||
if ( dExtraBox > EPS_ZERO)
|
||||
SurfBBox.Expand( dExtraBox) ;
|
||||
|
||||
// Determino i punti estremi del bounding box
|
||||
Point3d ptMapOrig, ptMapEnd ;
|
||||
SurfBBox.GetMinMax( ptMapOrig, ptMapEnd) ;
|
||||
|
||||
// Sistema di riferimento intrinseco dello Zmap
|
||||
m_MapFrame.Set( ptMapOrig, Frame3d::TOP) ;
|
||||
@@ -760,15 +856,15 @@ VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex
|
||||
|
||||
// ciclo sulle griglie
|
||||
bool bCompleted = true ;
|
||||
for ( int g = 0 ; g < m_nMapNum ; ++ g) {
|
||||
for ( int nG = 0 ; nG < m_nMapNum ; ++ nG) {
|
||||
|
||||
// Definisco dei sistemi di riferimento ausiliari
|
||||
Frame3d frMapFrame ;
|
||||
if ( g == 0)
|
||||
if ( nG == 0)
|
||||
frMapFrame = m_MapFrame ;
|
||||
else if ( g == 1)
|
||||
else if ( nG == 1)
|
||||
frMapFrame.Set( ptMapOrig, Y_AX, Z_AX, X_AX) ;
|
||||
else if ( g == 2)
|
||||
else if ( nG == 2)
|
||||
frMapFrame.Set( ptMapOrig, Z_AX, X_AX, Y_AX) ;
|
||||
|
||||
// Oggetto per calcolo massivo intersezioni
|
||||
@@ -778,28 +874,28 @@ VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex
|
||||
int nThreadMax = max( 1, int( thread::hardware_concurrency()) - 1) ;
|
||||
vector< future<bool>> vRes ;
|
||||
vRes.resize( nThreadMax) ;
|
||||
if ( m_nNx[g] > m_nNy[g]) {
|
||||
int nDexNum = m_nNx[g] / nThreadMax ;
|
||||
int nRemainder = m_nNx[g] % nThreadMax ;
|
||||
if ( m_nNx[nG] > m_nNy[nG]) {
|
||||
int nDexNum = m_nNx[nG] / nThreadMax ;
|
||||
int nRemainder = m_nNx[nG] % nThreadMax ;
|
||||
int nInfI = 0 ;
|
||||
int nSupI = 0 ;
|
||||
for ( int nThread = 0 ; nThread < nThreadMax ; ++ nThread) {
|
||||
nInfI = nSupI ;
|
||||
nSupI = nInfI + ( nThread < nRemainder ? nDexNum + 1 : nDexNum) ;
|
||||
vRes[nThread] = async( launch::async, &VolZmap::CreateMapPart, this, g,
|
||||
nInfI, nSupI, 0, m_nNy[g], ref( vtLen), ref( ptMapOrig), ref( Surf), ref( intPLSTM)) ;
|
||||
vRes[nThread] = async( launch::async, &VolZmap::CreateMapPart, this, nG,
|
||||
nInfI, nSupI, 0, m_nNy[nG], ref( vtLen), ref( ptMapOrig), ref( Surf), ref( intPLSTM)) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
int nDexNum = m_nNy[g] / nThreadMax ;
|
||||
int nRemainder = m_nNy[g] % nThreadMax ;
|
||||
int nDexNum = m_nNy[nG] / nThreadMax ;
|
||||
int nRemainder = m_nNy[nG] % nThreadMax ;
|
||||
int nInfJ = 0 ;
|
||||
int nSupJ = 0 ;
|
||||
for ( int nThread = 0 ; nThread < nThreadMax ; ++ nThread) {
|
||||
nInfJ = nSupJ ;
|
||||
nSupJ = nInfJ + ( nThread < nRemainder ? nDexNum + 1 : nDexNum) ;
|
||||
vRes[nThread] = async( launch::async, &VolZmap::CreateMapPart, this, g,
|
||||
0, m_nNx[g], nInfJ, nSupJ, ref( vtLen), ref( ptMapOrig), ref( Surf),ref( intPLSTM)) ;
|
||||
vRes[nThread] = async( launch::async, &VolZmap::CreateMapPart, this, nG,
|
||||
0, m_nNx[nG], nInfJ, nSupJ, ref( vtLen), ref( ptMapOrig), ref( Surf),ref( intPLSTM)) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -825,7 +921,7 @@ VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex
|
||||
m_dMaxZ[2] = ( bTriDex ? vtLen.y : 0) ;
|
||||
|
||||
// Tipologia
|
||||
m_nShape = ( IsBox() ? BOX : GENERIC) ;
|
||||
m_nShape = ( dExtraBox > EPS_ZERO && IsBox() ? BOX : GENERIC) ;
|
||||
|
||||
// Aggiornamento dello stato
|
||||
m_nStatus = OK ;
|
||||
|
||||
+31
-1
@@ -19,6 +19,7 @@
|
||||
#include "MC_Tables.h"
|
||||
#include "PolygonPlane.h"
|
||||
#include "IntersLineBox.h"
|
||||
#include "SurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkChainCurves.h"
|
||||
@@ -571,6 +572,35 @@ VolZmap::GetBlockTriangles( int nBlock, TRIA3DEXVECTOR& vTria) const
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ISurfTriMesh*
|
||||
VolZmap::GetSurfTriMesh( void) const
|
||||
{
|
||||
// controllo che lo Zmap sia valido
|
||||
if ( ! IsValid())
|
||||
return nullptr ;
|
||||
|
||||
// inizializzo la superficie
|
||||
PtrOwner<SurfTriMesh> pStm( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pStm) || ! pStm->Init( 3, 1))
|
||||
return nullptr ;
|
||||
PointGrid3d VertGrid ; VertGrid.Init( 50000) ;
|
||||
|
||||
// ciclo lungo i blocchi dello Zmap
|
||||
for ( int nB = 0 ; nB < GetBlockCount() ; ++ nB) {
|
||||
TRIA3DEXVECTOR vTria ;
|
||||
GetBlockTriangles( nB, vTria) ;
|
||||
if ( ! pStm->AddTriaFromZMap( vTria, VertGrid))
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
// sistemo la topologia
|
||||
if ( ! pStm->AdjustTopologyFromZMap())
|
||||
return nullptr ;
|
||||
|
||||
return ( Release( pStm)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
VolZmap::GetBlockCount( void) const
|
||||
@@ -1142,7 +1172,7 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
|
||||
}
|
||||
|
||||
// Controllo se il voxel ha una sola faccia che giace in un piano canonico e quindi ha gestione speciale
|
||||
if ( m_nShape != BOX) {
|
||||
if ( m_nShape != BOX && m_nShape != OFFSET) {
|
||||
// Faccia XY normale Z+
|
||||
if ( nIndex == 15) {
|
||||
int nTool ; double dPos ;
|
||||
|
||||
@@ -0,0 +1,568 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2025-2025
|
||||
//----------------------------------------------------------------------------
|
||||
// File : OffsetSurfTm.cpp Data : 09.06.25 Versione : 2.7e3
|
||||
// Contenuto : Dichiarazione della funzione per calcolare l'offset di superfici TriMesh
|
||||
// mediante Zmap
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 09.06.25 RE Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "VolZmap.h"
|
||||
#include "CurveLine.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkStmFromCurves.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include <future>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Funzione per sottrarre intervalli lungo un Dexel per l'offset di una superficie TriMesh
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::SubtractIntervalsForOffset( int nGrid, int nI, int nJ,
|
||||
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax,
|
||||
int nToolNum, bool bSkipSwap)
|
||||
{
|
||||
// TODO -- Aggiustare eventuali tolleranze
|
||||
return SubtractIntervals( nGrid, nI, nJ, dMin, dMax, vtNMin, vtNMax, nToolNum, bSkipSwap) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Funzione per aggiungere intervalli lungo un Dexel per l'offset di una superficie TriMesh
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::AddIntervalsForOffset( int nGrid, int nI, int nJ,
|
||||
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax,
|
||||
int nToolNum, bool bSkipSwap)
|
||||
{
|
||||
// TODO -- Aggiustare eventuali tolleranze
|
||||
return AddIntervals( nGrid, nI, nJ, dMin, dMax, vtNMin, vtNMax, nToolNum, bSkipSwap) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Funzione per la creazione di una sfera di Offset centrata sul vertice di una TriMesh con cui
|
||||
// aggiungere o sottrarre intervalli lungo i Dexel coinvolti
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::CreateOffsSphereOnVertex( const Point3d& ptV, double dOffs, int nGrid, int nTool)
|
||||
{
|
||||
// determino il Box della sfera posizionata su tale vertice
|
||||
BBox3d BBoxSphere( ptV - dOffs * Vector3d( 1., 1., 1.),
|
||||
ptV + dOffs * Vector3d( 1., 1., 1.)) ;
|
||||
// determino gli intervalli di interesse mediante intersezione con Box della sfera
|
||||
int nStartI = max( 0, int( BBoxSphere.GetMin().x / m_dStep)) ;
|
||||
int nEndI = min( m_nNx[nGrid] - 1, int( BBoxSphere.GetMax().x / m_dStep)) ;
|
||||
int nStartJ = max( 0, int( BBoxSphere.GetMin().y / m_dStep)) ;
|
||||
int nEndJ = min( m_nNy[nGrid] - 1, int( BBoxSphere.GetMax().y / m_dStep)) ;
|
||||
// aggiorno gli spilloni interessati
|
||||
double dSqRad = dOffs * dOffs ;
|
||||
for ( int i = nStartI ; i <= nEndI ; ++ i) {
|
||||
for ( int j = nStartJ ; j <= nEndJ ; ++ j) {
|
||||
double dX = ( i + 0.5) * m_dStep ;
|
||||
double dY = ( j + 0.5) * m_dStep ;
|
||||
Point3d ptC( dX, dY, 0.) ;
|
||||
double dStSqDXY = SqDistXY( ptC, ptV) ;
|
||||
if ( dStSqDXY < dSqRad) {
|
||||
double dMin = ptV.z - sqrt( dSqRad - dStSqDXY) ;
|
||||
Vector3d vtNmin = Point3d( dX, dY, dMin) - ptV ;
|
||||
vtNmin.Normalize() ;
|
||||
double dMax = ptV.z + sqrt( dSqRad - dStSqDXY) ;
|
||||
Vector3d vtNmax = Point3d( dX, dY, dMax) - ptV ;
|
||||
vtNmax.Normalize() ;
|
||||
if ( dOffs > 0.)
|
||||
AddIntervalsForOffset( nGrid, i, j, dMin, dMax, vtNmin, vtNmax, nTool) ;
|
||||
else
|
||||
SubtractIntervalsForOffset( nGrid, i, j, dMin, dMax, -vtNmin, -vtNmax, nTool) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Funzione per la creazione di un cilindro di Offset sul vertice di una TriMesh con cui
|
||||
// aggiungere o sottrarre intervalli lungo i Dexel coinvolti.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::CreateOffsCylinderOnEdge( const Point3d& ptP1, const Point3d& ptP2, double dOffs, int nGrid,
|
||||
int nTool)
|
||||
{
|
||||
// determino la lunghezza dello spigolo corrente
|
||||
double dH = Dist( ptP1, ptP2) ;
|
||||
// asse del cilindro
|
||||
Vector3d vtV = ptP2 - ptP1 ; vtV.Normalize() ;
|
||||
// calcolo box del cilindro
|
||||
BBox3d BBoxCylinder ;
|
||||
BBoxCylinder.Add( ptP1) ;
|
||||
BBoxCylinder.Add( ptP2) ;
|
||||
if ( AreSameOrOppositeVectorApprox( vtV, X_AX))
|
||||
BBoxCylinder.Expand( 0., abs( dOffs), abs( dOffs)) ;
|
||||
else if ( AreSameOrOppositeVectorApprox( vtV, Y_AX))
|
||||
BBoxCylinder.Expand( abs( dOffs), 0., abs( dOffs)) ;
|
||||
else if ( AreSameOrOppositeVectorApprox( vtV, Z_AX))
|
||||
BBoxCylinder.Expand( abs( dOffs), abs( dOffs), 0.) ;
|
||||
else {
|
||||
double dExpandX = abs( dOffs) * sqrt( 1 - vtV.x * vtV.x) ;
|
||||
double dExpandY = abs( dOffs) * sqrt( 1 - vtV.y * vtV.y) ;
|
||||
double dExpandZ = abs( dOffs) * sqrt( 1 - vtV.z * vtV.z) ;
|
||||
BBoxCylinder.Expand( dExpandX, dExpandY, dExpandZ) ;
|
||||
}
|
||||
// determino gli intervalli di interesse mediante intersezione
|
||||
int nStartI = max( 0, int( BBoxCylinder.GetMin().x / m_dStep)) ;
|
||||
int nEndI = min( m_nNx[nGrid] - 1, int( BBoxCylinder.GetMax().x / m_dStep)) ;
|
||||
int nStartJ = max( 0, int( BBoxCylinder.GetMin().y / m_dStep)) ;
|
||||
int nEndJ = min( m_nNy[nGrid] - 1, int( BBoxCylinder.GetMax().y / m_dStep)) ;
|
||||
// aggiorno gli spilloni interessati
|
||||
Frame3d CylFrame ;
|
||||
if ( ! CylFrame.Set( ptP1, vtV))
|
||||
return false ;
|
||||
for ( int i = nStartI ; i <= nEndI ; ++ i) {
|
||||
for ( int j = nStartJ ; j <= nEndJ ; ++ j) {
|
||||
Point3d ptC( ( i + 0.5) * m_dStep, ( j + 0.5) * m_dStep, 0) ;
|
||||
Point3d ptInt1, ptInt2 ;
|
||||
Vector3d vtN1, vtN2 ;
|
||||
if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dH, abs( dOffs), true, true,
|
||||
ptInt1, vtN1, ptInt2, vtN2)) {
|
||||
if ( dOffs > 0.)
|
||||
AddIntervalsForOffset( nGrid, i, j, ptInt1.z, ptInt2.z, -vtN1, -vtN2, nTool) ;
|
||||
else
|
||||
SubtractIntervalsForOffset( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nTool) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Funzione per inizializzare lo ZMap a partire da un vettore di superfici TriMesh
|
||||
// L'idea è quella di creare uno ZMap a partire dal Box complessivo delle superfici TriMesh :
|
||||
// - le superfici chiuse possono già inserire i rispettivi spilloni
|
||||
// - le superfici aperte non danno contributo
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::InitVolZMapOffs( const CISURFTMPVECTOR& vSurf, double dOffs, double dTol)
|
||||
{
|
||||
// se non ho superfici, non faccio nulla
|
||||
if ( vSurf.empty())
|
||||
return true ;
|
||||
// controllo delle superfici
|
||||
for ( const ISurfTriMesh* Surf : vSurf) {
|
||||
if ( Surf == nullptr)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// definisco la tolleranza di espansione del Box per la creazione dellop ZMap
|
||||
double dBoxExpansion = ( abs( dOffs) + 1.5 * dTol) + 10 * EPS_SMALL ;
|
||||
|
||||
// --- se una sola superficie
|
||||
if ( int( vSurf.size()) == 1) {
|
||||
// controllo la validità della superficie
|
||||
if ( ! vSurf[0]->IsValid() || vSurf[0]->GetTriangleCount() == 0)
|
||||
return true ;
|
||||
// --- se superficie chiusa posso direttamente creare lo Zmap iniziale
|
||||
if ( vSurf[0]->IsClosed()) {
|
||||
// definisco lo Zamp a partire dall'espansione del Box della superficie
|
||||
if ( ! CreateFromTriMesh( *vSurf[0], dTol, true, dBoxExpansion))
|
||||
return false ;
|
||||
}
|
||||
// --- se superficie aperta, lo creo inizialmente vuoto a partire dal suo Box
|
||||
BBox3d BBoxSurf ;
|
||||
vSurf[0]->GetLocalBBox( BBoxSurf) ;
|
||||
BBoxSurf.Expand( dBoxExpansion) ;
|
||||
if ( ! CreateEmpty( BBoxSurf.GetMin(), BBoxSurf.GetDimX(), BBoxSurf.GetDimY(), BBoxSurf.GetDimZ(), dTol, true))
|
||||
return false ;
|
||||
}
|
||||
// --- se più superfici
|
||||
else {
|
||||
// calcolo il Box complessivo
|
||||
BBox3d BBoxGlob ;
|
||||
for ( const ISurfTriMesh* Surf : vSurf) {
|
||||
// controllo la validità della superficie
|
||||
if ( ! Surf->IsValid() || Surf->GetTriangleCount() == 0)
|
||||
continue ;
|
||||
// calcolo il Box della superficie
|
||||
BBox3d BBoxSurf ; Surf->GetLocalBBox( BBoxSurf) ;
|
||||
// aggiungo il Box a quello complessivo
|
||||
BBoxGlob.Add( BBoxSurf) ;
|
||||
}
|
||||
// definisco uno Zmap vuoto a partire dal Box
|
||||
BBoxGlob.Expand( dBoxExpansion) ;
|
||||
if ( ! CreateEmpty( BBoxGlob.GetMin(), BBoxGlob.GetDimX(), BBoxGlob.GetDimY(), BBoxGlob.GetDimZ(), dTol, true))
|
||||
return false ;
|
||||
// aggiungo tutte le superfici chiuse
|
||||
for ( const ISurfTriMesh* Surf : vSurf) {
|
||||
if ( ! Surf->IsValid() || Surf->GetTriangleCount() == 0 || ! Surf->IsClosed())
|
||||
continue ;
|
||||
if ( ! AddSurfTm( Surf))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Funzione per inizializzare lo ZMap a partire da un vettore di superfici TriMesh
|
||||
// L'idea è quella di creare uno ZMap vuoto a partire dal Box complessivo delle superfici TriMesh
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::InitVolZMapThickeningOffs( const CISURFTMPVECTOR& vSurf, double dOffs, double dTol)
|
||||
{
|
||||
// se non ho superfici, non faccio nulla
|
||||
if ( vSurf.empty())
|
||||
return true ;
|
||||
// controllo delle superfici
|
||||
for ( const ISurfTriMesh* Surf : vSurf) {
|
||||
if ( Surf == nullptr)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// definisco la tolleranza di espansione del Box per la creazione dellop ZMap
|
||||
double dBoxExpansion = ( abs( dOffs) + 1.5 * dTol) + 10 * EPS_SMALL ;
|
||||
|
||||
// calcolo il Box complessivo
|
||||
BBox3d BBoxGlob ;
|
||||
for ( const ISurfTriMesh* Surf : vSurf) {
|
||||
// controllo la validità della superficie
|
||||
if ( ! Surf->IsValid() || Surf->GetTriangleCount() == 0)
|
||||
continue ;
|
||||
// calcolo il Box della superficie
|
||||
BBox3d BBoxSurf ; Surf->GetLocalBBox( BBoxSurf) ;
|
||||
// aggiungo il Box a quello complessivo
|
||||
BBoxGlob.Add( BBoxSurf) ;
|
||||
}
|
||||
// definisco uno Zmap vuoto a partire dal Box
|
||||
BBoxGlob.Expand( dBoxExpansion) ;
|
||||
return ( CreateEmpty( BBoxGlob.GetMin(), BBoxGlob.GetDimX(), BBoxGlob.GetDimY(), BBoxGlob.GetDimZ(), dTol, true)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// [Fillet] Funzione per aggiornare mediante Sfere, Cilindri e Facce di estrusione lo ZMap corrente
|
||||
// mediante una superficie aperta
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::UpdateVolZMapByOpenSurfFilletOffset( const ISurfTriMesh* Surf, double dOffs, double dTol)
|
||||
{
|
||||
// da studiare...
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// [Fillet] Funzione per aggiornare mediante Sfere, Cilindri e Facce di estrusione lo ZMap corrente
|
||||
// mediante una superficie chiusa
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::UpdateVolZMapByClosedSurfFilletOffset( const ISurfTriMesh* Surf, double dOffs, double dTol)
|
||||
{
|
||||
// controlli sulla superficie
|
||||
if ( Surf == nullptr || ! Surf->IsClosed())
|
||||
return false ;
|
||||
if ( ! Surf->IsValid() || Surf->GetTriangleCount() == 0)
|
||||
return true ;
|
||||
|
||||
// Assunzioni :
|
||||
// - Idea Generale di Offset
|
||||
// - Su ogni vertice viene definita una sfera ( con raggio pari al valore di Offset e
|
||||
// centro il vertice corrente)
|
||||
// - Su ogni lato viene definito un cilindro ( con raggio di base pari al valore di Offset
|
||||
// e asse definito dall'edge stesso)
|
||||
// - Su ogni faccia viene definita una superficie di estrusione ( dove le due basi sono
|
||||
// definite dalla traslazione sia in positivo che in negativo della faccia lungo la sua normale)
|
||||
//
|
||||
// - Segno dell'Offset :
|
||||
// - Positivo ( si sommano gli intervalli corrisipondenti alle entità create)
|
||||
// - Negativo ( si sottraggono gli intervalli corrispondenti alle enetità create)
|
||||
//
|
||||
// - Semplificazione entità :
|
||||
// La creazione di Sfere e Cilindri potrebbe essere resa più "corretta" definitendo solo
|
||||
// "spicchi 3d" di sfera e "spicchi 3d" di cilindri. Dato che le operazioni di somma, sottrazioni e
|
||||
// calcolo delle normali per gli spilloni sono elementari su queste figure, si rischia di appesantire
|
||||
// troppo i conti introducendo variabili angolari che non sommando tutte le parti.
|
||||
//
|
||||
|
||||
// definisco vettore di frame Locali alle 3 griglie
|
||||
FRAME3DVECTOR vFrGrid( 4) ;
|
||||
vFrGrid[0].Set( ORIG, X_AX, Y_AX, Z_AX) ;
|
||||
vFrGrid[1].Set( m_MapFrame.Orig(), m_MapFrame.VersX(), m_MapFrame.VersY(), m_MapFrame.VersZ()) ;
|
||||
vFrGrid[2].Set( m_MapFrame.Orig(), m_MapFrame.VersY(), m_MapFrame.VersZ(), m_MapFrame.VersX()) ;
|
||||
vFrGrid[3].Set( m_MapFrame.Orig(), m_MapFrame.VersZ(), m_MapFrame.VersX(), m_MapFrame.VersY()) ;
|
||||
|
||||
// definisco una mappa dei vertici, in modo da sapere su quali sono state già create le sfere
|
||||
BOOLVECTOR vbVert( Surf->GetVertexCount(), false) ;
|
||||
// ----------------------- Cilindri e Sfere -----------------------
|
||||
// scorro gli Edge della superficie
|
||||
for ( int nE = 0 ; nE < Surf->GetEdgeCount() ; ++ nE) {
|
||||
// recupero lo spigolo
|
||||
int nV1, nV2, nF1, nF2 ; double dAng ;
|
||||
Surf->GetEdge( nE, nV1, nV2, nF1, nF2, dAng) ;
|
||||
// controllo se il cilindro serve
|
||||
// NB. la mancata creazione del cilindro comporta la mancata creazione delle sfere sui suoi vertici
|
||||
// durante questa iterazione; non significa che questa sfera non verrà mai creata...
|
||||
// Non esiste la sfera sul vertive V <=> non esiste alcun cilindro su tutti gli edge concorrenti
|
||||
if ( dAng * dOffs < 0)
|
||||
continue ;
|
||||
// recupero le coordinate dei vertici
|
||||
Point3d ptP1 ; Surf->GetVertex( nV1, ptP1) ;
|
||||
Point3d ptP2 ; Surf->GetVertex( nV2, ptP2) ;
|
||||
// ciclo sulle griglie
|
||||
for ( int nGrid = 0 ; nGrid < 3 ; ++ nGrid) {
|
||||
// esprimo gli estremi nel riferimento della griglia
|
||||
ptP1.LocToLoc( vFrGrid[nGrid], vFrGrid[nGrid + 1]) ;
|
||||
ptP2.LocToLoc( vFrGrid[nGrid], vFrGrid[nGrid + 1]) ;
|
||||
// aggiungo/sottraggo gli intervalli definiti dal cilindro
|
||||
if ( ! CreateOffsCylinderOnEdge( ptP1, ptP2, dOffs, nGrid))
|
||||
return false ;
|
||||
// aggiungo/sottraggo gli intervalli definiti dalla sfera
|
||||
if ( ! vbVert[nV1]) {
|
||||
if ( ! CreateOffsSphereOnVertex( ptP1, dOffs, nGrid))
|
||||
return false ;
|
||||
}
|
||||
if ( ! vbVert[nV2]) {
|
||||
if ( ! CreateOffsSphereOnVertex( ptP2, dOffs, nGrid))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
vbVert[nV1] = true ;
|
||||
vbVert[nV2] = true ;
|
||||
}
|
||||
// ----------------------- Facce -----------------------
|
||||
// scorro tutte le facce definendo una superficie di estrusione
|
||||
for ( int nF = 0 ; nF < Surf->GetFacetCount() ; ++ nF) {
|
||||
// recupero lo faccia
|
||||
POLYLINEVECTOR vPL ; Surf->GetFacetLoops( nF, vPL) ;
|
||||
// recupero la normale della faccia
|
||||
Vector3d vtN ; Surf->GetFacetNormal( nF, vtN) ;
|
||||
// definisco la superficie di estrusione
|
||||
CICURVEPVECTOR vpCrvs ; vpCrvs.reserve( vPL.size()) ;
|
||||
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
|
||||
vPL[i].Translate( - abs( dOffs) * vtN) ;
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo) || ! pCrvCompo->FromPolyLine( vPL[i])) {
|
||||
// dealloco le curve
|
||||
for ( int i = 0 ; i < int( vpCrvs.size()) ; ++ i) {
|
||||
delete ( vpCrvs[i]) ;
|
||||
vpCrvs[i] = nullptr ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
vpCrvs.emplace_back( Release( pCrvCompo)) ;
|
||||
}
|
||||
// recupero la TriMesh di estrusione
|
||||
PtrOwner<ISurfTriMesh> pStmExtr( GetSurfTriMeshByRegionExtrusion( vpCrvs, 2 * abs( dOffs) * vtN)) ;
|
||||
if ( IsNull( pStmExtr) || ! pStmExtr->IsValid() || pStmExtr->GetTriangleCount() == 0) {
|
||||
// dealloco le curve
|
||||
for ( int i = 0 ; i < int( vpCrvs.size()) ; ++ i) {
|
||||
delete ( vpCrvs[i]) ;
|
||||
vpCrvs[i] = nullptr ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
// aggiorno gli spilloni
|
||||
if ( dOffs > 0.)
|
||||
AddSurfTm( pStmExtr) ;
|
||||
else
|
||||
SubtractSurfTm( pStmExtr) ;
|
||||
// dealloco le curve
|
||||
for ( int i = 0 ; i < int( vpCrvs.size()) ; ++ i) {
|
||||
delete ( vpCrvs[i]) ;
|
||||
vpCrvs[i] = nullptr ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// [Fillet Thickening] Funzione per aggiornare mediante Sfere, Cilindri e Facce di estrusione lo ZMap corrente
|
||||
// mediante una superficie generica (aperta o chiusa)
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::UpdateVolZMapBySurfThickeningFilletOffset( const ISurfTriMesh* Surf, double dOffs, double dTol)
|
||||
{
|
||||
// controlli sulla superficie
|
||||
if ( Surf == nullptr)
|
||||
return false ;
|
||||
if ( ! Surf->IsValid() || Surf->GetTriangleCount() == 0)
|
||||
return true ;
|
||||
|
||||
// non inizializzo lo Zmap, semplicemente lavoro con facce, spigoli e vertici
|
||||
|
||||
// definisco vettore di frame Locali alle 3 griglie
|
||||
FRAME3DVECTOR vFrGrid( 4) ;
|
||||
vFrGrid[0].Set( ORIG, X_AX, Y_AX, Z_AX) ;
|
||||
vFrGrid[1].Set( m_MapFrame.Orig(), m_MapFrame.VersX(), m_MapFrame.VersY(), m_MapFrame.VersZ()) ;
|
||||
vFrGrid[2].Set( m_MapFrame.Orig(), m_MapFrame.VersY(), m_MapFrame.VersZ(), m_MapFrame.VersX()) ;
|
||||
vFrGrid[3].Set( m_MapFrame.Orig(), m_MapFrame.VersZ(), m_MapFrame.VersX(), m_MapFrame.VersY()) ;
|
||||
|
||||
// definisco una mappa dei vertici, in modo da sapere su quali sono state già create le sfere
|
||||
BOOLVECTOR vbVert( Surf->GetVertexCount(), false) ;
|
||||
// ----------------------- Cilindri e Sfere -----------------------
|
||||
// scorro gli Edge della superficie
|
||||
for ( int nE = 0 ; nE < Surf->GetEdgeCount() ; ++ nE) {
|
||||
// recupero lo spigolo
|
||||
int nV1, nV2, nF1, nF2 ; double dAng ;
|
||||
Surf->GetEdge( nE, nV1, nV2, nF1, nF2, dAng) ;
|
||||
// recupero le coordinate dei vertici
|
||||
Point3d ptP1 ; Surf->GetVertex( nV1, ptP1) ;
|
||||
Point3d ptP2 ; Surf->GetVertex( nV2, ptP2) ;
|
||||
// ciclo sulle griglie
|
||||
for ( int nGrid = 0 ; nGrid < 3 ; ++ nGrid) {
|
||||
// esprimo gli estremi nel riferimento della griglia
|
||||
ptP1.LocToLoc( vFrGrid[nGrid], vFrGrid[nGrid + 1]) ;
|
||||
ptP2.LocToLoc( vFrGrid[nGrid], vFrGrid[nGrid + 1]) ;
|
||||
// aggiungo/sottraggo gli intervalli definiti dal cilindro
|
||||
if ( ! CreateOffsCylinderOnEdge( ptP1, ptP2, abs( dOffs), nGrid))
|
||||
return false ;
|
||||
// aggiungo/sottraggo gli intervalli definiti dalla sfera
|
||||
if ( ! vbVert[nV1]) {
|
||||
if ( ! CreateOffsSphereOnVertex( ptP1, abs( dOffs), nGrid))
|
||||
return false ;
|
||||
}
|
||||
if ( ! vbVert[nV2]) {
|
||||
if ( ! CreateOffsSphereOnVertex( ptP2, abs( dOffs), nGrid))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
vbVert[nV1] = true ;
|
||||
vbVert[nV2] = true ;
|
||||
}
|
||||
// ----------------------- Facce -----------------------
|
||||
// scorro tutte le facce definendo una superficie di estrusione
|
||||
for ( int nF = 0 ; nF < Surf->GetFacetCount() ; ++ nF) {
|
||||
// recupero lo faccia
|
||||
POLYLINEVECTOR vPL ; Surf->GetFacetLoops( nF, vPL) ;
|
||||
// recupero la normale della faccia
|
||||
Vector3d vtN ; Surf->GetFacetNormal( nF, vtN) ;
|
||||
// definisco la superficie di estrusione
|
||||
CICURVEPVECTOR vpCrvs ; vpCrvs.reserve( vPL.size()) ;
|
||||
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
|
||||
vPL[i].Translate( - abs( dOffs) * vtN) ;
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo) || ! pCrvCompo->FromPolyLine( vPL[i])) {
|
||||
// dealloco le curve
|
||||
for ( int i = 0 ; i < int( vpCrvs.size()) ; ++ i) {
|
||||
delete ( vpCrvs[i]) ;
|
||||
vpCrvs[i] = nullptr ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
vpCrvs.emplace_back( Release( pCrvCompo)) ;
|
||||
}
|
||||
// recupero la TriMesh di estrusione
|
||||
PtrOwner<ISurfTriMesh> pStmExtr( GetSurfTriMeshByRegionExtrusion( vpCrvs, 2 * abs( dOffs) * vtN)) ;
|
||||
if ( IsNull( pStmExtr) || ! pStmExtr->IsValid() || pStmExtr->GetTriangleCount() == 0) {
|
||||
// dealloco le curve
|
||||
for ( int i = 0 ; i < int( vpCrvs.size()) ; ++ i) {
|
||||
delete ( vpCrvs[i]) ;
|
||||
vpCrvs[i] = nullptr ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
// aggiorno gli spilloni
|
||||
AddSurfTm( pStmExtr) ;
|
||||
// dealloco le curve
|
||||
for ( int i = 0 ; i < int( vpCrvs.size()) ; ++ i) {
|
||||
delete ( vpCrvs[i]) ;
|
||||
vpCrvs[i] = nullptr ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Funzione per la creazine di uno Zmap di Offset (positivo o negativo) a partire da un
|
||||
// vettore di superfici TriMesh (aperte o chiuse).
|
||||
// Definizione :
|
||||
// - Lo Zmap di Offset ( positivo o negativo) di una superficie chiusa è automaticamente l'Offset stesso
|
||||
// - Lo Zmap di Offset ( positivo o negativo) di una superficie aperta è ????? ( da capire...)
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::CreateFromTriMeshOffset( const CISURFTMPVECTOR& vSurf, double dOffs, double dTol, int nType)
|
||||
{
|
||||
// controllo delle superfici
|
||||
for ( const ISurfTriMesh* Surf : vSurf) {
|
||||
if ( Surf == nullptr)
|
||||
return false ;
|
||||
}
|
||||
// verifica sul parametro di Offset ( coerente con Curve e FlatRegion)
|
||||
if ( abs( dOffs) < 10 * EPS_SMALL)
|
||||
return true ;
|
||||
// se non ho superfici, non faccio nulla
|
||||
if ( vSurf.empty())
|
||||
return true ;
|
||||
|
||||
// inizializzo lo Zmap di Offset a partire dalle superfici
|
||||
if ( ! InitVolZMapOffs( vSurf, dOffs, dTol))
|
||||
return false ;
|
||||
|
||||
// scorro le superfici
|
||||
for ( const ISurfTriMesh* Surf : vSurf) {
|
||||
// se superficie non valida, passo alla successiva
|
||||
if ( ! Surf->IsValid() || Surf->GetTriangleCount() == 0)
|
||||
continue ;
|
||||
// aggiorno lo ZMap
|
||||
if ( Surf->IsClosed()) {
|
||||
if ( nType == STMOFF_FILLET) {
|
||||
if ( ! UpdateVolZMapByClosedSurfFilletOffset( Surf, dOffs, dTol))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// --- LE SUPERFICI APERTE SONO PER ORA DISABILITATE ---
|
||||
}
|
||||
}
|
||||
|
||||
m_nShape = OFFSET ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Funzione per la creazine di uno Zmap di Fat Offset a partire da un
|
||||
// vettore di superfici TriMesh (aperte o chiuse).
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::CreateFromTriMeshThickeningOffset( const CISURFTMPVECTOR& vSurf, double dOffs, double dTol, int nType)
|
||||
{
|
||||
// controllo delle superfici
|
||||
for ( const ISurfTriMesh* Surf : vSurf) {
|
||||
if ( Surf == nullptr)
|
||||
return false ;
|
||||
}
|
||||
// verifica sul parametro di Offset ( coerente con Curve e FlatRegion)
|
||||
if ( abs( dOffs) < 10 * EPS_SMALL)
|
||||
return true ;
|
||||
// se non ho superfici, non faccio nulla
|
||||
if ( vSurf.empty())
|
||||
return true ;
|
||||
|
||||
// inizializzo lo Zmap di Offset a partire dalle superfici
|
||||
if ( ! InitVolZMapThickeningOffs( vSurf, dOffs, dTol))
|
||||
return false ;
|
||||
|
||||
// scorro le superfici
|
||||
for ( const ISurfTriMesh* Surf : vSurf) {
|
||||
// se superficie non valida, passo alla successiva
|
||||
if ( ! Surf->IsValid() || Surf->GetTriangleCount() == 0)
|
||||
continue ;
|
||||
|
||||
// aggiorno lo Zmap
|
||||
if ( nType == STMOFF_FILLET) {
|
||||
if ( ! UpdateVolZMapBySurfThickeningFilletOffset( Surf, dOffs, dTol))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
m_nShape = OFFSET ;
|
||||
return true ;
|
||||
}
|
||||
+1854
-186
File diff suppressed because it is too large
Load Diff
+187
-172
@@ -25,7 +25,7 @@
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Voronoi::Voronoi( const ICurve* pCrv, bool bAllowAdd)
|
||||
Voronoi::Voronoi( const ICurve* pCrv, bool bAllowAdd)
|
||||
: m_vroni( nullptr), m_nBound( VORONOI_STD_BOUND), m_bVDComputed( false), m_bAllowAdd( true)
|
||||
{
|
||||
// tento di aggiungere la curva
|
||||
@@ -35,7 +35,7 @@ Voronoi::Voronoi( const ICurve* pCrv, bool bAllowAdd)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Voronoi::Voronoi( const ISurfFlatRegion* pSfr, bool bAllowAdd)
|
||||
Voronoi::Voronoi( const ISurfFlatRegion* pSfr, bool bAllowAdd)
|
||||
: m_vroni( nullptr), m_nBound( VORONOI_STD_BOUND), m_bVDComputed( false), m_bAllowAdd( true)
|
||||
{
|
||||
// tento di aggiungere la superficie
|
||||
@@ -45,16 +45,16 @@ Voronoi::Voronoi( const ISurfFlatRegion* pSfr, bool bAllowAdd)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Voronoi::~Voronoi( void)
|
||||
Voronoi::~Voronoi( void)
|
||||
{
|
||||
Clear() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::Clear( void)
|
||||
Voronoi::Clear( void)
|
||||
{
|
||||
// pulizia oggetto vroni
|
||||
// pulizia oggetto vroni
|
||||
if ( m_vroni != nullptr)
|
||||
delete m_vroni ;
|
||||
m_vroni = nullptr ;
|
||||
@@ -72,7 +72,7 @@ Voronoi::Clear( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::AddCurve( const ICurve* pCrv)
|
||||
Voronoi::AddCurve( const ICurve* pCrv)
|
||||
{
|
||||
if ( ! m_bAllowAdd)
|
||||
return false ;
|
||||
@@ -99,21 +99,21 @@ Voronoi::AddCurve( const ICurve* pCrv)
|
||||
if ( ! vtExtr.IsSmall())
|
||||
plPlane.Set( ptS, vtExtr) ;
|
||||
else
|
||||
plPlane.Set( ptS, Z_AX) ;
|
||||
plPlane.Set( ptS, Z_AX) ;
|
||||
}
|
||||
else {
|
||||
if ( ! pCrv->IsFlat( plPlane, false, 10 * EPS_SMALL))
|
||||
return false ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
if ( m_vpCrvs.empty()) {
|
||||
// se prima curva considerata assegno il frame al Voronoi
|
||||
m_Frame.Set( plPlane.GetPoint(), plPlane.GetVersN()) ;
|
||||
m_Frame.Set( plPlane.GetPoint(), plPlane.GetVersN()) ;
|
||||
}
|
||||
else {
|
||||
// altrimenti verifico sia complanare ad eventuali curve già presenti
|
||||
if ( ! AreSameOrOppositeVectorApprox( m_Frame.VersZ(), plPlane.GetVersN()) || ! PointInPlaneApprox( m_Frame.Orig(), plPlane))
|
||||
return false ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// creo una copia della curva e la porto in locale
|
||||
@@ -128,8 +128,8 @@ Voronoi::AddCurve( const ICurve* pCrv)
|
||||
m_vroni = new( nothrow) vroniObject() ;
|
||||
if ( m_vroni == nullptr)
|
||||
return false ;
|
||||
m_vroni->apiInitializeProgram() ;
|
||||
}
|
||||
m_vroni->apiInitializeProgram() ;
|
||||
}
|
||||
|
||||
// aggiungo la curva in locale all'oggetto vroni
|
||||
if ( ! AddCurveToVroni( pCrvLoc))
|
||||
@@ -144,61 +144,61 @@ Voronoi::AddCurve( const ICurve* pCrv)
|
||||
BBox3d bBox ;
|
||||
pCrvLoc->GetLocalBBox( bBox) ;
|
||||
m_bBox.Add( bBox) ;
|
||||
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::AddSurfFlatRegion( const ISurfFlatRegion* pSfr)
|
||||
Voronoi::AddSurfFlatRegion( const ISurfFlatRegion* pSfr)
|
||||
{
|
||||
if ( ! m_bAllowAdd)
|
||||
return false ;
|
||||
|
||||
if ( pSfr == nullptr)
|
||||
return false ;
|
||||
|
||||
|
||||
// recupero il piano
|
||||
Point3d ptCen ; pSfr->GetCentroid( ptCen) ;
|
||||
Vector3d vtN = pSfr->GetNormVersor() ;
|
||||
Vector3d vtN = pSfr->GetNormVersor() ;
|
||||
if ( m_vpCrvs.empty()) {
|
||||
// assegno il frame al Voronoi
|
||||
m_Frame.Set( ptCen, vtN) ;
|
||||
m_Frame.Set( ptCen, vtN) ;
|
||||
}
|
||||
else {
|
||||
// verifico sia complanare ad eventuali curve già presenti
|
||||
Plane3d plPlane ;
|
||||
plPlane.Set( ptCen, pSfr->GetNormVersor()) ;
|
||||
if ( ! AreSameOrOppositeVectorApprox( m_Frame.VersZ(), pSfr->GetNormVersor()) || ! PointInPlaneApprox( m_Frame.Orig(), plPlane))
|
||||
return false ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// verifico se oggetto vroni è stato inizializzato
|
||||
if ( m_vroni == nullptr) {
|
||||
m_vroni = new( nothrow) vroniObject() ;
|
||||
if ( m_vroni == nullptr)
|
||||
return false ;
|
||||
m_vroni->apiInitializeProgram() ;
|
||||
m_vroni->apiInitializeProgram() ;
|
||||
}
|
||||
|
||||
|
||||
// aggiungo le curve di loop
|
||||
for ( int i = 0 ; i < pSfr->GetChunkCount() ; i ++) {
|
||||
for ( int j = 0 ; j < pSfr->GetLoopCount( i) ; j ++) {
|
||||
PtrOwner<ICurve> pCrvLoc( pSfr->GetLoop( i, j)) ;
|
||||
if ( IsNull( pCrvLoc))
|
||||
return false ;
|
||||
pCrvLoc->ToLoc( m_Frame) ;
|
||||
pCrvLoc->ToLoc( m_Frame) ;
|
||||
if ( ! AddCurveToVroni( pCrvLoc))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
LOG_ERROR( GetEGkLogger(), m_vroni->GetExceptionMessage())
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
// aggiorno il box complessivo
|
||||
BBox3d bBox ;
|
||||
Frame3d frSrf = m_Frame ;
|
||||
@@ -211,16 +211,16 @@ Voronoi::AddSurfFlatRegion( const ISurfFlatRegion* pSfr)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::AddCurveToVroni( const ICurve* pCrv)
|
||||
Voronoi::AddCurveToVroni( const ICurve* pCrv)
|
||||
{
|
||||
int nLoopId = m_vpCrvs.size() ;
|
||||
|
||||
// aggiungo il punto iniziale
|
||||
Point3d ptStart ;
|
||||
Point3d ptStart ;
|
||||
if ( ! pCrv->GetStartPoint( ptStart))
|
||||
return false ;
|
||||
int nCrv = m_vroni->HandlePnt( ptStart.x, ptStart.y, {nLoopId, 0}) ;
|
||||
|
||||
|
||||
// aggiungo la parte rimanente della curva
|
||||
switch ( pCrv->GetType()) {
|
||||
case CRV_LINE :
|
||||
@@ -229,7 +229,7 @@ Voronoi::AddCurveToVroni( const ICurve* pCrv)
|
||||
case CRV_ARC :
|
||||
m_vpCrvs.emplace_back( pCrv->Clone()) ;
|
||||
return AddArcToVroni( GetCurveArc( pCrv), nCrv, nLoopId) ;
|
||||
case CRV_COMPO :
|
||||
case CRV_COMPO :
|
||||
return AddCompoToVroni( GetCurveComposite( pCrv), nCrv, nLoopId) ;
|
||||
case CRV_BEZIER :
|
||||
return AddBezierToVroni( GetCurveBezier( pCrv), nCrv, nLoopId) ;
|
||||
@@ -242,7 +242,7 @@ Voronoi::AddCurveToVroni( const ICurve* pCrv)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::AddLineToVroni( const ICurveLine* pLine, int& nVroniCrv, int nLoopId, int nCrvId, Point3d ptEnd)
|
||||
Voronoi::AddLineToVroni( const ICurveLine* pLine, int& nVroniCrv, int nLoopId, int nCrvId, Point3d ptEnd)
|
||||
{
|
||||
if ( pLine == nullptr)
|
||||
return false ;
|
||||
@@ -250,7 +250,7 @@ Voronoi::AddLineToVroni( const ICurveLine* pLine, int& nVroniCrv, int nLoopId, i
|
||||
// verifico se il punto finale viene forzato oppure deve essere ricavato dalla pLine
|
||||
if ( ! ptEnd.IsValid()) {
|
||||
if ( ! pLine->GetEndPoint( ptEnd))
|
||||
return false ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
m_vroni->AddSeg( &nVroniCrv, ptEnd.x, ptEnd.y, {nLoopId, nCrvId}) ;
|
||||
@@ -259,7 +259,7 @@ Voronoi::AddLineToVroni( const ICurveLine* pLine, int& nVroniCrv, int nLoopId, i
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::AddArcToVroni( const ICurveArc* pArc, int& nVroniCrv, int nLoopId, int nCrvId, Point3d ptEnd)
|
||||
Voronoi::AddArcToVroni( const ICurveArc* pArc, int& nVroniCrv, int nLoopId, int nCrvId, Point3d ptEnd)
|
||||
{
|
||||
if ( pArc == nullptr)
|
||||
return false ;
|
||||
@@ -285,7 +285,7 @@ Voronoi::AddArcToVroni( const ICurveArc* pArc, int& nVroniCrv, int nLoopId, int
|
||||
// verifico se il punto finale viene forzato oppure deve essere ricavato dal pArc
|
||||
if ( ! ptEnd.IsValid()) {
|
||||
if ( ! pArc->GetEndPoint( ptEnd))
|
||||
return false ;
|
||||
return false ;
|
||||
}
|
||||
m_vroni->AddArc( &nVroniCrv, ptEnd.x, ptEnd.y, ptCen.x, ptCen.y, nArcSiteType, {nLoopId, nCrvId}) ;
|
||||
}
|
||||
@@ -295,7 +295,7 @@ Voronoi::AddArcToVroni( const ICurveArc* pArc, int& nVroniCrv, int nLoopId, int
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::AddCompoToVroni( const ICurveComposite* pCompo, int& nVroniCrv, int nLoopId)
|
||||
Voronoi::AddCompoToVroni( const ICurveComposite* pCompo, int& nVroniCrv, int nLoopId)
|
||||
{
|
||||
if ( pCompo == nullptr)
|
||||
return false ;
|
||||
@@ -315,18 +315,18 @@ Voronoi::AddCompoToVroni( const ICurveComposite* pCompo, int& nVroniCrv, int nLo
|
||||
bool bClosed = pCopy->IsClosed() ;
|
||||
for ( int i = 0 ; i < pCopy->GetCurveCount() ; i++) {
|
||||
Point3d ptForcedEnd = P_INVALID ;
|
||||
|
||||
|
||||
// se curva è chiusa, forzo l'end point a coincidere con lo start ( per le tolleranze di vroni)
|
||||
if ( i == pCopy->GetCurveCount() - 1 && bClosed)
|
||||
pCompo->GetStartPoint( ptForcedEnd) ;
|
||||
|
||||
|
||||
// aggiungo
|
||||
const ICurve* pCrv = pCopy->GetCurve( i) ;
|
||||
int nType = pCrv->GetType() ;
|
||||
if ( nType == CRV_LINE)
|
||||
AddLineToVroni( GetCurveLine( pCrv), nVroniCrv, nLoopId, i, ptForcedEnd) ;
|
||||
else if ( nType == CRV_ARC)
|
||||
AddArcToVroni( GetCurveArc( pCrv), nVroniCrv, nLoopId, i, ptForcedEnd) ;
|
||||
AddArcToVroni( GetCurveArc( pCrv), nVroniCrv, nLoopId, i, ptForcedEnd) ;
|
||||
}
|
||||
|
||||
// aggiungo al vettore di curve
|
||||
@@ -341,7 +341,7 @@ Voronoi::AddBezierToVroni( const ICurveBezier* pBezier, int& nVroniCrv, int nLoo
|
||||
{
|
||||
if ( pBezier == nullptr)
|
||||
return false ;
|
||||
|
||||
|
||||
// riconduco al caso di curva composita
|
||||
PtrOwner<CurveComposite> pCompo( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCompo))
|
||||
@@ -352,28 +352,28 @@ Voronoi::AddBezierToVroni( const ICurveBezier* pBezier, int& nVroniCrv, int nLoo
|
||||
|
||||
Vector3d vtExtr ; pBezier->GetExtrusion( vtExtr) ;
|
||||
pCompo->SetExtrusion( vtExtr) ;
|
||||
|
||||
|
||||
return AddCompoToVroni( pCompo, nVroniCrv, nLoopId) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
ICurve*
|
||||
Voronoi::GetCurve( int nId) const
|
||||
{
|
||||
// verifico validità indice
|
||||
if ( nId < 0 || nId > ( int)m_vpCrvs.size() - 1)
|
||||
return nullptr ;
|
||||
return nullptr ;
|
||||
// ne faccio una copia
|
||||
ICurve* pCrv = m_vpCrvs[nId]->Clone() ;
|
||||
if ( pCrv == nullptr)
|
||||
return nullptr ;
|
||||
return nullptr ;
|
||||
// la porto nel riferimento globale
|
||||
pCrv->ToGlob( m_Frame) ;
|
||||
return pCrv ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
bool
|
||||
Voronoi::GetVroniPlane( Plane3d& plPlane) const
|
||||
{
|
||||
if ( ! IsValid())
|
||||
@@ -383,13 +383,13 @@ Voronoi::GetVroniPlane( Plane3d& plPlane) const
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
bool
|
||||
Voronoi::CalcVoronoi( int nBound)
|
||||
{
|
||||
{
|
||||
// se già stato calcolato con lo stesso bound non devo fare nulla
|
||||
if ( m_bVDComputed && nBound == m_nBound)
|
||||
return true ;
|
||||
|
||||
|
||||
// se già stato calcolato reset dei dati
|
||||
if ( m_bVDComputed)
|
||||
m_vroni->ResetVoronoiDiagram() ;
|
||||
@@ -398,9 +398,9 @@ Voronoi::CalcVoronoi( int nBound)
|
||||
m_nBound = max( nBound, VORONOI_STD_BOUND) ;
|
||||
|
||||
// calcolo
|
||||
m_bVDComputed = true ;
|
||||
m_bVDComputed = true ;
|
||||
string sTmp = "" ;
|
||||
m_vroni->apiComputeVD( false, true, false, m_nBound, 0, 0, &sTmp[0], false, false, false, &sTmp[0], true) ;
|
||||
m_vroni->apiComputeVD( false, true, false, m_nBound, 0, 0, &sTmp[0], false, false, false, &sTmp[0], true) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -416,7 +416,7 @@ Voronoi::GetBisectorCurve( int i)
|
||||
int nType = m_vroni->GetBisectorType( i) ;
|
||||
|
||||
// linea
|
||||
if ( nType == BisectorType::LINE) {
|
||||
if ( nType == BisectorType::LINE) {
|
||||
// recupero i dati del bisettore da vroni
|
||||
Point3d ptS, ptE ;
|
||||
double dParS, dParE ;
|
||||
@@ -434,7 +434,7 @@ Voronoi::GetBisectorCurve( int i)
|
||||
pLine->SetTempParam( dParS, 0) ;
|
||||
pLine->SetTempParam( dParE, 1) ;
|
||||
pLine->ToGlob( m_Frame) ;
|
||||
return pLine ;
|
||||
return pLine ;
|
||||
}
|
||||
|
||||
// degenerate hyperellipse ( arco)
|
||||
@@ -454,20 +454,20 @@ Voronoi::GetBisectorCurve( int i)
|
||||
pArc->SetTempParam( dParS, 0) ;
|
||||
pArc->SetTempParam( dParS, 1) ; // dParE = dParS
|
||||
pArc->ToGlob( m_Frame) ;
|
||||
return pArc ;
|
||||
return pArc ;
|
||||
}
|
||||
|
||||
|
||||
// bisettore generico
|
||||
else if ( nType != BisectorType::NONE) {
|
||||
// approssimo linearmente il bisettore
|
||||
int nPoints = m_vroni->GetApproxedBisectorPointsNbr( i) ;
|
||||
if ( nPoints < 2)
|
||||
return nullptr ;
|
||||
|
||||
|
||||
CurveComposite* pCompo = CreateBasicCurveComposite() ;
|
||||
if ( pCompo == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
|
||||
// verifico se devo leggere i punti del bisettore al contrario per averlo orientato dal parametro minore al maggiore
|
||||
bool bInvert = false ;
|
||||
double dPar1, dPar2 ;
|
||||
@@ -481,13 +481,13 @@ Voronoi::GetBisectorCurve( int i)
|
||||
m_vroni->GetApproxedBisectorPoint( i, bInvert ? nPoints - 1 : 0, pt.v, dParS) ;
|
||||
pCompo->AddPoint( pt) ;
|
||||
int nCrvCount = 0 ;
|
||||
|
||||
|
||||
double dParPrev = dParS ;
|
||||
int j = bInvert ? nPoints - 2 : 1 ;
|
||||
while ( ( bInvert && j >= 0) || ( ! bInvert && j < nPoints)) {
|
||||
double dPar ;
|
||||
m_vroni->GetApproxedBisectorPoint( i, j, pt.v, dPar) ;
|
||||
if ( pCompo->AddLine( pt)) {
|
||||
if ( pCompo->AddLine( pt)) {
|
||||
// setto i parametri sulla sottocurva
|
||||
pCompo->SetCurveTempParam( nCrvCount, dParPrev, 0) ;
|
||||
pCompo->SetCurveTempParam( nCrvCount, dPar, 1) ;
|
||||
@@ -501,7 +501,7 @@ Voronoi::GetBisectorCurve( int i)
|
||||
else
|
||||
j ++ ;
|
||||
}
|
||||
|
||||
|
||||
// setto parametri sulla curva
|
||||
pCompo->SetTempParam( dParS, 0) ;
|
||||
pCompo->SetTempParam( dParPrev, 1) ;
|
||||
@@ -521,12 +521,12 @@ Voronoi::CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound)
|
||||
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
|
||||
try {
|
||||
// verifico se necessario calcolo Voronoi
|
||||
if ( ! m_bVDComputed || nBound != m_nBound)
|
||||
CalcVoronoi( nBound) ;
|
||||
|
||||
|
||||
for ( int i = 4 ; i < m_vroni->GetNumberOfEdges() ; i ++) {
|
||||
// recupero la curva del bisettore
|
||||
PtrOwner<ICurve> pCrv( GetBisectorCurve( i)) ;
|
||||
@@ -546,7 +546,7 @@ Voronoi::CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
bool
|
||||
Voronoi::CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide)
|
||||
{
|
||||
vCrvs.clear() ;
|
||||
@@ -561,21 +561,21 @@ Voronoi::CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide)
|
||||
bRight = false ;
|
||||
else if ( nSide == WMAT_RIGHT)
|
||||
bLeft = false ;
|
||||
|
||||
try {
|
||||
|
||||
try {
|
||||
if ( ! m_bVDComputed)
|
||||
CalcVoronoi() ;
|
||||
|
||||
// calcolo medial axis
|
||||
m_vroni->apiComputeWMAT( false, 0.0, 0.0, false, bLeft, bRight) ;
|
||||
|
||||
|
||||
for ( int i = 4 ; i < m_vroni->GetNumberOfEdges() ; i ++) {
|
||||
// verifico se il lato appartiene al medial axis
|
||||
if ( m_vroni->IsWMATEdge( i)) {
|
||||
PtrOwner<ICurve> pCrv( GetBisectorCurve( i)) ;
|
||||
if ( ! IsNull( pCrv) && pCrv->IsValid())
|
||||
vCrvs.emplace_back( Release( pCrv)) ;
|
||||
}
|
||||
if ( ! IsNull( pCrv) && pCrv->IsValid())
|
||||
vCrvs.emplace_back( Release( pCrv)) ;
|
||||
}
|
||||
}
|
||||
|
||||
// libero la memoria di vroni utilizzata per calcolare bisettore
|
||||
@@ -590,7 +590,7 @@ Voronoi::CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
bool
|
||||
Voronoi::CalcOffset( ICURVEPOVECTOR& vOffs, double dOffs, int nType)
|
||||
{
|
||||
vOffs.clear() ;
|
||||
@@ -603,38 +603,34 @@ Voronoi::CalcOffset( ICURVEPOVECTOR& vOffs, double dOffs, int nType)
|
||||
for ( auto pCrv : m_vpCrvs)
|
||||
vOffs.emplace_back( pCrv->Clone()) ;
|
||||
}
|
||||
|
||||
|
||||
// calcolo offset
|
||||
ICRVCOMPOPLIST OffsList ;
|
||||
if ( ! CalcVroniOffset( OffsList, abs( dOffs)))
|
||||
return false ;
|
||||
|
||||
return false ;
|
||||
|
||||
// sistemo le curve di offset calcolate con vroni
|
||||
for ( auto pCrv : OffsList) {
|
||||
|
||||
// seleziono le porzioni dell'offset che si trovano dal lato richiesto
|
||||
ICRVCOMPOPOVECTOR vResult = AdjustOffsetCurves( pCrv, dOffs) ;
|
||||
|
||||
for ( int i = 0 ; i < int( vResult.size()) ; ++ i) {
|
||||
|
||||
|
||||
for ( int i = 0 ; i < int( vResult.size()) ; ++ i) {
|
||||
|
||||
// eventuale inversione
|
||||
if ( dOffs > EPS_SMALL)
|
||||
vResult[i]->Invert() ;
|
||||
|
||||
|
||||
// sistemo il punto di inizio
|
||||
if ( vResult[i]->IsClosed())
|
||||
if ( vResult[i]->IsClosed())
|
||||
AdjustOffsetStart( vResult[i]) ;
|
||||
|
||||
// sistemo i raccordi
|
||||
if ( ( nType & ICurve::OFF_CHAMFER) != 0 || ( nType & ICurve::OFF_EXTEND) != 0) {
|
||||
|
||||
// identifico i raccordi
|
||||
if ( ( nType & ICurve::OFF_CHAMFER) != 0 || ( nType & ICurve::OFF_EXTEND) != 0)
|
||||
IdentifyFillets( vResult[i], dOffs) ;
|
||||
AdjustCurveFillets( vResult[i], dOffs, nType) ;
|
||||
}
|
||||
|
||||
// porto nel frame globale
|
||||
vResult[i]->ToGlob( m_Frame) ;
|
||||
|
||||
// unisco le parti allineate
|
||||
vResult[i]->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG, true, true) ;
|
||||
vResult[i]->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG, true, true) ;
|
||||
// aggiungo al vettore finale
|
||||
vOffs.emplace_back( Release( vResult[i])) ;
|
||||
}
|
||||
@@ -642,11 +638,22 @@ Voronoi::CalcOffset( ICURVEPOVECTOR& vOffs, double dOffs, int nType)
|
||||
delete( pCrv) ;
|
||||
}
|
||||
|
||||
// aggiusto i raccordi
|
||||
if ( ( nType & ICurve::OFF_CHAMFER) != 0 || ( nType & ICurve::OFF_EXTEND) != 0)
|
||||
if ( ! AdjustCurveFillets( vOffs, dOffs, nType)) {
|
||||
vOffs.clear() ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// porto nel frame globale
|
||||
for ( int i = 0 ; i < int( vOffs.size()) ; i++)
|
||||
vOffs[i]->ToGlob( m_Frame) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
bool
|
||||
Voronoi::CalcSingleCurvesOffset( ICURVEPOVECTOR& vOffs, double dOffs)
|
||||
{
|
||||
// calcola, se possibile, le curve di offset del valore richiesto come curve singole, andando a recuperare i tratti del
|
||||
@@ -660,22 +667,22 @@ Voronoi::CalcSingleCurvesOffset( ICURVEPOVECTOR& vOffs, double dOffs)
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
try {
|
||||
try {
|
||||
if ( ! m_bVDComputed)
|
||||
CalcVoronoi() ;
|
||||
|
||||
// individuo il lato richiesto
|
||||
// individuo il lato richiesto
|
||||
bool bLeft = ( dOffs < 0) ;
|
||||
bool bRight = ! bLeft ;
|
||||
bool bRight = ! bLeft ;
|
||||
for ( int i = 0 ; i < int( m_vpCrvs.size()) ; i++) {
|
||||
if ( ! m_vpCrvs[i]->IsClosed()) {
|
||||
// se è presente una curva aperta il medial axis deve essere fatto sia a destra sia a sinistra
|
||||
bLeft = true ;
|
||||
bRight = true ;
|
||||
break ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
int nSideRef = ( dOffs < 0 ? MDS_LEFT : MDS_RIGHT) ;
|
||||
int nSideRef = ( dOffs < 0 ? MDS_LEFT : MDS_RIGHT) ;
|
||||
|
||||
// seleziono le curve del medial axis aventi parametro costante pari all'offset richiesto
|
||||
m_vroni->apiComputeWMAT( false, 0.0, 0.0, false, bLeft, bRight) ;
|
||||
@@ -688,7 +695,7 @@ Voronoi::CalcSingleCurvesOffset( ICURVEPOVECTOR& vOffs, double dOffs)
|
||||
m_vroni->GetBisectorParams( i, dParS, dParE) ;
|
||||
if ( abs( dParS - abs( dOffs)) < EPS_SMALL && abs( dParE - abs( dOffs)) < EPS_SMALL) {
|
||||
PtrOwner<ICurve> pCrv( GetBisectorCurve( i)) ;
|
||||
if ( ! IsNull( pCrv) && pCrv->IsValid()) {
|
||||
if ( ! IsNull( pCrv) && pCrv->IsValid()) {
|
||||
// se necessario verifico se dal lato corretto rispetto ai siti di riferimento
|
||||
if ( bLeft && bRight) {
|
||||
// recupero i siti di riferimento
|
||||
@@ -700,7 +707,7 @@ Voronoi::CalcSingleCurvesOffset( ICURVEPOVECTOR& vOffs, double dOffs)
|
||||
pCrv->SetTempProp( nOrigCrv1, 1) ;
|
||||
int nSide = GetOffsetCurveSide( pCrv) ;
|
||||
if ( nSide != nSideRef)
|
||||
continue ;
|
||||
continue ;
|
||||
}
|
||||
if ( nOrigCrv2 != -1) {
|
||||
// verifico il lato rispetto al secondo sito
|
||||
@@ -709,18 +716,18 @@ Voronoi::CalcSingleCurvesOffset( ICURVEPOVECTOR& vOffs, double dOffs)
|
||||
int nSide = GetOffsetCurveSide( pCrv) ;
|
||||
if ( nSide != nSideRef)
|
||||
continue ;
|
||||
}
|
||||
}
|
||||
}
|
||||
vCrvs.emplace_back( Release( pCrv)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
vCrvs.emplace_back( Release( pCrv)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// concateno le curve ottenute
|
||||
if ( vCrvs.size() == 1)
|
||||
vOffs.emplace_back( Release( vCrvs[0])) ;
|
||||
else if ( ! vCrvs.empty()) {
|
||||
else if ( ! vCrvs.empty()) {
|
||||
ChainCurves chainC ;
|
||||
chainC.Init( true, 10 * EPS_SMALL, int( vCrvs.size())) ;
|
||||
for ( int i = 0 ; i < int( vCrvs.size()) ; ++ i) {
|
||||
@@ -747,14 +754,14 @@ Voronoi::CalcSingleCurvesOffset( ICURVEPOVECTOR& vOffs, double dOffs)
|
||||
vCrvs[nInd]->Invert() ;
|
||||
// aggiungo alla composita
|
||||
if ( ! pCrvCompo->AddCurve( Release( vCrvs[nInd])))
|
||||
return false ;
|
||||
return false ;
|
||||
}
|
||||
if ( pCrvCompo->IsValid()) {
|
||||
pCrvCompo->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG) ;
|
||||
vOffs.emplace_back( Release( pCrvCompo)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// libero la memoria di vroni utilizzata per calcolare bisettore
|
||||
m_vroni->apiFreeBisectorBuffer() ;
|
||||
@@ -768,11 +775,11 @@ Voronoi::CalcSingleCurvesOffset( ICURVEPOVECTOR& vOffs, double dOffs)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
bool
|
||||
Voronoi::CalcSpecialPointOffset( PNTVECTVECTOR& vResult, double dOffs)
|
||||
{
|
||||
// calcola i punti e le tangenti sui bisettori del medial axis in corrispondenza del valore di offset richiesto
|
||||
|
||||
|
||||
vResult.clear() ;
|
||||
|
||||
if ( abs( dOffs) < EPS_SMALL)
|
||||
@@ -785,12 +792,12 @@ Voronoi::CalcSpecialPointOffset( PNTVECTVECTOR& vResult, double dOffs)
|
||||
// verifico se necessario ricalcolo Voronoi
|
||||
UpdateVoronoi( dOffs) ;
|
||||
|
||||
// indivudio lato medial axis per curve chiuse ( suppongo di chiamare la funzione dalla singola curva, quindi vale controllare
|
||||
// indivudio lato medial axis per curve chiuse ( suppongo di chiamare la funzione dalla singola curva, quindi vale controllare
|
||||
// la chiusura solo sulla prima curva. Eventualmente da estendere)
|
||||
bool bLeft = true, bRight = true ;
|
||||
if ( m_vpCrvs[0]->IsClosed()) {
|
||||
bLeft = dOffs < 0 ;
|
||||
bRight = ! bLeft ;
|
||||
bRight = ! bLeft ;
|
||||
}
|
||||
|
||||
// calcolo medial axis
|
||||
@@ -819,12 +826,12 @@ Voronoi::CalcSpecialPointOffset( PNTVECTVECTOR& vResult, double dOffs)
|
||||
double dPar ;
|
||||
Point3d ptTemp ;
|
||||
Vector3d vtDir ;
|
||||
if ( ! pCrv->GetParamAtPoint( pt, dPar, 100 * EPS_SMALL) || ! pCrv->GetPointD1D2( dPar, ICurve::FROM_MINUS, ptTemp, &vtDir))
|
||||
return false ;
|
||||
if ( ! pCrv->GetParamAtPoint( pt, dPar, 100 * EPS_SMALL) || ! pCrv->GetPointD1D2( dPar, ICurve::FROM_MINUS, ptTemp, &vtDir))
|
||||
return false ;
|
||||
vtDir.Normalize() ;
|
||||
|
||||
vResult.emplace_back( pt, vtDir) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// libero la memoria di vroni utilizzata per calcolare bisettori
|
||||
@@ -839,22 +846,23 @@ Voronoi::CalcSpecialPointOffset( PNTVECTVECTOR& vResult, double dOffs)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::CalcFatCurve( ICURVEPOVECTOR& vCrvs, double dOffs, bool bSquareEnds, bool bSquareMids)
|
||||
bool
|
||||
Voronoi::CalcFatCurve( ICURVEPOVECTOR& vCrvs, double dOffs, bool bSquareEnds, bool bSquareMids,
|
||||
bool bMergeOnlySameProps)
|
||||
{
|
||||
vCrvs.clear() ;
|
||||
|
||||
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
// se offset nullo errore
|
||||
if ( abs( dOffs) < EPS_SMALL)
|
||||
return false ;
|
||||
|
||||
ICRVCOMPOPLIST OffsList ;
|
||||
|
||||
// se offset nullo errore
|
||||
if ( abs( dOffs) < EPS_SMALL)
|
||||
return false ;
|
||||
|
||||
ICRVCOMPOPLIST OffsList ;
|
||||
if ( ! CalcVroniOffset( OffsList, abs( dOffs)))
|
||||
return false ;
|
||||
|
||||
|
||||
// sistemo le curve di offset calcolate con vroni
|
||||
bool bClosed = m_vpCrvs[0]->IsClosed() ;
|
||||
for ( auto pCrvOffs : OffsList) {
|
||||
@@ -863,11 +871,10 @@ Voronoi::CalcFatCurve( ICURVEPOVECTOR& vCrvs, double dOffs, bool bSquareEnds, bo
|
||||
if ( dOffs > EPS_SMALL)
|
||||
pCrvOffs->Invert() ;
|
||||
|
||||
// sistemo i raccordi
|
||||
// identifico i raccordi da modificare
|
||||
if ( bClosed && bSquareMids) {
|
||||
// se curva è chiusa tutti i raccordi rispondono a bSquareMids
|
||||
IdentifyFillets( pCrvOffs, dOffs) ;
|
||||
AdjustCurveFillets( pCrvOffs, dOffs, ICurve::OFF_EXTEND) ;
|
||||
}
|
||||
else if ( ! bClosed && ( bSquareMids || bSquareEnds)) {
|
||||
// se curva è aperta devo distinguere i raccordi interni da quelli relativi agli estremi e
|
||||
@@ -880,22 +887,30 @@ Voronoi::CalcFatCurve( ICURVEPOVECTOR& vCrvs, double dOffs, bool bSquareEnds, bo
|
||||
else
|
||||
pCrvOffs->SetCurveTempParam( j, 0) ;
|
||||
}
|
||||
AdjustCurveFillets( pCrvOffs, dOffs, ICurve::OFF_EXTEND) ;
|
||||
}
|
||||
|
||||
// porto nel frame globale
|
||||
pCrvOffs->ToGlob( m_Frame) ;
|
||||
// unisco le parti allineate
|
||||
pCrvOffs->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG, true, true) ;
|
||||
pCrvOffs->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG, true, bMergeOnlySameProps) ;
|
||||
// aggiungo al vettore finale
|
||||
vCrvs.emplace_back( pCrvOffs) ;
|
||||
vCrvs.emplace_back( pCrvOffs) ;
|
||||
}
|
||||
|
||||
|
||||
// sistemo i raccordi
|
||||
if ( bSquareMids || bSquareEnds)
|
||||
if ( ! AdjustCurveFillets( vCrvs, dOffs, ICurve::OFF_EXTEND)) {
|
||||
vCrvs.clear() ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// porto nel frame globale
|
||||
for ( int i = 0 ; i < int( vCrvs.size()) ; i++)
|
||||
vCrvs[i]->ToGlob( m_Frame) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
bool
|
||||
Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs)
|
||||
{
|
||||
OffsList.clear() ;
|
||||
@@ -916,21 +931,21 @@ Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs)
|
||||
m_vroni->apiComputeOff( false, &sTmp[0], false, false, dOffs, 0.0, false, true, true) ;
|
||||
|
||||
// recupero le curve di offset da vroni
|
||||
int nOffsCnt = m_vroni->GetOffsetCount() ;
|
||||
int nOffsCnt = m_vroni->GetOffsetCount() ;
|
||||
for ( int i = 0 ; i < nOffsCnt ; i++) {
|
||||
Point3d ptSChain = P_INVALID ;
|
||||
PtrOwner<CurveComposite> pCrvOffs ( CreateBasicCurveComposite()) ;
|
||||
int nCrvCnt = m_vroni->GetOffsetCurveCount( i) ; // numero di sottocurve
|
||||
|
||||
for ( int j = 0 ; j < nCrvCnt ; j ++) {
|
||||
// recupero la sottocurva da vroni
|
||||
// recupero la sottocurva da vroni
|
||||
Point3d ptS, ptE, ptC ;
|
||||
int nType ;
|
||||
int nOrigCrv, nOrigLoop, nOrigPnt ; // sito
|
||||
m_vroni->GetOffsetCurve( i, j, nType, ptS.v, ptE.v, ptC.v, nOrigLoop, nOrigCrv, nOrigPnt) ;
|
||||
|
||||
if ( j == 0)
|
||||
pCrvOffs->AddPoint( ptS) ;
|
||||
pCrvOffs->AddPoint( ptS) ;
|
||||
|
||||
// se estremi coincidenti la curva va ignorata ( da vroni non possono arrivare circonferenze)
|
||||
// ma controllo se appartiene ad una catena di tratti infinitesimi
|
||||
@@ -939,7 +954,7 @@ Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs)
|
||||
if ( ! AreSamePointApprox( ptSChain, ptE)) {
|
||||
if ( ! pCrvOffs->AddLine( ptE))
|
||||
return false ;
|
||||
ptSChain = P_INVALID ;
|
||||
ptSChain = P_INVALID ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -955,16 +970,16 @@ Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs)
|
||||
if ( ! pCrvOffs->AddLine( ptE))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
else {
|
||||
PtrOwner<CurveArc> pArc( CreateBasicCurveArc()) ;
|
||||
if ( ! pArc->SetC2P( ptC, ptS, ptE)) {
|
||||
// se raggio minore di EPS_SMALL approssimo con linea
|
||||
if ( AreSamePointApprox( ptC, ptS)) {
|
||||
if ( ! pCrvOffs->AddLine( ptE))
|
||||
return false ;
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
// verifico orientamento
|
||||
@@ -973,25 +988,25 @@ Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs)
|
||||
pArc->ToExplementary() ;
|
||||
// aggiungo alla composita
|
||||
if ( ! pCrvOffs->AddCurve( Release( pArc)))
|
||||
return false ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
// setto come info la sottocurva da cui si è generata
|
||||
int nCurrCrvId = pCrvOffs->GetCurveCount() - 1 ;
|
||||
pCrvOffs->SetCurveTempProp( nCurrCrvId, nOrigCrv + 1, 0) ;
|
||||
pCrvOffs->SetCurveTempProp( nCurrCrvId, nOrigLoop, 1) ;
|
||||
// verifico se è una giunzione, ovvero un raccordo relativo agli estremi di una curva ( con distinzione fra curva
|
||||
// verifico se è una giunzione, ovvero un raccordo relativo agli estremi di una curva ( con distinzione fra curva
|
||||
// aperta e chiusa)
|
||||
if ( nOrigCrv == -1) {
|
||||
int nOrigCrvCnt = 1 ;
|
||||
if ( m_vpCrvs[nOrigLoop]->GetType() == CRV_COMPO)
|
||||
nOrigCrvCnt = GetBasicCurveComposite( m_vpCrvs[nOrigLoop])->GetCurveCount() ;
|
||||
if ( nOrigPnt == 0 || nOrigPnt == nOrigCrvCnt) {
|
||||
double dParam = m_vpCrvs[nOrigLoop]->IsClosed() ? VRONI_JUNCTION_CLOSED : VRONI_JUNCTION_OPEN ;
|
||||
double dParam = m_vpCrvs[nOrigLoop]->IsClosed() ? VRONI_JUNCTION_CLOSED : VRONI_JUNCTION_OPEN ;
|
||||
pCrvOffs->SetCurveTempParam( nCurrCrvId, dParam, 0) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rimuovo tratti di lunghezza inferiore a 5 * EPS_SMALL
|
||||
@@ -999,8 +1014,8 @@ Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs)
|
||||
|
||||
// aggiungo la curva alla lista degli offset
|
||||
if ( ! IsNull( pCrvOffs) && pCrvOffs->IsValid() && pCrvOffs->GetCurveCount() > 0)
|
||||
OffsList.push_back( Release( pCrvOffs)) ;
|
||||
}
|
||||
OffsList.push_back( Release( pCrvOffs)) ;
|
||||
}
|
||||
|
||||
// libero la memoria di vroni dedicata agli offset
|
||||
m_vroni->apiFreeOffsetData() ;
|
||||
@@ -1014,11 +1029,11 @@ Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
bool
|
||||
Voronoi::UpdateVoronoi( double dOffs)
|
||||
{
|
||||
// calcolo il bound necessario per l'offset desiderato
|
||||
double dNeededBound = abs( dOffs) / 0.49 / sqrt( m_bBox.GetDimX() * m_bBox.GetDimX() + m_bBox.GetDimY() * m_bBox.GetDimY()) ;
|
||||
double dNeededBound = abs( dOffs) / 0.49 / sqrt( m_bBox.GetDimX() * m_bBox.GetDimX() + m_bBox.GetDimY() * m_bBox.GetDimY()) ;
|
||||
if ( ! m_bVDComputed || dNeededBound > m_nBound) {
|
||||
// aggiorno il valore del bound
|
||||
int nBound = ( int)( ceil( dNeededBound) + 0.5) ;
|
||||
@@ -1030,9 +1045,9 @@ Voronoi::UpdateVoronoi( double dOffs)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICRVCOMPOPOVECTOR
|
||||
Voronoi::AdjustOffsetCurves( const ICurveComposite* pCompo, double dOffs) const
|
||||
{
|
||||
ICRVCOMPOPOVECTOR
|
||||
Voronoi::AdjustOffsetCurves( const ICurveComposite* pCompo, double dOffs) const
|
||||
{
|
||||
ICRVCOMPOPOVECTOR vResult ;
|
||||
int nSideRef = dOffs < EPS_SMALL ? MDS_LEFT : MDS_RIGHT ;
|
||||
|
||||
@@ -1050,13 +1065,13 @@ Voronoi::AdjustOffsetCurves( const ICurveComposite* pCompo, double dOffs) const
|
||||
// controllo la curva complessiva
|
||||
int nSide = GetOffsetCurveSide( pCompo->GetCurve( 0)) ;
|
||||
if ( nSide == nSideRef)
|
||||
vResult.emplace_back( pCompo->Clone()) ;
|
||||
vResult.emplace_back( pCompo->Clone()) ;
|
||||
}
|
||||
else {
|
||||
else {
|
||||
// scorro la curva eliminando le giunzioni relative a curve aperte e le sottocurve che si trovano dal lato sbagliato
|
||||
PtrOwner<CurveComposite> pCompoCurr( CreateBasicCurveComposite()) ;
|
||||
for ( int i = 0 ; i < pCompo->GetCurveCount() ; i ++) {
|
||||
bool bKeep = true ;
|
||||
bool bKeep = true ;
|
||||
double dParTmp ; pCompo->GetCurveTempParam( i, dParTmp) ;
|
||||
if ( abs( dParTmp - VRONI_JUNCTION_OPEN) < EPS_SMALL)
|
||||
bKeep = false ;
|
||||
@@ -1072,8 +1087,8 @@ Voronoi::AdjustOffsetCurves( const ICurveComposite* pCompo, double dOffs) const
|
||||
if ( pCompoCurr->IsValid()) {
|
||||
vResult.emplace_back( Release( pCompoCurr)) ;
|
||||
pCompoCurr.Set( CreateBasicCurveComposite()) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// salvo eventuale ultima curva
|
||||
if ( pCompoCurr->IsValid())
|
||||
@@ -1087,17 +1102,17 @@ Voronoi::AdjustOffsetCurves( const ICurveComposite* pCompo, double dOffs) const
|
||||
vResult.pop_back() ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return vResult ;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int
|
||||
Voronoi::GetOffsetCurveSide( const ICurve* pCrv) const
|
||||
{
|
||||
int
|
||||
Voronoi::GetOffsetCurveSide( const ICurve* pCrv) const
|
||||
{
|
||||
if ( pCrv == nullptr)
|
||||
return -1 ;
|
||||
|
||||
|
||||
Point3d ptM ; pCrv->GetMidPoint( ptM) ;
|
||||
|
||||
// recupero curva e sottocurva di riferimento dalle temp prop
|
||||
@@ -1106,8 +1121,8 @@ Voronoi::GetOffsetCurveSide( const ICurve* pCrv) const
|
||||
const ICurve* pCrvRef = m_vpCrvs[nOrigCrv] ;
|
||||
if ( nOrigSubCrv != 0 && m_vpCrvs[nOrigCrv]->GetType() == CRV_COMPO) {
|
||||
const CurveComposite* pCompoOrig = GetBasicCurveComposite( m_vpCrvs[nOrigCrv]) ;
|
||||
if ( pCompoOrig != nullptr)
|
||||
pCrvRef = pCompoOrig->GetCurve( nOrigSubCrv - 1) ;
|
||||
if ( pCompoOrig != nullptr)
|
||||
pCrvRef = pCompoOrig->GetCurve( nOrigSubCrv - 1) ;
|
||||
}
|
||||
|
||||
DistPointCurve distPC( ptM, *pCrvRef) ;
|
||||
@@ -1117,9 +1132,9 @@ Voronoi::GetOffsetCurveSide( const ICurve* pCrv) const
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::AdjustOffsetStart( ICurveComposite* pCrv) const
|
||||
{
|
||||
bool
|
||||
Voronoi::AdjustOffsetStart( ICurveComposite* pCrv) const
|
||||
{
|
||||
for ( int i = 0 ; i < pCrv->GetCurveCount() ; i++) {
|
||||
// cerco il tratto associato alla prima sottocurva originale
|
||||
int nOrigCrv ; pCrv->GetCurveTempProp( i, nOrigCrv) ;
|
||||
@@ -1139,15 +1154,15 @@ Voronoi::AdjustOffsetStart( ICurveComposite* pCrv) const
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::Translate( const Vector3d & vtMove)
|
||||
{
|
||||
Voronoi::Translate( const Vector3d & vtMove)
|
||||
{
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
return m_Frame.Translate( vtMove) ;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool
|
||||
bool
|
||||
Voronoi::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{
|
||||
if ( ! IsValid())
|
||||
@@ -1156,7 +1171,7 @@ Voronoi::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool
|
||||
bool
|
||||
Voronoi::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{
|
||||
if ( ! IsValid())
|
||||
@@ -1165,7 +1180,7 @@ Voronoi::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, doub
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool
|
||||
bool
|
||||
Voronoi::ToGlob( const Frame3d& frRef)
|
||||
{
|
||||
if ( ! IsValid())
|
||||
@@ -1174,7 +1189,7 @@ Voronoi::ToGlob( const Frame3d& frRef)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool
|
||||
bool
|
||||
Voronoi::ToLoc( const Frame3d& frRef)
|
||||
{
|
||||
if ( ! IsValid())
|
||||
@@ -1183,7 +1198,7 @@ Voronoi::ToLoc( const Frame3d& frRef)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool
|
||||
bool
|
||||
Voronoi::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
{
|
||||
if ( ! IsValid())
|
||||
@@ -1192,7 +1207,7 @@ Voronoi::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool
|
||||
bool
|
||||
Voronoi::CalcLimitOffset( int nCrv, bool bLeft, double& dOffs)
|
||||
{
|
||||
if ( nCrv < 0 || nCrv > int( m_vpCrvs.size()) - 1)
|
||||
@@ -1206,14 +1221,14 @@ Voronoi::CalcLimitOffset( int nCrv, bool bLeft, double& dOffs)
|
||||
// verifico se necessario calcolo Voronoi
|
||||
if ( ! m_bVDComputed)
|
||||
CalcVoronoi() ;
|
||||
|
||||
|
||||
for ( int i = 4 ; i < m_vroni->GetNumberOfEdges() ; i ++) {
|
||||
// verifico se è un bisettore relativo alla curva richiesta e dal lato opportuno
|
||||
if ( m_vroni->IsRelatedEdge( i, nCrv, bLeft)) {
|
||||
// calcolo i parametri del bisettore
|
||||
double dParS, dParE ;
|
||||
m_vroni->GetBisectorParams( i, dParS, dParE) ;
|
||||
dOffs = max( { dParS, dParE, dOffs}) ;
|
||||
dOffs = max( { dParS, dParE, dOffs}) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class Voronoi
|
||||
bool CalcOffset( ICURVEPOVECTOR& vOffs, double dOffs, int nType) ;
|
||||
bool CalcSingleCurvesOffset( ICURVEPOVECTOR& vOffs, double dOffs) ;
|
||||
bool CalcSpecialPointOffset( PNTVECTVECTOR& vResult, double dOffs) ;
|
||||
bool CalcFatCurve( ICURVEPOVECTOR& vOffs, double dOffs, bool bSquareEnds, bool bSquareMids) ;
|
||||
bool CalcFatCurve( ICURVEPOVECTOR& vOffs, double dOffs, bool bSquareEnds, bool bSquareMids, bool bMergeOnlySameProps = true) ;
|
||||
bool CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) ;
|
||||
bool CalcLimitOffset( int nCrv, bool bLeft, double& dOffs) ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user