EgtGeomKernel :

- modifiche a sistemazione topologie di intersezioni di curve composite
- eliminazione di linee inutili in generale
- cambio nome di variabili che nascondono omonime.
This commit is contained in:
Dario Sassi
2020-10-05 06:56:24 +00:00
parent 74df7ecfcd
commit be027def9c
18 changed files with 152 additions and 232 deletions
-1
View File
@@ -200,7 +200,6 @@ CAvToolSurfTm::TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, dou
if ( lPntM.empty())
return true ;
// Ciclo sui punti
int nCount = int( lPntM.size()) ;
Point3d ptPrev, ptCurr ;
auto itPntMPrev = lPntM.end() ;
auto itPntMCurr = lPntM.begin() ;
+9 -12
View File
@@ -143,7 +143,7 @@ static int LinePlaneDDistPar( const Point3d& ptPlane, const Vector3d& vtPlane
static double LineLineSqDist( const Point3d& ptP1, const Vector3d& vtD1, const Point3d& ptP2, const Vector3d& vtD2) ;
static double LineSegmentSqDist( const Point3d& ptPLn, const Vector3d& vtDLn,
const Point3d& ptPSg, const Vector3d& vtDSg, double dSgLen) ;
static bool CoplanarDiscTriangleInterferance( const Point3d& ptCen, double dRad, const Triangle3d& trTria, int nTriType) ;
static bool CoplanarDiscTriangleInterference( const Point3d& ptCen, double dRad, const Triangle3d& trTria, int nTriType) ;
static bool FindLineLineMinDistPar( const Point3d& ptL1, const Vector3d& vtV1,
const Point3d& ptL2, const Vector3d& vtV2,
double& dU1, double& dU2) ;
@@ -742,13 +742,10 @@ CylSegmentEscapeDistOrtMotion( const Point3d& ptCylOrig, const Vector3d& vtCylAx
// Lunghezza della componente del vettore radiale ortogonale alla linea di movimento
double dDotRemRad = abs( vtRad * vtMove) ;
double dOrtLen = sqrt( max( dCylRad * dCylRad - dDotRemRad * dDotRemRad, 0.)) ;
// Cerco lungo la retta un punto che stia nel segmento e abbia distanza dal piano
// abbia distanza dal piano +/- dOrtLen.
Vector3d vtPlane = vtMove ^ vtCylAx ;
vtPlane.Normalize() ;
// Cerco lungo la retta un punto che stia nel segmento e abbia distanza dal piano +/- dOrtLen
Vector3d vtD = ptSeg - ptCylOrig ;
double dDotPlaneD = vtD * vtPlane ;
double dDotPlaneSeg = vtSeg * vtPlane ;
double dDotPlaneD = - vtD * vtPlane ;
double dDotPlaneSeg = - vtSeg * vtPlane ;
double dPlusU = ( dOrtLen - dDotPlaneD) / dDotPlaneSeg ;
double dMinusU = ( - dOrtLen - dDotPlaneD) / dDotPlaneSeg ;
Point3d ptTanPlus = ptSeg + dPlusU * vtSeg ;
@@ -2446,7 +2443,7 @@ CAvDiskTriangle( const Point3d& ptDiskCen, const Vector3d& vtDiskAx, double dDis
ptV1 - dVertEscapeDist[1] * vtMove,
ptV2 - dVertEscapeDist[2] * vtMove) ;
// Se non c'è interferenza fra triangolo proiettato e disco la distanza di fuga è nulla
if ( ! CoplanarDiscTriangleInterferance( ptDiskCen, dDiskRad, trTriaOnPlane, TriangleType::CLOSED)) // OPEN EXACT O CLOSED ?
if ( ! CoplanarDiscTriangleInterference( ptDiskCen, dDiskRad, trTriaOnPlane, TriangleType::CLOSED)) // OPEN EXACT O CLOSED ?
return 0. ;
double dSqSafeRad = dDiskRad * dDiskRad - 2 * dDiskRad * EPS_SMALL ;
bool bInside[3] ;
@@ -2548,7 +2545,7 @@ DiskTriaInteriorEscapeDistLongMot( const Point3d& ptDiskCen, double dDiskRad,
// Se disco e triangolo sono complanari
if ( AreSameVectorApprox( vtMove, trTria.GetN())) {
double dDist = max( - PointPlaneSignedDist( ptDiskCen, trTria.GetP( 0), trTria.GetN()), 0.) ;
if ( CoplanarDiscTriangleInterferance( ptDiskCen + dDist * vtMove, dDiskRad - EPS_SMALL, trTria, TriangleType::EXACT))
if ( CoplanarDiscTriangleInterference( ptDiskCen + dDist * vtMove, dDiskRad - EPS_SMALL, trTria, TriangleType::EXACT))
return dDist ;
return 0. ;
}
@@ -2715,7 +2712,7 @@ DiskTriaInteriorEscapeDistGenMot( const Point3d& ptDiskCen, const Vector3d& vtDi
// Se disco e triangolo sono complanari
if ( AreSameVectorApprox( vtDiskAx, trTria.GetN())) {
double dDist = max( ( ( trTria.GetP( 0) - ptDiskCen) * trTria.GetN()) / ( vtMove * trTria.GetN()), 0.) ;
if ( CoplanarDiscTriangleInterferance( ptDiskCen + dDist * vtMove, dDiskRad, trTria, TriangleType::EXACT))
if ( CoplanarDiscTriangleInterference( ptDiskCen + dDist * vtMove, dDiskRad, trTria, TriangleType::EXACT))
return dDist ;
return 0. ;
}
@@ -2868,7 +2865,7 @@ LineSegmentSqDist( const Point3d& ptPLn, const Vector3d& vtDLn,
// L'informazione su n è contenuta nell'oggetto triangolo; quella su a non è passata
// in quanto inutile sotto le nostre assunzioni.
bool
CoplanarDiscTriangleInterferance( const Point3d& ptCen, double dRad, const Triangle3d& trTria, int nTriType)
CoplanarDiscTriangleInterference( const Point3d& ptCen, double dRad, const Triangle3d& trTria, int nTriType)
{
// Se il centro del disco non sta sul piano del triangolo, non sono complanari
if ( abs( PointPlaneSignedDist( ptCen, trTria.GetP( 0), trTria.GetN())) > EPS_SMALL)
@@ -2877,7 +2874,7 @@ CoplanarDiscTriangleInterferance( const Point3d& ptCen, double dRad, const Trian
if ( IsPointInsideTriangle( ptCen, trTria, TriangleType::EXACT))
return true ;
double dSqMinDist ;
double dSqMinDist = 0 ;
switch ( nTriType) {
case OPEN :
dSqMinDist = dRad * dRad - 2 * dRad * EPS_SMALL ;
+1 -1
View File
@@ -2046,7 +2046,7 @@ CurveComposite::TrimEndAtLen( double dLenTrim)
bool bToErase = false ;
double dLenToTrim = dLenTrim ;
for ( auto Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ;) {
double dCrvLen ;
double dCrvLen = 0 ;
// se non sono già nella zona da cancellare, aggiorno lunghezze
if ( ! bToErase) {
// lunghezza della curva
+2
View File
@@ -193,6 +193,7 @@ copy $(TargetPath) \EgtProg\DllD64</Command>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<WholeProgramOptimization>false</WholeProgramOptimization>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -237,6 +238,7 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<WholeProgramOptimization>false</WholeProgramOptimization>
<DebugInformationFormat>None</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
+5 -49
View File
@@ -3248,8 +3248,6 @@ GdbExecutor::LineDiscInters( const STRVECTOR& vsParams)
if ( nIntType == D_ERROR_INT)
return false ;
if ( nIntType == D_NO_INTERS)
int nSol = 0 ;
if ( nIntType == D_BOUNDARY_INT_LINE_NOT_IN_PLANE) {
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
pLine->Set( ptPS - vtLine, ptPS + vtLine) ;
@@ -3318,8 +3316,6 @@ GdbExecutor::RayDiscInters( const STRVECTOR& vsParams)
if ( nIntType == D_ERROR_INT)
return false ;
if ( nIntType == D_NO_INTERS)
int nSol = 0 ;
if ( nIntType == D_BOUNDARY_INT_LINE_NOT_IN_PLANE) {
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
pLine->Set( ptPS - vtLine, ptPS + vtLine) ;
@@ -3392,8 +3388,6 @@ GdbExecutor::SegmentDiscInters( const STRVECTOR& vsParams)
if ( nIntType == D_ERROR_INT)
return false ;
if ( nIntType == D_NO_INTERS)
int nSol = 0 ;
if ( nIntType == D_BOUNDARY_INT_LINE_NOT_IN_PLANE) {
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
pLine->Set( ptPS - vtLine, ptPS + vtLine) ;
@@ -3457,8 +3451,6 @@ GdbExecutor::LineSphereInters( const STRVECTOR& vsParams)
if ( nIntType == S_ERROR_INT)
return false ;
if ( nIntType == S_NO_INTERS)
int nSol = 0 ;
if ( nIntType == S_TWO_INT) {
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
pLine->Set( ptPS, ptPE) ;
@@ -3510,8 +3502,6 @@ GdbExecutor::RaySphereInters( const STRVECTOR& vsParams)
if ( nIntType == S_ERROR_INT)
return false ;
if ( nIntType == S_NO_INTERS)
int nSol = 0 ;
if ( nIntType == S_TWO_INT) {
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
pLine->Set( ptPS, ptPE) ;
@@ -3572,8 +3562,6 @@ GdbExecutor::SegmentSphereInters( const STRVECTOR& vsParams)
if ( nIntType == S_ERROR_INT)
return false ;
if ( nIntType == S_NO_INTERS)
int nSol = 0 ;
if ( nIntType == S_TWO_INT) {
Point3d ptPS = ptP + dU1 * vtV ;
Point3d ptPE = ptP + dU2 * vtV ;
@@ -3641,8 +3629,6 @@ GdbExecutor::LineSemiSphereInters( const STRVECTOR& vsParams)
if ( nIntType == S_ERROR_INT)
return false ;
if ( nIntType == S_NO_INTERS)
int nSol = 0 ;
if ( nIntType == S_TWO_INT) {
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
pLine->Set( ptPS, ptPE) ;
@@ -3700,8 +3686,6 @@ GdbExecutor::RaySemiSphereInters( const STRVECTOR& vsParams)
if ( nIntType == S_ERROR_INT)
return false ;
if ( nIntType == S_NO_INTERS)
int nSol = 0 ;
if ( nIntType == S_TWO_INT) {
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
pLine->Set( ptPS, ptPE) ;
@@ -3767,8 +3751,6 @@ GdbExecutor::SegmentSemiSphereInters( const STRVECTOR& vsParams)
if ( nIntType == S_ERROR_INT)
return false ;
if ( nIntType == S_NO_INTERS)
int nSol = 0 ;
if ( nIntType == S_TWO_INT) {
Point3d ptPS = ptP + dU1 * vtV ;
Point3d ptPE = ptP + dU2 * vtV ;
@@ -3840,8 +3822,6 @@ GdbExecutor::LinCompSemiSphereInters( const STRVECTOR& vsParams)
if ( nIntType == S_ERROR_INT)
return false ;
if ( nIntType == S_NO_INTERS)
int nSol = 0 ;
if ( nIntType == S_TWO_INT) {
Point3d ptPS = ptP + dU1 * vtV ;
Point3d ptPE = ptP + dU2 * vtV ;
@@ -3909,8 +3889,6 @@ GdbExecutor::LineInfiniteCylinderInters( const STRVECTOR& vsParams)
if ( nTypeInt == CC_ERROR_INT)
return false ;
if ( nTypeInt == CC_NO_INTERS)
int nSol = 0 ;
if ( nTypeInt == CC_ONE_INT_SEC) {
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ;
@@ -3980,8 +3958,6 @@ GdbExecutor::RayInfiniteCylinderInters( const STRVECTOR& vsParams)
if ( nTypeInt == CC_ERROR_INT)
return false ;
if ( nTypeInt == CC_NO_INTERS)
int nSol = 0 ;
if ( nTypeInt == CC_ONE_INT_SEC) {
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ;
@@ -4054,8 +4030,6 @@ GdbExecutor::SegmentInfiniteCylinderInters( const STRVECTOR& vsParams)
if ( nTypeInt == CC_ERROR_INT)
return false ;
if ( nTypeInt == CC_NO_INTERS)
int nSol = 0 ;
if ( nTypeInt == CC_ONE_INT_SEC) {
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ;
@@ -4132,8 +4106,6 @@ GdbExecutor::SegmentCylinderInters( const STRVECTOR& vsParams)
if ( nTypeInt == CC_ERROR_INT)
return false ;
if ( nTypeInt == CC_NO_INTERS)
int nSol = 0 ;
if ( nTypeInt == CC_ONE_INT_SEC) {
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ;
@@ -4210,8 +4182,6 @@ GdbExecutor::SegmentConeInters( const STRVECTOR& vsParams)
if ( nTypeInt == CC_ERROR_INT)
return false ;
if ( nTypeInt == CC_NO_INTERS)
int nSol = 0 ;
if ( nTypeInt == CC_ONE_INT_SEC) {
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ;
@@ -4293,8 +4263,6 @@ GdbExecutor::LineTruncateConeInters( const STRVECTOR& vsParams)
if ( nTypeInt == CC_ERROR_INT)
return false ;
if ( nTypeInt == CC_NO_INTERS)
int nSol = 0 ;
if ( nTypeInt == CC_ONE_INT_SEC) {
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ;
@@ -4377,8 +4345,6 @@ GdbExecutor::RayTruncateConeInters( const STRVECTOR& vsParams)
if ( nTypeInt == CC_ERROR_INT)
return false ;
if ( nTypeInt == CC_NO_INTERS)
int nSol = 0 ;
if ( nTypeInt == CC_ONE_INT_SEC) {
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ;
@@ -4464,8 +4430,6 @@ GdbExecutor::SegmentTruncateConeInters( const STRVECTOR& vsParams)
if ( nTypeInt == CC_ERROR_INT)
return false ;
if ( nTypeInt == CC_NO_INTERS)
int nSol = 0 ;
if ( nTypeInt == CC_ONE_INT_SEC) {
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ;
@@ -4542,8 +4506,6 @@ GdbExecutor::LineTorusInters( const STRVECTOR& vsParams)
if ( nTypeInt == T_ERROR)
return false ;
if ( nTypeInt == T_NO_INT)
int nSol = 0 ;
if ( nTypeInt == T_ONE_TAN) {
Point3d ptInt = ptLine + vdP[0] * vtLine ;
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
@@ -4599,7 +4561,7 @@ GdbExecutor::LineTorusInters( const STRVECTOR& vsParams)
AddGeoObj( "$NN", vsParams[1], Release( pLine1))) ;
}
}
else if ( T_FOUR_SEC) {
else if ( nTypeInt == T_FOUR_SEC) {
Point3d ptInt0 = ptLine + vdP[0] * vtLine ;
Point3d ptInt1 = ptLine + vdP[1] * vtLine ;
Point3d ptInt2 = ptLine + vdP[2] * vtLine ;
@@ -4659,8 +4621,6 @@ GdbExecutor::RayTorusInters( const STRVECTOR& vsParams)
if ( nTypeInt == T_ERROR)
return false ;
if ( nTypeInt == T_NO_INT)
int nSol = 0 ;
if ( nTypeInt == T_ONE_TAN) {
Point3d ptInt = ptLine + vdP[0] * vtLine ;
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
@@ -4815,8 +4775,6 @@ GdbExecutor::SegmentTorusInters( const STRVECTOR& vsParams)
if ( nTypeInt == T_ERROR)
return false ;
if ( nTypeInt == T_NO_INT)
int nSol = 0 ;
if ( nTypeInt == T_ONE_TAN) {
Point3d ptInt = ptLine + vdP[0] * vtLine ;
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
@@ -4989,8 +4947,6 @@ GdbExecutor::LinCompTorusPartInters( const STRVECTOR& vsParams)
if ( nTypeInt == T_ERROR)
return false ;
if ( nTypeInt == T_NO_INT)
int nSol = 0 ;
if ( nTypeInt == T_ONE_TAN) {
Point3d ptInt = ptLine + vdP[0] * vtLine ;
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
@@ -7793,10 +7749,10 @@ GdbExecutor::CurveCopyByChain( const STRVECTOR& vsParams)
if ( IsNull( pCrvCompo))
return false ;
// recupero le curve semplici e le inserisco nella curva composita
INTVECTOR::iterator Iter ;
for ( Iter = vIds.begin() ; Iter != vIds.end() ; ++Iter) {
int nId = abs( *Iter) ;
bool bInvert = ( *Iter < 0) ;
INTVECTOR::iterator Iter2 ;
for ( Iter2 = vIds.begin() ; Iter2 != vIds.end() ; ++Iter2) {
int nId = abs( *Iter2) ;
bool bInvert = ( *Iter2 < 0) ;
// recupero la curva e il suo riferimento
ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nId)) ;
if ( pCrv == nullptr)
+34 -18
View File
@@ -26,7 +26,7 @@ static bool CompatibleParamA( const IntCrvCrvInfo& Icci1, const IntCrvCrvInfo& I
bool bCrvAClosed, double dCrvASpan) ;
static bool CompatibleParamB( const IntCrvCrvInfo& Icci1, const IntCrvCrvInfo& Icci2,
bool bCrvBClosed, double dCrvBSpan) ;
static void MediaParamPoints( IntCrvInfo& Ici1, IntCrvInfo& Ici2) ;
static void MediaParamPoints( IntCrvInfo& Ici1, IntCrvInfo& Ici2, const ICurveComposite& crvCompo) ;
static int GetCrvBDirAPrev( IntCrvCrvInfo& Icci) ;
static int GetCrvBDirANext( IntCrvCrvInfo& Icci) ;
static bool CalcATypeFromDisk( const ICurve& CurveA, double dUA, ICurve::Side nSideA,
@@ -226,8 +226,8 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
m_Info[j].IciB[kj].nNextTy = m_Info[i].IciA[ki].nPrevTy ;
}
// medio parametri e punti separatamente per le due curve
MediaParamPoints( m_Info[i].IciA[ki], m_Info[j].IciA[kj]) ;
MediaParamPoints( m_Info[i].IciB[ki], m_Info[j].IciB[kj]) ;
MediaParamPoints( m_Info[i].IciA[ki], m_Info[j].IciA[kj], CCompoA) ;
MediaParamPoints( m_Info[i].IciB[ki], m_Info[j].IciB[kj], CCompoB) ;
// se entrambi overlap non cancello
if ( m_Info[j].bOverlap && m_Info[i].bOverlap)
continue ;
@@ -270,8 +270,8 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
m_Info[j].IciB[kj].nNextTy = m_Info[i].IciA[ki].nPrevTy ;
}
// medio parametri e punti separatamente per le due curve
MediaParamPoints( m_Info[i].IciA[ki], m_Info[j].IciA[kj]) ;
MediaParamPoints( m_Info[i].IciB[ki], m_Info[j].IciB[kj]) ;
MediaParamPoints( m_Info[i].IciA[ki], m_Info[j].IciA[kj], CCompoA) ;
MediaParamPoints( m_Info[i].IciB[ki], m_Info[j].IciB[kj], CCompoB) ;
// se entrambi overlap non cancello
if ( m_Info[j].bOverlap && m_Info[i].bOverlap)
continue ;
@@ -374,8 +374,8 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
m_Info[j].IciA[kj].nNextTy = m_Info[i].IciB[ki].nPrevTy ;
}
// medio parametri e punti separatamente per le due curve
MediaParamPoints( m_Info[i].IciA[ki], m_Info[j].IciA[kj]) ;
MediaParamPoints( m_Info[i].IciB[ki], m_Info[j].IciB[kj]) ;
MediaParamPoints( m_Info[i].IciA[ki], m_Info[j].IciA[kj], CCompoA) ;
MediaParamPoints( m_Info[i].IciB[ki], m_Info[j].IciB[kj], CCompoB) ;
// se entrambi overlap non cancello
if ( m_Info[j].bOverlap && m_Info[i].bOverlap)
continue ;
@@ -418,8 +418,8 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
m_Info[j].IciA[kj].nNextTy = m_Info[i].IciB[ki].nPrevTy ;
}
// medio parametri e punti separatamente per le due curve
MediaParamPoints( m_Info[i].IciA[ki], m_Info[j].IciA[kj]) ;
MediaParamPoints( m_Info[i].IciB[ki], m_Info[j].IciB[kj]) ;
MediaParamPoints( m_Info[i].IciA[ki], m_Info[j].IciA[kj], CCompoA) ;
MediaParamPoints( m_Info[i].IciB[ki], m_Info[j].IciB[kj], CCompoB) ;
// se entrambi overlap non cancello
if ( m_Info[j].bOverlap && m_Info[i].bOverlap)
continue ;
@@ -452,12 +452,16 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
// caso NULL-NULL per corrente di seconda curva
else if ( m_Info[i].IciB[ki].nPrevTy == ICCT_NULL && m_Info[i].IciB[ki].nNextTy == ICCT_NULL) {
m_Info[j].IciB[kj].nNextTy = m_Info[i].IciB[ki].nNextTy ;
if ( m_Info[i].IciA[ki].dU > m_Info[j].IciA[kj].dU + EPS_PARAM)
m_Info[j].IciA[kj].nNextTy = m_Info[i].IciA[ki].nNextTy ;
// cancello l'intersezione corrente (non aggiunge nulla rispetto alla precedente)
EraseCurrentInfo( i, j) ;
}
// caso NULL-NULL per precedente di seconda curva
else if ( m_Info[j].IciB[kj].nPrevTy == ICCT_NULL && m_Info[j].IciB[kj].nNextTy == ICCT_NULL) {
m_Info[i].IciB[0].nPrevTy = m_Info[j].IciB[0].nPrevTy ;
if ( m_Info[j].IciA[0].dU < m_Info[i].IciA[0].dU - EPS_PARAM)
m_Info[i].IciA[0].nPrevTy = m_Info[j].IciA[0].nPrevTy ;
// cancello l'intersezione precedente (non aggiunge nulla rispetto alla corrente)
EraseOtherInfo( i, j) ;
}
@@ -476,11 +480,12 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
m_Info[i].IciA[0].nPrevTy = ( m_Info[j].bOverlap ? m_Info[j].IciA[1].nNextTy : m_Info[j].IciA[0].nNextTy) ;
}
// se il tipo di allontanamento per la curva A non è definito
if ( m_Info[i].IciA[0].nNextTy == ICCT_NULL) {
int ki = ( m_Info[i].bOverlap ? 1 : 0) ;
if ( m_Info[i].IciA[ki].nNextTy == ICCT_NULL) {
if ( i == m_nNumInters - 1 && ! bCrvAClosed)
continue ;
int j = ( i < m_nNumInters - 1 ? i + 1 : 0) ;
m_Info[i].IciA[0].nNextTy = m_Info[j].IciA[0].nPrevTy ;
m_Info[i].IciA[ki].nNextTy = m_Info[j].IciA[0].nPrevTy ;
}
}
@@ -911,16 +916,27 @@ CompatibleParamB( const IntCrvCrvInfo& Icci1, const IntCrvCrvInfo& Icci2,
//----------------------------------------------------------------------------
static void
MediaParamPoints( IntCrvInfo& Ici1, IntCrvInfo& Ici2)
MediaParamPoints( IntCrvInfo& Ici1, IntCrvInfo& Ici2, const ICurveComposite& crvCompo)
{
// medio i parametri e i punti
// per non mediare i parametri tra gli estremi di curva chiusa
if ( abs( Ici1.dU - Ici2.dU) < 0.1 * SPAN_PARAM) {
Ici1.dU = 0.5 * ( Ici1.dU + Ici2.dU) ;
Ici2.dU = Ici1.dU ;
}
// distanza tra i punti
//double dSqDist = SqDist( Ici1.ptI, Ici2.ptI) ;
// medio i punti
Ici1.ptI = 0.5 * ( Ici1.ptI + Ici2.ptI) ;
Ici2.ptI = Ici1.ptI ;
// per non mediare i parametri tra gli estremi di curva chiusa
if ( abs( Ici1.dU - Ici2.dU) > 0.1 * SPAN_PARAM)
return ;
// determino il punto della curva che corrisponde al valore medio dei parametri
double dUmed = 0.5 * ( Ici1.dU + Ici2.dU) ;
//Point3d ptMed ;
//if ( ! crvCompo.GetPointD1D2( dUmed, ICurve::FROM_MINUS, ptMed))
// return ;
// verifico che non sia più lontano dei punti originali dal loro medio
//if ( SqDist( Ici1.ptI, ptMed) > dSqDist / 4)
// return ;
// medio i parametri
Ici1.dU = dUmed ;
Ici2.dU = dUmed ;
}
//----------------------------------------------------------------------------
+1 -1
View File
@@ -331,7 +331,7 @@ IntersCoplanarLineTria( const Point3d& ptL, const Vector3d& vtL, double dLen, co
// se altrimenti un vertice del triangolo giace sulla retta e gli altri due sono da parti opposte
else if ( nVertPos == 1 && nVertNeg == 1) {
// Determino il vertice sulla linea e gli altri due da interpolare
int nP, nM ;
int nP = -1, nM = -1 ;
for ( int i = 0 ; i < 3 ; ++i) {
if ( vPos[i] == 0)
ptInt = trTria.GetP( i) ;
+8 -12
View File
@@ -93,16 +93,12 @@ IntersSurfTmSurfTm( const ISurfTriMesh& Stm1, const ISurfTriMesh& Stm2,
// verifico se già inserito
bool bFound = false ;
BBox3d b3Line( ptInt, ptInt2) ;
INTVECTOR vnIds ;
if ( LnGrid.Find( b3Line, vnIds)) {
for ( int i = 0 ; i < int( vnIds.size()) ; ++ i) {
int nA = vnIds[i] ;
INTVECTOR vnId2s ;
if ( LnGrid.Find( b3Line, vnId2s)) {
for ( int i = 0 ; i < int( vnId2s.size()) ; ++ i) {
int nA = vnId2s[i] ;
const Point3d& ptOth = vBpt[nA].first ;
const Point3d& ptOth2 = vBpt[nA].second ;
//if ( ( AreSamePointEpsilon( ptInt, ptOth, 10 * EPS_SMALL) &&
// AreSamePointEpsilon( ptInt2, ptOth2, 10 * EPS_SMALL)) ||
// ( AreSamePointEpsilon( ptInt, ptOth2, 10 * EPS_SMALL) &&
// AreSamePointEpsilon( ptInt2, ptOth, 10 * EPS_SMALL))) {
if ( ( AreSamePointEpsilon( ptInt, ptOth, 10 * EPS_SMALL) &&
AreSamePointEpsilon( ptInt2, ptOth2, 10 * EPS_SMALL))) {
bFound = true ;
@@ -125,10 +121,10 @@ IntersSurfTmSurfTm( const ISurfTriMesh& Stm1, const ISurfTriMesh& Stm2,
bool bFound = false ;
BBox3d b3Tria ;
Tria.GetLocalBBox( b3Tria) ;
INTVECTOR vnIds ;
if ( TrGrid.Find( b3Tria, vnIds)) {
for ( int i = 0 ; i < int( vnIds.size()) ; ++ i) {
int nA = vnIds[i] ;
INTVECTOR vnId2s ;
if ( TrGrid.Find( b3Tria, vnId2s)) {
for ( int i = 0 ; i < int( vnId2s.size()) ; ++ i) {
int nA = vnId2s[i] ;
const Triangle3d& trOth = vTria[nA] ;
array< bool, 3> bOth = { false, false, false} ;
for ( int j = 0 ; j < 3 ; ++ j) {
+1 -1
View File
@@ -211,7 +211,7 @@ GetSurfTriMeshByRevolve( const ICurve* pCurve, const Point3d& ptAx, const Vector
if ( bCapEnds && ! PL.IsClosed()) {
Vector3d vtAxN = vtAx ;
vtAxN.Normalize() ;
double dPosIni, dPosFin ;
double dPosIni = 0, dPosFin = 0 ;
Point3d ptP ;
// proietto l'ultimo punto sull'asse di rotazione
if ( PL.GetLastPoint( ptP)) {
+3 -3
View File
@@ -1014,12 +1014,12 @@ SurfBezier::Invert( void)
}
if ( m_bRat) {
DBLVECTOR vWeCtrl = m_vWeCtrl ;
int l = 0 ;
int lr = 0 ;
for ( int i = 0 ; i <= m_nDegU ; ++ i) {
for ( int j = 0 ; j <= m_nDegV ; ++ j) {
int k = i + ( m_nDegU + 1) * j ;
m_vWeCtrl[l] = vWeCtrl[k] ;
++ l ;
m_vWeCtrl[lr] = vWeCtrl[k] ;
++ lr ;
}
}
}
+6 -6
View File
@@ -303,11 +303,11 @@ SurfFlatRegion::AddSimpleIntLoop( ICurve* pCrv)
int nLoopCnt = GetLoopCount( i) ;
for ( int j = 0 ; j < nLoopCnt ; ++ j) {
int k = m_vExtInd[i] + j ;
IntersCurveCurve ccInt( *pMyCrv, *m_vpLoop[k]) ;
CRVCVECTOR ccClass ;
if ( ccInt.GetCrossOrOverlapIntersCount() > 0 ||
! ccInt.GetCurveClassification( 0, ccClass) ||
ccClass.empty() || ccClass[0].nClass != CRVC_IN) {
IntersCurveCurve ccInt2( *pMyCrv, *m_vpLoop[k]) ;
CRVCVECTOR ccClass2 ;
if ( ccInt2.GetCrossOrOverlapIntersCount() > 0 ||
! ccInt2.GetCurveClassification( 0, ccClass2) ||
ccClass2.empty() || ccClass2[0].nClass != CRVC_IN) {
bOk = false ;
break ;
}
@@ -534,7 +534,7 @@ SurfFlatRegion::Load( NgeReader& ngeIn)
int j ;
bool bOk = ngeIn.ReadString( sName, ";") &&
FromString( sName.substr(2), j) && i == j ;
int nChunk, nLoop ;
int nChunk = 0, nLoop = 0 ;
bOk = ngeIn.ReadInt( nChunk, ",") &&
ngeIn.ReadInt( nLoop, ";", true) ;
// ne leggo i dati
+6 -4
View File
@@ -366,14 +366,16 @@ SurfFlatRegion::MyChainCurves( PCRV_DEQUE& vpCurve, PCRV_DEQUE& vpLoop)
double dCrvLen ;
if ( ! pCrvCompo->GetLength( dCrvLen) || dCrvLen < 2. * dToler)
continue ;
// se curva chiusa entro 2 volte la tolleranza ma considerata aperta, la chiudo bene
// se curva chiusa entro 3 volte la tolleranza ma considerata aperta, la chiudo bene
Point3d ptStart, ptEnd ;
if ( pCrvCompo->GetStartPoint( ptStart) &&
pCrvCompo->GetEndPoint( ptEnd) &&
AreSamePointEpsilon( ptStart, ptEnd, 2. * dToler) &&
AreSamePointEpsilon( ptStart, ptEnd, 3 * dToler) &&
! AreSamePointApprox( ptStart, ptEnd)) {
// porto il punto finale a coincidere esattamente con l'inizio
pCrvCompo->ModifyEnd( ptStart) ;
// porto i punti iniziale e finale a coincidere esattamente
Point3d ptNew = Media( ptStart, ptEnd) ;
pCrvCompo->ModifyStart( ptNew) ;
pCrvCompo->ModifyEnd( ptNew) ;
}
// compatto la nuova curva
pCrvCompo->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG) ;
+20 -20
View File
@@ -1996,16 +1996,16 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR
return false ;
// Recupero i punti iniziali sulla curva 1
int nV1p ; int nP1p = 0 ;
int nV1s ; int nP1s = 1 ;
int nV1p = -1 ; int nP1p = 0 ;
int nV1s = -1 ; int nP1s = 1 ;
bool bNext1 = ( nP1s < nTotP1) ;
if ( ! bNext1)
return false ;
if ( ( nV1p = AddVertex( vPnt1[nP1p].first)) == SVT_NULL)
return false ;
// Recupero i punti iniziali sulla curva 2
int nV2p ; int nP2p = 0 ;
int nV2s ; int nP2s = 1 ;
int nV2p = -1 ; int nP2p = 0 ;
int nV2s = -1 ; int nP2s = 1 ;
bool bNext2 = ( nP2s < nTotP2) ;
if ( ! bNext2)
return false ;
@@ -2112,23 +2112,23 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR
return false ;
// recupero i punti iniziali su curva 1
int nV1p = SVT_NULL ; double dU1p ; double dA1p ; Point3d ptP1p ;
int nV1s = SVT_NULL ; double dU1s ; double dA1s ; Point3d ptP1s ;
int nV1p = SVT_NULL ; double dU1p = 0 ; Point3d ptP1p ;
int nV1s = SVT_NULL ; double dU1s = 0 ; Point3d ptP1s ;
bool bNext1 = PL1.GetFirstUPoint( &dU1p, &ptP1p) && PL1.GetNextUPoint( &dU1s, &ptP1s, bClosed) ;
if ( ! bNext1)
return false ;
dA1p = 0 ;
dA1s = ( dU1s - dU1F) / dDeltaU1 ;
double dA1p = 0 ;
double dA1s = ( dU1s - dU1F) / dDeltaU1 ;
if ( ( nV1p = AddVertex( ptP1p)) == SVT_NULL)
return false ;
// recupero i punti iniziali su curva 2
int nV2p = SVT_NULL ; double dU2p ; double dA2p ; Point3d ptP2p ;
int nV2s = SVT_NULL ; double dU2s ; double dA2s ; Point3d ptP2s ;
int nV2p = SVT_NULL ; double dU2p = 0 ; Point3d ptP2p ;
int nV2s = SVT_NULL ; double dU2s = 0 ; Point3d ptP2s ;
bool bNext2 = PL2.GetFirstUPoint( &dU2p, &ptP2p) && PL2.GetNextUPoint( &dU2s, &ptP2s, bClosed) ;
if ( ! bNext2)
return false ;
dA2p = 0 ;
dA2s = ( dU2s - dU2F) / dDeltaU2 ;
double dA2p = 0 ;
double dA2s = ( dU2s - dU2F) / dDeltaU2 ;
int nIdV[3] ;
// se i punti iniziali non coincidono, inserisco il vertice iniziale di 2
if ( ! AreSamePointApprox( ptP1p, ptP2p)) {
@@ -2283,20 +2283,20 @@ SurfTriMesh::VerifyPolylinesForTwoCurves( const PolyLine& PL1, const PolyLine& P
if ( dDeltaU2 < EPS_SMALL)
return false ;
// ciclo sui punti
double dA1p ; double dU1p ; Point3d ptP1p ;
double dA1s ; double dU1s ; Point3d ptP1s ;
double dU1p = 0 ; Point3d ptP1p ;
double dU1s = 0 ; Point3d ptP1s ;
bool bNext1 = PL1.GetFirstUPoint( &dU1p, &ptP1p) && PL1.GetNextUPoint( &dU1s, &ptP1s, true) ;
if ( ! bNext1)
return true ;
dA1p = 0 ;
dA1s = ( dU1s - dU1F) / dDeltaU1 ;
double dA2p ; double dU2s ; Point3d ptP2s ;
double dA2s ; double dU2p ; Point3d ptP2p ;
double dA1p = 0 ;
double dA1s = ( dU1s - dU1F) / dDeltaU1 ;
double dU2s = 0 ; Point3d ptP2s ;
double dU2p = 0 ; Point3d ptP2p ;
bool bNext2 = PL2.GetFirstUPoint( &dU2p, &ptP2p) && PL2.GetNextUPoint( &dU2s, &ptP2s, true) ;
if ( ! bNext2)
return true ;
dA2p = 0 ;
dA2s = ( dU2s - dU2F) / dDeltaU2 ;
double dA2p = 0 ;
double dA2s = ( dU2s - dU2F) / dDeltaU2 ;
// se chiuse, verifico la coincidenza dell'inizio delle due curve
if ( bClosed && AreSamePointApprox( ptP1p, ptP2p))
return false ;
+17 -23
View File
@@ -337,7 +337,6 @@ SurfTriMesh::GeneralizedCut( const ICurve& cvCurve, bool bSaveOnEq)
// Vettore di catene di punti
CHAINVECTOR vChain ;
// Ciclo sui segmenti
bool bStartInside = false ;
int nChainCnt = 0 ;
bool bChain = false ;
Point3d ptChSt, ptChEn ;
@@ -572,7 +571,6 @@ SurfTriMesh::GeneralizedCut( const ICurve& cvCurve, bool bSaveOnEq)
cvBoundClosedLoopVec[nCL + 1] = cvBoundClosedLoopVec[nCL] ;
vbInOut[nCL + 1] = vbInOut[nCL] ;
}
int nLastPointLoop2 = int( Loop2.size()) - 1 ;
Vector3d vtTest = Loop1[1] - Loop1[0] ;
vtTest.Normalize() ;
bool bSecondInside = vtTest * cvOpenChain[nLastOpenLoopN][0].vtOuter < 0. ;
@@ -590,7 +588,6 @@ SurfTriMesh::GeneralizedCut( const ICurve& cvCurve, bool bSaveOnEq)
vtVecProva.Normalize( EPS_ZERO) ;
for ( int nLoop = 0 ; nLoop < int( cvBoundClosedLoopVec.size()) ; ++ nLoop) {
// Estremi del loop aperto
int nLastOpenLoopPoint = max(int(cvOpenChain[nLastOpenLoopN].size()) - 1, 0) ;
Point3d ptOpenLoopStP = cvOpenChain[nLastOpenLoopN][0].ptSt ;
Point3d ptOpenLoopEnP = cvOpenChain[nLastOpenLoopN][0].ptEn ;
// Cerco se esistono dei tratti del loop chiuso corrente che sono
@@ -794,7 +791,6 @@ SurfTriMesh::DecomposeLoop( CHAINVECTOR& cvOpenChain, INTVECTOR& vnDegVec, PNTMA
vtVecProva.Normalize( EPS_ZERO) ;
for ( int nLoop = 0 ; nLoop < int( cvBoundClosedLoopVec.size()) ; ++ nLoop) {
// Estremi del loop aperto
int nLastOpenLoopPoint = max( int( cvOpenChain[nLastOpenLoopN].size()) - 1, 0) ;
Point3d ptOpenLoopStP = cvOpenChain[nLastOpenLoopN][0].ptSt ;
Point3d ptOpenLoopEnP = cvOpenChain[nLastOpenLoopN][0].ptEn ;
// Cerco se esistono dei tratti del loop chiuso corrente che sono
@@ -1231,7 +1227,7 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
bool bPointOnSt = false ;
bool bPointOnEn = false ;
int nSegNum = 0 ;
int nSegMin ;
int nSegMin = 0 ;
Point3d ptS, ptE ;
bool bContinueS = vplPolyVec[nLoop].GetFirstPoint( ptS) ;
bool bContinueE = vplPolyVec[nLoop].GetNextPoint( ptE) ;
@@ -1261,10 +1257,10 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
Vector3d vtTan = ptE - ptS ;
vtTan.Normalize() ;
Vector3d vtOut = vtTan ^ trTria.GetN() ;
Point3d ptMinDist ;
Point3d ptMinDist2 ;
DistPointLine DistCalculator( ptLoopStart, ptS, ptE) ;
DistCalculator.GetMinDistPoint( ptMinDist) ;
double dMinDistDot = ( ptLoopStart - ptMinDist) * vtOut ;
DistCalculator.GetMinDistPoint( ptMinDist2) ;
double dMinDistDot = ( ptLoopStart - ptMinDist2) * vtOut ;
if ( dMinDistDot < - EPS_SMALL) {
vInnerLoop.emplace_back( nCLI) ;
break ;
@@ -1468,13 +1464,13 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
// Lista dei punti della PolyLine Loop corrente
PNTULIST& LoopPointList = vPolygons[nL].GetUPointList() ;
// Ciclo sui segmenti
auto itSt = LoopPointList.begin() ;
auto itEn = itSt ;
++ itEn ;
for ( ; itSt != LoopPointList.end() && itEn != LoopPointList.end() ; ++ itSt, ++ itEn) {
auto itSt2 = LoopPointList.begin() ;
auto itEn2 = itSt2 ;
++ itEn2 ;
for ( ; itSt2 != LoopPointList.end() && itEn2 != LoopPointList.end() ; ++ itSt2, ++ itEn2) {
// Segmento corrente
Point3d ptSt = itSt->first ;
Point3d ptEn = itEn->first ;
Point3d ptSt = itSt2->first ;
Point3d ptEn = itEn2->first ;
Vector3d vtSeg = ptEn - ptSt ;
double dSegLen = vtSeg.Len() ;
vtSeg /= dSegLen ;
@@ -1483,7 +1479,7 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
// Ciclo su tutti i punti non del segmento corrente
auto itP = LoopPointList.begin() ;
for ( ; itP != LoopPointList.end() ; ++ itP) {
if ( itP != itSt && itP != itEn) {
if ( itP != itSt2 && itP != itEn2) {
Point3d ptP = itP->first ;
DistPointLine DistCalculator( ptP, ptSt, ptEn) ;
double dDist ;
@@ -1507,7 +1503,7 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
}
// Aggiungo i punti al loop esterno
for ( int nPi = 0 ; nPi < int( vAddingPointWithOrder.size()) ; ++ nPi) {
itSt = LoopPointList.emplace( itEn, vAddingPointWithOrder[nPi]) ;
itSt2 = LoopPointList.emplace( itEn2, vAddingPointWithOrder[nPi]) ;
}
}
// Spezzo i loop autointersecantesi
@@ -1520,9 +1516,9 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
bSplitted = false ;
for ( int nl = 0 ; nl < int( vAuxPolygons.size()) ; ++ nl) {
PNTULIST& PntLst = vAuxPolygons[nl].GetUPointList() ;
std::vector<Point3d> vPoint ;
for ( auto it = PntLst.begin() ; it != PntLst.end() ; ++ it) {
vPoint.emplace_back( it->first) ;
PNTVECTOR vPoint ;
for ( auto it2 = PntLst.begin() ; it2 != PntLst.end() ; ++ it2) {
vPoint.emplace_back( it2->first) ;
}
int nStartPt = -1 ;
int nEndPt = int( vPoint.size()) ;
@@ -1774,7 +1770,6 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
// Recupero i triangoli di B che interferiscono col box del triangolo di A
INTVECTOR vNearTria ;
SurfB.GetAllTriaOverlapBox( b3dTriaA, vNearTria) ;
bool bNewTriaA = true ;
for ( int nTB = 0 ; nTB < int( vNearTria.size()) ; ++ nTB) {
// Se il triangolo B non è valido, continuo
Triangle3d trTriaB ;
@@ -2012,10 +2007,10 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
bContinue = ( AdjustVertices() && DoCompacting() && SurfB.AdjustVertices() && SurfB.DoCompacting()) ;
// Triangoli sovrapposti
if ( bContinue) {
int nTriaNumA = GetTriangleSize() ;
int nTriaNum2A = GetTriangleSize() ;
// Resetto e ricalcolo la HashGrid della superficie B
SurfB.ResetHashGrids3d() ;
for ( int nTA = 0 ; nTA < nTriaNumA ; ++ nTA) {
for ( int nTA = 0 ; nTA < nTriaNum2A ; ++ nTA) {
// Se il triangolo A non è valido, continuo
Triangle3d trTriaA ;
if ( ! GetTriangle( nTA, trTriaA) || ! trTriaA.Validate( true))
@@ -2026,7 +2021,6 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
// Recupero i triangoli di B che interferiscono col box del triangolo di A
INTVECTOR vNearTria ;
SurfB.GetAllTriaOverlapBox( b3dTriaA, vNearTria) ;
bool bNewTriaA = true ;
for ( int nTB = 0 ; nTB < int( vNearTria.size()) ; ++ nTB) {
// Se il triangolo B non è valido, continuo
Triangle3d trTriaB ;
+2 -2
View File
@@ -109,9 +109,9 @@ Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr)
// verifico le altre polilinee
for ( int i = 1 ; i < int( vPL.size()) ; ++i) {
// deve essere chiusa, giacere nello stesso piano ed essere orientata al contrario della esterna
double dArea ;
double dArea2 ;
Plane3d plPlane ;
if ( ! vPL[i].IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL) ||
if ( ! vPL[i].IsClosedAndFlat( plPlane, dArea2, 50 * EPS_SMALL) ||
! AreOppositeVectorApprox( plExtPlane.GetVersN(), plPlane.GetVersN()))
return false ;
}
+5 -5
View File
@@ -358,10 +358,10 @@ VolZmap::GetDepthWithDexel( const Point3d& ptPLoc, const Vector3d& vtDLoc, doubl
while ( ( bOnX && i <= nFi) || ( ! bOnX && j <= nFj)) {
// Eseguo controllo
double dU1, dU2 ;
if ( IntersRayDexel( ptP0, vtV0, nGrid, i, j, dU1, dU2)) {
dInLen[nGrid] = min( dInLen[nGrid], dU1) ;
dOutLen[nGrid] = max( dOutLen[nGrid], dU2) ;
double dV1, dV2 ;
if ( IntersRayDexel( ptP0, vtV0, nGrid, i, j, dV1, dV2)) {
dInLen[nGrid] = min( dInLen[nGrid], dV1) ;
dOutLen[nGrid] = max( dOutLen[nGrid], dV2) ;
}
// Calcolo spostamento (a destra o sopra)
@@ -447,7 +447,7 @@ VolZmap::GetDepthWithVoxel( const Point3d& ptP, const Vector3d& vtD, double& dIn
dInLength = INFINITO ;
dOutLength = -INFINITO ;
int nFirstPosN ;
int nFirstPosN = 0 ;
for ( int nN = 0; nN < int( vIntersInfo.size()) ; ++ nN) {
if ( vIntersInfo[nN].dU > - EPS_SMALL) {
nFirstPosN = nN ;
+25 -49
View File
@@ -99,7 +99,7 @@ int
TestOnNormal( const AppliedVector CompoField[], int nCompoElem)
{
// Cerco la massima deviazione tra le normali nei punti della parte connessa
int nI, nJ ;
int nI = -1, nJ = -1 ;
double dMinCosTheta = 2 ;
for ( int i = 0 ; i < nCompoElem ; ++ i) {
for ( int j = i + 1 ; j < nCompoElem ; ++ j) {
@@ -142,7 +142,7 @@ bool
CanonicPlaneTest( const AppliedVector CompoField[], int nDir, double& dPos, int& nTool)
{
// Verifico posizione dei punti
int nI ;
int nI = -1 ;
switch ( nDir) {
case X_PLUS : case X_MINUS : nI = 0 ; break ;
case Y_PLUS : case Y_MINUS : nI = 1 ; break ;
@@ -166,7 +166,6 @@ CanonicPlaneTest( const AppliedVector CompoField[], int nDir, double& dPos, int&
case Z_PLUS : vtN = Z_AX ; break ;
case Z_MINUS : vtN = - Z_AX ; break ;
}
int nDifferent = 0 ;
for ( int i = 0 ; i < 4 ; ++ i) {
if ( CompoField[i].vtVec * vtN < 0.999)
return false ;
@@ -657,8 +656,8 @@ VolZmap::GetChunkPrisms( int nPos1, int nPos2, int nDim1, int nDim2, int nDimChk
{
// determino se è un semplice parallelepipedo
bool bIsSimple = true ;
double dBotZ ;
double dTopZ ;
double dBotZ = 0 ;
double dTopZ = 0 ;
for ( int i = 0 ; i < nDim1 && bIsSimple ; ++ i) {
for ( int j = 0 ; j < nDim2 && bIsSimple ; ++ j) {
int nPos = ( nPos1 + i) + ( nPos2 + j) * m_nNx[0] ;
@@ -1224,8 +1223,8 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
int nIJKSl[3] = { ( nAdjVox3[nCount] != 1 ? i : i + 1),
( nAdjVox3[nCount] != 2 ? j : j + 1),
( nAdjVox3[nCount] != 3 ? k : k + 1) } ;
int nSliceN ;
int nSlBlockN ;
int nSliceN = -1 ;
int nSlBlockN = -1 ;
if ( GetVoxNFromIJK(nIJKSl[0], nIJKSl[1], nIJKSl[2], nSliceN)) {
int nSlBlockIJK[3] ;
GetVoxelBlockIJK(nIJKSl, nSlBlockIJK) ;
@@ -1622,8 +1621,8 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
nFace[nCurFaceXY] = 0 ;
// Per ogni faccia in gioco vediamo se c'è materiale: se sì assegnamo l'indice 1
int nSlYZN ;
int nSlYZBlockN ;
int nSlYZN = -1 ;
int nSlYZBlockN =-1 ;
if ( GetVoxNFromIJK( nIJKSlYZ[0], nIJKSlYZ[1], nIJKSlYZ[2], nSlYZN)) {
// Slice interna al blocco
auto it = SliceYZ.find( nSlYZN) ;
@@ -1646,8 +1645,8 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
}
}
}
int nSlXZN ;
int nSlXZBlockN ;
int nSlXZN = -1 ;
int nSlXZBlockN =-1 ;
if ( GetVoxNFromIJK( nIJKSlXZ[0], nIJKSlXZ[1], nIJKSlXZ[2], nSlXZN)) {
// Slice interna al blocco
auto it = SliceXZ.find( nSlXZN) ;
@@ -1670,8 +1669,8 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
}
}
}
int nSlXYN ;
int nSlXYBlockN ;
int nSlXYN =-1 ;
int nSlXYBlockN =-1 ;
if ( GetVoxNFromIJK( nIJKSlXY[0], nIJKSlXY[1], nIJKSlXY[2], nSlXYN)) {
// Slice interna al blocco
auto it = SliceXY.find( nSlXYN) ;
@@ -1938,9 +1937,6 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
int nVoxSmootSizePrev = int( VoxSmoothTria.vTria.size()) ;
int nVoxSmootSize = nVoxSmootSizePrev ;
// Numero di feature nel voxel: al più vi è una feature per componente connessa.
int nFeatureInVoxel = 0 ;
// Ciclo sulle componenti
for ( int nComp = 0 ; nComp < nComponents ; ++ nComp) {
@@ -2482,31 +2478,12 @@ VolZmap::RegulateFeaturesChain( vector<VoxelContainer>& vVecVox) const
double dMidU = ( ptMid - ptPSt) * vtStEn ;
double dCurU = ( ptPCur - ptPSt) * vtStEn ;
Point3d ptNew ;
//Point3d ptPLine ;
//Vector3d vtDLine ;
if ( dMidU < dCurU) {
//ptPLine = ptPEn ;
//vtDLine = - vtCurrEn ;
ptNew = ptPEn + ( ptMid - ptPEn) * vtCurrEn * vtCurrEn ;
}
else {
//ptPLine = ptPSt ;
//vtDLine = vtStCurr ;
ptNew = ptPSt + ( ptMid - ptPSt) * vtStCurr * vtStCurr ;
}
//Point3d ptCubeInf( ( CurVox.i * m_nDexVoxRatio + 0.5) * m_dStep,
// ( CurVox.j * m_nDexVoxRatio + 0.5) * m_dStep,
// ( CurVox.k * m_nDexVoxRatio + 0.5) * m_dStep) ;
//Point3d ptCubeSup( ( ( CurVox.i + 1) * m_nDexVoxRatio + 0.5) * m_dStep,
// ( ( CurVox.j + 1) * m_nDexVoxRatio + 0.5) * m_dStep,
// ( ( CurVox.k + 1) * m_nDexVoxRatio + 0.5) * m_dStep) ;
//double dU1, dU2 ;
//if ( 1 - abs( vtStCurr * vtCurrEn ) < EPS_ZERO &&
// IntersLineBox( ptPLine, vtDLine, ptCubeInf, ptCubeSup, dU1, dU2)) {
// double dU = abs( dU1) < abs( dU2) ? dU1 + ( dU2 - dU1) / 2 : dU2 + ( dU1 - dU2) / 2 ;
// ptNew = ptPLine + dU * vtDLine ;
//}
bool bNewInside = IsPointInsideVoxelApprox( CurVox.i, CurVox.j, CurVox.k, ptNew, 0) ;
if ( abs( vtStCurr * vtStEn) > 0.95 && abs( vtStCurr * vtCurrEn) > 0.95 &&
abs( vtStEn * vtCurrEn) > 0.95) {
CurVox.Compo[nComp].ptVert = ptNew ;
@@ -2597,7 +2574,6 @@ VolZmap::RegulateFeaturesChain( vector<VoxelContainer>& vVecVox) const
double dU = ( dU1 + dU2) / 2 ;
ptNew = ptPLine + dU * vtDLine ;
}
bool bNewInside = IsPointInsideVoxelApprox( CurVox.i, CurVox.j, CurVox.k, ptNew, 0) ;
if ( abs( vtStCurr * vtStEn) > 0.95 && abs( vtStCurr * vtCurrEn) > 0.95 &&
abs( vtStEn * vtCurrEn) > 0.95 /*&& bNewInside*/) {
CurVox.Compo[nComp].ptVert = ptNew ;
@@ -2959,7 +2935,7 @@ VolZmap::FlipEdgesII( int nBlock) const
if ( bOnPlane) {
Triangle3d trT1 = vTria1[nTri1] ;
Triangle3d trT2 = vTria2[nTri2] ;
int nVert1, nVert2 ;
int nVert1 = -1, nVert2 = -1 ;
// Determino gli indici dei punti sharp-feature
for ( int nP = 0 ; nP < 3 ; ++ nP) {
if ( nP != 1 && nP != 2)
@@ -3023,7 +2999,7 @@ VolZmap::FlipEdgesII( int nBlock) const
}
}
// Trovo il colore associato al vertice di massimo prodotto scalare
int nCol ;
int nCol = -1 ;
switch ( nMaxPos) {
case 0 :
nCol = vTria1[nTri1].GetAttrib( 1) ;
@@ -3241,7 +3217,7 @@ VolZmap::FlipEdgesBB( void) const
if ( bOnPlane) {
Triangle3dEx trTF = m_InterBlockSharpTria[tFB][tVFB].vCompoTria[tCmpF][tTriFB] ;
Triangle3dEx trTL = m_InterBlockSharpTria[tLB][tVLB].vCompoTria[tCmpL][tTriLB] ;
int nVertF, nVertL ;
int nVertF = -1, nVertL =-1 ;
// Determino gli indici dei punti sharp-feature
for ( int nP = 0 ; nP < 3 ; ++ nP) {
if ( nP != 1 && nP != 2)
@@ -3312,7 +3288,7 @@ VolZmap::FlipEdgesBB( void) const
}
}
// Trovo il colore associato al vertice di massimo prodotto scalare
int nCol ;
int nCol = -1 ;
switch ( nMaxPos) {
case 0 :
nCol = m_InterBlockSharpTria[tFB][tVFB].vCompoTria[tCmpF][tTriFB].GetAttrib( 1) ;
@@ -3386,7 +3362,7 @@ VolZmap::IsThereMat( int nI, int nJ, int nK) const
bool bInterOnNode[3] = { false, false, false} ;
for ( int nGrid = 0 ; nGrid < int( m_nMapNum) ; ++ nGrid) {
// assegnazione dati vertice dipendenti dalla griglia
int nGrI, nGrJ ;
int nGrI = -1, nGrJ = -1 ;
switch ( nGrid) {
case 0 :
nGrI = nI ;
@@ -4086,7 +4062,7 @@ VolZmap::GetLastVoxIJK( int& i, int& j, int& k) const
if ( m_nShape != BOX)
return false ;
// Calcolo indici
int ni, nj ;
int ni = -1, nj = -1 ;
for ( ni = int( m_nNx[0]) - 1 ; ni > int( m_nNx[0]) - 3 ; -- ni) {
bool bNotEmpty = false ;
for ( nj = int( m_nNy[0]) - 1 ; nj > int( m_nNy[0]) - 3 ; -- nj) {
@@ -4099,7 +4075,7 @@ VolZmap::GetLastVoxIJK( int& i, int& j, int& k) const
if ( bNotEmpty)
break ;
}
int mi, mj ;
int mi = -1, mj = -1 ;
for ( mi = int( m_nNx[1]) - 1 ; mi > int( m_nNx[1]) - 3 ; -- mi) {
bool bNotEmpty = false ;
for ( mj = int( m_nNy[1]) - 1 ; mj > int( m_nNy[1]) - 3 ; -- mj) {
@@ -4332,8 +4308,8 @@ VolZmap::ProcessVoxContXY( FlatVoxelContainer& VoxContXY, int nBlock, bool bPlus
}
Tria0.SetGrade( nToolNum) ;
Tria1.SetGrade( nToolNum) ;
bool bV0 = Tria0.Validate( true) ;
bool bV1 = Tria1.Validate( true) ;
Tria0.Validate( true) ;
Tria1.Validate( true) ;
// Aggiungo alla lista
m_BlockBigTria[nBlock].emplace_back( Tria0) ;
m_BlockBigTria[nBlock].emplace_back( Tria1) ;
@@ -4452,8 +4428,8 @@ VolZmap::ProcessVoxContYZ( FlatVoxelContainer& VoxContYZ, int nBlock, bool bPlus
}
Tria0.SetGrade( nToolNum) ;
Tria1.SetGrade( nToolNum) ;
bool bV0 = Tria0.Validate( true) ;
bool bV1 = Tria1.Validate( true) ;
Tria0.Validate( true) ;
Tria1.Validate( true) ;
// Aggiungo alla lista
m_BlockBigTria[nBlock].emplace_back( Tria0) ;
m_BlockBigTria[nBlock].emplace_back( Tria1) ;
@@ -4572,8 +4548,8 @@ VolZmap::ProcessVoxContXZ( FlatVoxelContainer& VoxContXZ, int nBlock, bool bPlus
}
Tria0.SetGrade( nToolNum) ;
Tria1.SetGrade( nToolNum) ;
bool bV0 = Tria0.Validate( true) ;
bool bV1 = Tria1.Validate( true) ;
Tria0.Validate( true) ;
Tria1.Validate( true) ;
// Aggiungo alla lista
m_BlockBigTria[nBlock].emplace_back( Tria0) ;
m_BlockBigTria[nBlock].emplace_back( Tria1) ;
+7 -25
View File
@@ -845,7 +845,6 @@ VolZmap::CylBall_ZPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const
// Parametri geometrici dell'utensile
double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ;
double dSqRad = m_Tool.GetRadius() * m_Tool.GetRadius() ;
double dSafeRad = m_Tool.GetRadius() - EPS_SMALL ;
double dSafeSqRad = dSafeRad * dSafeRad ;
@@ -990,22 +989,18 @@ VolZmap::CylBall_ZMilling( int nGrid, const Point3d & ptS, const Point3d & ptE,
double dZMaxI = max( ptI.z, ptIT.z) ;
double dZMaxF = max( ptF.z, ptFT.z) ;
double dZMinI = dZMaxI - dStemHeigth ;
double dZMinF = dZMaxF - dStemHeigth ;
double dDeltaZ = dZMaxF - dZMaxI ;
// Vettori caratterizzanti il moto
Vector3d vtMove = ptF - ptI ;
Vector3d vtMoveXY( vtMove.x, vtMove.y, 0) ;
double dLen = vtMove.Len() ;
double dLenXY = vtMoveXY.LenXY() ;
vtMove.Normalize() ;
// Parametri per determinare l'ellisse proiettata
double dCos = vtToolDir * vtMove ;
double dSin = ( abs( dCos) < 1 ? 1 - dCos * dCos : 0) ;
double dSemiAxMin = m_Tool.GetRadius() * dCos ; // x1^2 = a^2 - (a / b)^2 x2^2 ; a = r dCos e b = r;
double dSqSemiAxMin = dSemiAxMin * dSemiAxMin ; // da cui si ottiene x1^2 = a^2 - dCos^2 x2^2
double dSqRatio = dSqSemiAxMin / dSqRad ;
// Definizione di un sistema di riferimento ad hoc
Vector3d vtV1, vtV2 ;
@@ -1649,7 +1644,7 @@ VolZmap::GenTool_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
const ICurve* pCurve = ToolProfile.GetFirstCurve() ;
while ( pCurve != nullptr) {
double dHeight ;
double dHeight = 0 ;
// Se segmento
if ( pCurve->GetType() == CRV_LINE) {
@@ -1738,7 +1733,7 @@ VolZmap::GenTool_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co
const ICurve* pCurve = ToolProfile.GetFirstCurve() ;
while ( pCurve != nullptr) {
double dHeight ;
double dHeight = 0 ;
// Se segmento
if ( pCurve->GetType() == CRV_LINE) {
@@ -1953,7 +1948,6 @@ VolZmap::CylBall_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, cons
// Parte sferica
double dCos = vtMove.z ; // vtMove.z > 0 : ptF.z >= ptI.z
double dSin = ( dCos < 1 ? sqrt( 1 - dCos * dCos) : 0) ;
double dSemiAxMin = m_Tool.GetRadius() * dCos ;
double dInfZ, dSupZ ;
@@ -2191,8 +2185,6 @@ VolZmap::Conus_XYDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co
double dMinRad = min( m_Tool.GetRadius(), m_Tool.GetTipRadius()) ;
double dMaxRad = max( m_Tool.GetRadius(), m_Tool.GetTipRadius()) ;
double dDeltaRad = dMaxRad - dMinRad ;
double dSqMinRad = dMinRad * dMinRad ;
double dSqMaxRad = dMaxRad * dMaxRad ;
// Geometria del moto
double dLenXY = ( ptE - ptS).LenXY() ;
@@ -2319,11 +2311,8 @@ VolZmap::Conus_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const
double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ;
double dMinRad = min( m_Tool.GetRadius(), m_Tool.GetTipRadius()) ;
double dMaxRad = max( m_Tool.GetRadius(), m_Tool.GetTipRadius()) ;
double dSqTipRad = m_Tool.GetTipRadius() * m_Tool.GetTipRadius() ;
double dSqRad = m_Tool.GetRadius() * m_Tool.GetRadius() ;
double dDeltaRad = dMaxRad - dMinRad ;
double dSqMinRad = dMinRad * dMinRad ;
double dSqMaxRad = dMaxRad * dMaxRad ;
// Studio delle simmetrie del moto
Point3d ptI = ( ptS.z < ptE.z ? ptS : ptE) ;
@@ -2337,7 +2326,6 @@ VolZmap::Conus_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const
// Cinematica del moto
Vector3d vtMove = ptF - ptI ;
double dLenPath = vtMove.Len() ;
double dLengthPathXY = vtMove.LenXY() ;
double dDeltaZ = ptF.z - ptI.z ;
double dZI = ptI.z ;
@@ -2870,7 +2858,7 @@ VolZmap::GenTool_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co
const ICurve* pCurve = ToolProfile.GetFirstCurve() ;
while ( pCurve != nullptr) {
double dHeight ;
double dHeight = 0 ;
// Se segmento
if ( pCurve->GetType() == CRV_LINE) {
@@ -2987,7 +2975,7 @@ VolZmap::GenTool_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, con
const ICurve* pCurve = ToolProfile.GetFirstCurve() ;
while ( pCurve != nullptr) {
double dHeight ;
double dHeight = 0 ;
// Se segmento
if ( pCurve->GetType() == CRV_LINE) {
@@ -3317,22 +3305,18 @@ VolZmap::CompCyl_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co
double dZMaxI = max( ptI.z, ptIT.z) ;
double dZMaxF = max( ptF.z, ptFT.z) ;
double dZMinI = dZMaxI - dHei ;
double dZMinF = dZMaxF - dHei ;
double dDeltaZ = dZMaxF - dZMaxI ;
// Vettori caratterizzanti il moto
Vector3d vtMove = ptF - ptI ;
Vector3d vtMoveXY( vtMove.x, vtMove.y, 0) ;
double dLen = vtMove.Len() ;
double dLenXY = vtMoveXY.LenXY() ;
vtMove.Normalize() ;
// Parametri per determinare l'ellisse proiettata
double dCos = vtToolDir * vtMove ;
double dSin = ( abs( dCos) < 1 ? 1 - dCos * dCos : 0) ;
double dSemiAxMin = dRad * dCos ; // x1^2 = a^2 - (a / b)^2 x2^2 ; a = r dCos e b = r;
double dSqSemiAxMin = dSemiAxMin * dSemiAxMin ; // da cui si ottiene x1^2 = a^2 - dCos^2 x2^2
double dSqRatio = dSqSemiAxMin / dSqRad ;
double dSafeRad = dRad - EPS_SMALL ;
@@ -3436,8 +3420,8 @@ VolZmap::CompConus_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE,
Point3d ptIxy( ptI.x, ptI.y, 0) ;
Point3d ptFxy( ptF.x, ptF.y, 0) ;
Vector3d vtMove = ptF - ptI ; double dLen = vtMove.Len() ;
Vector3d vtMLong = ( vtMove * vtToolDir) * vtToolDir ; double dLLong = vtMLong.Len() ;
Vector3d vtMove = ptF - ptI ;
Vector3d vtMLong = ( vtMove * vtToolDir) * vtToolDir ;
Vector3d vtMOrt = vtMove - vtMLong ; double dLOrt = vtMOrt.Len() ;
Vector3d vtV1 = vtToolDir ;
@@ -3472,7 +3456,7 @@ VolZmap::CompConus_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE,
double dDots = vtR0 * vtNs ;
double dDotd = vtR0 * vtNd ;
double dMin, dMax, dPLim, dMLim ;
double dMin = 0, dMax = 0, dPLim = 0, dMLim = 0 ;
Vector3d vtMin, vtMax, vtP, vtM ;
Vector3d vtUmv = vtMove ;
@@ -3624,7 +3608,6 @@ VolZmap::CompConus_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE,
}
else {
double dLatMin = dMinRad * dSin ;
double dLatMax = dMaxRad * dSin ;
double dDeltaLat = dDeltaR * dSin ;
Vector3d vtRadial = dCos * vtV2 - dSin * vtV3 ;
vtRadial.Normalize() ;
@@ -3660,7 +3643,6 @@ VolZmap::CompConus_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE,
}
else {
double dLatMin = dMinRad * dSin ;
double dLatMax = dMaxRad * dSin ;
double dDeltaLat = dDeltaR * dSin ;
Vector3d vtRadial = dCos * vtV2 + dSin * vtV3 ;
vtRadial.Normalize() ;