Compare commits
64 Commits
NewRuled
...
5AxTrimming
| Author | SHA1 | Date | |
|---|---|---|---|
| 1cfd283f26 | |||
| 1f47402215 | |||
| 55e2983991 | |||
| 7c85ea2d43 | |||
| 1c49379ee1 | |||
| 481d81a8d2 | |||
| 68e25e10e8 | |||
| 88410333e9 | |||
| 6bbedc812f | |||
| 4e6dd05aa9 | |||
| a5684b2bf3 | |||
| 119bbe0bcb | |||
| 35b903e8a0 | |||
| 979597084d | |||
| 02742ee80f | |||
| a2bcc4d682 | |||
| cbd487e4ff | |||
| 37aaa98df6 | |||
| 2dcaa57aa3 | |||
| ba7379e752 | |||
| 6646aee01c | |||
| 7f8382f1b8 | |||
| 4bcdb03598 | |||
| 68e9be7901 | |||
| 9e3bac4a68 | |||
| 1fee7b8e49 | |||
| f668d7ac11 | |||
| 4a1c13154f | |||
| 68a9848748 | |||
| f5059166ed | |||
| ad7f209fc9 | |||
| 8b5bfb6e19 | |||
| 1efd17f6ee | |||
| b8caeb49e0 | |||
| a9fc259745 | |||
| bbc98fe282 | |||
| a445ddd89b | |||
| e874b2eb36 | |||
| a45faa4793 | |||
| 344f0da7ff | |||
| cea869c6ee | |||
| 8ad2887c38 | |||
| 2b1d2a512d | |||
| a55770d702 | |||
| 2e4b1cdd40 | |||
| 3ffc0b40d8 | |||
| cd2cde40da | |||
| efc656a72c | |||
| e1eb139aee | |||
| e7d25b2d0e | |||
| ce05ce577c | |||
| ae2cac48d1 | |||
| 37e9a05347 | |||
| 02cb8a0d3c | |||
| 6942f5fc23 | |||
| 6c4bf3f05a | |||
| 4bc8590ce9 | |||
| 5b68e33d1f | |||
| a70f7ee9c9 | |||
| 95a070413a | |||
| 223489e80d | |||
| f6a535d94c | |||
| dbc3e7d2bf | |||
| b3ebb35d01 |
+2
-4
@@ -2440,12 +2440,10 @@ CAvDiskTriangle( const Point3d& ptDiskCen, const Vector3d& vtDiskAx, double dDis
|
||||
// Allontanamento dall'interno
|
||||
double dEscapeDist = max( DiskTriaInteriorEscapeDistGenMot( ptDiskCen, vtDiskAx, dDiskRad, trTria, vtMove), 0.) ;
|
||||
// Allontanamento dalla frontiera
|
||||
Vector3d vtMoveOrt = vtMove - vtMove * vtDiskAx * vtDiskAx ;
|
||||
Vector3d vtMoveOrt = OrthoCompo( vtMove, vtDiskAx) ;
|
||||
vtMoveOrt.Normalize() ;
|
||||
Frame3d DiskFrame ;
|
||||
Vector3d vtJ = vtDiskAx ^ vtMoveOrt ;
|
||||
vtJ.Normalize() ;
|
||||
DiskFrame.Set( ptDiskCen, vtMoveOrt, vtJ, vtDiskAx) ;
|
||||
DiskFrame.Set( ptDiskCen, vtDiskAx, vtMoveOrt) ;
|
||||
Triangle3d trTriaLoc = trTria ;
|
||||
Vector3d vtMoveLoc = vtMove ;
|
||||
trTriaLoc.ToLoc( DiskFrame) ;
|
||||
|
||||
+572
-360
File diff suppressed because it is too large
Load Diff
+173
-5
@@ -25,19 +25,24 @@
|
||||
#include "IntersLineLine.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EGkUiUnits.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurvePlane.h"
|
||||
#include "/EgtDev/Include/EGkCurveByInterp.h"
|
||||
#include "/EgtDev/Include/EGkChainCurves.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#define EIGEN_NO_IO
|
||||
#include "/EgtDev/Extern/Eigen/Dense"
|
||||
|
||||
#define SAVEAPPROX 0
|
||||
#define SAVECURVEPASSED 0
|
||||
#define SAVELINEARAPPROX 0
|
||||
#if SAVEAPPROX || SAVECURVEPASSED || SAVELINEARAPPROX
|
||||
#define SAVESYNCLINES 0
|
||||
#if SAVEAPPROX || SAVECURVEPASSED || SAVELINEARAPPROX || SAVESYNCLINES
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
static int nCrvPassed = 0 ;
|
||||
std::vector<IGeoObj*> VT ;
|
||||
std::vector<Color> VC ;
|
||||
#include "/EgtDev/Include/EGkGeoObjSave.h"
|
||||
#endif
|
||||
|
||||
@@ -1595,8 +1600,10 @@ FitWithBezier( const ICurve* pCrvOrig, const PNTVECTOR& vPnt, DBLVECTOR& vParam,
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
ApproxCurveWithBezier( const ICurve* pCrv , double dTol)
|
||||
ApproxCurveWithBezier( const ICurve* pCrv , double dTol, const Vector3d& vtStart, const Vector3d& vtEnd)
|
||||
{
|
||||
if ( pCrv == nullptr || ! pCrv->IsValid())
|
||||
return nullptr ;
|
||||
|
||||
#if SAVECURVEPASSED
|
||||
SaveGeoObj( pCrv->Clone(), "D:\\Temp\\bezier\\approxWithBezier\\CurveDaApprossimare\\"+ToString(nCrvPassed) + ".nge") ;
|
||||
@@ -1668,6 +1675,10 @@ ApproxCurveWithBezier( const ICurve* pCrv , double dTol)
|
||||
VCT3DVECTOR vPrevDer ;
|
||||
VCT3DVECTOR vNextDer ;
|
||||
ComputeAkimaTangents( false, vParam, vPnt, vPrevDer, vNextDer) ;
|
||||
if ( ! AreSameVectorExact(vtStart, V_NULL)) {
|
||||
vNextDer[0] = vtStart ;
|
||||
vPrevDer.back() = vtEnd ;
|
||||
}
|
||||
|
||||
int nOverSampling = ssize( vPntOverSampling) ;
|
||||
vParam.resize( nOverSampling) ;
|
||||
@@ -1718,7 +1729,11 @@ CalcApproxError( const ICurve* pCrvOri, const ICurve* pCrvNew, double& dErr, int
|
||||
// controllo l'errore effettivo campionando più finemente
|
||||
double dLenOri = 0 ; pCrvOri->GetLength( dLenOri) ;
|
||||
double dLenNew = 0 ; pCrvNew->GetLength( dLenNew) ;
|
||||
dErr = 0 ;
|
||||
Point3d ptStart0 ; pCrvOri->GetStartPoint( ptStart0) ;
|
||||
Point3d ptStart1 ; pCrvNew->GetStartPoint( ptStart1) ;
|
||||
Point3d ptEnd0 ; pCrvOri->GetEndPoint( ptEnd0) ;
|
||||
Point3d ptEnd1 ; pCrvNew->GetEndPoint( ptEnd1) ;
|
||||
dErr = max( Dist( ptStart1, ptStart0), Dist( ptEnd1, ptEnd0)) ;
|
||||
for ( int i = 1 ; i < nPoints ; ++i) {
|
||||
Point3d ptOri, ptNew ;
|
||||
double dParOri, dParNew ;
|
||||
@@ -2687,3 +2702,156 @@ GetChainedCurves( ICRVCOMPOPOVECTOR& vCrv, double dChainTol, bool bAllowInvert)
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double
|
||||
CalcWeightVal( double dLen, const ICurve* pCrv, const Vector3d vtCurr1, const Point3d& ptCurr1, double dCoeff, double dMyDist, double& dUStep2)
|
||||
{
|
||||
pCrv->GetParamAtLength( dLen, dUStep2) ;
|
||||
Point3d ptStep2 ; Vector3d vtStep2 = V_NULL ;
|
||||
pCrv->GetPointD1D2( dUStep2, ICurve::FROM_MINUS, ptStep2, &vtStep2) ; vtStep2.Normalize() ;
|
||||
double dStepCos2 = vtCurr1 * vtStep2 ;
|
||||
double dDist = Dist( ptCurr1, ptStep2) ;
|
||||
return (1 - dStepCos2) + dCoeff * dDist / dMyDist ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GetIsoPointOnSecondCurve( const ICurve* pCrvEdge1, const ICurve* pCrvEdge2, double dUCurr1, double& dUCurr2, double dMyDist, double dUPrev2,
|
||||
double dLenPrev2, double& dLenCurr2, double dLen2)
|
||||
{
|
||||
Point3d ptCurr1 ;
|
||||
Vector3d vtCurr1 ;
|
||||
pCrvEdge1->GetPointD1D2( dUCurr1, ICurve::FROM_MINUS, ptCurr1, &vtCurr1) ;
|
||||
vtCurr1.Normalize() ;
|
||||
// --- Piano di taglio per punto a minima distanza
|
||||
IntersCurvePlane ICP( *pCrvEdge2, ptCurr1, vtCurr1) ;
|
||||
int nIndParCloser = - 1, nIndPointCloser = -1 ;
|
||||
double dSqMinDist = INFINITO ;
|
||||
for ( int nInfo = 0 ; nInfo < ICP.GetIntersCount() ; ++ nInfo) {
|
||||
IntCrvPlnInfo aInfo ;
|
||||
if ( ICP.GetIntCrvPlnInfo( nInfo, aInfo) && aInfo.Ici[0].dU > dUPrev2) {
|
||||
if ( nIndParCloser == -1)
|
||||
nIndParCloser = nInfo ;
|
||||
double dSqDist = SqDist( ptCurr1, aInfo.Ici[0].ptI) ;
|
||||
if ( dSqDist < dSqMinDist) {
|
||||
dSqMinDist = dSqDist ;
|
||||
nIndPointCloser = nInfo ;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool bOkPlane = ( nIndParCloser != -1 && nIndPointCloser != -1) ;
|
||||
if ( bOkPlane) {
|
||||
// Se gli indici sono tra loro coerenti allora ho individuato il punto
|
||||
if ( nIndParCloser == nIndPointCloser) {
|
||||
IntCrvPlnInfo aInfo ;
|
||||
ICP.GetIntCrvPlnInfo( nIndParCloser, aInfo) ;
|
||||
dUCurr2 = aInfo.Ici[0].dU ;
|
||||
}
|
||||
// Se gli indici sono discordi, devo scegliere quale dei due punti tenere
|
||||
else {
|
||||
// scelgo il punto più vicino al corrente
|
||||
IntCrvPlnInfo aInfoPt, aInfoPar ;
|
||||
ICP.GetIntCrvPlnInfo( nIndPointCloser, aInfoPt) ;
|
||||
ICP.GetIntCrvPlnInfo( nIndParCloser, aInfoPar) ;
|
||||
dUCurr2 = ( SqDist( ptCurr1, aInfoPt.Ici[0].ptI) < SqDist( ptCurr1, aInfoPar.Ici[0].ptI) ?
|
||||
aInfoPt.Ici[0].dU : aInfoPar.Ici[0].dU) ;
|
||||
#if SAVESYNCLINES
|
||||
VT.clear() ; VC.clear() ;
|
||||
VT.emplace_back( pCrvEdge1->Clone()) ; VC.emplace_back( Color( 0, 128, 255)) ;
|
||||
VT.emplace_back( pCrvEdge2->Clone()) ; VC.emplace_back( Color( 0, 128, 255)) ;
|
||||
PtrOwner<IGeoPoint3d> ptCurr1Geo( CreateGeoPoint3d()) ; ptCurr1Geo->Set( ptCurr1) ;
|
||||
VT.emplace_back( Release( ptCurr1Geo)) ; VC.emplace_back( BLUE) ;
|
||||
PtrOwner<IGeoPoint3d> ptPar( CreateGeoPoint3d()) ; ptPar->Set( aInfoPar.Ici[0].ptI) ;
|
||||
PtrOwner<IGeoPoint3d> ptPt( CreateGeoPoint3d()) ; ptPt->Set( aInfoPt.Ici[0].ptI) ;
|
||||
VT.emplace_back( Release( ptPar)) ; VC.emplace_back( LIME) ;
|
||||
VT.emplace_back( Release( ptPt)) ; VC.emplace_back( FUCHSIA) ;
|
||||
SaveGeoObj( VT, VC, "C:\\Temp\\bezier\\ruled\\TestTrimmingPlane.nge") ;
|
||||
#endif
|
||||
}
|
||||
// Verifico di non essermi allontanato troppo
|
||||
double dLen ; pCrvEdge2->GetLengthAtParam( dUCurr2, dLen) ;
|
||||
bOkPlane = ( dLen < dLenPrev2 + 2. * dMyDist) ;
|
||||
}
|
||||
if ( ! bOkPlane) {
|
||||
// --- Altrimenti, cerco il punto a minima distanza
|
||||
DistPointCurve DPC( ptCurr1, *pCrvEdge2) ;
|
||||
int nFlag ;
|
||||
bool bOkMinDist = ( DPC.GetParamAtMinDistPoint( dUPrev2, dUCurr2, nFlag) && dUCurr2 > dUPrev2) ;
|
||||
// Verifico di non essermi allontanato troppo
|
||||
if ( bOkMinDist) {
|
||||
double dLen ; pCrvEdge2->GetLengthAtParam( dUCurr2, dLen) ;
|
||||
bOkMinDist = ( dLen < dLenPrev2 + 2. * dMyDist) ;
|
||||
}
|
||||
if ( ! bOkMinDist) {
|
||||
// --- Aumento la distanza corrente del passo di campionamento
|
||||
double dLen = Clamp( dLenPrev2 + dMyDist, 0., dLen2) ;
|
||||
pCrvEdge2->GetParamAtLength( dLen, dUCurr2) ;
|
||||
}
|
||||
}
|
||||
|
||||
// Recupero il punto corrente e la direzione tangente sul secondo bordo
|
||||
pCrvEdge2->GetLengthAtParam( dUCurr2, dLenCurr2) ;
|
||||
Point3d ptCurr2 ;
|
||||
Vector3d vtCurr2 ;
|
||||
pCrvEdge2->GetPointD1D2( dUCurr2, ICurve::FROM_MINUS, ptCurr2, &vtCurr2) ;
|
||||
vtCurr2.Normalize() ;
|
||||
|
||||
// Verifico se le direzioni tangenti sono tra di loro circa parallele
|
||||
const double COS_ANG_TOL = cos( 15. * DEGTORAD) ;
|
||||
const double COS_SMALL_ANG_TOL = cos( 4. * DEGTORAD) ;
|
||||
double dSearchLen = dMyDist / 2 ;
|
||||
int NUM_STEP = 10 ;
|
||||
const double dCoeff = 0.1 ;
|
||||
double dCos = vtCurr1 * vtCurr2 ;
|
||||
double dDistCurr = Dist( ptCurr1, ptCurr2) ;
|
||||
double dMin = (1 - dCos) + dCoeff * dDistCurr / dMyDist ;
|
||||
double bUpdated = false ;
|
||||
// se poco fuori tolleranza controllo se ho un punto abbastanza vicino con la stessa tangente
|
||||
if ( vtCurr1 * vtCurr2 < COS_SMALL_ANG_TOL) {
|
||||
// Se tanto fuori dalla tolleranza, recupero il miglior versore tangente sul secondo bordo nell'intervallo successivo di lunghezza ( 2. * dMyDist)
|
||||
if ( vtCurr1 * vtCurr2 < COS_ANG_TOL) {
|
||||
dSearchLen = dMyDist ;
|
||||
NUM_STEP = 20 ;
|
||||
}
|
||||
pCrvEdge2->GetLengthAtPoint( ptCurr2, dLenCurr2) ;
|
||||
double dLimInfLen2 = Clamp( dLenCurr2 - dSearchLen, dLenPrev2, dLen2) ;
|
||||
double dLimSupLen2 = Clamp( dLenCurr2 + dSearchLen, dLenPrev2, dLen2) ;
|
||||
|
||||
// faccio un campionamento grossolano e poi campiono più finemente in prossimità dei minimi
|
||||
DBLVECTOR vVal ;
|
||||
for ( int i = 0 ; i <= NUM_STEP ; ++ i) {
|
||||
double dLen = dLimInfLen2 + i * ( dLimSupLen2 - dLimInfLen2) / NUM_STEP ;
|
||||
double dUStep2 ;
|
||||
vVal.push_back( CalcWeightVal( dLen, pCrvEdge2, vtCurr1, ptCurr1, dCoeff, dMyDist, dUStep2)) ;
|
||||
if ( vVal.back() < dMin) {
|
||||
dMin = vVal.back() ;
|
||||
dUCurr2 = dUStep2 ;
|
||||
}
|
||||
}
|
||||
DBLDBLVECTOR vInterv ;
|
||||
for ( int i = 1 ; i < ssize(vVal) - 1 ; ++i) {
|
||||
if ( vVal[i] < vVal[i-1] && vVal[i] < vVal[i+1])
|
||||
vInterv.emplace_back( dLimInfLen2 + ( i - 1) * ( dLimSupLen2 - dLimInfLen2) / NUM_STEP,
|
||||
dLimInfLen2 + ( i + 1) * ( dLimSupLen2 - dLimInfLen2) / NUM_STEP) ;
|
||||
}
|
||||
if ( ssize( vInterv) != 0) {
|
||||
for ( int j = 0 ; j < ssize( vInterv) ; ++j) {
|
||||
for ( int i = 0 ; i <= NUM_STEP ; ++ i) {
|
||||
double dLen = vInterv[j].first + i * ( vInterv[j].second - vInterv[j].first) / NUM_STEP ;
|
||||
double dUStep2 ;
|
||||
double dVal = CalcWeightVal( dLen, pCrvEdge2, vtCurr1, ptCurr1, dCoeff, dMyDist, dUStep2) ;
|
||||
if ( dVal < dMin) {
|
||||
dUCurr2 = dUStep2 ;
|
||||
dMin = dVal ;
|
||||
bUpdated = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// se il parametro è cambiato devo ricalcolare la lunghezza, che viene restituita
|
||||
if ( bUpdated)
|
||||
pCrvEdge2->GetLengthAtParam( dUCurr2, dLenCurr2) ;
|
||||
return true ;
|
||||
}
|
||||
+1
-1
@@ -35,4 +35,4 @@ bool CopyExtrusion( const ICurve* pSouCrv, ICurve* pDestCrv) ;
|
||||
bool CopyThickness( const ICurve* pSouCrv, ICurve* pDestCrv) ;
|
||||
ICurveBezier* ApproxCurveBezierWithSingleCubic( const ICurve* pCrv) ;
|
||||
Voronoi* GetCurveVoronoi( const ICurve& crvC) ;
|
||||
bool GetChainedCurves( ICRVCOMPOPOVECTOR& vCrv, double dChainTol, bool bAllowInvert) ;
|
||||
bool GetChainedCurves( ICRVCOMPOPOVECTOR& vCrv, double dChainTol, bool bAllowInvert) ;
|
||||
+166
-1
@@ -1967,7 +1967,120 @@ CurveComposite::AddJoint( double dU)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::ModifyJoint( int nU, const Point3d& ptNewJoint)
|
||||
CurveComposite::ModifyJoint( int nU, const Point3d& ptNewJoint, double dTol)
|
||||
{
|
||||
int nCrvCount = GetCurveCount() ;
|
||||
// verifico l'indice della giunzione
|
||||
if ( nU < 0 || nU > nCrvCount)
|
||||
return false ;
|
||||
// salvo le vecchie curve e nel caso le ripristino
|
||||
int nPrevCrv = -1 ;
|
||||
// recupero l'indice e il puntatore alla curva precedente (se esiste)
|
||||
if ( nU >= 0)
|
||||
nPrevCrv = nU - 1 ;
|
||||
else if ( IsClosed())
|
||||
nPrevCrv = nCrvCount - 1 ;
|
||||
PtrOwner<CurveComposite> pOrigCrv( CreateBasicCurveComposite()) ;
|
||||
if ( nPrevCrv >= 0)
|
||||
pOrigCrv->AddCurve( m_CrvSmplS[ nPrevCrv]->Clone()) ;
|
||||
// recupero il puntatore alla curva successiva (se esiste)
|
||||
int nNextCrv = -1 ;
|
||||
if ( nU < nCrvCount)
|
||||
nNextCrv = nU ;
|
||||
else if ( IsClosed())
|
||||
nNextCrv = 0 ;
|
||||
else
|
||||
nNextCrv = - 1 ;
|
||||
if ( nNextCrv >= 0)
|
||||
pOrigCrv->AddCurve( m_CrvSmplS[ nNextCrv]->Clone()) ;
|
||||
|
||||
int nCrvNmbr = GetCurveCount() ;
|
||||
int nFlagDel = DeletedCurve::NONE ;
|
||||
if ( ! ModifyJoint( nU, ptNewJoint, &nFlagDel))
|
||||
return false ;
|
||||
|
||||
bool bErasedSomeCrv = nCrvCount > GetCurveCount() ;
|
||||
bool bErasedPrev = ( nFlagDel == DeletedCurve::PREV) ;
|
||||
bool bErasedNext = ( nFlagDel == DeletedCurve::NEXT) ;
|
||||
if ( ( bErasedPrev && nNextCrv == -1) || ( bErasedNext && nPrevCrv == -1)) {
|
||||
// se sono su un estremo di una curva aperta e ho cancellato la sottocurva di estremità devo verificare che fosse più piccola della tolleranza
|
||||
if ( bErasedPrev && nNextCrv == -1) {
|
||||
Point3d ptOrigEnd ; pOrigCrv->GetEndPoint( ptOrigEnd) ;
|
||||
Point3d ptNewEnd ; GetEndPoint( ptNewEnd) ;
|
||||
if ( Dist( ptOrigEnd, ptNewEnd) > dTol)
|
||||
m_CrvSmplS.push_back( Release( pOrigCrv)) ;
|
||||
return true ;
|
||||
}
|
||||
if ( bErasedNext && nPrevCrv == -1) {
|
||||
Point3d ptOrigStart ; pOrigCrv->GetStartPoint( ptOrigStart) ;
|
||||
Point3d ptNewStart ; GetStartPoint( ptNewStart) ;
|
||||
if ( Dist( ptOrigStart, ptNewStart) > dTol)
|
||||
m_CrvSmplS.insert( m_CrvSmplS.begin(), Release( pOrigCrv)) ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
double dStart ;
|
||||
double dEnd ;
|
||||
if ( bErasedPrev) {
|
||||
dStart = nU ;
|
||||
dEnd = nNextCrv + 1 ;
|
||||
}
|
||||
else if ( bErasedNext) {
|
||||
dStart = nPrevCrv ;
|
||||
dEnd = nU ;
|
||||
if ( nU == 0)
|
||||
dStart -= 1 ;
|
||||
}
|
||||
else { // ! bErasedSomeCrv
|
||||
dStart = ( nPrevCrv != -1 ? nPrevCrv : 0) ;
|
||||
dEnd = ( nNextCrv != -1 ? nNextCrv + 1 : nCrvNmbr) ;
|
||||
}
|
||||
PtrOwner<ICurve> pNewCurve( CopyParamRange( dStart, dEnd)) ;
|
||||
double dErr = 0 ;
|
||||
if ( ! CalcApproxError( pOrigCrv, pNewCurve, dErr, 6) || dErr > dTol) {
|
||||
// se ho fallito il check o la variazione è superiore alla tolleranza richiesta, ripristino le curve originali
|
||||
if ( ! bErasedSomeCrv) {
|
||||
if ( nNextCrv != -1) {
|
||||
delete m_CrvSmplS[nNextCrv] ;
|
||||
m_CrvSmplS[nNextCrv] = pOrigCrv->RemoveFirstOrLastCurve( true) ;
|
||||
}
|
||||
if ( nPrevCrv != -1) {
|
||||
delete m_CrvSmplS[nPrevCrv] ;
|
||||
m_CrvSmplS[nPrevCrv] = pOrigCrv->RemoveFirstOrLastCurve( true) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( bErasedNext) {
|
||||
int nPos = nU == 0 ? nPrevCrv - 1 : nU ;
|
||||
delete m_CrvSmplS[nPos] ;
|
||||
if ( nU == 0) {
|
||||
m_CrvSmplS[nPos] = pOrigCrv->RemoveFirstOrLastCurve( false) ;
|
||||
nPos = 0 ;
|
||||
}
|
||||
else
|
||||
m_CrvSmplS[nPos] = pOrigCrv->RemoveFirstOrLastCurve( true) ;
|
||||
m_CrvSmplS.insert( m_CrvSmplS.begin() + nPos, pOrigCrv->RemoveFirstOrLastCurve( true)) ;
|
||||
}
|
||||
else {
|
||||
int nPos = nU == 0 ? nU : nPrevCrv ;
|
||||
delete m_CrvSmplS[nPos] ;
|
||||
if ( nU == 0) {
|
||||
m_CrvSmplS[nPos] = pOrigCrv->RemoveFirstOrLastCurve( true) ;
|
||||
nPos = nCrvNmbr - 1 ;
|
||||
}
|
||||
else
|
||||
m_CrvSmplS[nPos] = pOrigCrv->RemoveFirstOrLastCurve( true) ;
|
||||
m_CrvSmplS.insert( m_CrvSmplS.begin() + nPos, pOrigCrv->RemoveFirstOrLastCurve( true)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::ModifyJoint( int nU, const Point3d& ptNewJoint, int* pnFlagDel)
|
||||
{
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
@@ -1977,6 +2090,8 @@ CurveComposite::ModifyJoint( int nU, const Point3d& ptNewJoint)
|
||||
// verifico l'indice della giunzione
|
||||
if ( nU < 0 || nU > nCrvCount)
|
||||
return false ;
|
||||
if ( pnFlagDel != nullptr)
|
||||
*pnFlagDel = DeletedCurve::NONE ;
|
||||
// recupero l'indice e il puntatore alla curva precedente (se esiste)
|
||||
int nPrevCrv = -1 ;
|
||||
if ( nU > 0)
|
||||
@@ -2005,6 +2120,8 @@ CurveComposite::ModifyJoint( int nU, const Point3d& ptNewJoint)
|
||||
if ( AreSamePointApprox( ptStart, ptNewJoint)) {
|
||||
delete pPrevCrv ;
|
||||
m_CrvSmplS.erase( m_CrvSmplS.begin() + nPrevCrv) ;
|
||||
if ( pnFlagDel != nullptr)
|
||||
*pnFlagDel = DeletedCurve::PREV ;
|
||||
}
|
||||
// altrimenti diventa un segmento di retta
|
||||
else {
|
||||
@@ -2024,6 +2141,8 @@ CurveComposite::ModifyJoint( int nU, const Point3d& ptNewJoint)
|
||||
if ( AreSamePointApprox( ptNewJoint, ptEnd)) {
|
||||
delete pNextCrv ;
|
||||
m_CrvSmplS.erase( m_CrvSmplS.begin() + nNextCrv) ;
|
||||
if ( pnFlagDel != nullptr)
|
||||
*pnFlagDel = DeletedCurve::NEXT ;
|
||||
}
|
||||
// altrimenti diventa un segmento di retta
|
||||
else {
|
||||
@@ -3858,3 +3977,49 @@ CurveComposite::GetOnlyPoint(Point3d& ptStart) const
|
||||
ptStart = m_ptStart ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::ReplaceSingleCurve( int nSubCrv, ICurve* pNewCurveToAdd, double dTolStartEnd, double dTolAlong)
|
||||
{
|
||||
// prendo il possesso e verifico la curva
|
||||
PtrOwner<ICurve> pNewCurve( pNewCurveToAdd) ;
|
||||
if ( IsNull( pNewCurve) || ! pNewCurve->IsValid())
|
||||
return false ;
|
||||
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico l'indice sia sensato
|
||||
if ( nSubCrv < 0 || nSubCrv > GetCurveCount())
|
||||
return false ;
|
||||
|
||||
// verifico che start e end coincidano entro la tolleranza
|
||||
Point3d ptStart ; m_CrvSmplS[nSubCrv]->GetStartPoint( ptStart) ;
|
||||
Point3d ptEnd ; m_CrvSmplS[nSubCrv]->GetEndPoint( ptEnd) ;
|
||||
Point3d ptNewStart ; pNewCurve->GetStartPoint( ptNewStart) ;
|
||||
Point3d ptNewEnd ; pNewCurve->GetEndPoint( ptNewEnd) ;
|
||||
if ( ! AreSamePointApprox( ptStart, ptNewStart) || ! AreSamePointApprox( ptEnd, ptNewEnd)) {
|
||||
// se i punti di inizio e fine non sono entro EPS_SMALL ma sono entro la tolleranza passata allora modifico la curva da aggiungere
|
||||
if ( AreSamePointEpsilon( ptStart, ptNewStart, dTolStartEnd) && AreSamePointEpsilon( ptEnd, ptNewEnd, dTolStartEnd)) {
|
||||
if ( ! pNewCurve->ModifyStart( ptStart) || ! pNewCurve->ModifyEnd( ptEnd))
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
// se presente una tolleranza lungo la curva controllo che sia rispettata
|
||||
if ( dTolAlong < INFINITO) {
|
||||
double dErr = 0 ;
|
||||
CalcApproxError( m_CrvSmplS[nSubCrv], pNewCurve, dErr, 20) ;
|
||||
if ( dErr > dTolAlong)
|
||||
return false ;
|
||||
}
|
||||
|
||||
delete m_CrvSmplS[nSubCrv] ;
|
||||
m_CrvSmplS[nSubCrv] = Release( pNewCurve) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
+8
-1
@@ -26,6 +26,9 @@ class Voronoi ;
|
||||
//----------------------------------------------------------------------------
|
||||
class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
{
|
||||
public :
|
||||
enum DeletedCurve { NONE = 0, PREV = 1, NEXT = 2 } ;
|
||||
|
||||
public : // IGeoObj
|
||||
~CurveComposite( void) override ;
|
||||
CurveComposite* Clone( void) const override ;
|
||||
@@ -156,7 +159,9 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
bool AddArc2P( const Point3d& ptOther, const Point3d& ptNew, bool bEndOrStart = true) override ;
|
||||
bool AddArcTg( const Point3d& ptNew, bool bEndOrStart = true) override ;
|
||||
bool AddJoint( double dU) override ;
|
||||
bool ModifyJoint( int nU, const Point3d& ptNewJoint) override ;
|
||||
bool ModifyJoint( int nU, const Point3d& ptNewJoint) override
|
||||
{ return ModifyJoint( nU, ptNewJoint, nullptr) ; }
|
||||
bool ModifyJoint( int nU, const Point3d& ptNewJoint, double dTol) override ; // verifico se le curve interessate sono in tolleranza con la versione prima della modifica
|
||||
bool RemoveJoint( int nU) override ;
|
||||
bool MoveCurve( int nCrv, const Vector3d& vtMove) override ;
|
||||
bool ModifyCurveToArc( int nCrv, const Point3d& ptMid) override ;
|
||||
@@ -178,6 +183,7 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
bool SetCurveTempParam( int nCrv, double dParam, int nParamInd = 0) override ;
|
||||
bool GetCurveTempParam( int nCrv, double& dParam, int nParamInd = 0) const override ;
|
||||
bool GetOnlyPoint( Point3d& ptStart) const override ;
|
||||
bool ReplaceSingleCurve( int nSubCrv, ICurve* pNewCurve, double dTolStartEnd, double dTolAlong = INFINITO) override ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
@@ -211,6 +217,7 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
bool SimpleOffsetXY( double dDist, int nType = OFF_FILLET, double dMaxAngExt = ANG_RIGHT) ;
|
||||
bool IsOneCircle( Point3d& ptCen, Vector3d& vtN, double& dRad, bool& bCCW) const ;
|
||||
bool CalcVoronoiObject( void) const ;
|
||||
bool ModifyJoint( int nU, const Point3d& ptNewJoint, int* pnFlagDel) ;
|
||||
|
||||
private :
|
||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2, IS_A_POINT = 3} ;
|
||||
|
||||
Binary file not shown.
@@ -324,6 +324,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="IntersLineVolZmap.cpp" />
|
||||
<ClCompile Include="IntersPlaneVolZmap.cpp" />
|
||||
<ClCompile Include="IntersLineSurfBez.cpp" />
|
||||
<ClCompile Include="OffsetCurve3d.cpp" />
|
||||
<ClCompile Include="Trimming.cpp" />
|
||||
<ClCompile Include="MultiGeomDB.cpp" />
|
||||
<ClCompile Include="SurfTriMeshOffset.cpp" />
|
||||
|
||||
@@ -573,6 +573,12 @@
|
||||
<ClCompile Include="CAvSurfFrMove.cpp">
|
||||
<Filter>File di origine\GeoCollisionAvoid</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Trimming.cpp">
|
||||
<Filter>File di origine\GeoStriping</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="OffsetCurve3d.cpp">
|
||||
<Filter>File di origine\GeoOffset</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h">
|
||||
|
||||
@@ -198,13 +198,16 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
// se coincidono U e ptInt tra A e B
|
||||
if ( abs( m_Info[i].IciA[0].dU - m_Info[j].IciB[0].dU) < EPS_SMALL &&
|
||||
AreSamePointXYEpsilon( m_Info[i].IciA[0].ptI, m_Info[j].IciB[0].ptI, 10 * EPS_SMALL)) {
|
||||
// se non è alla fine di curva chiusa
|
||||
if ( ! bCrvAClosed || abs( m_Info[j].IciA[0].dU - dCrvBSpan) > EPS_SMALL)
|
||||
// elimino la seconda
|
||||
EraseOtherInfo( i, j) ;
|
||||
else
|
||||
// elimino la prima
|
||||
// se j è alla fine di curva chiusa
|
||||
// se j è alla fine di curva chiusa e la prima intersezione è di overlap con partenza dall'inizio ( compreso nel caso precedente)
|
||||
// oppure se i è all'inizio di curva chiusa e l'intersezione successiva a j è di overlap con lo stesso parametro
|
||||
if ( bCrvAClosed && (( abs( m_Info[j].IciA[0].dU - dCrvBSpan) < EPS_SMALL) ||
|
||||
( i == 0 && ssize(m_Info) > 2 && m_Info[i].IciA[0].dU < EPS_SMALL && m_Info[j+1].bOverlap && abs( m_Info[j].IciA[0].dU - m_Info[j+1].IciA[0].dU) < EPS_SMALL)))
|
||||
// elimino la prima
|
||||
EraseCurrentInfo( i, j) ;
|
||||
else
|
||||
// elimino la seconda
|
||||
EraseOtherInfo( i, j) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
+171
-53
@@ -15,6 +15,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "IntersLineCyl.h"
|
||||
#include "/EgtDev/Include/EGkFrame3d.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineCylinder.h"
|
||||
#include "/EgtDev/Include/ENkPolynomialRoots.h"
|
||||
|
||||
using namespace std ;
|
||||
@@ -25,99 +26,176 @@ using namespace std ;
|
||||
// In caso di intersezione viene restituito true e i parametri in dU1 e dU2.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
double dRad, double dHeight,
|
||||
double& dU1, double& dU2)
|
||||
IntersLineCyl( const Point3d& ptP, const Vector3d& vtV, double dH, double dRad, bool bTapLow, bool bTapUp,
|
||||
double& dU1, Point3d& ptInt1, Vector3d& vtN1, double& dU2, Point3d& ptInt2, Vector3d& vtN2, bool bIgnoreTap, bool bInvertNormals)
|
||||
{
|
||||
// Verifico il versore
|
||||
if ( vtL.IsSmall())
|
||||
dU1 = NAN ;
|
||||
dU2 = NAN ;
|
||||
|
||||
// Verifico il versore
|
||||
if ( vtV.IsSmall())
|
||||
return false ;
|
||||
|
||||
// Verifico il cilindro
|
||||
if ( dRad < EPS_SMALL || dHeight < EPS_SMALL)
|
||||
// Verifico il cilindro
|
||||
if ( dRad < EPS_SMALL || dH < EPS_SMALL)
|
||||
return false ;
|
||||
|
||||
// Determino le eventuali intersezioni con le due basi a quota minima e massima (solo se linea non parallela ad esse)
|
||||
// Determino le eventuali intersezioni con le due basi a quota minima e massima (solo se linea non parallela ad esse)
|
||||
int nBasInt = 0 ;
|
||||
if ( abs( vtL.z) > EPS_ZERO) {
|
||||
if ( abs( vtV.z) > EPS_ZERO) {
|
||||
// le linee tangenti al cilindro non sono considerate intersecanti
|
||||
double EpsRad = ( vtL.IsZeroXY() ? - EPS_SMALL : EPS_SMALL) ;
|
||||
Point3d ptInt1 = ptL + ( ( 0 - ptL.z) / vtL.z) * vtL ;
|
||||
if ( ptInt1.x * ptInt1.x + ptInt1.y * ptInt1.y < dRad * dRad + 2 * dRad * EpsRad) {
|
||||
dU1 = ( ptInt1 - ptL) * vtL ;
|
||||
double dEpsRad = ( vtV.IsZeroXY() ? - EPS_SMALL : EPS_SMALL) ;
|
||||
if ( bIgnoreTap)
|
||||
dEpsRad = 0. ;
|
||||
ptInt1 = ptP + ( ( 0 - ptP.z) / vtV.z) * vtV ;
|
||||
if ( ptInt1.x * ptInt1.x + ptInt1.y * ptInt1.y < dRad * dRad + 2 * dRad * dEpsRad) {
|
||||
nBasInt += 1 ;
|
||||
vtN1 = - Z_AX ;
|
||||
dU1 = ( ( 0 - ptP.z) / vtV.z) ;
|
||||
}
|
||||
Point3d ptInt2 = ptL + ( ( dHeight - ptL.z) / vtL.z) * vtL ;
|
||||
if ( ptInt2.x * ptInt2.x + ptInt2.y * ptInt2.y < dRad * dRad + 2 * dRad * EpsRad) {
|
||||
dU2 = ( ptInt2 - ptL) * vtL ;
|
||||
ptInt2 = ptP + ( ( dH - ptP.z) / vtV.z) * vtV ;
|
||||
if ( ptInt2.x * ptInt2.x + ptInt2.y * ptInt2.y < dRad * dRad + 2 * dRad * dEpsRad) {
|
||||
nBasInt += 2 ;
|
||||
vtN2 = Z_AX ;
|
||||
dU2 = ( ( dH - ptP.z) / vtV.z) ;
|
||||
}
|
||||
}
|
||||
|
||||
// Se la linea interseca entrambe le basi, si sono trovate le due intersezioni
|
||||
// Se la linea interseca entrambe le basi, si sono trovate le due intersezioni
|
||||
if ( nBasInt == 3) {
|
||||
if ( dU1 > dU2)
|
||||
if ( dU1 > dU2) {
|
||||
swap( dU1, dU2) ;
|
||||
// Trovate intersezioni
|
||||
swap( ptInt1, ptInt2) ;
|
||||
swap( vtN1, vtN2) ;
|
||||
}
|
||||
if ( bInvertNormals) {
|
||||
vtN1 *= - 1 ;
|
||||
vtN2 *= - 1 ;
|
||||
}
|
||||
// Trovate intersezioni
|
||||
return true ;
|
||||
}
|
||||
|
||||
// Determino le intersezioni con la superficie laterale del cilindro
|
||||
DBLVECTOR vdCoeff{ ptL.x * ptL.x + ptL.y * ptL.y - dRad * dRad,
|
||||
2 * ( ptL.x * vtL.x + ptL.y * vtL.y),
|
||||
vtL.x * vtL.x + vtL.y * vtL.y} ;
|
||||
|
||||
// Determino le intersezioni con la superficie laterale del cilindro
|
||||
DBLVECTOR vdCoeff{ ptP.x * ptP.x + ptP.y * ptP.y - dRad * dRad,
|
||||
2 * ( ptP.x * vtV.x + ptP.y * vtV.y),
|
||||
vtV.x * vtV.x + vtV.y * vtV.y} ;
|
||||
DBLVECTOR vdRoots ;
|
||||
int nRoot = PolynomialRoots( 2, vdCoeff, vdRoots) ;
|
||||
|
||||
// Elimino le soluzioni cha danno intersezioni fuori dai limiti in Z del cilindro
|
||||
// Epsilon per piani di tappo
|
||||
double dEpsLow = ( bTapLow ? - EPS_SMALL : EPS_SMALL) ;
|
||||
double dEpsUp = ( bTapUp ? EPS_SMALL : - EPS_SMALL) ;
|
||||
if ( bIgnoreTap) {
|
||||
dEpsLow = 0. ;
|
||||
dEpsUp = 0. ;
|
||||
}
|
||||
|
||||
// Elimino le soluzioni cha danno intersezioni fuori dai limiti in Z del cilindro
|
||||
if ( nRoot == 2) {
|
||||
double dIntZ2 = ptL.z + vdRoots[1] * vtL.z ;
|
||||
if ( dIntZ2 < 0 - EPS_SMALL || dIntZ2 > dHeight + EPS_SMALL)
|
||||
double dIntZ2 = ptP.z + vdRoots[1] * vtV.z ;
|
||||
if ( dIntZ2 < 0 + dEpsLow || dIntZ2 > dH + dEpsUp)
|
||||
-- nRoot ;
|
||||
}
|
||||
if ( nRoot >= 1) {
|
||||
double dIntZ1 = ptL.z + vdRoots[0] * vtL.z ;
|
||||
if ( dIntZ1 < 0 - EPS_SMALL || dIntZ1 > dHeight + EPS_SMALL) {
|
||||
double dIntZ1 = ptP.z + vdRoots[0] * vtV.z ;
|
||||
if ( dIntZ1 < 0 + dEpsLow || dIntZ1 > dH + dEpsUp) {
|
||||
if ( nRoot == 2)
|
||||
vdRoots[0] = vdRoots[1] ;
|
||||
-- nRoot ;
|
||||
}
|
||||
}
|
||||
|
||||
// Due soluzioni: la retta interseca due volte la superficie laterale
|
||||
// Due soluzioni: la retta interseca due volte la superficie laterale
|
||||
if ( nRoot == 2) {
|
||||
// Punti di intersezione con la superficie del cilindro
|
||||
ptInt1 = ptP + vdRoots[0] * vtV ;
|
||||
ptInt2 = ptP + vdRoots[1] * vtV ;
|
||||
dU1 = vdRoots[0] ;
|
||||
dU2 = vdRoots[1] ;
|
||||
if ( dU1 > dU2)
|
||||
// Determino le normali
|
||||
vtN1.Set( ptInt1.x, ptInt1.y, 0) ;
|
||||
vtN1.Normalize() ;
|
||||
vtN2.Set( ptInt2.x, ptInt2.y, 0) ;
|
||||
vtN2.Normalize() ;
|
||||
if ( dU1 > dU2) {
|
||||
swap( dU1, dU2) ;
|
||||
// Trovate intersezioni
|
||||
return true ;
|
||||
}
|
||||
|
||||
// Una soluzione : la retta interseca la superficie laterale e un piano
|
||||
else if ( nRoot == 1) {
|
||||
// Se piano superiore
|
||||
if ( nBasInt == 2) {
|
||||
dU1 = vdRoots[0] ;
|
||||
swap( ptInt1, ptInt2) ;
|
||||
swap( vtN1, vtN2) ;
|
||||
}
|
||||
// altrimenti piano inferiore
|
||||
else if ( nBasInt == 1) {
|
||||
dU2 = vdRoots[0] ;
|
||||
if ( bInvertNormals) {
|
||||
vtN1 *= - 1 ;
|
||||
vtN2 *= - 1 ;
|
||||
}
|
||||
// altrimenti niente
|
||||
else
|
||||
return false ;
|
||||
if ( dU1 > dU2)
|
||||
swap( dU1, dU2) ;
|
||||
// Trovate intersezioni
|
||||
// Trovate intersezioni
|
||||
return true ;
|
||||
}
|
||||
|
||||
// Nessuna soluzione : nessuna intersezione
|
||||
// Una soluzione : la retta interseca la superficie laterale e un piano
|
||||
else if ( nRoot == 1) {
|
||||
// Se piano superiore
|
||||
if ( nBasInt == 2) {
|
||||
// Punto di intersezione
|
||||
dU1 = vdRoots[0] ;
|
||||
ptInt1 = ptP + vdRoots[0] * vtV ;
|
||||
// Normale alla superficie del cilindro verso l'interno
|
||||
vtN1.Set( ptInt1.x, ptInt1.y, 0) ;
|
||||
vtN1.Normalize() ;
|
||||
}
|
||||
// altrimenti piano inferiore
|
||||
else if ( nBasInt == 1) {
|
||||
// Punto di intersezione
|
||||
dU2 = vdRoots[0] ;
|
||||
ptInt2 = ptP + vdRoots[0] * vtV ;
|
||||
// Normale alla superficie del cilindro verso l'interno
|
||||
vtN2.Set( ptInt2.x, ptInt2.y, 0) ;
|
||||
vtN2.Normalize() ;
|
||||
}
|
||||
// altrimenti niente
|
||||
else
|
||||
return false ;
|
||||
if ( dU1 > dU2) {
|
||||
swap( dU1, dU2) ;
|
||||
swap( ptInt1, ptInt2) ;
|
||||
swap( vtN1, vtN2) ;
|
||||
}
|
||||
if ( bInvertNormals) {
|
||||
vtN1 *= - 1 ;
|
||||
vtN2 *= - 1 ;
|
||||
}
|
||||
// Trovate intersezioni
|
||||
return true ;
|
||||
}
|
||||
|
||||
// Nessuna soluzione : nessuna intersezione
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Riferimento con origine nel centro della base e asse di simmetria coincidente con l'asse Z.
|
||||
// La funzione restituisce true in caso di intersezione, false altrimenti.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersLineCyl( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
const Frame3d& CylFrame, double dH, double dRad, bool bTapLow, bool bTapUp,
|
||||
double& dU1, Point3d& ptInt1, Vector3d& vtN1, double& dU2, Point3d& ptInt2, Vector3d& vtN2, bool bIgnoreTap, bool bInvertNormals)
|
||||
{
|
||||
// Porto la linea nel riferimento del cilindro
|
||||
Point3d ptP = GetToLoc( ptLineSt, CylFrame) ;
|
||||
Vector3d vtV = GetToLoc( vtLineDir, CylFrame) ;
|
||||
if ( IntersLineCyl( ptP, vtV, dH, dRad, bTapLow, bTapUp,
|
||||
dU1, ptInt1, vtN1, dU2, ptInt2, vtN2, bIgnoreTap, bInvertNormals))
|
||||
{
|
||||
ptInt1.ToGlob( CylFrame) ;
|
||||
vtN1.ToGlob( CylFrame) ;
|
||||
ptInt2.ToGlob( CylFrame) ;
|
||||
vtN2.ToGlob( CylFrame) ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Linea e cilindro sono nel medesimo riferimento.
|
||||
// Il cilindro è definito con centro della base, asse, raggio e altezza.
|
||||
@@ -133,7 +211,13 @@ IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
if ( ! frCyl.Set( ptCyl, vtCyl))
|
||||
return false ;
|
||||
// Ora eseguo i conti nel riferimento intrinseco
|
||||
return IntersLineCyl( GetToLoc( ptL, frCyl), GetToLoc( vtL, frCyl), dRad, dHeight, dU1, dU2) ;
|
||||
bool bTapLow = false ;
|
||||
bool bTapUp = false ;
|
||||
bool bIgnoreTap = true ;
|
||||
Point3d ptInt1, ptInt2 ;
|
||||
Vector3d vtN1, vtN2 ;
|
||||
return IntersLineCyl( ptL, vtL, frCyl, dHeight, dRad, bTapLow, bTapUp,
|
||||
dU1, ptInt1, vtN1, dU2, ptInt2, vtN2, bIgnoreTap) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -144,7 +228,7 @@ IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
bool
|
||||
IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
const Point3d& ptCyl1, const Point3d& ptCyl2, double dRad,
|
||||
double& dU1, double& dU2)
|
||||
double& dU1, double& dU2)
|
||||
{
|
||||
// Determino asse ed altezza del cilindro
|
||||
Vector3d vtCyl = ptCyl2 - ptCyl1 ;
|
||||
@@ -157,5 +241,39 @@ IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
if ( ! frCyl.Set( ptCyl1, vtCyl))
|
||||
return false ;
|
||||
// Ora eseguo i conti nel riferimento intrinseco
|
||||
return IntersLineCyl( GetToLoc( ptL, frCyl), GetToLoc( vtL, frCyl), dRad, dHeight, dU1, dU2) ;
|
||||
bool bTapLow = false ;
|
||||
bool bTapUp = false ;
|
||||
bool bIgnoreTap = true ;
|
||||
Point3d ptInt1, ptInt2 ;
|
||||
Vector3d vtN1, vtN2 ;
|
||||
return IntersLineCyl( ptL, vtL, frCyl, dHeight, dRad, bTapLow, bTapUp,
|
||||
dU1, ptInt1, vtN1, dU2, ptInt2, vtN2, bIgnoreTap) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// linea già nel riferimento intrinseco del cilindro
|
||||
//----------------------------------------------------------------------------
|
||||
bool IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
double dRad, double dHeight,
|
||||
double& dU1, double& dU2)
|
||||
{
|
||||
Point3d ptInt1, ptInt2 ;
|
||||
Vector3d vtN1, vtN2 ;
|
||||
bool bTapLow = false, bTapUp = false ;
|
||||
bool bIgnoreTap = true ;
|
||||
return IntersLineCyl( ptL, vtL, dHeight, dRad, bTapLow, bTapUp,
|
||||
dU1, ptInt1, vtN1, dU2, ptInt2, vtN2, bIgnoreTap) ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// funzione esposta per altre dll
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersLineCyl( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
const Frame3d& CylFrame, double dH, double dRad,
|
||||
double& dU1, Point3d& ptInt1, Vector3d& vtN1, double& dU2, Point3d& ptInt2, Vector3d& vtN2)
|
||||
{
|
||||
return IntersLineCyl( ptLineSt, vtLineDir, CylFrame, dH, dRad, false, false,
|
||||
dU1, ptInt1, vtN1, dU2, ptInt2, vtN2, true, false) ;
|
||||
}
|
||||
|
||||
+23
-4
@@ -20,17 +20,27 @@
|
||||
// Il cilindro è centrato sull'asse Z e appoggiato sul piano XY.
|
||||
// Con intersezione viene restituito true e i parametri in dU1 e dU2.
|
||||
//----------------------------------------------------------------------------
|
||||
bool IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
double dRad, double dHeight,
|
||||
double& dU1, double& dU2) ;
|
||||
bool
|
||||
IntersLineCyl( const Point3d& ptP, const Vector3d& vtV, double dH, double dRad, bool bTapLow, bool bTapUp,
|
||||
double& dU1, Point3d& ptInt1, Vector3d& vtN1, double& dU2, Point3d& ptInt2, Vector3d& vtN2, bool bIgnoreTap = false, bool bInvertNormals = false) ;
|
||||
|
||||
// come sopra ma passo il riferimento intrinseco del cilindro in cui portare la linea
|
||||
bool
|
||||
IntersLineCyl( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
const Frame3d& CylFrame, double dH, double dRad, bool bTapLow, bool bTapUp,
|
||||
double& dU1, Point3d& ptInt1, Vector3d& vtN1, double& dU2, Point3d& ptInt2, Vector3d& vtN2, bool bIgnoreTap = false, bool bInvertNormals = false) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool
|
||||
TestIntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
double dRad, double dHeight)
|
||||
{
|
||||
Point3d ptInt1, ptInt2 ;
|
||||
Vector3d vtN1, vtN2 ;
|
||||
double dU1, dU2 ;
|
||||
return IntersLineCyl( ptL, vtL, dRad, dHeight, dU1, dU2) ;
|
||||
bool bTapLow = false, bTapUp = false ;
|
||||
bool bIgnoreTap = true ;
|
||||
return IntersLineCyl( ptL, vtL, dHeight, dRad, bTapLow, bTapUp, dU1, ptInt1, vtN1, dU2, ptInt2, vtN2, bIgnoreTap) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -50,3 +60,12 @@ bool IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
bool IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
const Point3d& ptCyl1, const Point3d& ptCyl2, double dRad,
|
||||
double& dU1, double& dU2) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// // Linea e cilindro sono nel medesimo riferimento.
|
||||
// Il cilindro è definito con raggio e altezza. ( la linea è già nel riferimento intrinseco del cilindro)
|
||||
// In caso di intersezione viene restituito true e i parametri in dU1 e dU2.
|
||||
//----------------------------------------------------------------------------
|
||||
bool IntersLineCyl( const Point3d& ptL, const Vector3d& vtL,
|
||||
double dRad, double dHeight,
|
||||
double& dU1, double& dU2) ;
|
||||
|
||||
@@ -0,0 +1,464 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2026
|
||||
//----------------------------------------------------------------------------
|
||||
// File : OffsetCurve3d.cpp Data : 10.06.26 Versione : 3.1f1
|
||||
// Contenuto : Classe per offset di Curve 3d.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 10.06.26 DB Creazione modulo.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "GeoConst.h"
|
||||
#include "CurveLine.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "RemoveCurveDefects.h"
|
||||
#include "IntersLineCyl.h"
|
||||
#include "/EgtDev/Include/EGkPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||
#include "/EgtDev/Include/EGkOffsetCurve3d.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
#define SAVECVRORIG 1
|
||||
#define SAVEOFFDIR 1
|
||||
#define SAVECYL 1
|
||||
#if SAVECVRORIG || SAVEOFFDIR || SAVECYL
|
||||
#include "/EgtDev/Include/EGkColor.h"
|
||||
#include "/EgtDev/Include/EGkGeoVector3d.h"
|
||||
vector<IGeoObj*> vGeo ;
|
||||
vector<Color> vCol ;
|
||||
#include "/EgtDev/Include/EGkGeoObjSave.h"
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool AdjustConcavePartsInPath( const ICurveComposite* pCrv, ICURVEPOVECTOR& vOffsetCrvs, const INTVECTOR& vFlag, double dRad) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
OffsetCurve3d::~OffsetCurve3d( void)
|
||||
{
|
||||
Reset() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OffsetCurve3d::Reset( void)
|
||||
{
|
||||
for ( auto& pCrv : m_CrvLst) {
|
||||
if ( pCrv != nullptr) {
|
||||
delete pCrv ;
|
||||
pCrv = nullptr ;
|
||||
}
|
||||
}
|
||||
m_CrvLst.clear() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OffsetCurve3d::Make( const PolyLine& PL, const VCT3DVECTOR& vOffDir, double dOffDist, int nType)
|
||||
{
|
||||
// pulisco tutto
|
||||
Reset() ;
|
||||
PtrOwner<CurveComposite> pCrv( CreateBasicCurveComposite()) ;
|
||||
if ( ! pCrv->FromPolyLine( PL))
|
||||
return false ;
|
||||
|
||||
#if SAVECVRORIG
|
||||
vGeo.push_back( pCrv->Clone()) ;
|
||||
vCol.push_back( AQUA) ;
|
||||
Point3d ptBase ; PL.GetFirstPoint( ptBase) ;
|
||||
for ( int i = 0 ; i < ssize( vOffDir) ; ++i) {
|
||||
IGeoVector3d* pVec = CreateGeoVector3d() ;
|
||||
pVec->Set( vOffDir[i] * dOffDist, ptBase) ;
|
||||
PL.GetNextPoint( ptBase) ;
|
||||
vGeo.push_back( pVec) ;
|
||||
vCol.push_back( BLUE) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
// verifico se la curva è un segmento di retta
|
||||
bool bIsLine = PL.GetPointNbr() == 2 ;
|
||||
if ( bIsLine) {
|
||||
// faccio l'offset di una linea
|
||||
return true ;
|
||||
}
|
||||
|
||||
// se offset nullo, copio la curva ed esco
|
||||
if ( abs( dOffDist) < 10 * EPS_SMALL) {
|
||||
PtrOwner<CurveComposite> pCopy( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCopy) || ! pCopy->CopyFrom( pCrv))
|
||||
return false ;
|
||||
// unisco parti allineate (tranne gli estremi)
|
||||
pCopy->MergeCurves( 10 * EPS_SMALL, ANG_TOL_STD_DEG, false) ;
|
||||
// sposto in lista
|
||||
m_CrvLst.push_back( Release( pCopy)) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
// elimino tratti molto corti
|
||||
if ( ! RemoveCurveSmallParts( pCrv, m_dLinTol))
|
||||
return false ;
|
||||
|
||||
bool bClosed = pCrv->IsClosed() ;
|
||||
|
||||
INTVECTOR vFlag ;
|
||||
vFlag.push_back( OffsetCurve3d::AngType::ANG_STR) ;
|
||||
const ICurve* pSubCrv = pCrv->GetFirstCurve() ;
|
||||
for ( int i = 1 ; i < pCrv->GetCurveCount() ; ++i) {
|
||||
pSubCrv = pCrv->GetNextCurve() ;
|
||||
Vector3d vtDirCurr ; pSubCrv->GetStartDir( vtDirCurr) ;
|
||||
int nFlag = vtDirCurr * vOffDir[i] > 0 ? OffsetCurve3d::AngType::ANG_SMOOTH_CONC : OffsetCurve3d::AngType::ANG_STR ;
|
||||
vFlag.push_back( nFlag) ;
|
||||
}
|
||||
|
||||
double dRadCorr ;
|
||||
Point3d ptPrev ; pCrv->GetStartPoint( ptPrev) ;
|
||||
ptPrev += vOffDir[0] * dOffDist ;
|
||||
Vector3d vtNormPrev ;
|
||||
Vector3d vtCorrPrev ;
|
||||
Vector3d vtTangPrev ;
|
||||
Vector3d vtDirPrev ; pCrv->GetStartDir( vtDirPrev) ;
|
||||
const ICurve* pCrvPrev = pCrv->GetFirstCurve() ;
|
||||
const ICurve* pCrvCurr ;
|
||||
vector<PtrOwner<ICurve>> vOffsetCrvs ;
|
||||
for ( int i = 1 ; i < pCrv->GetCurveCount() ; ++i) {
|
||||
pCrvCurr = pCrv->GetNextCurve() ;
|
||||
Vector3d vtOffDir = vOffDir[i] ;
|
||||
Vector3d vtDirCurr ; pCrvCurr->GetStartDir( vtDirCurr) ;
|
||||
pCrvPrev->GetStartDir( vtDirPrev) ;
|
||||
Vector3d vtTang = Media( vtDirCurr, vtDirPrev) ;
|
||||
vtTang.Normalize() ;
|
||||
Vector3d vtNorm = vtOffDir ;
|
||||
vtNorm.Rotate( vtTang, -90) ;
|
||||
//Vector3d vtCorr = vtTang ^ vtNorm ; vtCorr.Normalize() ;
|
||||
// devo invertire vtCorr??? se sì, quando?/////////////////////////////////////////
|
||||
Vector3d vtCorr = vtOffDir ;
|
||||
double dCorrK = 1 ;
|
||||
if ( vFlag[i] == OffsetCurve3d::AngType::ANG_CONC) {
|
||||
double dHalfAlfa = acos( vtTang * vtTangPrev) ;
|
||||
dCorrK = 1 / sin( 90 - dHalfAlfa) ;
|
||||
}
|
||||
|
||||
Point3d ptP ; pCrvCurr->GetStartPoint( ptP) ;
|
||||
dRadCorr = dOffDist ;
|
||||
ptP = ptP + dRadCorr * dCorrK * vtCorr ;
|
||||
// se secondo punto di angolo esterno di fianco, inserisco movimenti intermedi
|
||||
if ( vFlag[i] == OffsetCurve3d::AngType::ANG_CVEX && vFlag[i-1] == OffsetCurve3d::AngType::ANG_CVEX) {
|
||||
double dAlfa = acos( vtTang * vtTangPrev) ;
|
||||
double dDelta = dOffDist * tan( dAlfa / 4) ;
|
||||
Point3d ptAdd1 = ptPrev + dDelta * vtTangPrev ;
|
||||
ICurveLine* pCL1 = CreateBasicCurveLine() ;
|
||||
pCL1->Set( ptPrev, ptAdd1) ;
|
||||
vOffsetCrvs.emplace_back( pCL1) ;
|
||||
Point3d ptAdd2 = ptP - dDelta * vtTang ;
|
||||
ICurveLine* pCL2 = CreateBasicCurveLine() ;
|
||||
pCL2->Set( ptAdd1, ptAdd2) ;
|
||||
vOffsetCrvs.emplace_back( pCL2) ;
|
||||
ptPrev = ptAdd2 ;
|
||||
}
|
||||
|
||||
//// se punto di angolo interno di fianco, elimino eventuali movimenti precedenti invertiti
|
||||
//if ( vFlag[i] == OffsetCurve3d::AngType::ANG_CVEX == 3) {
|
||||
// local nLastId = EgtGetLastInGroup( nClPathId)
|
||||
// while nLastId do
|
||||
// local vtMlast = ptP - EgtEP( nLastId, GDB_ID.ROOT) ; vtMlast:normalize()
|
||||
// if vtMlast * vtGpre < 0.5 then
|
||||
// ptPpre = EgtSP( nLastId, GDB_ID.ROOT)
|
||||
// EgtErase( nLastId)
|
||||
// else
|
||||
// break
|
||||
// end
|
||||
// nLastId = EgtGetLastInGroup( nClPathId)
|
||||
// end
|
||||
//}
|
||||
|
||||
//// se appena dopo angolo interno di fianco, verifico se da aggiungere
|
||||
//bool bToAdd = true
|
||||
//if ( nFlpre == 3 and abs( dSideAng) > GEO.EPS_ANG_SMALL) {
|
||||
// local vtMove = ptP - ptPpre ; vtMove:normalize()
|
||||
// if vtMove * vtTang < 0.5 then
|
||||
// bToAdd = false
|
||||
// end
|
||||
//}
|
||||
|
||||
// aggiungo tratto
|
||||
ICurveLine* pCL = CreateBasicCurveLine() ;
|
||||
pCL->Set( ptPrev, ptP) ;
|
||||
vOffsetCrvs.emplace_back( pCL) ;
|
||||
// aggiorno punto precedente
|
||||
ptPrev = ptP ;
|
||||
vtNormPrev = vtNorm ;
|
||||
vtCorrPrev = vtCorr ;
|
||||
vtTangPrev = vtTang ;
|
||||
vtDirPrev = vtDirCurr ;
|
||||
}
|
||||
|
||||
//// qui faccio la correzione per gli angoli interni
|
||||
//AdjustConcavePartsInPath( pCrv, vOffsetCrvs, vFlag, dOffDist) ;
|
||||
|
||||
#if SAVECVRORIG || SAVEOFFDIR || SAVECYL
|
||||
SaveGeoObj( vGeo, vCol, "C:\\Temp\\curve offset 3d\\crvoffset.nge") ;
|
||||
#endif
|
||||
|
||||
PtrOwner<ICurveComposite> pCrvOffset( CreateBasicCurveComposite()) ;
|
||||
for ( int i = 0 ; i < ssize( vOffsetCrvs) ; ++i) {
|
||||
if ( ! pCrvOffset->AddCurve( Release( vOffsetCrvs[i])))
|
||||
return false ;
|
||||
}
|
||||
m_CrvLst.push_back( Release( pCrvOffset)) ;
|
||||
|
||||
return true ;
|
||||
|
||||
|
||||
// raccordi
|
||||
|
||||
// angoli interni
|
||||
|
||||
// angoli esterni
|
||||
|
||||
// auto intersezioni
|
||||
|
||||
//// sesto passo : se curva aperta, elimino i tratti che stanno nella circonferenza di offset dei punti estremi
|
||||
|
||||
//// ottavo passo : concateno i percorsi risultanti (senza cambiare verso)
|
||||
|
||||
//// nono passo : se con smusso o estensione, sostituisco i fillet con questi
|
||||
|
||||
//// ordino le curve in ordine decrescente di lunghezza
|
||||
//if ( m_CrvLst.size() > 1) {
|
||||
// for ( auto pCrv : m_CrvLst) {
|
||||
// double dLen ;
|
||||
// if ( pCrv->GetLength( dLen))
|
||||
// pCrv->SetTempProp( int( 1000 * dLen)) ;
|
||||
// else
|
||||
// pCrv->SetTempProp( 0) ;
|
||||
// }
|
||||
// m_CrvLst.sort( []( const ICurve* pA, const ICurve* pB) { return ( pA->GetTempProp() > pB->GetTempProp()) ; }) ;
|
||||
//}
|
||||
|
||||
//// se originale era chiusa, verifico le risultanti e se necessario cerco di chiuderle
|
||||
//if ( bClosed) {
|
||||
// for ( auto pCrv : m_CrvLst) {
|
||||
// CurveComposite* pCrvCo = GetBasicCurveComposite( pCrv) ;
|
||||
// if ( pCrvCo != nullptr)
|
||||
// pCrvCo->Close() ;
|
||||
// }
|
||||
//}
|
||||
|
||||
//return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
OffsetCurve3d::GetCurve( void)
|
||||
{
|
||||
return GetLongerCurve() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
OffsetCurve3d::GetLongerCurve( void)
|
||||
{
|
||||
if ( m_CrvLst.empty())
|
||||
return nullptr ;
|
||||
// le curve sono ordinate in senso decrescente di lunghezza
|
||||
ICurve* pCrv = m_CrvLst.front() ;
|
||||
m_CrvLst.pop_front() ;
|
||||
return pCrv ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
OffsetCurve3d::GetShorterCurve( void)
|
||||
{
|
||||
if ( m_CrvLst.empty())
|
||||
return nullptr ;
|
||||
// le curve sono ordinate in senso decrescente di lunghezza
|
||||
ICurve* pCrv = m_CrvLst.back() ;
|
||||
m_CrvLst.pop_back() ;
|
||||
return pCrv ;
|
||||
}
|
||||
|
||||
struct Cyl {
|
||||
Cyl( void): frCyl( GLOB_FRM), dH( 0.), dRad( 0.) {;} ;
|
||||
Cyl( const Frame3d& _frCyl, double _dH, double _dRad, double _dLinTol) :
|
||||
frCyl( _frCyl), dH( _dH), dRad( _dRad) { ;}
|
||||
Cyl( const Point3d& _ptBase, const Vector3d& vtZ, double _dH, double _dRad, double _dLinTol) :
|
||||
dH( _dH), dRad( _dRad){
|
||||
frCyl.Set( _ptBase, vtZ); }
|
||||
public :
|
||||
Frame3d frCyl ;
|
||||
public:
|
||||
double dH ;
|
||||
double dRad ;
|
||||
};
|
||||
|
||||
typedef vector<Cyl> CYLVECT ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IsPointInsideCylinder( const Point3d& ptTest, const Cyl& offCyl)
|
||||
{
|
||||
Point3d ptTestLoc = ptTest ; ptTestLoc.ToLoc( offCyl.frCyl) ;
|
||||
if ( ptTestLoc.z > offCyl.dH || ptTestLoc.z < 0)
|
||||
return false ;
|
||||
double dDist = ptTestLoc.x * ptTestLoc.x + ptTestLoc.y * ptTestLoc.y ;
|
||||
double dRadSq = offCyl.dRad * offCyl.dRad ;
|
||||
if ( dDist > dRadSq)
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool
|
||||
AdjustConcavePartsInPath( const ICurveComposite* pCrv, ICURVEPOVECTOR& vOffsetCrvs, const INTVECTOR& vFlag, double dRad)
|
||||
{
|
||||
const double dLinTol = 5 * EPS_SMALL ;
|
||||
INTVECTOR vErase ;
|
||||
for ( int i = 0 ; i < ssize( vOffsetCrvs) ; ++i) {
|
||||
int nFlag = vFlag[i] ;
|
||||
if ( nFlag == OffsetCurve3d::AngType::ANG_SMOOTH_CONC) {
|
||||
// scorro i prossimi finchè trovo la fine della zona concava
|
||||
INTVECTOR vLines ;
|
||||
while ( nFlag == OffsetCurve3d::AngType::ANG_SMOOTH_CONC) {
|
||||
vLines.push_back( i) ;
|
||||
++i ;
|
||||
nFlag = vFlag[i] ;
|
||||
}
|
||||
CYLVECT vCyl ;
|
||||
// creo un cilindro della dimensione del raggio
|
||||
for ( int j = 0 ; j < ssize( vLines) ; ++j) {
|
||||
const ICurve* pSubCrv = pCrv->GetCurve( vLines[j]) ;
|
||||
Point3d ptStart, ptEnd ;
|
||||
pSubCrv->GetStartPoint( ptStart) ;
|
||||
pSubCrv->GetEndPoint( ptEnd) ;
|
||||
Vector3d vtHeight = ptEnd - ptStart ; vtHeight.Normalize() ;
|
||||
double dHeight = vtHeight.Len() ;
|
||||
vCyl.emplace_back( ptStart, vtHeight, dHeight, dRad, dLinTol) ;
|
||||
}
|
||||
|
||||
// controllo l'end di ogni linea per verificare se sta nel cilindro definito da uno degli altri tratti
|
||||
// controllo tutto i punti
|
||||
bool bErasedSomePart = false ;
|
||||
bool bErasedPrev = false ;
|
||||
INTVECTOR vInters ;
|
||||
for ( int j = 0 ; j < ssize( vLines) ; ++j) {
|
||||
Point3d ptStart, ptEnd ;
|
||||
const ICurve* pSubCrv = pCrv->GetCurve( vLines[j]) ;
|
||||
if ( pSubCrv == nullptr)
|
||||
return false ;
|
||||
pSubCrv->GetEndPoint( ptEnd) ;
|
||||
pSubCrv->GetStartPoint( ptStart) ;
|
||||
// se stanno in uno dei cilindri degli altri tratti della zona concava
|
||||
for ( int k = 0 ; k < ssize( vLines) ; ++k) {
|
||||
if ( j == k)
|
||||
continue ;
|
||||
bool bToErase = IsPointInsideCylinder( ptEnd, vCyl[k]) ;
|
||||
if ( bErasedPrev && ! bToErase)
|
||||
bToErase = bToErase || IsPointInsideCylinder( ptStart, vCyl[k]) ;
|
||||
if ( bToErase) {
|
||||
bErasedSomePart = true ;
|
||||
bErasedPrev = true ;
|
||||
vInters.push_back( vLines[j]) ;
|
||||
if ( j < ssize( vLines) - 1)
|
||||
vInters.push_back( vLines[j+1]) ;
|
||||
++j ;
|
||||
break ;
|
||||
}
|
||||
else
|
||||
bErasedPrev = false ;
|
||||
}
|
||||
}
|
||||
if ( bErasedSomePart) {
|
||||
// calcolo le intersezioni effettive del primo e ultimo tratto cancellati con i cilindri che li hanno cancellati
|
||||
// controllo che effettivamente tutti i tratti cancellati siano consecutivi
|
||||
for ( int j = 1 ; j < ssize( vInters) ; ++j) {
|
||||
if ( vInters[j] != vInters[j-1] + 1)
|
||||
return false ;
|
||||
}
|
||||
for ( int j = 0 ; j < ssize( vInters) ; ++j) {
|
||||
// cancello i tratti intermedi
|
||||
if ( j > 0 && j < ssize( vInters) - 1) {
|
||||
vErase.push_back( vInters[j]) ;
|
||||
continue ;
|
||||
}
|
||||
// per il primo e ultimo controllo le intersezioni con tutti i cilindri
|
||||
ICurve* pCL = vOffsetCrvs[vInters[j]] ;
|
||||
Point3d ptStart ; pCL->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ; pCL->GetStartDir( vtStart) ;
|
||||
double dLen ; pCL->GetLength( dLen) ;
|
||||
double dUTrim = ( j == 0 ? INFINITO : 0) ;
|
||||
Point3d ptTrim = P_INVALID ;
|
||||
for ( int k = 0 ; k < ssize( vCyl) ; ++k) {
|
||||
if ( vInters[j] == k)
|
||||
continue ;
|
||||
Point3d ptInt1 = P_INVALID, ptInt2 = P_INVALID ;
|
||||
double dU1, dU2 ;
|
||||
Vector3d vtN1, vtN2 ;
|
||||
if ( IntersLineCyl( ptStart, vtStart * dLen, vCyl[k].frCyl, vCyl[k].dH, vCyl[k].dRad, false, false, dU1, ptInt1, vtN1, dU2, ptInt2, vtN2, true)) {
|
||||
bool bUpdate = ( j == 0 ? dU1 < dUTrim : dU1 > dUTrim) ;
|
||||
bUpdate = bUpdate && ptInt1.IsValid() && dU1 > 0 && dU1 < 1 ;
|
||||
bUpdate = bUpdate && vtN1 * vtStart < 0 ;
|
||||
if ( bUpdate) {
|
||||
dUTrim = dU1 ;
|
||||
ptTrim = ptInt1 ;
|
||||
}
|
||||
bUpdate = ( j == 0 ? dU2 < dUTrim : dU2 > dUTrim) ;
|
||||
bUpdate = bUpdate && ptInt2.IsValid() && dU2 > 0 && dU2 < 1 ;
|
||||
bUpdate = bUpdate && vtN2 * vtStart > 0 ;
|
||||
if ( bUpdate) {
|
||||
dUTrim = dU2 ;
|
||||
ptTrim = ptInt2 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ptTrim.IsValid()) {
|
||||
if ( j == 0) {
|
||||
pCL->ModifyEnd( ptTrim) ;
|
||||
double dNewLen ; pCL->GetLength( dNewLen) ;
|
||||
if ( dNewLen < 0.1 && vInters[0] != 0) { // se fosse il primo allora potrei modificare il successivo
|
||||
int nPrev = vInters[0] - 1 ;
|
||||
vErase.push_back( vInters[0]) ;
|
||||
vInters[0] = nPrev ;
|
||||
ICurve* pCLPrev = vOffsetCrvs[nPrev] ;
|
||||
pCLPrev->ModifyEnd( ptTrim) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
pCL->ModifyStart( ptTrim) ;
|
||||
double dNewLen ; pCL->GetLength( dNewLen) ;
|
||||
if ( dNewLen < 0.1 && vInters[j] != ssize( vOffsetCrvs) - 1) { // se fosse l'ultima curva allora potrei modificare la precedente
|
||||
int nNext = vInters[j] + 1 ;
|
||||
vErase.push_back( vInters[j]) ;
|
||||
vInters[j] = nNext ;
|
||||
ICurve* pCLNext = vOffsetCrvs[nNext] ;
|
||||
pCLNext->ModifyStart( ptTrim) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
i = vLines.back() ;
|
||||
}
|
||||
}
|
||||
|
||||
// scorro tutto il vettore delle linee di offset e unisco aggiungendo una linea dove ne ho cancellate
|
||||
for ( int i = 0 ; i < ssize( vOffsetCrvs) - 1 ; ++i) {
|
||||
Point3d ptEndCurr, ptStartNext ;
|
||||
vOffsetCrvs[i]->GetEndPoint( ptEndCurr) ;
|
||||
vOffsetCrvs[i+1]->GetStartPoint( ptStartNext) ;
|
||||
if ( ! AreSamePointApprox( ptEndCurr, ptStartNext)) {
|
||||
ICurveLine* pCL = CreateBasicCurveLine() ;
|
||||
pCL->Set( ptEndCurr, ptStartNext) ;
|
||||
PtrOwner<ICurve> pCrvL( pCL) ;
|
||||
vOffsetCrvs.insert( vOffsetCrvs.begin() + i + 1, std::move(pCrvL)) ;
|
||||
++i ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
+2
-8
@@ -1991,17 +1991,11 @@ MatchPolyLinesAddingPoints( const PolyLine& PL1, const PolyLine& PL2, int nType,
|
||||
nAddedSpan = 0 ;
|
||||
nCrv1 = 0 ;
|
||||
nCrv2 = 0 ;
|
||||
bool bLast1 = false ;
|
||||
bool bLast2 = false ;
|
||||
while ( nAddedSpan < nPnt) {
|
||||
if ( nCrv1 >= nPnt1) {
|
||||
if ( nCrv1 >= nPnt1)
|
||||
nCrv1 = nPnt1 - 1 ;
|
||||
bLast1 = true ;
|
||||
}
|
||||
if ( nCrv2 >= nPnt2) {
|
||||
if ( nCrv2 >= nPnt2)
|
||||
nCrv2 = nPnt2 - 1 ;
|
||||
bLast2 = true ;
|
||||
}
|
||||
bool bRep1 = vbRep1[nCrv1] ;
|
||||
bool bRep2 = vbRep2[nCrv2] ;
|
||||
const ICurve* pSubCrv1 = cc1.GetCurve( nCrv1) ;
|
||||
|
||||
+213
-80
@@ -40,6 +40,7 @@ const int P5AX_CVEX = 2 ; // su angolo convesso
|
||||
const int P5AX_CONC = 3 ; // in angolo concavo
|
||||
const int P5AX_BEFORE_CONC = 4 ; // adiacente ad angolo concavo
|
||||
const int P5AX_AFTER_CONC = 5 ; // adiacente ad angolo concavo
|
||||
const int P5AX_SMOOTH_CONC = 6 ; // zona concava curva, senza spigolo netto
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static double
|
||||
@@ -64,6 +65,7 @@ PointsInTolerance( const PNT5AXVECTOR& vPt5ax, int nPrec, int nCurr, int nNext,
|
||||
static bool
|
||||
AddPointsOnCorners( PNT5AXVECTOR& vPt5ax)
|
||||
{
|
||||
const double dSinSmallAngle = sin( 0 * DEGTORAD) ;
|
||||
for ( int i = 1 ; i < ssize( vPt5ax) ; ++ i) {
|
||||
// precedente
|
||||
int j = i - 1 ;
|
||||
@@ -79,18 +81,24 @@ AddPointsOnCorners( PNT5AXVECTOR& vPt5ax)
|
||||
Point3d ptInt ;
|
||||
if ( IntersLinePlane( ptEdge, vtEdge, 1, plPlane3, ptInt, false) == ILPT_YES) {
|
||||
// verifico se spigolo convesso o concavo
|
||||
bool bConvex ;
|
||||
if ( ! AreSamePointApprox( ptInt, vPt5ax[j].ptP))
|
||||
bConvex = ( ( vPt5ax[j].vtDir1 ^ ( ptInt - vPt5ax[j].ptP)) * vtEdge > 0) ;
|
||||
else
|
||||
bConvex = (( vPt5ax[i].vtDir1 ^ ( ptInt - vPt5ax[i].ptP)) * vtEdge < 0) ;
|
||||
bool bConvex = (vPt5ax[i].ptP - vPt5ax[j].ptP) * vPt5ax[j].vtDir1 < 0 ;
|
||||
bool bValidInters = true ;
|
||||
if ( i > 2) {
|
||||
int k = i - 2 ;
|
||||
// verifico la concavità anche tornando indietro lungo la linea
|
||||
if ( ( ( vPt5ax[k].ptP - vPt5ax[j].ptP) * vPt5ax[i].vtDir1 < 0) != bConvex) {
|
||||
LOG_WARN( GetEGkLogger(), "La superficie su cui si sta proiettando la curva ha delle normali incoerenti")
|
||||
return false ;
|
||||
}
|
||||
// verifico che l'intersezione sia tra i e j e non prima di j
|
||||
bValidInters = ( ptInt - vPt5ax[j].ptP) * ( vPt5ax[j].ptP - vPt5ax[k].ptP) > 0 ;
|
||||
}
|
||||
// se convesso, metto due punti con direzione appena prima e appena dopo
|
||||
if ( bConvex) {
|
||||
Vector3d vtLine1 = ptInt - vPt5ax[j].ptP ; double dLen1 = vtLine1.Len() ;
|
||||
Vector3d vtLine2 = vPt5ax[i].ptP - ptInt ; double dLen2 = vtLine2.Len() ;
|
||||
if ( dLen1 > 2 * EPS_SMALL) {
|
||||
if ( dLen1 > 10 * EPS_SMALL && bValidInters) {
|
||||
Point5ax Pt5ax ;
|
||||
Pt5ax.ptP = ptInt - vtLine1 / dLen1 * 2 * EPS_SMALL ;
|
||||
Pt5ax.vtDir1 = vPt5ax[j].vtDir1 ;
|
||||
Pt5ax.vtDir2 = vPt5ax[j].vtDir2 ;
|
||||
Pt5ax.vtDirU = vPt5ax[j].vtDirU ;
|
||||
@@ -102,9 +110,14 @@ AddPointsOnCorners( PNT5AXVECTOR& vPt5ax)
|
||||
}
|
||||
else
|
||||
vPt5ax[j].nFlag = P5AX_CVEX ;
|
||||
if ( dLen2 > 2 * EPS_SMALL) {
|
||||
if ( dLen2 > 10 * EPS_SMALL) {
|
||||
Point5ax Pt5ax ;
|
||||
Pt5ax.ptP = ptInt + vtLine2 / dLen2 * 2 * EPS_SMALL ;
|
||||
if ( bValidInters)
|
||||
Pt5ax.ptP = ptInt + vtLine2 / dLen2 * 2 * EPS_SMALL ;
|
||||
else {
|
||||
Vector3d vtNewLine = vPt5ax[i].ptP - vPt5ax[j].ptP ; vtNewLine.Normalize() ;
|
||||
Pt5ax.ptP = vPt5ax[j].ptP + vtNewLine * 2 * EPS_SMALL ;
|
||||
}
|
||||
Pt5ax.vtDir1 = vPt5ax[i].vtDir1 ;
|
||||
Pt5ax.vtDir2 = vPt5ax[i].vtDir2 ;
|
||||
Pt5ax.vtDirU = vPt5ax[i].vtDirU ;
|
||||
@@ -133,6 +146,21 @@ AddPointsOnCorners( PNT5AXVECTOR& vPt5ax)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// guardo se la proiezione il tratto successivo, lungo la normale precedente + maggiore di un angolo minimo ( angolo interno smooth)
|
||||
Vector3d vtDirNext = vPt5ax[i].ptP - vPt5ax[j].ptP ;
|
||||
vtDirNext.Normalize() ;
|
||||
if ( vtDirNext * vPt5ax[j].vtDir1 > dSinSmallAngle) {
|
||||
// se concavo senza spigolo netto segnalo zona concava smooth
|
||||
vPt5ax[i].nFlag = P5AX_SMOOTH_CONC ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// riscorro tutto il vettore per vedere se ho creato delle zone concave smooth frammentate (separate solo da un tratto non classificato concavo), che quindi uniformo
|
||||
for ( int i = 1 ; i < ssize( vPt5ax) - 1 ; ++ i) {
|
||||
if ( vPt5ax[i].nFlag != P5AX_SMOOTH_CONC && vPt5ax[i-1].nFlag == P5AX_SMOOTH_CONC && vPt5ax[i+1].nFlag == P5AX_SMOOTH_CONC)
|
||||
vPt5ax[i].nFlag = P5AX_SMOOTH_CONC ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -377,8 +405,10 @@ ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf,
|
||||
}
|
||||
|
||||
// se richiesto, inserimento punti intermedi in presenza di spigoli
|
||||
if ( bSharpEdges)
|
||||
AddPointsOnCorners( vPt5ax) ;
|
||||
if ( bSharpEdges) {
|
||||
if ( ! AddPointsOnCorners( vPt5ax))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// rimozione punti in eccesso rispetto alle tolleranze
|
||||
RemovePointsInExcess( vPt5ax, dLinTol, dMaxSegmLen, bSharpEdges) ;
|
||||
@@ -393,7 +423,7 @@ typedef std::vector<IntersParLinesSurfTm*> INTPARLINESTMPVECTOR ;
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const Frame3d& frRefLine, const INTPARLINESTMPVECTOR& vpIntPLSTM,
|
||||
double dPar, Point5ax& Pt5ax)
|
||||
double dPar, bool bFromVsTo, Point5ax& Pt5ax)
|
||||
{
|
||||
// intersezione retta di proiezione con superfici (conservo l'intersezione più alta)
|
||||
Point3d ptL = GetToLoc( ptP, frRefLine) ;
|
||||
@@ -402,23 +432,48 @@ ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const Frame
|
||||
for ( int i = 0 ; i < ssize( vpIntPLSTM) ; ++ 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 = ssize( vIntRes) - 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) {
|
||||
// se dalla direzione
|
||||
if ( bFromVsTo) {
|
||||
// cerco la prima intersezione valida a partire dall'ultima (è la più alta)
|
||||
int nI = ssize( vIntRes) - 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 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// altrimenti verso la direzione
|
||||
else {
|
||||
// cerco la prima intersezione valida a partire dalla prima (è la più alta)
|
||||
int nI = 0 ;
|
||||
while ( nI < ssize( vIntRes) && abs( vIntRes[nI].dCosDN) < COS_ANG_LIM)
|
||||
++nI ;
|
||||
// se trovata
|
||||
if ( nI < ssize( vIntRes)) {
|
||||
if ( nInd < 0) {
|
||||
IntRes = vIntRes[nI] ;
|
||||
nInd = i ;
|
||||
}
|
||||
else {
|
||||
double dUref = (( IntRes.nILTT == ILTT_SEGM || IntRes.nILTT == ILTT_SEGM_ON_EDGE) ? IntRes.dU : IntRes.dU2) ;
|
||||
double dU = (( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE) ? vIntRes[nI].dU : vIntRes[nI].dU2) ;
|
||||
if ( dU < dUref) {
|
||||
IntRes = vIntRes[nI] ;
|
||||
nInd = i ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -455,7 +510,7 @@ ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const Frame
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const Vector3d& vtDir,
|
||||
double dLinTol, double dMaxSegmLen, bool bSharpEdges, PNT5AXVECTOR& vPt5ax)
|
||||
double dLinTol, double dMaxSegmLen, bool bSharpEdges, bool bFromVsTo, PNT5AXVECTOR& vPt5ax)
|
||||
{
|
||||
// sistemazioni per tipo di superficie
|
||||
CISRFTMPVECTOR vpSurfTm ;
|
||||
@@ -521,7 +576,7 @@ ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const Vect
|
||||
while ( bFound) {
|
||||
// se trovo proiezione, la salvo
|
||||
Point5ax Pt5ax ;
|
||||
if ( ProjectPointOnSurf( ptP, vpSurfTm, frRefLine, vpIntPLSTM, dPar, Pt5ax))
|
||||
if ( ProjectPointOnSurf( ptP, vpSurfTm, frRefLine, vpIntPLSTM, dPar, bFromVsTo, Pt5ax))
|
||||
vPt5ax.emplace_back( Pt5ax) ;
|
||||
// passo al successivo
|
||||
bFound = PL.GetNextUPoint( &dPar, &ptP) ;
|
||||
@@ -543,7 +598,8 @@ ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const Vect
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const IGeoPoint3d& gpRef, double dPar, Point5ax& Pt5ax)
|
||||
ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const IGeoPoint3d& gpRef, double dPar, bool bFromVsTo,
|
||||
Point5ax& Pt5ax)
|
||||
{
|
||||
// punto di riferimento
|
||||
Point3d ptMin = gpRef.GetPoint() ;
|
||||
@@ -558,23 +614,48 @@ ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const IGeoP
|
||||
for ( int i = 0 ; i < ssize( vpStm) ; ++ 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 = ssize( vIntRes) - 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) {
|
||||
// se dal punto
|
||||
if ( bFromVsTo) {
|
||||
// cerco la prima intersezione valida a partire dall'ultima (è la più alta)
|
||||
int nI = ssize( vIntRes) - 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 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// altrimenti verso il punto
|
||||
else {
|
||||
// cerco la prima intersezione valida a partire dalla prima (è la più alta)
|
||||
int nI = 0 ;
|
||||
while ( nI < ssize( vIntRes) && abs( vIntRes[nI].dCosDN) < COS_ANG_LIM)
|
||||
++nI ;
|
||||
// se trovata
|
||||
if ( nI < ssize( vIntRes)) {
|
||||
if ( nInd < 0) {
|
||||
IntRes = vIntRes[nI] ;
|
||||
nInd = i ;
|
||||
}
|
||||
else {
|
||||
double dUref = (( IntRes.nILTT == ILTT_SEGM || IntRes.nILTT == ILTT_SEGM_ON_EDGE) ? IntRes.dU : IntRes.dU2) ;
|
||||
double dU = (( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE) ? vIntRes[nI].dU : vIntRes[nI].dU2) ;
|
||||
if ( dU < dUref) {
|
||||
IntRes = vIntRes[nI] ;
|
||||
nInd = i ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -612,7 +693,7 @@ ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const IGeoP
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const IGeoPoint3d& gpRef,
|
||||
double dLinTol, double dMaxSegmLen, bool bSharpEdges, PNT5AXVECTOR& vPt5ax)
|
||||
double dLinTol, double dMaxSegmLen, bool bSharpEdges, bool bFromVsTo, PNT5AXVECTOR& vPt5ax)
|
||||
{
|
||||
// sistemazioni per tipo di superficie
|
||||
CISRFTMPVECTOR vpSurfTm ;
|
||||
@@ -663,7 +744,7 @@ ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const IGeo
|
||||
while ( bFound) {
|
||||
// se trovo proiezione, la salvo
|
||||
Point5ax Pt5ax ;
|
||||
if ( ProjectPointOnSurf( ptP, vpSurfTm, gpRef, dPar, Pt5ax))
|
||||
if ( ProjectPointOnSurf( ptP, vpSurfTm, gpRef, dPar, bFromVsTo, Pt5ax))
|
||||
vPt5ax.emplace_back( Pt5ax) ;
|
||||
// passo al successivo
|
||||
bFound = PL.GetNextUPoint( &dPar, &ptP) ;
|
||||
@@ -681,7 +762,8 @@ ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const IGeo
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const ICurve& crRef, double dPar, Point5ax& Pt5ax)
|
||||
ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const ICurve& crRef, double dPar, bool bFromVsTo,
|
||||
Point5ax& Pt5ax)
|
||||
{
|
||||
// punto a minima distanza
|
||||
DistPointCurve dPC( ptP, crRef) ;
|
||||
@@ -699,23 +781,48 @@ ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const ICurv
|
||||
for ( int i = 0 ; i < ssize( vpStm) ; ++ 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 = ssize( vIntRes) - 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) {
|
||||
// se dalla curva
|
||||
if ( bFromVsTo) {
|
||||
// cerco la prima intersezione valida a partire dall'ultima (è la più alta)
|
||||
int nI = ssize( vIntRes) - 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 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// altrimenti verso la curva
|
||||
else {
|
||||
// cerco la prima intersezione valida a partire dalla prima (è la più alta)
|
||||
int nI = 0 ;
|
||||
while ( nI < ssize( vIntRes) && abs( vIntRes[nI].dCosDN) < COS_ANG_LIM)
|
||||
++nI ;
|
||||
// se trovata
|
||||
if ( nI < ssize( vIntRes)) {
|
||||
if ( nInd < 0) {
|
||||
IntRes = vIntRes[nI] ;
|
||||
nInd = i ;
|
||||
}
|
||||
else {
|
||||
double dUref = (( IntRes.nILTT == ILTT_SEGM || IntRes.nILTT == ILTT_SEGM_ON_EDGE) ? IntRes.dU : IntRes.dU2) ;
|
||||
double dU = (( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE) ? vIntRes[nI].dU : vIntRes[nI].dU2) ;
|
||||
if ( dU < dUref) {
|
||||
IntRes = vIntRes[nI] ;
|
||||
nInd = i ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -738,7 +845,7 @@ ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const ICurv
|
||||
// assegno valori al punto 5assi
|
||||
Pt5ax.ptP = ptInt ;
|
||||
Pt5ax.vtDir1 = vtN ;
|
||||
Pt5ax.vtDir2 = vtLine ;
|
||||
Pt5ax.vtDir2 = ( bFromVsTo ? vtLine : -vtLine) ;
|
||||
Pt5ax.vtDirU = V_NULL ;
|
||||
Pt5ax.vtDirV = V_NULL ;
|
||||
Pt5ax.dPar = dPar ;
|
||||
@@ -754,7 +861,7 @@ ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const ICurv
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const ICurve& crRef,
|
||||
double dLinTol, double dMaxSegmLen, bool bSharpEdges, PNT5AXVECTOR& vPt5ax)
|
||||
double dLinTol, double dMaxSegmLen, bool bSharpEdges, bool bFromVsTo, PNT5AXVECTOR& vPt5ax)
|
||||
{
|
||||
// Sistemazioni per tipo di superficie
|
||||
CISRFTMPVECTOR vpSurfTm ;
|
||||
@@ -805,7 +912,7 @@ ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const ICur
|
||||
while ( bFound) {
|
||||
// se trovo proiezione, la salvo
|
||||
Point5ax Pt5ax ;
|
||||
if ( ProjectPointOnSurf( ptP, vpSurfTm, crRef, dPar, Pt5ax))
|
||||
if ( ProjectPointOnSurf( ptP, vpSurfTm, crRef, dPar, bFromVsTo, Pt5ax))
|
||||
vPt5ax.emplace_back( Pt5ax) ;
|
||||
// passo al successivo
|
||||
bFound = PL.GetNextUPoint( &dPar, &ptP) ;
|
||||
@@ -823,7 +930,8 @@ ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const ICur
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const SurfTriMesh& stmRef, double dPar, Point5ax& Pt5ax)
|
||||
ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const SurfTriMesh& stmRef, double dPar, bool bFromVsTo,
|
||||
Point5ax& Pt5ax)
|
||||
{
|
||||
// punto sulla superficie guida a minima distanza
|
||||
DistPointSurfTm dPS( ptP, stmRef) ;
|
||||
@@ -850,23 +958,48 @@ ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const SurfT
|
||||
for ( int i = 0 ; i < ssize( vpStm) ; ++ 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 = ssize( vIntRes) - 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) {
|
||||
// se dalla superficie
|
||||
if ( bFromVsTo) {
|
||||
// cerco la prima intersezione valida a partire dall'ultima (è la più alta)
|
||||
int nI = ssize( vIntRes) - 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 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// altrimenti verso la superficie
|
||||
else {
|
||||
// cerco la prima intersezione valida a partire dalla prima (è la più alta)
|
||||
int nI = 0 ;
|
||||
while ( nI < ssize( vIntRes) && abs( vIntRes[nI].dCosDN) < COS_ANG_LIM)
|
||||
++nI ;
|
||||
// se trovata
|
||||
if ( nI < ssize( vIntRes)) {
|
||||
if ( nInd < 0) {
|
||||
IntRes = vIntRes[nI] ;
|
||||
nInd = i ;
|
||||
}
|
||||
else {
|
||||
double dUref = (( IntRes.nILTT == ILTT_SEGM || IntRes.nILTT == ILTT_SEGM_ON_EDGE) ? IntRes.dU : IntRes.dU2) ;
|
||||
double dU = (( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE) ? vIntRes[nI].dU : vIntRes[nI].dU2) ;
|
||||
if ( dU < dUref) {
|
||||
IntRes = vIntRes[nI] ;
|
||||
nInd = i ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -911,7 +1044,7 @@ ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const SurfT
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const ISurf& sfRef,
|
||||
double dLinTol, double dMaxSegmLen, bool bSharpEdges, PNT5AXVECTOR& vPt5ax)
|
||||
double dLinTol, double dMaxSegmLen, bool bSharpEdges, bool bFromVsTo, PNT5AXVECTOR& vPt5ax)
|
||||
{
|
||||
// sistemazioni per tipo di superficie
|
||||
CISRFTMPVECTOR vpSurfTm ;
|
||||
@@ -983,7 +1116,7 @@ ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const ISur
|
||||
while ( bFound) {
|
||||
// se trovo proiezione, la salvo
|
||||
Point5ax Pt5ax ;
|
||||
if ( ProjectPointOnSurf( ptP, vpSurfTm, *pRefTm, dPar, Pt5ax))
|
||||
if ( ProjectPointOnSurf( ptP, vpSurfTm, *pRefTm, dPar, bFromVsTo, Pt5ax))
|
||||
vPt5ax.emplace_back( Pt5ax) ;
|
||||
// passo al successivo
|
||||
bFound = PL.GetNextUPoint( &dPar, &ptP) ;
|
||||
|
||||
@@ -92,11 +92,18 @@ RotationMinimizingFrame::GetFrameAtParam( const Frame3d& frAct, const double dPa
|
||||
Vector3d vtCurrR = frAct.VersX() ;
|
||||
Vector3d vtCurrT = frAct.VersZ() ;
|
||||
|
||||
// punto i-esimo sulla curva e suo vettore tangente
|
||||
// punto i-esimo sulla curva e suo vettore tangente medio
|
||||
Point3d ptNextM, ptNextP ;
|
||||
Vector3d vtNextM, vtNextP ;
|
||||
if ( ! m_pCrv->GetPointD1D2( dParNext, ICurve::FROM_MINUS, ptNextM, &vtNextM) ||
|
||||
! m_pCrv->GetPointD1D2( dParNext, ICurve::FROM_PLUS, ptNextP, &vtNextP) ||
|
||||
! vtNextM.Normalize() || ! vtNextP.Normalize())
|
||||
return false ;
|
||||
Point3d ptNext ;
|
||||
Vector3d vtNextT ;
|
||||
if ( ! m_pCrv->GetPointD1D2( dParNext, ICurve::FROM_MINUS, ptNext, &vtNextT) ||
|
||||
! vtNextT.Normalize())
|
||||
ptNext = Media( ptNextM, ptNextP) ;
|
||||
vtNextT = Media( vtNextM, vtNextP) ;
|
||||
if ( ! vtNextT.Normalize())
|
||||
return false ;
|
||||
|
||||
// controllo per casi degeneri
|
||||
|
||||
+2
-2
@@ -735,7 +735,7 @@ GetSurfBezierRuled( const ICurve* pCurve1, const ICurve* pCurve2, int nType, dou
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
ISurfBezier*
|
||||
GetSurfBezierRuledSmooth( const ICurve* pCurve1, const ICurve* pCurve2, double dSampleLen)
|
||||
GetSurfBezierRuledSmooth( const ICurve* pCurve1, const ICurve* pCurve2, BIPNTVECTOR& vSyncLines, double dSampleLen)
|
||||
{
|
||||
// verifica parametri
|
||||
if ( pCurve1 == nullptr || pCurve2 == nullptr)
|
||||
@@ -762,7 +762,7 @@ GetSurfBezierRuledSmooth( const ICurve* pCurve1, const ICurve* pCurve2, double d
|
||||
|
||||
// creo e setto la superficie trimesh
|
||||
PtrOwner<SurfBezier> pSbz( CreateBasicSurfBezier()) ;
|
||||
if ( IsNull( pSbz) || ! pSbz->CreateSmoothRuledByTwoCurves( pCC1, pCC2, dSampleLen))
|
||||
if ( IsNull( pSbz) || ! pSbz->CreateSmoothRuledByTwoCurves( pCC1, pCC2, dSampleLen, vSyncLines))
|
||||
return nullptr ;
|
||||
|
||||
// restituisco la superficie
|
||||
|
||||
+1120
-541
File diff suppressed because it is too large
Load Diff
+395
-229
@@ -52,11 +52,12 @@
|
||||
#define SAVEMATCHCURVES 0
|
||||
#define SAVEFAILEDTREE 0
|
||||
#define SAVELIMITSURF 0
|
||||
#define SAVEPACEDISO 1
|
||||
#define SAVEPACEDISO 0
|
||||
#if SAVEFAILEDTRIANGULATION || SAVEREBUILTISO || SAVERULEDISO || SAVERULEDGUIDEDISO || SAVEMATCHCURVES \
|
||||
|| SAVEFAILEDTREE || SAVELIMITSURF || SAVEPACEDISO
|
||||
#include "/EgtDev/Include/EGkGeoObjSave.h"
|
||||
std::vector<IGeoObj*> vGeo ;
|
||||
std::vector<Color> vCol ;
|
||||
#endif
|
||||
|
||||
using namespace std ;
|
||||
@@ -4501,55 +4502,6 @@ ChangeStartForClosed( PolyLine& plU0, PolyLine& plU1, ICurveComposite* pCrvU0, I
|
||||
return true ;
|
||||
}
|
||||
|
||||
static bool
|
||||
GetEdgeSplitByAngTol( const PolyLine& PL, double dAngTol, BOOLVECTOR& vEdgeSplit)
|
||||
{
|
||||
int nPoints = PL.GetPointNbr() ;
|
||||
vEdgeSplit.clear() ;
|
||||
vEdgeSplit.resize( nPoints) ;
|
||||
fill( vEdgeSplit.begin(), vEdgeSplit.end(), false) ;
|
||||
bool bClosed = PL.IsClosed() ;
|
||||
// Recupero l'insieme di punti associati alla PolyLine
|
||||
PNTVECTOR vPoints ; vPoints.reserve( nPoints) ;
|
||||
Point3d ptCurr = P_INVALID ;
|
||||
// aggiungo come primo punto il penultimo punto della polyline in modo da analizzare direttamente anche la chiusura ( se è una polyline chiusa)
|
||||
PL.GetLastPoint( ptCurr) ;
|
||||
PL.GetPrevPoint( ptCurr) ;
|
||||
vPoints.emplace_back( ptCurr) ;
|
||||
bool bFound = PL.GetFirstPoint( ptCurr) ;
|
||||
while ( bFound) {
|
||||
vPoints.emplace_back( ptCurr) ;
|
||||
bFound = PL.GetNextPoint( ptCurr) ;
|
||||
}
|
||||
Vector3d vtTanCurr = V_INVALID, vtTanNext = V_INVALID ;
|
||||
// cos della tolleranza angolare massima
|
||||
double dCosTol = cos( dAngTol * DEGTORAD) ;
|
||||
for ( int nP = 0 ; nP < nPoints - 2 ; ++ nP) {
|
||||
// Recupero il punto corrente e i due punti successivi
|
||||
Point3d& ptCurr = vPoints[nP] ;
|
||||
Point3d& ptNext = vPoints[nP + 1] ;
|
||||
Point3d& ptNextNext = vPoints[nP + 2] ;
|
||||
// Recupero i versori tangenti definiti dai tre punti ( ptCurr|ptNext e ptNext|ptNextNext)
|
||||
if ( nP == 0) {
|
||||
vtTanCurr = ptNext - ptCurr ;
|
||||
vtTanCurr.Normalize() ;
|
||||
}
|
||||
else
|
||||
vtTanCurr = vtTanNext ;
|
||||
vtTanNext = ptNextNext - ptNext ; vtTanNext.Normalize() ;
|
||||
// Calcolo il Coseno tra i due versori
|
||||
double dCos = vtTanCurr * vtTanNext ;
|
||||
// Se oltre la tolleranza allora ho incontrato un edge
|
||||
if ( dCos < dCosTol)
|
||||
vEdgeSplit[nP] = true ;
|
||||
}
|
||||
|
||||
if ( ! bClosed)
|
||||
vEdgeSplit[0] = false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
static bool
|
||||
GetEdgeSplitByAngTol( const ICurveComposite* pCC, double dAngTol, BOOLVECTOR& vEdgeSplit)
|
||||
{
|
||||
@@ -5896,15 +5848,31 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
return true ;
|
||||
}
|
||||
|
||||
// Struttura per Spigolo
|
||||
struct SharpEdge {
|
||||
double dParU ;
|
||||
Point3d ptEdge ;
|
||||
Vector3d vtTanPrev, vtTanAft ;
|
||||
Vector3d vtTanPrev, vtTanNext ;
|
||||
SharpEdge( double dU, const Point3d ptE, const Vector3d& vtTP, const Vector3d& vtTA)
|
||||
: dParU( dU), ptEdge( ptE), vtTanPrev( vtTP), vtTanAft( vtTA) {}
|
||||
: dParU( dU), ptEdge( ptE), vtTanPrev( vtTP), vtTanNext( vtTA) {}
|
||||
} ;
|
||||
typedef vector<SharpEdge> SHARPEDGEVECTOR ;
|
||||
|
||||
// Struttura per Punto a Curvatura Massima
|
||||
struct CurvaturePoint {
|
||||
double dParU ;
|
||||
Point3d ptCurvature ;
|
||||
Vector3d vtTanPrev, vtTanNext ;
|
||||
CurvaturePoint( double dU, const Point3d ptE, const Vector3d& vtTP, const Vector3d& vtTA)
|
||||
: dParU( dU), ptCurvature( ptE), vtTanPrev( vtTP), vtTanNext( vtTA) {}
|
||||
} ;
|
||||
typedef vector<SharpEdge> SHARPEDGEVECTOR ;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Calcolo delle Curve di Sync tra gli spigoli di una curva e l'altra curva nella sua integrità
|
||||
// [Dato un vettore di SharpEdge di una Curva di Bordo si calcola la Linea di Sincronizzazione tra ognuno di essi
|
||||
// e l'altra Curva di Bordo]
|
||||
// -> Restituisce un vettore di Linee di Sincronizzazione
|
||||
static bool
|
||||
CalcSyncPointFromEdge( const SHARPEDGEVECTOR& vSharpEdge, const ICurveComposite* pCompoSubEdge, const SHARPEDGEVECTOR& vSharpSubEdge,
|
||||
BIPNTVECTOR& vSyncLines)
|
||||
@@ -5919,13 +5887,20 @@ CalcSyncPointFromEdge( const SHARPEDGEVECTOR& vSharpEdge, const ICurveComposite*
|
||||
if ( vSharpEdge.empty())
|
||||
return true ;
|
||||
|
||||
// Se il numero di Spigoli coincide, allora li unisco sequenzialmente tra loro ( considerazione buona ???)
|
||||
if ( ssize( vSharpEdge) == ssize( vSharpSubEdge)) {
|
||||
for ( int i = 0 ; i < ssize( vSharpEdge) ; ++ i)
|
||||
vSyncLines.emplace_back( vSharpEdge[i].ptEdge, vSharpSubEdge[i].ptEdge) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// Scorro gli SharpEdges
|
||||
double dUPrevSubEdge = 0., dUCurrSubEdge = 0. ;
|
||||
for ( const SharpEdge& mySharpEdge : vSharpEdge) {
|
||||
|
||||
// Recupero il parametro sulla curva di sincronizzazione
|
||||
// --- Piano di taglio per punto a distanza minima
|
||||
IntersCurvePlane ICP( *pCompoSubEdge, mySharpEdge.ptEdge, Media( mySharpEdge.vtTanPrev, mySharpEdge.vtTanAft)) ;
|
||||
IntersCurvePlane ICP( *pCompoSubEdge, mySharpEdge.ptEdge, Media( mySharpEdge.vtTanPrev, mySharpEdge.vtTanNext)) ;
|
||||
int nIndParCloser = -1, nIndPointCloser = -1 ;
|
||||
double dSqMinDist = INFINITO ;
|
||||
for ( int nInfo = 0 ; nInfo < ICP.GetIntersCount() ; ++ nInfo) {
|
||||
@@ -5940,7 +5915,7 @@ CalcSyncPointFromEdge( const SHARPEDGEVECTOR& vSharpEdge, const ICurveComposite*
|
||||
}
|
||||
}
|
||||
}
|
||||
bool bOkPlane = ( nIndParCloser != -1 && nIndPointCloser != -1) ;
|
||||
bool bOkPlane = ( nIndParCloser != -1 && nIndPointCloser != -1) ;
|
||||
if ( bOkPlane) {
|
||||
// Se gli indici sono tra loro coerenti allora ho individuato il punto
|
||||
if ( nIndParCloser == nIndPointCloser) {
|
||||
@@ -5948,30 +5923,31 @@ CalcSyncPointFromEdge( const SHARPEDGEVECTOR& vSharpEdge, const ICurveComposite*
|
||||
ICP.GetIntCrvPlnInfo( nIndParCloser, aInfo) ;
|
||||
dUCurrSubEdge = aInfo.Ici[0].dU ;
|
||||
}
|
||||
// Se gli indici sono discordi, devo scegliere quale dei due punti tenere
|
||||
else {
|
||||
// scelgo il punto più vicino al corrente
|
||||
IntCrvPlnInfo aInfoPt, aInfoPar ;
|
||||
ICP.GetIntCrvPlnInfo( nIndPointCloser, aInfoPt) ;
|
||||
ICP.GetIntCrvPlnInfo( nIndParCloser, aInfoPar) ;
|
||||
dUCurrSubEdge = ( SqDist( mySharpEdge.ptEdge, aInfoPt.Ici[0].ptI) < SqDist( mySharpEdge.ptEdge, aInfoPar.Ici[0].ptI) ?
|
||||
aInfoPt.Ici[0].dU : aInfoPar.Ici[0].dU) ;
|
||||
}
|
||||
}
|
||||
// Se gli indici sono discordi, devo scegliere quale dei due punti tenere
|
||||
else {
|
||||
// scelgo il punto più vicino al corrente
|
||||
IntCrvPlnInfo aInfoPt, aInfoPar ;
|
||||
ICP.GetIntCrvPlnInfo( nIndPointCloser, aInfoPt) ;
|
||||
ICP.GetIntCrvPlnInfo( nIndParCloser, aInfoPar) ;
|
||||
dUCurrSubEdge = ( SqDist( mySharpEdge.ptEdge, aInfoPt.Ici[0].ptI) < SqDist( mySharpEdge.ptEdge, aInfoPar.Ici[0].ptI) ?
|
||||
aInfoPt.Ici[0].dU : aInfoPar.Ici[0].dU) ;
|
||||
if ( ! bOkPlane) {
|
||||
// --- Altrimenti, cerco il punto a minima distanza
|
||||
DistPointCurve DPC( mySharpEdge.ptEdge, *pCompoSubEdge) ;
|
||||
int nFlag ;
|
||||
bool bOkMinDist = ( DPC.GetParamAtMinDistPoint( dUPrevSubEdge, dUCurrSubEdge, nFlag) && dUCurrSubEdge > dUPrevSubEdge) ;
|
||||
if ( ! bOkMinDist) {
|
||||
// --- Eh.... bho ( se arrivo qui non so che fare...)
|
||||
double dUStart, dUEnd ;
|
||||
pCompoSubEdge->GetDomain( dUStart, dUEnd) ;
|
||||
dUCurrSubEdge = ( dUEnd - dUCurrSubEdge) / 2. ;
|
||||
}
|
||||
if ( ! bOkPlane) {
|
||||
// --- Altrimenti, cerco il punto a minima distanza
|
||||
DistPointCurve DPC( mySharpEdge.ptEdge, *pCompoSubEdge) ;
|
||||
int nFlag ;
|
||||
bool bOkMinDist = ( DPC.GetParamAtMinDistPoint( dUPrevSubEdge, dUCurrSubEdge, nFlag) && dUCurrSubEdge > dUPrevSubEdge) ;
|
||||
if ( ! bOkMinDist) {
|
||||
// --- Alla peggio mi posiziono a metà tra la posizione corrente e quella finale
|
||||
double dPrevLen ; pCompoSubEdge->GetLengthAtParam( dUPrevSubEdge, dPrevLen) ;
|
||||
double dLen ; pCompoSubEdge->GetLength( dLen) ;
|
||||
pCompoSubEdge->GetParamAtLength( ( dPrevLen + dLen) / 2., dUCurrSubEdge) ;
|
||||
}
|
||||
}
|
||||
|
||||
// Verifico se tale parametro può essere avvicinato ad uno Spigolo presente sulla curva
|
||||
// NB. Come descitto sopra gli spigoli in generale è meglio sincronizzarli tra loro
|
||||
if ( ! vSharpSubEdge.empty()) {
|
||||
const double EDGE_LEN_TOL = 5. ;
|
||||
for ( const SharpEdge& mySharpSubEdge : vSharpSubEdge) {
|
||||
@@ -6001,7 +5977,7 @@ CalcSyncPointFromEdge( const SHARPEDGEVECTOR& vSharpEdge, const ICurveComposite*
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Debug [Gestione Edge in Quadrangolazioni]
|
||||
// Gestione degli spigoli all'interno della Quadrangolazione corrente
|
||||
static bool
|
||||
ManageEdgesInQuadrangulation( const ICurveComposite* pSubEdge1, const ICurveComposite* pSubEdge2, BIPNTVECTOR& vSyncLines)
|
||||
{
|
||||
@@ -6020,7 +5996,7 @@ ManageEdgesInQuadrangulation( const ICurveComposite* pSubEdge1, const ICurveComp
|
||||
SHARPEDGEVECTOR vSharpEdges2 ; vSharpEdges2.reserve( max( 0, nCrv2 - 1)) ;
|
||||
|
||||
// --- Cerco gli Spigoli sul SottoTratto del primo bordo
|
||||
// Se la CurvaA ha solo una sottocurva, non faccio nulla
|
||||
// Se la CurvaA ha più di una sottocurva, verifico l'esistenza di Spigoli (Sharp Edges)
|
||||
if ( nCrv1 > 1) {
|
||||
Point3d ptCurr1 ;
|
||||
// Scorro le sottocurve
|
||||
@@ -6029,17 +6005,17 @@ ManageEdgesInQuadrangulation( const ICurveComposite* pSubEdge1, const ICurveComp
|
||||
double dU = double( nCrv + 1) ;
|
||||
// Recupero le tangenti prima e dopo tale parametro
|
||||
Vector3d vtTanPrev ; pSubEdge1->GetPointD1D2( dU, ICurve::FROM_MINUS, ptCurr1, &vtTanPrev) ;
|
||||
Vector3d vtTanAft ; pSubEdge1->GetPointD1D2( dU, ICurve::FROM_PLUS, ptCurr1, &vtTanAft) ;
|
||||
Vector3d vtTanNext ; pSubEdge1->GetPointD1D2( dU, ICurve::FROM_PLUS, ptCurr1, &vtTanNext) ;
|
||||
// Verifico se ho uno spigolo
|
||||
vtTanPrev.Normalize() ;
|
||||
vtTanAft.Normalize() ;
|
||||
if ( vtTanPrev * vtTanAft < COS_EDGE_LIMIT)
|
||||
vSharpEdges1.emplace_back( dU, ptCurr1, vtTanPrev, vtTanAft) ;
|
||||
vtTanNext.Normalize() ;
|
||||
if ( vtTanPrev * vtTanNext < COS_EDGE_LIMIT)
|
||||
vSharpEdges1.emplace_back( dU, ptCurr1, vtTanPrev, vtTanNext) ;
|
||||
}
|
||||
}
|
||||
|
||||
// --- Cerco gli spigoli sul Sottotratto del secondo bordo
|
||||
// Se la Curva B ha solo una sottocurva, non faccio nulla
|
||||
// Se la Curva B ha più di una sottocurva, verifico l'esistena di Spigoli (Sharp Edges)
|
||||
if ( nCrv2 > 1) {
|
||||
Point3d ptCurr2 ;
|
||||
// Scorro le sottocurve
|
||||
@@ -6048,24 +6024,24 @@ ManageEdgesInQuadrangulation( const ICurveComposite* pSubEdge1, const ICurveComp
|
||||
double dU = double( nCrv + 1) ;
|
||||
// Recupero le tangenti prima e dopo tale parametro
|
||||
Vector3d vtTanPrev ; pSubEdge2->GetPointD1D2( dU, ICurve::FROM_MINUS, ptCurr2, &vtTanPrev) ;
|
||||
Vector3d vtTanAft ; pSubEdge2->GetPointD1D2( dU, ICurve::FROM_PLUS, ptCurr2, &vtTanAft) ;
|
||||
Vector3d vtTanNext ; pSubEdge2->GetPointD1D2( dU, ICurve::FROM_PLUS, ptCurr2, &vtTanNext) ;
|
||||
// Verifico se ho uno spigolo
|
||||
vtTanPrev.Normalize() ;
|
||||
vtTanAft.Normalize() ;
|
||||
if ( vtTanPrev * vtTanAft < COS_EDGE_LIMIT)
|
||||
vSharpEdges2.emplace_back( dU, ptCurr2, vtTanPrev, vtTanAft) ;
|
||||
vtTanNext.Normalize() ;
|
||||
if ( vtTanPrev * vtTanNext < COS_EDGE_LIMIT)
|
||||
vSharpEdges2.emplace_back( dU, ptCurr2, vtTanPrev, vtTanNext) ;
|
||||
}
|
||||
}
|
||||
|
||||
// Se non ho alcuno spigolo, allora non faccio nulla
|
||||
// Se non ho alcuno spigolo per entrambe le curve di Bordo, non faccio nulla
|
||||
if ( vSharpEdges1.empty() && vSharpEdges2.empty())
|
||||
return true ;
|
||||
|
||||
// Recupero le Curve di Sincronizzazione dell'Edge 1 sull'Edge 2
|
||||
// Recupero le Curve di Sincronizzazione associate agli spigoli dal primo Bordo al secondo Bordo
|
||||
BIPNTVECTOR vSyncLines1 ;
|
||||
CalcSyncPointFromEdge( vSharpEdges1, pSubEdge2, vSharpEdges2, vSyncLines1) ;
|
||||
|
||||
// Recupero le Curve di Sincronizzazione dell'Edge 2 sull'Egde 1
|
||||
// Recupero le Curve di Sincronizzazione associate agli spigoli dal secondo Bordo al primo Bordo
|
||||
BIPNTVECTOR vSyncLines2 ;
|
||||
CalcSyncPointFromEdge( vSharpEdges2, pSubEdge1, vSharpEdges1, vSyncLines2) ;
|
||||
|
||||
@@ -6078,7 +6054,7 @@ ManageEdgesInQuadrangulation( const ICurveComposite* pSubEdge1, const ICurveComp
|
||||
}) ;
|
||||
}) ;
|
||||
|
||||
// Ordino tutte le curve in base al parametro dU della curva principale
|
||||
// Ordino tutte le curve in base al parametro dU della prima curva di Bordo
|
||||
vector<pair<BIPOINT, double>> vSyncLinesPar ; vSyncLinesPar.reserve( vSyncLines1.size() + vSyncLines2.size()) ;
|
||||
for ( BIPOINT& SyncLine1 : vSyncLines1) {
|
||||
vSyncLinesPar.emplace_back( make_pair( make_pair( SyncLine1.first, SyncLine1.second),
|
||||
@@ -6094,9 +6070,226 @@ ManageEdgesInQuadrangulation( const ICurveComposite* pSubEdge1, const ICurveComp
|
||||
return SyncLineParA.second < SyncLineParB.second ;
|
||||
}) ;
|
||||
|
||||
// Restituisco il risultato
|
||||
for ( auto Iter = vSyncLinesPar.begin() ; Iter != vSyncLinesPar.end() ; ++ Iter)
|
||||
vSyncLines.emplace_back( Iter->first) ;
|
||||
// Controllo che le linee di sincronizzazione non si intreccino e restituisco il risultato
|
||||
// NB. Inserisco solo che curve che progressivamente non si intrecciano sulla seconda curva di Bordo
|
||||
double dUSecondPrev = EPS_PARAM ;
|
||||
for ( auto Iter = vSyncLinesPar.begin() ; Iter != vSyncLinesPar.end() ; ++ Iter) {
|
||||
double dUSecondCurr ; pSubEdge2->GetParamAtPoint( ( *Iter).first.second, dUSecondCurr, TOL) ;
|
||||
if ( dUSecondCurr > dUSecondPrev + EPS_SMALL) {
|
||||
vSyncLines.emplace_back( Iter->first) ;
|
||||
dUSecondPrev = dUSecondCurr ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Calcolo delle Curve di Sync per evitare Twist
|
||||
static bool
|
||||
ManageTwistInQuadrangulation( const ICurveComposite* pSubEdge1, const ICurveComposite* pSubEdge2, BIPNTVECTOR& vSyncLines, bool& bEraseLastIso)
|
||||
{
|
||||
// Verifica validità delle curve
|
||||
if ( pSubEdge1 == nullptr || ! pSubEdge1->IsValid() || pSubEdge2 == nullptr || ! pSubEdge2->IsValid())
|
||||
return false ;
|
||||
|
||||
const double COS_LIMIT = cos( 50. * DEGTORAD) ;
|
||||
const int NUM_SAMPLE_PNT = 20 ;
|
||||
const int nStepSkip = NUM_SAMPLE_PNT / 10 ;
|
||||
#if DEBUG_CURVATURE
|
||||
vector<pair<Point3d, double>> _vPtK1 ;
|
||||
vector<pair<Point3d, double>> _vPtK2 ;
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
#endif
|
||||
|
||||
// --- Verifico il cambiamento di Deviazione angolare tra Inizio-Fine della prima curva di Bordo
|
||||
Vector3d vtS1 ; pSubEdge1->GetStartDir( vtS1) ;
|
||||
Vector3d vtE1 ; pSubEdge1->GetEndDir( vtE1) ;
|
||||
double dLen1 = - EPS_SMALL ;
|
||||
double dLen2 = - EPS_SMALL ;
|
||||
pSubEdge1->GetLength( dLen1) ;
|
||||
pSubEdge2->GetLength( dLen2) ;
|
||||
double dMyDist = min( dLen1, dLen2) * 0.85 ;
|
||||
bool bSplit1 = ( vtS1 * vtE1 < COS_LIMIT) ;
|
||||
if ( bSplit1) {
|
||||
// Individuo il punto a Curvatura Massima
|
||||
double dKMax1 = - INFINITO + 1, dUK1Max = - EPS_SMALL ;
|
||||
Point3d ptKMax1 ; Vector3d vtTanKMax1Prev, vtTanKMax1Next ;
|
||||
for ( int i = nStepSkip ; i <= NUM_SAMPLE_PNT - nStepSkip ; ++ i) {
|
||||
// Ricavo la Lunghezza corrente e il parametro dU associato
|
||||
double dCurrLen1 = Clamp( i * ( dLen1 / NUM_SAMPLE_PNT), 0., dLen1) ;
|
||||
double dUCurr1 ; pSubEdge1->GetParamAtLength( dCurrLen1, dUCurr1) ;
|
||||
// Calcolo la Curvatura
|
||||
Point3d ptCurrSub1 ;
|
||||
Vector3d vtCurrSub1Der1Prev, vtCurrSub1Der2Prev, vtCurrSub1Der1Next, vtCurrSub1Der2Next ;
|
||||
pSubEdge1->GetPointD1D2( dUCurr1, ICurve::FROM_MINUS, ptCurrSub1, &vtCurrSub1Der1Prev, &vtCurrSub1Der2Prev) ;
|
||||
pSubEdge1->GetPointD1D2( dUCurr1, ICurve::FROM_PLUS, ptCurrSub1, &vtCurrSub1Der1Next, &vtCurrSub1Der2Next) ;
|
||||
Vector3d vtCurrSub1Der1 = Media( vtCurrSub1Der1Prev, vtCurrSub1Der1Next) ;
|
||||
Vector3d vtCurrSub1Der2 = Media( vtCurrSub1Der2Prev, vtCurrSub1Der2Next) ;
|
||||
double dCurrK1 = ( vtCurrSub1Der1 ^ vtCurrSub1Der2).Len() / max( EPS_SMALL, Pow( vtCurrSub1Der1.Len(), 3)) ;
|
||||
// Se maggiore della massima trovata, aggiorno la massima
|
||||
if ( dCurrK1 > dKMax1) {
|
||||
dKMax1 = dCurrK1 ;
|
||||
ptKMax1 = ptCurrSub1 ;
|
||||
dUK1Max = dUCurr1 ;
|
||||
vtTanKMax1Prev = vtCurrSub1Der1Prev ;
|
||||
vtTanKMax1Next = vtCurrSub1Der1Next ;
|
||||
}
|
||||
#if DEBUG_CURVATURE
|
||||
_vPtK1.emplace_back( make_pair( ptCurrSub1, dCurrK1)) ;
|
||||
#endif
|
||||
}
|
||||
vtTanKMax1Prev.Normalize() ;
|
||||
vtTanKMax1Next.Normalize() ;
|
||||
// Calcolo la nuova linea di sincronizzazione
|
||||
CurvaturePoint myCurvaturePoint( dUK1Max, ptKMax1, vtTanKMax1Prev, vtTanKMax1Next) ;
|
||||
double dUOn2 ; double dLenCurr2 ;
|
||||
GetIsoPointOnSecondCurve( pSubEdge1, pSubEdge2, dUK1Max, dUOn2, dMyDist, 0, 0, dLenCurr2, dLen2) ;
|
||||
Point3d ptOn2 ; pSubEdge2->GetPointD1D2( dUOn2, ICurve::FROM_MINUS, ptOn2) ;
|
||||
vSyncLines.emplace_back( ptKMax1, ptOn2) ;
|
||||
}
|
||||
|
||||
// --- Verifico il cambiamento di Deviazione angolare tra Inizio-Fine del tratto per la prima curva di Bordo
|
||||
Vector3d vtS2 ; pSubEdge2->GetStartDir( vtS2) ;
|
||||
Vector3d vtE2 ; pSubEdge2->GetEndDir( vtE2) ;
|
||||
bool bSplit2 = ( vtS2 * vtE2 < COS_LIMIT) ;
|
||||
if ( bSplit2) {
|
||||
// Individuo il punto a Curvatura Massima
|
||||
double dKMax2 = - INFINITO + 1, dUK2Max = - EPS_SMALL ;
|
||||
Point3d ptKMax2 ; Vector3d vtTanKMax2Prev, vtTanKMax2Next ;
|
||||
for ( int i = nStepSkip ; i <= NUM_SAMPLE_PNT - nStepSkip ; ++ i) {
|
||||
// Ricavo la Lunghezza corrente e il parametro dU associato
|
||||
double dCurrLen2 = Clamp( i * ( dLen2 / NUM_SAMPLE_PNT), 0., dLen2) ;
|
||||
double dUCurr2 ; pSubEdge2->GetParamAtLength( dCurrLen2, dUCurr2) ;
|
||||
// Calcolo la Curvatura
|
||||
Point3d ptCurrSub2 ;
|
||||
Vector3d vtCurrSub2Der1Prev, vtCurrSub2Der2Prev, vtCurrSub2Der1Next, vtCurrSub2Der2Next ;
|
||||
pSubEdge2->GetPointD1D2( dUCurr2, ICurve::FROM_MINUS, ptCurrSub2, &vtCurrSub2Der1Prev, &vtCurrSub2Der2Prev) ;
|
||||
pSubEdge2->GetPointD1D2( dUCurr2, ICurve::FROM_PLUS, ptCurrSub2, &vtCurrSub2Der1Next, &vtCurrSub2Der2Next) ;
|
||||
Vector3d vtCurrSub2Der1 = Media( vtCurrSub2Der1Prev, vtCurrSub2Der1Next) ;
|
||||
Vector3d vtCurrSub2Der2 = Media( vtCurrSub2Der2Prev, vtCurrSub2Der2Next) ;
|
||||
double dCurrK2 = ( vtCurrSub2Der1 ^ vtCurrSub2Der2).Len() / max( EPS_SMALL, Pow( vtCurrSub2Der1.Len(), 3)) ;
|
||||
// Se maggiore della massima trovata, aggiorno la massima
|
||||
if ( dCurrK2 > dKMax2) {
|
||||
dKMax2 = dCurrK2 ;
|
||||
ptKMax2 = ptCurrSub2 ;
|
||||
dUK2Max = dUCurr2 ;
|
||||
vtTanKMax2Prev = vtCurrSub2Der1Prev ;
|
||||
vtTanKMax2Next = vtCurrSub2Der1Next ;
|
||||
}
|
||||
#if DEBUG_CURVATURE
|
||||
_vPtK1.emplace_back( make_pair( ptCurrSub2, dCurrK2)) ;
|
||||
#endif
|
||||
}
|
||||
vtTanKMax2Prev.Normalize() ;
|
||||
vtTanKMax2Next.Normalize() ;
|
||||
// Calcolo la nuova linea di sincronizzazione
|
||||
CurvaturePoint myCurvaturePoint( dUK2Max, ptKMax2, vtTanKMax2Prev, vtTanKMax2Next) ;
|
||||
double dUOn1 ; double dLenCurr1 ;
|
||||
GetIsoPointOnSecondCurve( pSubEdge2, pSubEdge1, dUK2Max, dUOn1, dMyDist, 0, 0, dLenCurr1, dLen1) ;
|
||||
Point3d ptOn1 ; pSubEdge1->GetPointD1D2( dUOn1, ICurve::FROM_MINUS, ptOn1) ;
|
||||
vSyncLines.emplace_back( ptOn1, ptKMax2) ;
|
||||
}
|
||||
|
||||
#if DEBUG_CURVATURE // Curvatura minima -> AQUA | Curvatura massima -> ORANGE
|
||||
auto [itMin1, itMax1] = std::minmax_element( _vPtK1.begin(), _vPtK1.end(), [](auto const& A, auto const& B) {
|
||||
return A.second < B.second ;
|
||||
}) ;
|
||||
double _dK1Max = itMax1->second ;
|
||||
double _dK1Min = itMin1->second ;
|
||||
for ( int i = 0 ; i < ssize( _vPtK1) ; ++ i) {
|
||||
double _t = 0. ;
|
||||
if ( _dK1Max > _dK1Min)
|
||||
_t = ( _vPtK1[i].second - _dK1Min) / ( _dK1Max - _dK1Min) ;
|
||||
double _dh = 30 - 180. ; // AQUA -> HSV( 180, 1, 1) | ORANGE -> HSV( 30, 1, 1)
|
||||
if ( _dh > 180.) _dh -= 360.0 ;
|
||||
if ( _dh < -180.0) _dh += 360.0 ;
|
||||
double _h = 180. + _t * _dh ;
|
||||
if ( _h < 0.0) _h += 360.0 ;
|
||||
if ( _h >= 360.0) _h -= 360.0 ;
|
||||
PtrOwner<IGeoPoint3d> _ptC( CreateGeoPoint3d()) ; _ptC->Set( _vPtK1[i].first) ;
|
||||
int _nId = pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, Release( _ptC)) ;
|
||||
pGeomDB->SetMaterial( _nId, Color( GetColorFromHSV( HSV( _h, 1., 1.)))) ;
|
||||
}
|
||||
auto [itMin2, itMax2] = std::minmax_element( _vPtK2.begin(), _vPtK2.end(), [](auto const& A, auto const& B) {
|
||||
return A.second < B.second ;
|
||||
}) ;
|
||||
double _dK2Max = itMax2->second ;
|
||||
double _dK2Min = itMin2->second ;
|
||||
for ( int i = 0 ; i < ssize( _vPtK2) ; ++ i) {
|
||||
double _t = 0. ;
|
||||
if ( _dK2Max > _dK2Min)
|
||||
_t = ( _vPtK2[i].second - _dK2Min) / ( _dK2Max - _dK2Min) ;
|
||||
double _dh = 30 - 180. ; // CYAN -> HSV( 180, 1, 1) | ORANGE -> HSV( 30, 1, 1)
|
||||
if ( _dh > 180.) _dh -= 360.0 ;
|
||||
if ( _dh < -180.0) _dh += 360.0 ;
|
||||
double _h = 180. + _t * _dh ;
|
||||
if ( _h < 0.0) _h += 360.0 ;
|
||||
if ( _h >= 360.0) _h -= 360.0 ;
|
||||
PtrOwner<IGeoPoint3d> _ptC( CreateGeoPoint3d()) ; _ptC->Set( _vPtK2[i].first) ;
|
||||
int _nId = pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, Release( _ptC)) ;
|
||||
pGeomDB->SetMaterial( _nId, Color( GetColorFromHSV( HSV( _h, 1., 1.)))) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Se non ho alcuna linea di sincronizzazione, non faccio nulla
|
||||
if ( vSyncLines.empty())
|
||||
return true ;
|
||||
|
||||
const double TOL = 250. * EPS_SMALL ;
|
||||
|
||||
// Elimino tutte le curve di Sincronizzazione a ridosso degli estremi della Quadrangolazione
|
||||
// NB. Risultano ridondanti, creano SottoQuadrangolazioni molto strette o possono Inclinare eccssivamente l'Utensile
|
||||
// NB. Così facendo evito anche di creare curve di Sync lungo le diagonali della Quadrangolazione
|
||||
const double LEN_TOL = 2. ;
|
||||
const double dParTol = 0.1 ;
|
||||
double dLenPrev1 = - LEN_TOL, dLenPrev2 = - LEN_TOL ;
|
||||
for ( int i = 0 ; i < ssize( vSyncLines) ; ++ i) {
|
||||
double dSyncLen1 ; pSubEdge1->GetLengthAtPoint( vSyncLines[i].first, dSyncLen1, TOL) ;
|
||||
bool bErase = ( dSyncLen1 < max( LEN_TOL, dParTol * dLen1) || dSyncLen1 - dLenPrev1 < LEN_TOL) ;
|
||||
bEraseLastIso = dSyncLen1 > min( dLen1 - LEN_TOL, ( 1 - dParTol) * dLen1) ;
|
||||
if ( ! bErase) {
|
||||
double dSyncLen2 ; pSubEdge2->GetLengthAtPoint( vSyncLines[i].second, dSyncLen2, TOL) ;
|
||||
bErase = ( dSyncLen2 < max( LEN_TOL, dParTol * dLen2) || dSyncLen2 - dLenPrev2 < LEN_TOL) ;
|
||||
bEraseLastIso = bEraseLastIso || dSyncLen2 > min( dLen2 - LEN_TOL, ( 1 - dParTol) * dLen2) ;
|
||||
dLenPrev2 = dSyncLen2 ;
|
||||
}
|
||||
if ( bErase && ! bEraseLastIso) {
|
||||
vSyncLines.erase( vSyncLines.begin() + i) ;
|
||||
-- i ;
|
||||
}
|
||||
dLenPrev1 = dSyncLen1 ;
|
||||
if ( bEraseLastIso)
|
||||
break ;
|
||||
}
|
||||
if ( vSyncLines.empty())
|
||||
return true ;
|
||||
|
||||
// Se due curve di Sincronizzazione rimaste
|
||||
if ( ssize( vSyncLines) == 2) {
|
||||
// Se si sovrappongono, ne elimino una
|
||||
if ( AreSamePointEpsilon( vSyncLines[0].first, vSyncLines[1].first, LEN_TOL) &&
|
||||
AreSamePointEpsilon( vSyncLines[0].second, vSyncLines[1].second, LEN_TOL))
|
||||
vSyncLines.pop_back() ;
|
||||
}
|
||||
// Se due curve di Sincronizzazione rimaste
|
||||
if ( ssize( vSyncLines) == 2) {
|
||||
// Ordino tutte le linee di sincronizzazione in base al parametro dU della curva principale
|
||||
double dU0 ; pSubEdge1->GetParamAtPoint( vSyncLines[0].first, dU0, TOL) ;
|
||||
double dU1 ; pSubEdge1->GetParamAtPoint( vSyncLines[1].first, dU1, TOL) ;
|
||||
if ( dU0 > dU1 - EPS_SMALL)
|
||||
swap( vSyncLines[0], vSyncLines[1]) ;
|
||||
// Verifico che le curve non si intreccino
|
||||
pSubEdge2->GetParamAtPoint( vSyncLines[0].second, dU0, TOL) ;
|
||||
pSubEdge2->GetParamAtPoint( vSyncLines[1].second, dU1, TOL) ;
|
||||
if ( dU0 > dU1 - EPS_SMALL)
|
||||
vSyncLines.pop_back() ; // lascio solo la prima... ( bisognerebbe scegliere quale lasciare con un criterio migliore ?)
|
||||
}
|
||||
|
||||
// se ne ho due tengo solo la prima
|
||||
if ( ssize( vSyncLines) == 2)
|
||||
vSyncLines.pop_back() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -6104,14 +6297,29 @@ ManageEdgesInQuadrangulation( const ICurveComposite* pSubEdge1, const ICurveComp
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfBezier::CreateSmoothRuledByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, double dSampleLen)
|
||||
{
|
||||
BIPNTVECTOR vSyncLines ;
|
||||
return CreateSmoothRuledByTwoCurves( pCurve0, pCurve1, dSampleLen, vSyncLines) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfBezier::CreateSmoothRuledByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, double dSampleLen, BIPNTVECTOR& vSyncLines)
|
||||
{
|
||||
// converto in bezier le curve iniziali
|
||||
PtrOwner<ICurveBezier> pCrvEdge1( GetCurveBezier( CurveToBezierCurve( pCurve0, 3, false))) ;
|
||||
PtrOwner<ICurveBezier> pCrvEdge2( GetCurveBezier( CurveToBezierCurve( pCurve1, 3, false))) ;
|
||||
PtrOwner<ICurveComposite> pCrvEdge1( ConvertCurveToComposite(CurveToBezierCurve( pCurve0, 3, false))) ;
|
||||
PtrOwner<ICurveComposite> pCrvEdge2( ConvertCurveToComposite(CurveToBezierCurve( pCurve1, 3, false))) ;
|
||||
|
||||
if ( IsNull( pCrvEdge1) || IsNull( pCrvEdge2))
|
||||
return false ;
|
||||
|
||||
#if SAVEPACEDISO
|
||||
vGeo.clear() ;
|
||||
vCol.clear() ;
|
||||
#endif
|
||||
|
||||
// Verifico che la distanza di campionamento sia ammissibile
|
||||
double dMyDist = Clamp( dSampleLen, 2., 30.) ; // 20.0 sembra un passo di campionamento ideale
|
||||
// Recupero parametri iniziali
|
||||
double dLen1 ; pCrvEdge1->GetLength( dLen1) ;
|
||||
double dLen2 ; pCrvEdge2->GetLength( dLen2) ;
|
||||
@@ -6124,155 +6332,113 @@ SurfBezier::CreateSmoothRuledByTwoCurves( const ICurve* pCurve0, const ICurve* p
|
||||
Point3d ptPrev1, ptCurr1 ; pCrvEdge1->GetStartPoint( ptPrev1) ;
|
||||
Point3d ptPrev2, ptCurr2 ; pCrvEdge2->GetStartPoint( ptPrev2) ;
|
||||
Vector3d vtCurr1 = V_NULL, vtCurr2 = V_NULL ;
|
||||
BIPNTVECTOR vEdgeSyncLines ;
|
||||
while ( dLenPrev1 + dSampleLen < dLen1 - EPS_ZERO) {
|
||||
// Recupero dU, Point3d e dLen corrente sul primo bordo, per un incremento del passo di campionamento
|
||||
dLenCurr1 = Clamp( dLenPrev1 + dSampleLen, 0., dLen1) ;
|
||||
|
||||
while ( dLenPrev1 + dMyDist < dLen1 - EPS_ZERO) {
|
||||
// Recupero dU, Point3d e dLen corrente sul primo bordo, per un incremento del passo di campionamento
|
||||
dLenCurr1 = Clamp( dLenPrev1 + dMyDist, 0., dLen1) ;
|
||||
pCrvEdge1->GetParamAtLength( dLenCurr1, dUCurr1) ;
|
||||
// se sono abbastanza vicino ad una joint allora prendo quel punto
|
||||
double dUClosestJoint1 = round( dUCurr1) ;
|
||||
double dLenAlt1 = 0 ; pCrvEdge1->GetLengthAtParam( dUClosestJoint1, dLenAlt1) ;
|
||||
if ( abs( dLenCurr1 - dLenAlt1) < 1)
|
||||
dUCurr1 = dUClosestJoint1 ;
|
||||
pCrvEdge1->GetPointD1D2( dUCurr1, ICurve::FROM_MINUS, ptCurr1, &vtCurr1) ;
|
||||
vtCurr1.Normalize() ;
|
||||
|
||||
#if DEBUG_SYNCLINES
|
||||
PtrOwner<IGeoPoint3d> ptGeo1( CreateGeoPoint3d()) ; ptGeo1->Set( ptCurr1) ;
|
||||
PtrOwner<IGeoVector3d> vtGeo1( CreateGeoVector3d()) ; vtGeo1->Set( 5. * vtCurr1, ptCurr1) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nLay1, Release( ptGeo1)) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nLay1, Release( vtGeo1)) ;
|
||||
#endif
|
||||
#if DEBUG_SYNCLINES
|
||||
PtrOwner<IGeoPoint3d> ptGeo1( CreateGeoPoint3d()) ; ptGeo1->Set( ptCurr1) ;
|
||||
PtrOwner<IGeoVector3d> vtGeo1( CreateGeoVector3d()) ; vtGeo1->Set( 5. * vtCurr1, ptCurr1) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nLay1, Release( ptGeo1)) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nLay1, Release( vtGeo1)) ;
|
||||
#endif
|
||||
|
||||
// --- Piano di taglio per punto a minima distanza
|
||||
IntersCurvePlane ICP( *pCrvEdge2, ptCurr1, vtCurr1) ;
|
||||
int nIndParCloser = - 1, nIndPointCloser = -1 ;
|
||||
double dSqMinDist = INFINITO ;
|
||||
for ( int nInfo = 0 ; nInfo < ICP.GetIntersCount() ; ++ nInfo) {
|
||||
IntCrvPlnInfo aInfo ;
|
||||
if ( ICP.GetIntCrvPlnInfo( nInfo, aInfo) && aInfo.Ici[0].dU > dUPrev2) {
|
||||
if ( nIndParCloser == -1)
|
||||
nIndParCloser = nInfo ;
|
||||
double dSqDist = SqDist( ptCurr1, aInfo.Ici[0].ptI) ;
|
||||
if ( dSqDist < dSqMinDist) {
|
||||
dSqMinDist = dSqDist ;
|
||||
nIndPointCloser = nInfo ;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool bOkPlane = ( nIndParCloser != -1 && nIndPointCloser != -1) ;
|
||||
if ( bOkPlane) {
|
||||
// Se gli indici sono tra loro coerenti allora ho individuato il punto
|
||||
if ( nIndParCloser == nIndPointCloser) {
|
||||
IntCrvPlnInfo aInfo ;
|
||||
ICP.GetIntCrvPlnInfo( nIndParCloser, aInfo) ;
|
||||
dUCurr2 = aInfo.Ici[0].dU ;
|
||||
}
|
||||
// Se gli indici sono discordi, devo scegliere quale dei due punti tenere
|
||||
else {
|
||||
// scelgo il punto più vicino al corrente
|
||||
IntCrvPlnInfo aInfoPt, aInfoPar ;
|
||||
ICP.GetIntCrvPlnInfo( nIndPointCloser, aInfoPt) ;
|
||||
ICP.GetIntCrvPlnInfo( nIndParCloser, aInfoPar) ;
|
||||
dUCurr2 = ( SqDist( ptCurr1, aInfoPt.Ici[0].ptI) < SqDist( ptCurr1, aInfoPar.Ici[0].ptI) ?
|
||||
aInfoPt.Ici[0].dU : aInfoPar.Ici[0].dU) ;
|
||||
#if DEBUG_SYNCLINES && 0
|
||||
VT.clear() ; VC.clear() ;
|
||||
VT.emplace_back( pCrvEdge1->Clone()) ; VC.emplace_back( Color( 0, 128, 255)) ;
|
||||
VT.emplace_back( pCrvEdge2->Clone()) ; VC.emplace_back( Color( 0, 128, 255)) ;
|
||||
PtrOwner<IGeoPoint3d> ptCurr1Geo( CreateGeoPoint3d()) ; ptCurr1Geo->Set( ptCurr1) ;
|
||||
VT.emplace_back( Release( ptCurr1Geo)) ; VC.emplace_back( BLUE) ;
|
||||
PtrOwner<IGeoPoint3d> ptPar( CreateGeoPoint3d()) ; ptPar->Set( aInfoPar.Ici[0].ptI) ;
|
||||
PtrOwner<IGeoPoint3d> ptPt( CreateGeoPoint3d()) ; ptPt->Set( aInfoPt.Ici[0].ptI) ;
|
||||
VT.emplace_back( Release( ptPar)) ; VC.emplace_back( LIME) ;
|
||||
VT.emplace_back( Release( ptPt)) ; VC.emplace_back( FUCHSIA) ;
|
||||
SaveGeoObj( VT, VC, "C:\\Temp\\TestTrimmingPlane.nge") ;
|
||||
#endif
|
||||
}
|
||||
// Verifico di non essermi allontanato troppo
|
||||
double dLen ; pCrvEdge2->GetLengthAtParam( dUCurr2, dLen) ;
|
||||
bOkPlane = ( dLen < dLenPrev2 + 2. * dSampleLen) ;
|
||||
}
|
||||
if ( ! bOkPlane) {
|
||||
// --- Altrimenti, cerco il punto a minima distanza
|
||||
DistPointCurve DPC( ptCurr1, *pCrvEdge2) ;
|
||||
int nFlag ;
|
||||
bool bOkMinDist = ( DPC.GetParamAtMinDistPoint( dUPrev2, dUCurr2, nFlag) && dUCurr2 > dUPrev2) ;
|
||||
// Verifico di non essermi allontanato troppo
|
||||
if ( bOkMinDist) {
|
||||
double dLen ; pCrvEdge2->GetLengthAtParam( dUCurr2, dLen) ;
|
||||
bOkMinDist = ( dLen < dLenPrev2 + 2. * dSampleLen) ;
|
||||
}
|
||||
if ( ! bOkMinDist) {
|
||||
// --- Aumento la distanza corrente del passo di campionamento
|
||||
double dLen = Clamp( dLenPrev2 + dSampleLen, 0., dLen2) ;
|
||||
pCrvEdge2->GetParamAtLength( dLen, dUCurr2) ;
|
||||
}
|
||||
}
|
||||
GetIsoPointOnSecondCurve( pCrvEdge1, pCrvEdge2, dUCurr1, dUCurr2, dMyDist, dUPrev2, dLenPrev2, dLenCurr2, dLen2) ;
|
||||
|
||||
// Recupero il punto corrente e la direzione tangente sul secondo bordo
|
||||
pCrvEdge2->GetLengthAtParam( dUCurr2, dLenCurr2) ;
|
||||
pCrvEdge2->GetPointD1D2( dUCurr2, ICurve::FROM_MINUS, ptCurr2, &vtCurr2) ;
|
||||
vtCurr2.Normalize() ;
|
||||
|
||||
// Verifico se le direzioni tangenti sono tra di loro circa parallele
|
||||
const double COS_ANG_TOL = cos( 15. * DEGTORAD) ;
|
||||
if ( vtCurr1 * vtCurr2 < COS_ANG_TOL) {
|
||||
// Se fuori dalla tolleranza, recupero il miglior versore tangente sul secondo bordo nell'intervallo successivo di lunghezza ( 2. * dSampleLen)
|
||||
pCrvEdge2->GetLengthAtPoint( ptCurr2, dLenCurr2) ;
|
||||
double dLimInfLen2 = Clamp( dLenCurr2 - dSampleLen, dLenPrev2, dLen2) ;
|
||||
double dLimSupLen2 = Clamp( dLenCurr2 + dSampleLen, dLenPrev2, dLen2) ;
|
||||
// [Controllo migliorabile, magari mendiante metodo di bisezione (?)]
|
||||
const int NUM_STEP = 20 ;
|
||||
double dMinCos = - 1. - EPS_ZERO ;
|
||||
const double DEGTOL = 5. ;
|
||||
for ( int i = 0 ; i <= NUM_STEP ; ++ i) {
|
||||
double dLen = dLimInfLen2 + i * ( dLimSupLen2 - dLimInfLen2) / NUM_STEP ;
|
||||
double dUStep2 ; pCrvEdge2->GetParamAtLength( dLen, dUStep2) ;
|
||||
Point3d ptStep2 ; Vector3d vtStep2 = V_NULL ;
|
||||
pCrvEdge2->GetPointD1D2( dUStep2, ICurve::FROM_MINUS, ptStep2, &vtStep2) ; vtStep2.Normalize() ;
|
||||
double dStepCos2 = vtCurr1 * vtStep2 ;
|
||||
double dAngTol = ( i < NUM_STEP / 2 ? ( 2. * DEGTOL) / NUM_STEP * i :
|
||||
( - 2. * DEGTOL) / NUM_STEP * ( i - NUM_STEP)) ;
|
||||
double dCosTol = 1. - cos( dAngTol * DEGTORAD) ;
|
||||
if ( dStepCos2 + dCosTol > dMinCos) {
|
||||
ptCurr2 = ptStep2 ;
|
||||
vtCurr2 = vtStep2 ;
|
||||
dUCurr2 = dUStep2 ;
|
||||
dMinCos = dStepCos2 + dCosTol ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG_SYNCLINES
|
||||
PtrOwner<IGeoPoint3d> ptGeo2( CreateGeoPoint3d()) ; ptGeo2->Set( ptCurr2) ;
|
||||
PtrOwner<IGeoVector3d> vtGeo2( CreateGeoVector3d()) ; vtGeo2->Set( 5. * vtCurr2, ptCurr2) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nLay2, Release( ptGeo2)) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nLay2, Release( vtGeo2)) ;
|
||||
#endif
|
||||
|
||||
// debug
|
||||
//// Inserisco le curve di sincronizzazione nel Layer di destinazine
|
||||
// PtrOwner<ICurveLine> pLine( CreateCurveLine()) ; pLine->Set( ptCurr1, ptCurr2) ;
|
||||
// pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrp, Release( pLine)) ;
|
||||
|
||||
// --- Analisi degli spigoli all'interno della Quadrangolazione ---
|
||||
// Perchè si fa questa cosa ? Perchè parametrizzando per la lunghezza i SottoTratti ricavati, non è sempre detto
|
||||
// che uno spigolo di una curva sia sincronizzato con lo spigolo di un'altra ( se questi esistono)... Pertanto
|
||||
// la Bezier Ruled ricavata non è detto che sia in grado di approssimare lo spigolo correttamente, potrebbe sdondarlo
|
||||
PtrOwner<ICurveComposite> pCrvQuad1( ConvertCurveToComposite( pCrvEdge1->CopyParamRange( dUPrev1, dUCurr1))) ;
|
||||
PtrOwner<ICurveComposite> pCrvQuad2( ConvertCurveToComposite( pCrvEdge2->CopyParamRange( dUPrev2, dUCurr2))) ;
|
||||
ManageEdgesInQuadrangulation( pCrvQuad1, pCrvQuad2, vEdgeSyncLines) ;
|
||||
|
||||
//debug
|
||||
//for ( int i = 0 ; i < ssize( vEdgeSyncLines) ; ++ i) {
|
||||
// PtrOwner<ICurveLine> pLine( CreateCurveLine()) ; pLine->Set( vEdgeSyncLines[i].first, vEdgeSyncLines[i].second) ;
|
||||
// int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrp, Release( pLine)) ;
|
||||
// pGeomDB->SetMaterial( nNewId, GREEN) ;
|
||||
//////////////////////////N.B.: se si aggiunge questo pezzo bisogna anche gestire il fatto che i punti precedentemente aggiunti potrebbero non stare più sulla curva modificata!!!
|
||||
//// verifico se sono vicino ad una joint esistente allora modifico la curva 2
|
||||
//double dUClosestJoint2 = round( dUCurr2) ;
|
||||
//double dLenAlt2 = 0 ; pCrvEdge2->GetLengthAtParam( dUClosestJoint2, dLenAlt2) ;
|
||||
//if ( abs( dLenCurr2 - dLenAlt2) < 1) {
|
||||
// Point3d ptNewJoint ; pCrvEdge2->GetPointD1D2( dUCurr2, ICurve::FROM_MINUS, ptNewJoint) ;
|
||||
// if ( pCrvEdge2->ModifyJoint( int( dUClosestJoint2), ptNewJoint))
|
||||
// dUCurr2 = dUClosestJoint2 ;
|
||||
//}
|
||||
|
||||
|
||||
// Aggiorno i parametri
|
||||
pCrvEdge2->GetPointD1D2( dUCurr2, ICurve::FROM_MINUS, ptCurr2, &vtCurr2) ;
|
||||
|
||||
#if DEBUG_SYNCLINES
|
||||
PtrOwner<IGeoPoint3d> ptGeo2( CreateGeoPoint3d()) ; ptGeo2->Set( ptCurr2) ;
|
||||
PtrOwner<IGeoVector3d> vtGeo2( CreateGeoVector3d()) ; vtGeo2->Set( 5. * vtCurr2, ptCurr2) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nLay2, Release( ptGeo2)) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nLay2, Release( vtGeo2)) ;
|
||||
#endif
|
||||
vSyncLines.emplace_back( ptCurr1, ptCurr2) ;
|
||||
|
||||
// --- Analisi degli spigoli all'interno della Quadrangolazione corrente ---
|
||||
// NB. Non è sempre detto che uno spigolo di una curva sia sincronizzato con lo spigolo di un'altra ( se questi esistono)...
|
||||
// Pertanto la Bezier Ruled ricavata non è detto che sia in grado di approssimare lo spigolo correttamente, potrebbe sdondarlo
|
||||
PtrOwner<ICurveComposite> pCrvQuad1( ConvertCurveToComposite( pCrvEdge1->CopyParamRange( dUPrev1, dUCurr1))) ;
|
||||
PtrOwner<ICurveComposite> pCrvQuad2( ConvertCurveToComposite( pCrvEdge2->CopyParamRange( dUPrev2, dUCurr2))) ;
|
||||
BIPNTVECTOR vEdgeSyncLines ;
|
||||
ManageEdgesInQuadrangulation( pCrvQuad1, pCrvQuad2, vEdgeSyncLines) ;
|
||||
|
||||
// --- Aggiunta di Linee di Sync all'interno della Quandrangolazione corrente ---
|
||||
// Perchè parametrizzando per la lunghezza i SottoTratti ricavati, nel caso di elevate variazioni angolari tra l'inizio e la fine
|
||||
// ( tra due curva di Sync) si potrebbero generare delle torsioni non volute
|
||||
// -->! NB. Queste linee vengono create considerando le SubQuadrangolazioni con gli Spigoli. !<--
|
||||
BIPNTVECTOR vTwistSyncLines ;
|
||||
bool bEraseLastIso = false ;
|
||||
if ( vEdgeSyncLines.empty())
|
||||
ManageTwistInQuadrangulation( pCrvQuad1, pCrvQuad2, vTwistSyncLines, bEraseLastIso) ;
|
||||
else {
|
||||
BIPOINT SyncLinePrev, SyncLineNext ;
|
||||
pCrvQuad1->GetStartPoint( SyncLinePrev.first) ;
|
||||
pCrvQuad2->GetStartPoint( SyncLinePrev.second) ;
|
||||
for ( int i = 0 ; i < ssize( vEdgeSyncLines) ; ++ i) {
|
||||
if ( i == ssize( vEdgeSyncLines) - 1) {
|
||||
pCrvQuad1->GetEndPoint( SyncLineNext.first) ;
|
||||
pCrvQuad2->GetEndPoint( SyncLineNext.second) ;
|
||||
}
|
||||
else {
|
||||
SyncLineNext.first = vEdgeSyncLines[i].first ;
|
||||
SyncLineNext.second = vEdgeSyncLines[i].second ;
|
||||
}
|
||||
// Recupero i parametri correnti
|
||||
double dUS1, dUE1, dUS2, dUE2 ;
|
||||
pCrvQuad1->GetParamAtPoint( SyncLinePrev.first, dUS1) ;
|
||||
pCrvQuad2->GetParamAtPoint( SyncLinePrev.second, dUS2) ;
|
||||
pCrvQuad1->GetParamAtPoint( SyncLineNext.first, dUE1) ;
|
||||
pCrvQuad2->GetParamAtPoint( SyncLineNext.second, dUE2) ;
|
||||
PtrOwner<ICurveComposite> pCrvSubQuad1( ConvertCurveToComposite( pCrvQuad1->CopyParamRange( dUS1, dUE1))) ;
|
||||
PtrOwner<ICurveComposite> pCrvSubQuad2( ConvertCurveToComposite( pCrvQuad2->CopyParamRange( dUE1, dUE2))) ;
|
||||
ManageTwistInQuadrangulation( pCrvSubQuad1, pCrvSubQuad2, vTwistSyncLines, bEraseLastIso) ;
|
||||
// Aggiorno i parametri
|
||||
SyncLinePrev = SyncLineNext ;
|
||||
}
|
||||
bEraseLastIso = false ;
|
||||
}
|
||||
if ( bEraseLastIso) {
|
||||
vSyncLines.pop_back() ;
|
||||
double dQuadLen1 ; pCrvQuad1->GetLengthAtPoint( vTwistSyncLines[0].first, dQuadLen1) ;
|
||||
dLenCurr1 = dLenPrev1 + dQuadLen1 ;
|
||||
double dQuadLen2 ; pCrvQuad2->GetLengthAtPoint( vTwistSyncLines[0].second, dQuadLen2) ;
|
||||
dLenCurr2 = dLenPrev2 + dQuadLen2 ;
|
||||
}
|
||||
// aggiungo le nuove curve ( non importa che siano ordinate per parametro)
|
||||
vSyncLines.insert( vSyncLines.end(), vEdgeSyncLines.begin(), vEdgeSyncLines.end()) ;
|
||||
vSyncLines.insert( vSyncLines.end(), vTwistSyncLines.begin(), vTwistSyncLines.end()) ;
|
||||
|
||||
// Aggiorno i parametri
|
||||
ptPrev1 = ptCurr1 ; dUPrev1 = dUCurr1 ; dLenPrev1 = dLenCurr1 ;
|
||||
ptPrev2 = ptCurr2 ; dUPrev2 = dUCurr2 ; dLenPrev2 = dLenCurr2 ;
|
||||
}
|
||||
|
||||
return CreateByIsoParamSet( pCrvEdge1, pCrvEdge2, vEdgeSyncLines) ;
|
||||
#if SAVEPACEDISO
|
||||
SaveGeoObj( vGeo, vCol, "D:\\Temp\\bezier\\ruled\\trimming\\smooth.nge") ;
|
||||
#endif
|
||||
|
||||
return CreateByIsoParamSet( pCrvEdge1, pCrvEdge2, vSyncLines) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -155,6 +155,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
bool SwapParameters( void) ;
|
||||
bool LimitSurfToTrimmedRegion( void) override ;
|
||||
bool CreateSmoothRuledByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, double dSampleLen) override ;
|
||||
bool CreateSmoothRuledByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, double dSampleLen, BIPNTVECTOR& vSyncLines) override ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
|
||||
+37
-13
@@ -1188,8 +1188,10 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR&
|
||||
pSfrTria->Offset( dTol, ICurve::OFF_FILLET) ;
|
||||
if ( IsNull( pSfr))
|
||||
pSfr.Set( pSfrTria) ;
|
||||
else
|
||||
pSfr->Add( *pSfrTria) ;
|
||||
else {
|
||||
if ( ! pSfr->Add( *pSfrTria))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// passo al successivo
|
||||
@@ -1201,14 +1203,18 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR&
|
||||
return false ;
|
||||
|
||||
// Effettuo contro-offset
|
||||
pSfr->Offset( -dTol, ICurve::OFF_EXTEND) ;
|
||||
if ( ! pSfr->Offset( -dTol, ICurve::OFF_EXTEND))
|
||||
return false ;
|
||||
|
||||
// Recupero i contorni della regione
|
||||
for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) {
|
||||
for ( int j = 0 ; j < pSfr->GetLoopCount( i) ; ++ j) {
|
||||
PolyLine PL ;
|
||||
if ( pSfr->ApproxLoopWithLines( i, j, LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
||||
vPL.emplace_back( PL) ;
|
||||
if ( ! pSfr->ApproxLoopWithLines( i, j, LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL)) {
|
||||
vPL.clear() ;
|
||||
return false ;
|
||||
}
|
||||
vPL.emplace_back( PL) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1259,8 +1265,10 @@ SurfTriMesh::GetSilhouette( const Plane3d& plPlane, double dTol, POLYLINEVECTOR&
|
||||
pSfrTria->Offset( dTol, ICurve::OFF_FILLET) ;
|
||||
if ( IsNull( pSfr))
|
||||
pSfr.Set( pSfrTria) ;
|
||||
else
|
||||
pSfr->Add( *pSfrTria) ;
|
||||
else {
|
||||
if ( ! pSfr->Add( *pSfrTria))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1274,14 +1282,18 @@ SurfTriMesh::GetSilhouette( const Plane3d& plPlane, double dTol, POLYLINEVECTOR&
|
||||
return true ;
|
||||
|
||||
// Effettuo contro-offset
|
||||
pSfr->Offset( -dTol, ICurve::OFF_EXTEND) ;
|
||||
if ( ! pSfr->Offset( -dTol, ICurve::OFF_EXTEND))
|
||||
return false ;
|
||||
|
||||
// Recupero i contorni della regione
|
||||
for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) {
|
||||
for ( int j = 0 ; j < pSfr->GetLoopCount( i) ; ++ j) {
|
||||
PolyLine PL ;
|
||||
if ( pSfr->ApproxLoopWithLines( i, j, LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
||||
vPL.emplace_back( PL) ;
|
||||
if ( ! pSfr->ApproxLoopWithLines( i, j, LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL)) {
|
||||
vPL.clear() ;
|
||||
return false ;
|
||||
}
|
||||
vPL.emplace_back( PL) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3810,12 +3822,19 @@ SurfTriMesh::VerifyConnection( bool bShellsAndParts) const
|
||||
BBox3d b3Box ;
|
||||
PtrOwner<ISurfTriMesh> pStmShell ;
|
||||
} ;
|
||||
// vettore di shell con vettori dei propri triangoli (per accelerare nei casi degeneri)
|
||||
INTMATRIX mShellTria( m_nShells) ;
|
||||
for ( int i = 0 ; i < ssize( m_vTria) ; ++ i) {
|
||||
if ( m_vTria[i].nShell < m_nShells)
|
||||
mShellTria[m_vTria[i].nShell].push_back( i) ;
|
||||
}
|
||||
// classificazione delle shell
|
||||
vector<SHELLINFO> vOuterShells ;
|
||||
vector<SHELLINFO> vInnerShells ;
|
||||
INTVECTOR vOpenShells ;
|
||||
for ( int nSh = 0 ; nSh < m_nShells ; ++ nSh) {
|
||||
// se la shell è chiusa
|
||||
if ( IsShellClosed( nSh)) {
|
||||
if ( ssize( mShellTria[nSh]) >= 4 && IsShellClosed( nSh)) {
|
||||
// creo una superficie clonata dalla shell
|
||||
PtrOwner<ISurfTriMesh> pStmShell( CloneShell( nSh)) ;
|
||||
if ( IsNull( pStmShell) || ! pStmShell->IsValid())
|
||||
@@ -3827,7 +3846,9 @@ SurfTriMesh::VerifyConnection( bool bShellsAndParts) const
|
||||
BBox3d b3Box ;
|
||||
pStmShell->GetLocalBBox( b3Box, BBF_STANDARD) ;
|
||||
// la inserisco nel vettore opportuno
|
||||
if ( dVol > 0)
|
||||
if ( abs( dVol) < 1 * 1 * EPS_SMALL)
|
||||
vOpenShells.push_back( nSh) ;
|
||||
else if ( dVol > 0)
|
||||
vOuterShells.emplace_back( nSh, dVol, b3Box, Release( pStmShell)) ;
|
||||
else
|
||||
vInnerShells.emplace_back( nSh, dVol, b3Box, Release( pStmShell)) ;
|
||||
@@ -3979,6 +4000,7 @@ SurfTriMesh::IsShellClosed( int nShell) const
|
||||
return false ;
|
||||
// ciclo sui triangoli della shell
|
||||
bool bClosed = true ;
|
||||
int nTriaCnt = 0 ;
|
||||
for ( int i = 0 ; i < GetTriangleSize() ; ++ i) {
|
||||
// se triangolo non cancellato e della shell
|
||||
if ( m_vTria[i].nIdVert[0] != SVT_DEL && m_vTria[i].nShell == nShell) {
|
||||
@@ -3989,10 +4011,12 @@ SurfTriMesh::IsShellClosed( int nShell) const
|
||||
bClosed = false ;
|
||||
break ;
|
||||
}
|
||||
else
|
||||
++ nTriaCnt ;
|
||||
}
|
||||
}
|
||||
// restituisco il risultato
|
||||
return bClosed ;
|
||||
return ( bClosed && nTriaCnt >= 4) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+648
-117
@@ -36,13 +36,13 @@
|
||||
#include "/EgtDev/Include/EGkIntersLineBox.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurvePlane.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMeshAux.h"
|
||||
#include "/EgtDev/Include/EGkRotationMinimizingFrame.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include <thread>
|
||||
#include <future>
|
||||
#include <numeric>
|
||||
|
||||
// -------------------------- Debug --------------------------------------------
|
||||
#define DEBUG 0
|
||||
#define DEBUG_BASIC_BORDERS 0
|
||||
#define DEBUG_CHAIN_CURVES 0
|
||||
#define DEBUG_ANG_APPROX 0
|
||||
@@ -63,11 +63,12 @@
|
||||
#define DEBUG_EDGES 0
|
||||
#define DEBUG_SHAPE_STM 0
|
||||
#define DEBUG_HOLES 0
|
||||
#define DEBUG_SMOOTH_CURVATURE 0
|
||||
#if DEBUG_BASIC_BORDERS || DEBUG_CHAIN_CURVES || DEBUG_ANG_APPROX || DEBUG_BEZIER_INTERP || \
|
||||
DEBUG_FACE_SEARCH || DEBUG_FACE_SEARCH_TRIA_MODIF || DEBUG_BRK_POINTS || DEBUG_BRK_THICK || \
|
||||
DEBUG_BRK || DEBUG_BORDERS_BY_NORMALS || DEBUG_SYNC_POINTS || DEBUG_SYNC_INTERPOLATION || \
|
||||
DEBUG_BEZIER_RULED || DEBUG_CURVATURE || DEBUG_SIMPLE_PATCHES || DEBUG_SURF_PATCHES || \
|
||||
DEBUG_RAW_EDGES || DEBUG_EDGES || DEBUG_SHAPE_STM || DEBUG_HOLES || DEBUG
|
||||
DEBUG_RAW_EDGES || DEBUG_EDGES || DEBUG_SHAPE_STM || DEBUG_HOLES || DEBUG_SMOOTH_CURVATURE
|
||||
#include "CurveLine.h"
|
||||
#include "/EgtDev/Include/EGkGeoObjSave.h"
|
||||
#include "/EgtDev/Include/EgtPerfCounter.h"
|
||||
@@ -284,58 +285,6 @@ GetPointSetByAngTol( const PolyLine& PL, double dAngTol, POLYLINEVECTOR& vPL)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Funzione per spezzare una curva compo in diversi tratti in corrispondenza
|
||||
// di cambi di direzione maggiori della tolleranza angolare passata
|
||||
static bool
|
||||
SplitCurveCompoByAngTol( const ICurveComposite* pCC, double dAngTol, ICRVCOMPOPOVECTOR& vCC)
|
||||
{
|
||||
int nCurves = pCC->GetCurveCount() ;
|
||||
vCC.emplace_back( CreateCurveComposite()) ;
|
||||
vCC.back()->AddCurve( pCC->GetCurve(0)->Clone()) ;
|
||||
// Cos della tolleranza angolare massima
|
||||
double dCosTol = cos( dAngTol * DEGTORAD) ;
|
||||
|
||||
for ( int nC = 0 ; nC < nCurves - 2; ++ nC) {
|
||||
// Recupero l'angolo tra la fine della curva corrente e l'inizio della successiva
|
||||
const ICurve* pCrvCurr = pCC->GetCurve( nC) ;
|
||||
const ICurve* pCrvNext = pCC->GetCurve( nC + 1) ;
|
||||
Vector3d vtCurrEnd ; pCrvCurr->GetEndDir( vtCurrEnd) ;
|
||||
Vector3d vtNextStart ; pCrvNext->GetStartDir( vtNextStart) ;
|
||||
// Calcolo il Coseno tra i due versori
|
||||
double dCos = vtCurrEnd * vtNextStart ;
|
||||
// Se dentro alla tolleranza, allora i punti apparterranno alla stessa curva
|
||||
if ( dCos > dCosTol) {
|
||||
// Aggiungo la curva
|
||||
vCC.back()->AddCurve( pCrvNext->Clone()) ;
|
||||
}
|
||||
// Se tratto al di fuori della tolleranza, devo definire una nuova curva
|
||||
else {
|
||||
vCC.emplace_back( CreateCurveComposite()) ;
|
||||
vCC.back()->AddCurve( pCrvNext->Clone()) ;
|
||||
}
|
||||
}
|
||||
|
||||
// Se curva originale chiusa
|
||||
if ( pCC->IsClosed() && ssize( vCC) > 1) {
|
||||
// Se ho più tratti, potrei riunire il primo con l'ultimo
|
||||
const ICurve* pCrvFirst = pCC->GetCurve( 0) ;
|
||||
const ICurve* pCrvLast = pCC->GetCurve( nCurves - 1) ;
|
||||
Vector3d vtFirstStart ; pCrvFirst->GetEndDir( vtFirstStart) ;
|
||||
Vector3d vtLastEnd ; pCrvLast->GetStartDir( vtLastEnd) ;
|
||||
// Calcolo il Coseno tra i due versori
|
||||
double dCos = vtFirstStart * vtLastEnd ;
|
||||
// Se dentro alla tolleranza, allora i punti appartengono alla stessa curva
|
||||
if ( dCos > dCosTol) {
|
||||
// Aggiungo la curva
|
||||
vCC.back()->AddCurve( Release( vCC.front())) ;
|
||||
vCC.erase( vCC.begin()) ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
////-----------------------------------------------------------------------------
|
||||
//// Funzione che approssima la curva di bordo per la costruzione della Bezier Ruled mediante
|
||||
//// Patches di curve di Bezier
|
||||
@@ -3584,10 +3533,11 @@ IsBorderAButtonHole( const PolyLine& PL, double dLinTol, double dAngTol, Frame3d
|
||||
//-----------------------------------------------------------------------------
|
||||
static bool
|
||||
InterpolateSyncCurvesOnEndGuidePoints( const ICurveComposite* pGuide, const ICurveComposite* pOtherGuide,
|
||||
const Plane3d& plStart, const Plane3d& plEnd, double dLinTol,
|
||||
BIPNTVECTOR& vBiPts)
|
||||
const Plane3d& plStart, const Plane3d& plEnd, const Vector3d vtAuxStart, const Vector3d vtAuxEnd,
|
||||
double dLinTol, BIPNTVECTOR& vBiPts)
|
||||
{
|
||||
vBiPts.clear() ;
|
||||
const double dLinAngTol = 15 * EPS_SMALL ; // tolleranza sulla lunghezza della corda dell'angolo di tolleranza
|
||||
|
||||
// Verifico che le curve siano valide
|
||||
if ( pGuide == nullptr || ! pGuide->IsValid() ||
|
||||
@@ -3617,52 +3567,134 @@ InterpolateSyncCurvesOnEndGuidePoints( const ICurveComposite* pGuide, const ICur
|
||||
// Interpolo le normali dei piani rispetto a tale valore
|
||||
Vector3d vtN = Media( plStart.GetVersN(), plEnd.GetVersN(), dInterPar) ;
|
||||
vtN.Normalize() ;
|
||||
Vector3d vtAux = Media( vtAuxStart, vtAuxEnd, dInterPar) ; vtAux.Normalize() ;
|
||||
// Definisco il piano di intersezione
|
||||
Point3d ptCurr ;
|
||||
if ( ! pCrv->GetEndPoint( ptCurr))
|
||||
return false ;
|
||||
|
||||
// con i piani
|
||||
#if DEBUG_SYNC_INTERPOLATION
|
||||
Frame3d frPl ; frPl.Set( ptCurr, vtN) ;
|
||||
PtrOwner<IGeoFrame3d> frCurr( CreateGeoFrame3d()) ; frCurr->Set( frPl) ;
|
||||
VT.emplace_back( Release( frCurr)) ;
|
||||
VC.emplace_back( WHITE) ;
|
||||
SaveGeoObj( VT, VC, "C:\\Temp\\SyncLinesPlanes.nge") ;
|
||||
SaveGeoObj( VT, VC, "C:\\Temp\\trimming\\interpolate\\SyncLinesPlanes.nge") ;
|
||||
#endif
|
||||
// Recupero il parametro di intersezione tra la curva e il piano
|
||||
#if 0
|
||||
VT.clear() ; VC.clear() ;
|
||||
PtrOwner<IGeoPoint3d> PT( CreateGeoPoint3d()) ; PT->Set( ptCurr) ;
|
||||
VT.emplace_back( Release( PT)) ;
|
||||
VC.emplace_back( AQUA) ;
|
||||
PtrOwner<IGeoVector3d> VECT( CreateGeoVector3d()) ; VECT->Set( vtN) ;
|
||||
VECT->ChangeBase( ptCurr) ;
|
||||
PtrOwner<ICurveArc> pArc( CreateCurveArc()) ; pArc->Set( ptCurr, vtN, 1000.) ;
|
||||
PtrOwner<ISurfFlatRegion> pSfrPlane( CreateSurfFlatRegion()) ;
|
||||
pSfrPlane->AddExtLoop( Release( pArc)) ;
|
||||
VT.emplace_back( Release( pSfrPlane)) ;
|
||||
VC.emplace_back( Color( 0., 0., 0., .5)) ;
|
||||
VT.emplace_back( Release( VECT)) ;
|
||||
VC.emplace_back( BLUE) ;
|
||||
VT.emplace_back( pOtherGuide->Clone()) ;
|
||||
VC.emplace_back( WHITE) ;
|
||||
SaveGeoObj( VT, VC, "C:\\Temp\\SyncLinesPlanes.nge") ;
|
||||
#endif
|
||||
IntersCurvePlane IntCP( *pOtherGuide, ptCurr, vtN) ;
|
||||
if ( IntCP.GetIntersCount() == 0)
|
||||
return false ; // ambiguità
|
||||
// Recupero il punto della prima intersezione trovata
|
||||
Point3d ptInt ;
|
||||
double dPar ;
|
||||
if ( ! IntCP.GetIntersPointNearTo( ptCurr, ptInt, dPar))
|
||||
return false ;
|
||||
#if DEBUG_SYNC_INTERPOLATION
|
||||
PtrOwner<IGeoPoint3d> ptG( CreateGeoPoint3d()) ; ptG->Set( ptInt) ;
|
||||
VT.emplace_back( Release( ptG)) ;
|
||||
VC.emplace_back( WHITE) ;
|
||||
SaveGeoObj( VT, VC, "C:\\Temp\\SyncLinesPlanes.nge") ;
|
||||
if ( false) {
|
||||
VT.clear() ; VC.clear() ;
|
||||
PtrOwner<IGeoPoint3d> PT( CreateGeoPoint3d()) ; PT->Set( ptCurr) ;
|
||||
VT.emplace_back( Release( PT)) ;
|
||||
VC.emplace_back( AQUA) ;
|
||||
PtrOwner<IGeoVector3d> VECT( CreateGeoVector3d()) ; VECT->Set( vtN) ;
|
||||
VECT->ChangeBase( ptCurr) ;
|
||||
PtrOwner<ICurveArc> pArc( CreateCurveArc()) ; pArc->Set( ptCurr, vtN, 1000.) ;
|
||||
PtrOwner<ISurfFlatRegion> pSfrPlane( CreateSurfFlatRegion()) ;
|
||||
pSfrPlane->AddExtLoop( Release( pArc)) ;
|
||||
VT.emplace_back( Release( pSfrPlane)) ;
|
||||
VC.emplace_back( Color( 0., 0., 0., .5)) ;
|
||||
VT.emplace_back( Release( VECT)) ;
|
||||
VC.emplace_back( BLUE) ;
|
||||
VT.emplace_back( pOtherGuide->Clone()) ;
|
||||
VC.emplace_back( WHITE) ;
|
||||
SaveGeoObj( VT, VC, "C:\\Temp\\trimming\\interpolate\\SyncLinesPlanes.nge") ;
|
||||
}
|
||||
#endif
|
||||
// Memorizzo tale punto
|
||||
vBiPts.emplace_back( make_pair( ptCurr, ptInt)) ;
|
||||
|
||||
IntersCurvePlane IntCP( *pOtherGuide, ptCurr, vtN) ;
|
||||
bool bFound = false ;
|
||||
if ( IntCP.GetIntersCount() != 0) {
|
||||
// Recupero il punto della prima intersezione trovata
|
||||
Point3d ptIntClosest ;
|
||||
double dPar ;
|
||||
IntCP.GetIntersPointNearTo( ptCurr, ptIntClosest, dPar) ;
|
||||
// verifico che sia allineato con la direzione che dovrebbe avere
|
||||
Vector3d vtDir = ptIntClosest - ptCurr ;
|
||||
vtDir.Normalize() ;
|
||||
double dDiff = (vtDir - vtAux).Len() ;
|
||||
if ( dDiff < dLinAngTol) {
|
||||
#if DEBUG_SYNC_INTERPOLATION
|
||||
PtrOwner<IGeoPoint3d> ptG( CreateGeoPoint3d()) ; ptG->Set( ptIntClosest) ;
|
||||
VT.emplace_back( Release( ptG)) ;
|
||||
VC.emplace_back( WHITE) ;
|
||||
SaveGeoObj( VT, VC, "C:\\Temp\\trimming\\interpolate\\SyncLinesPlanes.nge") ;
|
||||
#endif
|
||||
//Memorizzo tale punto
|
||||
vBiPts.emplace_back( make_pair( ptCurr, ptIntClosest)) ;
|
||||
bFound = true ;
|
||||
}
|
||||
else if ( IntCP.GetIntersCount() > 1) {
|
||||
double dMinDiff = INFINITO ;
|
||||
Point3d ptBest ;
|
||||
for ( int j = 0 ; j < IntCP.GetIntersCount() ; ++j) {
|
||||
IntCrvPlnInfo icpi ; IntCP.GetIntCrvPlnInfo( j, icpi) ;
|
||||
Point3d ptInt = icpi.Ici->ptI ;
|
||||
double dDiff = ( ptInt - ptCurr).Len() ;
|
||||
if ( dDiff < dMinDiff) {
|
||||
dMinDiff = dDiff ;
|
||||
ptBest = ptInt ;
|
||||
}
|
||||
}
|
||||
if ( dMinDiff < dLinAngTol)
|
||||
bFound = true ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! bFound) {
|
||||
// applico la direzione desiderata nel punto corrente della guida
|
||||
// calcolo la lunghezza dell'isocurva in quella zona
|
||||
Point3d ptS1, ptS2 ;
|
||||
pGuide->GetStartPoint( ptS1) ;
|
||||
pOtherGuide->GetStartPoint( ptS2);
|
||||
double dDistRef = Dist( ptS1, ptS2) ;
|
||||
double dParamOther = -1. ;
|
||||
int nFlag = -1 ;
|
||||
Point3d ptEnd = ptCurr + (vtAux * dDistRef) ;
|
||||
if ( ! DistPointCurve( ptEnd, *pOtherGuide).GetParamAtMinDistPoint( 0, dParamOther, nFlag))
|
||||
return false ;
|
||||
|
||||
// nell'intorno del più vicino, cerco l'isocurva più vicina alla direzione desiderata
|
||||
Point3d ptBest ;
|
||||
double dMinDiff = INFINITO ;
|
||||
double dSearchLen = 3. ;
|
||||
double dStepLen = 0.1 ;
|
||||
double dCurrLenOther ; pOtherGuide->GetLengthAtParam( dParamOther, dCurrLenOther) ;
|
||||
double dLenOther ; pOtherGuide->GetLength( dLenOther) ;
|
||||
dCurrLenOther -= dSearchLen ;
|
||||
dCurrLenOther = Clamp( dCurrLenOther, 0., dLenOther) ;
|
||||
for ( int j = 0 ; j < 2 * dSearchLen / dStepLen ; ++j) {
|
||||
dCurrLenOther += j * dStepLen ;
|
||||
if ( dCurrLenOther > dLenOther)
|
||||
break ;
|
||||
double dCurrParOther = 0 ; pOtherGuide->GetParamAtLength( dCurrLenOther, dCurrParOther) ;
|
||||
Point3d ptCurrOther ; pOtherGuide->GetPointD1D2( dCurrParOther, ICurve::FROM_MINUS, ptCurrOther) ;
|
||||
Vector3d vtDir = ptCurrOther - ptCurr ; vtDir.Normalize() ;
|
||||
double dDiff = ( vtDir - vtAux).Len() ;
|
||||
if ( dDiff < dMinDiff) {
|
||||
dMinDiff = dDiff ;
|
||||
ptBest = ptCurrOther ;
|
||||
}
|
||||
#if DEBUG_SYNC_INTERPOLATION
|
||||
VT.clear() ;
|
||||
VC.clear() ;
|
||||
VT.emplace_back( pGuide->Clone()) ;
|
||||
VC.emplace_back( BLUE) ;
|
||||
VT.emplace_back( pOtherGuide->Clone()) ;
|
||||
VC.emplace_back( BLUE) ;
|
||||
PtrOwner<IGeoVector3d> vtFirst( CreateGeoVector3d()) ; vtFirst->Set( -vtN * 12, ptCurrOther) ;
|
||||
VT.emplace_back( Release( vtFirst)) ;
|
||||
VC.emplace_back( AQUA) ;
|
||||
PtrOwner<IGeoVector3d> vtCurr( CreateGeoVector3d()) ; vtCurr->Set( -vtDir * 12, ptCurrOther) ;
|
||||
VT.emplace_back( Release( vtCurr)) ;
|
||||
VC.emplace_back( WHITE) ;
|
||||
SaveGeoObj( VT, VC, "C:\\Temp\\trimming\\interpolate\\SyncLinesPlanes.nge") ;
|
||||
#endif
|
||||
}
|
||||
if ( dMinDiff < 2 * dLinAngTol)
|
||||
vBiPts.emplace_back( make_pair( ptCurr, ptBest)) ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -3947,8 +3979,8 @@ GetTrimmingSurfBzSyncPoints( const ICurve* pCrvEdge1, const ICurve* pCrvEdge2,
|
||||
! pCompoEdge1->IsValid() || ! pCompoEdge2->IsValid())
|
||||
return false ;
|
||||
|
||||
// Controllo sulla tolleranza lineare
|
||||
double dMyLinTol = Clamp( dLinTol, EPS_SMALL, 1e5 * EPS_SMALL) ;
|
||||
//// Controllo sulla tolleranza lineare
|
||||
//double dMyLinTol = Clamp( dLinTol, EPS_SMALL, 1e5 * EPS_SMALL) ;
|
||||
|
||||
#if DEBUG_SYNC_POINTS
|
||||
VT.clear() ; VC.clear() ;
|
||||
@@ -3959,26 +3991,26 @@ GetTrimmingSurfBzSyncPoints( const ICurve* pCrvEdge1, const ICurve* pCrvEdge2,
|
||||
#endif
|
||||
|
||||
// Definisco la superficie di Bezier rigata
|
||||
PtrOwner<SurfBezier> pSBzRuled( GetBasicSurfBezier( GetSurfBezierRuled( pCompoEdge1, pCompoEdge2, ISurfBezier::RLT_B_MINDIST_PLUS, dMyLinTol))) ;
|
||||
PtrOwner<SurfBezier> pSBzRuled( GetBasicSurfBezier( GetSurfBezierRuledSmooth( pCompoEdge1, pCompoEdge2, vSyncPoints, 20.0))) ;
|
||||
if ( IsNull( pSBzRuled) || ! pSBzRuled->IsValid())
|
||||
return false ;
|
||||
|
||||
// Recupero i punti di sincronizzazione e li restituisco
|
||||
ICURVEPOVECTOR vCrv ;
|
||||
pSBzRuled->GetAllPatchesIsocurves( false, vCrv) ;
|
||||
vSyncPoints.reserve( vCrv.size()) ;
|
||||
for ( int i = 0 ; i < ssize( vCrv) ; ++ i) {
|
||||
if ( ! IsNull( vCrv[i]) && vCrv[i]->IsValid()) {
|
||||
#if DEBUG_SYNC_POINTS
|
||||
VT.emplace_back( vCrv[i]->Clone()) ;
|
||||
VC.emplace_back( LIME) ;
|
||||
#endif
|
||||
Point3d ptStart ; vCrv[i]->GetStartPoint( ptStart) ;
|
||||
Point3d ptEnd ; vCrv[i]->GetEndPoint( ptEnd) ;
|
||||
if ( ! AreSamePointApprox( ptStart, ptEnd))
|
||||
vSyncPoints.emplace_back( make_pair( ptStart, ptEnd)) ;
|
||||
}
|
||||
}
|
||||
//// Recupero i punti di sincronizzazione e li restituisco
|
||||
// ICURVEPOVECTOR vCrv ;
|
||||
// pSBzRuled->GetAllPatchesIsocurves( false, vCrv) ;
|
||||
// vSyncPoints.reserve( vCrv.size()) ;
|
||||
// for ( int i = 0 ; i < ssize( vCrv) ; ++ i) {
|
||||
// if ( ! IsNull( vCrv[i]) && vCrv[i]->IsValid()) {
|
||||
// #if DEBUG_SYNC_POINTS
|
||||
// VT.emplace_back( vCrv[i]->Clone()) ;
|
||||
// VC.emplace_back( LIME) ;
|
||||
// #endif
|
||||
// Point3d ptStart ; vCrv[i]->GetStartPoint( ptStart) ;
|
||||
// Point3d ptEnd ; vCrv[i]->GetEndPoint( ptEnd) ;
|
||||
// if ( ! AreSamePointApprox( ptStart, ptEnd))
|
||||
// vSyncPoints.emplace_back( make_pair( ptStart, ptEnd)) ;
|
||||
// }
|
||||
// }
|
||||
|
||||
#if DEBUG_SYNC_POINTS
|
||||
SaveGeoObj( VT, VC, "C:\\Temp\\BorderSyncPoints.nge") ;
|
||||
@@ -4009,7 +4041,7 @@ GetTrimmingSyncInterpolation( const ICurve* pCrvEdge1, const ICurve* pCrvEdge2,
|
||||
|
||||
// Verifico i valori delle tolleranze
|
||||
double dMyLinTol = Clamp( dLinTol, EPS_SMALL, 1e5 * EPS_SMALL) ;
|
||||
double dMyAngTol = Clamp( dAngTol, EPS_ANG_SMALL, 60.) ;
|
||||
//double dMyAngTol = Clamp( dAngTol, EPS_ANG_SMALL, 60.) ;
|
||||
|
||||
// Verifico le due curve di sincronizzazione abbiano gli estremi sulle due curve di bordo
|
||||
Point3d ptS1 ; pSync1->GetStartPoint( ptS1) ;
|
||||
@@ -4117,18 +4149,18 @@ GetTrimmingSyncInterpolation( const ICurve* pCrvEdge1, const ICurve* pCrvEdge2,
|
||||
Vector3d vtStart1, vtStart2 ;
|
||||
if ( ! pCompoGuide1->GetStartDir( vtStart1) || ! pCompoGuide2->GetStartDir( vtStart2))
|
||||
return false ;
|
||||
Vector3d vtAux = ptE1 - ptS1 ; vtAux.Normalize() ;
|
||||
Vector3d vtAuxStart = ptE1 - ptS1 ; vtAuxStart.Normalize() ;
|
||||
Vector3d vtMTan = Media( vtStart1, vtStart2) ; vtMTan.Normalize() ;
|
||||
Vector3d vtN = OrthoCompo( vtMTan, vtAux) ; vtN.Normalize() ;
|
||||
Vector3d vtN = OrthoCompo( vtMTan, vtAuxStart) ; vtN.Normalize() ;
|
||||
Plane3d plStart ;
|
||||
if ( ! plStart.Set( ptS1, vtN))
|
||||
return false ;
|
||||
Vector3d vtEnd1, vtEnd2 ;
|
||||
if ( ! pCompoGuide1->GetEndDir( vtEnd1) || ! pCompoGuide2->GetEndDir( vtEnd2))
|
||||
return false ;
|
||||
vtAux = ptE2 - ptS2 ; vtAux.Normalize() ;
|
||||
Vector3d vtAuxEnd = ptE2 - ptS2 ; vtAuxEnd.Normalize() ;
|
||||
vtMTan = Media( vtEnd1, vtEnd2) ; vtMTan.Normalize() ;
|
||||
vtN = OrthoCompo( vtMTan, vtAux) ; vtN.Normalize() ;
|
||||
vtN = OrthoCompo( vtMTan, vtAuxEnd) ; vtN.Normalize() ;
|
||||
Plane3d plEnd ;
|
||||
if ( ! plEnd.Set( ptS2, vtN))
|
||||
return false ;
|
||||
@@ -4147,13 +4179,15 @@ GetTrimmingSyncInterpolation( const ICurve* pCrvEdge1, const ICurve* pCrvEdge2,
|
||||
|
||||
// Curve di Sincronizzazione del Bordo 1 sul Bordo 2
|
||||
BIPNTVECTOR vBiPts1 ;
|
||||
if ( ! InterpolateSyncCurvesOnEndGuidePoints( pCompoGuide1, pCompoGuide2, plStart, plEnd, dMyLinTol, vBiPts1))
|
||||
if ( ! InterpolateSyncCurvesOnEndGuidePoints( pCompoGuide1, pCompoGuide2, plStart, plEnd, vtAuxStart, vtAuxEnd, dMyLinTol, vBiPts1))
|
||||
return false ;
|
||||
|
||||
vtAuxStart *= -1 ;
|
||||
vtAuxEnd *= -1 ;
|
||||
// Curve di Sincronizzazione del Bordo 2 sul Bordo 1
|
||||
BIPNTVECTOR vBiPts2 ;
|
||||
if ( ! InterpolateSyncCurvesOnEndGuidePoints( pCompoGuide2, pCompoGuide1, plStart, plEnd, dMyLinTol, vBiPts2))
|
||||
return false ;
|
||||
//if ( ! InterpolateSyncCurvesOnEndGuidePoints( pCompoGuide2, pCompoGuide1, plStart, plEnd, vtAuxStart, vtAuxEnd, dMyLinTol, vBiPts2))
|
||||
// return false ;
|
||||
|
||||
// Restituisco le Curve di Sincronizzazione
|
||||
// [Da Bordo 1 a Bordo 2 originale]
|
||||
@@ -4219,7 +4253,8 @@ GetTrimmingRuledBezier( const CISURFPVECTOR& vSurf, const ICurve* pCrvEdge1,
|
||||
|
||||
// Se non ho punti di controllo forzati
|
||||
if ( vSyncPoints.empty()) {
|
||||
pSurfBz.Set( GetSurfBezierRuledSmooth( pCompoEdge1, pCompoEdge2, 10)) ;
|
||||
BIPNTVECTOR vSyncLines ;
|
||||
pSurfBz.Set( GetSurfBezierRuledSmooth( pCompoEdge1, pCompoEdge2, vSyncLines, 20.0)) ;
|
||||
if ( IsNull( pSurfBz) || ! pSurfBz->IsValid()) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error in Trimming : Ruled Bezier invalid") ;
|
||||
return nullptr ;
|
||||
@@ -4950,3 +4985,499 @@ GetTrimmingHoleBorders( const CISURFPVECTOR& vpSurf, const Point3d& ptRef, doubl
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
struct PntInfo{
|
||||
Point3d pt ;
|
||||
double dDist ;
|
||||
Vector3d vtPos ;
|
||||
PntInfo( const Point3d& _pt, double _dDist, const Vector3d& _vtPos) :
|
||||
pt( _pt), dDist( _dDist), vtPos( _vtPos) {;}
|
||||
};
|
||||
typedef vector<PntInfo> PNTINFOVECTOR ;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static bool
|
||||
FillPntInfo( const PNTVECTOR& vPnt, const ICurveComposite* pCC, PNTINFOVECTOR& vPntInfo)
|
||||
{
|
||||
for ( int i = 0 ; i < ssize( vPnt) - 3 ; i+=3) {
|
||||
bool bOk = false ;
|
||||
const ICurveBezier* pSubCrv = GetCurveBezier( pCC->GetCurve( i / 3)) ;
|
||||
for ( int j = i == 0 ? 0 : 1 ; j <= 3 ; ++j) {
|
||||
Point3d pt = pSubCrv->GetControlPoint( j, &bOk) ;
|
||||
double dDist = 0 ;
|
||||
Vector3d vtPos = V_NULL ;
|
||||
if ( j > 0 && j < 3){
|
||||
DistPointCurve dpc( pt, *pSubCrv) ;
|
||||
dpc.GetDist( dDist) ;
|
||||
int nFlag = - 1 ;
|
||||
Point3d ptMinDist ;
|
||||
dpc.GetMinDistPoint( 0., ptMinDist, nFlag) ;
|
||||
vtPos = pt - ptMinDist ;
|
||||
}
|
||||
vPntInfo.emplace_back( pt, dDist, vtPos) ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static bool
|
||||
RemoveInflexionPoints( PNTVECTOR& vPnt, PNTINFOVECTOR& vPntInfo, PNTINFOVECTOR& vPntRefInfo)
|
||||
{
|
||||
// se trovo tre punti di fila che sono dallo stesso lato, opposto a quello degli altri punti attorno, allora cerco di spostarli lungo la
|
||||
// normale alla superficie in modo da evitare cambi di concavità
|
||||
bool bSameSideAsPrev = true ;
|
||||
double dSmallDist = 5 * EPS_SMALL ;
|
||||
for ( int i = 2 ; i < ssize( vPntInfo) - 2 ; ++i) {
|
||||
// se è un punto di split o sta sulla curva vado avanti
|
||||
if ( vPntInfo[i].dDist < dSmallDist)
|
||||
continue ;
|
||||
int nPrev = vPntInfo[i-1].dDist < EPS_ZERO ? i - 2 : i - 1 ;
|
||||
double dProj = vPntInfo[i].vtPos * vPntInfo[nPrev].vtPos ;
|
||||
bSameSideAsPrev = dProj > EPS_ZERO ;
|
||||
if ( abs(dProj) < EPS_ZERO){
|
||||
int nPrevPrev = nPrev - 1 ;
|
||||
dProj = vPntInfo[i].vtPos * vPntInfo[nPrevPrev].vtPos ;
|
||||
bSameSideAsPrev = dProj > EPS_ZERO ;
|
||||
}
|
||||
if ( ! bSameSideAsPrev) {
|
||||
// devo verificare anche che sia diverso anche dal successivo ( o dal quello dopo ancora, se il successivo sta sulla curva)
|
||||
bool bCurrOrPrev = vPntInfo[i+1].dDist < EPS_ZERO ;
|
||||
int nFirst, nSecond, nThird ;
|
||||
if ( bCurrOrPrev) {
|
||||
nFirst = i ;
|
||||
nSecond = i + 1 ;
|
||||
nThird = i + 2 ;
|
||||
}
|
||||
else {
|
||||
nFirst = i - 2 ;
|
||||
nSecond = i - 1 ;
|
||||
nThird = i ;
|
||||
}
|
||||
int nNext = bCurrOrPrev ? i + 2 : i + 1 ;
|
||||
// se il successivo è diverso ho un terzetto anomalo da aggiustare
|
||||
// altrimenti ho un cambio naturale di concavità
|
||||
if ( vPntInfo[i].vtPos * vPntInfo[nNext].vtPos < 0 || vPntInfo[nNext].dDist < dSmallDist) {
|
||||
// ruoto il terzetto fino a matchare la tangente sull'altra curva
|
||||
// ruoto il punto solo se non stava già esattamente sulla SubCrv ( che suppongo essere un tratto rettilineo)
|
||||
if ( vPntInfo[nFirst].dDist > dSmallDist) {
|
||||
Vector3d vtCurr = vPntInfo[nSecond].pt - vPntInfo[nFirst].pt ;
|
||||
Vector3d vtRef = vPntRefInfo[nSecond].pt - vPntRefInfo[nFirst].pt ;
|
||||
Vector3d vtAx = vPntRefInfo[nSecond].pt - vPntInfo[nSecond].pt ;
|
||||
bool bDet = false ;
|
||||
double dAng = 0 ; vtCurr.GetRotation(vtRef, vtAx, dAng, bDet) ;
|
||||
if ( abs(dAng) > 170)
|
||||
dAng = 180 - dAng ;
|
||||
vPnt[nFirst].Rotate( vPnt[nSecond], vtAx, dAng) ;
|
||||
}
|
||||
if ( vPntInfo[nThird].dDist > dSmallDist) {
|
||||
Vector3d vtCurr = vPntInfo[nThird].pt - vPntInfo[nSecond].pt ;
|
||||
Vector3d vtRef = vPntRefInfo[nThird].pt - vPntRefInfo[nSecond].pt ;
|
||||
Vector3d vtAx = vPntRefInfo[nSecond].pt - vPntInfo[nSecond].pt ;
|
||||
bool bDet = false ;
|
||||
double dAng = 0 ; vtCurr.GetRotation(vtRef, vtAx, dAng, bDet) ;
|
||||
if ( abs(dAng) > 170)
|
||||
dAng = 180 - dAng ;
|
||||
vPnt[nThird].Rotate( vPnt[nSecond], vtAx, dAng) ;
|
||||
}
|
||||
if ( bCurrOrPrev)
|
||||
i += 2 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
// Funzione per la regolarizzazione delle curve di bordo di una lavorazione di trim
|
||||
// Le curve vengono modificate entro una data tolleranza, in modo che
|
||||
ISurfBezier*
|
||||
RegolarizeBordersLocallyRMF( const ISurfBezier* pSurfBz, const BIPOINT& bpIsoStart, const BIPOINT& bpIsoEnd, double dTol)
|
||||
{
|
||||
#if DEBUG_SMOOTH_CURVATURE
|
||||
VT.clear() ;
|
||||
#endif
|
||||
|
||||
// prendo per buone le isocurve di inizio e fine tratto e devo identificare tra loro le isocurve che creano troppo twist e che sono da raddrizzare
|
||||
Point3d ptS1 = bpIsoStart.first ;
|
||||
Point3d ptS2 = bpIsoEnd.first ;
|
||||
Vector3d vtDir1 = bpIsoStart.second - ptS1 ;
|
||||
Vector3d vtDir2 = bpIsoEnd.second - ptS2 ;
|
||||
|
||||
int nDegU, nDegV, nSpanU, nSpanV ;
|
||||
bool bRat, bTrimmed ;
|
||||
pSurfBz->GetInfo( nDegU, nDegV, nSpanU, nSpanV, bRat, bTrimmed) ;
|
||||
if ( nDegU != 3)
|
||||
return nullptr ;
|
||||
// individuo quali isocurve sono state indicate come inizio e fine
|
||||
PtrOwner<ICurveComposite> pCrv1( pSurfBz->GetSingleEdge3D( false, 2)) ;
|
||||
PtrOwner<ICurveComposite> pCrv2( pSurfBz->GetSingleEdge3D( false, 0)) ;
|
||||
// inverto la curva corrispondente al bordo 2 della bezier per avere le due guide concordi
|
||||
pCrv2->Invert() ;
|
||||
double dParS1 = -1 ; double dParS2 = -1 ;
|
||||
if ( ! pCrv1->GetParamAtPoint( ptS1, dParS1) || ! pCrv1->GetParamAtPoint( ptS2, dParS2))
|
||||
return nullptr ;
|
||||
int nUS1 = int ( dParS1) * nDegU ;
|
||||
int nUS2 = int ( dParS2) * nDegU ;
|
||||
if ( nUS1 > nUS2) {
|
||||
swap( nUS1, nUS2) ;
|
||||
swap( dParS1, dParS2) ;
|
||||
swap( ptS1, ptS2) ;
|
||||
swap( vtDir1, vtDir2) ;
|
||||
}
|
||||
PtrOwner<ICurveComposite> pCrvOrig1( ConvertCurveToComposite( pCrv1->CopyParamRange( dParS1, dParS2))) ;
|
||||
PtrOwner<ICurveComposite> pCrvOrig2( ConvertCurveToComposite( pCrv2->CopyParamRange( dParS1, dParS2))) ;
|
||||
|
||||
/////////////////////// versione con RMF
|
||||
// campiono finemente la prima curva e ottengo il punto che dovrebbe stare sull'altra curva
|
||||
Vector3d vtTang1 ; pCrvOrig1->GetStartDir( vtTang1) ;
|
||||
Frame3d frStart1 ; frStart1.Set( ptS1, vtTang1, vtDir1) ; // uso la tangente (come z) e l'isocurva in V (come x) per il frame iniziale
|
||||
RotationMinimizingFrame rmf ; rmf.Set( pCrvOrig1, frStart1) ;
|
||||
double dLenTot = 0. ; pCrvOrig1->GetLength( dLenTot) ;
|
||||
double dStep = dLenTot / ceil( dLenTot) ;
|
||||
FRAME3DVECTOR vRMF ;
|
||||
rmf.GetFramesByStep( dStep, true, vRMF) ;
|
||||
PNTVECTOR vPnt1 ;
|
||||
PolyLine PL2 ;
|
||||
double dLenCurr = 0. ;
|
||||
double dWidth = vtDir1.Len() ;
|
||||
for ( int i = 0 ; i < ssize( vRMF) ; ++i) {
|
||||
double dPar ; pCrvOrig1->GetParamAtLength( dLenCurr, dPar) ;
|
||||
Point3d pt0 ; pCrvOrig1->GetPointD1D2( dPar, ICurve::FROM_MINUS, pt0) ;
|
||||
Point3d pt1 = pt0 + vRMF[i].VersX() * dWidth ;
|
||||
vPnt1.push_back( pt1) ;
|
||||
PL2.AddUPoint( i, pt1) ;
|
||||
|
||||
dLenCurr += dStep ;
|
||||
}
|
||||
|
||||
CurveComposite CCToApprox2 ; CCToApprox2.FromPolyLine( PL2) ;
|
||||
Vector3d vtStart2 ; pCrvOrig2->GetStartDir( vtStart2) ;
|
||||
Vector3d vtEnd2 ; pCrvOrig2->GetEndDir( vtEnd2) ;
|
||||
PtrOwner<ICurveComposite> pCC2( ConvertCurveToComposite( ApproxCurveWithBezier( &CCToApprox2, 0.05, vtStart2, vtEnd2))) ;
|
||||
if ( IsNull( pCC2) || ! pCC2->IsValid())
|
||||
return nullptr ;
|
||||
|
||||
// dalla seconda ricostruisco la prima
|
||||
Vector3d vtTang2 ; pCC2->GetStartDir( vtTang2) ;
|
||||
Frame3d frStart2 ; frStart2.Set( bpIsoStart.second, vtTang2, vtDir1) ; // uso la tangente (come z) e l'isocurva in V (come x) per il frame iniziale
|
||||
RotationMinimizingFrame rmf2 ; rmf2.Set( pCC2, frStart2) ;
|
||||
double dLenTot2 = 0. ; pCC2->GetLength( dLenTot2) ;
|
||||
double dStep2 = dLenTot2 / ceil( dLenTot2) ;
|
||||
FRAME3DVECTOR vRMF2 ;
|
||||
rmf2.GetFramesByStep( dStep2, true, vRMF2) ;
|
||||
PNTVECTOR vPnt0 ;
|
||||
PolyLine PL1 ;
|
||||
double dLenCurr2 = 0. ;
|
||||
for ( int i = 0 ; i < ssize( vRMF2) ; ++i) {
|
||||
double dPar ; pCC2->GetParamAtLength( dLenCurr2, dPar) ;
|
||||
Point3d pt1 ; pCC2->GetPointD1D2( dPar, ICurve::FROM_MINUS, pt1) ;
|
||||
Point3d pt0 = pt1 - vRMF2[i].VersX() * dWidth ;
|
||||
vPnt0.push_back( pt0) ;
|
||||
PL1.AddUPoint( i, pt0) ;
|
||||
|
||||
dLenCurr2 += dStep2 ;
|
||||
}
|
||||
|
||||
CurveComposite CCToApprox1 ; CCToApprox1.FromPolyLine( PL1) ;
|
||||
Vector3d vtStart1 ; pCrvOrig1->GetStartDir( vtStart1) ;
|
||||
Vector3d vtEnd1 ; pCrvOrig1->GetEndDir( vtEnd1) ;
|
||||
PtrOwner<ICurveComposite> pCC1( ConvertCurveToComposite( ApproxCurveWithBezier( &CCToApprox1, 0.05, vtStart1, vtEnd1))) ;
|
||||
if ( IsNull( pCC1) || ! pCC1->IsValid())
|
||||
return nullptr ;
|
||||
|
||||
#if DEBUG_SMOOTH_CURVATURE
|
||||
for( int i = 0 ; i < ssize( vPnt1) ; ++i) {
|
||||
PtrOwner<IGeoPoint3d> pPT( CreateGeoPoint3d()) ; pPT->Set( vPnt1[i]) ;
|
||||
VT.push_back( Release( pPT)) ;
|
||||
}
|
||||
for( int i = 0 ; i < ssize( vPnt0) ; ++i) {
|
||||
PtrOwner<IGeoPoint3d> pPT( CreateGeoPoint3d()) ; pPT->Set( vPnt0[i]) ;
|
||||
VT.push_back( Release( pPT)) ;
|
||||
}
|
||||
VT.push_back( pCC1->Clone()) ;
|
||||
VT.push_back( pCC2->Clone()) ;
|
||||
SaveGeoObj( VT, "C:\\Temp\\bezier\\ruled\\smoothness\\regolarized_RMF.nge") ;
|
||||
#endif
|
||||
|
||||
// controllo di essere rimasto in tolleranza
|
||||
double dErr = 0 ;
|
||||
CalcApproxError( pCrvOrig1, pCC1, dErr, 20) ;
|
||||
if ( dErr > dTol)
|
||||
return nullptr ;
|
||||
dErr = 0 ;
|
||||
CalcApproxError( pCrvOrig2, pCC2, dErr, 20) ;
|
||||
if ( dErr > dTol)
|
||||
return nullptr ;
|
||||
|
||||
// creo una surf di bezier uguale a quella di partenza, ma a cui cambio la parte da modificare
|
||||
PtrOwner<SurfBezier> pNewSurf( CreateBasicSurfBezier()) ;
|
||||
int nNewCrvs = pCC1->GetCurveCount() ;
|
||||
if ( pCC2->GetCurveCount() != nNewCrvs)
|
||||
return nullptr ;
|
||||
int nDiff = nNewCrvs - pCrvOrig1->GetCurveCount() ;
|
||||
pNewSurf->Init( nDegU, nDegV, nSpanU, nSpanV, bRat) ;
|
||||
// copio la parte uguale
|
||||
for ( int i = 0 ; i < nSpanU * nDegU + 1 ; ++i) {
|
||||
if ( i > nUS1 && i < nUS2)
|
||||
continue ;
|
||||
bool bOk = false ;
|
||||
Point3d pt = pSurfBz->GetControlPoint( i, 0, &bOk) ;
|
||||
int nNewI = i ;
|
||||
if ( i > nUS2)
|
||||
nNewI = i + nDiff ;
|
||||
pNewSurf->SetControlPoint( nNewI, 0, pt) ;
|
||||
pt = pSurfBz->GetControlPoint( i, 1, &bOk) ;
|
||||
pNewSurf->SetControlPoint( nNewI, 1, pt) ;
|
||||
}
|
||||
// aggiungo la parte diversa
|
||||
for ( int i = 0 ; i < nNewCrvs * nDegU + 1 ; ++i) {
|
||||
int nSub = i / 3 ;
|
||||
int nPnt = i % 3 ;
|
||||
if ( nSub == nNewCrvs) {
|
||||
--nSub ;
|
||||
nPnt = 3 ;
|
||||
}
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( pCC1->GetCurve( nSub)) ;
|
||||
Point3d pt = pSubCrv1->GetControlPoint( nPnt) ;
|
||||
int nNewI = i + nUS1 ;
|
||||
pNewSurf->SetControlPoint( nNewI, 0, pt) ;
|
||||
const ICurveBezier* pSubCrv2 = GetCurveBezier( pCC2->GetCurve( nSub)) ;
|
||||
pt = pSubCrv2->GetControlPoint( nPnt) ;
|
||||
pNewSurf->SetControlPoint( nNewI, 1, pt) ;
|
||||
}
|
||||
|
||||
return Release( pNewSurf) ;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Funzione per la regolarizzazione delle curve di bordo di una lavorazione di trim
|
||||
// Le curve vengono modificate entro una data tolleranza, in modo che
|
||||
ISurfBezier*
|
||||
RegolarizeBordersLocally( const ISurfBezier* pSurfBz, const BIPOINT& bpIsoStart, const BIPOINT& bpIsoEnd, double dTol, int nType)
|
||||
{
|
||||
if ( nType == RegolarizeType::RMF)
|
||||
return RegolarizeBordersLocallyRMF( pSurfBz, bpIsoStart, bpIsoEnd, dTol) ;
|
||||
|
||||
#if DEBUG_SMOOTH_CURVATURE
|
||||
VT.clear() ;
|
||||
#endif
|
||||
|
||||
// prendo per buone le isocurve di inizio e fine tratto e devo identificare tra loro le isocurve che creano troppo twist e che sono da raddrizzare
|
||||
Point3d ptS1 = bpIsoStart.first ;
|
||||
Point3d ptS2 = bpIsoEnd.first ;
|
||||
Vector3d vtDir1 = bpIsoStart.second - ptS1 ;
|
||||
Vector3d vtDir2 = bpIsoEnd.second - ptS2 ;
|
||||
//double dInterpolateAngTol = 4 ;
|
||||
//double dAngInterp = 0 ;
|
||||
//vtDir1.GetAngle( vtDir2, dAngInterp) ;
|
||||
//bool bInterpolate = dAngInterp > dInterpolateAngTol ;
|
||||
|
||||
int nDegU, nDegV, nSpanU, nSpanV ;
|
||||
bool bRat, bTrimmed ;
|
||||
pSurfBz->GetInfo( nDegU, nDegV, nSpanU, nSpanV, bRat, bTrimmed) ;
|
||||
if ( nDegU != 3)
|
||||
return nullptr ;
|
||||
// individuo quali isocurve sono state indicate come inizio e fine
|
||||
PtrOwner<ICurveComposite> pCrv1( pSurfBz->GetSingleEdge3D( false, 2)) ;
|
||||
PtrOwner<ICurveComposite> pCrv2( pSurfBz->GetSingleEdge3D( false, 0)) ;
|
||||
// inverto la curva corrispondente al bordo 2 della bezier per avere le due guide concordi
|
||||
pCrv2->Invert() ;
|
||||
double dParS1 = -1 ; double dParS2 = -1 ;
|
||||
if ( ! pCrv1->GetParamAtPoint( ptS1, dParS1) || ! pCrv1->GetParamAtPoint( ptS2, dParS2))
|
||||
return nullptr ;
|
||||
int nUS1 = int ( dParS1) * nDegU ;
|
||||
int nUS2 = int ( dParS2) * nDegU ;
|
||||
bool bInverted = false ;
|
||||
if ( nUS1 > nUS2) {
|
||||
swap( nUS1, nUS2) ;
|
||||
swap( dParS1, dParS2) ;
|
||||
swap( ptS1, ptS2) ;
|
||||
swap( vtDir1, vtDir2) ;
|
||||
bInverted = true ;
|
||||
}
|
||||
PtrOwner<ICurve> pCrvOrig1( pCrv1->CopyParamRange( dParS1, dParS2)) ;
|
||||
PtrOwner<ICurve> pCrvOrig2( pCrv2->CopyParamRange( dParS1, dParS2)) ;
|
||||
double dLen = 0 ; pCrvOrig1->GetLength( dLen) ;
|
||||
|
||||
///// versione con correzioni a mano
|
||||
Point3d ptPrevS = ptS1 ;
|
||||
Point3d ptPrevE = ! bInverted ? bpIsoStart.second : bpIsoEnd.second ;
|
||||
Vector3d vtIsoPrev = ptPrevE - ptPrevS ; vtIsoPrev.Normalize() ;
|
||||
Point3d ptBez ; Vector3d vtNCurr ;
|
||||
pSurfBz->GetPointNrmD1D2( dParS1, 0.5, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, ptBez, vtNCurr) ;
|
||||
int nPoints = ( nUS2 - nUS1) * nDegU + 1 ;
|
||||
PNTVECTOR vPnt0 ; vPnt0.reserve( nPoints) ; vPnt0.push_back( ptPrevS) ;
|
||||
PNTVECTOR vPnt1 ; vPnt1.reserve( nPoints) ; vPnt1.push_back( ptPrevE) ;
|
||||
// salvo il secondo punto di controllo della patch
|
||||
bool bOk = false ;
|
||||
Point3d ptSecond1Curr = pSurfBz->GetControlPoint( nUS1 + 1, 0, &bOk) ;
|
||||
vPnt0.push_back( ptSecond1Curr) ;
|
||||
Point3d ptSecond2Curr = pSurfBz->GetControlPoint( nUS1 + 1, 1, &bOk) ;
|
||||
vPnt1.push_back( ptSecond2Curr) ;
|
||||
// scorro le isocurve di separazione tra patch
|
||||
for ( int i = nUS1 + 3 ; i < nUS2 ; i +=3) {
|
||||
// recupero precedente e successivo
|
||||
Point3d ptThird1Prev = pSurfBz->GetControlPoint( i - 1, 0, &bOk) ;
|
||||
Point3d ptThird2Prev = pSurfBz->GetControlPoint( i - 1, 1, &bOk) ;
|
||||
Point3d ptSecond1Next = pSurfBz->GetControlPoint( i + 1, 0, &bOk) ;
|
||||
Point3d ptSecond2Next = pSurfBz->GetControlPoint( i + 1, 1, &bOk) ;
|
||||
// recupero corrente e verifico la torsione
|
||||
Point3d ptCurr1 = pSurfBz->GetControlPoint( i, 0, &bOk) ;
|
||||
Point3d ptCurr2 = pSurfBz->GetControlPoint( i, 1, &bOk) ;
|
||||
Vector3d vtIsoCurr = ptCurr2 - ptCurr1 ;
|
||||
double dDist = vtIsoCurr.Len() ;
|
||||
vtIsoCurr.Normalize() ;
|
||||
//Vector3d vtDirPrev = vtIsoPrev ^ vtNPrev ;
|
||||
Vector3d vtDirCurr = ptSecond1Next - ptCurr1 ; vtDirCurr.Normalize() ;
|
||||
double dLenCurr = 0 ; pCrvOrig1->GetLengthAtParam( i, dLenCurr) ;
|
||||
double dCoeff = dLenCurr / dLen ;
|
||||
Vector3d vtIsoInterp = Media( vtDir1, vtDir2, dCoeff) ; vtIsoInterp.Normalize() ;
|
||||
bool bDet = false ;
|
||||
//double dAng = 0 ; vtIsoCurr.GetRotation( vtIsoPrev, vtDirPrev, dAng, bDet) ;
|
||||
double dAng = 0 ; vtIsoCurr.GetRotation( vtIsoInterp, vtDirCurr, dAng, bDet) ;
|
||||
vtNCurr = vtDirCurr ^ vtIsoCurr ; vtNCurr.Rotate( vtDirCurr, dAng) ;
|
||||
double dSinAngTol = sin( 5 * DEGTORAD) ;
|
||||
Vector3d vtPrev1 = ptCurr1 - ptThird1Prev ; vtPrev1.Normalize() ;
|
||||
Vector3d vtNext1 = ptSecond1Next - ptCurr1 ; vtNext1.Normalize() ;
|
||||
bool bAngularPoint1 = ! AreSameVectorEpsilon( vtPrev1, vtNext1, dSinAngTol) ;
|
||||
Vector3d vtPrev2 = ptCurr2 - ptThird2Prev ; vtPrev2.Normalize() ;
|
||||
Vector3d vtNext2 = ptSecond2Next - ptCurr2 ; vtNext2.Normalize() ;
|
||||
bool bAngularPoint2 = ! AreSameVectorEpsilon( vtPrev2, vtNext2, dSinAngTol) ;
|
||||
if ( abs( dAng) > 0) {
|
||||
// se l'isocurva di separazione dalla patch successiva è torta rispetto alla precedente
|
||||
// allora prendo il penultimo punto della curva precedente, il punto di joint e il secondo della prossima e li sposto lungo la normale della superficie
|
||||
dDist *= dAng * DEGTORAD / 2 ;
|
||||
if ( ! bAngularPoint1) {
|
||||
// se non ho un punto angoloso muovo tutto il terzetto insieme
|
||||
ptThird1Prev -= vtNCurr * dDist ;
|
||||
ptSecond1Next -= vtNCurr * dDist ;
|
||||
ptCurr1 -= vtNCurr * dDist ;
|
||||
}
|
||||
else {
|
||||
// altrimenti sposto solo il punto corrente verso la congiungente tra il precedente e il successivo
|
||||
DistPointLine dpl( ptCurr1, ptThird1Prev, ptSecond1Next, true) ;
|
||||
Point3d ptMinDist ; dpl.GetMinDistPoint( ptMinDist) ;
|
||||
Vector3d vtCorrDir = ptMinDist - ptCurr1 ; vtCorrDir.Normalize() ;
|
||||
double dProjDir = vtNCurr * vtCorrDir ;
|
||||
if ( dProjDir < 0)
|
||||
LOG_ERROR( GetEGkLogger(), "Error : regolarizing crv0 near an angular point") ;
|
||||
double dDistCorr = min( dDist, Dist( ptMinDist, ptCurr1)) ;
|
||||
ptCurr1 -= vtCorrDir * dDistCorr ;
|
||||
}
|
||||
if ( ! bAngularPoint2) {
|
||||
ptThird2Prev += vtNCurr * dDist ;
|
||||
ptSecond2Next += vtNCurr * dDist ;
|
||||
ptCurr2 += vtNCurr * dDist ;
|
||||
}
|
||||
else {
|
||||
// altrimenti sposto solo il punto corrente verso la congiungente tra il precedente e il successivo
|
||||
DistPointLine dpl( ptCurr2, ptThird2Prev, ptSecond2Next, true) ;
|
||||
Point3d ptMinDist ; dpl.GetMinDistPoint( ptMinDist) ;
|
||||
Vector3d vtCorrDir = ptMinDist - ptCurr2 ; vtCorrDir.Normalize() ;
|
||||
double dProjDir = vtNCurr * vtCorrDir ;
|
||||
if ( dProjDir < 0)
|
||||
LOG_ERROR( GetEGkLogger(), "Error : regolarizing crv1 near an angular point") ;
|
||||
double dDistCorr = min( dDist, Dist( ptMinDist, ptCurr2)) ;
|
||||
ptCurr2 += vtCorrDir * dDistCorr ;
|
||||
}
|
||||
}
|
||||
vPnt0.push_back( ptThird1Prev) ;
|
||||
vPnt0.push_back( ptCurr1) ;
|
||||
vPnt0.push_back( ptSecond1Next) ;
|
||||
|
||||
vPnt1.push_back( ptThird2Prev) ;
|
||||
vPnt1.push_back( ptCurr2) ;
|
||||
vPnt1.push_back( ptSecond2Next) ;
|
||||
|
||||
//vtIsoPrev = ptCurr2 - ptCurr1 ; vtIsoPrev.Normalize() ;
|
||||
//vtNPrev = ( ptSecond1Next - ptCurr1) ^ vtIsoPrev ; vtNPrev.Normalize() ;
|
||||
}
|
||||
// aggiungo gli ultimi due punti
|
||||
Point3d ptThird1Prev = pSurfBz->GetControlPoint( nUS2 - 1, 0, &bOk) ;
|
||||
vPnt0.push_back( ptThird1Prev) ;
|
||||
Point3d ptFourth1Curr = pSurfBz->GetControlPoint( nUS2, 0, &bOk) ;
|
||||
vPnt0.push_back( ptFourth1Curr) ;
|
||||
Point3d ptThird2Prev = pSurfBz->GetControlPoint( nUS2 - 1, 1, &bOk) ;
|
||||
vPnt1.push_back( ptThird2Prev) ;
|
||||
Point3d ptFourth2Curr = pSurfBz->GetControlPoint( nUS2, 1, &bOk) ;
|
||||
vPnt1.push_back( ptFourth2Curr) ;
|
||||
|
||||
PtrOwner<ICurveComposite> pCC1( CreateCurveComposite()) ;
|
||||
PtrOwner<ICurveComposite> pCC2( CreateCurveComposite()) ;
|
||||
for ( int i = 0 ; i < ssize( vPnt0) - 3 ; i+=3) {
|
||||
PtrOwner<ICurveBezier> cb1( CreateCurveBezier()) ; cb1->Init( 3, false) ;
|
||||
cb1->SetControlPoint( 0, vPnt0[i]) ;
|
||||
cb1->SetControlPoint( 1, vPnt0[i+1]) ;
|
||||
cb1->SetControlPoint( 2, vPnt0[i+2]) ;
|
||||
cb1->SetControlPoint( 3, vPnt0[i+3]) ;
|
||||
pCC1->AddCurve( Release( cb1)) ;
|
||||
|
||||
PtrOwner<ICurveBezier> cb2( CreateCurveBezier()) ; cb2->Init( 3, false) ;
|
||||
cb2->SetControlPoint( 0, vPnt1[i]) ;
|
||||
cb2->SetControlPoint( 1, vPnt1[i+1]) ;
|
||||
cb2->SetControlPoint( 2, vPnt1[i+2]) ;
|
||||
cb2->SetControlPoint( 3, vPnt1[i+3]) ;
|
||||
pCC2->AddCurve( Release( cb2)) ;
|
||||
}
|
||||
|
||||
////// N.B.:dovrei tener conto anche della patch PRECEDENTE e SUCCESSIVA a quelle indicate, altrimenti non vedo se ho creato flessi al bordo della zona
|
||||
#if DEBUG_SMOOTH_CURVATURE
|
||||
VT.push_back( pCC1->Clone()) ;
|
||||
VT.push_back( pCC2->Clone()) ;
|
||||
SaveGeoObj( VT, "C:\\Temp\\bezier\\ruled\\smoothness\\regolarized_first_step.nge") ;
|
||||
#endif
|
||||
|
||||
// ora verifico l'eventuale presenza di cambi di concavità non desiderati
|
||||
// se ne trovo su una curva e non sull'altra allora ruoto il terzetto di punti della curva con flesso in modo
|
||||
// da matchare la tangente dell'altra curva
|
||||
PNTINFOVECTOR vPntInfo1, vPntInfo2 ;
|
||||
FillPntInfo( vPnt0, pCC1, vPntInfo1) ;
|
||||
FillPntInfo( vPnt1, pCC2, vPntInfo2) ;
|
||||
|
||||
RemoveInflexionPoints( vPnt0, vPntInfo1, vPntInfo2) ;
|
||||
RemoveInflexionPoints( vPnt1, vPntInfo2, vPntInfo1) ;
|
||||
|
||||
pCC1->Clear() ;
|
||||
pCC2->Clear() ;
|
||||
for ( int i = 0 ; i < ssize( vPnt0) - 3 ; i+=3) {
|
||||
PtrOwner<ICurveBezier> cb1( CreateCurveBezier()) ; cb1->Init( 3, false) ;
|
||||
cb1->SetControlPoint( 0, vPnt0[i]) ;
|
||||
cb1->SetControlPoint( 1, vPnt0[i+1]) ;
|
||||
cb1->SetControlPoint( 2, vPnt0[i+2]) ;
|
||||
cb1->SetControlPoint( 3, vPnt0[i+3]) ;
|
||||
pCC1->AddCurve( Release( cb1)) ;
|
||||
|
||||
PtrOwner<ICurveBezier> cb2( CreateCurveBezier()) ; cb2->Init( 3, false) ;
|
||||
cb2->SetControlPoint( 0, vPnt1[i]) ;
|
||||
cb2->SetControlPoint( 1, vPnt1[i+1]) ;
|
||||
cb2->SetControlPoint( 2, vPnt1[i+2]) ;
|
||||
cb2->SetControlPoint( 3, vPnt1[i+3]) ;
|
||||
pCC2->AddCurve( Release( cb2)) ;
|
||||
}
|
||||
|
||||
// controllo di essere rimasto in tolleranza
|
||||
double dErr = 0 ;
|
||||
CalcApproxError( pCrvOrig1, pCC1, dErr, 20) ;
|
||||
if ( dErr > dTol)
|
||||
return nullptr ;
|
||||
CalcApproxError( pCrvOrig2, pCC2, dErr, 20) ;
|
||||
if ( dErr > dTol)
|
||||
return nullptr ;
|
||||
|
||||
PtrOwner<ISurfBezier> pNewSurf( pSurfBz->Clone()) ;
|
||||
// aggiorno i punti di controllo della superficie di bezier
|
||||
for ( int i = 0 ; i < ssize( vPnt0) ; ++i) {
|
||||
pNewSurf->SetControlPoint( nUS1 + i, 0, vPnt0[i]) ;
|
||||
pNewSurf->SetControlPoint( nUS1 + i, 1, vPnt1[i]) ;
|
||||
}
|
||||
#if DEBUG_SMOOTH_CURVATURE
|
||||
VT.clear() ;
|
||||
VT.push_back( Release(pCC1)) ;
|
||||
VT.push_back( Release(pCC2)) ;
|
||||
SaveGeoObj( VT, "C:\\Temp\\bezier\\ruled\\smoothness\\regolarized.nge") ;
|
||||
#endif
|
||||
|
||||
return Release( pNewSurf) ;
|
||||
}
|
||||
@@ -393,9 +393,6 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
double& dU1, double& dU2) const ;
|
||||
bool GetDepthWithDexel( const Point3d& ptP, const Vector3d& vtDir, double& dInLength, double& dOutLength) const ;
|
||||
bool GetDepthWithVoxel( const Point3d& ptP, const Vector3d& vtDir, double& dInLength, double& dOutLength) const ;
|
||||
bool IntersLineCylinder( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
const Frame3d& CylFrame, double dH, double dRad, bool bTapLow, bool bTapUp,
|
||||
Point3d& ptInt1, Vector3d& vtN1, Point3d& ptInt2, Vector3d& vtN2) const ;
|
||||
bool IntersLineEllipticalCylinder( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
const Frame3d& CircFrame, double dRad, double dLongMvLen, double dOrtMvLen,
|
||||
bool bTapLow, bool bTapUp,
|
||||
|
||||
@@ -2071,127 +2071,6 @@ VolZmap::CDeSurfTm( const ISurfTriMesh& tmSurf, double dSafeDist, bool bPrecise)
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Riferimento con origine nel centro della base e asse di simmetria coincidente con l'asse Z.
|
||||
// La funzione restituisce true in caso di intersezione, false altrimenti.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::IntersLineCylinder( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
const Frame3d& CylFrame, double dH, double dRad, bool bTapLow, bool bTapUp,
|
||||
Point3d& ptInt1, Vector3d& vtN1, Point3d& ptInt2, Vector3d& vtN2) const
|
||||
{
|
||||
// Porto la linea nel riferimento del cilindro
|
||||
Point3d ptP = GetToLoc( ptLineSt, CylFrame) ;
|
||||
Vector3d vtV = GetToLoc( vtLineDir, CylFrame) ;
|
||||
|
||||
// Determino le eventuali intersezioni con le due basi a quota minima e massima (solo se linea non parallela ad esse)
|
||||
int nBasInt = 0 ;
|
||||
if ( abs( vtV.z) > EPS_ZERO) {
|
||||
// le linee tangenti al cilindro non sono considerate intersecanti
|
||||
double dEpsRad = ( vtV.IsZeroXY() ? - EPS_SMALL : EPS_SMALL) ;
|
||||
ptInt1 = ptP + ( ( 0 - ptP.z) / vtV.z) * vtV ;
|
||||
if ( ptInt1.x * ptInt1.x + ptInt1.y * ptInt1.y < dRad * dRad + 2 * dRad * dEpsRad) {
|
||||
nBasInt += 1 ;
|
||||
vtN1 = Z_AX ;
|
||||
}
|
||||
ptInt2 = ptP + ( ( dH - ptP.z) / vtV.z) * vtV ;
|
||||
if ( ptInt2.x * ptInt2.x + ptInt2.y * ptInt2.y < dRad * dRad + 2 * dRad * dEpsRad) {
|
||||
nBasInt += 2 ;
|
||||
vtN2 = - Z_AX ;
|
||||
}
|
||||
}
|
||||
|
||||
// Se la linea interseca entrambe le basi, si sono trovate le due intersezioni
|
||||
if ( nBasInt == 3) {
|
||||
// Porto i punti e i versori nel riferimento globale
|
||||
ptInt1.ToGlob( CylFrame) ;
|
||||
vtN1.ToGlob( CylFrame) ;
|
||||
ptInt2.ToGlob( CylFrame) ;
|
||||
vtN2.ToGlob( CylFrame) ;
|
||||
// Trovate intersezioni
|
||||
return true ;
|
||||
}
|
||||
|
||||
// Determino le intersezioni con la superficie laterale del cilindro
|
||||
DBLVECTOR vdCoeff{ ptP.x * ptP.x + ptP.y * ptP.y - dRad * dRad,
|
||||
2 * ( ptP.x * vtV.x + ptP.y * vtV.y),
|
||||
vtV.x * vtV.x + vtV.y * vtV.y} ;
|
||||
DBLVECTOR vdRoots ;
|
||||
int nRoot = PolynomialRoots( 2, vdCoeff, vdRoots) ;
|
||||
|
||||
// Epsilon per piani di tappo
|
||||
double dEpsLow = ( bTapLow ? - EPS_SMALL : EPS_SMALL) ;
|
||||
double dEpsUp = ( bTapUp ? EPS_SMALL : - EPS_SMALL) ;
|
||||
|
||||
// Elimino le soluzioni cha danno intersezioni fuori dai limiti in Z del cilindro
|
||||
if ( nRoot == 2) {
|
||||
double dIntZ2 = ptP.z + vdRoots[1] * vtV.z ;
|
||||
if ( dIntZ2 < 0 + dEpsLow || dIntZ2 > dH + dEpsUp)
|
||||
-- nRoot ;
|
||||
}
|
||||
if ( nRoot >= 1) {
|
||||
double dIntZ1 = ptP.z + vdRoots[0] * vtV.z ;
|
||||
if ( dIntZ1 < 0 + dEpsLow || dIntZ1 > dH + dEpsUp) {
|
||||
if ( nRoot == 2)
|
||||
vdRoots[0] = vdRoots[1] ;
|
||||
-- nRoot ;
|
||||
}
|
||||
}
|
||||
|
||||
// Due soluzioni: la retta interseca due volte la superficie laterale
|
||||
if ( nRoot == 2) {
|
||||
// Punti di intersezione con la superficie del cilindro
|
||||
ptInt1 = ptP + vdRoots[0] * vtV ;
|
||||
ptInt2 = ptP + vdRoots[1] * vtV ;
|
||||
// Determino le normali
|
||||
vtN1.Set( -ptInt1.x, -ptInt1.y, 0) ;
|
||||
vtN1.Normalize() ;
|
||||
vtN2.Set( -ptInt2.x, -ptInt2.y, 0) ;
|
||||
vtN2.Normalize() ;
|
||||
// Porto i punti e i versori nel riferimento globale
|
||||
ptInt1.ToGlob( CylFrame) ;
|
||||
vtN1.ToGlob( CylFrame) ;
|
||||
ptInt2.ToGlob( CylFrame) ;
|
||||
vtN2.ToGlob( CylFrame) ;
|
||||
// Trovate intersezioni
|
||||
return true ;
|
||||
}
|
||||
|
||||
// Una soluzione : la retta interseca la superficie laterale e un piano
|
||||
else if ( nRoot == 1) {
|
||||
// Se piano superiore
|
||||
if ( nBasInt == 2) {
|
||||
// Punto di intersezione
|
||||
ptInt1 = ptP + vdRoots[0] * vtV ;
|
||||
// Normale alla superficie del cilindro verso l'interno
|
||||
vtN1.Set( -ptInt1.x, -ptInt1.y, 0) ;
|
||||
vtN1.Normalize() ;
|
||||
}
|
||||
// altrimenti piano inferiore
|
||||
else if ( nBasInt == 1) {
|
||||
// Punto di intersezione
|
||||
ptInt2 = ptP + vdRoots[0] * vtV ;
|
||||
// Normale alla superficie del cilindro verso l'interno
|
||||
vtN2.Set( -ptInt2.x, -ptInt2.y, 0) ;
|
||||
vtN2.Normalize() ;
|
||||
}
|
||||
// altrimenti niente
|
||||
else
|
||||
return false ;
|
||||
// Porto i punti e i versori nel riferimento globale
|
||||
ptInt1.ToGlob( CylFrame) ;
|
||||
vtN1.ToGlob( CylFrame) ;
|
||||
ptInt2.ToGlob( CylFrame) ;
|
||||
vtN2.ToGlob( CylFrame) ;
|
||||
// Trovate intersezioni
|
||||
return true ;
|
||||
}
|
||||
|
||||
// Nessuna soluzione : nessuna intersezione
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Riferimento con origine nel vertice del cono e asse di simmetria coincidente con l'asse Z.
|
||||
// La funzione restituisce true in caso di intersezione, false altrimenti.
|
||||
|
||||
+6
-4
@@ -21,6 +21,7 @@
|
||||
#include "CurveLine.h"
|
||||
#include "CurveArc.h"
|
||||
#include "GeoConst.h"
|
||||
#include "IntersLineCyl.h"
|
||||
#include "/EgtDev/Include/EGkStmFromCurves.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
@@ -968,12 +969,13 @@ VolZmap::CreateOffsetCylinderOnEdge( const Point3d& ptP1, const Point3d& ptP2, d
|
||||
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)) {
|
||||
double dU1, dU2 ;
|
||||
if ( IntersLineCyl( ptC, Z_AX, CylFrame, dH, abs( dOffs), true, true,
|
||||
dU1, ptInt1, vtN1, dU2, ptInt2, vtN2, false, false)) {
|
||||
if ( dOffs > 0.)
|
||||
AddIntervalsForOffset( nGrid, i, j, ptInt1.z, ptInt2.z, -vtN1, -vtN2, nTool, nTool) ;
|
||||
AddIntervalsForOffset( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nTool, nTool) ;
|
||||
else
|
||||
SubtractIntervalsForOffset( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nTool) ;
|
||||
SubtractIntervalsForOffset( nGrid, i, j, ptInt1.z, ptInt2.z, -vtN1, -vtN2, nTool) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+23
-15
@@ -21,6 +21,7 @@
|
||||
#include "VolZmap.h"
|
||||
#include "GeoConst.h"
|
||||
#include "IntersLineBox.h"
|
||||
#include "IntersLineCyl.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
@@ -1770,6 +1771,8 @@ VolZmap::Comp_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
|
||||
if ( bInverse)
|
||||
nTotSurf += 4 ;
|
||||
if ( bSmallMovement)
|
||||
nTotSurf += 2 ;
|
||||
|
||||
int nSurfInd = 0 ;
|
||||
vector<SurfBezForInters> vSurfBez( nTotSurf) ;
|
||||
@@ -6247,7 +6250,8 @@ VolZmap::CompCyl_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co
|
||||
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, dRad, bTapB, bTapT, ptInt1, vtN1, ptInt2, vtN2)) {
|
||||
double dU1, dU2 ;
|
||||
if ( IntersLineCyl( ptC, Z_AX, CylFrame, dH, dRad, bTapB, bTapT, dU1, ptInt1, vtN1, dU2, ptInt2, vtN2, false, true)) {
|
||||
SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ;
|
||||
}
|
||||
}
|
||||
@@ -6292,8 +6296,9 @@ VolZmap::CompConus_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE,
|
||||
Vector3d vtN1, vtN2 ;
|
||||
|
||||
// Cilindro
|
||||
if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dH, dMaxRad, true, bTapT,
|
||||
ptInt1, vtN1, ptInt2, vtN2)) {
|
||||
double dU1, dU2 ;
|
||||
if ( IntersLineCyl( ptC, Z_AX, CylFrame, dH, dMaxRad, true, bTapT,
|
||||
dU1, ptInt1, vtN1, dU2, ptInt2, vtN2, false, true)) {
|
||||
SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ;
|
||||
}
|
||||
|
||||
@@ -6472,7 +6477,8 @@ VolZmap::CompCyl_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE,
|
||||
|
||||
// Cilindro iniziale
|
||||
CylFrame.ChangeOrig( ptITip) ;
|
||||
if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dHei, dRad, bTapB, bTapT, ptInt1, vtN1, ptInt2, vtN2)) {
|
||||
double dU1, dU2 ;
|
||||
if ( IntersLineCyl( ptC, Z_AX, CylFrame, dHei, dRad, bTapB, bTapT, dU1, ptInt1, vtN1, dU2, ptInt2, vtN2, false, true)) {
|
||||
SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ;
|
||||
}
|
||||
|
||||
@@ -6480,7 +6486,7 @@ VolZmap::CompCyl_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE,
|
||||
// del sistema di riferimento, quindi usiamo lo stesso sistema sommando a ptC
|
||||
// il vettore che congiunge le due origini.
|
||||
CylFrame.ChangeOrig( ptITip + vtMove) ;
|
||||
if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dHei, dRad, bTapB, bTapT, ptInt1, vtN1, ptInt2, vtN2)) {
|
||||
if ( IntersLineCyl( ptC, Z_AX, CylFrame, dHei, dRad, bTapB, bTapT, dU1, ptInt1, vtN1, dU2, ptInt2, vtN2, false, true)) {
|
||||
SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ;
|
||||
}
|
||||
|
||||
@@ -7067,7 +7073,8 @@ VolZmap::CompBall_Milling( int nGrid, const Point3d& ptLs, const Point3d& ptLe,
|
||||
// Cilindro inviluppo della sfera
|
||||
Point3d ptInt1, ptInt2 ;
|
||||
Vector3d vtN1, vtN2 ;
|
||||
if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dLengthPath, dRad, false, false, ptInt1, vtN1, ptInt2, vtN2)) {
|
||||
double dU1, dU2 ;
|
||||
if ( IntersLineCyl( ptC, Z_AX, CylFrame, dLengthPath, dRad, false, false, dU1, ptInt1, vtN1, dU2, ptInt2, vtN2, false, true)) {
|
||||
SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ;
|
||||
}
|
||||
}
|
||||
@@ -7215,15 +7222,15 @@ VolZmap::AddingCylinder( int nGrid, const Point3d& ptS, const Point3d& ptE, cons
|
||||
|
||||
Point3d ptInt1, ptInt2 ;
|
||||
Vector3d vtN1, vtN2 ;
|
||||
|
||||
if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dHei, dRad, true, true,
|
||||
ptInt1, vtN1, ptInt2, vtN2)) {
|
||||
AddIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, - vtN1, - vtN2, CurrTool.GetToolNum()) ;
|
||||
double dU1, dU2 ;
|
||||
if ( IntersLineCyl( ptC, Z_AX, CylFrame, dHei, dRad, true, true,
|
||||
dU1, ptInt1, vtN1, dU2, ptInt2, vtN2, false, false)) {
|
||||
AddIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, CurrTool.GetToolNum()) ;
|
||||
}
|
||||
|
||||
if ( IntersLineCylinder( ptC - dLen1 * vtV1, Z_AX, CylFrame, dHei, dRad, true, true,
|
||||
ptInt1, vtN1, ptInt2, vtN2)) {
|
||||
AddIntervals( nGrid, i, j, ptInt1.z + dLen1 * vtV1.z, ptInt2.z + dLen1 * vtV1.z, - vtN1, - vtN2, CurrTool.GetToolNum()) ;
|
||||
if ( IntersLineCyl( ptC - dLen1 * vtV1, Z_AX, CylFrame, dHei, dRad, true, true,
|
||||
dU1, ptInt1, vtN1, dU2, ptInt2, vtN2, false, false)) {
|
||||
AddIntervals( nGrid, i, j, ptInt1.z + dLen1 * vtV1.z, ptInt2.z + dLen1 * vtV1.z, vtN1, vtN2, CurrTool.GetToolNum()) ;
|
||||
}
|
||||
|
||||
if ( IntersLineMyPolyhedron( ptC, Z_AX, PolyFrame, dLen1, 2 * ( dRad + dMyTol), dHei + 2 * dMyTol, 0,
|
||||
@@ -7619,8 +7626,9 @@ VolZmap::AddingSphere( int nGrid, const Point3d& ptS, const Point3d& ptE, double
|
||||
// Cilindro inviluppo della sfera
|
||||
Point3d ptInt1, ptInt2 ;
|
||||
Vector3d vtN1, vtN2 ;
|
||||
if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dLengthPath, dRad, false, false, ptInt1, vtN1, ptInt2, vtN2)) {
|
||||
AddIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, - vtN1, - vtN2, CurrTool.GetToolNum()) ;
|
||||
double dU1, dU2 ;
|
||||
if ( IntersLineCyl( ptC, Z_AX, CylFrame, dLengthPath, dRad, false, false, dU1, ptInt1, vtN1, dU2, ptInt2, vtN2, false, false)) {
|
||||
AddIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, CurrTool.GetToolNum()) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+21
-3
@@ -828,10 +828,19 @@ Voronoi::CalcSpecialPointOffset( PNTVECTVECTOR& vResult, double dOffs)
|
||||
Point3d ptTemp ;
|
||||
Vector3d vtDir ;
|
||||
if ( ! pCrv->GetParamAtPoint( pt, dPar, 100 * EPS_SMALL) || ! pCrv->GetPointD1D2( dPar, ICurve::FROM_MINUS, ptTemp, &vtDir))
|
||||
return false ;
|
||||
continue ;
|
||||
vtDir.Normalize() ;
|
||||
|
||||
vResult.emplace_back( pt, vtDir) ;
|
||||
// verifico che il punto non sia già stato trovato
|
||||
bool bAdd = true ;
|
||||
for ( int j = 0 ; j < ssize( vResult) ; j ++) {
|
||||
if ( AreSamePointApprox( vResult[j].first, pt)) {
|
||||
bAdd = false ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if ( bAdd)
|
||||
vResult.emplace_back( pt, vtDir) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1014,8 +1023,17 @@ Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs)
|
||||
RemoveCurveSmallParts( pCrvOffs, 5 * EPS_SMALL) ;
|
||||
|
||||
// aggiungo la curva alla lista degli offset
|
||||
if ( ! IsNull( pCrvOffs) && pCrvOffs->IsValid() && pCrvOffs->GetCurveCount() > 0)
|
||||
if ( ! IsNull( pCrvOffs) && pCrvOffs->IsValid() && pCrvOffs->GetCurveCount() > 0) {
|
||||
// forzo chiusura
|
||||
if ( ! pCrvOffs->IsClosed()) {
|
||||
Point3d ptS ; pCrvOffs->GetStartPoint( ptS) ;
|
||||
Point3d ptE ; pCrvOffs->GetEndPoint( ptE) ;
|
||||
if ( SqDist( ptS, ptE) > 100. * SQ_EPS_SMALL)
|
||||
return false ;
|
||||
pCrvOffs->Close() ;
|
||||
}
|
||||
OffsList.push_back( Release( pCrvOffs)) ;
|
||||
}
|
||||
}
|
||||
|
||||
// libero la memoria di vroni dedicata agli offset
|
||||
|
||||
Reference in New Issue
Block a user