Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a4ee5cc19 | |||
| 32883dab86 | |||
| 8ac3fdab47 |
+21
-84
@@ -15,30 +15,15 @@
|
||||
#include "stdafx.h"
|
||||
#include "GeoConst.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "RemoveCurveDefects.h"
|
||||
#include "RemoveCurveSpikes.h"
|
||||
#include "AdjustLoops.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//-------------------------------------------------------
|
||||
static bool
|
||||
SortCrvCrvInfo( const IntCrvCrvInfo& aInfo1, const IntCrvCrvInfo& aInfo2)
|
||||
{
|
||||
// confronto i valori del primo punto della curva A
|
||||
double dU1 = aInfo1.IciA[0].dU ;
|
||||
double dU2 = aInfo2.IciA[0].dU ;
|
||||
if ( abs( dU1 - dU2) < EPS_SMALL)
|
||||
// se sono uguali confronto i valori del primo punto della curva B
|
||||
return aInfo1.IciB[0].dU > aInfo2.IciB[0].dU ;
|
||||
else
|
||||
return dU1 < dU2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
|
||||
@@ -88,75 +73,43 @@ MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
|
||||
return false ;
|
||||
Intervals inOk( EPS_PARAM) ;
|
||||
inOk.Set( dStart, dEnd) ;
|
||||
|
||||
// recupero tutte le info delle autointersezioni
|
||||
IntCrvCrvInfo iccInfo ;
|
||||
ICCIVECTOR vIccInfo( sintC.GetIntersCount()) ;
|
||||
for ( int i = 0 ; sintC.GetIntCrvCrvInfo( i, iccInfo) ; ++ i)
|
||||
vIccInfo[i]= iccInfo ;
|
||||
// ordino il vettore
|
||||
sort( vIccInfo.begin(), vIccInfo.end(), SortCrvCrvInfo) ;
|
||||
|
||||
|
||||
// Tolgo le parti da eliminare
|
||||
int nCross = 0 ;
|
||||
for ( int i = 0 ; i < int( vIccInfo.size()) ; ++ i) {
|
||||
|
||||
if ( i < int( vIccInfo.size()) - 1) {
|
||||
// se anche l'intersezione successiva è overlap che parte dallo stesso punto
|
||||
if ( vIccInfo[i].bOverlap && vIccInfo[i+1].bOverlap &&
|
||||
abs( vIccInfo[i].IciA[0].dU - vIccInfo[i+1].IciA[0].dU) < EPS_SMALL &&
|
||||
abs( vIccInfo[i].IciB[0].dU - vIccInfo[i+1].IciB[0].dU) < EPS_SMALL) {
|
||||
// elimino il tratto
|
||||
inOk.Subtract( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciB[0].dU) ;
|
||||
// salto le intersezioni successive già considerate rimuovendo questo intervallo
|
||||
int j = i + 2 ;
|
||||
while ( j < ( int)vIccInfo.size() && vIccInfo[j].IciA[0].dU > vIccInfo[i].IciA[0].dU - EPS_SMALL &&
|
||||
vIccInfo[j].IciA[1].dU < vIccInfo[i].IciB[0].dU + EPS_SMALL) {
|
||||
j ++ ;
|
||||
}
|
||||
// aggiorno il contatore
|
||||
i = j - 1 ;
|
||||
continue ;
|
||||
}
|
||||
}
|
||||
|
||||
IntCrvCrvInfo iccInfo ;
|
||||
for ( int i = 0 ; sintC.GetIntCrvCrvInfo( i, iccInfo) ; ++ i) {
|
||||
// se con sovrapposizione
|
||||
if ( vIccInfo[i].bOverlap) {
|
||||
if ( iccInfo.bOverlap) {
|
||||
// se solo touch
|
||||
if ( ( vIccInfo[i].IciA[0].nPrevTy == vIccInfo[i].IciA[1].nNextTy ||
|
||||
vIccInfo[i].IciA[0].nPrevTy == ICCT_SPK || vIccInfo[i].IciA[1].nNextTy == ICCT_SPK) &&
|
||||
vIccInfo[i].IciA[0].nPrevTy != ICCT_NULL && vIccInfo[i].IciA[1].nNextTy != ICCT_NULL) {
|
||||
if ( ( iccInfo.IciA[0].nPrevTy == iccInfo.IciA[1].nNextTy ||
|
||||
iccInfo.IciA[0].nPrevTy == ICCT_SPK || iccInfo.IciA[1].nNextTy == ICCT_SPK) &&
|
||||
iccInfo.IciA[0].nPrevTy != ICCT_NULL && iccInfo.IciA[1].nNextTy != ICCT_NULL) {
|
||||
// obbligatoriamente controversi, elimino entrambi i tratti
|
||||
inOk.Subtract( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciA[1].dU) ;
|
||||
inOk.Subtract( vIccInfo[i].IciB[0].dU, vIccInfo[i].IciB[1].dU) ;
|
||||
inOk.Subtract( iccInfo.IciA[0].dU, iccInfo.IciA[1].dU) ;
|
||||
inOk.Subtract( iccInfo.IciB[0].dU, iccInfo.IciB[1].dU) ;
|
||||
}
|
||||
// altrimenti attraversamento
|
||||
else {
|
||||
// elimino la parte interna
|
||||
if ( vIccInfo[i].bCBOverEq)
|
||||
inOk.Subtract( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciB[0].dU) ;
|
||||
if ( iccInfo.bCBOverEq)
|
||||
inOk.Subtract( iccInfo.IciA[0].dU, iccInfo.IciB[0].dU) ;
|
||||
else
|
||||
inOk.Subtract( min( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciB[1].dU), max( vIccInfo[i].IciB[0].dU, vIccInfo[i].IciA[1].dU)) ;
|
||||
inOk.Subtract( min( iccInfo.IciA[0].dU, iccInfo.IciB[1].dU), max( iccInfo.IciB[0].dU, iccInfo.IciA[1].dU)) ;
|
||||
}
|
||||
}
|
||||
// altrimenti
|
||||
else {
|
||||
// se solo touch
|
||||
if ( vIccInfo[i].IciA[0].nPrevTy == vIccInfo[i].IciA[0].nNextTy &&
|
||||
vIccInfo[i].IciA[0].nPrevTy != ICCT_NULL && vIccInfo[i].IciA[0].nNextTy != ICCT_NULL) {
|
||||
inOk.Subtract( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciA[0].dU) ;
|
||||
inOk.Subtract( vIccInfo[i].IciB[0].dU, vIccInfo[i].IciB[0].dU) ;
|
||||
if ( iccInfo.IciA[0].nPrevTy == iccInfo.IciA[0].nNextTy &&
|
||||
iccInfo.IciA[0].nPrevTy != ICCT_NULL && iccInfo.IciA[0].nNextTy != ICCT_NULL) {
|
||||
inOk.Subtract( iccInfo.IciA[0].dU, iccInfo.IciA[0].dU) ;
|
||||
inOk.Subtract( iccInfo.IciB[0].dU, iccInfo.IciB[0].dU) ;
|
||||
}
|
||||
// altrimenti attraversamento
|
||||
else {
|
||||
if ( IsEven( nCross))
|
||||
inOk.Subtract( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciB[0].dU) ;
|
||||
else
|
||||
inOk.Add( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciB[0].dU) ;
|
||||
++ nCross ;
|
||||
inOk.Subtract( iccInfo.IciA[0].dU, iccInfo.IciB[0].dU) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copio le parti da conservare
|
||||
double dParS, dParE ;
|
||||
@@ -248,22 +201,6 @@ MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
|
||||
++ iIter ;
|
||||
}
|
||||
|
||||
// elimino le curve troppo piccole
|
||||
for ( auto iIter = CrvLst.begin() ; iIter != CrvLst.end() ;) {
|
||||
CurveComposite* pCrvCo = GetBasicCurveComposite( *iIter) ;
|
||||
BBox3d b3CrvCo ;
|
||||
double dDiam ;
|
||||
if ( ! pCrvCo->GetLocalBBox( b3CrvCo) || b3CrvCo.IsEmpty() ||
|
||||
! b3CrvCo.GetDiameter( dDiam) || dDiam < 20 * EPS_SMALL) {
|
||||
delete pCrvCo ;
|
||||
pCrvCo = nullptr ;
|
||||
iIter = CrvLst.erase( iIter) ;
|
||||
}
|
||||
else {
|
||||
++ iIter ;
|
||||
}
|
||||
}
|
||||
|
||||
// riporto le curve nel riferimento originale
|
||||
if ( bNeedRef) {
|
||||
for ( auto pCrv : CrvLst)
|
||||
@@ -288,10 +225,10 @@ AdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
|
||||
// se curva composita
|
||||
CurveComposite* pCrvCo = GetBasicCurveComposite( pCrv) ;
|
||||
if ( pCrvCo != nullptr) {
|
||||
// elimino eventuali Spikes e Small Z
|
||||
pCrvCo->RemoveSmallDefects( 2 * LIN_TOL_MIN, ANG_TOL_STD_DEG, true) ;
|
||||
// unisco eventuali tratti allineati
|
||||
pCrvCo->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG) ;
|
||||
// elimino eventuali spikes
|
||||
RemoveCurveSpikes( pCrvCo) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,57 +63,3 @@ AngleInSpan( double dAngDeg, double dAngRefDeg, double dAngSpanDeg)
|
||||
dAngDiffDeg < dHalfAngSpanDeg + EPS_ANG_SMALL) ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
AngleInRange( double dAngDeg, double dAngMinDeg, double dAngMaxDeg)
|
||||
{
|
||||
return AngleInSpan( dAngDeg, ( dAngMinDeg + dAngMaxDeg) / 2, dAngMaxDeg - dAngMinDeg) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
AdjustAngleInSpan( double& dAngDeg, double dAngRefDeg, double dAngSpanDeg)
|
||||
{
|
||||
// Verifico consistenza intervallo
|
||||
if ( dAngSpanDeg < -EPS_ANG_ZERO)
|
||||
return false ;
|
||||
// Se intervallo vero
|
||||
if ( dAngSpanDeg > EPS_ANG_SMALL) {
|
||||
double dTryDeg = dAngDeg ;
|
||||
// eseguo gli aggiustamenti
|
||||
while ( dTryDeg < dAngRefDeg - dAngSpanDeg)
|
||||
dTryDeg += ANG_FULL ;
|
||||
while ( dTryDeg > dAngRefDeg + dAngSpanDeg)
|
||||
dTryDeg -= ANG_FULL ;
|
||||
// verifico
|
||||
if ( dTryDeg >= dAngRefDeg - dAngSpanDeg && dTryDeg <= dAngRefDeg + dAngSpanDeg) {
|
||||
dAngDeg = dTryDeg ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
// altrimenti un valore
|
||||
else {
|
||||
double dTryDeg = dAngDeg ;
|
||||
// eseguo gli aggiustamenti
|
||||
while ( dTryDeg < dAngRefDeg - EPS_ANG_SMALL)
|
||||
dTryDeg += ANG_FULL ;
|
||||
while ( dTryDeg > dAngRefDeg + EPS_ANG_SMALL)
|
||||
dTryDeg -= ANG_FULL ;
|
||||
// verifico
|
||||
if ( abs( dTryDeg - dAngRefDeg) < EPS_ANG_SMALL) {
|
||||
dAngDeg = dAngRefDeg ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
AdjustAngleInRange( double& dAngDeg, double dAngMinDeg, double dAngMaxDeg)
|
||||
{
|
||||
return AdjustAngleInSpan( dAngDeg, ( dAngMinDeg + dAngMaxDeg) / 2, dAngMaxDeg - dAngMinDeg) ;
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
#include "CurveComposite.h"
|
||||
#include "CreateCurveAux.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkArcCenTgCurvePnt.h"
|
||||
#include "/EgtDev/Include/EGkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EGkCircleCenTgCurve.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgkArcCenTgCurvePnt.h"
|
||||
#include "/EgtDev/Include/EgkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EgkCircleCenTgCurve.h"
|
||||
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
#include "CreateCurveAux.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkArcPntDirTgCurve.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EgkArcPntDirTgCurve.h"
|
||||
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
|
||||
|
||||
+35
-57
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2022
|
||||
// EgalTech 2014-2015
|
||||
//----------------------------------------------------------------------------
|
||||
// File : ArcSpecial.cpp Data : 18.08.22 Versione : 2.4h2
|
||||
// File : ArcSpecial.cpp Data : 15.03.15 Versione : 1.6c2
|
||||
// Contenuto : Implementazione funzioni per calcoli speciali archi.
|
||||
//
|
||||
//
|
||||
@@ -14,8 +14,8 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CreateCurveAux.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EgkCurveLine.h"
|
||||
#include "/EgtDev/Include/EgkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
@@ -28,13 +28,15 @@ ICurve*
|
||||
GetArc2PD( const Point3d& ptStart, const Point3d& ptEnd, double dDirStartDeg)
|
||||
{
|
||||
// creo l'oggetto arco
|
||||
PtrOwner<ICurveArc> pArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pArc))
|
||||
ICurveArc* pArc = CreateCurveArc() ;
|
||||
if ( pArc == nullptr)
|
||||
return nullptr ;
|
||||
// inizializzo il puntatore a curva con l'arco
|
||||
PtrOwner<ICurve> pCrv( pArc) ;
|
||||
|
||||
// calcolo l'arco, se ok lo restituisco ed esco
|
||||
if ( pArc->Set2PD( ptStart, ptEnd, dDirStartDeg))
|
||||
return Release( pArc) ;
|
||||
return Release( pCrv) ;
|
||||
|
||||
// calcolo arco non riuscito, verifico se retta va bene
|
||||
Vector3d vtDiff = ptEnd - ptStart ;
|
||||
@@ -43,12 +45,14 @@ GetArc2PD( const Point3d& ptStart, const Point3d& ptEnd, double dDirStartDeg)
|
||||
// verifico se i punti sono allineati con la direzione e nel giusto verso
|
||||
if ( abs( CrossXY( vtDiff, vtDir)) < EPS_SMALL && ScalarXY( vtDiff, vtDir) > EPS_SMALL) {
|
||||
// creo l'oggetto retta
|
||||
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
|
||||
if ( IsNull( pLine))
|
||||
ICurveLine* pLine = CreateCurveLine() ;
|
||||
if ( pLine == nullptr)
|
||||
return nullptr ;
|
||||
// inizializzo il puntatore a curva con la retta
|
||||
pCrv.Set( pLine) ;
|
||||
// calcolo retta, se ok la restituisco ed esco
|
||||
if ( pLine->Set( ptStart, ptEnd))
|
||||
return Release( pLine) ;
|
||||
return Release( pCrv) ;
|
||||
}
|
||||
|
||||
return nullptr ;
|
||||
@@ -61,25 +65,29 @@ ICurve*
|
||||
GetArc2PVN( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDirS, const Vector3d& vtN)
|
||||
{
|
||||
// creo l'oggetto arco
|
||||
PtrOwner<ICurveArc> pArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pArc))
|
||||
ICurveArc* pArc = CreateCurveArc() ;
|
||||
if ( pArc == nullptr)
|
||||
return nullptr ;
|
||||
// inizializzo il puntatore a curva con l'arco
|
||||
PtrOwner<ICurve> pCrv( pArc) ;
|
||||
|
||||
// calcolo l'arco, se ok lo restituisco ed esco
|
||||
if ( pArc->Set2PVN( ptStart, ptEnd, vtDirS, vtN))
|
||||
return Release( pArc) ;
|
||||
return Release( pCrv) ;
|
||||
|
||||
// calcolo arco non riuscito, verifico se retta va bene
|
||||
Vector3d vtDiff = ptEnd - ptStart ;
|
||||
// verifico se i punti sono allineati con la direzione e nel giusto verso nel piano perpendicolare a vtN
|
||||
if ( abs( ( vtDiff ^ vtDirS) * vtN) < EPS_SMALL && vtDiff * vtDirS > EPS_SMALL) {
|
||||
// creo l'oggetto retta
|
||||
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
|
||||
if ( IsNull( pLine))
|
||||
ICurveLine* pLine = CreateCurveLine() ;
|
||||
if ( pLine == nullptr)
|
||||
return nullptr ;
|
||||
// inizializzo il puntatore a curva con la retta
|
||||
pCrv.Set( pLine) ;
|
||||
// calcolo retta, se ok la restituisco ed esco
|
||||
if ( pLine->Set( ptStart, ptEnd))
|
||||
return Release( pLine) ;
|
||||
return Release( pCrv) ;
|
||||
}
|
||||
|
||||
return nullptr ;
|
||||
@@ -92,15 +100,17 @@ ICurve*
|
||||
GetArc3P( const Point3d& ptStart, const Point3d& ptOther, const Point3d& ptEnd, bool bCirc)
|
||||
{
|
||||
// creo l'oggetto arco
|
||||
PtrOwner<ICurveArc> pArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pArc))
|
||||
ICurveArc* pArc = CreateCurveArc() ;
|
||||
if ( pArc == nullptr)
|
||||
return nullptr ;
|
||||
// inizializzo il puntatore a curva con l'arco
|
||||
PtrOwner<ICurve> pCrv( pArc) ;
|
||||
|
||||
// calcolo l'arco, se ok lo restituisco ed esco
|
||||
if ( pArc->Set3P( ptStart, ptOther, ptEnd, bCirc))
|
||||
return Release( pArc) ;
|
||||
return Release( pCrv) ;
|
||||
|
||||
// se era richiesta una circonferenza, errore perchè punti allineati
|
||||
// se era richiesta una circonferenza, errore
|
||||
if ( bCirc)
|
||||
return nullptr ;
|
||||
|
||||
@@ -108,47 +118,15 @@ GetArc3P( const Point3d& ptStart, const Point3d& ptOther, const Point3d& ptEnd,
|
||||
// verifico se i punti sono allineati nel giusto verso
|
||||
if ( ( ptOther - ptStart) * ( ptEnd - ptOther) > EPS_ZERO) {
|
||||
// creo l'oggetto retta
|
||||
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
|
||||
if ( IsNull( pLine))
|
||||
ICurveLine* pLine = CreateCurveLine() ;
|
||||
if ( pLine == nullptr)
|
||||
return nullptr ;
|
||||
// inizializzo il puntatore a curva con la retta
|
||||
pCrv.Set( pLine) ;
|
||||
// calcolo retta, se ok la restituisco ed esco
|
||||
if ( pLine->Set( ptStart, ptEnd))
|
||||
return Release( pLine) ;
|
||||
return Release( pCrv) ;
|
||||
}
|
||||
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Come la CurveArc::SetC2PN, ma garantisce il passaggio per gli estremi e minimizza errore sul centro
|
||||
//----------------------------------------------------------------------------
|
||||
ICurveArc*
|
||||
GetArc2PCN( const Point3d& ptStart, const Point3d& ptEnd, const Point3d& ptNearCen, const Vector3d& vtN)
|
||||
{
|
||||
// creo l'oggetto arco
|
||||
PtrOwner<ICurveArc> pArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pArc))
|
||||
return nullptr ;
|
||||
|
||||
// vettori dal centro a inizio e fine
|
||||
Vector3d vtStart = ptStart - ptNearCen ;
|
||||
Vector3d vtEnd = ptEnd - ptNearCen ;
|
||||
|
||||
// determino il raggio medio
|
||||
double dStartRad = OrthoCompo( vtStart, vtN).Len() ;
|
||||
double dEndRad = OrthoCompo( vtEnd, vtN).Len() ;
|
||||
double dRad = ( dStartRad + dEndRad) / 2 ;
|
||||
if ( dRad < EPS_SMALL)
|
||||
return nullptr ;
|
||||
|
||||
// determino un valore approssimato dell'angolo al centro
|
||||
double dAngDeg ; bool bDet ;
|
||||
if ( ! vtStart.GetRotation( vtEnd, vtN, dAngDeg, bDet) || ! bDet || abs( dAngDeg) < EPS_ANG_ZERO)
|
||||
return nullptr ;
|
||||
|
||||
// calcolo l'arco antiorario per i due punti con il raggio medio
|
||||
if ( pArc->Set2PNRS( ptStart, ptEnd, vtN, dRad, ( dAngDeg > 0)))
|
||||
return Release( pArc) ;
|
||||
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
+3
-19
@@ -18,7 +18,7 @@
|
||||
#include "NgeReader.h"
|
||||
#include "GeomDB.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGnStringKeyVal.h"
|
||||
#include "/EgtDev/Include/EgnStringKeyVal.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -212,7 +212,7 @@ bool
|
||||
Attribs::SetName( const string& sName)
|
||||
{
|
||||
// se nome non valido, esco con errore
|
||||
if ( sName.empty() || ! IsValidVal( sName))
|
||||
if ( ! IsValidVal( sName))
|
||||
return false ;
|
||||
|
||||
// può essere solo la prima stringa
|
||||
@@ -282,7 +282,7 @@ bool
|
||||
Attribs::SetInfo( const string& sKey, const string& sVal)
|
||||
{
|
||||
// se chiave o valore non validi, esco con errore
|
||||
if ( ! IsValidKey( sKey) || sVal.empty() || ! IsValidVal( sVal))
|
||||
if ( ! IsValidKey( sKey) || ! IsValidVal( sVal))
|
||||
return false ;
|
||||
|
||||
// se è il nome
|
||||
@@ -356,22 +356,6 @@ Attribs::RemoveInfo( const string& sKey)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Attribs::GetAllInfo( STRVECTOR& vsInfo) const
|
||||
{
|
||||
// riservo spazio opportuno per il vettore delle stringhe
|
||||
vsInfo.clear() ;
|
||||
vsInfo.reserve( m_slInfo.size()) ;
|
||||
// recupero tutte le info tranne il nome (se presente sempre al primo posto)
|
||||
auto iIter = m_slInfo.cbegin() ;
|
||||
if ( FindKey( *iIter, NAME))
|
||||
++ iIter ;
|
||||
for ( ; iIter != m_slInfo.cend() ; ++ iIter)
|
||||
vsInfo.emplace_back( *iIter) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Attribs::CopyAllInfoFrom( const Attribs& attrSou)
|
||||
|
||||
@@ -89,7 +89,6 @@ class Attribs
|
||||
bool GetInfo( const std::string& sKey, std::string& sVal) const ;
|
||||
bool ExistsInfo( const std::string& sKey) const ;
|
||||
bool RemoveInfo( const std::string& sKey) ;
|
||||
bool GetAllInfo( STRVECTOR& vsInfo) const ;
|
||||
bool CopyAllInfoFrom( const Attribs& attrSou) ;
|
||||
|
||||
private :
|
||||
@@ -101,7 +100,7 @@ class Attribs
|
||||
private :
|
||||
unsigned char m_Data[DIM] ;
|
||||
unsigned char m_OldData[DIM] ;
|
||||
int m_Material ;
|
||||
Color m_Color ;
|
||||
STRLIST m_slInfo ;
|
||||
int m_Material ;
|
||||
Color m_Color ;
|
||||
STRLIST m_slInfo ;
|
||||
} ;
|
||||
+4
-31
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2022
|
||||
// EgalTech 2013-2013
|
||||
//----------------------------------------------------------------------------
|
||||
// File : BBox3d.cpp Data : 17.08.22 Versione : 2.4h1
|
||||
// File : BBox3d.cpp Data : 14.01.14 Versione : 1.5a3
|
||||
// Contenuto : Implementazione della classe axis aligned bounding box BBox3d.
|
||||
//
|
||||
//
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "/EgtDev/Include/EGkBBox3d.h"
|
||||
#include "/EgtDev/Include/EGkFrame3d.h"
|
||||
#include "\EgtDev\Include\EGkBBox3d.h"
|
||||
#include "\EgtDev\Include\EGkFrame3d.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
@@ -210,33 +210,6 @@ BBox3d::GetMinDim( Point3d& ptMin, double& dDimX, double& dDimY, double& dDimZ)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double
|
||||
BBox3d::GetDimX( void) const
|
||||
{
|
||||
if ( ! IsValid())
|
||||
return 0 ;
|
||||
return ( m_ptMax.x - m_ptMin.x) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double
|
||||
BBox3d::GetDimY( void) const
|
||||
{
|
||||
if ( ! IsValid())
|
||||
return 0 ;
|
||||
return ( m_ptMax.y - m_ptMin.y) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double
|
||||
BBox3d::GetDimZ( void) const
|
||||
{
|
||||
if ( ! IsValid())
|
||||
return 0 ;
|
||||
return ( m_ptMax.z - m_ptMin.z) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
BBox3d::GetCenterExtent( Point3d& ptCenter, Vector3d& vtExtent) const
|
||||
|
||||
+3
-3
@@ -16,9 +16,9 @@
|
||||
#include "BiArcs.h"
|
||||
#include "CurveArc.h"
|
||||
#include "/EgtDev/Include/EGkAngle.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EgkCurveLine.h"
|
||||
#include "/EgtDev/Include/EgkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EgkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkBiArcs.h"
|
||||
#include "/EgtDev/Include/EgkBiArcs.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
ICurve* GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir1Deg,
|
||||
|
||||
@@ -27,10 +27,9 @@ CDeBoxClosedSurfTm( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDi
|
||||
BBox3d b3Poly = Stm.GetAllTriaBox() ;
|
||||
// calcolo il BBox del parallelepipedo
|
||||
BBox3d b3Box( ORIG, ORIG + vtDiag) ;
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3Box.Expand( dSafeDist) ;
|
||||
b3Box.Expand( dSafeDist) ;
|
||||
b3Box.ToGlob( frBox) ;
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
// confronto i due Box
|
||||
if ( ! b3Box.Overlaps( b3Poly))
|
||||
return false ;
|
||||
// recupero i triangoli che interferiscono con il box
|
||||
@@ -47,9 +46,9 @@ CDeBoxClosedSurfTm( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDi
|
||||
if ( ! Stm.IsClosed())
|
||||
return false ;
|
||||
// Verifico se il box è dentro la superficie tramite calcolo distanza minima.
|
||||
Point3d ptBoxCen = ORIG + vtDiag / 2 ;
|
||||
ptBoxCen.ToGlob( frBox) ;
|
||||
DistPointSurfTm DistBoxCenSurfCalc( ptBoxCen, Stm) ;
|
||||
Point3d ptBoxOrig, ptBoxMax ;
|
||||
b3Box.GetMinMax( ptBoxOrig, ptBoxMax) ;
|
||||
DistPointSurfTm DistBoxOrigSurfCalc( ptBoxOrig, Stm) ;
|
||||
// Se il box è interno c'è collisione
|
||||
return DistBoxCenSurfCalc.IsPointInside() ;
|
||||
return DistBoxOrigSurfCalc.IsPointInside() ;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "CDeBoxTria.h"
|
||||
#include "CDeSpheTria.h"
|
||||
#include "CDeCylTria.h"
|
||||
#include "CDeCapsTria.h"
|
||||
#include "/EgtDev/Include/EGkPlane3d.h"
|
||||
|
||||
using namespace std ;
|
||||
@@ -100,17 +99,9 @@ CDeSimpleBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, const Triangle3d
|
||||
Triangle3d trTriaL = trTria ;
|
||||
trTriaL.ToLoc( frBox) ;
|
||||
|
||||
// Calcolo il box locale del triangolo
|
||||
BBox3d b3TriaL ;
|
||||
trTriaL.GetLocalBBox( b3TriaL) ;
|
||||
|
||||
// Calcolo il box come tale
|
||||
BBox3d b3Box( ORIG, ORIG + vtDiag) ;
|
||||
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
if ( ! b3Box.Overlaps( b3TriaL))
|
||||
return false ;
|
||||
|
||||
// Compute box center and extents
|
||||
Point3d ptCen ;
|
||||
Vector3d vtExt ;
|
||||
@@ -197,7 +188,6 @@ CDeBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist, cons
|
||||
if ( CDeSimpleBoxTria( frTmp, vtDiag + 2 * dSafeDist * Z_AX, trTriaL))
|
||||
return true ;
|
||||
|
||||
#if 1
|
||||
// Sfere centrate negli otto vertici
|
||||
if ( CDeSimpleSpheTria( Point3d( 0, 0, 0), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
@@ -253,33 +243,6 @@ CDeBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist, cons
|
||||
frTmp.Set( Point3d( 0., vtDiag.y, 0.), Z_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.z, trTriaL))
|
||||
return true ;
|
||||
#else
|
||||
// Capsule centrati sui dodici spigoli
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, 0, 0), Point3d( vtDiag.x, 0, 0), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, vtDiag.y, 0), Point3d( vtDiag.x, vtDiag.y, 0), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, 0, 0), Point3d( 0, vtDiag.y, 0), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleCapsTria( Point3d( vtDiag.x, 0, 0), Point3d( vtDiag.x, vtDiag.y, 0), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, 0, vtDiag.z), Point3d( vtDiag.x, 0, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, vtDiag.y, vtDiag.z), Point3d( vtDiag.x, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, 0, vtDiag.z), Point3d( 0, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleCapsTria( Point3d( vtDiag.x, 0, vtDiag.z), Point3d( vtDiag.x, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, 0, 0), Point3d( 0, 0, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleCapsTria( Point3d( vtDiag.x, 0, 0), Point3d( vtDiag.x, 0, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleCapsTria( Point3d( vtDiag.x, vtDiag.y, 0), Point3d( vtDiag.x, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, vtDiag.y, 0), Point3d( 0, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
#endif
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2022-2022
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CDeCapsTria.cpp Data : 14.05.22 Versione : 2.4e2
|
||||
// Contenuto : Implementazione della verifica di collisione tra
|
||||
// Capsule (cilindro con estremità semisferiche) e Triangle3d.
|
||||
//
|
||||
//
|
||||
// Modifiche :14.05.22 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CDeCapsTria.h"
|
||||
#include "CDeSpheTria.h"
|
||||
#include "ProjPlane.h"
|
||||
#include "/EgtDev/Include/EGkPolygon3d.h"
|
||||
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
||||
#include "/EgtDev/Include/EGkDistPointTria.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSphere.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CDeSimpleCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, const Triangle3d& trTria)
|
||||
{
|
||||
// vedi Ericson, Real-Time Collision Detection, pag. 226 (Nettle method)
|
||||
|
||||
// Dati della capsule come sfera che si muove
|
||||
Point3d ptC = ptP1 ;
|
||||
Vector3d vtDir = ptP2 - ptP1 ;
|
||||
double dLen = vtDir.Len() ;
|
||||
if ( dLen < EPS_SMALL)
|
||||
return CDeSimpleSpheTria( Media( ptP1, ptP2), dR, trTria) ;
|
||||
vtDir /= dLen ;
|
||||
if ( vtDir * trTria.GetN() > 0) {
|
||||
vtDir.Invert() ;
|
||||
ptC = ptP2 ;
|
||||
}
|
||||
// Determinazione primo possibile punto di contatto della sfera con il piano
|
||||
Point3d ptD = ptC - trTria.GetN() * dR ;
|
||||
// Intersezione della linea di movimento di questo punto con il piano del triangolo
|
||||
Point3d ptP ;
|
||||
int nLpRes = IntersLinePlane( ptD, vtDir, 1, trTria.GetPlane(), ptP, false) ;
|
||||
// Se non c'è intersezione passante
|
||||
if ( nLpRes != ILPT_YES) {
|
||||
// se il centro dista dal piano non meno del raggio, allora non c'è sicuramente collisione
|
||||
double dDist = DistPointPlane( ptP, trTria.GetPlane()) ;
|
||||
if ( abs( dDist) >= dR)
|
||||
return false ;
|
||||
// !!! DA FARE !!!!
|
||||
// si deve intersecare l'asse del capsule con i cilindri centrati sui lati del triangolo
|
||||
// se intersezione inferiore a dLen allora collisione
|
||||
// altrimenti si deve intersecare l'asse del capsule con le sfere centrate sui vertici del triangolo
|
||||
// se intersezione inferiore a dLen allora collisione
|
||||
// per ora salto
|
||||
return false ;
|
||||
}
|
||||
// Determino la posizione dell'intersezione rispetto al triangolo
|
||||
DistPointTriangle dptDist( ptP, trTria) ;
|
||||
// Se l'intersezione sta nel triangolo
|
||||
double dSqDist ;
|
||||
if ( dptDist.GetSqDist( dSqDist) && dSqDist < 4 * SQ_EPS_SMALL) {
|
||||
double dPos = ( ptP - ptD) * vtDir ;
|
||||
return ( dPos > -dR && dPos < dLen) ;
|
||||
}
|
||||
// Altrimenti, recupero il punto del triangolo più vicino all'intersezione
|
||||
Point3d ptQ ;
|
||||
if ( dptDist.GetMinDistPoint( ptQ)) {
|
||||
Point3d ptI1, ptI2 ;
|
||||
int nLsRes = IntersLineSphere( ptQ, -vtDir, ptC, dR, ptI1, ptI2) ;
|
||||
if ( nLsRes != ILST_SEC)
|
||||
return false ;
|
||||
double dPos = ( ptQ - ptI1) * vtDir ;
|
||||
return ( dPos > -dR && dPos < dLen) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CDeCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, double dSafeDist, const Triangle3d& trTria)
|
||||
{
|
||||
return CDeSimpleCapsTria( ptP1, ptP2, dR + max( 0., dSafeDist), trTria) ;
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2022-2022
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EGkCDeCapsTria.h Data : 14.05.22 Versione : 2.4e2
|
||||
// Contenuto : Dichiarazione funzione verifica collisione tra
|
||||
// Capsule (cilindro con estremità semisferiche) e Triangle3d.
|
||||
//
|
||||
// Modifiche : 14.05.22 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkTriangle3d.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool CDeSimpleCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, const Triangle3d& trTria) ;
|
||||
bool CDeCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, double dSafeDist, const Triangle3d& trTria) ;
|
||||
@@ -20,7 +20,7 @@
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Il sistema di riferimento deve avere l'asse di simmetria del cono come asse Z e origine nel centro della base.
|
||||
// Il sisitema di riferimento deve avere l'asse di simmetria del cono come asse Z e origine nel centro della base.
|
||||
// La distanza di sicurezza ha effetto solo se maggiore di epsilon, altrimenti è ignorata ed è ininfluente.
|
||||
// Il sistema di riferimento del cono deve essere immerso in quello della superficie.
|
||||
bool
|
||||
@@ -35,10 +35,10 @@ CDeConeFrustumClosedSurfTm( const Frame3d& frCone, double dBaseRad, double dTopR
|
||||
// Calcolo il BBox del tronco di cono
|
||||
double dMaxRad = max( dBaseRad, dTopRad) ;
|
||||
BBox3d b3Cone( - dMaxRad, - dMaxRad, 0, dMaxRad, dMaxRad, dHeight) ;
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3Cone.Expand( dSafeDist) ;
|
||||
b3Cone.Expand( dSafeDist) ;
|
||||
// Porto BBox del cono nel sistema della superficie.
|
||||
b3Cone.ToGlob( frCone) ;
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
// Se i BBox non interferiscono, ho finito.
|
||||
if ( ! b3Cone.Overlaps( b3Surf))
|
||||
return false ;
|
||||
// Recupero i triangoli che interferiscono con il box del cono
|
||||
@@ -56,9 +56,9 @@ CDeConeFrustumClosedSurfTm( const Frame3d& frCone, double dBaseRad, double dTopR
|
||||
if ( ! Stm.IsClosed())
|
||||
return false ;
|
||||
// Verifico se il tronco di cono è dentro la superficie tramite calcolo distanza minima.
|
||||
Point3d ptConeCen( 0, 0, dHeight / 2) ;
|
||||
ptConeCen.ToGlob( frCone) ;
|
||||
DistPointSurfTm DistConeCenSurfCalc( ptConeCen, Stm) ;
|
||||
Point3d ptConeOrig ;
|
||||
ptConeOrig.ToGlob( frCone) ;
|
||||
DistPointSurfTm DistConeOrigSurfCalc( ptConeOrig, Stm) ;
|
||||
// Se il tronco di cono è interno c'è collisione
|
||||
return DistConeCenSurfCalc.IsPointInside() ;
|
||||
return DistConeOrigSurfCalc.IsPointInside() ;
|
||||
}
|
||||
@@ -33,10 +33,9 @@ CDeCylClosedSurfTm( const Frame3d& frCyl, double dR, double dH, double dSafeDist
|
||||
}
|
||||
// calcolo il BBox del cilindro
|
||||
BBox3d b3Cyl( -dR, -dR, 0, dR, dR, dH) ;
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3Cyl.Expand( dSafeDist) ;
|
||||
b3Cyl.Expand( dSafeDist) ;
|
||||
b3Cyl.ToGlob( frC) ;
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
// confronto i due Box
|
||||
if ( ! b3Cyl.Overlaps( b3Poly))
|
||||
return false ;
|
||||
// recupero i triangoli che interferiscono con il box del Cilindro
|
||||
@@ -53,9 +52,9 @@ CDeCylClosedSurfTm( const Frame3d& frCyl, double dR, double dH, double dSafeDist
|
||||
if ( ! Stm.IsClosed())
|
||||
return false ;
|
||||
// Verifico se il cilindro è dentro la superficie tramite calcolo distanza minima.
|
||||
Point3d ptCylCen( 0, 0, dH / 2) ;
|
||||
ptCylCen.ToGlob( frC) ;
|
||||
DistPointSurfTm DistCylCenSurfCalc( ptCylCen, Stm) ;
|
||||
Point3d ptCylOrig( 0., 0., - dSafeDist) ;
|
||||
ptCylOrig.ToGlob( frC) ;
|
||||
DistPointSurfTm DistCylOrigSurfCalc( ptCylOrig, Stm) ;
|
||||
// Se il cilindro è interno c'è collisione
|
||||
return ( DistCylCenSurfCalc.IsPointInside()) ;
|
||||
return ( DistCylOrigSurfCalc.IsPointInside()) ;
|
||||
}
|
||||
|
||||
@@ -38,8 +38,11 @@ CDeRectPrismoidClosedSurfTm( const Frame3d& frPrismoid, double dLenghtBaseX, dou
|
||||
double dMaxLenX = max( dLenghtBaseX, dLenghtTopX) ;
|
||||
double dMaxLenY = max( dLenghtBaseY, dLenghtTopY) ;
|
||||
BBox3d b3Pyr( -dMaxLenX / 2, -dMaxLenY / 2, 0., dMaxLenX / 2, dMaxLenY / 2, dHeight) ;
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
// Se la distanza di sicurezza è maggiore di epsilon aumento le dimensioni del tronco di piramide.
|
||||
if ( dSafeDist > EPS_SMALL) {
|
||||
b3Pyr.Expand( dSafeDist) ;
|
||||
}
|
||||
// Porto BBox del tronco di piramide nel sistema della superficie.
|
||||
b3Pyr.ToGlob( frPrismoid) ;
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
if ( ! b3Pyr.Overlaps( b3Surf))
|
||||
@@ -60,9 +63,8 @@ CDeRectPrismoidClosedSurfTm( const Frame3d& frPrismoid, double dLenghtBaseX, dou
|
||||
if ( ! Stm.IsClosed())
|
||||
return false ;
|
||||
// Verifico se il tronco di piramide è dentro la superficie tramite calcolo distanza minima.
|
||||
Point3d ptPyrCen( 0, 0, dHeight / 2) ;
|
||||
ptPyrCen.ToGlob( frPrismoid) ;
|
||||
DistPointSurfTm DistPyrCenSurfCalc( ptPyrCen, Stm) ;
|
||||
Point3d ptPyrOrig = frPrismoid.Orig() ;
|
||||
DistPointSurfTm DistBoxOrigSurfCalc( ptPyrOrig, Stm) ;
|
||||
// C'è collisione se il tronco di piramide è interno.
|
||||
return ( DistPyrCenSurfCalc.IsPointInside()) ;
|
||||
return ( DistBoxOrigSurfCalc.IsPointInside()) ;
|
||||
}
|
||||
|
||||
@@ -27,9 +27,8 @@ CDeSpheClosedSurfTm( const Point3d& ptCen, double dR, double dSafeDist, const IS
|
||||
BBox3d b3Poly = Stm.GetAllTriaBox() ;
|
||||
// calcolo il BBox della sfera
|
||||
BBox3d b3Sphe( ptCen, dR) ;
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3Sphe.Expand( dSafeDist) ;
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
b3Sphe.Expand( dSafeDist) ;
|
||||
// confronto i due Box
|
||||
if ( ! b3Sphe.Overlaps( b3Poly))
|
||||
return false ;
|
||||
// recupero i triangoli che interferiscono con il box della Sfera
|
||||
|
||||
+5
-5
@@ -109,7 +109,7 @@ CDeTriaTria( const Triangle3d& trTriaA, const Triangle3d& trTriaB)
|
||||
DistLineLine LineLineDistCalc( ptStA, PtEnA, ptStB, PtEnB) ;
|
||||
double dSqSegSegDist ;
|
||||
LineLineDistCalc.GetSqDist( dSqSegSegDist) ;
|
||||
if ( dSqSegSegDist < SQ_EPS_SMALL)
|
||||
if ( dSqSegSegDist < EPS_SMALL * EPS_SMALL)
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
@@ -136,14 +136,14 @@ CDeTriaTria( const Triangle3d& trTriaA, const Triangle3d& trTriaB)
|
||||
vtSegFirstA /= dSegLenFirstA ;
|
||||
DistLineLine LineLineDistCalcFirstA( ptLineP, vtLineV, 100., trTriaA.GetP( nFirstMaxPosA), vtSegFirstA, dSegLenFirstA, false) ;
|
||||
double dIntParStA, dOtherParFirstA ;
|
||||
LineLineDistCalcFirstA.GetPositionsAtMinDistPoints( dIntParStA, dOtherParFirstA) ;
|
||||
LineLineDistCalcFirstA.GetParamsAtMinDistPoints( dIntParStA, dOtherParFirstA) ;
|
||||
// Limito la retta col secondo segmento trovato di A
|
||||
Vector3d vtSegSecondA = trTriaA.GetP( ( nSecondMaxPosA + 1) % 3) - trTriaA.GetP( nSecondMaxPosA) ;
|
||||
double dSegLenSecondA = vtSegSecondA.Len() ;
|
||||
vtSegSecondA /= dSegLenSecondA ;
|
||||
DistLineLine LineLineDistCalcSecondA( ptLineP, vtLineV, 100., trTriaA.GetP( nSecondMaxPosA), vtSegSecondA, dSegLenSecondA, false) ;
|
||||
double dIntParEnA, dOtherParSecondA ;
|
||||
LineLineDistCalcSecondA.GetPositionsAtMinDistPoints( dIntParEnA, dOtherParSecondA) ;
|
||||
LineLineDistCalcSecondA.GetParamsAtMinDistPoints( dIntParEnA, dOtherParSecondA) ;
|
||||
// Ordino i parametri lungo la retta di intersezione fra i piani
|
||||
if ( dIntParStA > dIntParEnA) {
|
||||
swap( dIntParStA, dIntParEnA) ;
|
||||
@@ -163,14 +163,14 @@ CDeTriaTria( const Triangle3d& trTriaA, const Triangle3d& trTriaB)
|
||||
vtSegFirstB /= dSegLenFirstB ;
|
||||
DistLineLine LineLineDistCalcFirstB( ptLineP, vtLineV, 100., trTriaB.GetP( nFirstMaxPosB), vtSegFirstB, dSegLenFirstB, false) ;
|
||||
double dIntParStB, dOtherParFirstB ;
|
||||
LineLineDistCalcFirstB.GetPositionsAtMinDistPoints( dIntParStB, dOtherParFirstB) ;
|
||||
LineLineDistCalcFirstB.GetParamsAtMinDistPoints( dIntParStB, dOtherParFirstB) ;
|
||||
// Limito la retta col secondo segmento trovato di B
|
||||
Vector3d vtSegSecondB = trTriaB.GetP( ( nSecondMaxPosB + 1) % 3) - trTriaB.GetP( nSecondMaxPosB) ;
|
||||
double dSegLenSecondB = vtSegSecondB.Len() ;
|
||||
vtSegSecondB /= dSegLenSecondB ;
|
||||
DistLineLine LineLineDistCalcSecondB( ptLineP, vtLineV, 100., trTriaB.GetP( nSecondMaxPosA), vtSegSecondB, dSegLenSecondB, false) ;
|
||||
double dIntParEnB, dOtherParSecondB ;
|
||||
LineLineDistCalcSecondB.GetPositionsAtMinDistPoints( dIntParEnB, dOtherParSecondB) ;
|
||||
LineLineDistCalcSecondB.GetParamsAtMinDistPoints( dIntParEnB, dOtherParSecondB) ;
|
||||
// Ordino i parametri lungo la retta di intersezione fra i piani
|
||||
if ( dIntParStB > dIntParEnB) {
|
||||
swap( dIntParStB, dIntParEnB) ;
|
||||
|
||||
+3
-3
@@ -13,9 +13,9 @@
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "/EgtDev/Include/EGkChainCurves.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EgkChainCurves.h"
|
||||
#include "/EgtDev/Include/EgkGeomDB.h"
|
||||
#include "/EgtDev/Include/EgkCurve.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2022-2022
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Circle2P.cpp Data : 18.08.22 Versione : 2.4h2
|
||||
// Contenuto : Implementazione funzioni per calcolo circonferenze per 2 punti
|
||||
// diametrali.
|
||||
//
|
||||
//
|
||||
// Modifiche : 18.08.22 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CurveArc.h"
|
||||
#include "/EgtDev/Include/EGkCircle2P.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurveArc*
|
||||
GetCircle2P( const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtN)
|
||||
{
|
||||
// Verifico che i due punti siano distinti
|
||||
if ( AreSamePointEpsilon( ptP1, ptP2, EPS_SMALL))
|
||||
return nullptr ;
|
||||
// verifico che la normale non sia allineata con i punti
|
||||
Vector3d vtO = OrthoCompo( vtN, ptP2 - ptP1) ;
|
||||
if ( ! vtO.Normalize())
|
||||
return nullptr ;
|
||||
|
||||
// Creo l'oggetto arco
|
||||
PtrOwner<CurveArc> pCrvArc( CreateBasicCurveArc()) ;
|
||||
if ( IsNull( pCrvArc))
|
||||
return nullptr ;
|
||||
|
||||
// Eseguo calcoli
|
||||
if ( ! pCrvArc->SetCPAN( Media( ptP1, ptP2), ptP1, ANG_FULL, 0, vtO))
|
||||
return nullptr ;
|
||||
|
||||
return Release( pCrvArc) ;
|
||||
}
|
||||
@@ -18,8 +18,8 @@
|
||||
#include "CreateCurveAux.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkCircleCenTgCurve.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgkCircleCenTgCurve.h"
|
||||
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "/EgtDev/Include/EGkColor.h"
|
||||
#include "/EgtDev/Include/EGkAngle.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EGtNumUtils.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
+53
-132
@@ -59,10 +59,8 @@ class ArcApproxer
|
||||
//----------------------------------------------------------------------------
|
||||
CurveArc::CurveArc( void)
|
||||
: m_nStatus( TO_VERIFY), m_PtCen(), m_VtN(), m_VtS(), m_dRad(),
|
||||
m_dAngCenDeg(), m_dDeltaN(), m_VtExtr(), m_dThick()
|
||||
m_dAngCenDeg(), m_dDeltaN(), m_VtExtr(), m_dThick(), m_nTempProp()
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -580,8 +578,7 @@ CurveArc::CopyFrom( const CurveArc& caSrc)
|
||||
return true ;
|
||||
m_VtExtr = caSrc.m_VtExtr ;
|
||||
m_dThick = caSrc.m_dThick ;
|
||||
m_nTempProp[0] = caSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = caSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = caSrc.m_nTempProp ;
|
||||
return Set( caSrc.m_PtCen, caSrc.m_VtN, caSrc.m_dRad,
|
||||
caSrc.m_VtS, caSrc.m_dAngCenDeg, caSrc.m_dDeltaN) ;
|
||||
}
|
||||
@@ -699,9 +696,29 @@ CurveArc::Load( NgeReader& ngeIn)
|
||||
bool
|
||||
CurveArc::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
|
||||
{
|
||||
// richiamo della funzione generale
|
||||
return GetBBox( GLOB_FRM, b3Loc, nFlag) ;
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// assegno il box in locale
|
||||
b3Loc.Reset() ;
|
||||
double dLinTol = LIN_TOL_APPROX ;
|
||||
double dAngTolDeg = ANG_TOL_APPROX_DEG ;
|
||||
if ( ( nFlag & BBF_EXACT) != 0)
|
||||
dLinTol = LIN_TOL_MIN ;
|
||||
ArcApproxer aAppr( dLinTol, dAngTolDeg, false, *this) ;
|
||||
double dU ;
|
||||
Point3d ptPos ;
|
||||
while ( aAppr.GetPoint( dU, ptPos))
|
||||
b3Loc.Add( ptPos) ;
|
||||
// se c'è estrusione, devo tenerne conto
|
||||
if ( ! m_VtExtr.IsSmall() && abs( m_dThick) > EPS_SMALL) {
|
||||
Point3d ptMinExtr = b3Loc.GetMin() + m_VtExtr * m_dThick ;
|
||||
Point3d ptMaxExtr = b3Loc.GetMax() + m_VtExtr * m_dThick ;
|
||||
b3Loc.Add( ptMinExtr) ;
|
||||
b3Loc.Add( ptMaxExtr) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -716,102 +733,6 @@ CurveArc::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
||||
return false ;
|
||||
// assegno il box nel riferimento
|
||||
b3Ref.Reset() ;
|
||||
|
||||
// ricavo il Frame3D solidale all'arco
|
||||
Frame3d frArc; frArc.Set( m_PtCen, m_dAngCenDeg > 0 ? m_VtN : - m_VtN, m_VtS) ;
|
||||
|
||||
// cordinate nel FrRef dei versori del sistema di riferimento dell'arco
|
||||
Vector3d a = frArc.VersX() ;
|
||||
a.ToGlob( frRef) ;
|
||||
double ax = a.x ;
|
||||
double ay = a.y ;
|
||||
double az = a.z ;
|
||||
|
||||
Vector3d b = frArc.VersY() ;
|
||||
b.ToGlob( frRef) ;
|
||||
double bx = b.x ;
|
||||
double by = b.y ;
|
||||
double bz = b.z ;
|
||||
|
||||
Vector3d c = frArc.VersZ() ;
|
||||
c.ToGlob( frRef) ;
|
||||
double nx = c.x ;
|
||||
double ny = c.y ;
|
||||
double nz = c.z ;
|
||||
|
||||
// vettore degli angoli e dei punti di estremi
|
||||
PNTVECTOR vPoints ;
|
||||
DBLVECTOR vdTheta ;
|
||||
|
||||
// il punto iniziale e finale sono punti candidati per estremanti
|
||||
Point3d ptS, ptE ;
|
||||
GetPointD1D2( 0, FROM_PLUS, ptS) ; if ( ! abs( m_dAngCenDeg - 360) < EPS_SMALL) { GetPointD1D2( 1, FROM_MINUS, ptE) ; }
|
||||
vPoints.push_back( ptS) ; if ( ! abs( m_dAngCenDeg - 360) < EPS_SMALL) { vPoints.push_back( ptE) ; }
|
||||
|
||||
// angolo al centro, raggio e parametro Q
|
||||
double dAngCenRad = m_dAngCenDeg * DEGTORAD ;
|
||||
ptE.ToLoc( frArc) ; ptS.ToLoc( frArc) ;
|
||||
double Q = ( ptE.z - ptS.z) / abs( dAngCenRad) ;
|
||||
double dRad = m_dRad ;
|
||||
|
||||
if ( abs( Q) < EPS_SMALL) {
|
||||
if ( abs( ax) > EPS_SMALL) {
|
||||
vdTheta.push_back( atan( bx / ax)) ;
|
||||
vdTheta.push_back( vdTheta.back() > 0 ? vdTheta.back() + PIGRECO : vdTheta.back() - PIGRECO) ;
|
||||
}
|
||||
if ( abs( ay) > EPS_SMALL) {
|
||||
vdTheta.push_back( atan( by / ay)) ;
|
||||
vdTheta.push_back( vdTheta.back() > 0 ? vdTheta.back() + PIGRECO : vdTheta.back() - PIGRECO) ;
|
||||
}
|
||||
if ( abs( az) > EPS_SMALL) {
|
||||
vdTheta.push_back( atan( bz / az)) ;
|
||||
vdTheta.push_back( vdTheta.back() > 0 ? vdTheta.back() + PIGRECO : vdTheta.back() - PIGRECO) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
vector<double> Va ; Va.push_back( ax) ; Va.push_back( ay) ; Va.push_back( az) ;
|
||||
vector<double> Vb ; Vb.push_back( bx) ; Vb.push_back( by) ; Vb.push_back( bz) ;
|
||||
vector<double> Vn ; Vn.push_back( nx) ; Vn.push_back( ny) ; Vn.push_back( nz) ;
|
||||
|
||||
for ( int i = 0 ; i < 3 ; i++) {
|
||||
double delta = dRad * dRad * Va[i] * Va[i] - Q * Q * Vn[i] * Vn[i] + Vb[i] * Vb[i] * dRad * dRad ;
|
||||
if ( delta > 0) {
|
||||
double t1 = ( dRad * Va[i] + sqrt( delta)) / ( Q * Vn[i] - dRad * Vb[i]) ;
|
||||
if ( abs( 1 - t1 * t1) > EPS_SMALL) {
|
||||
vdTheta.push_back( atan( 2 * t1 / (1 - t1 * t1))) ;
|
||||
vdTheta.push_back(vdTheta.back() > 0 ? vdTheta.back() + PIGRECO : vdTheta.back() - PIGRECO);
|
||||
}
|
||||
double t2 = ( dRad * Va[i] - sqrt( delta)) / ( Q * Vn[i] - dRad * Vb[i]) ;
|
||||
if ( abs( 1 - t2 * t2) > EPS_SMALL){
|
||||
vdTheta.push_back( atan( 2 * t2 / ( 1 - t2 * t2))) ;
|
||||
vdTheta.push_back( vdTheta.back() > 0 ? vdTheta.back() + PIGRECO : vdTheta.back() - PIGRECO) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vdTheta.push_back( PIGRECO) ;
|
||||
vdTheta.push_back( PIGRECO / 2) ;
|
||||
vdTheta.push_back( 3 * PIGRECO / 2) ;
|
||||
|
||||
for ( int i = 0 ; i < vdTheta.size() ; i++) {
|
||||
double dTheta = vdTheta[i] > 0 ? vdTheta[i] : 2 * PIGRECO + vdTheta[i] ;
|
||||
if ( dTheta < abs( dAngCenRad)) {
|
||||
Point3d pt ;
|
||||
GetPointD1D2( dTheta / ( abs( dAngCenRad)), FROM_MINUS, pt) ;
|
||||
vPoints.push_back( pt) ;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < vPoints.size(); i++) {
|
||||
vPoints[i].ToGlob( frRef) ;
|
||||
b3Ref.Add( vPoints[i]) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
|
||||
/*
|
||||
double dLinTol = LIN_TOL_APPROX ;
|
||||
double dAngTolDeg = ANG_TOL_APPROX_DEG ;
|
||||
if ( ( nFlag & BBF_EXACT) != 0)
|
||||
@@ -823,9 +744,6 @@ CurveArc::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
||||
ptPos.ToGlob( frRef) ;
|
||||
b3Ref.Add( ptPos) ;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
// se c'è estrusione, devo tenerne conto
|
||||
if ( ! m_VtExtr.IsSmall() && abs( m_dThick) > EPS_SMALL) {
|
||||
Vector3d vtFrExtr = m_VtExtr ;
|
||||
@@ -910,7 +828,7 @@ CurveArc::GetEndPoint( Point3d& ptEnd) const
|
||||
double dAng = m_dAngCenDeg * DEGTORAD ;
|
||||
Vector3d vtDir = cos( dAng) * m_VtS + sin( dAng) * ( m_VtN ^ m_VtS) ;
|
||||
ptEnd = m_PtCen + m_dRad * vtDir ;
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
ptEnd += m_dDeltaN * m_VtN ;
|
||||
|
||||
return true ;
|
||||
@@ -928,7 +846,7 @@ CurveArc::GetMidPoint( Point3d& ptMid) const
|
||||
double dAng = 0.5 * m_dAngCenDeg * DEGTORAD ;
|
||||
Vector3d vtDir = cos( dAng) * m_VtS + sin( dAng) * ( m_VtN ^ m_VtS) ;
|
||||
ptMid = m_PtCen + m_dRad * vtDir ;
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
ptMid += ( 0.5 * m_dDeltaN) * m_VtN ;
|
||||
|
||||
return true ;
|
||||
@@ -956,7 +874,7 @@ CurveArc::GetCentroid( Point3d& ptCen) const
|
||||
return false ;
|
||||
// approssimo la curva con una polilinea
|
||||
PolyLine PL ;
|
||||
if ( ! ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, APL_STD, PL))
|
||||
if ( ! ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
||||
return false ;
|
||||
// calcolo il centro mediante PolygonPlane
|
||||
Point3d ptP ;
|
||||
@@ -988,7 +906,7 @@ CurveArc::GetDir( double dU, Vector3d& vtDir) const
|
||||
Vector3d vtRad = cos( dAng) * m_VtS + sin( dAng) * ( m_VtN ^ m_VtS) ;
|
||||
// calcolo della tangente nel punto finale
|
||||
vtDir = ( m_dRad * m_dAngCenDeg * DEGTORAD) * ( m_VtN ^ vtRad) ;
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
vtDir += m_dDeltaN * m_VtN ;
|
||||
// normalizzo
|
||||
return vtDir.Normalize( EPS_ZERO) ;
|
||||
@@ -1014,13 +932,13 @@ CurveArc::GetPointD1D2( double dU, Side nS, Point3d& ptPos, Vector3d* pvtDer1, V
|
||||
|
||||
// calcolo del punto
|
||||
ptPos = m_PtCen + m_dRad * vtDir ;
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
ptPos += ( dU * m_dDeltaN) * m_VtN ;
|
||||
|
||||
// calcolo della derivata prima
|
||||
if ( pvtDer1 != nullptr) {
|
||||
*pvtDer1 = ( m_dRad * m_dAngCenDeg * DEGTORAD) * ( m_VtN ^ vtDir) ;
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
*pvtDer1 += m_dDeltaN * m_VtN ;
|
||||
}
|
||||
|
||||
@@ -1042,7 +960,7 @@ CurveArc::GetLength( double& dLen) const
|
||||
// lunghezza dell'arco piano
|
||||
dLen = m_dRad * abs( m_dAngCenDeg) * DEGTORAD ;
|
||||
// aggiunta eventuale parte ortogonale
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
dLen = sqrt( dLen * dLen + m_dDeltaN * m_dDeltaN) ;
|
||||
|
||||
return ( dLen > EPS_SMALL) ;
|
||||
@@ -1283,7 +1201,7 @@ CurveArc::Invert( void)
|
||||
return false ;
|
||||
|
||||
// il centro va spostato di DeltaN
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
m_PtCen += m_dDeltaN * m_VtN ;
|
||||
// il versore normale rimane inalterato
|
||||
// il versore iniziale diventa quello finale
|
||||
@@ -1454,11 +1372,13 @@ CurveArc::ModifyEnd( const Point3d& ptNewEnd)
|
||||
bool
|
||||
CurveArc::TrimStartAtParam( double dUTrim)
|
||||
{
|
||||
double dLen ;
|
||||
|
||||
|
||||
// riporto i parametri nel loro range
|
||||
dUTrim = ( ( dUTrim < 0) ? 0 : (( dUTrim > 1) ? 1 : dUTrim)) ;
|
||||
|
||||
// recupero lunghezza
|
||||
double dLen ;
|
||||
if ( ! GetLength( dLen))
|
||||
return false ;
|
||||
|
||||
@@ -1470,11 +1390,13 @@ CurveArc::TrimStartAtParam( double dUTrim)
|
||||
bool
|
||||
CurveArc::TrimEndAtParam( double dUTrim)
|
||||
{
|
||||
double dLen ;
|
||||
|
||||
|
||||
// riporto i parametri nel loro range
|
||||
dUTrim = ( ( dUTrim < 0) ? 0 : (( dUTrim > 1) ? 1 : dUTrim)) ;
|
||||
|
||||
// recupero lunghezza
|
||||
double dLen ;
|
||||
if ( ! GetLength( dLen))
|
||||
return false ;
|
||||
|
||||
@@ -1522,7 +1444,7 @@ CurveArc::TrimStartAtLen( double dLenTrim)
|
||||
dAngRot = m_dAngCenDeg * dLenTrim / dLen ;
|
||||
m_VtS.Rotate( m_VtN, dAngRot) ;
|
||||
m_dAngCenDeg -= dAngRot ;
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL) {
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL) {
|
||||
dMoveN = m_dDeltaN * dLenTrim / dLen ;
|
||||
m_PtCen.Translate( m_VtN * dMoveN) ;
|
||||
m_dDeltaN -= dMoveN ;
|
||||
@@ -1552,7 +1474,7 @@ CurveArc::TrimEndAtLen( double dLenTrim)
|
||||
// eseguo il trim
|
||||
if ( ( dLen - dLenTrim) > EPS_ZERO) {
|
||||
m_dAngCenDeg *= dLenTrim / dLen ;
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
m_dDeltaN *= dLenTrim / dLen ;
|
||||
}
|
||||
|
||||
@@ -1976,10 +1898,6 @@ CurveArc::ChangeRadius( double dNewRadius)
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico validità del raggio
|
||||
if ( ! ( dNewRadius > EPS_SMALL && dNewRadius < MAX_ARC_RAD))
|
||||
return false ;
|
||||
|
||||
// cambio il raggio
|
||||
m_dRad = dNewRadius ;
|
||||
|
||||
@@ -2018,10 +1936,6 @@ CurveArc::ChangeAngCenter( double dNewAngCenDeg)
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico accettabilità angolo
|
||||
if ( ! ( abs( m_dAngCenDeg) > EPS_ANG_ZERO))
|
||||
return false ;
|
||||
|
||||
// cambio il parametro
|
||||
m_dAngCenDeg = dNewAngCenDeg ;
|
||||
|
||||
@@ -2114,6 +2028,10 @@ CurveArc::Flip( void)
|
||||
//----------------------------------------------------------------------------
|
||||
ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const CurveArc& arArc)
|
||||
{
|
||||
int nStep ;
|
||||
double dAngStepDeg ;
|
||||
|
||||
|
||||
// inizializzazioni
|
||||
m_nTotPnt = 0 ;
|
||||
m_nCurrPnt = - 1 ;
|
||||
@@ -2131,7 +2049,6 @@ ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const
|
||||
dAngTolDeg = min( dAngTolDeg, ANG_TOL_EXT_MAX_DEG) ;
|
||||
|
||||
// determinazione dello step angolare
|
||||
double dAngStepDeg ;
|
||||
double dLinTolRel = dLinTol / arArc.GetRadius() ;
|
||||
if ( bInside)
|
||||
dAngStepDeg = sqrt( 8 * dLinTolRel) * RADTODEG ;
|
||||
@@ -2140,7 +2057,7 @@ ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const
|
||||
dAngStepDeg = min( dAngStepDeg, dAngTolDeg) ;
|
||||
|
||||
// dall'angolo al centro ricavo il numero di passi
|
||||
int nStep = int( abs( arArc.GetAngCenter()) / dAngStepDeg + 0.999) ;
|
||||
nStep = (int) ( abs( arArc.GetAngCenter()) / dAngStepDeg + 0.999) ;
|
||||
nStep = max( nStep, 1) ;
|
||||
|
||||
// sistemo lo step (per il numero intero di passi)
|
||||
@@ -2167,6 +2084,10 @@ ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const
|
||||
bool
|
||||
ArcApproxer::GetPoint( double& dU, Point3d& ptP)
|
||||
{
|
||||
Vector3d vtA1p ;
|
||||
Vector3d vtA2p ;
|
||||
|
||||
|
||||
// incremento indice punto corrente
|
||||
++ m_nCurrPnt ;
|
||||
|
||||
@@ -2185,7 +2106,7 @@ ArcApproxer::GetPoint( double& dU, Point3d& ptP)
|
||||
if ( ! m_bInside && m_nCurrPnt == m_nTotPnt - 1) {
|
||||
dU = 1 ;
|
||||
ptP = m_PtCen + m_vtA1 * m_dRad ;
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
ptP += ( dU * m_dDeltaN) * m_VtN ;
|
||||
return true ;
|
||||
}
|
||||
@@ -2197,8 +2118,8 @@ ArcApproxer::GetPoint( double& dU, Point3d& ptP)
|
||||
else
|
||||
dU = ( m_nCurrPnt - 0.5) / (double) ( m_nTotPnt - 2) ;
|
||||
// nuovo valore versori
|
||||
Vector3d vtA1p = m_vtA1 ;
|
||||
Vector3d vtA2p = m_vtA2 ;
|
||||
vtA1p = m_vtA1 ;
|
||||
vtA2p = m_vtA2 ;
|
||||
m_vtA1 = m_dCosA * vtA1p + m_dSinA * vtA2p ;
|
||||
m_vtA2 = - m_dSinA * vtA1p + m_dCosA * vtA2p ;
|
||||
// calcolo del punto
|
||||
@@ -2206,7 +2127,7 @@ ArcApproxer::GetPoint( double& dU, Point3d& ptP)
|
||||
ptP = m_PtCen + m_vtA1 * m_dRad ;
|
||||
else
|
||||
ptP = m_PtCen + ( vtA1p + m_vtA1) * ( m_dRad / ( 1 + m_dCosA)) ;
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
ptP += ( dU * m_dDeltaN) * m_VtN ;
|
||||
|
||||
return true ;
|
||||
|
||||
+5
-6
@@ -49,11 +49,10 @@ class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // ICurve
|
||||
bool IsSimple( void) const override
|
||||
@@ -212,7 +211,7 @@ class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
double m_dDeltaN ; // variazione di quota lungo VtN della fine rispetto all'inizio
|
||||
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
|
||||
double m_dThick ; // spessore
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+1
-1
@@ -790,7 +790,7 @@ ProjectCurveOnPlane( const ICurve& crCrv, const Plane3d& plPlane)
|
||||
{
|
||||
// determino se curva piana e suo eventuale piano
|
||||
Plane3d plCrv ;
|
||||
if ( crCrv.IsFlat( plCrv, false, EPS_SMALL / 2)) {
|
||||
if ( crCrv.IsFlat( plCrv)) {
|
||||
// se il piano della curva è parallelo a quello di proiezione
|
||||
if ( AreSameOrOppositeVectorExact( plCrv.GetVersN(), plPlane.GetVersN())) {
|
||||
// copio la curva
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkCurveAux.h"
|
||||
#include "/EgtDev/Include/EgkCurveAux.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool IsClosed( const ICurve& crvC) ;
|
||||
|
||||
+6
-9
@@ -45,10 +45,8 @@ GEOOBJ_REGISTER( CRV_BEZIER, NGE_C_BEZ, CurveBezier) ;
|
||||
//----------------------------------------------------------------------------
|
||||
CurveBezier::CurveBezier( void)
|
||||
: m_nStatus( TO_VERIFY), m_nDeg(), m_bRat( false), m_dParSing( -2),
|
||||
m_VtExtr(), m_dThick()
|
||||
m_VtExtr(), m_dThick(), m_nTempProp()
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -285,8 +283,7 @@ CurveBezier::CopyFrom( const CurveBezier& cbSrc)
|
||||
m_vWeCtrl = cbSrc.m_vWeCtrl ;
|
||||
m_VtExtr = cbSrc.m_VtExtr ;
|
||||
m_dThick = cbSrc.m_dThick ;
|
||||
m_nTempProp[0] = cbSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = cbSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = cbSrc.m_nTempProp ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -448,7 +445,7 @@ CurveBezier::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
|
||||
else {
|
||||
// costruisco una approssimazione lineare
|
||||
PolyLine PL ;
|
||||
if ( ! ApproxWithLines( LIN_TOL_MIN, ANG_TOL_APPROX_DEG, APL_STD, PL))
|
||||
if ( ! ApproxWithLines( LIN_TOL_MIN, ANG_TOL_APPROX_DEG, ICurve::APL_STD, PL))
|
||||
return false ;
|
||||
// ciclo sui punti della approssimazione
|
||||
Point3d ptTemp ;
|
||||
@@ -491,7 +488,7 @@ CurveBezier::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
||||
else {
|
||||
// costruisco una approssimazione lineare
|
||||
PolyLine PL ;
|
||||
if ( ! ApproxWithLines( LIN_TOL_MIN, ANG_TOL_APPROX_DEG, APL_STD, PL))
|
||||
if ( ! ApproxWithLines( LIN_TOL_MIN, ANG_TOL_APPROX_DEG, ICurve::APL_STD, PL))
|
||||
return false ;
|
||||
// ciclo sui punti della approssimazione
|
||||
Point3d ptTemp ;
|
||||
@@ -618,7 +615,7 @@ CurveBezier::GetCentroid( Point3d& ptCen) const
|
||||
return false ;
|
||||
// approssimo la curva con una polilinea
|
||||
PolyLine PL ;
|
||||
if ( ! ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, APL_STD, PL))
|
||||
if ( ! ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
||||
return false ;
|
||||
// calcolo il centro mediante PolygonPlane
|
||||
Point3d ptP ;
|
||||
@@ -1429,7 +1426,7 @@ CurveBezier::ApproxWithArcsXY( double dLinTol, double dAngTolDeg, PolyArc& PA) c
|
||||
|
||||
// costruisco una approssimazione lineare
|
||||
PolyLine PL ;
|
||||
if ( ! ApproxWithLines( dLinTol, dAngTolDeg, APL_STD, PL))
|
||||
if ( ! ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, PL))
|
||||
return false ;
|
||||
|
||||
// approssimo la curva per approssimazioni successive mediante bisezione
|
||||
|
||||
+5
-6
@@ -51,11 +51,10 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // ICurve
|
||||
bool IsSimple( void) const override { return true ; }
|
||||
@@ -190,7 +189,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
DBLVECTOR m_vWeCtrl ; // vettore dei pesi di controllo
|
||||
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
|
||||
double m_dThick ; // spessore
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "CalcDerivate.h"
|
||||
#include "BiArcs.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "RemoveCurveDefects.h"
|
||||
#include "/EgtDev/Include/EGkCurveByApprox.h"
|
||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||
#include "/EgtDev/Include/EGkPolyArc.h"
|
||||
@@ -66,8 +65,6 @@ CurveByApprox::GetCurve( int nType, double dLinTol, double dAngTolDeg, double dL
|
||||
PtrOwner<CurveComposite> pCC( CreateBasicCurveComposite()) ;
|
||||
if ( ! pCC->FromPolyArc( PA))
|
||||
return nullptr ;
|
||||
// elimino eventuali Small Z
|
||||
pCC->RemoveSmallDefects( dLinTol, dAngTolDeg) ;
|
||||
// eventuale fusione di curve compatibili
|
||||
pCC->MergeCurves( dLinTol, dAngTolDeg) ;
|
||||
// restituisco la curva
|
||||
|
||||
+3
-3
@@ -15,9 +15,9 @@
|
||||
#include "stdafx.h"
|
||||
#include "CalcDerivate.h"
|
||||
#include "/EgtDev/Include/EGkCurveByInterp.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkBiArcs.h"
|
||||
#include "/EgtDev/Include/EGkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EgkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EgkBiArcs.h"
|
||||
#include "/EgtDev/Include/EgkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
|
||||
|
||||
+23
-183
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2022
|
||||
// EgalTech 2013-2013
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CurveComposite.cpp Data : 23.01.22 Versione : 2.4a4
|
||||
// File : CurveComposite.cpp Data : 23.11.13 Versione : 1.3a1
|
||||
// Contenuto : Implementazione della classe CCurveComposite.
|
||||
//
|
||||
//
|
||||
@@ -21,17 +21,15 @@
|
||||
#include "CurveBezier.h"
|
||||
#include "PolygonPlane.h"
|
||||
#include "SurfFlatRegion.h"
|
||||
#include "RemoveCurveDefects.h"
|
||||
#include "GeoConst.h"
|
||||
#include "GeoObjFactory.h"
|
||||
#include "NgeWriter.h"
|
||||
#include "NgeReader.h"
|
||||
#include "/EgtDev/Include/EGkCurveByApprox.h"
|
||||
#include "/EgtDev/Include/EGkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EgkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <algorithm>
|
||||
|
||||
@@ -42,10 +40,8 @@ GEOOBJ_REGISTER( CRV_COMPO, NGE_C_CMP, CurveComposite) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
CurveComposite::CurveComposite( void)
|
||||
: m_nStatus( TO_VERIFY), m_VtExtr(), m_dThick(), m_ptStart(), m_Iter( m_CrvSmplS.end())
|
||||
: m_nStatus( TO_VERIFY), m_VtExtr(), m_dThick(), m_ptStart(), m_nTempProp(), m_Iter( m_CrvSmplS.end())
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -67,8 +63,7 @@ CurveComposite::Clear( void)
|
||||
m_VtExtr = V_NULL ;
|
||||
m_dThick = 0 ;
|
||||
m_ptStart = ORIG ;
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
m_nTempProp = 0 ;
|
||||
m_Iter = m_CrvSmplS.end() ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
@@ -210,15 +205,8 @@ CurveComposite::AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart, double dLinT
|
||||
if ( ! AreSamePointEpsilon( ptCrvStart, ptEnd, 0.01 * EPS_SMALL)) {
|
||||
// se in tolleranza, modifico l'inizio dell'entità
|
||||
if ( SqDist( ptCrvStart, ptEnd) < ( dLinTol * dLinTol)) {
|
||||
// lunghezza della curva originale
|
||||
double dOldLen ; pCrv->GetLength( dOldLen) ;
|
||||
// eseguo modifica
|
||||
if ( ! pCrv->ModifyStart( ptEnd))
|
||||
return false ;
|
||||
// verifico che la lunghezza non sia variata troppo
|
||||
double dNewLen ; pCrv->GetLength( dNewLen) ;
|
||||
if ( abs( dNewLen - dOldLen) > 10 * dLinTol)
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
@@ -263,25 +251,14 @@ CurveComposite::Close( void)
|
||||
// se già chiusa, non faccio alcunché
|
||||
if ( IsClosed())
|
||||
return true ;
|
||||
// determino la distanza tra gli estremi
|
||||
// aggiungo la linea di chiusura
|
||||
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
||||
Point3d ptStart, ptEnd ;
|
||||
if ( ! GetStartPoint( ptStart) ||
|
||||
! GetEndPoint( ptEnd))
|
||||
! GetEndPoint( ptEnd) ||
|
||||
! pLine->Set( ptEnd, ptStart) ||
|
||||
! AddSimpleCurve( Release( pLine)))
|
||||
return false ;
|
||||
// se molto vicini li modifico
|
||||
if ( SqDist( ptStart, ptEnd) < 100 * SQ_EPS_SMALL) {
|
||||
Point3d ptMid = Media( ptStart, ptEnd) ;
|
||||
if ( ! ModifyStart( ptMid) ||
|
||||
! ModifyEnd( ptMid))
|
||||
return false ;
|
||||
}
|
||||
// altrimenti aggiungo la linea di chiusura
|
||||
else {
|
||||
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
||||
if ( ! pLine->Set( ptEnd, ptStart) ||
|
||||
! AddSimpleCurve( Release( pLine)))
|
||||
return false ;
|
||||
}
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -564,8 +541,7 @@ CurveComposite::CopyFrom( const CurveComposite& ccSrc)
|
||||
Clear() ;
|
||||
m_VtExtr = ccSrc.m_VtExtr ;
|
||||
m_dThick = ccSrc.m_dThick ;
|
||||
m_nTempProp[0] = ccSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = ccSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = ccSrc.m_nTempProp ;
|
||||
for ( auto& pCrv : ccSrc.m_CrvSmplS) {
|
||||
if ( ! AddCurve( *pCrv))
|
||||
return false ;
|
||||
@@ -582,8 +558,7 @@ CurveComposite::RelocateFrom( CurveComposite& ccSrc)
|
||||
Clear() ;
|
||||
m_VtExtr = ccSrc.m_VtExtr ;
|
||||
m_dThick = ccSrc.m_dThick ;
|
||||
m_nTempProp[0] = ccSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = ccSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = ccSrc.m_nTempProp ;
|
||||
for ( ICurve* pCrv = ccSrc.RemoveFirstOrLastCurve( false) ;
|
||||
pCrv != nullptr ;
|
||||
pCrv = ccSrc.RemoveFirstOrLastCurve( false)) {
|
||||
@@ -987,7 +962,7 @@ CurveComposite::GetCentroid( Point3d& ptCen) const
|
||||
return false ;
|
||||
// approssimo la curva con una polilinea
|
||||
PolyLine PL ;
|
||||
if ( ! ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, APL_SPECIAL, PL))
|
||||
if ( ! ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
|
||||
return false ;
|
||||
// calcolo il centro mediante PolygonPlane
|
||||
Point3d ptP ;
|
||||
@@ -1036,7 +1011,7 @@ CurveComposite::GetMidDir( Vector3d& vtDir) const
|
||||
if ( ! GetLength( dLen) || ! GetParamAtLength( 0.5 * dLen, dMid))
|
||||
return false ;
|
||||
// calcolo la direzione
|
||||
return ::GetTang( *this, dMid, FROM_MINUS, vtDir) ;
|
||||
return ::GetTang( *this, 0.5 * m_CrvSmplS.size(), FROM_MINUS, vtDir) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1341,8 +1316,8 @@ CurveComposite::ApproxWithLines( double dLinTol, double dAngTolDeg, int nType, P
|
||||
// se lineare con lato obbligato...
|
||||
if ( nType == APL_LEFT || nType == APL_LEFT_CONVEX ||
|
||||
nType == APL_RIGHT || nType == APL_RIGHT_CONVEX) {
|
||||
// prima approssimazione lineare alla tolleranza minima del programma
|
||||
if ( ! ApproxWithLines( EPS_SMALL, dAngTolDeg, APL_SPECIAL, PL))
|
||||
// prima approssimazione lineare a 10 * Epsilon
|
||||
if ( ! ApproxWithLines( 10 * EPS_SMALL, dAngTolDeg, APL_SPECIAL, PL))
|
||||
return false ;
|
||||
// eliminazione dei punti in tolleranza andando solo dalla parte ammessa
|
||||
Vector3d vtExtr = ( m_VtExtr.IsSmall() ? Z_AX : m_VtExtr) ;
|
||||
@@ -1434,13 +1409,6 @@ CurveComposite::ApproxWithArcsEx( double dLinTol, double dAngTolDeg, double dLin
|
||||
crvByApprox.Reset() ;
|
||||
crvByApprox.AddPoint( pLine->GetStart()) ;
|
||||
}
|
||||
// aggiungo punti a distanza opportuna
|
||||
const double STEP = 5 ;
|
||||
int nStep = int( dLen / STEP) ;
|
||||
for ( int i = 1 ; i < nStep ; ++ i) {
|
||||
double dCoeff = i / double( nStep) ;
|
||||
crvByApprox.AddPoint( Media( pLine->GetStart(), pLine->GetEnd(), dCoeff)) ;
|
||||
}
|
||||
// aggiungo il punto finale
|
||||
crvByApprox.AddPoint( pLine->GetEnd()) ;
|
||||
}
|
||||
@@ -1484,8 +1452,8 @@ CurveComposite::ApproxWithArcsEx( double dLinTol, double dAngTolDeg, double dLin
|
||||
// assegno estrusione della curva composita
|
||||
PA.SetExtrusion( m_VtExtr) ;
|
||||
|
||||
// eliminazione dei punti in tolleranza (opportunamente diminuita)
|
||||
return PA.RemoveAlignedPoints( 0.5 * dLinTol) ;
|
||||
// eliminazione dei punti in tolleranza
|
||||
return PA.RemoveAlignedPoints( dLinTol) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1641,40 +1609,6 @@ CurveComposite::AddPoint( const Point3d& ptStart)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::AddLineTg( double dLen, bool bEndOrStart)
|
||||
{
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// costruisco la linea
|
||||
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pLine))
|
||||
return false ;
|
||||
// se da aggiungere alla fine
|
||||
if ( bEndOrStart) {
|
||||
Point3d ptEnd ;
|
||||
Vector3d vtEnd ;
|
||||
if ( ! GetEndPoint( ptEnd) || ! GetEndDir( vtEnd))
|
||||
return false ;
|
||||
Point3d ptNew = ptEnd + vtEnd * dLen ;
|
||||
if ( ! pLine->Set( ptEnd, ptNew))
|
||||
return false ;
|
||||
}
|
||||
// altrimenti da aggiungere all'inizio
|
||||
else {
|
||||
Point3d ptStart ;
|
||||
Vector3d vtStart ;
|
||||
if ( ! GetStartPoint( ptStart) || ! GetStartDir( vtStart))
|
||||
return false ;
|
||||
Point3d ptNew = ptStart - vtStart * dLen ;
|
||||
if ( ! pLine->Set( ptNew, ptStart))
|
||||
return false ;
|
||||
}
|
||||
return AddCurve( Release( pLine), bEndOrStart) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::AddLine( const Point3d& ptNew, bool bEndOrStart)
|
||||
@@ -3076,13 +3010,6 @@ CurveComposite::MergeCurves( double dLinTol, double dAngTolDeg, bool bStartEnd,
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::RemoveSmallDefects( double dLinTol, double dAngTolDeg, bool bAlsoSpikes)
|
||||
{
|
||||
return (( ! bAlsoSpikes || RemoveCurveSpikes( this, dLinTol)) && RemoveCurveSmallZs(this, dLinTol)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
SplitTopBottomArcs( CurveComposite& cCompo)
|
||||
@@ -3202,7 +3129,7 @@ CurveComposite::RemoveUndercutOnY( double dLinTol, double dAngTolDeg)
|
||||
pSfrCut->Translate( b3Box.GetMin() - Point3d( 10 * EPS_SMALL, dLen, 0)) ;
|
||||
// calcolo la classificazione della curva rispetto alla regione
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( ! pSfrCut->GetCurveClassification( *pOutLoop, EPS_SMALL, ccClass))
|
||||
if ( ! pSfrCut->GetCurveClassification( *pOutLoop, ccClass))
|
||||
return false ;
|
||||
// determino gli intervalli di curva da conservare
|
||||
Intervals inOk ;
|
||||
@@ -3316,94 +3243,7 @@ CurveComposite::IsACircle( double dLinTol, Point3d& ptCen, Vector3d& vtN, double
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::IsARectangle( double dLinTol, Point3d& ptP, Vector3d& vtL1, Vector3d& vtL2) const
|
||||
{
|
||||
// deve essere chiusa
|
||||
if ( ! IsClosed())
|
||||
return false ;
|
||||
// approssimo con segmenti di retta
|
||||
PolyLine PL ;
|
||||
if ( ! ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, APL_STD, PL))
|
||||
return false ;
|
||||
// deve giacere in un piano entro la tolleranza
|
||||
Plane3d plPlane ;
|
||||
if ( ! PL.IsFlat( plPlane, dLinTol))
|
||||
return false ;
|
||||
// deve essere formata da 4 segmenti
|
||||
if ( PL.GetLineNbr() != 4)
|
||||
return false ;
|
||||
// recupero i 4 vertici
|
||||
Point3d ptV1 ; PL.GetFirstPoint( ptV1) ;
|
||||
Point3d ptV2 ; PL.GetNextPoint( ptV2) ;
|
||||
Point3d ptV3 ; PL.GetNextPoint( ptV3) ;
|
||||
Point3d ptV4 ; PL.GetNextPoint( ptV4) ;
|
||||
// verifico che le diagonali si incontrino nel loro punto medio (-> è un parallelogramma)
|
||||
if ( ! AreSamePointEpsilon( Media( ptV1, ptV3), Media( ptV2, ptV4), dLinTol / 2))
|
||||
return false ;
|
||||
// verifico che le diagonali abbiano la stessa lunghezza (-> è un rettangolo)
|
||||
if ( abs( Dist( ptV1, ptV3) - Dist( ptV2, ptV4)) > dLinTol)
|
||||
return false ;
|
||||
// assegno i parametri del rettangolo
|
||||
ptP = ptV1 ;
|
||||
vtL1 = ptV2 - ptV1 ;
|
||||
vtL2 = ptV4 - ptV1 ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::IsATrapezoid( double dLinTol, Point3d& ptP, Vector3d& vtB1, Vector3d& vtL1, Vector3d& vtB2) const
|
||||
{
|
||||
// deve essere chiusa
|
||||
if ( ! IsClosed())
|
||||
return false ;
|
||||
// approssimo con segmenti di retta
|
||||
PolyLine PL ;
|
||||
if ( ! ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, APL_STD, PL))
|
||||
return false ;
|
||||
// deve giacere in un piano entro la tolleranza
|
||||
Plane3d plPlane ;
|
||||
if ( ! PL.IsFlat( plPlane, dLinTol))
|
||||
return false ;
|
||||
// deve essere formata da 4 segmenti
|
||||
if ( PL.GetLineNbr() != 4)
|
||||
return false ;
|
||||
// recupero i 4 vertici
|
||||
Point3d ptV1 ; PL.GetFirstPoint( ptV1) ;
|
||||
Point3d ptV2 ; PL.GetNextPoint( ptV2) ;
|
||||
Point3d ptV3 ; PL.GetNextPoint( ptV3) ;
|
||||
Point3d ptV4 ; PL.GetNextPoint( ptV4) ;
|
||||
// verifico se V4->V3 è parallelo a V1->V2
|
||||
double dV3B12, dV4B12 ;
|
||||
if ( ! DistPointLine( ptV3, ptV1, ptV2, false).GetDist( dV3B12) ||
|
||||
! DistPointLine( ptV4, ptV1, ptV2, false).GetDist( dV4B12))
|
||||
return false ;
|
||||
if ( abs( dV3B12 - dV4B12) < EPS_SMALL) {
|
||||
ptP = ptV1 ;
|
||||
vtB1 = ptV2 - ptV1 ;
|
||||
vtL1 = ptV4 - ptV1 ;
|
||||
vtB2 = ptV3 - ptV4 ;
|
||||
return true ;
|
||||
}
|
||||
// verifico se V1->V4 è parallelo a V2->V3
|
||||
double dV1B23, dV4B23 ;
|
||||
if ( ! DistPointLine( ptV1, ptV2, ptV3, false).GetDist( dV1B23) ||
|
||||
! DistPointLine( ptV4, ptV2, ptV3, false).GetDist( dV4B23))
|
||||
return false ;
|
||||
if ( abs( dV1B23 - dV4B23) < EPS_SMALL) {
|
||||
ptP = ptV2 ;
|
||||
vtB1 = ptV3 - ptV2 ;
|
||||
vtL1 = ptV1 - ptV2 ;
|
||||
vtB2 = ptV4 - ptV1 ;
|
||||
return true ;
|
||||
}
|
||||
// non è un trapezio
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::SetCurveTempProp( int nCrv, int nProp, int nPropNum)
|
||||
CurveComposite::SetCurveTempProp( int nCrv, int nProp)
|
||||
{
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
@@ -3412,13 +3252,13 @@ CurveComposite::SetCurveTempProp( int nCrv, int nProp, int nPropNum)
|
||||
if ( nCrv < 0 || nCrv >= int( m_CrvSmplS.size()))
|
||||
return false ;
|
||||
// eseguo assegnazione
|
||||
m_CrvSmplS[nCrv]->SetTempProp( nProp, nPropNum) ;
|
||||
m_CrvSmplS[nCrv]->SetTempProp( nProp) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::GetCurveTempProp( int nCrv, int& nProp, int nPropNum) const
|
||||
CurveComposite::GetCurveTempProp( int nCrv, int& nProp) const
|
||||
{
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
@@ -3427,6 +3267,6 @@ CurveComposite::GetCurveTempProp( int nCrv, int& nProp, int nPropNum) const
|
||||
if ( nCrv < 0 || nCrv >= int( m_CrvSmplS.size()))
|
||||
return false ;
|
||||
// eseguo recupero
|
||||
nProp = m_CrvSmplS[nCrv]->GetTempProp( nPropNum) ;
|
||||
nProp = m_CrvSmplS[nCrv]->GetTempProp() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
+10
-16
@@ -1,13 +1,12 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2022
|
||||
// EgalTech 2013-2021
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CurveComposite.h Data : 24.03.22 Versione : 2.4c2
|
||||
// File : CurveComposite.h Data : 03.04.21 Versione : 2.3d1
|
||||
// Contenuto : Dichiarazione della classe Curva composita.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 16.04.13 DS Creazione modulo.
|
||||
// 24.03.22 DS Aggiunto metodo AddLineTg.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -51,11 +50,10 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // ICurve
|
||||
bool IsSimple( void) const override
|
||||
@@ -145,9 +143,8 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
bool ChangeStartPoint( double dU) override ;
|
||||
bool AddPoint( const Point3d& ptStart) override ;
|
||||
bool AddLine( const Point3d& ptNew, bool bEndOrStart = true) override ;
|
||||
bool AddLineTg( double dLen, bool bEndOrStart = true) override ;
|
||||
bool AddArc2P( const Point3d& ptOther, const Point3d& ptNew, bool bEndOrStart = true) override ;
|
||||
bool AddArcTg( const Point3d& ptNew, bool bEndOrStart = true) override ;
|
||||
bool AddArc2P( const Point3d& ptOther, const Point3d& ptNew, bool bEndOrStart = true) override ;
|
||||
bool AddJoint( double dU) override ;
|
||||
bool ModifyJoint( int nU, const Point3d& ptNewJoint) override ;
|
||||
bool RemoveJoint( int nU) override ;
|
||||
@@ -157,15 +154,12 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
bool ArcsToBezierCurves( void) override ;
|
||||
bool ArcsBezierCurvesToArcsPerpExtr( double dLinTol, double dAngTolDeg) override ;
|
||||
bool MergeCurves( double dLinTol, double dAngTolDeg, bool bStartEnd = true, bool bNeedSameProp = false) override ;
|
||||
bool RemoveSmallDefects( double dLinTol, double dAngTolDeg, bool bAlsoSpikes = false) override ;
|
||||
bool RemoveUndercutOnY( double dLinTol, double dAngTolDeg) override ;
|
||||
bool IsAPoint( void) const override ;
|
||||
bool IsALine( double dLinTol, Point3d& ptStart, Point3d& ptEnd) const override ;
|
||||
bool IsACircle( double dLinTol, Point3d& ptCen, Vector3d& vtN, double& dRad, bool& bCCW) const override ;
|
||||
bool IsARectangle( double dLinTol, Point3d& ptP, Vector3d& vtL1, Vector3d& vtL2) const override ;
|
||||
bool IsATrapezoid( double dLinTol, Point3d& ptP, Vector3d& vtB1, Vector3d& vtL1, Vector3d& vtB2) const override ;
|
||||
bool SetCurveTempProp( int nCrv, int nProp, int nPropNum = 0) override ;
|
||||
bool GetCurveTempProp( int nCrv, int& nProp, int nPropNum = 0) const override ;
|
||||
bool SetCurveTempProp( int nCrv, int nProp) override ;
|
||||
bool GetCurveTempProp( int nCrv, int& nProp) const override ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
@@ -208,7 +202,7 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
|
||||
double m_dThick ; // spessore
|
||||
Point3d m_ptStart ; // punto iniziale per composita vuota per Add di linee o archi
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
mutable PCSD_CONST_ITER m_Iter ; // iteratore
|
||||
} ;
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
#include "CurveLine.h"
|
||||
#include "CurveArc.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EgkCurve.h"
|
||||
#include "/EgtDev/Include/EgkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
+2
-5
@@ -29,10 +29,8 @@ GEOOBJ_REGISTER( CRV_LINE, NGE_C_LIN, CurveLine) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
CurveLine::CurveLine( void)
|
||||
: m_nStatus( TO_VERIFY), m_PtStart(), m_PtEnd(), m_VtExtr(), m_dThick()
|
||||
: m_nStatus( TO_VERIFY), m_PtStart(), m_PtEnd(), m_VtExtr(), m_dThick(), m_nTempProp()
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[0] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -125,8 +123,7 @@ CurveLine::CopyFrom( const CurveLine& clSrc)
|
||||
return true ;
|
||||
m_VtExtr = clSrc.m_VtExtr ;
|
||||
m_dThick = clSrc.m_dThick ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = clSrc.m_nTempProp ;
|
||||
return Set( clSrc.m_PtStart, clSrc.m_PtEnd) ;
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -49,11 +49,10 @@ class CurveLine : public ICurveLine, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // ICurve
|
||||
bool IsSimple( void) const override
|
||||
@@ -165,7 +164,7 @@ class CurveLine : public ICurveLine, public IGeoObjRW
|
||||
Point3d m_PtEnd ; // punto finale
|
||||
Vector3d m_VtExtr ; // vettore estrusione
|
||||
double m_dThick ; // spessore
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+96
-100
@@ -1,13 +1,13 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2022
|
||||
// EgalTech 2020-2020
|
||||
//----------------------------------------------------------------------------
|
||||
// File : DistLineLine.h Data : 12.08.22 Versione : 2.4h1
|
||||
// File : DistLineLine.h Data : 06.11.20 Versione : 2.2k1
|
||||
// Contenuto : Implementazione della classe distanza fra elementi lineari.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 06.11.20 LM Creazione modulo.
|
||||
// 12.08.22 DS Correzioni e migliorie varie.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -18,26 +18,22 @@
|
||||
#include "/EgtDev/Include/EGkGeoConst.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
DistLineLine::DistLineLine( const Point3d& ptSt1, const Point3d& ptEn1,
|
||||
const Point3d& ptSt2, const Point3d& ptEn2,
|
||||
bool bIsSegment1, bool bIsSegment2)
|
||||
{
|
||||
// reset oggetto
|
||||
m_dSqDist = - 1 ;
|
||||
m_dDist = - 1 ;
|
||||
// calcolo direzione segmenti
|
||||
Vector3d vtD1 = ptEn1 - ptSt1 ;
|
||||
double dLen1 = vtD1.Len() ;
|
||||
Vector3d vtD2 = ptEn2 - ptSt2 ;
|
||||
double dLen2 = vtD2.Len() ;
|
||||
if ( dLen1 < EPS_SMALL || dLen2 < EPS_SMALL)
|
||||
double dLen2 = vtD1.Len() ;
|
||||
if ( dLen1 < EPS_SMALL || dLen2 < EPS_SMALL) {
|
||||
m_dSqDist = - 1 ;
|
||||
m_dDist = - 1 ;
|
||||
return ;
|
||||
}
|
||||
vtD1 /= dLen1 ;
|
||||
vtD2 /= dLen2 ;
|
||||
// eseguo
|
||||
Calculate( ptSt1, vtD1, dLen1, ptSt2, vtD2, dLen2, bIsSegment1, bIsSegment2) ;
|
||||
}
|
||||
|
||||
@@ -47,13 +43,11 @@ DistLineLine::DistLineLine( const Point3d& ptSt1, const Vector3d& vtD1, double d
|
||||
const Point3d& ptSt2, const Vector3d& vtD2, double dLen2,
|
||||
bool bIsSegment1, bool bIsSegment2)
|
||||
{
|
||||
// reset oggetto
|
||||
m_dSqDist = - 1 ;
|
||||
m_dDist = - 1 ;
|
||||
// verifico segmenti
|
||||
if ( dLen1 < EPS_SMALL || dLen2 < EPS_SMALL)
|
||||
if ( dLen1 < EPS_SMALL || dLen2 < EPS_SMALL) {
|
||||
m_dSqDist = - 1 ;
|
||||
m_dDist = - 1 ;
|
||||
return ;
|
||||
// eseguo
|
||||
}
|
||||
Calculate( ptSt1, vtD1, dLen1, ptSt2, vtD2, dLen2, bIsSegment1, bIsSegment2) ;
|
||||
}
|
||||
|
||||
@@ -63,7 +57,6 @@ DistLineLine::GetSqDist( double& dSqDist)
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
|
||||
dSqDist = m_dSqDist ;
|
||||
return true ;
|
||||
}
|
||||
@@ -74,10 +67,7 @@ DistLineLine::GetDist( double& dDist)
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
|
||||
if ( m_dDist < 0)
|
||||
m_dDist = sqrt( m_dSqDist) ;
|
||||
dDist = m_dDist ;
|
||||
dDist = sqrt( m_dSqDist) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -94,48 +84,55 @@ DistLineLine::GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistLineLine::GetPositionsAtMinDistPoints( double& dPos1, double& dPos2)
|
||||
DistLineLine::GetParamsAtMinDistPoints( double& dPar1, double& dPar2)
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
dPos1 = m_dPos1 ;
|
||||
dPos2 = m_dPos2 ;
|
||||
dPar1 = m_dPar1 ;
|
||||
dPar2 = m_dPar2 ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Calcola la distanza fra i due elementi lineari, i punti di minima distanza e le loro posizioni.
|
||||
// Se i due elementi sono paralleli i punti di minimo sono scelti secondo convenienza.
|
||||
// Calcola la distanza fra i due elemnti lineari, i punti di minima distanza e
|
||||
// i loro rispettivi parametri.
|
||||
// Se la coppia di punti di minima distanza non è unica ne viene scelta una
|
||||
// in base a comodità di calcolo.
|
||||
void
|
||||
DistLineLine::Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen1,
|
||||
const Point3d& ptSt2, const Vector3d& vtD2, double dLen2,
|
||||
bool bIsSegment1, bool bIsSegment2)
|
||||
{
|
||||
// Se elementi paralleli o antiparalleli
|
||||
// Caso di elementi lineari paralleli/antiparalleli
|
||||
if ( AreSameOrOppositeVectorExact( vtD1, vtD2)) {
|
||||
// Se il primo elemento è una retta infinita
|
||||
if ( ! bIsSegment1) {
|
||||
Vector3d vtStSt = ptSt2 - ptSt1 ;
|
||||
double dLong = vtStSt * vtD1 ;
|
||||
Vector3d vtDist = vtStSt - dLong * vtD1 ;
|
||||
m_dSqDist = vtDist.SqLen() ;
|
||||
m_dPos1 = dLong ;
|
||||
m_dPos2 = 0 ;
|
||||
m_ptMinDist1 = ptSt1 + dLong * vtD1 ;
|
||||
m_ptMinDist2 = ptSt2 ;
|
||||
}
|
||||
// se altrimenti il secondo elemento è una retta infinita
|
||||
else if ( ! bIsSegment2) {
|
||||
Vector3d vtStSt = ptSt1 - ptSt2 ;
|
||||
double dLong = vtStSt * vtD2 ;
|
||||
Vector3d vtDist = vtStSt - dLong * vtD2 ;
|
||||
m_dSqDist = vtDist.SqLen() ;
|
||||
m_dPos1 = 0 ;
|
||||
m_dPos2 = dLong ;
|
||||
m_ptMinDist1 = ptSt1 ;
|
||||
m_ptMinDist2 = ptSt2 + dLong * vtD2 ;
|
||||
// Almeno un elemento è una retta
|
||||
if ( ! ( bIsSegment1 && bIsSegment2)) {
|
||||
// Il primo elemento è segmento, quindi deve essere una retta il secondo
|
||||
if ( bIsSegment1) {
|
||||
Vector3d vtStSt = ptSt1 - ptSt2 ;
|
||||
double dLong = vtStSt * vtD2 ;
|
||||
Vector3d vtDist = vtStSt - dLong * vtD2 ;
|
||||
m_dSqDist = vtDist.SqLen() ;
|
||||
m_dDist = sqrt( m_dSqDist) ;
|
||||
m_dPar1 = 0 ;
|
||||
m_dPar2 = dLong ;
|
||||
m_ptMinDist1 = ptSt1 ;
|
||||
m_ptMinDist2 = ptSt2 + dLong * vtD2 ;
|
||||
}
|
||||
// Il primo elemento è una retta
|
||||
else {
|
||||
Vector3d vtStSt = ptSt2 - ptSt1 ;
|
||||
double dLong = vtStSt * vtD1 ;
|
||||
Vector3d vtDist = vtStSt - dLong * vtD1 ;
|
||||
m_dSqDist = vtDist.SqLen() ;
|
||||
m_dDist = sqrt( m_dSqDist) ;
|
||||
m_dPar1 = dLong ;
|
||||
m_dPar2 = 0 ;
|
||||
m_ptMinDist1 = ptSt1 + dLong * vtD1 ;
|
||||
m_ptMinDist2 = ptSt2 ;
|
||||
}
|
||||
}
|
||||
// altrimenti entrambi gli elementi sono segmenti
|
||||
// Entrambi gli elementi sono segmenti
|
||||
else {
|
||||
Point3d ptEn1 = ptSt1 + dLen1 * vtD1 ;
|
||||
Point3d ptEn2 = ptSt2 + dLen2 * vtD2 ;
|
||||
@@ -143,7 +140,7 @@ DistLineLine::Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen
|
||||
Vector3d vtStEn = ptEn2 - ptSt1 ;
|
||||
double dStU = vtStSt * vtD1 ;
|
||||
double dEnU = vtStEn * vtD1 ;
|
||||
// Classifico i punti del secondo segmento in base alla loro
|
||||
// Classifico i punti del segmento segmento in base alla loro
|
||||
// coordinata rispetto all'ordinamento generato dal primo.
|
||||
double dMinPar, dMaxPar ;
|
||||
Point3d ptMinPar, ptMaxPar ;
|
||||
@@ -162,71 +159,70 @@ DistLineLine::Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen
|
||||
// Possibili posizioni reciproche dei segmenti
|
||||
if ( dMinPar > dLen1) {
|
||||
m_dSqDist = SqDist( ptEn1, ptMinPar) ;
|
||||
m_dDist = sqrt( m_dSqDist) ;
|
||||
m_ptMinDist1 = ptEn1 ;
|
||||
m_ptMinDist2 = ptMinPar ;
|
||||
m_dPos1 = dLen1 ;
|
||||
m_dPos2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
|
||||
m_dPar1 = dLen1 ;
|
||||
m_dPar2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
|
||||
}
|
||||
else if ( dMinPar > 0) {
|
||||
m_dSqDist = max( vtStSt * vtStSt - dStU * dStU, 0.) ;
|
||||
m_dSqDist = std::max( vtStSt * vtStSt - dStU * dStU, 0.) ;
|
||||
m_dDist = sqrt( m_dSqDist) ;
|
||||
m_ptMinDist1 = ptSt1 + dMinPar * vtD1 ;
|
||||
m_ptMinDist2 = ptMinPar ;
|
||||
m_dPos1 = dMinPar ;
|
||||
m_dPos2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
|
||||
m_dPar1 = dMinPar ;
|
||||
m_dPar2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
|
||||
}
|
||||
else if ( dMaxPar > 0) {
|
||||
m_dSqDist = max( vtStSt * vtStSt - dStU * dStU, 0.) ;
|
||||
m_dSqDist = std::max( vtStSt * vtStSt - dStU * dStU, 0.) ;
|
||||
m_dDist = sqrt( m_dSqDist) ;
|
||||
m_ptMinDist1 = ptSt1 ;
|
||||
m_ptMinDist2 = ptSt2 + ( ptSt1 - ptSt2) * vtD2 * vtD2 ;
|
||||
m_dPos1 = 0 ;
|
||||
m_dPos2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
|
||||
m_dPar1 = 0 ;
|
||||
m_dPar2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
|
||||
}
|
||||
else {
|
||||
m_dSqDist = SqDist( ptSt1, ptMaxPar) ;
|
||||
m_dDist = sqrt( m_dSqDist) ;
|
||||
m_ptMinDist1 = ptSt1 ;
|
||||
m_ptMinDist2 = ptMaxPar ;
|
||||
m_dPos1 = 0 ;
|
||||
m_dPos2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
|
||||
m_dPar1 = 0 ;
|
||||
m_dPar2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
|
||||
}
|
||||
}
|
||||
return ;
|
||||
}
|
||||
// Caso generale
|
||||
else {
|
||||
// Posizioni a distanza minima tra rette illimitate
|
||||
Vector3d vtStSt = ptSt2 - ptSt1 ;
|
||||
double dDist01 = vtStSt * vtD1 ;
|
||||
double dDist02 = vtStSt * vtD2 ;
|
||||
double dDotD1D2 = vtD1 * vtD2 ;
|
||||
double dT1 = ( dDist01 - dDotD1D2 * dDist02) / ( 1 - dDotD1D2 * dDotD1D2) ;
|
||||
double dT2 = ( dDotD1D2 * dDist01 - dDist02) / ( 1 - dDotD1D2 * dDotD1D2) ;
|
||||
// Posizioni minime e massime sui segmenti
|
||||
double dMin1 = ( bIsSegment1 ? 0 : -INFINITO) ;
|
||||
double dMax1 = ( bIsSegment1 ? dLen1 : INFINITO) ;
|
||||
double dMin2 = ( bIsSegment2 ? 0 : -INFINITO) ;
|
||||
double dMax2 = ( bIsSegment2 ? dLen2 : INFINITO) ;
|
||||
// Se entrambe le posizioni stanno nei segmenti
|
||||
if ( dT1 >= dMin1 && dT1 <= dMax1 && dT2 >= dMin2 && dT2 <= dMax2) {
|
||||
m_dPos1 = dT1 ;
|
||||
m_dPos2 = dT2 ;
|
||||
}
|
||||
// se altrimenti solo la prima sta nel segmento
|
||||
else if ( dT1 >= dMin1 && dT1 <= dMax1) {
|
||||
m_dPos2 = Clamp( dT2, dMin2, dMax2) ;
|
||||
m_dPos1 = Clamp( (( ptSt2 + m_dPos2 * vtD2) - ptSt1) * vtD1, dMin1, dMax1) ;
|
||||
}
|
||||
// se altrimenti solo la seconda sta nel segmento
|
||||
else if ( dT2 >= dMin2 && dT2 <= dMax2) {
|
||||
m_dPos1 = Clamp( dT1, dMin1, dMax1) ;
|
||||
m_dPos2 = Clamp( (( ptSt1 + m_dPos1 * vtD1) - ptSt2) * vtD2, dMin2, dMax2) ;
|
||||
}
|
||||
// altrimenti nessuna sta nel suo segmento
|
||||
else {
|
||||
m_dPos1 = Clamp( dT1, dMin1, dMax1) ;
|
||||
m_dPos2 = Clamp( (( ptSt1 + m_dPos1 * vtD1) - ptSt2) * vtD2, dMin2, dMax2) ;
|
||||
m_dPos1 = Clamp( (( ptSt2 + m_dPos2 * vtD2) - ptSt1) * vtD1, dMin1, dMax1) ;
|
||||
}
|
||||
m_ptMinDist1 = ptSt1 + m_dPos1 * vtD1 ;
|
||||
m_ptMinDist2 = ptSt2 + m_dPos2 * vtD2 ;
|
||||
m_dSqDist = SqDist( m_ptMinDist1, m_ptMinDist2) ;
|
||||
Vector3d vtDist0 = ptSt2 - ptSt1 ;
|
||||
double dDist01 = vtDist0 * vtD1 ;
|
||||
double dDist02 = vtDist0 * vtD2 ;
|
||||
double dDotD1D2 = vtD1 * vtD2 ;
|
||||
double dT1 = dDist01 + ( ( dDist01 * dDotD1D2 - dDist02) * dDotD1D2) / ( 1 - dDotD1D2 * dDotD1D2) ;
|
||||
double dT2 = ( dDist01 * dDotD1D2 - dDist02) / ( 1 - dDotD1D2 * dDotD1D2) ;
|
||||
double dMin1 = - INFINITO ;
|
||||
double dMax1 = INFINITO ;
|
||||
double dMin2 = - INFINITO ;
|
||||
double dMax2 = INFINITO ;
|
||||
double dSt1On2 = ( ptSt1 - ptSt2) * vtD2 ;
|
||||
double dEn1On2 = ( ptSt1 + dLen1 * vtD1 - ptSt2) * vtD2 ;
|
||||
if ( bIsSegment1) {
|
||||
dMin1 = 0 ;
|
||||
dMax1 = dLen1 ;
|
||||
dMin2 = std::min( dSt1On2, dEn1On2) ;
|
||||
dMax2 = std::max( dSt1On2, dEn1On2) ;
|
||||
}
|
||||
}
|
||||
if ( bIsSegment2) {
|
||||
double dSt2On1 = ( ptSt2 - ptSt1) * vtD1 ;
|
||||
double dEn2On1 = ( ptSt2 + dLen2 * vtD2 - ptSt1) * vtD1 ;
|
||||
dMin1 = std::max( dMin1, std::min( dSt2On1, dEn2On1)) ;
|
||||
dMax1 = std::min( dMax1, std::max( dSt2On1, dEn2On1)) ;
|
||||
dMin2 = std::max( dMin2, 0.) ;
|
||||
dMax2 = std::min( dMax2, dLen2) ;
|
||||
}
|
||||
m_dPar1 = Clamp( dT1, dMin1, dMax1) ;
|
||||
m_dPar2 = Clamp( dT2, dMin2, dMax2) ;
|
||||
m_ptMinDist1 = ptSt1 + m_dPar1 * vtD1 ;
|
||||
m_ptMinDist2 = ptSt2 + m_dPar2 * vtD2 ;
|
||||
m_dSqDist = SqDist( m_ptMinDist1, m_ptMinDist2) ;
|
||||
m_dDist = sqrt( m_dSqDist) ;
|
||||
}
|
||||
+4
-4
@@ -37,17 +37,17 @@ class DistLineLine
|
||||
bool IsSmall( void) { return IsEpsilon( EPS_SMALL) ; }
|
||||
bool IsZero( void) { return IsEpsilon( EPS_ZERO) ; }
|
||||
bool GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) ;
|
||||
bool GetPositionsAtMinDistPoints( double& dPos1, double& dPos2) ;
|
||||
bool GetParamsAtMinDistPoints( double& dPar1, double& dPar2) ;
|
||||
|
||||
private :
|
||||
void Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen1,
|
||||
const Point3d& ptSt2, const Vector3d& vtD2, double dLen2,
|
||||
bool bIsSegment1, bool bIsSegment2) ;
|
||||
bool bIsSegment1 = true, bool bIsSegment2 = true) ;
|
||||
private:
|
||||
double m_dSqDist ;
|
||||
double m_dDist ;
|
||||
double m_dPos1 ;
|
||||
double m_dPos2 ;
|
||||
double m_dPar1 ;
|
||||
double m_dPar2 ;
|
||||
Point3d m_ptMinDist1 ;
|
||||
Point3d m_ptMinDist2 ;
|
||||
} ;
|
||||
|
||||
+11
-10
@@ -23,30 +23,33 @@
|
||||
bool
|
||||
CalcMinDistPointPolyLine( const Point3d& ptP, PolyLine& PL, double dLinTol, MDCVECTOR& vApproxMin)
|
||||
{
|
||||
double dSqDist ;
|
||||
double dPar ;
|
||||
double dUIni ;
|
||||
double dUFin ;
|
||||
Point3d ptIni ;
|
||||
Point3d ptFin ;
|
||||
double dMinDist ;
|
||||
double dSqMinDist ;
|
||||
MinDistCalc approxMin ;
|
||||
|
||||
vApproxMin.reserve( 4) ;
|
||||
vApproxMin.clear() ;
|
||||
|
||||
bool bFound = false ;
|
||||
bool bOnEnd = false ;
|
||||
double dUIni, dUFin ;
|
||||
Point3d ptIni, ptFin ;
|
||||
double dMinDist, dSqMinDist ;
|
||||
vApproxMin.reserve( 4) ;
|
||||
vApproxMin.clear() ;
|
||||
for ( bool bLine = PL.GetFirstULine( &dUIni, &ptIni, &dUFin, &ptFin) ;
|
||||
bLine ;
|
||||
bLine = PL.GetNextULine( &dUIni, &ptIni, &dUFin, &ptFin)) {
|
||||
// calcolo la distanza del punto dal segmento
|
||||
DistPointLine dstPtLn( ptP, ptIni, ptFin) ;
|
||||
double dSqDist ;
|
||||
if ( ! dstPtLn.GetSqDist( dSqDist))
|
||||
continue ;
|
||||
// altro punto con la stessa minima distanza già trovata
|
||||
if ( bFound && abs( dSqDist - dSqMinDist) < 2 * dMinDist * dLinTol) {
|
||||
// salvo i dati nella struttura
|
||||
MinDistCalc approxMin ;
|
||||
approxMin.dDist = dMinDist ;
|
||||
dstPtLn.GetMinDistPoint( approxMin.ptQ) ;
|
||||
double dPar ;
|
||||
dstPtLn.GetParamAtMinDistPoint( dPar) ;
|
||||
approxMin.dPar = ( 1 - dPar) * dUIni + dPar * dUFin ;
|
||||
approxMin.dParMin = dUIni ;
|
||||
@@ -63,10 +66,8 @@ CalcMinDistPointPolyLine( const Point3d& ptP, PolyLine& PL, double dLinTol, MDCV
|
||||
dSqMinDist = dSqDist ;
|
||||
dMinDist = sqrt( dSqMinDist) ;
|
||||
// salvo i dati nella struttura
|
||||
MinDistCalc approxMin ;
|
||||
approxMin.dDist = dMinDist ;
|
||||
dstPtLn.GetMinDistPoint( approxMin.ptQ) ;
|
||||
double dPar ;
|
||||
dstPtLn.GetParamAtMinDistPoint( dPar) ;
|
||||
approxMin.dPar = ( 1 - dPar) * dUIni + dPar * dUFin ;
|
||||
approxMin.dParMin = dUIni ;
|
||||
|
||||
@@ -89,18 +89,8 @@ DistPointCrvComposite::DistPointCrvComposite( const Point3d& ptP, const ICurveCo
|
||||
}
|
||||
}
|
||||
// altrimenti aggiungo
|
||||
else {
|
||||
if ( dCurrDist < m_dDist) {
|
||||
// aggiorno i minimi
|
||||
m_dDist = dCurrDist ;
|
||||
// inserisco in testa
|
||||
m_Info.insert( m_Info.begin(), aInfo) ;
|
||||
}
|
||||
else {
|
||||
// inserisco in coda
|
||||
m_Info.push_back( aInfo) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
m_Info.push_back( aInfo) ;
|
||||
// passo al successivo
|
||||
++ i ;
|
||||
}
|
||||
|
||||
@@ -20,5 +20,4 @@
|
||||
int GetEGkDebugLev( void) ;
|
||||
ILogger* GetEGkLogger( void) ;
|
||||
const std::string& GetEGkKey( void) ;
|
||||
bool GetEGkNetHwKey( void) ;
|
||||
int ProcessEvents( int nProg, int nPause) ;
|
||||
|
||||
+1
-16
@@ -16,7 +16,7 @@
|
||||
#include "DllMain.h"
|
||||
#include "FontManager.h"
|
||||
#include "\EgtDev\Include\EGkDllMain.h"
|
||||
#include "\EgtDev\Include\EGnGetModuleVer.h"
|
||||
#include "\EgtDev\Include\EgnGetModuleVer.h"
|
||||
#include "\EgtDev\Include\EgtTrace.h"
|
||||
#include "\EgtDev\Include\SELkLockId.h"
|
||||
|
||||
@@ -115,7 +115,6 @@ GetEGkLogger( void)
|
||||
//-----------------------------------------------------------------------------
|
||||
static string s_sKey ;
|
||||
static int s_nKeyType = KEY_LOCK_TYPE_ANY ;
|
||||
static bool s_bNetHwKey = false ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
@@ -131,13 +130,6 @@ SetEGkKeyType( int nType)
|
||||
s_nKeyType = nType ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
SetEGkNetHwKey( bool bNetHwKey)
|
||||
{
|
||||
s_bNetHwKey = bNetHwKey ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const string&
|
||||
GetEGkKey( void)
|
||||
@@ -146,13 +138,6 @@ GetEGkKey( void)
|
||||
return s_sKey ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
GetEGkNetHwKey( void)
|
||||
{
|
||||
return s_bNetHwKey ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
InitFontManager( const string& sNfeFontDir, const string& sDefaultFont)
|
||||
|
||||
Binary file not shown.
+29
-29
@@ -30,7 +30,7 @@
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
@@ -46,12 +46,12 @@
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<PlatformToolset>ClangCL</PlatformToolset>
|
||||
@@ -86,7 +86,6 @@
|
||||
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
|
||||
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
|
||||
<IncludePath>C:\;$(IncludePath)</IncludePath>
|
||||
<EnableClangTidyCodeAnalysis>false</EnableClangTidyCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<TargetName>$(ProjectName)R$(PlatformArchitecture)</TargetName>
|
||||
@@ -102,7 +101,6 @@
|
||||
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
|
||||
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
|
||||
<IncludePath>C:\;$(IncludePath)</IncludePath>
|
||||
<EnableClangTidyCodeAnalysis>false</EnableClangTidyCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -116,6 +114,7 @@
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<EnablePREfast>false</EnablePREfast>
|
||||
<AdditionalIncludeDirectories>\EgtDev\Extern\GeometricToolsEngine</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -150,8 +149,7 @@ copy $(TargetPath) \EgtProg\DllD32</Command>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions>
|
||||
<AdditionalIncludeDirectories>\EgtDev\Extern\GeometricToolsEngine</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -198,6 +196,7 @@ copy $(TargetPath) \EgtProg\DllD64</Command>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>\EgtDev\Extern\GeometricToolsEngine</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -240,12 +239,10 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions>
|
||||
<IntelJCCErratum>true</IntelJCCErratum>
|
||||
<AdditionalIncludeDirectories>\EgtDev\Extern\GeometricToolsEngine</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -283,7 +280,6 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="CAvToolTriangle.cpp" />
|
||||
<ClCompile Include="CDeBoxClosedSurfTm.cpp" />
|
||||
<ClCompile Include="CDeBoxTria.cpp" />
|
||||
<ClCompile Include="CDeCapsTria.cpp" />
|
||||
<ClCompile Include="CDeClosedSurfTmClosedSurfTm.cpp" />
|
||||
<ClCompile Include="CDeConeFrustumClosedSurfTm.cpp" />
|
||||
<ClCompile Include="CDeConeFrustumTria.cpp" />
|
||||
@@ -299,7 +295,6 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="CDeTriaTria.cpp" />
|
||||
<ClCompile Include="CDeUtility.cpp" />
|
||||
<ClCompile Include="ChainCurves.cpp" />
|
||||
<ClCompile Include="Circle2P.cpp" />
|
||||
<ClCompile Include="CircleCenTgCurve.cpp" />
|
||||
<ClCompile Include="Color.cpp" />
|
||||
<ClCompile Include="CreateCurveAux.cpp" />
|
||||
@@ -313,7 +308,6 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="..\Include\EGkIntersLineBox.h" />
|
||||
<ClInclude Include="..\Include\EGkIntersPlaneBox.h" />
|
||||
<ClInclude Include="CDeBoxTria.h" />
|
||||
<ClInclude Include="CDeCapsTria.h" />
|
||||
<ClInclude Include="CDeConeFrustumTria.h" />
|
||||
<ClInclude Include="CDeConeTria.h" />
|
||||
<ClInclude Include="CDeConvexTorusTria.h" />
|
||||
@@ -327,7 +321,6 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="DistPointSurfTm.cpp" />
|
||||
<ClCompile Include="DistPointTria.cpp" />
|
||||
<ClCompile Include="ExtDimension.cpp" />
|
||||
<ClCompile Include="HashGrids1d.cpp" />
|
||||
<ClCompile Include="IntersLineBox.cpp" />
|
||||
<ClCompile Include="IntersLineSphere.cpp" />
|
||||
<ClCompile Include="IntersLineSurfStd.cpp" />
|
||||
@@ -337,7 +330,6 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="IntersPlaneTria.cpp" />
|
||||
<ClCompile Include="IntersSurfTmSurfTm.cpp" />
|
||||
<ClCompile Include="IntersTriaTria.cpp" />
|
||||
<ClCompile Include="MedialAxis.cpp" />
|
||||
<ClCompile Include="OffsetCurve.cpp" />
|
||||
<ClCompile Include="DistPointArc.cpp" />
|
||||
<ClCompile Include="DistPointCrvAux.cpp" />
|
||||
@@ -374,7 +366,12 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="IntersCurveCurve.cpp" />
|
||||
<ClCompile Include="IntersLineArc.cpp" />
|
||||
<ClCompile Include="IntersLineLine.cpp" />
|
||||
<ClCompile Include="IntersLinePlane.cpp" />
|
||||
<ClCompile Include="IntersLinePlane.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IntersLineSurfTm.cpp" />
|
||||
<ClCompile Include="IntersLineTria.cpp" />
|
||||
<ClCompile Include="Intervals.cpp" />
|
||||
@@ -392,7 +389,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="OffsetCurveOnX.cpp" />
|
||||
<ClCompile Include="Polygon3d.cpp" />
|
||||
<ClCompile Include="AdjustLoops.cpp" />
|
||||
<ClCompile Include="RemoveCurveDefects.cpp" />
|
||||
<ClCompile Include="RemoveCurveSpikes.cpp" />
|
||||
<ClCompile Include="SelfIntersCurve.cpp" />
|
||||
<ClCompile Include="SfrCreate.cpp" />
|
||||
<ClCompile Include="SurfBezier.cpp" />
|
||||
@@ -400,10 +397,10 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="SurfFlatRegionBooleans.cpp" />
|
||||
<ClCompile Include="SurfFlatRegionOffset.cpp" />
|
||||
<ClCompile Include="SurfTriMeshBooleans.cpp" />
|
||||
<ClCompile Include="SurfTriMeshCuts.cpp" />
|
||||
<ClCompile Include="SurfTriMeshUtilities.cpp" />
|
||||
<ClCompile Include="TextureData.cpp" />
|
||||
<ClCompile Include="Tool.cpp" />
|
||||
<ClCompile Include="tpp_assert.cpp" />
|
||||
<ClCompile Include="tpp_impl.cpp" />
|
||||
<ClCompile Include="UserObjDefault.cpp" />
|
||||
<ClCompile Include="UserObjFactory.cpp" />
|
||||
<ClCompile Include="OutTsc.cpp" />
|
||||
@@ -450,14 +447,14 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="..\Include\EGkChainCurves.h" />
|
||||
<ClInclude Include="..\Include\EGkCircleCenTgCurve.h" />
|
||||
<ClInclude Include="..\Include\EGkColor.h" />
|
||||
<ClInclude Include="..\Include\EGkCurve.h" />
|
||||
<ClInclude Include="..\Include\EGkCurveArc.h" />
|
||||
<ClInclude Include="..\Include\EGkCurveAux.h" />
|
||||
<ClInclude Include="..\Include\EGkCurveBezier.h" />
|
||||
<ClInclude Include="..\Include\EgkCurve.h" />
|
||||
<ClInclude Include="..\Include\EgkCurveArc.h" />
|
||||
<ClInclude Include="..\Include\EgkCurveAux.h" />
|
||||
<ClInclude Include="..\Include\EgkCurveBezier.h" />
|
||||
<ClInclude Include="..\Include\EGkCurveByApprox.h" />
|
||||
<ClInclude Include="..\Include\EGkCurveComposite.h" />
|
||||
<ClInclude Include="..\Include\EgkCurveComposite.h" />
|
||||
<ClInclude Include="..\Include\EGkCurveByInterp.h" />
|
||||
<ClInclude Include="..\Include\EGkCurveLine.h" />
|
||||
<ClInclude Include="..\Include\EgkCurveLine.h" />
|
||||
<ClInclude Include="..\Include\EGkCurveLocal.h" />
|
||||
<ClInclude Include="..\Include\EGkCurvePointDiffGeom.h" />
|
||||
<ClInclude Include="..\Include\EGkDistPointCurve.h" />
|
||||
@@ -567,7 +564,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="DistPointCrvComposite.h" />
|
||||
<ClInclude Include="DistPointLine.h" />
|
||||
<ClInclude Include="DllMain.h" />
|
||||
<ClInclude Include="earcut.hpp" />
|
||||
<ClInclude Include="dpoint.hpp" />
|
||||
<ClInclude Include="ExtDimension.h" />
|
||||
<ClInclude Include="ExtText.h" />
|
||||
<ClInclude Include="FontAux.h" />
|
||||
@@ -596,7 +593,6 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="IntersArcArc.h" />
|
||||
<ClInclude Include="IntersCrvCompoCrvCompo.h" />
|
||||
<ClInclude Include="IntersLineArc.h" />
|
||||
<ClInclude Include="IntersLineBox.h" />
|
||||
<ClInclude Include="IntersLineLine.h" />
|
||||
<ClInclude Include="IntersLineSurfStd.h" />
|
||||
<ClInclude Include="IntersLineTria.h" />
|
||||
@@ -610,12 +606,16 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="ObjGraphicsMgr.h" />
|
||||
<ClInclude Include="FontOs.h" />
|
||||
<ClInclude Include="AdjustLoops.h" />
|
||||
<ClInclude Include="RemoveCurveDefects.h" />
|
||||
<ClInclude Include="RemoveCurveSpikes.h" />
|
||||
<ClInclude Include="SurfBezier.h" />
|
||||
<ClInclude Include="SurfFlatRegion.h" />
|
||||
<ClInclude Include="TextureData.h" />
|
||||
<ClInclude Include="Tool.h" />
|
||||
<ClInclude Include="CAvToolTriangle.h" />
|
||||
<ClInclude Include="tpp_assert.hpp" />
|
||||
<ClInclude Include="tpp_interface.hpp" />
|
||||
<ClInclude Include="triangle.h" />
|
||||
<ClInclude Include="triangle_impl.hpp" />
|
||||
<ClInclude Include="UserObjDefault.h" />
|
||||
<ClInclude Include="OutTsc.h" />
|
||||
<ClInclude Include="PointsPCA.h" />
|
||||
|
||||
@@ -46,6 +46,12 @@
|
||||
<Filter Include="File di origine\GeoCollision">
|
||||
<UniqueIdentifier>{865b76ee-b10d-41fc-861c-b48ce52fa277}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="File di intestazione\tpp">
|
||||
<UniqueIdentifier>{9596e38a-8880-4ab5-bd65-e1db39c92ac5}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="File di origine\tpp">
|
||||
<UniqueIdentifier>{636e60fa-4b24-4a7b-b2e9-74e1c1e8fb31}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Vector3d.cpp">
|
||||
@@ -327,7 +333,7 @@
|
||||
<ClCompile Include="OffsetCurveOnX.cpp">
|
||||
<Filter>File di origine\GeoOffset</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RemoveCurveDefects.cpp">
|
||||
<ClCompile Include="RemoveCurveSpikes.cpp">
|
||||
<Filter>File di origine\GeoInters</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Polygon3d.cpp">
|
||||
@@ -453,23 +459,11 @@
|
||||
<ClCompile Include="CDeRectPrismoidTria.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SurfTriMeshUtilities.cpp">
|
||||
<Filter>File di origine\Geo</Filter>
|
||||
<ClCompile Include="tpp_assert.cpp">
|
||||
<Filter>File di origine\tpp</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SurfTriMeshCuts.cpp">
|
||||
<Filter>File di origine\Geo</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HashGrids1d.cpp">
|
||||
<Filter>File di origine\Base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeCapsTria.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Circle2P.cpp">
|
||||
<Filter>File di origine\GeoCreate</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MedialAxis.cpp">
|
||||
<Filter>File di origine\GeoOffset</Filter>
|
||||
<ClCompile Include="tpp_impl.cpp">
|
||||
<Filter>File di origine\tpp</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -641,28 +635,28 @@
|
||||
<ClInclude Include="..\Include\EGkChainCurves.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkCurveBezier.h">
|
||||
<ClInclude Include="..\Include\EgkCurveBezier.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkColor.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkCurve.h">
|
||||
<ClInclude Include="..\Include\EgkCurve.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkCurveArc.h">
|
||||
<ClInclude Include="..\Include\EgkCurveArc.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkCurveAux.h">
|
||||
<ClInclude Include="..\Include\EgkCurveAux.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkCurveByInterp.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkCurveComposite.h">
|
||||
<ClInclude Include="..\Include\EgkCurveComposite.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkCurveLine.h">
|
||||
<ClInclude Include="..\Include\EgkCurveLine.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkCurvePointDiffGeom.h">
|
||||
@@ -857,7 +851,7 @@
|
||||
<ClInclude Include="..\Include\EGkIntersLineSurfTm.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RemoveCurveDefects.h">
|
||||
<ClInclude Include="RemoveCurveSpikes.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkIntersPlanePlane.h">
|
||||
@@ -1094,14 +1088,20 @@
|
||||
<ClInclude Include="CDeRectPrismoidTria.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="earcut.hpp">
|
||||
<Filter>File di intestazione</Filter>
|
||||
<ClInclude Include="dpoint.hpp">
|
||||
<Filter>File di intestazione\tpp</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="IntersLineBox.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
<ClInclude Include="tpp_assert.hpp">
|
||||
<Filter>File di intestazione\tpp</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CDeCapsTria.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
<ClInclude Include="tpp_interface.hpp">
|
||||
<Filter>File di intestazione\tpp</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="triangle.h">
|
||||
<Filter>File di intestazione\tpp</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="triangle_impl.hpp">
|
||||
<Filter>File di intestazione\tpp</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
+2
-5
@@ -49,8 +49,6 @@ ExtDimension::ExtDimension( void)
|
||||
: m_dExtLineLen( STD_EXTLINELEN), m_dArrowLen( STD_ARROWLEN), m_dTextDist( STD_TEXTDIST),
|
||||
m_bLenIsMM( true), m_nDecDigit( STD_DECDIGIT), m_sFont( STD_FONT), m_dTextHeight( STD_TEXTHEIGHT)
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -188,8 +186,7 @@ ExtDimension::CopyFrom( const ExtDimension& clSrc)
|
||||
m_nDecDigit = clSrc.m_nDecDigit ;
|
||||
m_sFont = clSrc.m_sFont ;
|
||||
m_dTextHeight = clSrc.m_dTextHeight ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = clSrc.m_nTempProp ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -796,7 +793,7 @@ ExtDimension::GetTextHalfDist( const Point3d& ptText) const
|
||||
double dHalfDist = m_dTextHeight / 2 + m_dTextDist ;
|
||||
// recupero il box di ingombro del testo
|
||||
BBox3d b3Text ;
|
||||
if ( GetTextMyBBox( ptText, b3Text) && ! b3Text.IsEmpty()) {
|
||||
if ( GetTextMyBBox( ptText, b3Text)) {
|
||||
double dHalfL = ( b3Text.GetMax().x - b3Text.GetMin().x) / 2 ;
|
||||
double dHalfH = ( b3Text.GetMax().y - b3Text.GetMin().y) / 2 ;
|
||||
dHalfDist = sqrt( dHalfL * dHalfL + dHalfH * dHalfH) ;
|
||||
|
||||
+5
-6
@@ -50,11 +50,10 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // IExtDimension
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -149,5 +148,5 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
|
||||
int m_nDecDigit ; // numero di cifre decimali
|
||||
std::string m_sFont ; // font del testo
|
||||
double m_dTextHeight ; // altezza del testo
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
+2
-5
@@ -35,10 +35,8 @@ GEOOBJ_REGISTER( EXT_TEXT, NGE_E_TXT, ExtText) ;
|
||||
//----------------------------------------------------------------------------
|
||||
ExtText::ExtText( void)
|
||||
: m_pSTM( nullptr), m_bNoSTM( false), m_ptP(), m_vtN( 0, 0, 1), m_vtD( 1, 0, 0), m_sFont(),
|
||||
m_nWeight( 400), m_bItalic( false), m_dHeight( 10), m_dRatio( 1), m_dAddAdvance( 0)
|
||||
m_nWeight( 400), m_bItalic( false), m_dHeight( 10), m_dRatio( 1), m_dAddAdvance( 0), m_nTempProp()
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -186,8 +184,7 @@ ExtText::CopyFrom( const ExtText& clSrc)
|
||||
m_dRatio = clSrc.m_dRatio ;
|
||||
m_dAddAdvance = clSrc.m_dAddAdvance ;
|
||||
m_nInsPos = clSrc.m_nInsPos ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = clSrc.m_nTempProp ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,11 +50,10 @@ class ExtText : public IExtText, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // IExtText
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -144,5 +143,5 @@ class ExtText : public IExtText, public IGeoObjRW
|
||||
double m_dRatio ; // rapporto tra larghezza e altezza
|
||||
double m_dAddAdvance ; // avanzamento addizionale tra caratteri
|
||||
int m_nInsPos ; // posizione del punto di inserimento rispetto al testo
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
+71
-107
@@ -15,90 +15,13 @@
|
||||
#include "stdafx.h"
|
||||
#include "CurveArc.h"
|
||||
#include "CurveLine.h"
|
||||
#include "/EgtDev/Include/EGkFilletChamfer.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EgkFilletChamfer.h"
|
||||
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
CalcForFillet( const ICurve& cCrv1, const Point3d& ptNear1,
|
||||
const ICurve& cCrv2, const Point3d& ptNear2,
|
||||
const Vector3d& vtNorm, double dRadius,
|
||||
Point3d& ptCen, Point3d& ptTg1, Point3d& ptTg2,
|
||||
int& nSide1, int& nSide2, double& dSinA, double& dTgPar1, double& dTgPar2)
|
||||
{
|
||||
// calcolo un riferimento sul piano perpendicolare alla normale
|
||||
Frame3d frIntr ;
|
||||
if ( ! frIntr.Set( ORIG, vtNorm))
|
||||
return false ;
|
||||
|
||||
// determino il lato di offset della curva 1
|
||||
DistPointCurve dPC1( ptNear2, cCrv1) ;
|
||||
if ( ! dPC1.GetSideAtMinDistPoint( 0, vtNorm, nSide1))
|
||||
return false ;
|
||||
double dOffs1 = ( nSide1 == MDS_RIGHT ? dRadius : - dRadius) ;
|
||||
// calcolo l'offset nel piano locale e dal lato opportuno di una copia della curva 1
|
||||
PtrOwner<ICurve> pCopy1( cCrv1.Clone()) ;
|
||||
if ( IsNull( pCopy1))
|
||||
return false ;
|
||||
pCopy1->ToLoc( frIntr) ;
|
||||
pCopy1->SetExtrusion( Z_AX) ;
|
||||
if ( ! pCopy1->SimpleOffset( dOffs1, ICurve::OFF_FILLET))
|
||||
return false ;
|
||||
|
||||
// determino il lato di offset della curva 2
|
||||
DistPointCurve dPC2( ptNear1, cCrv2) ;
|
||||
if ( ! dPC2.GetSideAtMinDistPoint( 0, vtNorm, nSide2))
|
||||
return false ;
|
||||
double dOffs2 = ( nSide2 == MDS_RIGHT ? dRadius : - dRadius) ;
|
||||
// calcolo l'offset nel piano locale e dal lato opportuno di una copia della curva 2
|
||||
PtrOwner<ICurve> pCopy2( cCrv2.Clone()) ;
|
||||
if ( IsNull( pCopy2))
|
||||
return false ;
|
||||
pCopy2->ToLoc( frIntr) ;
|
||||
pCopy2->SetExtrusion( Z_AX) ;
|
||||
if ( ! pCopy2->SimpleOffset( dOffs2, ICurve::OFF_FILLET))
|
||||
return false ;
|
||||
|
||||
// calcolo l'intersezione tra le due curve
|
||||
Point3d ptInt1, ptInt2 ;
|
||||
Point3d ptNearI = Media( ptNear1, ptNear2) ;
|
||||
ptNearI.ToLoc( frIntr) ;
|
||||
IntersCurveCurve intCC( *pCopy1, *pCopy2) ;
|
||||
if ( ! intCC.GetIntersPointNearTo( 0, ptNearI, ptInt1) ||
|
||||
! intCC.GetIntersPointNearTo( 1, ptNearI, ptInt2))
|
||||
return false ;
|
||||
ptInt1.ToGlob( frIntr) ;
|
||||
ptInt2.ToGlob( frIntr) ;
|
||||
ptCen = Media( ptInt1, ptInt2) ;
|
||||
|
||||
// proiezione del punto di intersezione sulla prima curva
|
||||
DistPointCurve dPCI1( ptInt1, cCrv1) ;
|
||||
int nFlag1 ;
|
||||
if ( ! dPCI1.GetParamAtMinDistPoint( 0, dTgPar1, nFlag1) || nFlag1 != MDPCI_NORMAL)
|
||||
return false ;
|
||||
Vector3d vtTg1 ;
|
||||
if ( ! cCrv1.GetPointTang( dTgPar1, ICurve::FROM_MINUS, ptTg1, vtTg1))
|
||||
return false ;
|
||||
|
||||
// proiezione del punto di intersezione sulla seconda curva
|
||||
DistPointCurve dPCI2( ptInt2, cCrv2) ;
|
||||
int nFlag2 ;
|
||||
if ( ! dPCI2.GetParamAtMinDistPoint( 0, dTgPar2, nFlag2) || nFlag2 != MDPCI_NORMAL)
|
||||
return false ;
|
||||
Vector3d vtTg2 ;
|
||||
if ( ! cCrv2.GetPointTang( dTgPar2, ICurve::FROM_MINUS, ptTg2, vtTg2))
|
||||
return false ;
|
||||
|
||||
// determino rotazione tra le curve
|
||||
dSinA = ( vtTg1 ^ vtTg2) * vtNorm ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurveArc*
|
||||
CreateFillet( const ICurve& cCrv1, const Point3d& ptNear1,
|
||||
@@ -111,26 +34,76 @@ CreateFillet( const ICurve& cCrv1, const Point3d& ptNear1,
|
||||
&vtNorm == nullptr || &dPar1 == nullptr || &dPar2 == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
// eseguo calcoli
|
||||
Point3d ptCen, ptTg1, ptTg2 ;
|
||||
int nSide1, nSide2 ;
|
||||
double dSinA, dTgPar1, dTgPar2 ;
|
||||
if ( ! CalcForFillet( cCrv1, ptNear1, cCrv2, ptNear2, vtNorm, dRadius,
|
||||
ptCen, ptTg1, ptTg2, nSide1, nSide2, dSinA, dTgPar1, dTgPar2))
|
||||
// calcolo un riferimento sul piano perpendicolare alla normale
|
||||
Frame3d frIntr ;
|
||||
if ( ! frIntr.Set( ORIG, vtNorm))
|
||||
return nullptr ;
|
||||
|
||||
// se tangenti parallele al contatto con fillet, ricalcolo con raggio più piccolo
|
||||
bool bParallel = ( abs( dSinA) < EPS_SMALL) ;
|
||||
if ( bParallel) {
|
||||
Point3d ptQQQ, ptQQ1, ptQQ2 ;
|
||||
double dQQQ1, dQQQ2 ;
|
||||
if ( ! CalcForFillet( cCrv1, ptNear1, cCrv2, ptNear2, vtNorm, dRadius - 10 * EPS_SMALL,
|
||||
ptQQQ, ptQQ1, ptQQ2, nSide1, nSide2, dSinA, dQQQ1, dQQQ2) || abs( dSinA) < EPS_SMALL)
|
||||
return nullptr ;
|
||||
}
|
||||
// determino il lato di offset della curva 1
|
||||
DistPointCurve dPC1( ptNear2, cCrv1) ;
|
||||
int nSide1 ;
|
||||
if ( ! dPC1.GetSideAtMinDistPoint( 0, vtNorm, nSide1))
|
||||
return nullptr ;
|
||||
double dOffs1 = ( nSide1 == MDS_RIGHT ? dRadius : - dRadius) ;
|
||||
// calcolo l'offset nel piano locale e dal lato opportuno di una copia della curva 1
|
||||
PtrOwner<ICurve> pCopy1( cCrv1.Clone()) ;
|
||||
if ( IsNull( pCopy1))
|
||||
return nullptr ;
|
||||
pCopy1->ToLoc( frIntr) ;
|
||||
pCopy1->SetExtrusion( Z_AX) ;
|
||||
if ( ! pCopy1->SimpleOffset( dOffs1, ICurve::OFF_FILLET))
|
||||
return nullptr ;
|
||||
|
||||
// orientamento tra le curve
|
||||
bool bCCW = ( dSinA > 0) ;
|
||||
// determino il lato di offset della curva 2
|
||||
DistPointCurve dPC2( ptNear1, cCrv2) ;
|
||||
int nSide2 ;
|
||||
if ( ! dPC2.GetSideAtMinDistPoint( 0, vtNorm, nSide2))
|
||||
return nullptr ;
|
||||
double dOffs2 = ( nSide2 == MDS_RIGHT ? dRadius : - dRadius) ;
|
||||
// calcolo l'offset nel piano locale e dal lato opportuno di una copia della curva 2
|
||||
PtrOwner<ICurve> pCopy2( cCrv2.Clone()) ;
|
||||
if ( IsNull( pCopy2))
|
||||
return nullptr ;
|
||||
pCopy2->ToLoc( frIntr) ;
|
||||
pCopy2->SetExtrusion( Z_AX) ;
|
||||
if ( ! pCopy2->SimpleOffset( dOffs2, ICurve::OFF_FILLET))
|
||||
return nullptr ;
|
||||
|
||||
// calcolo l'intersezione tra le due curve
|
||||
Point3d ptInt1, ptInt2 ;
|
||||
Point3d ptNear1I = ptNear1 ;
|
||||
ptNear1I.ToLoc( frIntr) ;
|
||||
IntersCurveCurve intCC( *pCopy1, *pCopy2) ;
|
||||
if ( ! intCC.GetIntersPointNearTo( 0, ptNear1I, ptInt1) ||
|
||||
! intCC.GetIntersPointNearTo( 1, ptNear1I, ptInt2))
|
||||
return nullptr ;
|
||||
ptInt1.ToGlob( frIntr) ;
|
||||
ptInt2.ToGlob( frIntr) ;
|
||||
|
||||
// proiezione del punto di intersezione sulla prima curva
|
||||
DistPointCurve dPCI1( ptInt1, cCrv1) ;
|
||||
double dTgPar1 ;
|
||||
int nFlag1 ;
|
||||
if ( ! dPCI1.GetParamAtMinDistPoint( 0, dTgPar1, nFlag1) || nFlag1 != MDPCI_NORMAL)
|
||||
return nullptr ;
|
||||
Point3d ptTg1 ;
|
||||
Vector3d vtTg1 ;
|
||||
if ( ! cCrv1.GetPointTang( dTgPar1, ICurve::FROM_MINUS, ptTg1, vtTg1))
|
||||
return nullptr ;
|
||||
|
||||
// proiezione del punto di intersezione sulla seconda curva
|
||||
DistPointCurve dPCI2( ptInt2, cCrv2) ;
|
||||
double dTgPar2 ;
|
||||
int nFlag2 ;
|
||||
if ( ! dPCI2.GetParamAtMinDistPoint( 0, dTgPar2, nFlag2) || nFlag2 != MDPCI_NORMAL)
|
||||
return nullptr ;
|
||||
Point3d ptTg2 ;
|
||||
Vector3d vtTg2 ;
|
||||
if ( ! cCrv2.GetPointTang( dTgPar2, ICurve::FROM_MINUS, ptTg2, vtTg2))
|
||||
return nullptr ;
|
||||
|
||||
// determino rotazione tra le curve
|
||||
bool bCCW = (( vtTg1 ^ vtTg2) * vtNorm) > 0 ;
|
||||
|
||||
// assegno i valori dei parametri di trim (+ da inizio, - da fine)
|
||||
if ( bCCW) {
|
||||
@@ -145,17 +118,8 @@ CreateFillet( const ICurve& cCrv1, const Point3d& ptNear1,
|
||||
// creo l'arco di fillet
|
||||
PtrOwner<CurveArc> crvFillet( CreateBasicCurveArc()) ;
|
||||
if ( IsNull( crvFillet) ||
|
||||
! crvFillet->SetC2PN( ptCen, ptTg1, ptTg2, vtNorm))
|
||||
! crvFillet->SetC2PN( ptInt1, ptTg1, ptTg2, vtNorm))
|
||||
return nullptr ;
|
||||
// se direzioni agli estremi praticamente parallele
|
||||
if ( bParallel) {
|
||||
// calcolo il verso dell'arco di fillet
|
||||
bool bFilletCcw = ( ( bCCW && nSide1 == nSide2) || ( ! bCCW && nSide1 != nSide2)) ;
|
||||
// si deve verificare se va usato l'arco esplementare
|
||||
bool bArcCcw = ( crvFillet->GetAngCenter() > 0) ;
|
||||
if ( bFilletCcw != bArcCcw)
|
||||
crvFillet->ToExplementary() ;
|
||||
}
|
||||
return Release(crvFillet) ;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkVector3d.h"
|
||||
#include "/EgtDev/Include/EgtNumCollection.h"
|
||||
#include "/EgtDev/Include/EGtNumCollection.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double AdjustFontRatio( double dRatio) ;
|
||||
|
||||
+2
-2
@@ -17,9 +17,9 @@
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGnFileUtils.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgnFileUtils.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
+2
-1
@@ -378,7 +378,8 @@ OsFont::GetRegion( const string& sText, int nInsPos, ISURFFRPLIST& lstSFR) const
|
||||
if ( ! GetCharOutline( vCode[i], dAdvance, lstPC))
|
||||
return false ;
|
||||
// lo trasformo opportunamente
|
||||
for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
|
||||
ICURVEPLIST::iterator iIter ;
|
||||
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
|
||||
// inverto i percorsi per avere gli esterni CCW
|
||||
(*iIter)->Invert() ;
|
||||
// la trasformo per avere solo archi e rette
|
||||
|
||||
+3
-3
@@ -224,10 +224,10 @@ Frame3d::Set( const Point3d& ptOrig, double dAngCDeg, double dAngADeg, double dA
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Frame3d::Reset( bool bGlob)
|
||||
Frame3d::Reset( void)
|
||||
{
|
||||
m_nType = ( bGlob ? TOP : ERR) ;
|
||||
m_nZType = ( bGlob ? TOP : ERR) ;
|
||||
m_nType = TOP ;
|
||||
m_nZType = TOP ;
|
||||
m_ptOrig = ORIG ;
|
||||
m_vtVersX = X_AX ;
|
||||
m_vtVersY = Y_AX ;
|
||||
|
||||
+120
-120
@@ -57,7 +57,7 @@
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Per Id di entità
|
||||
// Per Id di entità
|
||||
static const int ID_NO = -99 ;
|
||||
// Per tipo di costruzione di poligono
|
||||
static const int POLYG_INSCR = 1 ;
|
||||
@@ -189,7 +189,7 @@ GdbExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR&
|
||||
LOG_ERROR( GetEGkLogger(), "Error : null GeomDb in GdbExecutor.")
|
||||
return ER_ERR ;
|
||||
}
|
||||
// verifico validità CmdParser
|
||||
// verifico validità CmdParser
|
||||
if ( m_pParser == nullptr) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error : null CmdParser in GdbExecutor.")
|
||||
return ER_ERR ;
|
||||
@@ -218,7 +218,7 @@ GdbExecutor::ExecuteGroup( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// 2 o 3 parametri : Id, Id del padre[, Frame]
|
||||
if ( vsParams.size() != 2 && vsParams.size() != 3)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -236,7 +236,7 @@ GdbExecutor::ExecuteGroup( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// 3 parametri : Id, Id del padre, Orig
|
||||
if ( vsParams.size() != 3)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -253,7 +253,7 @@ GdbExecutor::ExecuteGroup( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// creo il gruppo
|
||||
int nIdDest = GetIdParam( vsParams[0], true) ;
|
||||
int nIdNew = m_pGDB->AddGroup( nIdDest, GetIdParam( vsParams[1]), frFrame) ;
|
||||
// se IdDest da calcolare, può essere una variabili a cui cambiare il valore
|
||||
// se IdDest da calcolare, può essere una variabili a cui cambiare il valore
|
||||
if ( nIdDest == GDB_ID_NULL)
|
||||
m_pParser->SetVariable( vsParams[0], nIdNew) ;
|
||||
|
||||
@@ -270,7 +270,7 @@ GdbExecutor::ExecutePoint( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// 3 parametri : Id, IdParent e punto
|
||||
if ( vsParams.size() != 3)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frPnt ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frPnt))
|
||||
return false ;
|
||||
@@ -289,7 +289,7 @@ GdbExecutor::ExecutePoint( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// 4 : Id, IdParent, ptP, vtV
|
||||
if ( vsParams.size() != 4)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frPnt ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frPnt))
|
||||
return false ;
|
||||
@@ -351,7 +351,7 @@ GdbExecutor::VectorMake( const STRVECTOR& vsParams)
|
||||
// 3 o 4 parametri : Id, IdParent, Vettore [, ScaleFactor]
|
||||
if ( vsParams.size() != 3 && vsParams.size() != 4)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frVect ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
|
||||
return false ;
|
||||
@@ -378,7 +378,7 @@ GdbExecutor::VectorFromSpherical( const STRVECTOR& vsParams)
|
||||
// 5 parametri : Id, IdParent, dLen, dAngVertDeg, dAngOrizzDeg
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frVect ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
|
||||
return false ;
|
||||
@@ -386,7 +386,7 @@ GdbExecutor::VectorFromSpherical( const STRVECTOR& vsParams)
|
||||
double dLen ;
|
||||
if ( ! GetLengthParam( vsParams[2], dLen))
|
||||
return false ;
|
||||
// recupero l'angolo in verticale (non c'è metodo generale)
|
||||
// recupero l'angolo in verticale (non c'è metodo generale)
|
||||
double dAngVertDeg ;
|
||||
if ( ! FromString( vsParams[3], dAngVertDeg))
|
||||
return false ;
|
||||
@@ -410,7 +410,7 @@ GdbExecutor::VectorCrossProduct( const STRVECTOR& vsParams)
|
||||
// 4 o 5 parametri : Id, IdParent, vtV1, vtV2 [, bNorm]
|
||||
if ( vsParams.size() != 4 && vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frVect ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
|
||||
return false ;
|
||||
@@ -444,7 +444,7 @@ GdbExecutor::VectorDifference( const STRVECTOR& vsParams)
|
||||
// 4 o 5 parametri : Id, IdParent, ptP1, ptP2 [, bNorm]
|
||||
if ( vsParams.size() != 4 && vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frVect ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
|
||||
return false ;
|
||||
@@ -478,7 +478,7 @@ GdbExecutor::VectorBaseVector( const STRVECTOR& vsParams)
|
||||
// 4 o 5 parametri : Id, IdParent, PtBase, Vettore [, ScaleFactor]
|
||||
if ( vsParams.size() != 4 && vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frVect ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
|
||||
return false ;
|
||||
@@ -512,7 +512,7 @@ GdbExecutor::VectorModifyBase( const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
// indice dell'oggetto
|
||||
int nId = GetIdParam( vsParams[0]) ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frVect ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nId, frVect))
|
||||
return false ;
|
||||
@@ -537,7 +537,7 @@ GdbExecutor::ExecuteFrame( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// 3 parametri : Id, ParentId, Frame
|
||||
if ( vsParams.size() != 3)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -557,7 +557,7 @@ GdbExecutor::ExecuteFrame( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// 5 parametri : Id, ParentId, ptOrig, ptOnX, ptNearY
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -579,7 +579,7 @@ GdbExecutor::ExecuteFrame( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// 4 parametri
|
||||
if ( vsParams.size() != 4)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -634,7 +634,7 @@ GdbExecutor::CurveLineMake( const STRVECTOR& vsParams)
|
||||
// 4 parametri : Id, IdParent, ptStart, ptEnd
|
||||
if ( vsParams.size() != 4)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -664,7 +664,7 @@ GdbExecutor::CurveLineVersorLength( const STRVECTOR& vsParams)
|
||||
// 5 parametri : Id, IdParent, ptStart, vtDir, dLen
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -698,7 +698,7 @@ GdbExecutor::CurveLineDirLength( const STRVECTOR& vsParams)
|
||||
// 5 parametri : Id, IdParent, ptStart, dAngDeg, dLen
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -863,7 +863,7 @@ GdbExecutor::CurveLineMinPointCurve( const STRVECTOR& vsParams)
|
||||
// porto il punto nel riferimento della curva
|
||||
Point3d ptSloc = ptStart ;
|
||||
ptSloc.LocToLoc( frPoint, frCurve) ;
|
||||
// recupero eventuale parametro per discriminare tra più soluzioni
|
||||
// recupero eventuale parametro per discriminare tra più soluzioni
|
||||
double dNearParam ;
|
||||
if ( vsParams.size() < 5 || ! FromString( vsParams[4], dNearParam))
|
||||
dNearParam = 0 ;
|
||||
@@ -962,7 +962,7 @@ GdbExecutor::CurveCircleMake( const STRVECTOR& vsParams)
|
||||
// 5 parametri
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -996,7 +996,7 @@ GdbExecutor::CurveCirclePlaneXY( const STRVECTOR& vsParams)
|
||||
// 4 parametri
|
||||
if ( vsParams.size() != 4)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1026,7 +1026,7 @@ GdbExecutor::CurveArcMake( const STRVECTOR& vsParams)
|
||||
// 8 parametri
|
||||
if ( vsParams.size() != 8)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1072,7 +1072,7 @@ GdbExecutor::CurveArcPlaneXY( const STRVECTOR& vsParams)
|
||||
// 7 parametri
|
||||
if ( vsParams.size() != 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1114,7 +1114,7 @@ GdbExecutor::CurveArcCircle3P( const STRVECTOR& vsParams, bool bCirc)
|
||||
// 5 parametri : Id, ParentId, ptP0, ptP1, ptP2
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1148,7 +1148,7 @@ GdbExecutor::CurveArc2PDi( const STRVECTOR& vsParams)
|
||||
// 5 parametri : Id, ParentId, ptPi, ptPf, dDiri
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1164,7 +1164,7 @@ GdbExecutor::CurveArc2PDi( const STRVECTOR& vsParams)
|
||||
double dDirI ;
|
||||
if ( ! GetDirParam( vsParams[4], frRef, dDirI))
|
||||
return false ;
|
||||
// calcolo l'arco (in casi particolari può essere una retta)
|
||||
// calcolo l'arco (in casi particolari può essere una retta)
|
||||
ICurve* pCurve = GetArc2PD( ptPi, ptPf, dDirI) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
@@ -1179,7 +1179,7 @@ GdbExecutor::CurveArc2PRS( const STRVECTOR& vsParams)
|
||||
// 5 o 6 parametri : Id, ParentId, ptPi, ptPf, dRad[, CCW/CW]
|
||||
if ( vsParams.size() != 5 && vsParams.size() != 6)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1217,7 +1217,7 @@ GdbExecutor::CurveArcC2P( const STRVECTOR& vsParams)
|
||||
// 5 parametri : Id, ParentId, ptCen, ptPi, ptNearPf
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1251,7 +1251,7 @@ GdbExecutor::CurveCircleCenterTgArc( const STRVECTOR& vsParams)
|
||||
// 5 parametri : Id, ParentId, ptCen, IdArc, ptNear
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frDest ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
|
||||
return false ;
|
||||
@@ -1297,7 +1297,7 @@ GdbExecutor::CurveArcCenterTgArcP( const STRVECTOR& vsParams)
|
||||
// 6 parametri : Id, ParentId, ptCen, IdArc, ptNearTg, ptNearEnd
|
||||
if ( vsParams.size() != 6)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frDest ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
|
||||
return false ;
|
||||
@@ -1349,7 +1349,7 @@ GdbExecutor::CurveArcPDiTgArc( const STRVECTOR& vsParams)
|
||||
// 6 parametri : Id, ParentId, ptStart, dirStart, IdArc, ptNear
|
||||
if ( vsParams.size() != 6)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frDest ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
|
||||
return false ;
|
||||
@@ -1382,7 +1382,7 @@ GdbExecutor::CurveArcPDiTgArc( const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
Point3d ptNtloc = ptNear ;
|
||||
ptNtloc.LocToLoc( frDest, frTgArc) ;
|
||||
// calcolo l'arco (in casi particolari può essere una linea)
|
||||
// calcolo l'arco (in casi particolari può essere una linea)
|
||||
ICurve* pCurve = GetArcPntDirTgCurve( ptSloc, FromPolar( 1, dDirI), *pTgArc, ptNtloc, Z_AX) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
@@ -1521,7 +1521,7 @@ GdbExecutor::ExecuteCurveBez( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// inizializzo la curva di Bezier
|
||||
if ( ! pCrvBez->Init( nDeg, false))
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immersa
|
||||
// recupero il riferimento in cui è immersa
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1547,7 +1547,7 @@ GdbExecutor::ExecuteCurveBez( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// inizializzo la curva di Bezier
|
||||
if ( ! pCrvBez->Init( nDeg, true))
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immersa
|
||||
// recupero il riferimento in cui è immersa
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1949,7 +1949,7 @@ GdbExecutor::CurveCompoFromPolygon( const STRVECTOR& vsParams, int nType)
|
||||
int nNumLati ;
|
||||
if ( ! FromString( vsParams[2], nNumLati))
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1994,7 +1994,7 @@ GdbExecutor::CurveCompoFromBiarc( const STRVECTOR& vsParams)
|
||||
// 6 o 7 parametri : Id, IdParent, ptP1, Dir1, ptP2, Dir2 [, Par]
|
||||
if ( vsParams.size() != 6 && vsParams.size() != 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -2074,7 +2074,7 @@ GdbExecutor::CurveCompoExtractCurve( const STRVECTOR& vsParams, bool bEndOrStart
|
||||
Frame3d frSou ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdCCompo, frSou))
|
||||
return false ;
|
||||
// estraggo la opportuna entità
|
||||
// estraggo la opportuna entità
|
||||
PtrOwner<ICurve> pCrv( pCrvCompo->RemoveFirstOrLastCurve( bEndOrStart)) ;
|
||||
// se 1 solo parametro -> cancellazione
|
||||
if ( vsParams.size() == 1)
|
||||
@@ -2161,7 +2161,7 @@ GdbExecutor::ExecuteSurfTriMesh( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
else if ( sCmd2 == "COMP" || sCmd2 == "DOCOMPACTING") {
|
||||
return SurfTriMeshDoCompacting( vsParams) ;
|
||||
}
|
||||
// se unione di due o più superfici per cucitura
|
||||
// se unione di due o più superfici per cucitura
|
||||
else if ( sCmd2 == "SEW" || sCmd2 == "DOSEWING") {
|
||||
return SurfTriMeshDoSewing( vsParams) ;
|
||||
}
|
||||
@@ -2395,7 +2395,7 @@ GdbExecutor::SurfTriMeshByExtrusion( const STRVECTOR& vsParams)
|
||||
CurveLocal CrvLoc( m_pGDB, nCrvId, frDest) ;
|
||||
if ( CrvLoc.Get() == nullptr)
|
||||
return false ;
|
||||
// recupero il vettore di estrusione (già in locale)
|
||||
// recupero il vettore di estrusione (già in locale)
|
||||
Vector3d vtExtr ;
|
||||
if ( ! GetVectorParam( vsParams[3], frDest, vtExtr))
|
||||
return false ;
|
||||
@@ -2471,7 +2471,7 @@ GdbExecutor::SurfTriMeshByScrewing( bool bMove, const STRVECTOR& vsParams)
|
||||
// recupero la tolleranza lineare
|
||||
if ( vsParams.size() == 7)
|
||||
FromString( vsParams[6], dLinTol) ;
|
||||
// non c'é movimento lungo l'asse
|
||||
// non c'é movimento lungo l'asse
|
||||
}
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frDest ;
|
||||
@@ -2642,7 +2642,7 @@ GdbExecutor::SurfTrimeshClonePart( const STRVECTOR& vsParams)
|
||||
// Parametri : IdNew, IdOld, IdParent, nPart
|
||||
if ( vsParams.size() != 4)
|
||||
return false ;
|
||||
// Recupero il riferimento in cui è immerso
|
||||
// Recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[2]), frRef))
|
||||
return false ;
|
||||
@@ -2785,7 +2785,7 @@ GdbExecutor::VolZmapCreate( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptO, dLengthX, dLengthY, dLengthZ, dPrec [, bTriDexel]
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -2829,7 +2829,7 @@ GdbExecutor::VolZmapCreateFromFlatRegion( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, idCurv, dPrec, dLengthZ [, bTriDexel]
|
||||
if ( vsParams.size() < 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -2867,7 +2867,7 @@ GdbExecutor::VolZmapCreateFromTriMesh( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, idSurf, dPrec, bFlag
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -2900,7 +2900,7 @@ GdbExecutor::VolZmapMilling( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptPs, ptPe, vtVs, vtVe, dLinTol, dAngTolDeg (dLinTol e dAngTol sono per lavo con gen tool), bType
|
||||
if ( vsParams.size() != 9)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3019,7 +3019,7 @@ bool GdbExecutor::VolZmapDeepnessMeasure( const STRVECTOR& vsParams) {
|
||||
VolZmap* pZmap = GetBasicVolZmap( m_pGDB->GetGeoObj( nZmapId)) ;
|
||||
if ( pZmap == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso lo Zmap
|
||||
// recupero il riferimento in cui è immerso lo Zmap
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3051,7 +3051,7 @@ GdbExecutor::VolZmapBBoxZmapIntersection( const STRVECTOR& vsParams)
|
||||
VolZmap* pZmap = GetBasicVolZmap( m_pGDB->GetGeoObj( nZmapId)) ;
|
||||
if ( pZmap == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso lo Zmap
|
||||
// recupero il riferimento in cui è immerso lo Zmap
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3096,7 +3096,7 @@ GdbExecutor::VolZmapBBoxZmapIntersection( const STRVECTOR& vsParams)
|
||||
// VolZmap* pZmap = GetBasicVolZmap( m_pGDB->GetGeoObj( nZmapId)) ;
|
||||
// if ( pZmap == nullptr)
|
||||
// return false ;
|
||||
// // recupero il riferimento in cui è immerso lo Zmap
|
||||
// // recupero il riferimento in cui è immerso lo Zmap
|
||||
// Frame3d frRef ;
|
||||
// if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
// return false ;
|
||||
@@ -3143,7 +3143,7 @@ GdbExecutor::VolZmapBBoxZmapIntersection( const STRVECTOR& vsParams)
|
||||
// VolZmap* pZmap = GetBasicVolZmap( m_pGDB->GetGeoObj( nZmapId)) ;
|
||||
// if ( pZmap == nullptr)
|
||||
// return false;
|
||||
// // recupero il riferimento in cui è immerso lo Zmap
|
||||
// // recupero il riferimento in cui è immerso lo Zmap
|
||||
// Frame3d frRef ;
|
||||
// if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
// return false ;
|
||||
@@ -3213,7 +3213,7 @@ GdbExecutor::LineDiscInters( const STRVECTOR& vsParams)
|
||||
{ // parametri : Id, IdParent, ptDisc, ptLine, vtDisc, vtLine, dRad
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3281,7 +3281,7 @@ GdbExecutor::RayDiscInters( const STRVECTOR& vsParams)
|
||||
{ // parametri : Id, IdParent, ptDisc, ptLine, vtDisc, vtLine, dRad
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3349,7 +3349,7 @@ GdbExecutor::SegmentDiscInters( const STRVECTOR& vsParams)
|
||||
{ // parametri : Id, IdParent, ptDisc, ptLine, vtDisc, vtLine, dRad, dLen
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3421,7 +3421,7 @@ GdbExecutor::LineSphereInters( const STRVECTOR& vsParams)
|
||||
{ // parametri : Id, IdParent, ptC, ptP, vtV, dRad
|
||||
if ( vsParams.size() < 6)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3472,7 +3472,7 @@ GdbExecutor::RaySphereInters( const STRVECTOR& vsParams)
|
||||
{ // parametri : Id, IdParent, ptC, ptP, vtV, dRad
|
||||
if ( vsParams.size() < 6)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3530,7 +3530,7 @@ GdbExecutor::SegmentSphereInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptC, ptP, vtV, dRad, dLen
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3594,7 +3594,7 @@ GdbExecutor::LineSemiSphereInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptC, ptP, vtSphOr, vtV, dRad
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3651,7 +3651,7 @@ GdbExecutor::RaySemiSphereInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptC, ptP, vtSphOr, vtV, dRad
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3714,7 +3714,7 @@ GdbExecutor::SegmentSemiSphereInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptC, ptP, vtSphOr, vtV, dRad, dLen
|
||||
if ( vsParams.size() < 8)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3783,7 +3783,7 @@ GdbExecutor::LinCompSemiSphereInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptC, ptP, vtSphOr, vtV, dRad, dLen, nLinType
|
||||
if ( vsParams.size() < 9)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3854,7 +3854,7 @@ GdbExecutor::LineInfiniteCylinderInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptCyl, ptLine, vtCyl, vtLine, dRad
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3923,7 +3923,7 @@ GdbExecutor::RayInfiniteCylinderInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptCyl, ptLine, vtCyl, vtLine, dRad
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3992,7 +3992,7 @@ GdbExecutor::SegmentInfiniteCylinderInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptCyl, ptLine, vtCyl, vtLine, dRad, dLen
|
||||
if ( vsParams.size() < 8)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4064,7 +4064,7 @@ GdbExecutor::SegmentCylinderInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptCyl, ptLine, vtCyl, vtLine, dRad, dCylHeigth, dLen
|
||||
if ( vsParams.size() < 9)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4140,7 +4140,7 @@ GdbExecutor::SegmentConeInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptVCone, ptLine, vtCone, vtLine, dRad, dCylHeigth, dLen
|
||||
if ( vsParams.size() < 9)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4221,7 +4221,7 @@ GdbExecutor::LineTruncateConeInters( const STRVECTOR& vsParams)
|
||||
{ // parametri : Id, IdParent, ptMinBase, ptLine, vtCone, vtLine, dMinRad, dMaxRad, dConeHeigth
|
||||
if ( vsParams.size() < 9)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4303,7 +4303,7 @@ GdbExecutor::RayTruncateConeInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptMinBase, ptLine, vtCone, vtLine, dMinRad, dMaxRad, dConeHeigth
|
||||
if ( vsParams.size() < 9)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4384,7 +4384,7 @@ GdbExecutor::SegmentTruncateConeInters( const STRVECTOR& vsParams)
|
||||
{ // parametri : Id, IdParent, ptMinBase, ptLine, vtCone, vtLine, dMinRad, dMaxRad, dConeHeigth
|
||||
if ( vsParams.size() < 10)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4469,7 +4469,7 @@ GdbExecutor::LineTorusInters( const STRVECTOR& vsParams)
|
||||
{ // parametri : Id, IdParent, ptTorus, ptLine, vtTorus, vtLine, dMinRad, dMaxRad,
|
||||
if ( vsParams.size() < 8)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4584,7 +4584,7 @@ GdbExecutor::RayTorusInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptTorus, ptLine, vtTorus, vtLine, dMinRad, dMaxRad,
|
||||
if ( vsParams.size() < 8)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4734,7 +4734,7 @@ GdbExecutor::SegmentTorusInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptTorus, ptLine, vtTorus, vtLine, dMinRad, dMaxRad, dSgLen
|
||||
if ( vsParams.size() < 9)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4903,7 +4903,7 @@ GdbExecutor::LinCompTorusPartInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptTorus, ptLine, vtTorus, vtLine, dMinRad, dMaxRad, dSgLen, nLinType
|
||||
if ( vsParams.size() < 10)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -5124,7 +5124,7 @@ GdbExecutor::ExecuteDistPointTrimesh( const std::string& sCmd2, const STRVECTOR&
|
||||
// parametri : Id, IdMovedTria, IdParent, ptP, idSurf
|
||||
if ( vsParams.size() != 4)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -5228,7 +5228,7 @@ GdbExecutor::TextSimple( const STRVECTOR& vsParams)
|
||||
// parametri : Id, ParentId, Text, Point, AngDeg, H
|
||||
if ( vsParams.size() != 6)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -5266,7 +5266,7 @@ GdbExecutor::TextComplete( const STRVECTOR& vsParams)
|
||||
// parametri : Id, ParentId, Text, Point, AngDeg, Font, W, Italic, H, Rat, AddAdv, PosIns
|
||||
if ( vsParams.size() != 12)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -5486,7 +5486,7 @@ GdbExecutor::AddGeoObj( const string& sId, const string& sIdParent, IGeoObj* pGe
|
||||
// creo il gruppo
|
||||
int nId = GetIdParam( sId, true) ;
|
||||
int nIdNew = m_pGDB->AddGeoObj( nId, GetIdParam( sIdParent), pGeoObj) ;
|
||||
// se nId da calcolare, può essere una variabile a cui cambiare il valore
|
||||
// se nId da calcolare, può essere una variabile a cui cambiare il valore
|
||||
if ( nId == GDB_ID_NULL)
|
||||
m_pParser->SetVariable( sId, nIdNew) ;
|
||||
|
||||
@@ -5600,9 +5600,9 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
|
||||
// ci deve essere almeno un parametro
|
||||
if ( vsParams.size() < 1)
|
||||
return false ;
|
||||
// recupero l'indice dell'entità indicata dal primo parametro
|
||||
// recupero l'indice dell'entità indicata dal primo parametro
|
||||
int nIdEnt = GetIdParam( vsParams[0]) ;
|
||||
// recupero il riferimento in cui è immersa
|
||||
// recupero il riferimento in cui è immersa
|
||||
Frame3d frEnt ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdEnt, frEnt))
|
||||
return false ;
|
||||
@@ -5623,7 +5623,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se entità geometrica
|
||||
// se entità geometrica
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = m_pGDB->GetGeoObj( nIdEnt)) != nullptr) {
|
||||
// se curva
|
||||
@@ -5659,7 +5659,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
|
||||
return false ;
|
||||
return vtV.LocToLoc( frEnt, frVect) ;
|
||||
}
|
||||
case 'N' : // versore direzione nel punto più vicino a punto dato
|
||||
case 'N' : // versore direzione nel punto più vicino a punto dato
|
||||
{
|
||||
// secondo parametro : punto di riferimento
|
||||
Point3d ptRef ;
|
||||
@@ -5669,7 +5669,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
|
||||
ICurve::Side nSide = ICurve::FROM_MINUS ;
|
||||
if ( vsParams.size() >= 3 && vsParams[2] == "+")
|
||||
nSide = ICurve::FROM_PLUS ;
|
||||
// calcolo il parametro del punto della curva più vicino al punto di riferimento
|
||||
// calcolo il parametro del punto della curva più vicino al punto di riferimento
|
||||
DistPointCurve dstPC( ptRef, *pCrv) ;
|
||||
int nFlag ;
|
||||
double dU ;
|
||||
@@ -5723,7 +5723,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
// altrimenti nome di vettore già nel DB
|
||||
// altrimenti nome di vettore già nel DB
|
||||
else {
|
||||
int nIdEnt = GetIdParam( sParam) ;
|
||||
const IGeoVector3d* pV ;
|
||||
@@ -5742,7 +5742,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
|
||||
bool
|
||||
GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d& ptP)
|
||||
{
|
||||
// se insieme di 2 o 3 coordinate (considerate già nel riferimento frPnt)
|
||||
// se insieme di 2 o 3 coordinate (considerate già nel riferimento frPnt)
|
||||
if ( sParam[0] == '(') {
|
||||
// divido in parti
|
||||
STRVECTOR vsParams ;
|
||||
@@ -5766,7 +5766,7 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
// se altrimenti punto predefinito ORIG (considerato già nel riferimento frPnt)
|
||||
// se altrimenti punto predefinito ORIG (considerato già nel riferimento frPnt)
|
||||
else if ( sParam == "ORIG") {
|
||||
ptP = ORIG ;
|
||||
return true ;
|
||||
@@ -5784,9 +5784,9 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
// ci deve essere almeno un parametro
|
||||
if ( vsParams.size() < 1)
|
||||
return false ;
|
||||
// recupero l'indice dell'entità indicata dal primo parametro
|
||||
// recupero l'indice dell'entità indicata dal primo parametro
|
||||
int nIdEnt = GetIdParam( vsParams[0]) ;
|
||||
// recupero il riferimento in cui è immersa
|
||||
// recupero il riferimento in cui è immersa
|
||||
Frame3d frEnt ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdEnt, frEnt))
|
||||
return false ;
|
||||
@@ -5801,7 +5801,7 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se entità geometrica
|
||||
// se entità geometrica
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = m_pGDB->GetGeoObj( nIdEnt)) != nullptr) {
|
||||
// se curva
|
||||
@@ -5835,13 +5835,13 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
return false ;
|
||||
return ptP.LocToLoc( frEnt, frPnt) ;
|
||||
}
|
||||
case 'N' : // punto più vicino a punto dato
|
||||
case 'N' : // punto più vicino a punto dato
|
||||
{
|
||||
// secondo parametro : punto di riferimento
|
||||
Point3d ptRef ;
|
||||
if ( vsParams.size() < 2 || ! GetPointParam( vsParams[1], frEnt, ptRef))
|
||||
return false ;
|
||||
// calcolo il punto della curva più vicino al punto di riferimento
|
||||
// calcolo il punto della curva più vicino al punto di riferimento
|
||||
DistPointCurve dstPC( ptRef, *pCrv) ;
|
||||
int nFlag ;
|
||||
if ( ! dstPC.GetMinDistPoint( 0, ptP, nFlag))
|
||||
@@ -5859,11 +5859,11 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
const ICurve* pCrv2 = GetCurve( pGObj2) ;
|
||||
if ( pCrv2 == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immersa
|
||||
// recupero il riferimento in cui è immersa
|
||||
Frame3d frEnt2 ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdEnt2, frEnt2))
|
||||
return false ;
|
||||
// se il riferimento è diverso da quello della prima entità, devo trasformarla
|
||||
// se il riferimento è diverso da quello della prima entità, devo trasformarla
|
||||
PtrOwner<ICurve> pcrvTrans( nullptr) ;
|
||||
if ( ! AreSameFrame( frEnt, frEnt2)) {
|
||||
pcrvTrans.Set( pCrv2->Clone()) ;
|
||||
@@ -5876,7 +5876,7 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
Point3d ptRef ;
|
||||
if ( vsParams.size() >= 3 && ! GetPointParam( vsParams[2], frEnt, ptRef))
|
||||
return false ;
|
||||
// calcolo il punto di intersezione sulla prima curva più vicino al punto di riferimento
|
||||
// calcolo il punto di intersezione sulla prima curva più vicino al punto di riferimento
|
||||
IntersCurveCurve intCC( *pCrv, *pCrv2, true) ;
|
||||
if ( ! intCC.GetIntersPointNearTo( 0, ptRef, ptP))
|
||||
return false ;
|
||||
@@ -5938,7 +5938,7 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
// altrimenti nome di punto già nel DB
|
||||
// altrimenti nome di punto già nel DB
|
||||
else {
|
||||
int nIdEnt = GetIdParam( sParam) ;
|
||||
const IGeoPoint3d* pPt ;
|
||||
@@ -6015,7 +6015,7 @@ GdbExecutor::GetPointWParam( const string& sParam, const Frame3d& frPnt, Point3d
|
||||
FromString( vsParams[1], ptP.y) &&
|
||||
FromString( vsParams[2], dW)) ;
|
||||
}
|
||||
// se 2 parti, nome di punto predefinito, punto notevole o già nel DB e un peso
|
||||
// se 2 parti, nome di punto predefinito, punto notevole o già nel DB e un peso
|
||||
else if ( vsParams.size() == 2) {
|
||||
// recupero il punto
|
||||
if ( ! GetPointParam( vsParams[0], frPnt, ptP))
|
||||
@@ -6065,7 +6065,7 @@ GdbExecutor::GetLengthParam( const string& sParam, double& dLen)
|
||||
// ci deve essere almeno un parametro
|
||||
if ( vsParams.size() < 1)
|
||||
return false ;
|
||||
// recupero l'entità indicata dal primo parametro
|
||||
// recupero l'entità indicata dal primo parametro
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = m_pGDB->GetGeoObj( GetIdParam( vsParams[0]))) == nullptr)
|
||||
return false ;
|
||||
@@ -6088,7 +6088,7 @@ GdbExecutor::GetLengthParam( const string& sParam, double& dLen)
|
||||
// ci deve essere almeno un parametro
|
||||
if ( vsParams.size() < 1)
|
||||
return false ;
|
||||
// recupero l'entità indicata dal primo parametro
|
||||
// recupero l'entità indicata dal primo parametro
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = m_pGDB->GetGeoObj( GetIdParam( vsParams[0]))) == nullptr)
|
||||
return false ;
|
||||
@@ -6124,12 +6124,12 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
|
||||
// ci deve essere almeno un parametro
|
||||
if ( vsParams.size() < 1)
|
||||
return false ;
|
||||
// recupero l'entità indicata dal primo parametro
|
||||
// recupero l'entità indicata dal primo parametro
|
||||
int nIdEnt = GetIdParam( vsParams[0]) ;
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = m_pGDB->GetGeoObj( nIdEnt)) == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immersa
|
||||
// recupero il riferimento in cui è immersa
|
||||
Frame3d frEnt ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdEnt, frEnt))
|
||||
return false ;
|
||||
@@ -6143,7 +6143,7 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
|
||||
if ( ! pCrv->GetStartDir( vtDir) || ! vtDir.LocToLoc( frEnt, frDir))
|
||||
return false ;
|
||||
vtDir.ToSpherical( nullptr, nullptr, &dDir) ;
|
||||
// se esiste un secondo parametro è un offset di rotazione
|
||||
// se esiste un secondo parametro è un offset di rotazione
|
||||
if ( vsParams.size() >= 2) {
|
||||
double dOffsetDeg = 0 ;
|
||||
FromString( vsParams[1], dOffsetDeg) ;
|
||||
@@ -6154,7 +6154,7 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
|
||||
if ( ! pCrv->GetEndDir( vtDir) || ! vtDir.LocToLoc( frEnt, frDir))
|
||||
return false ;
|
||||
vtDir.ToSpherical( nullptr, nullptr, &dDir) ;
|
||||
// se esiste un secondo parametro è un offset di rotazione
|
||||
// se esiste un secondo parametro è un offset di rotazione
|
||||
if ( vsParams.size() >= 2) {
|
||||
double dOffsetDeg = 0 ;
|
||||
FromString( vsParams[1], dOffsetDeg) ;
|
||||
@@ -6165,7 +6165,7 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
|
||||
if ( ! pCrv->GetMidDir( vtDir) || ! vtDir.LocToLoc( frEnt, frDir))
|
||||
return false ;
|
||||
vtDir.ToSpherical( nullptr, nullptr, &dDir) ;
|
||||
// se esiste un secondo parametro è un offset di rotazione
|
||||
// se esiste un secondo parametro è un offset di rotazione
|
||||
if ( vsParams.size() >= 2) {
|
||||
double dOffsetDeg = 0 ;
|
||||
FromString( vsParams[1], dOffsetDeg) ;
|
||||
@@ -6196,7 +6196,7 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
case 'N' : // versore direzione nel punto più vicino a punto dato
|
||||
case 'N' : // versore direzione nel punto più vicino a punto dato
|
||||
{
|
||||
// secondo parametro : punto di riferimento
|
||||
Point3d ptRef ;
|
||||
@@ -6206,7 +6206,7 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
|
||||
ICurve::Side nSide = ICurve::FROM_MINUS ;
|
||||
if ( vsParams.size() >= 3 && vsParams[2] == "+")
|
||||
nSide = ICurve::FROM_PLUS ;
|
||||
// calcolo il parametro del punto della curva più vicino al punto di riferimento
|
||||
// calcolo il parametro del punto della curva più vicino al punto di riferimento
|
||||
DistPointCurve dstPC( ptRef, *pCrv) ;
|
||||
int nFlag ;
|
||||
double dU ;
|
||||
@@ -6236,7 +6236,7 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
|
||||
Vector3d vtDir = pGVect->GetVector() ;
|
||||
vtDir.LocToLoc( frEnt, frDir) ;
|
||||
vtDir.ToSpherical( nullptr, nullptr, &dDir) ;
|
||||
// se esiste un secondo parametro è un offset di rotazione
|
||||
// se esiste un secondo parametro è un offset di rotazione
|
||||
if ( vsParams.size() >= 2) {
|
||||
double dOffsetDeg = 0 ;
|
||||
FromString( vsParams[1], dOffsetDeg) ;
|
||||
@@ -6294,7 +6294,7 @@ GdbExecutor::GetFrameParam( const string& sParam, const Frame3d& frRef, Frame3d&
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n") ;
|
||||
// se c'è un parametro è l'origine
|
||||
// se c'è un parametro è l'origine
|
||||
Point3d ptOrig ;
|
||||
if ( vsParams.size() >= 1) {
|
||||
if ( ! GetPointParam( vsParams[0], frRef, ptOrig))
|
||||
@@ -6325,11 +6325,11 @@ GdbExecutor::GetFrameParam( const string& sParam, const Frame3d& frRef, Frame3d&
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
// altrimenti nome di gruppo o di frame già nel DB
|
||||
// altrimenti nome di gruppo o di frame già nel DB
|
||||
else {
|
||||
// identificativo
|
||||
int nIdEnt = GetIdParam( sParam) ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frEnt ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdEnt, frEnt))
|
||||
return false ;
|
||||
@@ -6337,7 +6337,7 @@ GdbExecutor::GetFrameParam( const string& sParam, const Frame3d& frRef, Frame3d&
|
||||
if ( m_pGDB->GetGroupFrame( nIdEnt, frF)) {
|
||||
return frF.LocToLoc( frEnt, frRef) ;
|
||||
}
|
||||
// altrimenti entità geometrica
|
||||
// altrimenti entità geometrica
|
||||
else {
|
||||
// verifico se riferimento
|
||||
const IGeoFrame3d* pFr ;
|
||||
@@ -6393,7 +6393,7 @@ GdbExecutor::GetColorParam( const string& sParam, bool& bByParent, Color& cCol)
|
||||
// ci deve essere un parametro
|
||||
if ( vsParams.size() != 1)
|
||||
return false ;
|
||||
// recupero il colore dell'entità indicata dal parametro
|
||||
// recupero il colore dell'entità indicata dal parametro
|
||||
bByParent = false ;
|
||||
return m_pGDB->GetCalcMaterial( GetIdParam( vsParams[0]), cCol) ;
|
||||
}
|
||||
@@ -6427,7 +6427,7 @@ GdbExecutor::GetMaterialParam( const string& sParam, bool& bByParent, int& nMat)
|
||||
// ci deve essere un parametro
|
||||
if ( vsParams.size() != 1)
|
||||
return false ;
|
||||
// recupero il materiale dell'entità indicata dal parametro
|
||||
// recupero il materiale dell'entità indicata dal parametro
|
||||
bByParent = false ;
|
||||
return ( m_pGDB->GetCalcMaterial( GetIdParam( vsParams[0]), nMat) && nMat != GDB_MT_COLOR) ;
|
||||
}
|
||||
@@ -6975,7 +6975,7 @@ GdbExecutor::ExecuteCopy( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
nIdNew = m_pGDB->CopyGlob( GetIdParam( vsParams[0]), nIdDest, GetIdParam( vsParams[2]), nSonBeforeAfter) ;
|
||||
else
|
||||
nIdNew = m_pGDB->Copy( GetIdParam( vsParams[0]), nIdDest, GetIdParam( vsParams[2]), nSonBeforeAfter) ;
|
||||
// se IdDest da calcolare, può essere una variabile a cui cambiare il valore
|
||||
// se IdDest da calcolare, può essere una variabile a cui cambiare il valore
|
||||
if ( nIdDest == GDB_ID_NULL)
|
||||
m_pParser->SetVariable( vsParams[1], nIdNew) ;
|
||||
|
||||
@@ -7647,7 +7647,7 @@ GdbExecutor::CurveCopyBySplitClass( const STRVECTOR& vsParams)
|
||||
IntersCurveCurve intCC( *pCrv, *pCloCrv, true) ;
|
||||
// recupero la classificazione della prima curva
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( ! intCC.GetCurveClassification( 0, EPS_SMALL, ccClass))
|
||||
if ( ! intCC.GetCurveClassification( 0, ccClass))
|
||||
return false ;
|
||||
// recupero gli indici dei gruppi destinazione e i loro riferimenti
|
||||
const int N_GRP = 4 ;
|
||||
@@ -7877,7 +7877,7 @@ GdbExecutor::ExecuteOutTextIcci( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// devono essere 6 parametri : IdText, IdGroup, IdEnt1, IdEnt2, ptText, hText
|
||||
if ( vsParams.size() != 6)
|
||||
return false ;
|
||||
// recupero l'indice delle entità
|
||||
// recupero l'indice delle entità
|
||||
int nIdEnt1 = GetIdParam( vsParams[2]) ;
|
||||
int nIdEnt2 = GetIdParam( vsParams[3]) ;
|
||||
// verifico siano due curve
|
||||
@@ -7894,7 +7894,7 @@ GdbExecutor::ExecuteOutTextIcci( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
Frame3d frEnt2 ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdEnt2, frEnt2))
|
||||
return false ;
|
||||
// se i riferimenti sono diversi, porto la seconda entità nel riferimento della prima
|
||||
// se i riferimenti sono diversi, porto la seconda entità nel riferimento della prima
|
||||
PtrOwner<ICurve> pcrvTrans ;
|
||||
if ( ! AreSameFrame( frEnt1, frEnt2)) {
|
||||
pcrvTrans.Set( pCrv2->Clone()) ;
|
||||
@@ -7921,7 +7921,7 @@ GdbExecutor::ExecuteOutTextIcci( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
sText += "<br/> " ;
|
||||
sText += " U=" + ToString( aInfo.IciA[j].dU,7) + " P=(" + ToString( aInfo.IciA[j].ptI,4) + ")" ;
|
||||
switch( aInfo.IciA[j].nPrevTy) {
|
||||
case ICCT_NULL : sText += " ?" "?-" ; break ;
|
||||
case ICCT_NULL : sText += " ??-" ; break ;
|
||||
case ICCT_IN : sText += " IN-" ; break ;
|
||||
case ICCT_OUT : sText += " OUT-" ; break ;
|
||||
case ICCT_ON : sText += " ON-" ; break ;
|
||||
@@ -7940,7 +7940,7 @@ GdbExecutor::ExecuteOutTextIcci( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
sText += string( "<br/>") + ( aInfo.bCBOverEq ? " + " : " - ") ;
|
||||
sText += " U=" + ToString( aInfo.IciB[j].dU,7) + " P=(" + ToString( aInfo.IciB[j].ptI,4) + ")" ;
|
||||
switch( aInfo.IciB[j].nPrevTy) {
|
||||
case ICCT_NULL : sText += " ?" "?-" ; break ;
|
||||
case ICCT_NULL : sText += " ??-" ; break ;
|
||||
case ICCT_IN : sText += " IN-" ; break ;
|
||||
case ICCT_OUT : sText += " OUT-" ; break ;
|
||||
case ICCT_ON : sText += " ON-" ; break ;
|
||||
@@ -7953,7 +7953,7 @@ GdbExecutor::ExecuteOutTextIcci( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
}
|
||||
}
|
||||
}
|
||||
// recupero il riferimento in cui è immerso il testo
|
||||
// recupero il riferimento in cui è immerso il testo
|
||||
Frame3d frText ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frText))
|
||||
return false ;
|
||||
@@ -8090,7 +8090,7 @@ bool
|
||||
GdbExecutor::OutGroupTsc( int nId, int nFlag, int nLev)
|
||||
{
|
||||
m_OutTsc.Remark( "Start Group ---") ;
|
||||
// emetto dati gruppo ( se non è radice)
|
||||
// emetto dati gruppo ( se non è radice)
|
||||
if ( nId > GDB_ID_ROOT) {
|
||||
Frame3d frFrame ;
|
||||
if ( ( nLev == 0 && m_pGDB->GetGroupGlobFrame( nId, frFrame)) ||
|
||||
@@ -8113,7 +8113,7 @@ GdbExecutor::OutGroupTsc( int nId, int nFlag, int nLev)
|
||||
}
|
||||
}
|
||||
}
|
||||
// emetto entità gruppo
|
||||
// emetto entità gruppo
|
||||
m_OutTsc.Remark( "Entities :") ;
|
||||
GdbIterator Iter( m_pGDB) ;
|
||||
bool bNext = Iter.GoToFirstInGroup( nId) ;
|
||||
|
||||
+2
-2
@@ -14,10 +14,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "OutTsc.h"
|
||||
#include "/EgtDev/Include/EGkGdbExecutor.h"
|
||||
#include "/EgtDev/Include/EgkGdbExecutor.h"
|
||||
#include "/EgtDev/Include/EgtPerfCounter.h"
|
||||
#include "/EgtDev/Include/EgtExecMgr.h"
|
||||
#include "/EgtDev/Include/EGkGeoCollection.h"
|
||||
#include "/EgtDev/Include/EgkGeoCollection.h"
|
||||
#include "Tool.h"
|
||||
|
||||
class PolyLine ;
|
||||
|
||||
@@ -1618,39 +1618,6 @@ GdbIterator::RemoveInfo( const string& sKey)
|
||||
return m_pCurrObj->RemoveInfo( sKey) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::GetAllInfo( STRVECTOR& vsInfo) const
|
||||
{
|
||||
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
|
||||
return false ;
|
||||
|
||||
// recupero tutte le Info
|
||||
return m_pCurrObj->GetAllInfo( vsInfo) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::CopyAllInfoFrom( const IGdbIterator& iIter)
|
||||
{
|
||||
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
|
||||
return false ;
|
||||
|
||||
// recupero l'oggetto sorgente
|
||||
const GdbIterator* pIter = dynamic_cast<const GdbIterator*> (&iIter) ;
|
||||
if ( pIter == nullptr || pIter->m_pGDB != m_pGDB || pIter->m_pCurrObj == nullptr)
|
||||
return false ;
|
||||
const GdbObj* pGdbObjSou = pIter->m_pCurrObj ;
|
||||
|
||||
// copio tutte le Info
|
||||
if ( m_pCurrObj != pGdbObjSou && pGdbObjSou->m_pAttribs != nullptr) {
|
||||
m_pCurrObj->GetSafeAttribs() ;
|
||||
return ( m_pCurrObj->m_pAttribs != nullptr && m_pCurrObj->m_pAttribs->CopyAllInfoFrom( *(pGdbObjSou->m_pAttribs))) ;
|
||||
}
|
||||
else
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// TextureData
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+2
-4
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2022
|
||||
// EgalTech 2013-2013
|
||||
//----------------------------------------------------------------------------
|
||||
// File : GdbIterator.h Data : 29.01.23 Versione : 2.5a2
|
||||
// File : GdbIterator.h Data : 04.12.13 Versione : 1.4a3
|
||||
// Contenuto : Dichiarazione della classe GdbIterator.
|
||||
//
|
||||
//
|
||||
@@ -142,8 +142,6 @@ class GdbIterator : public IGdbIterator
|
||||
bool GetInfo( const std::string& sKey, STRVECTOR& vsInfo) const override ;
|
||||
bool ExistsInfo( const std::string& sKey) const override ;
|
||||
bool RemoveInfo( const std::string& sKey) override ;
|
||||
bool GetAllInfo( STRVECTOR& vsInfo) const override ;
|
||||
bool CopyAllInfoFrom( const IGdbIterator& iIter) override ;
|
||||
// TextureData
|
||||
bool SetTextureName( const std::string& sTxrName) override ;
|
||||
bool SetTextureFrame( const Frame3d& frTxrRef) override ;
|
||||
|
||||
+2
-16
@@ -32,9 +32,8 @@ using namespace std ;
|
||||
//----------------------------------------------------------------------------
|
||||
GdbObj::GdbObj( void)
|
||||
: m_nId( GDB_ID_NULL), m_pAttribs( nullptr), m_pTxrData( nullptr), m_pUserObj( nullptr),
|
||||
m_pGDB( nullptr), m_pNext( nullptr), m_pPrev( nullptr), m_pParent( nullptr),
|
||||
m_pSelNext( nullptr), m_pSelPrev( nullptr)
|
||||
|
||||
m_pSelPrev( nullptr), m_pSelNext( nullptr),
|
||||
m_pGDB( nullptr), m_pNext( nullptr), m_pPrev( nullptr), m_pParent( nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1024,19 +1023,6 @@ GdbObj::RemoveInfo( const string& sKey)
|
||||
return m_pAttribs->RemoveInfo( sKey) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbObj::GetAllInfo( STRVECTOR& vsInfo) const
|
||||
{
|
||||
// se non ci sono attributi
|
||||
if ( m_pAttribs == nullptr) {
|
||||
vsInfo.clear() ;
|
||||
return true ;
|
||||
}
|
||||
// recupero tutte le Info
|
||||
return m_pAttribs->GetAllInfo( vsInfo) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// TextureData
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -119,7 +119,6 @@ class GdbObj
|
||||
bool GetInfo( const std::string& sKey, STRVECTOR& vsInfo) const ;
|
||||
bool ExistsInfo( const std::string& sKey) const ;
|
||||
bool RemoveInfo( const std::string& sKey) ;
|
||||
bool GetAllInfo( STRVECTOR& vsInfo) const ;
|
||||
bool SaveTextureData( NgeWriter& ngeOut) const ;
|
||||
bool LoadTextureData( NgeReader& ngeIn) ;
|
||||
TextureData* GetTextureData( void)
|
||||
|
||||
+2
-6
@@ -50,11 +50,7 @@ const double BEZARC_ANG_CEN_MAX = 90 ;
|
||||
//----------------- Costanti per superfici TriMesh ---------------------------
|
||||
// tolleranza lineare standard
|
||||
const double STM_STD_LIN_TOL = 0.1 ;
|
||||
// angolo limite standard per definire un edge che è contorno di poligono
|
||||
// angolo limite per definire un edge che è contorno di poligono
|
||||
const double STM_STD_BOUNDARY_ANG = 0.1 ;
|
||||
// angolo limite standard per mediare le normali in un vertice
|
||||
// angolo limite per mediare le normali in un vertice
|
||||
const double STM_STD_SMOOTH_ANG = 25.0 ;
|
||||
// distanza limite tra diagonali per quadrilatero con twist
|
||||
const double STM_TWIST_DIAG_DIST = 1.0 ;
|
||||
// angolo limite con twist per mediare le normali in un vertice
|
||||
const double STM_TWIST_SMOOTH_ANG = 35.0 ;
|
||||
|
||||
+2
-5
@@ -29,10 +29,8 @@ GEOOBJ_REGISTER( GEO_FRAME3D, NGE_G_FRM, GeoFrame3d) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GeoFrame3d::GeoFrame3d( void)
|
||||
: m_frF()
|
||||
: m_frF(), m_nTempProp()
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -116,8 +114,7 @@ GeoFrame3d::CopyFrom( const GeoFrame3d& gfSrc)
|
||||
{
|
||||
if ( &gfSrc == this)
|
||||
return true ;
|
||||
m_nTempProp[0] = gfSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = gfSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = gfSrc.m_nTempProp ;
|
||||
return Set( gfSrc.m_frF) ;
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -57,11 +57,10 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // IGeoFrame3d
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -96,5 +95,5 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Frame3d m_frF ; // oggetto
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
+2
-5
@@ -28,10 +28,8 @@ GEOOBJ_REGISTER( GEO_PNT3D, NGE_G_PNT, GeoPoint3d) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GeoPoint3d::GeoPoint3d( void)
|
||||
: m_ptP()
|
||||
: m_ptP(), m_nTempProp()
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -84,8 +82,7 @@ GeoPoint3d::CopyFrom( const GeoPoint3d& clSrc)
|
||||
{
|
||||
if ( &clSrc == this)
|
||||
return true ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = clSrc.m_nTempProp ;
|
||||
return Set( clSrc.m_ptP) ;
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -57,11 +57,10 @@ class GeoPoint3d : public IGeoPoint3d, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // IGeoPoint3d
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -90,5 +89,5 @@ class GeoPoint3d : public IGeoPoint3d, public IGeoObjRW
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Point3d m_ptP ; // oggetto
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
+2
-5
@@ -29,10 +29,8 @@ GEOOBJ_REGISTER( GEO_VECT3D, NGE_G_VEC, GeoVector3d) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GeoVector3d::GeoVector3d( void)
|
||||
: m_vtV()
|
||||
: m_vtV(), m_nTempProp()
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -100,8 +98,7 @@ GeoVector3d::CopyFrom( const GeoVector3d& clSrc)
|
||||
{
|
||||
if ( &clSrc == this)
|
||||
return true ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = clSrc.m_nTempProp ;
|
||||
return Set( clSrc.m_vtV, clSrc.m_ptBase) ;
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -65,11 +65,10 @@ class GeoVector3d : public IGeoVector3d, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // IGeoVector3d
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -105,5 +104,5 @@ class GeoVector3d : public IGeoVector3d, public IGeoObjRW
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Vector3d m_vtV ; // oggetto
|
||||
Point3d m_ptBase ; // punto base da cui tracciare il vettore
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
+42
-68
@@ -37,25 +37,22 @@ IGeomDB*
|
||||
CreateGeomDB( void)
|
||||
{
|
||||
// verifico la chiave e le opzioni
|
||||
if ( ! GetEGkNetHwKey()) {
|
||||
unsigned int nOpt1, nOpt2 ;
|
||||
int nOptExpDays ;
|
||||
int nRet = GetKeyOptions( GetEGkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
|
||||
nOpt1, nOpt2, nOptExpDays) ;
|
||||
if ( nRet != KEY_OK && ! EqualNoCase( GetEGkKey(), "EGkBase")) {
|
||||
if ( nRet != KEY_OK) {
|
||||
string sErr = "Error on Key (GKC/" + ToString( nRet) + ")" ;
|
||||
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
|
||||
return nullptr ;
|
||||
}
|
||||
if ( (nOpt1 & KEYOPT_EGK_BASE) == 0 || nOptExpDays < GetCurrDay()) {
|
||||
string sErr = "Error on Key (GKC/OPT)" ;
|
||||
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
|
||||
return nullptr ;
|
||||
}
|
||||
unsigned int nOpt1, nOpt2 ;
|
||||
int nOptExpDays ;
|
||||
int nRet = GetKeyOptions( GetEGkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
|
||||
nOpt1, nOpt2, nOptExpDays) ;
|
||||
if ( nRet != KEY_OK && ! EqualNoCase( GetEGkKey(), "EGkBase")) {
|
||||
if ( nRet != KEY_OK) {
|
||||
string sErr = "Error on Key (GKC/" + ToString( nRet) + ")" ;
|
||||
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
|
||||
return nullptr ;
|
||||
}
|
||||
if ( (nOpt1 & KEYOPT_EGK_BASE) == 0 || nOptExpDays < GetCurrDay()) {
|
||||
string sErr = "Error on Key (GKC/OPT)" ;
|
||||
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
|
||||
return nullptr ;
|
||||
}
|
||||
}
|
||||
|
||||
// creo il GeomDB
|
||||
return static_cast<IGeomDB*> ( new( nothrow) GeomDB) ;
|
||||
}
|
||||
@@ -275,21 +272,19 @@ bool
|
||||
GeomDB::Save( int nId, const string& sFileOut, int nFlag) const
|
||||
{
|
||||
// verifico la chiave e le opzioni
|
||||
if ( ! GetEGkNetHwKey()) {
|
||||
unsigned int nOpt1, nOpt2 ;
|
||||
int nOptExpDays ;
|
||||
int nRet = GetKeyOptions( GetEGkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
|
||||
nOpt1, nOpt2, nOptExpDays) ;
|
||||
if ( nRet != KEY_OK) {
|
||||
string sErr = "Error on Key (GKS/" + ToString( nRet) + ")" ;
|
||||
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
if ( (nOpt1 & KEYOPT_EGK_SAVE) == 0 || nOptExpDays < GetCurrDay()) {
|
||||
string sErr = "Error on Key (GKS/OPT)" ;
|
||||
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
unsigned int nOpt1, nOpt2 ;
|
||||
int nOptExpDays ;
|
||||
int nRet = GetKeyOptions( GetEGkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
|
||||
nOpt1, nOpt2, nOptExpDays) ;
|
||||
if ( nRet != KEY_OK) {
|
||||
string sErr = "Error on Key (GKS/" + ToString( nRet) + ")" ;
|
||||
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
if ( (nOpt1 & KEYOPT_EGK_SAVE) == 0 || nOptExpDays < GetCurrDay()) {
|
||||
string sErr = "Error on Key (GKS/OPT)" ;
|
||||
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// assegno Id base
|
||||
@@ -387,21 +382,19 @@ bool
|
||||
GeomDB::Save( const INTVECTOR& vId, const string& sFileOut, int nFlag) const
|
||||
{
|
||||
// verifico la chiave e le opzioni
|
||||
if ( ! GetEGkNetHwKey()) {
|
||||
unsigned int nOpt1, nOpt2 ;
|
||||
int nOptExpDays ;
|
||||
int nRet = GetKeyOptions( GetEGkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
|
||||
nOpt1, nOpt2, nOptExpDays) ;
|
||||
if ( nRet != KEY_OK) {
|
||||
string sErr = "Error on Key (GKS/" + ToString( nRet) + ")" ;
|
||||
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
if ( (nOpt1 & KEYOPT_EGK_SAVE) == 0 || nOptExpDays < GetCurrDay()) {
|
||||
string sErr = "Error on Key (GKS/OPT)" ;
|
||||
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
unsigned int nOpt1, nOpt2 ;
|
||||
int nOptExpDays ;
|
||||
int nRet = GetKeyOptions( GetEGkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
|
||||
nOpt1, nOpt2, nOptExpDays) ;
|
||||
if ( nRet != KEY_OK) {
|
||||
string sErr = "Error on Key (GKS/" + ToString( nRet) + ")" ;
|
||||
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
if ( (nOpt1 & KEYOPT_EGK_SAVE) == 0 || nOptExpDays < GetCurrDay()) {
|
||||
string sErr = "Error on Key (GKS/OPT)" ;
|
||||
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// assegno Id base (nessuna riduzione degli Id)
|
||||
@@ -520,10 +513,7 @@ GeomDB::SaveHeader( NgeWriter& ngeOut) const
|
||||
|
||||
// LockId del sistema come commento
|
||||
string sLockId ;
|
||||
if ( GetEGkNetHwKey()) {
|
||||
sLockId = "NET-000000" ;
|
||||
}
|
||||
else if ( ! GetLockId( sLockId)) {
|
||||
if ( ! GetLockId( sLockId)) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error on Key (1)")
|
||||
return false ;
|
||||
}
|
||||
@@ -2531,9 +2521,6 @@ GeomDB::GetCalcMaterial( const GdbObj* pGdbObj, Material& mMat) const
|
||||
Color cCol ;
|
||||
if ( pGdbObj->GetCalcMaterial( cCol)) {
|
||||
mMat.Set( cCol) ;
|
||||
Color cDiff = cCol ;
|
||||
cDiff.Intensify( 1.25) ;
|
||||
mMat.SetDiffuse( cDiff) ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
@@ -2887,19 +2874,6 @@ GeomDB::RemoveInfo( int nId, const string& sKey)
|
||||
return pGdbObj->RemoveInfo( sKey) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::GetAllInfo( int nId, STRVECTOR& vsInfo) const
|
||||
{
|
||||
// recupero l'oggetto
|
||||
const GdbObj* pGdbObj = GetGdbObj( nId) ;
|
||||
if ( pGdbObj == nullptr)
|
||||
return false ;
|
||||
|
||||
// recupero tutte le Info
|
||||
return pGdbObj->GetAllInfo( vsInfo) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::CopyAllInfoFrom( int nId, int nSouId)
|
||||
@@ -2909,7 +2883,7 @@ GeomDB::CopyAllInfoFrom( int nId, int nSouId)
|
||||
if ( pGdbObj == nullptr)
|
||||
return false ;
|
||||
// recupero l'oggetto sorgente
|
||||
const GdbObj* pGdbObjSou = GetGdbObj( nSouId) ;
|
||||
GdbObj* pGdbObjSou = GetGdbObj( nSouId) ;
|
||||
if ( pGdbObjSou == nullptr)
|
||||
return false ;
|
||||
|
||||
|
||||
@@ -179,7 +179,6 @@ class GeomDB : public IGeomDB
|
||||
bool GetInfo( int nId, const std::string& sKey, STRVECTOR& vsInfo) const override ;
|
||||
bool ExistsInfo( int nId, const std::string& sKey) const override ;
|
||||
bool RemoveInfo( int nId, const std::string& sKey) override ;
|
||||
bool GetAllInfo( int nId, STRVECTOR& vsInfo) const override ;
|
||||
bool CopyAllInfoFrom( int nId, int nSouId) override ;
|
||||
// TextureData
|
||||
bool DumpTextureData( int nId, std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ;
|
||||
|
||||
-759
@@ -1,759 +0,0 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2018
|
||||
//----------------------------------------------------------------------------
|
||||
// File : HashGrids1d.cpp Data : 02.05.22 Versione : 2.4e1
|
||||
// Contenuto : Funzioni della classe HashGrids1d.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 04.07.15 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "DllMain.h"
|
||||
#include "/EgtDev/Include/EGkHashGrids1d.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const size_t CellCount = 16 ;
|
||||
const size_t cellVectorSize = 16 ;
|
||||
const size_t occupiedCellsVectorSize = 256 ;
|
||||
const size_t minimalGridDensity = 1 ;
|
||||
const size_t gridActivationThreshold = 64 ;
|
||||
const double hierarchyFactor = 2 ;
|
||||
const double MIN_CELL_SIZE = 5.0 ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// HashGrid1d
|
||||
//----------------------------------------------------------------------------
|
||||
class HashGrid1d
|
||||
{
|
||||
private :
|
||||
struct Cell
|
||||
{
|
||||
HashGrids1d::PtrObjVector* m_Objs ; // Vettore dei puntatori agli oggetti nella cella, come puntatore
|
||||
int* m_neighborOffset ; // Puntatore ad array con offsets per accedere direttamente ai vicini
|
||||
size_t m_occupiedCellsId ; // Indice della cella nel vettore delle celle occupate
|
||||
Cell( void)
|
||||
: m_Objs( nullptr), m_neighborOffset( nullptr), m_occupiedCellsId( 0) {}
|
||||
} ;
|
||||
|
||||
typedef vector<Cell*> CellVector ;
|
||||
|
||||
public :
|
||||
explicit HashGrid1d( double dCellSpan) ;
|
||||
~HashGrid1d( void) ;
|
||||
double GetCellSpan( void) const
|
||||
{ return m_dCellSpan ; }
|
||||
void Add( HashGrids1d::ObjData& obj) ;
|
||||
void Remove( HashGrids1d::ObjData& obj) ;
|
||||
void Update( HashGrids1d::ObjData& obj) ;
|
||||
void Find( const BBox3d& b3Test, INTVECTOR& vnIds) ;
|
||||
void Clear( void) ;
|
||||
|
||||
private :
|
||||
void InitNeighborOffsets( void) ;
|
||||
size_t Hash( const Point3d& ptP) const ;
|
||||
void Add( HashGrids1d::ObjData& obj, Cell* cell) ;
|
||||
void Remove( HashGrids1d::ObjData& obj, Cell* cell) ;
|
||||
void Enlarge( void) ;
|
||||
static inline bool PowerOfTwo( size_t number) ;
|
||||
|
||||
private :
|
||||
Cell* m_cell ; // Vettore di celle della griglia
|
||||
|
||||
size_t m_CellCount ; // Numero di celle allocate in direzione Z
|
||||
|
||||
size_t m_HashMask ; // Maschera di bit per calcolo hash
|
||||
|
||||
size_t m_enlargementThreshold ; // Soglia corrente per incremetare le dimensioni della griglia
|
||||
|
||||
double m_dCellSpan ; // Dimensione di una cella (cubica) della griglia
|
||||
double m_dInvCellSpan ; // Inverso della dimensione di una cella
|
||||
|
||||
CellVector m_occupiedCells ; // Vettore delle celle occupate in questa griglia
|
||||
|
||||
size_t m_objCount ; // Numero di oggetti presenti in questa griglia
|
||||
|
||||
int m_stdNeighborOffset[3] ; // Array degli offset standard per le adiacenze
|
||||
|
||||
BBox3d m_b3Grid ; // Box totale degli oggetti inseriti in questa griglia
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
HashGrid1d::HashGrid1d( double dCellSpan)
|
||||
{
|
||||
// Initialization of all member variables and ...
|
||||
m_CellCount = PowerOfTwo( CellCount) ? CellCount : 16 ;
|
||||
|
||||
m_HashMask = m_CellCount - 1 ;
|
||||
|
||||
m_enlargementThreshold = m_CellCount / minimalGridDensity ;
|
||||
|
||||
// allocazione dell'array lineare che rappresenta lo hash grid.
|
||||
m_cell = new Cell[ m_CellCount] ;
|
||||
|
||||
// ogni cella è già inizializzata come vuota
|
||||
// imposto gli offset ai vicini
|
||||
InitNeighborOffsets() ;
|
||||
|
||||
m_dCellSpan = max( dCellSpan, 10 * EPS_SMALL) ;
|
||||
m_dInvCellSpan = 1. / dCellSpan ;
|
||||
|
||||
m_occupiedCells.reserve( occupiedCellsVectorSize) ;
|
||||
|
||||
m_objCount = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
HashGrid1d::~HashGrid1d( void)
|
||||
{
|
||||
Clear() ;
|
||||
|
||||
for ( Cell* pCell = m_cell ; pCell < m_cell + m_CellCount ; ++ pCell) {
|
||||
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
|
||||
delete[] pCell->m_neighborOffset ;
|
||||
}
|
||||
delete[] m_cell ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
HashGrid1d::Add( HashGrids1d::ObjData& obj)
|
||||
{
|
||||
// If adding the body will cause the total number of bodies assigned to this grid to exceed the
|
||||
// enlargement threshold, the size of this hash grid must be increased.
|
||||
if ( m_objCount == m_enlargementThreshold)
|
||||
Enlarge() ;
|
||||
|
||||
// Calculate (and store) the hash value (= the body's cell association) and ...
|
||||
size_t h = Hash( obj.box.GetMin()) ;
|
||||
obj.nHash = h ;
|
||||
|
||||
// ... insert the body into the corresponding cell.
|
||||
Cell* pCell = m_cell + h ;
|
||||
Add( obj, pCell) ;
|
||||
++ m_objCount ;
|
||||
|
||||
// Aggiorno box di griglia
|
||||
m_b3Grid.Add( obj.box) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
HashGrid1d::Remove( HashGrids1d::ObjData& obj)
|
||||
{
|
||||
// The stored hash value (= the body's cell association) is used in order to directly access the
|
||||
// cell from which this body will be removed.
|
||||
Cell* pCell = m_cell + obj.nHash ;
|
||||
Remove( obj, pCell) ;
|
||||
-- m_objCount ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
HashGrid1d::Update( HashGrids1d::ObjData& obj)
|
||||
{
|
||||
// The hash value is recomputed based on the body's current spatial location.
|
||||
size_t newHash = Hash( obj.box.GetMin()) ;
|
||||
size_t oldHash = obj.nHash ;
|
||||
|
||||
// If this new hash value is identical to the hash value of the previous time step, the body
|
||||
// remains assigned to its current grid cell.
|
||||
if ( newHash == oldHash)
|
||||
return ;
|
||||
|
||||
// Only if the hash value changes, the cell association has to be changed, too - meaning, the
|
||||
// body has to be removed from its currently assigned cell and ...
|
||||
Cell* pCell = m_cell + oldHash ;
|
||||
Remove( obj, pCell) ;
|
||||
|
||||
obj.nHash = newHash ;
|
||||
|
||||
// ... stored in the cell that corresponds to the new hash value.
|
||||
pCell = m_cell + newHash ;
|
||||
Add( obj, pCell) ;
|
||||
|
||||
// Aggiorno box di griglia
|
||||
m_b3Grid.Add( obj.box) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
HashGrid1d::Find( const BBox3d& b3Test, INTVECTOR& vnIds)
|
||||
{
|
||||
// Limito il box a quello di griglia
|
||||
BBox3d b3Int ;
|
||||
if ( ! b3Test.FindIntersection( m_b3Grid, b3Int))
|
||||
return ;
|
||||
|
||||
// Recupero gli estremi del box
|
||||
Point3d ptMin ;
|
||||
double dXDim, dYDim, dZDim ;
|
||||
if ( ! b3Int.GetMinDim( ptMin, dXDim, dYDim, dZDim))
|
||||
return ;
|
||||
// Sposto p.to minimo in meno di una cella (oggetti possono occupare 2 celle) e allargo tutto di EPS_SMALL
|
||||
ptMin -= Vector3d( 0, 0, 1) * ( m_dCellSpan + EPS_SMALL) ;
|
||||
dZDim += m_dCellSpan + 2 * EPS_SMALL ;
|
||||
|
||||
// Numero di celle da esplorare sull'asse Z
|
||||
int nZSpan = min( static_cast<int>( ceil( dZDim * m_dInvCellSpan)), int( m_CellCount)) ;
|
||||
|
||||
//string sOut = "Celle=" + ToString( int( m_CellCount)) + " Occupate=" + ToString( int(m_occupiedCells.size())) + " Span=" + ToString( nZSpan) ;
|
||||
//LOG_INFO( GetEGkLogger(), sOut.c_str()) ;
|
||||
|
||||
// Se conviene verificare queste celle
|
||||
if ( nZSpan < 5 * int( m_occupiedCells.size())) {
|
||||
// cella di base
|
||||
int nZ = static_cast<int>( Hash( ptMin)) ;
|
||||
for ( int i = 0 ; i <= nZSpan ; ++ i) {
|
||||
// inserisco in lista gli oggetti della cella
|
||||
if ( m_cell[nZ].m_Objs != nullptr) {
|
||||
for ( auto pObj : *( m_cell[nZ].m_Objs)) {
|
||||
if ( b3Int.Overlaps( pObj->box))
|
||||
vnIds.push_back( pObj->nId) ;
|
||||
}
|
||||
}
|
||||
// passo alla successiva in Z+
|
||||
nZ += m_cell[nZ].m_neighborOffset[2] ;
|
||||
}
|
||||
}
|
||||
|
||||
// altrimenti verifico direttamente tutte e sole quelle occupate
|
||||
else {
|
||||
// ciclo sulle celle occupate
|
||||
for ( auto cell : m_occupiedCells) {
|
||||
// inserisco in lista gli oggetti della cella
|
||||
if ( cell->m_Objs != nullptr) {
|
||||
for ( auto pObj : *(cell->m_Objs)) {
|
||||
if ( b3Int.Overlaps( pObj->box))
|
||||
vnIds.push_back( pObj->nId) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
HashGrid1d::Clear( void)
|
||||
{
|
||||
for ( auto cell : m_occupiedCells) {
|
||||
delete cell->m_Objs ;
|
||||
cell->m_Objs = nullptr ;
|
||||
}
|
||||
m_occupiedCells.clear() ;
|
||||
m_objCount = 0 ;
|
||||
m_b3Grid.Reset() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
HashGrid1d::InitNeighborOffsets( void)
|
||||
{
|
||||
int nc = static_cast<int>( m_CellCount) ;
|
||||
|
||||
// Initialization of the grid-global offset array that is valid for all inner cells in the hash grid.
|
||||
m_stdNeighborOffset[0] = -1 ;
|
||||
m_stdNeighborOffset[1] = 0 ;
|
||||
m_stdNeighborOffset[2] = 1 ;
|
||||
|
||||
// Allocation and initialization of the offset arrays of all the border cells. All inner cells
|
||||
// are set to point to the grid-global offset array.
|
||||
Cell* c = m_cell ;
|
||||
for ( int i = 0 ; i < nc ; ++ i, ++ c) {
|
||||
// cella di bordo
|
||||
if ( i == 0) {
|
||||
c->m_neighborOffset = new int[3] ;
|
||||
c->m_neighborOffset[0] = nc - 1 ;
|
||||
c->m_neighborOffset[1] = 0 ;
|
||||
c->m_neighborOffset[2] = 1 ;
|
||||
}
|
||||
else if ( i == nc - 1) {
|
||||
c->m_neighborOffset = new int[3] ;
|
||||
c->m_neighborOffset[0] = -1 ;
|
||||
c->m_neighborOffset[1] = 0 ;
|
||||
c->m_neighborOffset[2] = -nc + 1 ;
|
||||
}
|
||||
// cella interna
|
||||
else {
|
||||
c->m_neighborOffset = m_stdNeighborOffset ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
size_t
|
||||
HashGrid1d::Hash( const Point3d& ptP) const
|
||||
{
|
||||
size_t nHash ;
|
||||
if ( ptP.z < 0) {
|
||||
double i = ( - ptP.z ) * m_dInvCellSpan ;
|
||||
nHash = m_CellCount - 1 - ( static_cast<size_t>( i ) & m_HashMask) ;
|
||||
}
|
||||
else {
|
||||
double i = ptP.z * m_dInvCellSpan ;
|
||||
nHash = static_cast<size_t>( i ) & m_HashMask ;
|
||||
}
|
||||
|
||||
return nHash ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
HashGrid1d::Add( HashGrids1d::ObjData& obj, Cell* cell)
|
||||
{
|
||||
// If this cell is already occupied by other bodies, which means the pointer to the body
|
||||
// container holds a valid address and thus the container itself is properly initialized, then
|
||||
// the body is simply added to this already existing body container. Note that the index position
|
||||
// is memorized (=> "body->setCellId()") in order to ensure constant time removal.
|
||||
if ( cell->m_Objs != nullptr) {
|
||||
obj.nCellId = cell->m_Objs->size() ;
|
||||
cell->m_Objs->push_back( &obj) ;
|
||||
}
|
||||
|
||||
// If, however, the cell is still empty, then the object container, first of all, must be created
|
||||
// (i.e., allocated) and properly initialized (i.e., sufficient initial storage capacity must be
|
||||
// reserved). Furthermore, the cell must be inserted into the grid-global vector 'm_occupiedCells'
|
||||
// in which all cells that are currently occupied by bodies are recorded.
|
||||
else {
|
||||
cell->m_Objs = new HashGrids1d::PtrObjVector ;
|
||||
cell->m_Objs->reserve( cellVectorSize) ;
|
||||
|
||||
obj.nCellId = 0 ;
|
||||
cell->m_Objs->push_back( &obj) ;
|
||||
|
||||
cell->m_occupiedCellsId = m_occupiedCells.size() ;
|
||||
m_occupiedCells.push_back( cell) ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
HashGrid1d::Remove( HashGrids1d::ObjData& obj, Cell* cell )
|
||||
{
|
||||
// If the body is the last body that is stored in this cell ...
|
||||
if ( cell->m_Objs->size() == 1) {
|
||||
// ... the cell's body container is destroyed and ...
|
||||
delete cell->m_Objs ;
|
||||
cell->m_Objs = nullptr ;
|
||||
|
||||
// ... the cell is removed from the grid-global vector 'm_occupiedCells' that records all
|
||||
// body-occupied cells. Since the cell memorized its index (=> 'm_occupiedCellsId') in this
|
||||
// vector, it can be removed in constant time, O(1).
|
||||
if ( cell->m_occupiedCellsId == m_occupiedCells.size() - 1) {
|
||||
m_occupiedCells.pop_back() ;
|
||||
}
|
||||
else {
|
||||
Cell* lastCell = m_occupiedCells.back() ;
|
||||
m_occupiedCells.pop_back() ;
|
||||
lastCell->m_occupiedCellsId = cell->m_occupiedCellsId ;
|
||||
m_occupiedCells[ cell->m_occupiedCellsId ] = lastCell ;
|
||||
}
|
||||
}
|
||||
// If the body is *not* the last body that is stored in this cell ...
|
||||
else {
|
||||
size_t cellId = obj.nCellId ;
|
||||
|
||||
// ... the body is removed from the cell's body container. Since the body memorized its
|
||||
// index (=> 'cellId') in this container, it can be removed in constant time, O(1).
|
||||
if ( cellId == cell->m_Objs->size() - 1) {
|
||||
cell->m_Objs->pop_back() ;
|
||||
}
|
||||
else {
|
||||
HashGrids1d::ObjData* lastElement = cell->m_Objs->back() ;
|
||||
cell->m_Objs->pop_back() ;
|
||||
lastElement->nCellId = cellId ;
|
||||
(*cell->m_Objs)[ cellId] = lastElement ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
HashGrid1d::Enlarge( void)
|
||||
{
|
||||
HashGrids1d::PtrObjVector PObjVecTemp ;
|
||||
PObjVecTemp.reserve( m_objCount) ;
|
||||
|
||||
// All objs that are assigned to this grid are temporarily removed, ...
|
||||
for ( auto cell = m_occupiedCells.begin() ; cell < m_occupiedCells.end() ; ++ cell) {
|
||||
HashGrids1d::PtrObjVector* cellBodies = (*cell)->m_Objs ;
|
||||
for ( auto e = cellBodies->begin() ; e < cellBodies->end() ; ++ e) {
|
||||
PObjVecTemp.push_back( *e) ;
|
||||
}
|
||||
}
|
||||
|
||||
// ... the grid's current data structures are deleted, ...
|
||||
Clear() ;
|
||||
|
||||
for ( auto pCell = m_cell ; pCell < m_cell + m_CellCount ; ++ pCell) {
|
||||
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
|
||||
delete[] pCell->m_neighborOffset ;
|
||||
}
|
||||
delete[] m_cell ;
|
||||
|
||||
// ... the number of cells is doubled in each coordinate direction, ...
|
||||
m_CellCount *= 2 ;
|
||||
m_HashMask = m_CellCount - 1 ;
|
||||
|
||||
// ... a new threshold for enlarging this hash grid is set, ...
|
||||
m_enlargementThreshold = m_CellCount / minimalGridDensity ;
|
||||
|
||||
// ... a new linear array of cells representing this enlarged hash grid is allocated and ...
|
||||
m_cell = new Cell[ m_CellCount] ;
|
||||
|
||||
// ... initialized, and finally ...
|
||||
InitNeighborOffsets() ;
|
||||
|
||||
// ... all previously removed objs are reinserted.
|
||||
for ( auto p = PObjVecTemp.begin() ; p < PObjVecTemp.end() ; ++ p) {
|
||||
Add( **p) ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
HashGrid1d::PowerOfTwo( size_t number)
|
||||
{
|
||||
return ( ( number > 0) && ( ( number & ( number - 1)) == 0)) ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// HashGrids1d
|
||||
//----------------------------------------------------------------------------
|
||||
HashGrids1d::HashGrids1d( void)
|
||||
{
|
||||
try {
|
||||
// Finchè il numero di oggetti non supera la soglia non si usano le griglie
|
||||
m_nonGridObjs.reserve( gridActivationThreshold) ;
|
||||
m_bActivate = true ;
|
||||
m_bGridActive = false ;
|
||||
}
|
||||
catch(...) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error in HashGrids1d constructor") ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
HashGrids1d::~HashGrids1d( void)
|
||||
{
|
||||
// Delete all grids that are stored in the grid hierarchy (=> m_GridList).
|
||||
for ( auto pGrid : m_GridList) {
|
||||
delete pGrid ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
HashGrids1d::SetActivationGrid( bool bActivate)
|
||||
{
|
||||
m_bActivate = bActivate ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
HashGrids1d::Add( int nObjId, const BBox3d& box)
|
||||
{
|
||||
try {
|
||||
// The body is marked as being added to 'm_objsToAdd' by setting the grid pointer to nullptr and
|
||||
// setting the cell-ID to '0'. Additionally, the hash value is used to memorize the body's
|
||||
// index position in the 'm_objsToAdd' vector.
|
||||
m_ObjsList.emplace_back( nObjId, box, nullptr, m_objsToAdd.size(), 0) ;
|
||||
|
||||
// inserisco nel Map
|
||||
m_ObjsMap.emplace( nObjId, &(m_ObjsList.back())) ;
|
||||
|
||||
// Temporarily add the body to 'm_objsToAdd'. As soon as "findContacts()" is called, all
|
||||
// bodies stored in 'm_objsToAdd' are finally inserted into the data structure.
|
||||
m_objsToAdd.push_back( &(m_ObjsList.back())) ;
|
||||
|
||||
// Aggiorno il box complessivo
|
||||
m_b3Objs.Add( box) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
catch(...) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error in HashGrids1d::Add") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
HashGrids1d::Modify( int nObjId, const BBox3d& box)
|
||||
{
|
||||
// Cerco l'oggetto con l'Id voluto
|
||||
auto iIter = m_ObjsMap.find( nObjId) ;
|
||||
if ( iIter == m_ObjsMap.end())
|
||||
return false ;
|
||||
ObjData* pObj = iIter->second ;
|
||||
if ( pObj == nullptr)
|
||||
return false ;
|
||||
|
||||
// Modifico il suo box
|
||||
pObj->box = box ;
|
||||
|
||||
// Aggiorno il box complessivo
|
||||
m_b3Objs.Add( box) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
HashGrids1d::Remove( int nObjId)
|
||||
{
|
||||
// Cerco l'oggetto con l'Id voluto
|
||||
auto iIter = m_ObjsMap.find( nObjId) ;
|
||||
if ( iIter == m_ObjsMap.end())
|
||||
return false ;
|
||||
ObjData* pObj = iIter->second ;
|
||||
if ( pObj == nullptr)
|
||||
return false ;
|
||||
|
||||
// Recupero la griglia di appartenenza
|
||||
HashGrid1d* pGrid = pObj->pHGrid ;
|
||||
|
||||
// The body is stored in a hash grid from which it must be removed.
|
||||
if ( pGrid != nullptr) {
|
||||
pGrid->Remove( *pObj) ;
|
||||
}
|
||||
// The body's grid pointer is equal to nullptr.
|
||||
// => The body is either stored in 'm_objsToAdd' (-> cell-ID = 0) or 'm_nonGridObjs' (-> cell-ID = 1).
|
||||
else {
|
||||
if ( pObj->nCellId == 0) {
|
||||
// the body's hash value => index of this body in 'm_objsToAdd'
|
||||
if ( pObj->nHash == m_objsToAdd.size() - 1) {
|
||||
m_objsToAdd.pop_back() ;
|
||||
}
|
||||
else if ( pObj->nHash < m_objsToAdd.size()) {
|
||||
ObjData* pLastObj = m_objsToAdd.back() ;
|
||||
m_objsToAdd.pop_back() ;
|
||||
pLastObj->nHash = pObj->nHash ;
|
||||
m_objsToAdd[ pObj->nHash] = pLastObj ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
// the body's hash value => index of this body in 'm_nonGridObjs'
|
||||
if ( pObj->nHash == m_nonGridObjs.size() - 1) {
|
||||
m_nonGridObjs.pop_back();
|
||||
}
|
||||
else if ( pObj->nHash < m_nonGridObjs.size()) {
|
||||
ObjData* pLastObj = m_nonGridObjs.back() ;
|
||||
m_nonGridObjs.pop_back() ;
|
||||
pLastObj->nHash = pObj->nHash ;
|
||||
m_nonGridObjs[ pObj->nHash] = pLastObj ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
HashGrids1d::Update( void)
|
||||
{
|
||||
try {
|
||||
// Salvo stato di precedente attivazione delle griglie
|
||||
bool bGridActivePrev = m_bGridActive ;
|
||||
// Inseriamo gli oggetti presenti nel vettore m_objsToAdd
|
||||
if ( m_objsToAdd.size() > 0 ) {
|
||||
for ( auto pObj : m_objsToAdd) {
|
||||
if ( m_bGridActive)
|
||||
addGrid( *pObj) ;
|
||||
else
|
||||
addList( *pObj) ;
|
||||
}
|
||||
m_objsToAdd.clear() ;
|
||||
}
|
||||
// Aggiorniamo per eventuali modifiche agli oggetti già precedentemente presenti nelle griglie
|
||||
if ( bGridActivePrev) {
|
||||
for ( auto& Obj : m_ObjsList) {
|
||||
HashGrid1d* pGrid = Obj.pHGrid ;
|
||||
if ( pGrid != nullptr) {
|
||||
double dSize = 0 ;
|
||||
Obj.box.GetDiameter( dSize) ;
|
||||
double dCellSpan = pGrid->GetCellSpan() ;
|
||||
|
||||
if ( dSize >= dCellSpan || dSize < ( dCellSpan / hierarchyFactor)) {
|
||||
pGrid->Remove( Obj) ;
|
||||
addGrid( Obj) ;
|
||||
}
|
||||
else {
|
||||
pGrid->Update( Obj) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
catch(...) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error in HashGrids1d::Update") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
HashGrids1d::Find( const BBox3d& b3Test, INTVECTOR& vnIds) const
|
||||
{
|
||||
// pulisco il risultato
|
||||
vnIds.clear() ;
|
||||
vnIds.reserve( 128) ;
|
||||
|
||||
// limito con box globale
|
||||
BBox3d b3Int ;
|
||||
if ( ! b3Test.FindIntersection( m_b3Objs, b3Int))
|
||||
return false ;
|
||||
|
||||
// ricerca nelle griglie
|
||||
if ( m_bGridActive) {
|
||||
for ( auto pGrid : m_GridList)
|
||||
pGrid->Find( b3Int, vnIds) ;
|
||||
}
|
||||
|
||||
// ricerca negli oggetti fuori griglia
|
||||
for ( auto pObj : m_nonGridObjs) {
|
||||
if ( b3Int.Overlaps( pObj->box))
|
||||
vnIds.push_back( pObj->nId) ;
|
||||
}
|
||||
|
||||
// ordino il risultato ed elimino gli indici ripetuti
|
||||
sort( vnIds.begin(), vnIds.end()) ;
|
||||
vnIds.erase( unique( vnIds.begin(), vnIds.end()), vnIds.end()) ;
|
||||
|
||||
return ( vnIds.size() > 0) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
HashGrids1d::Clear( void)
|
||||
{
|
||||
for ( auto pGrid : m_GridList) {
|
||||
delete pGrid ;
|
||||
}
|
||||
m_GridList.clear() ;
|
||||
|
||||
m_bGridActive = false ;
|
||||
|
||||
m_nonGridObjs.clear() ;
|
||||
|
||||
m_objsToAdd.clear() ;
|
||||
|
||||
m_b3Objs.Reset() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
HashGrids1d::addGrid( ObjData& obj)
|
||||
{
|
||||
double size = - 1 ;
|
||||
obj.box.GetDiameter( size) ;
|
||||
|
||||
// If the body is finite in size, it must be assigned to a grid with suitably sized cells.
|
||||
if ( size > - EPS_ZERO) {
|
||||
|
||||
size = max( size, MIN_CELL_SIZE) ;
|
||||
|
||||
HashGrid1d* pGrid = nullptr ;
|
||||
|
||||
if ( m_GridList.empty()) {
|
||||
// If no hash grid yet exists in the hierarchy, an initial hash grid is created
|
||||
// based on the body's size.
|
||||
|
||||
pGrid = new HashGrid1d( size * sqrt( hierarchyFactor)) ;
|
||||
}
|
||||
else {
|
||||
// Check the hierarchy for a hash grid with suitably sized cells - if such a grid does not
|
||||
// yet exist, it will be created.
|
||||
|
||||
double cellSpan = 0;
|
||||
for ( auto g = m_GridList.begin(); g != m_GridList.end(); ++ g) {
|
||||
pGrid = *g;
|
||||
cellSpan = pGrid->GetCellSpan();
|
||||
|
||||
if ( size < cellSpan) {
|
||||
cellSpan /= hierarchyFactor ;
|
||||
if ( size < cellSpan ) {
|
||||
while ( size < cellSpan)
|
||||
cellSpan /= hierarchyFactor ;
|
||||
pGrid = new HashGrid1d( cellSpan * hierarchyFactor) ;
|
||||
m_GridList.insert( g, pGrid) ;
|
||||
}
|
||||
|
||||
pGrid->Add( obj) ;
|
||||
obj.pHGrid = pGrid ;
|
||||
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
while ( size >= cellSpan)
|
||||
cellSpan *= hierarchyFactor ;
|
||||
pGrid = new HashGrid1d( cellSpan) ;
|
||||
}
|
||||
|
||||
pGrid->Add( obj) ;
|
||||
obj.pHGrid = pGrid ;
|
||||
|
||||
m_GridList.push_back( pGrid) ;
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
// The body - which is infinite in size - is marked as being added to 'm_nonGridObjs' by setting
|
||||
// the grid pointer to nullptr and setting the cell-ID to '1'. Additionally, the hash value is used
|
||||
// to memorize the body's index position in the 'm_nonGridObjs' vector.
|
||||
|
||||
obj.pHGrid = nullptr ;
|
||||
obj.nHash = m_nonGridObjs.size() ;
|
||||
obj.nCellId = 1 ;
|
||||
|
||||
m_nonGridObjs.push_back( &obj) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
HashGrids1d::addList( ObjData& obj)
|
||||
{
|
||||
// Se abilitato e superata la soglia ...
|
||||
if ( m_bActivate && m_nonGridObjs.size() == gridActivationThreshold) {
|
||||
if ( gridActivationThreshold > 0) {
|
||||
|
||||
// all objs stored in 'm_nonGridObjs' are inserted in grids
|
||||
for ( size_t i = 0; i < gridActivationThreshold; ++i ) {
|
||||
addGrid( *m_nonGridObjs[i] );
|
||||
}
|
||||
|
||||
// ... the 'm_nonGridObjs' vector is cleared ...
|
||||
m_nonGridObjs.clear() ;
|
||||
}
|
||||
|
||||
addGrid( obj) ;
|
||||
|
||||
// ... and the usage of the hierarchical hash grids is activated irrevocably.
|
||||
m_bGridActive = true ;
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
// The body is marked as being added to 'm_nonGridObjs' by setting the grid pointer to nullptr and
|
||||
// setting the cell-ID to '1'. Additionally, the hash value is used to memorize the body's index
|
||||
// position in the 'm_nonGridObjs' vector.
|
||||
obj.pHGrid = nullptr ;
|
||||
obj.nHash = m_nonGridObjs.size() ;
|
||||
obj.nCellId = 1 ;
|
||||
m_nonGridObjs.push_back( &obj) ;
|
||||
}
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "DllMain.h"
|
||||
#include "/EgtDev/Include/EGkHashGrids2d.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
+2
-1
@@ -15,7 +15,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "DllMain.h"
|
||||
#include "/EgtDev/Include/EGkHashGrids3d.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
@@ -684,6 +684,7 @@ HashGrids3d::Update( void)
|
||||
double dSize = 0 ;
|
||||
Obj.box.GetDiameter( dSize) ;
|
||||
double dCellSpan = pGrid->GetCellSpan() ;
|
||||
|
||||
if ( dSize >= dCellSpan || dSize < ( dCellSpan / hierarchyFactor)) {
|
||||
pGrid->Remove( Obj) ;
|
||||
addGrid( Obj) ;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "IntersCrvCompoCrvCompo.h"
|
||||
#include "CurveAux.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkAngle.h"
|
||||
#include "/EgtDev/Include/EGkHashGrids2d.h"
|
||||
#include <algorithm>
|
||||
@@ -541,7 +541,7 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
for ( int i = 0 ; i < m_nNumInters ; ++ i) {
|
||||
// se il tipo di accostamento per la curva A non è definito
|
||||
if ( m_Info[i].IciA[0].nPrevTy == ICCT_NULL) {
|
||||
if ( i > 0 || ( bCrvAClosed && ! bAutoInters)) {
|
||||
if ( i > 0 || bCrvAClosed) {
|
||||
int j = ( i > 0 ? i - 1 : m_nNumInters - 1) ;
|
||||
m_Info[i].IciA[0].nPrevTy = ( m_Info[j].bOverlap ? m_Info[j].IciA[1].nNextTy : m_Info[j].IciA[0].nNextTy) ;
|
||||
}
|
||||
@@ -549,7 +549,7 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
// se il tipo di allontanamento per la curva A non è definito
|
||||
int ki = ( m_Info[i].bOverlap ? 1 : 0) ;
|
||||
if ( m_Info[i].IciA[ki].nNextTy == ICCT_NULL) {
|
||||
if ( i < m_nNumInters - 1 || ( bCrvAClosed && ! bAutoInters)) {
|
||||
if ( i < m_nNumInters - 1 || bCrvAClosed) {
|
||||
int j = ( i < m_nNumInters - 1 ? i + 1 : 0) ;
|
||||
m_Info[i].IciA[ki].nNextTy = m_Info[j].IciA[0].nPrevTy ;
|
||||
}
|
||||
@@ -561,14 +561,14 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
for ( int i = 0 ; i < m_nNumInters ; ++ i) {
|
||||
// se il tipo di accostamento per la curva B non è definito
|
||||
if ( m_Info[i].IciB[0].nPrevTy == ICCT_NULL) {
|
||||
if ( i > 0 || ( bCrvBClosed && ! bAutoInters)) {
|
||||
if ( i > 0 || bCrvBClosed) {
|
||||
int j = ( i > 0 ? i - 1 : m_nNumInters - 1) ;
|
||||
m_Info[i].IciB[0].nPrevTy = ( m_Info[j].bOverlap && ! m_Info[j].bCBOverEq ? m_Info[j].IciB[1].nNextTy : m_Info[j].IciB[0].nNextTy) ;
|
||||
}
|
||||
}
|
||||
// se il tipo di allontanamento per la curva B non è definito
|
||||
if ( m_Info[i].IciB[0].nNextTy == ICCT_NULL) {
|
||||
if ( i < m_nNumInters - 1 || ( bCrvBClosed && ! bAutoInters)) {
|
||||
if ( i < m_nNumInters - 1 || bCrvBClosed) {
|
||||
int j = ( i < m_nNumInters - 1 ? i + 1 : 0) ;
|
||||
m_Info[i].IciB[0].nNextTy = ( m_Info[j].bOverlap && ! m_Info[j].bCBOverEq ? m_Info[j].IciB[1].nPrevTy : m_Info[j].IciB[0].nPrevTy) ;
|
||||
}
|
||||
@@ -702,9 +702,9 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
// assegno sottoindici (considero solo intersezioni overlap)
|
||||
int ki = 0 ;
|
||||
int kj = 1 ;
|
||||
// verifico se entrambe overlap con lo stesso verso, la precedente termina con ON e la successiva inizia con ON
|
||||
// verifico se entrambe overlap, la precedente termina con ON e la successiva inizia con ON
|
||||
// sia sulla curva A sia sulla curva B (tenendo conto del senso equiverso/controverso)
|
||||
if ( m_Info[j].bOverlap && m_Info[i].bOverlap && m_Info[j].bCBOverEq == m_Info[i].bCBOverEq &&
|
||||
if ( m_Info[j].bOverlap && m_Info[i].bOverlap &&
|
||||
m_Info[j].IciA[kj].nNextTy == ICCT_ON && m_Info[i].IciA[ki].nPrevTy == ICCT_ON &&
|
||||
GetCrvBDirANext( m_Info[j]) == ICCT_ON && GetCrvBDirAPrev( m_Info[i]) == ICCT_ON) {
|
||||
// CurvaA : riporto il secondo punto del successivo sul secondo punto del precedente
|
||||
|
||||
+9
-11
@@ -23,7 +23,7 @@
|
||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkPlane3d.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EGtPointerOwner.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
@@ -391,7 +391,7 @@ IntersCurveCurve::GetIntersPointNearTo( int nCrv, const Point3d& ptNear, Point3d
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersCurveCurve::GetCurveClassification( int nCrv, double dLenMin, CRVCVECTOR& ccClass)
|
||||
IntersCurveCurve::GetCurveClassification( int nCrv, CRVCVECTOR& ccClass)
|
||||
{
|
||||
// pulisco vettore classificazioni
|
||||
ccClass.clear() ;
|
||||
@@ -407,7 +407,7 @@ IntersCurveCurve::GetCurveClassification( int nCrv, double dLenMin, CRVCVECTOR&
|
||||
return false ;
|
||||
// se esiste almeno una intersezione
|
||||
if ( m_nIntersCount >= 1)
|
||||
return CalcCurveClassification( m_pCurve[0], m_Info, dLenMin, ccClass) ;
|
||||
return CalcCurveClassification( m_pCurve[0], m_Info, ccClass) ;
|
||||
// altrimenti la curva è completamente interna oppure completamente esterna
|
||||
else
|
||||
return CalcCurveInOrOut( m_pCurve[0], m_pCurve[1], ccClass) ;
|
||||
@@ -424,7 +424,7 @@ IntersCurveCurve::GetCurveClassification( int nCrv, double dLenMin, CRVCVECTOR&
|
||||
SwapInfoAB( InfoTmp, 1) ;
|
||||
// se esiste almeno una intersezione
|
||||
if ( m_nIntersCount >= 1)
|
||||
return CalcCurveClassification( m_pCurve[1], InfoTmp, dLenMin, ccClass) ;
|
||||
return CalcCurveClassification( m_pCurve[1], InfoTmp, ccClass) ;
|
||||
// altrimenti la curva è completamente interna oppure completamente esterna
|
||||
else
|
||||
return CalcCurveInOrOut( m_pCurve[1], m_pCurve[0], ccClass) ;
|
||||
@@ -461,7 +461,7 @@ IntersCurveCurve::SwapInfoAB( ICCIVECTOR& Info, int IndCrvOrd)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersCurveCurve::CalcCurveClassification( const ICurve* pCurve, const ICCIVECTOR& Info, double dLenMin, CRVCVECTOR& ccClass)
|
||||
IntersCurveCurve::CalcCurveClassification( const ICurve* pCurve, const ICCIVECTOR& Info, CRVCVECTOR& ccClass)
|
||||
{
|
||||
// numero intersezioni
|
||||
int nNumInters = int( Info.size()) ;
|
||||
@@ -471,8 +471,6 @@ IntersCurveCurve::CalcCurveClassification( const ICurve* pCurve, const ICCIVECTO
|
||||
double dStartPar, dEndPar ;
|
||||
if ( pCurve == nullptr || ! pCurve->GetDomain( dStartPar, dEndPar))
|
||||
return false ;
|
||||
// limito lunghezza minima
|
||||
dLenMin = max( dLenMin, EPS_ZERO) ;
|
||||
// elimino intersezioni senza attraversamento che giacciono in intervalli di sovrapposizione
|
||||
ICCIVECTOR InfoCorr ;
|
||||
InfoCorr.reserve( Info.size()) ;
|
||||
@@ -529,7 +527,7 @@ IntersCurveCurve::CalcCurveClassification( const ICurve* pCurve, const ICCIVECTO
|
||||
for ( int i = 0 ; i < nNumInters ; ++ i) {
|
||||
// se è definito un tratto precedente
|
||||
double dLenU ; pCurve->GetLengthAtParam( InfoCorr[i].IciA[0].dU, dLenU) ;
|
||||
if ( InfoCorr[i].IciA[0].dU > dCurrPar + EPS_PARAM && dLenU - dCurrLen > dLenMin) {
|
||||
if ( InfoCorr[i].IciA[0].dU > dCurrPar + EPS_PARAM && dLenU - dCurrLen > EPS_SMALL) {
|
||||
// verifico che la definizione sul tratto sia omogenea e valida
|
||||
int nPrevTy = InfoCorr[i].IciA[0].nPrevTy ;
|
||||
if ( ( nLastTy != ICCT_NULL && nPrevTy != nLastTy) ||
|
||||
@@ -564,7 +562,7 @@ IntersCurveCurve::CalcCurveClassification( const ICurve* pCurve, const ICCIVECTO
|
||||
}
|
||||
}
|
||||
// eventuale tratto finale rimasto
|
||||
if ( dCurrPar < dEndPar - EPS_PARAM && dEndLen - dCurrLen > dLenMin) {
|
||||
if ( dCurrPar < dEndPar - EPS_PARAM && dEndLen - dCurrLen > EPS_SMALL) {
|
||||
// verifico che la definizione sul tratto sia valida
|
||||
if ( nLastTy == ICCT_NULL || nLastTy == ICCT_ON)
|
||||
return false ;
|
||||
@@ -675,7 +673,7 @@ IntersCurveCurve::GetRegionCurveClassification( void)
|
||||
{
|
||||
// classifico la prima curva rispetto alla seconda
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( ! GetCurveClassification( 0, EPS_SMALL, ccClass))
|
||||
if ( ! GetCurveClassification( 0, ccClass))
|
||||
return CCREGC_NULL ;
|
||||
// derivo la classificazione delle curve come regioni
|
||||
bool bIn = false ;
|
||||
@@ -712,7 +710,7 @@ IntersCurveCurve::GetRegionCurveClassification( void)
|
||||
if ( bOnP)
|
||||
return CCREGC_IN2 ;
|
||||
CRVCVECTOR ccClass2 ;
|
||||
if ( ! GetCurveClassification( 1, EPS_SMALL, ccClass2) || ccClass2.empty())
|
||||
if ( ! GetCurveClassification( 1, ccClass2) || ccClass2.empty())
|
||||
return CCREGC_NULL ;
|
||||
if ( ccClass2[0].nClass == CRVC_OUT)
|
||||
return CCREGC_OUT ;
|
||||
|
||||
+104
-123
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2022
|
||||
// EgalTech 2020-2020
|
||||
//----------------------------------------------------------------------------
|
||||
// File : IntersLineBox.cpp Data : 08.01.22 Versione : 2.4a3
|
||||
// File : IntersLineBox.cpp Data : 07.05.20 Versione : 2.2e1
|
||||
// Contenuto : Implementazione della intersezione linea/box.
|
||||
//
|
||||
//
|
||||
@@ -13,77 +13,13 @@
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "IntersLineBox.h"
|
||||
#include "SurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineBox.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Linea e box allineato assi devono essere nel medesimo sistema di riferimento.
|
||||
// In caso di intersezione viene restituito true e i parametri in dU1 e dU2.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersLineBox( const Point3d& ptL, const Vector3d& vtL,
|
||||
const Point3d& ptMin, const Point3d& ptMax,
|
||||
double& dU1, double& dU2)
|
||||
{
|
||||
// Verifico il versore
|
||||
if ( vtL.IsSmall())
|
||||
return false ;
|
||||
|
||||
// Verifico gli estremi del box
|
||||
if ( ptMin.x > ptMax.x + EPS_SMALL ||
|
||||
ptMin.y > ptMax.y + EPS_SMALL ||
|
||||
ptMin.z > ptMax.z + EPS_SMALL)
|
||||
return false ;
|
||||
|
||||
// Casi di intersezione impossibile
|
||||
if ( abs( vtL.x) < EPS_ZERO && ( ptL.x < ptMin.x - EPS_SMALL || ptL.x > ptMax.x + EPS_SMALL))
|
||||
return false ;
|
||||
if ( abs( vtL.y) < EPS_ZERO && ( ptL.y < ptMin.y - EPS_SMALL || ptL.y > ptMax.y + EPS_SMALL))
|
||||
return false ;
|
||||
if ( abs( vtL.z) < EPS_ZERO && ( ptL.z < ptMin.z - EPS_SMALL || ptL.z > ptMax.z + EPS_SMALL))
|
||||
return false ;
|
||||
|
||||
// Parametri degli estremi della retta
|
||||
dU1 = -INFINITO ;
|
||||
dU2 = INFINITO ;
|
||||
|
||||
// Confronto con piani YZ (perpendicolari ad asse X)
|
||||
if ( vtL.x > EPS_ZERO) {
|
||||
dU1 = max( dU1, ( ptMin.x - ptL.x) / vtL.x) ;
|
||||
dU2 = min( dU2, ( ptMax.x - ptL.x) / vtL.x) ;
|
||||
}
|
||||
else if ( vtL.x < -EPS_ZERO) {
|
||||
dU1 = max( dU1, ( ptMax.x - ptL.x) / vtL.x) ;
|
||||
dU2 = min( dU2, ( ptMin.x - ptL.x) / vtL.x) ;
|
||||
}
|
||||
|
||||
// Confronto con piani ZX (perpendicolari ad asse Y)
|
||||
if ( vtL.y > EPS_ZERO) {
|
||||
dU1 = max( dU1, ( ptMin.y - ptL.y) / vtL.y) ;
|
||||
dU2 = min( dU2, ( ptMax.y - ptL.y) / vtL.y) ;
|
||||
}
|
||||
else if ( vtL.y < -EPS_ZERO) {
|
||||
dU1 = max( dU1, ( ptMax.y - ptL.y) / vtL.y) ;
|
||||
dU2 = min( dU2, ( ptMin.y - ptL.y) / vtL.y) ;
|
||||
}
|
||||
|
||||
// Confronto con piani XY (perpendicolari ad asse Z)
|
||||
if ( vtL.z > EPS_ZERO) {
|
||||
dU1 = max( dU1, ( ptMin.z - ptL.z) / vtL.z) ;
|
||||
dU2 = min( dU2, ( ptMax.z - ptL.z) / vtL.z) ;
|
||||
}
|
||||
else if ( vtL.z < -EPS_ZERO){
|
||||
dU1 = max( dU1, ( ptMax.z - ptL.z) / vtL.z) ;
|
||||
dU2 = min( dU2, ( ptMin.z - ptL.z) / vtL.z) ;
|
||||
}
|
||||
|
||||
return ( dU2 >= dU1) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersLineBox( const Point3d& ptL1, const Point3d& ptL2, const BBox3d& b3Box, INTDBLVECTOR& vInters, bool bFinite)
|
||||
@@ -102,69 +38,114 @@ bool
|
||||
IntersLineBox( const Point3d& ptL, const Vector3d& vtL, double dLen, const BBox3d& b3Box, INTDBLVECTOR& vInters, bool bFinite)
|
||||
{
|
||||
// Recupero i dati del Box
|
||||
Point3d ptMin, ptMax ;
|
||||
if ( ! b3Box.GetMinMax( ptMin, ptMax))
|
||||
Point3d ptMin ;
|
||||
double dDimX, dDimY, dDimZ ;
|
||||
if ( ! b3Box.GetMinDim( ptMin, dDimX, dDimY, dDimZ))
|
||||
return false ;
|
||||
|
||||
// Pulisco vettore intersezioni
|
||||
vInters.clear() ;
|
||||
|
||||
// Eseguo intersezione della linea completa
|
||||
double dU1, dU2 ;
|
||||
bool bInters = IntersLineBox( ptL, vtL, b3Box.GetMin(), b3Box.GetMax(), dU1, dU2) ;
|
||||
|
||||
// Se non c'è intersezione
|
||||
if ( ! bInters || ( bFinite && ( dU1 > dLen + EPS_SMALL || dU2 < -EPS_SMALL)))
|
||||
return true ;
|
||||
|
||||
// Se le due intersezioni coincidono
|
||||
if ( ( dU2 - dU1) < EPS_SMALL) {
|
||||
double dU = ( dU1 + dU2) / 2 ;
|
||||
if ( ! bFinite) {
|
||||
vInters.emplace_back( ILBT_TOUCH, dU) ;
|
||||
// Contorno di base
|
||||
PolyLine PL ;
|
||||
PL.AddUPoint( 0, ptMin) ;
|
||||
PL.AddUPoint( 1, ptMin + Vector3d( dDimX, 0, 0)) ;
|
||||
PL.AddUPoint( 2, ptMin + Vector3d( dDimX, dDimY, 0)) ;
|
||||
PL.AddUPoint( 3, ptMin + Vector3d( 0, dDimY, 0)) ;
|
||||
PL.Close() ;
|
||||
// Vettore altezza
|
||||
Vector3d vtExtr( 0, 0, dDimZ) ;
|
||||
// Creo la superficie trimesh equivalente
|
||||
SurfTriMesh Stm ;
|
||||
if ( ! Stm.CreateByExtrusion( PL, vtExtr))
|
||||
return false ;
|
||||
SurfTriMesh StmBot ;
|
||||
if ( ! StmBot.CreateByFlatContour( PL))
|
||||
return false ;
|
||||
StmBot.Invert() ;
|
||||
SurfTriMesh StmTop ;
|
||||
if ( ! StmTop.CreateByFlatContour( PL))
|
||||
return false ;
|
||||
StmTop.Translate( vtExtr) ;
|
||||
if ( ! Stm.DoSewing( StmBot) || ! Stm.DoSewing( StmTop))
|
||||
return false ;
|
||||
// Calcolo l'intersezione
|
||||
ILSIVECTOR vInfo ;
|
||||
if ( ! IntersLineSurfTm( ptL, vtL, dLen, Stm, vInfo, bFinite))
|
||||
return false ;
|
||||
// ciclo sulle intersezioni
|
||||
double dUcurr = -INFINITO ;
|
||||
for ( const auto& Info : vInfo) {
|
||||
// se intersezione puntuale
|
||||
if ( Info.nILTT == ILTT_VERT || Info.nILTT == ILTT_EDGE || Info.nILTT == ILTT_IN) {
|
||||
int nFlag = ILBT_TOUCH ;
|
||||
if ( Info.dCosDN > EPS_ZERO)
|
||||
nFlag = ILBT_OUT ;
|
||||
else if ( Info.dCosDN < -EPS_ZERO)
|
||||
nFlag = ILBT_IN ;
|
||||
vInters.emplace_back( nFlag, Info.dU) ;
|
||||
dUcurr = Info.dU ;
|
||||
}
|
||||
else {
|
||||
if ( dU > - EPS_SMALL && dU < dLen + EPS_SMALL)
|
||||
vInters.emplace_back( ILBT_TOUCH, Clamp( dU, 0., dLen)) ;
|
||||
// se altrimenti intersezione con coincidenza
|
||||
else if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) {
|
||||
if ( Info.dU > dUcurr - EPS_SMALL)
|
||||
vInters.emplace_back( ILBT_TG_INI, Info.dU) ;
|
||||
vInters.emplace_back( ILBT_TG_FIN, Info.dU2) ;
|
||||
dUcurr = Info.dU2 ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
// Se sono due intersezioni con la linea giacente su una faccia del box
|
||||
if ( ( abs( vtL.x) < EPS_ZERO && ( abs( ptL.x - ptMin.x) < EPS_SMALL || abs( ptL.x - ptMax.x) < EPS_SMALL)) ||
|
||||
( abs( vtL.y) < EPS_ZERO && ( abs( ptL.y - ptMin.y) < EPS_SMALL || abs( ptL.y - ptMax.y) < EPS_SMALL)) ||
|
||||
( abs( vtL.z) < EPS_ZERO && ( abs( ptL.z - ptMin.z) < EPS_SMALL || abs( ptL.z - ptMax.z) < EPS_SMALL))) {
|
||||
if ( ! bFinite) {
|
||||
vInters.emplace_back( ILBT_TG_INI, dU1) ;
|
||||
vInters.emplace_back( ILBT_TG_FIN, dU2) ;
|
||||
// elimino intersezioni ripetute
|
||||
for ( size_t j = 1 ; j < vInters.size() ; ) {
|
||||
// intersezione precedente
|
||||
size_t i = j - 1 ;
|
||||
// se sono dello stesso tipo, elimino una delle due
|
||||
if ( vInters[i].first == vInters[j].first) {
|
||||
// se entranti elimino la prima
|
||||
if ( vInters[i].first == ILBT_IN || vInters[i].first == ILBT_TG_INI)
|
||||
vInters.erase( vInters.begin() + i) ;
|
||||
// altrimenti la seconda
|
||||
else
|
||||
vInters.erase( vInters.begin() + j) ;
|
||||
if ( i > 0)
|
||||
-- j ;
|
||||
continue ;
|
||||
}
|
||||
else {
|
||||
if ( dU1 > dLen - EPS_SMALL)
|
||||
vInters.emplace_back( ILBT_IN, dLen) ;
|
||||
else if ( dU2 < EPS_SMALL)
|
||||
vInters.emplace_back( ILBT_OUT, 0) ;
|
||||
else {
|
||||
vInters.emplace_back( ILBT_TG_INI, Clamp( dU1, 0., dLen)) ;
|
||||
vInters.emplace_back( ILBT_TG_FIN, Clamp( dU2, 0., dLen)) ;
|
||||
// se hanno lo stesso parametro
|
||||
else if ( abs( vInters[i].second - vInters[j].second) < EPS_SMALL) {
|
||||
// se una entrante e l'altra uscente, cambio in touch ed elimino la seconda
|
||||
if ( ( vInters[i].first == ILBT_IN && vInters[j].first == ILBT_OUT) ||
|
||||
( vInters[i].first == ILBT_OUT && vInters[j].first == ILBT_IN)) {
|
||||
vInters[i].first = ILBT_TOUCH ;
|
||||
vInters.erase( vInters.begin() + j) ;
|
||||
if ( i > 0)
|
||||
-- j ;
|
||||
continue ;
|
||||
}
|
||||
// se prima puntuale e l'altra inizio o fine di coincidenza, elimino la prima
|
||||
else if ( ( vInters[i].first == ILBT_IN || vInters[i].first == ILBT_OUT || vInters[i].first == ILBT_TOUCH) &&
|
||||
( vInters[j].first == ILBT_TG_INI || vInters[j].first == ILBT_TG_FIN)) {
|
||||
vInters.erase( vInters.begin() + i) ;
|
||||
if ( i > 0)
|
||||
-- j ;
|
||||
continue ;
|
||||
}
|
||||
// se prima inizio o fine di coincidenza e l'altra puntuale, elimino la seconda
|
||||
else if ( ( vInters[i].first == ILBT_TG_INI || vInters[i].first == ILBT_TG_FIN) &&
|
||||
( vInters[j].first == ILBT_IN || vInters[j].first == ILBT_OUT || vInters[j].first == ILBT_TOUCH)) {
|
||||
vInters.erase( vInters.begin() + j) ;
|
||||
if ( i > 0)
|
||||
-- j ;
|
||||
continue ;
|
||||
}
|
||||
// se una fine di coincidenza e l'altra inizio di coincidenza, elimino entrambe
|
||||
else if ( ( vInters[i].first == ILBT_TG_FIN && vInters[j].first == ILBT_TG_INI) ||
|
||||
( vInters[i].first == ILBT_TG_INI && vInters[j].first == ILBT_TG_FIN)) {
|
||||
vInters.erase( vInters.begin() + j) ;
|
||||
vInters.erase( vInters.begin() + i) ;
|
||||
if ( i > 0)
|
||||
-- j ;
|
||||
continue ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
// passo alla successiva
|
||||
++ j ;
|
||||
}
|
||||
|
||||
// Altrimenti sono due intersezioni con attraversamento
|
||||
if ( ! bFinite) {
|
||||
vInters.emplace_back( ILBT_IN, dU1) ;
|
||||
vInters.emplace_back( ILBT_OUT, dU2) ;
|
||||
}
|
||||
else {
|
||||
if ( dU1 > dLen - EPS_SMALL)
|
||||
vInters.emplace_back( ILBT_IN, dLen) ;
|
||||
else if ( dU2 < EPS_SMALL)
|
||||
vInters.emplace_back( ILBT_OUT, 0) ;
|
||||
else {
|
||||
vInters.emplace_back( ILBT_IN, Clamp( dU1, 0., dLen)) ;
|
||||
vInters.emplace_back( ILBT_OUT, Clamp( dU2, 0., dLen)) ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2022-2022
|
||||
//----------------------------------------------------------------------------
|
||||
// File : IntersLineBox.h Data : 08.01.22 Versione : 2.4a3
|
||||
// Contenuto : Dichiarazione delle funzioni base per intersezione linea/box.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 08.01.22 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkPoint3d.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Linea e box allineato agli assi sono nel medesimo riferimento.
|
||||
// Con intersezione viene restituito true e i parametri in dU1 e dU2.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersLineBox( const Point3d& ptL, const Vector3d& vtL,
|
||||
const Point3d& ptMin, const Point3d& ptMax,
|
||||
double& dU1, double& dU2) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool
|
||||
TestIntersLineBox( const Point3d& ptL, const Vector3d& vtL,
|
||||
const Point3d& ptMin, const Point3d& ptMax)
|
||||
{
|
||||
double dU1, dU2 ;
|
||||
return IntersLineBox( ptL, vtL, ptMin, ptMax, dU1, dU2) ;
|
||||
}
|
||||
+56
-3
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2017-2022
|
||||
// EgalTech 2017-2018
|
||||
//----------------------------------------------------------------------------
|
||||
// File : IntersLineSurfStd.cpp Data : 08.01.22 Versione : 2.4a3
|
||||
// File : IntersLineSurfStd.cpp Data : 03.12.18 Versione : 1.9l1
|
||||
// Contenuto : Implementazione delle funzioni di intersezione
|
||||
// componente lineare e superficie standard.
|
||||
//
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "IntersLineSurfStd.h"
|
||||
#include "IntersLineBox.h"
|
||||
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
||||
#include "/EgtDev/Include/EGkFrame3d.h"
|
||||
#include "/EgtDev/Include/ENkPolynomialRoots.h"
|
||||
@@ -22,6 +21,60 @@
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Punti e vettore devono essere espressi nel medesimo sistema di riferimento.
|
||||
// Il box è allineato con gli assi di questo sistema di riferimento.
|
||||
// In caso di intersezione viene restituito true e i parametri in dU1 e dU2.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersLineBox( const Point3d& ptP, const Vector3d& vtV,
|
||||
const Point3d& ptMin, const Point3d& ptMax, double& dU1, double& dU2)
|
||||
{
|
||||
// Casi di intersezione impossibile
|
||||
if ( abs( vtV.x) < EPS_ZERO && ( ptP.x < ptMin.x - EPS_SMALL || ptP.x > ptMax.x + EPS_SMALL))
|
||||
return false ;
|
||||
if ( abs( vtV.y) < EPS_ZERO && ( ptP.y < ptMin.y - EPS_SMALL || ptP.y > ptMax.y + EPS_SMALL))
|
||||
return false ;
|
||||
if ( abs( vtV.z) < EPS_ZERO && ( ptP.z < ptMin.z - EPS_SMALL || ptP.z > ptMax.z + EPS_SMALL))
|
||||
return false ;
|
||||
|
||||
// Inizializzo parametri intersezioni
|
||||
dU1 = -INFINITO ;
|
||||
dU2 = INFINITO ;
|
||||
|
||||
// Confronto con piani YZ (perpendicolari ad asse X)
|
||||
if ( vtV.x > EPS_ZERO) {
|
||||
dU1 = max( dU1, ( ptMin.x - ptP.x) / vtV.x) ;
|
||||
dU2 = min( dU2, ( ptMax.x - ptP.x) / vtV.x) ;
|
||||
}
|
||||
else if ( vtV.x < -EPS_ZERO) {
|
||||
dU1 = max( dU1, ( ptMax.x - ptP.x) / vtV.x) ;
|
||||
dU2 = min( dU2, ( ptMin.x - ptP.x) / vtV.x) ;
|
||||
}
|
||||
|
||||
// Confronto con piani ZX (perpendicolari ad asse Y)
|
||||
if ( vtV.y > EPS_ZERO) {
|
||||
dU1 = max( dU1, ( ptMin.y - ptP.y) / vtV.y) ;
|
||||
dU2 = min( dU2, ( ptMax.y - ptP.y) / vtV.y) ;
|
||||
}
|
||||
else if ( vtV.y < -EPS_ZERO) {
|
||||
dU1 = max( dU1, ( ptMax.y - ptP.y) / vtV.y) ;
|
||||
dU2 = min( dU2, ( ptMin.y - ptP.y) / vtV.y) ;
|
||||
}
|
||||
|
||||
// Confronto con piani XY (perpendicolari ad asse Z)
|
||||
if ( vtV.z > EPS_ZERO) {
|
||||
dU1 = max( dU1, ( ptMin.z - ptP.z) / vtV.z) ;
|
||||
dU2 = min( dU2, ( ptMax.z - ptP.z) / vtV.z) ;
|
||||
}
|
||||
else if ( vtV.z < -EPS_ZERO) {
|
||||
dU1 = max( dU1, ( ptMax.z - ptP.z) / vtV.z) ;
|
||||
dU2 = min( dU2, ( ptMin.z - ptP.z) / vtV.z) ;
|
||||
}
|
||||
|
||||
return ( dU2 >= dU1) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
LineDisc( const Point3d& ptPLine, const Vector3d& vtVLine,
|
||||
|
||||
@@ -34,6 +34,11 @@
|
||||
// Costanti tipologia di componente lineare
|
||||
enum LinType { Line = 0, Ray = 1, Segment = 2} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool IntersLineBox( const Point3d& ptP, const Vector3d& vtV,
|
||||
const Point3d& ptMin, const Point3d& ptMax, double& dU1, double& dU2) ;
|
||||
|
||||
|
||||
// Costanti tipologia di intersezioni fra un componente lineare e un disco
|
||||
enum LinCompDiscIntersType { D_ERROR_INT = -1, D_NO_INTERS = 0, D_BOUNDARY_INT_LINE_NOT_IN_PLANE = 1,
|
||||
D_INNER_INT_LINE_NOT_IN_PLANE = 2, D_ONE_INT_LINE_ON_PLANE = 3,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2022
|
||||
// EgalTech 2015-2019
|
||||
//----------------------------------------------------------------------------
|
||||
// File : IntersLineSurfTm.cpp Data : 08.01.22 Versione : 2.4a3
|
||||
// File : IntersLineSurfTm.cpp Data : 09.03.15 Versione : 2.1b6
|
||||
// Contenuto : Implementazione della intersezione linea/superficie trimesh.
|
||||
//
|
||||
//
|
||||
@@ -14,7 +14,8 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "ProjPlane.h"
|
||||
#include "IntersLineBox.h"
|
||||
#include "IntersLineSurfStd.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineTria.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
|
||||
|
||||
+6
-34
@@ -1,8 +1,8 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
//----------------------------------------------------------------------------
|
||||
// File : IntersPlaneBox.cpp Data : 07.05.20 Versione : 2.2e1
|
||||
// Contenuto : Implementazione della intersezione piano/box.
|
||||
// File : IntersLineBox.cpp Data : 07.05.20 Versione : 2.2e1
|
||||
// Contenuto : Implementazione della intersezione linea/box.
|
||||
//
|
||||
//
|
||||
//
|
||||
@@ -20,47 +20,19 @@
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Box e piano devono essere nello stesso riferimento. Il box deve essere axis aligned.
|
||||
bool
|
||||
TestIntersPlaneBox( const Plane3d& plPlane, const BBox3d& b3Box)
|
||||
{
|
||||
// Verifica del piano
|
||||
if ( ! plPlane.IsValid())
|
||||
return false ;
|
||||
// Centro e estensione del box
|
||||
Point3d ptCen ;
|
||||
Vector3d vtExt ;
|
||||
if ( ! b3Box.GetCenterExtent( ptCen, vtExt))
|
||||
return false ;
|
||||
// Distanza del centro dal piano
|
||||
double dDist = DistPointPlane( ptCen, plPlane) ;
|
||||
// Proiezione dell'estensione sulla normale al piano
|
||||
Vector3d vtN = plPlane.GetVersN() ;
|
||||
double dProjExt = vtExt.x * abs( vtN.x) + vtExt.y * abs( vtN.y) + vtExt.z * abs( vtN.z) ;
|
||||
// Confronto distanza del centro con estensione proiettata
|
||||
return ( abs( dDist) < dProjExt + EPS_SMALL) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersPlaneBox( const Plane3d& plPlane, const BBox3d& b3Box,
|
||||
IntersPlaneBox( const Point3d& ptOn, const Vector3d& vtN, const BBox3d& b3Box,
|
||||
PNTVECTOR& vPnt, BIPNTVECTOR& vBpt, TRIA3DVECTOR& vTria)
|
||||
{
|
||||
// Verifico il piano
|
||||
if ( ! plPlane.IsValid())
|
||||
// Creo il piano
|
||||
Plane3d plPlane ;
|
||||
if ( ! plPlane.Set( ptOn, vtN))
|
||||
return false ;
|
||||
// Recupero i dati del Box
|
||||
Point3d ptMin ;
|
||||
double dDimX, dDimY, dDimZ ;
|
||||
if ( ! b3Box.GetMinDim( ptMin, dDimX, dDimY, dDimZ))
|
||||
return false ;
|
||||
// Pulisco vettori intersezioni
|
||||
vPnt.clear() ;
|
||||
vBpt.clear() ;
|
||||
vTria.clear() ;
|
||||
// Verifico se può esistere intersezione
|
||||
if ( ! TestIntersPlaneBox( plPlane, b3Box))
|
||||
return true ;
|
||||
// Contorno di base
|
||||
PolyLine PL ;
|
||||
PL.AddUPoint( 0, ptMin) ;
|
||||
|
||||
+97
-223
@@ -27,39 +27,102 @@
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static void
|
||||
UpdateIntersPlaneSurfTm( const Plane3d& plPlane, const Triangle3d& Tria, PNTVECTOR& vPnt, BIPNTVECTOR& vBpt, TRIA3DVECTOR& vTria,
|
||||
PointGrid3d& PtGrid, HashGrids3d& LnGrid, HashGrids3d& TrGrid)
|
||||
{
|
||||
// intersezione tra il piano e il triangolo
|
||||
Point3d ptInt, ptInt2 ;
|
||||
int nRes = IntersPlaneTria( plPlane, Tria, ptInt, ptInt2) ;
|
||||
// se vertice
|
||||
if ( nRes == IPTT_VERT) {
|
||||
// verifico se punto già inserito
|
||||
int nId ;
|
||||
if ( ! PtGrid.Find( ptInt, 10 * EPS_SMALL, nId)) {
|
||||
vPnt.emplace_back( ptInt) ;
|
||||
PtGrid.InsertPoint( ptInt, int( vPnt.size()) - 1) ;
|
||||
// Intersezione di un piano con una superficie TriMesh
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersPlaneSurfTm( const Plane3d& plPlane, const ISurfTriMesh& Stm,
|
||||
PNTVECTOR& vPnt, BIPNTVECTOR& vBpt, TRIA3DVECTOR& vTria)
|
||||
{
|
||||
// verifico piano
|
||||
if ( &plPlane == nullptr || plPlane.GetVersN().IsSmall())
|
||||
return false ;
|
||||
// verifico superficie
|
||||
if ( &Stm == nullptr || ! Stm.IsValid())
|
||||
return false ;
|
||||
// verifico parametri di ritorno
|
||||
if ( &vPnt == nullptr || &vBpt == nullptr || &vTria == nullptr)
|
||||
return false ;
|
||||
vPnt.clear() ;
|
||||
vBpt.clear() ;
|
||||
vTria.clear() ;
|
||||
|
||||
// per ricerca veloce di punti ripetuti
|
||||
PointGrid3d PtGrid ;
|
||||
PtGrid.Init( 100) ;
|
||||
|
||||
// per ricerca veloce di linee ripetute
|
||||
HashGrids3d LnGrid ;
|
||||
LnGrid.SetActivationGrid( true) ;
|
||||
|
||||
// per ricerca veloce di triangoli ripetuti
|
||||
HashGrids3d TrGrid ;
|
||||
TrGrid.SetActivationGrid( true) ;
|
||||
|
||||
// cerco i triangoli intersecati dal piano
|
||||
Triangle3d Tria ;
|
||||
int nT = Stm.GetFirstTriangle( Tria) ;
|
||||
while ( nT != SVT_NULL) {
|
||||
// intersezione tra il piano e il triangolo
|
||||
Point3d ptInt, ptInt2 ;
|
||||
int nRes = IntersPlaneTria( plPlane, Tria, ptInt, ptInt2) ;
|
||||
// se vertice
|
||||
if ( nRes == IPTT_VERT) {
|
||||
// verifico se punto già inserito
|
||||
int nId ;
|
||||
if ( ! PtGrid.Find( ptInt, 10 * EPS_SMALL, nId)) {
|
||||
vPnt.emplace_back( ptInt) ;
|
||||
PtGrid.InsertPoint( ptInt, int( vPnt.size()) - 1) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// se altrimenti segmento
|
||||
else if ( nRes == IPTT_EDGE || nRes == IPTT_YES) {
|
||||
// se abbastanza lungo
|
||||
if ( ! AreSamePointApprox( ptInt, ptInt2)) {
|
||||
// verifico se già inserito
|
||||
// se altrimenti segmento
|
||||
else if ( nRes == IPTT_EDGE || nRes == IPTT_YES) {
|
||||
// se abbastanza lungo
|
||||
if ( ! AreSamePointApprox( ptInt, ptInt2)) {
|
||||
// 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] ;
|
||||
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))) {
|
||||
bFound = true ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// se non inserito, procedo
|
||||
if ( ! bFound) {
|
||||
vBpt.emplace_back( ptInt, ptInt2) ;
|
||||
LnGrid.Add( int( vBpt.size()) - 1, b3Line) ;
|
||||
LnGrid.Update() ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// se altrimenti l'intero triangolo
|
||||
else if ( nRes == IPTT_OVERLAPS) {
|
||||
// verifico se triangolo già inserito
|
||||
bool bFound = false ;
|
||||
BBox3d b3Line( ptInt, ptInt2) ;
|
||||
BBox3d b3Tria( Tria.GetP( 0), Tria.GetP( 1)) ;
|
||||
b3Tria.Add( Tria.GetP( 2)) ;
|
||||
INTVECTOR vnIds ;
|
||||
if ( LnGrid.Find( b3Line, vnIds)) {
|
||||
if ( TrGrid.Find( b3Tria, vnIds)) {
|
||||
for ( int i = 0 ; i < int( vnIds.size()) ; ++ i) {
|
||||
int nA = vnIds[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))) {
|
||||
const Triangle3d& trOth = vTria[nA] ;
|
||||
array< bool, 3> bOth = { false, false, false} ;
|
||||
for ( int j = 0 ; j < 3 ; ++ j) {
|
||||
for ( int k = 0 ; k < 3 ; ++ k) {
|
||||
if ( ! bOth[k])
|
||||
bOth[k] = AreSamePointEpsilon( Tria.GetP( j), trOth.GetP( k), 10 * EPS_SMALL) ;
|
||||
}
|
||||
}
|
||||
if ( bOth[0] && bOth[1] && bOth[2]) {
|
||||
bFound = true ;
|
||||
break ;
|
||||
}
|
||||
@@ -67,52 +130,15 @@ UpdateIntersPlaneSurfTm( const Plane3d& plPlane, const Triangle3d& Tria, PNTVECT
|
||||
}
|
||||
// se non inserito, procedo
|
||||
if ( ! bFound) {
|
||||
vBpt.emplace_back( ptInt, ptInt2) ;
|
||||
LnGrid.Add( int( vBpt.size()) - 1, b3Line) ;
|
||||
LnGrid.Update() ;
|
||||
vTria.emplace_back( Tria) ;
|
||||
TrGrid.Add( int( vTria.size()) - 1, b3Tria) ;
|
||||
TrGrid.Update() ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// se altrimenti l'intero triangolo
|
||||
else if ( nRes == IPTT_OVERLAPS) {
|
||||
// verifico se triangolo già inserito
|
||||
bool bFound = false ;
|
||||
BBox3d b3Tria( Tria.GetP( 0), Tria.GetP( 1)) ;
|
||||
b3Tria.Add( Tria.GetP( 2)) ;
|
||||
INTVECTOR vnIds ;
|
||||
if ( TrGrid.Find( b3Tria, vnIds)) {
|
||||
for ( int i = 0 ; i < int( vnIds.size()) ; ++ i) {
|
||||
int nA = vnIds[i] ;
|
||||
const Triangle3d& trOth = vTria[nA] ;
|
||||
array< bool, 3> bOth = { false, false, false} ;
|
||||
for ( int j = 0 ; j < 3 ; ++ j) {
|
||||
for ( int k = 0 ; k < 3 ; ++ k) {
|
||||
if ( ! bOth[k])
|
||||
bOth[k] = AreSamePointEpsilon( Tria.GetP( j), trOth.GetP( k), 10 * EPS_SMALL) ;
|
||||
}
|
||||
}
|
||||
if ( bOth[0] && bOth[1] && bOth[2]) {
|
||||
bFound = true ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// se non inserito, procedo
|
||||
if ( ! bFound) {
|
||||
vTria.emplace_back( Tria) ;
|
||||
TrGrid.Add( int( vTria.size()) - 1, b3Tria) ;
|
||||
TrGrid.Update() ;
|
||||
}
|
||||
// passo al prossimo triangolo
|
||||
nT = Stm.GetNextTriangle( nT, Tria) ;
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static void
|
||||
AdjustIntersPlaneSurfTm( PNTVECTOR& vPnt, BIPNTVECTOR& vBpt, TRIA3DVECTOR& vTria,
|
||||
const Plane3d& plPlane, const HashGrids3d& LnGrid, const HashGrids3d& TrGrid)
|
||||
{
|
||||
// rimuovo i punti che stanno sui segmenti
|
||||
for ( int i = int( vPnt.size()) - 1 ; i >= 0 ; -- i) {
|
||||
bool bFound = false ;
|
||||
@@ -164,7 +190,7 @@ AdjustIntersPlaneSurfTm( PNTVECTOR& vPnt, BIPNTVECTOR& vBpt, TRIA3DVECTOR& vTria
|
||||
int nA = vnIds[j] ;
|
||||
const Triangle3d& trOth = vTria[nA] ;
|
||||
if ( DistPointTriangle( ptStart, trOth).IsEpsilon( 10 * EPS_SMALL) &&
|
||||
DistPointTriangle( ptEnd, trOth).IsEpsilon( 10 * EPS_SMALL)) {
|
||||
DistPointTriangle( ptEnd, trOth).IsEpsilon( 10 * EPS_SMALL)) {
|
||||
bFound = true ;
|
||||
break ;
|
||||
}
|
||||
@@ -174,157 +200,5 @@ AdjustIntersPlaneSurfTm( PNTVECTOR& vPnt, BIPNTVECTOR& vBpt, TRIA3DVECTOR& vTria
|
||||
vBpt.erase( vBpt.begin() + i) ;
|
||||
}
|
||||
|
||||
// porto i punti esattamente nel piano
|
||||
for ( int i = 0 ; i < int( vPnt.size()) ; ++ i) {
|
||||
vPnt[i] = ProjectPointOnPlane( vPnt[i], plPlane) ;
|
||||
}
|
||||
|
||||
// porto i segmenti esattamente nel piano
|
||||
for ( int i = 0 ; i < int( vBpt.size()) ; ++ i) {
|
||||
vBpt[i].first = ProjectPointOnPlane( vBpt[i].first, plPlane) ;
|
||||
vBpt[i].second = ProjectPointOnPlane( vBpt[i].second, plPlane) ;
|
||||
}
|
||||
|
||||
// porto i triangoli esattamente nel piano
|
||||
for ( int i = 0 ; i < int( vTria.size()) ; ++ i) {
|
||||
Triangle3d& trTria = vTria[i] ;
|
||||
trTria.SetP( 0, ProjectPointOnPlane( trTria.GetP( 0), plPlane)) ;
|
||||
trTria.SetP( 1, ProjectPointOnPlane( trTria.GetP( 1), plPlane)) ;
|
||||
trTria.SetP( 2, ProjectPointOnPlane( trTria.GetP( 2), plPlane)) ;
|
||||
trTria.Validate( true) ;
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Intersezione di un piano con una superficie TriMesh
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersPlaneSurfTm( const Plane3d& plPlane, const ISurfTriMesh& Stm,
|
||||
PNTVECTOR& vPnt, BIPNTVECTOR& vBpt, TRIA3DVECTOR& vTria)
|
||||
{
|
||||
// verifico piano
|
||||
if ( &plPlane == nullptr || plPlane.GetVersN().IsSmall())
|
||||
return false ;
|
||||
// verifico superficie
|
||||
if ( &Stm == nullptr || ! Stm.IsValid())
|
||||
return false ;
|
||||
// verifico parametri di ritorno
|
||||
if ( &vPnt == nullptr || &vBpt == nullptr || &vTria == nullptr)
|
||||
return false ;
|
||||
vPnt.clear() ;
|
||||
vBpt.clear() ;
|
||||
vTria.clear() ;
|
||||
|
||||
// per ricerca veloce di punti ripetuti
|
||||
PointGrid3d PtGrid ;
|
||||
PtGrid.Init( 100) ;
|
||||
|
||||
// per ricerca veloce di linee ripetute
|
||||
HashGrids3d LnGrid ;
|
||||
LnGrid.SetActivationGrid( true) ;
|
||||
|
||||
// per ricerca veloce di triangoli ripetuti
|
||||
HashGrids3d TrGrid ;
|
||||
TrGrid.SetActivationGrid( true) ;
|
||||
|
||||
// cerco i triangoli intersecati dal piano
|
||||
Triangle3d Tria ;
|
||||
int nT = Stm.GetFirstTriangle( Tria) ;
|
||||
while ( nT != SVT_NULL) {
|
||||
UpdateIntersPlaneSurfTm( plPlane, Tria, vPnt, vBpt, vTria, PtGrid, LnGrid, TrGrid) ;
|
||||
nT = Stm.GetNextTriangle( nT, Tria) ;
|
||||
}
|
||||
|
||||
AdjustIntersPlaneSurfTm( vPnt, vBpt, vTria, plPlane, LnGrid, TrGrid) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Intersezione di molti piani paralleli con una superficie TriMesh
|
||||
//----------------------------------------------------------------------------
|
||||
IntersParPlanesSurfTm::IntersParPlanesSurfTm( const Frame3d& frPlanes, const ISurfTriMesh& Stm)
|
||||
: m_bOk( false), m_frPlanes( frPlanes), m_pSTm( &Stm)
|
||||
{
|
||||
// verifico esistenza superficie
|
||||
if ( m_pSTm == nullptr || ! m_pSTm->IsValid())
|
||||
return ;
|
||||
|
||||
// creo HashGrid 1d
|
||||
const int LIM_HG_TRIA = 127 ;
|
||||
m_HGrids.SetActivationGrid( m_pSTm->GetTriangleCount() > LIM_HG_TRIA) ;
|
||||
|
||||
// riempio HashGrid
|
||||
Triangle3d Tria ;
|
||||
int nT = Stm.GetFirstTriangle( Tria) ;
|
||||
while ( nT != SVT_NULL) {
|
||||
// calcolo il BBox del triangolo nel riferimento dei piani
|
||||
Tria.ToLoc( m_frPlanes) ;
|
||||
BBox3d b3Tria ;
|
||||
b3Tria.Add( Tria.GetP( 0)) ;
|
||||
b3Tria.Add( Tria.GetP( 1)) ;
|
||||
b3Tria.Add( Tria.GetP( 2)) ;
|
||||
// inserisco nella griglia
|
||||
if ( ! m_HGrids.Add( nT, b3Tria))
|
||||
return ;
|
||||
// passo al prossimo triangolo
|
||||
nT = Stm.GetNextTriangle( nT, Tria) ;
|
||||
}
|
||||
// aggiorno
|
||||
m_bOk = m_HGrids.Update() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersParPlanesSurfTm::GetInters( double dDist, PNTVECTOR& vPnt, BIPNTVECTOR& vBpt, TRIA3DVECTOR& vTria) const
|
||||
{
|
||||
// verifico validità
|
||||
if ( ! m_bOk)
|
||||
return false ;
|
||||
|
||||
// verifico parametri di ritorno
|
||||
if ( &vPnt == nullptr || &vBpt == nullptr || &vTria == nullptr)
|
||||
return false ;
|
||||
vPnt.clear() ;
|
||||
vBpt.clear() ;
|
||||
vTria.clear() ;
|
||||
|
||||
// per ricerca veloce di punti ripetuti
|
||||
PointGrid3d PtGrid ;
|
||||
PtGrid.Init( 100) ;
|
||||
|
||||
// per ricerca veloce di linee ripetute
|
||||
HashGrids3d LnGrid ;
|
||||
LnGrid.SetActivationGrid( true) ;
|
||||
|
||||
// per ricerca veloce di triangoli ripetuti
|
||||
HashGrids3d TrGrid ;
|
||||
TrGrid.SetActivationGrid( true) ;
|
||||
|
||||
// calcolo il piano ( in globale)
|
||||
Point3d ptPl = m_frPlanes.Orig() + dDist * m_frPlanes.VersZ() ;
|
||||
Plane3d plPlane ;
|
||||
plPlane.Set( ptPl, m_frPlanes.VersZ()) ;
|
||||
|
||||
// calcolo box del piano ( nel riferimento)
|
||||
BBox3d b3Plane ;
|
||||
b3Plane.Add( Point3d( 0, 0, dDist)) ;
|
||||
b3Plane.Expand( INFINITO - 1 , INFINITO - 1, 0) ;
|
||||
|
||||
// recupero indici triangoli che intersecano box
|
||||
INTVECTOR vnIds ;
|
||||
if ( m_HGrids.Find( b3Plane, vnIds)) {
|
||||
for ( int i = 0 ; i < int( vnIds.size()) ; ++ i) {
|
||||
int nT = vnIds[i] ;
|
||||
Triangle3d Tria ;
|
||||
m_pSTm->GetTriangle( nT, Tria) ;
|
||||
UpdateIntersPlaneSurfTm( plPlane, Tria, vPnt, vBpt, vTria, PtGrid, LnGrid, TrGrid) ;
|
||||
}
|
||||
}
|
||||
|
||||
AdjustIntersPlaneSurfTm( vPnt, vBpt, vTria, plPlane, LnGrid, TrGrid) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "/EgtDev/Include/EGkPointGrid3d.h"
|
||||
#include "/EgtDev/Include/EGkHashGrids3d.h"
|
||||
#include "/EgtDev/Include/EGkDistPointTria.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include <array>
|
||||
|
||||
using namespace std ;
|
||||
@@ -116,7 +116,7 @@ IntersSurfTmSurfTm( const ISurfTriMesh& Stm1, const ISurfTriMesh& Stm2,
|
||||
}
|
||||
}
|
||||
// se altrimenti sovrapposizione
|
||||
else if ( nRes == ITTT_OVERLAPS || nRes == ITTT_COUNTER_OVERLAPS) {
|
||||
else if ( nRes == ITTT_OVERLAPS) {
|
||||
for ( const auto& Tria : vIttTria) {
|
||||
// verifico se triangolo già inserito
|
||||
bool bFound = false ;
|
||||
|
||||
+5
-34
@@ -83,37 +83,8 @@ IntersTriaTria( const Triangle3d& trTria1, const Triangle3d& trTria2, Point3d& p
|
||||
// se i triangoli sono complanari
|
||||
if ( nResPP == IPPT_OVERLAPS ||
|
||||
((( nVertPos1 == 0 && nVertNeg1 == 0) || ( nVertPos2 == 0 && nVertNeg2 == 0)) &&
|
||||
( trTria1.GetN() ^ trTria2.GetN()).SqLen() < 25 * SIN_EPS_ANG_SMALL * SIN_EPS_ANG_SMALL)) {
|
||||
// verifica per triangoli con normali controverse
|
||||
bool bCounter = false ;
|
||||
Triangle3d trMyTria2 = trTria2 ;
|
||||
if ( trTria1.GetN() * trTria2.GetN() < 0) {
|
||||
Point3d ptV0 = trMyTria2.GetP( 0) ;
|
||||
trMyTria2.SetP( 0, trMyTria2.GetP( 1)) ;
|
||||
trMyTria2.SetP( 1, ptV0) ;
|
||||
trMyTria2.Validate() ;
|
||||
bCounter = true ;
|
||||
}
|
||||
// verifica per triangoli coincidenti
|
||||
bool bAreSameTria = ( ( AreSamePointExact( trTria1.GetP( 0), trMyTria2.GetP( 0)) &&
|
||||
AreSamePointExact( trTria1.GetP( 1), trMyTria2.GetP( 1)) &&
|
||||
AreSamePointExact( trTria1.GetP( 2), trMyTria2.GetP( 2))) ||
|
||||
( AreSamePointExact( trTria1.GetP( 0), trMyTria2.GetP( 1)) &&
|
||||
AreSamePointExact( trTria1.GetP( 1), trMyTria2.GetP( 2)) &&
|
||||
AreSamePointExact( trTria1.GetP( 2), trMyTria2.GetP( 0))) ||
|
||||
( AreSamePointExact( trTria1.GetP( 0), trMyTria2.GetP( 2)) &&
|
||||
AreSamePointExact( trTria1.GetP( 1), trMyTria2.GetP( 0)) &&
|
||||
AreSamePointExact( trTria1.GetP( 2), trMyTria2.GetP( 1)))) &&
|
||||
( AreSameVectorExact( trTria1.GetN(), trMyTria2.GetN())) ;
|
||||
if ( bAreSameTria) {
|
||||
vTria.emplace_back( trTria1) ;
|
||||
return ( bCounter ? ITTT_COUNTER_OVERLAPS : ITTT_OVERLAPS) ;
|
||||
}
|
||||
if ( ITTT_OVERLAPS == IntersCoplanarTriaTria( trTria1, trMyTria2, vTria)) {
|
||||
return ( bCounter ? ITTT_COUNTER_OVERLAPS : ITTT_OVERLAPS) ;
|
||||
}
|
||||
return ITTT_NO ;
|
||||
}
|
||||
( trTria1.GetN() ^ trTria2.GetN()).SqLen() < 25 * SIN_EPS_ANG_SMALL * SIN_EPS_ANG_SMALL))
|
||||
return IntersCoplanarTriaTria( trTria1, trTria2, vTria) ;
|
||||
|
||||
// limito la linea di intersezione con il primo triangolo
|
||||
Point3d ptSt1, ptEn1 ;
|
||||
@@ -141,7 +112,7 @@ IntersTriaTria( const Triangle3d& trTria1, const Triangle3d& trTria2, Point3d& p
|
||||
int
|
||||
IntersCoplanarTriaTria( const Triangle3d& trTria1, const Triangle3d& trTria2, TRIA3DVECTOR& vTria)
|
||||
{
|
||||
// Se i tre vertici del secondo triangolo stanno tutti a destra di almeno un lato del primo, non c'� intersezione
|
||||
// Se i tre vertici del secondo triangolo stanno tutti a destra di almeno un lato del primo, non c'è intersezione
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
Vector3d vtSide = trTria1.GetP( ( i + 1) % 3) - trTria1.GetP( i) ;
|
||||
Vector3d vtSN = vtSide ^ trTria1.GetN() ;
|
||||
@@ -151,7 +122,7 @@ IntersCoplanarTriaTria( const Triangle3d& trTria1, const Triangle3d& trTria2, TR
|
||||
( trTria2.GetP( 2) - trTria1.GetP( i)) * vtSN > - EPS_TRIA_H)
|
||||
return ITTT_NO ;
|
||||
}
|
||||
// Se i tre vertici del primo triangolo stanno tutti a destra di almeno un lato del secondo, non c'� intersezione
|
||||
// Se i tre vertici del primo triangolo stanno tutti a destra di almeno un lato del secondo, non c'è intersezione
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
Vector3d vtSide = trTria2.GetP( ( i + 1) % 3) - trTria2.GetP( i) ;
|
||||
Vector3d vtSN = vtSide ^ trTria2.GetN() ;
|
||||
@@ -234,7 +205,7 @@ int
|
||||
FindTriaTriaIntersType( const Triangle3d& trTria1, const Triangle3d& trTria2, const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
double dStU1, double dEnU1, double dStU2, double dEnU2, int nRes1, int nRes2, double& dIntStU, double& dIntEnU)
|
||||
{
|
||||
// Controllo su validit� input
|
||||
// Controllo su validità input
|
||||
if ( ! ( trTria1.IsValid() && trTria2.IsValid() && vtLineDir.IsNormalized()))
|
||||
return ITTT_NO ;
|
||||
// Casi
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
#include "CurveLine.h"
|
||||
#include "CurveArc.h"
|
||||
#include "CreateCurveAux.h"
|
||||
#include "/EgtDev/Include/EGkLinePerpTwoCurves.h"
|
||||
#include "/EgtDev/Include/EGkLinePntPerpCurve.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgkLinePerpTwoCurves.h"
|
||||
#include "/EgtDev/Include/EgkLinePntPerpCurve.h"
|
||||
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CurveLine.h"
|
||||
#include "/EgtDev/Include/EGkLinePntMinDistCurve.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgkLinePntMinDistCurve.h"
|
||||
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
#include "CurveComposite.h"
|
||||
#include "CreateCurveAux.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkLinePntPerpCurve.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgkLinePntPerpCurve.h"
|
||||
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
+2
-2
@@ -19,8 +19,8 @@
|
||||
#include "CurveComposite.h"
|
||||
#include "CreateCurveAux.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkLinePntTgCurve.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgkLinePntTgCurve.h"
|
||||
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
#include "stdafx.h"
|
||||
#include "CreateCurveAux.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkLineTgCurvePerpCurve.h"
|
||||
#include "/EgtDev/Include/EGkLinePntTgCurve.h"
|
||||
#include "/EgtDev/Include/EgkLineTgCurvePerpCurve.h"
|
||||
#include "/EgtDev/Include/EgkLinePntTgCurve.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "CreateCurveAux.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkLineTgTwoCurves.h"
|
||||
#include "/EgtDev/Include/EgkLineTgTwoCurves.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
-232
@@ -1,232 +0,0 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2022-2022
|
||||
//----------------------------------------------------------------------------
|
||||
// File : MedialAxis.cpp Data : 22.08.22 Versione : 2.4h2
|
||||
// Contenuto : Funzione calcolo approssimato MedialAxis principale.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 22.08.22 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "GeoConst.h"
|
||||
#include "CurveLine.h"
|
||||
#include "CurveArc.h"
|
||||
#include "CurveBezier.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkBBox3d.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EGkMedialAxis.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
ProcessCircleCurve( const Point3d& ptCen, double dDiam, const CurveComposite& crvCompo,
|
||||
PNTVECTOR& vPnt, DBLVECTOR& vDiam)
|
||||
{
|
||||
|
||||
// pulizia risultati
|
||||
vPnt.clear() ;
|
||||
vDiam.clear() ;
|
||||
// creazione circonferenza
|
||||
CurveArc crvCirc ;
|
||||
crvCirc.Set( ptCen, Z_AX, dDiam / 2) ;
|
||||
// classificazioni parti di circonferenza rispetto alla curva
|
||||
IntersCurveCurve LnCmpInt( crvCirc, crvCompo) ;
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( ! LnCmpInt.GetCurveClassification( 0, 10 * EPS_SMALL, ccClass))
|
||||
return false ;
|
||||
int nCount = int( ccClass.size()) ;
|
||||
|
||||
// ... per evitare percorsi di ritorno
|
||||
int nInparts = 0 ;
|
||||
|
||||
for ( int i = 0 ; i < nCount ; ++ i) {
|
||||
if ( ccClass[i].nClass == CRVC_IN) {
|
||||
nInparts ++ ;
|
||||
// gestione unione intervallo a cavallo del parametro 0==1
|
||||
if ( i == nCount - 1 && ccClass[0].nClass == CRVC_IN && ccClass[0].dParS < EPS_ZERO && ccClass[i].dParE > 1 - EPS_ZERO) {
|
||||
double dPar = ( ccClass[i].dParS + 1 + ccClass[0].dParE) / 2 ;
|
||||
if ( dPar > 1)
|
||||
dPar -= 1 ;
|
||||
Point3d ptP ;
|
||||
crvCirc.GetPointD1D2( dPar, ICurve::FROM_MINUS, ptP) ;
|
||||
vPnt[0] = ptP ;
|
||||
double dDelta = ccClass[i].dParE - ccClass[i].dParS + ccClass[0].dParE - ccClass[0].dParS ;
|
||||
vDiam[0] = PIGRECO * dDiam * dDelta ;
|
||||
nInparts-- ;
|
||||
}
|
||||
// altrimenti caso standard
|
||||
else {
|
||||
double dPar = ( ccClass[i].dParS + ccClass[i].dParE) / 2 ;
|
||||
Point3d ptP ;
|
||||
crvCirc.GetPointD1D2( dPar, ICurve::FROM_MINUS, ptP) ;
|
||||
vPnt.emplace_back( ptP) ;
|
||||
double dDelta = ccClass[i].dParE - ccClass[i].dParS ;
|
||||
vDiam.emplace_back( PIGRECO * dDiam * dDelta) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( nInparts == 1)
|
||||
vPnt.clear() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveSimpleMedialAxis( const ICurve* pCrv, PolyLine& PL)
|
||||
{
|
||||
// pulizia della polilinea
|
||||
PL.Clear() ;
|
||||
// verifico che la curva esista
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
// verifico che la curva sia chiusa
|
||||
if ( ! pCrv->IsClosed())
|
||||
return false ;
|
||||
// verifico che la curva sia piana
|
||||
Plane3d plPlane ;
|
||||
if ( ! pCrv->IsFlat( plPlane, false, 10 * EPS_SMALL))
|
||||
return false ;
|
||||
// eventuali trasformazioni in composita
|
||||
CurveComposite crvCompo ;
|
||||
if ( pCrv->GetType() == CRV_ARC) {
|
||||
const CurveArc* pArc = GetBasicCurveArc( pCrv) ;
|
||||
crvCompo.AddCurve( *pArc) ;
|
||||
}
|
||||
else if ( pCrv->GetType() == CRV_BEZIER) {
|
||||
const CurveBezier* pBez = GetBasicCurveBezier( pCrv) ;
|
||||
PolyArc PA ;
|
||||
if ( ! pBez->ApproxWithArcs( 10 * EPS_SMALL, ANG_TOL_STD_DEG, PA) || ! crvCompo.FromPolyArc( PA))
|
||||
return false ;
|
||||
}
|
||||
else if ( pCrv->GetType() == CRV_COMPO) {
|
||||
crvCompo.AddCurve( *pCrv) ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
// se è una circonferenza
|
||||
Point3d ptCen ; Vector3d vtN ; double dRad ; bool bCCW ;
|
||||
if ( crvCompo.IsACircle( 10 * EPS_SMALL, ptCen, vtN, dRad, bCCW)) {
|
||||
PL.AddUPoint( 0, ptCen) ;
|
||||
return true ;
|
||||
}
|
||||
// la porto nel riferimento del piano
|
||||
Frame3d frLoc ;
|
||||
frLoc.Set( ORIG, plPlane.GetVersN()) ;
|
||||
crvCompo.ToLoc( frLoc) ;
|
||||
// lo oriento in senso antiorario
|
||||
double dArea ;
|
||||
if ( ! crvCompo.GetAreaXY( dArea))
|
||||
return false ;
|
||||
if ( dArea < 0)
|
||||
crvCompo.Invert() ;
|
||||
// ne calcolo il box
|
||||
BBox3d b3Compo ;
|
||||
if ( ! crvCompo.GetLocalBBox( b3Compo, BBF_STANDARD))
|
||||
return false ;
|
||||
|
||||
// ricerca di un punto di partenza
|
||||
CurveLine crvLine ;
|
||||
if ( b3Compo.GetDimX() > b3Compo.GetDimY()) {
|
||||
Point3d ptP1 = Media( b3Compo.GetMin(), b3Compo.GetMax()) - 0.6 * b3Compo.GetDimY() * Y_AX ;
|
||||
Point3d ptP2 = ptP1 + 1.2 * b3Compo.GetDimY() * Y_AX ;
|
||||
crvLine.Set( ptP1, ptP2) ;
|
||||
}
|
||||
else {
|
||||
Point3d ptP1 = Media( b3Compo.GetMin(), b3Compo.GetMax()) - 0.6 * b3Compo.GetDimX() * X_AX ;
|
||||
Point3d ptP2 = ptP1 + 1.2 * b3Compo.GetDimX() * X_AX ;
|
||||
crvLine.Set( ptP1, ptP2) ;
|
||||
}
|
||||
|
||||
IntersCurveCurve LnCmpInt( crvLine, crvCompo) ;
|
||||
if ( LnCmpInt.GetCrossIntersCount() < 2)
|
||||
return false ;
|
||||
IntCrvCrvInfo aInfo[2] ;
|
||||
LnCmpInt.GetIntCrvCrvInfo( 0, aInfo[0]) ;
|
||||
LnCmpInt.GetIntCrvCrvInfo( 1, aInfo[1]) ;
|
||||
Point3d ptOrig = Media( aInfo[0].IciA->ptI, aInfo[1].IciA->ptI) ;
|
||||
double dDiamOrig = 1.2 * DistXY( aInfo[0].IciA->ptI, aInfo[1].IciA->ptI) ;
|
||||
Vector3d vtTg0 ; Point3d ptP0 ; crvCompo.GetPointTang( aInfo[0].IciB->dU, ICurve::FROM_MINUS, ptP0, vtTg0) ;
|
||||
Vector3d vtTg1 ; Point3d ptP1 ; crvCompo.GetPointTang( aInfo[1].IciB->dU, ICurve::FROM_MINUS, ptP1, vtTg1) ;
|
||||
Vector3d vtDirOrig = Media( vtTg0, -vtTg1) ; vtDirOrig.Normalize() ;
|
||||
|
||||
// movimento lungo un ramo
|
||||
Point3d ptStart = ptOrig ;
|
||||
double dDiam = dDiamOrig ;
|
||||
Vector3d vtDir = vtDirOrig ;
|
||||
int i = 0 ;
|
||||
|
||||
while ( i < 1000) {
|
||||
PNTVECTOR vPnt ;
|
||||
DBLVECTOR vDiam ;
|
||||
if ( ! ProcessCircleCurve( ptStart, dDiam, crvCompo, vPnt, vDiam))
|
||||
return false ;
|
||||
if ( vPnt.empty())
|
||||
break ;
|
||||
int nInd = -1 ;
|
||||
double dCosMax = -0.5 ;
|
||||
for ( int j = 0 ; j < int( vPnt.size()) ; ++ j) {
|
||||
Vector3d vtNewDir = vPnt[j] - ptStart ;
|
||||
if ( vtNewDir.Normalize()) {
|
||||
double dCosA = vtDir * vtNewDir ;
|
||||
if ( dCosA > dCosMax) {
|
||||
nInd = j ;
|
||||
dCosMax = dCosA ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( nInd < 0)
|
||||
break ;
|
||||
vtDir = vPnt[nInd] - ptStart ;
|
||||
vtDir.Normalize() ;
|
||||
ptStart = vPnt[nInd] ;
|
||||
dDiam = 1.2 * vDiam[nInd] ;
|
||||
PL.AddUPoint( 0, GetToGlob( ptStart, frLoc)) ;
|
||||
++ i ;
|
||||
}
|
||||
|
||||
// movimento lungo l'altro ramo
|
||||
ptStart = ptOrig ;
|
||||
dDiam = dDiamOrig ;
|
||||
vtDir = -vtDirOrig ;
|
||||
i = 0 ;
|
||||
while ( i < 1000) {
|
||||
PNTVECTOR vPnt ;
|
||||
DBLVECTOR vDiam ;
|
||||
if ( ! ProcessCircleCurve( ptStart, dDiam, crvCompo, vPnt, vDiam))
|
||||
return false ;
|
||||
if ( vPnt.empty())
|
||||
break ;
|
||||
int nInd = -1 ;
|
||||
double dCosMax = -0.5 ;
|
||||
for ( int j = 0 ; j < int( vPnt.size()) ; ++ j) {
|
||||
Vector3d vtNewDir = vPnt[j] - ptStart ;
|
||||
if ( vtNewDir.Normalize()) {
|
||||
double dCosA = vtDir * vtNewDir ;
|
||||
if ( dCosA > dCosMax) {
|
||||
nInd = j ;
|
||||
dCosMax = dCosA ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( nInd < 0)
|
||||
break ;
|
||||
vtDir = vPnt[nInd] - ptStart ;
|
||||
vtDir.Normalize() ;
|
||||
ptStart = vPnt[nInd] ;
|
||||
dDiam = 1.2 * vDiam[nInd] ;
|
||||
PL.AddUPoint( 0, GetToGlob( ptStart, frLoc), false) ;
|
||||
++ i ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
#include "/EgtDev/Include/EGkGdbConst.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgtStringConverter.h"
|
||||
#include "/EgtDev/Extern/zlib/Include/zlib.h"
|
||||
#include "/EgtDev/Extern/Zlib/Include/zlib.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
+29
-115
@@ -17,7 +17,6 @@
|
||||
#include "CurveComposite.h"
|
||||
#include "CurveLine.h"
|
||||
#include "CurveArc.h"
|
||||
#include "RemoveCurveDefects.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkOffsetCurve.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||
@@ -69,39 +68,18 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
{
|
||||
// pulisco tutto
|
||||
Reset() ;
|
||||
// verifico che la curva esista
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
// verifico se la curva è un segmento di retta
|
||||
bool bIsLine = false ;
|
||||
const CurveLine* pLine = GetBasicCurveLine( pCrv) ;
|
||||
if ( pLine != nullptr)
|
||||
bIsLine = true ;
|
||||
else {
|
||||
const CurveComposite* pCompo = GetBasicCurveComposite( pCrv) ;
|
||||
Point3d ptStart, ptEnd ;
|
||||
if ( pCompo != nullptr && pCompo->IsALine( 10 * EPS_SMALL, ptStart, ptEnd))
|
||||
bIsLine = true ;
|
||||
}
|
||||
// verifico che la curva sia piana
|
||||
// verifico che la curva esista e sia piana
|
||||
Plane3d plPlane ;
|
||||
if ( ! pCrv->IsFlat( plPlane, bIsLine, 10 * EPS_SMALL))
|
||||
if ( pCrv == nullptr || ! pCrv->IsFlat( plPlane))
|
||||
return false ;
|
||||
// recupero o assegno estrusione
|
||||
// se esiste estrusione, verifico sia perpendicolare al piano della curva
|
||||
Vector3d vtExtr ;
|
||||
if ( ! pCrv->GetExtrusion( vtExtr) || vtExtr.IsSmall()) {
|
||||
vtExtr = plPlane.GetVersN() ;
|
||||
if ( vtExtr.IsZminus())
|
||||
vtExtr.Invert() ;
|
||||
if ( pCrv->GetExtrusion( vtExtr) && ! vtExtr.IsSmall()) {
|
||||
if ( ! AreSameOrOppositeVectorApprox( plPlane.GetVersN(), vtExtr))
|
||||
return false ;
|
||||
}
|
||||
// recupero normale al piano della curva
|
||||
Vector3d vtNorm = plPlane.GetVersN() ;
|
||||
if ( vtNorm * vtExtr < 0)
|
||||
vtNorm.Invert() ;
|
||||
// verifico che estrusione non sia troppo vicina al piano della curva (almeno 30 gradi di angolazione)
|
||||
double dExtrOnN = vtExtr * vtNorm ;
|
||||
if ( dExtrOnN < 0.5)
|
||||
return false ;
|
||||
else
|
||||
vtExtr = plPlane.GetVersN() ;
|
||||
// recupero spessore
|
||||
double dThick ;
|
||||
pCrv->GetThickness( dThick) ;
|
||||
@@ -124,9 +102,6 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
// determino se necessario cambiare riferimento ( dal vettore estrusione)
|
||||
bool bNeedRef = ( ! vtExtr.IsZplus()) ;
|
||||
|
||||
// determino se necessario effettuare scalatura
|
||||
bool bNeedScale = ( abs( dExtrOnN) < cos( 0.1 * DEGTORAD)) ;
|
||||
|
||||
// creo una copia della curva
|
||||
CurveComposite ccCopy ;
|
||||
if ( ! ccCopy.CopyFrom( pCrv))
|
||||
@@ -134,23 +109,13 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
ccCopy.SetExtrusion( vtExtr) ;
|
||||
|
||||
// se necessario cambio il riferimento
|
||||
Frame3d frCopy ;
|
||||
if ( bNeedScale) {
|
||||
// calcolo il riferimento con vtNorm come asse Z e componente di vtExtr perpendicolare a vtNorm come asse X
|
||||
if ( ! frCopy.Set( ORIG, vtNorm, vtExtr - dExtrOnN * vtNorm))
|
||||
return false ;
|
||||
ccCopy.SetExtrusion( vtNorm) ;
|
||||
// esprimo la curva in questo riferimento
|
||||
ccCopy.ToLoc( frCopy) ;
|
||||
// scalo lungo l'asse X locale
|
||||
ccCopy.Scale( GLOB_FRM, dExtrOnN, 1, 1) ;
|
||||
}
|
||||
else if ( bNeedRef) {
|
||||
Frame3d frExtr ;
|
||||
if ( bNeedRef) {
|
||||
// calcolo il riferimento OCS con VtExtr come asse Z
|
||||
if ( ! frCopy.Set( ORIG, vtExtr))
|
||||
if ( ! frExtr.Set( ORIG, vtExtr))
|
||||
return false ;
|
||||
// esprimo la curva in questo riferimento
|
||||
ccCopy.ToLoc( frCopy) ;
|
||||
ccCopy.ToLoc( frExtr) ;
|
||||
}
|
||||
|
||||
// verifico che la curva sia fatta solo da rette e archi che giacciono nel piano XY (VtExtr è ora Z+)
|
||||
@@ -160,9 +125,6 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
// verifico se curva chiusa e non forzata aperta
|
||||
bool bClosed = ccCopy.IsClosed() && ( nType & ICurve::OFF_FORCE_OPEN) == 0 ;
|
||||
|
||||
// elimino eventuali piccole Z
|
||||
RemoveCurveSmallZs( &ccCopy, 10 * EPS_SMALL) ;
|
||||
|
||||
// unisco parti allineate (tranne gli estremi)
|
||||
ccCopy.MergeCurves( 10 * EPS_SMALL, ANG_TOL_STD_DEG, false) ;
|
||||
|
||||
@@ -277,17 +239,6 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
}
|
||||
}
|
||||
|
||||
// aggiorno lunghezza segmenti di retta (possono essere stati allungati)
|
||||
for ( auto iIter = m_CrvLst.begin() ; iIter != m_CrvLst.end() ; ++ iIter) {
|
||||
const ICurve* pCrv = *iIter ;
|
||||
if ( pCrv->GetType() == CRV_LINE) {
|
||||
double dLen ; pCrv->GetLength( dLen) ;
|
||||
int nInd = abs( pCrv->GetTempProp()) - 1 ;
|
||||
if ( nInd >= 0 && nInd < int( vLens.size()))
|
||||
vLens[nInd] = dLen ;
|
||||
}
|
||||
}
|
||||
|
||||
// secondo passo : eliminazione archi invertiti e rette impossibili
|
||||
for ( auto iIter = m_CrvLst.begin() ; iIter != m_CrvLst.end() ;) {
|
||||
ICurve* pCrv = *iIter ;
|
||||
@@ -295,7 +246,6 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
if ( pCrv->GetTempProp() < 0 ||
|
||||
( pCrv->GetType() == CRV_ARC && GetBasicCurveArc(pCrv)->GetRadius() < EPS_SMALL)) {
|
||||
delete pCrv ;
|
||||
pCrv = nullptr ;
|
||||
iIter = m_CrvLst.erase( iIter) ;
|
||||
continue ;
|
||||
}
|
||||
@@ -350,17 +300,13 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
if ( ( nRes & 1) != 0) {
|
||||
auto iErase = prev( iIter != m_CrvLst.begin() ? iIter : m_CrvLst.end()) ;
|
||||
delete pPrev ;
|
||||
pPrev = nullptr ;
|
||||
m_CrvLst.erase( iErase) ;
|
||||
if ( m_CrvLst.empty())
|
||||
break ;
|
||||
auto iPrev = prev( iIter != m_CrvLst.begin() ? iIter : m_CrvLst.end()) ;
|
||||
pPrev = *iPrev ;
|
||||
}
|
||||
// corrente da cancellare
|
||||
if ( ( nRes & 2) != 0) {
|
||||
delete pCrv ;
|
||||
pCrv = nullptr ;
|
||||
iIter = m_CrvLst.erase( iIter) ;
|
||||
}
|
||||
// se eseguita una cancellazione, non devo incrementare
|
||||
@@ -381,13 +327,6 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
if ( ! m_CrvLst.empty())
|
||||
m_CrvLst.front()->GetStartPoint( ptPrec) ;
|
||||
for ( auto& pCrv : m_CrvLst) {
|
||||
// se curva troppo piccola la salto
|
||||
double dCrvLen ;
|
||||
if ( ! pCrv->GetLength( dCrvLen)) {
|
||||
delete( pCrv) ;
|
||||
pCrv = nullptr ;
|
||||
continue ;
|
||||
}
|
||||
// se punto iniziale diverso da precedente, inserisco segmento di collegamento
|
||||
Point3d ptStart ;
|
||||
pCrv->GetStartPoint( ptStart) ;
|
||||
@@ -468,7 +407,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
dLenPrev = vLen[i] ;
|
||||
}
|
||||
// se fatta almeno una suddivisione, trimmo l'ultima parte
|
||||
if ( dUPrev > EPS_PARAM)
|
||||
if ( dUPrev > EPS_PARAM) {}
|
||||
pCompo1->TrimStartAtParam( dUPrev) ;
|
||||
|
||||
// sesto passo : se curva aperta, elimino i tratti che stanno nella circonferenza di offset dei punti estremi
|
||||
@@ -490,7 +429,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
inOk.Set( dStart, dEnd) ;
|
||||
IntersCurveCurve ccInt( *pCrv, *pCircS) ;
|
||||
CRVCVECTOR ccPart ;
|
||||
if ( ! ccInt.GetCurveClassification( 0, EPS_SMALL, ccPart))
|
||||
if ( ! ccInt.GetCurveClassification( 0, ccPart))
|
||||
return false ;
|
||||
for ( auto& ccOne : ccPart) {
|
||||
switch ( ccOne.nClass) {
|
||||
@@ -539,7 +478,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
inOk.Set( dStart, dEnd) ;
|
||||
IntersCurveCurve ccInt( *pCrv, *pCircE) ;
|
||||
CRVCVECTOR ccPart ;
|
||||
if ( ! ccInt.GetCurveClassification( 0, EPS_SMALL, ccPart))
|
||||
if ( ! ccInt.GetCurveClassification( 0, ccPart))
|
||||
return false ;
|
||||
for ( auto& ccOne : ccPart) {
|
||||
switch ( ccOne.nClass) {
|
||||
@@ -608,18 +547,16 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
pCrvCo2->GetEndPoint( ptEnd2) ;
|
||||
// verifiche di concatenamento
|
||||
if ( AreSamePointEpsilon( ptEnd, ptStart2, 10 * EPS_SMALL)) {
|
||||
if ( pCrvCo->AddCurve( pCrvCo2, true, 10 * EPS_SMALL)) {
|
||||
m_CrvLst.erase( iIter2) ;
|
||||
ptEnd = ptEnd2 ;
|
||||
iIter2 = next( iIter) ;
|
||||
}
|
||||
pCrvCo->AddCurve( pCrvCo2, true, 10 * EPS_SMALL) ;
|
||||
m_CrvLst.erase( iIter2) ;
|
||||
ptEnd = ptEnd2 ;
|
||||
iIter2 = next( iIter) ;
|
||||
}
|
||||
else if ( AreSamePointEpsilon( ptEnd2, ptStart, 10 * EPS_SMALL)) {
|
||||
if ( pCrvCo->AddCurve( pCrvCo2, false, 10 * EPS_SMALL)) {
|
||||
m_CrvLst.erase( iIter2) ;
|
||||
ptStart = ptStart2 ;
|
||||
iIter2 = next( iIter) ;
|
||||
}
|
||||
pCrvCo->AddCurve( pCrvCo2, false, 10 * EPS_SMALL) ;
|
||||
m_CrvLst.erase( iIter2) ;
|
||||
ptStart = ptStart2 ;
|
||||
iIter2 = next( iIter) ;
|
||||
}
|
||||
else
|
||||
++ iIter2 ;
|
||||
@@ -664,15 +601,9 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
}
|
||||
|
||||
// riporto il risultato nel riferimento originale
|
||||
if ( bNeedScale) {
|
||||
for ( auto pCrv : m_CrvLst) {
|
||||
pCrv->Scale( GLOB_FRM, 1 / dExtrOnN, 1, 1) ;
|
||||
pCrv->ToGlob( frCopy) ;
|
||||
}
|
||||
}
|
||||
else if ( bNeedRef) {
|
||||
if ( bNeedRef) {
|
||||
for ( auto pCrv : m_CrvLst)
|
||||
pCrv->ToGlob( frCopy) ;
|
||||
pCrv->ToGlob( frExtr) ;
|
||||
}
|
||||
|
||||
// assegno estrusione e spessore come curva originale
|
||||
@@ -693,17 +624,6 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
m_CrvLst.sort( []( const ICurve* pA, const ICurve* pB) { return ( pA->GetTempProp() > pB->GetTempProp()) ; }) ;
|
||||
}
|
||||
|
||||
// elimino eventuali curve non uniche molto corte e aperte
|
||||
while ( ( m_CrvLst.size() > 1)) {
|
||||
ICurve* pCrv = m_CrvLst.back() ;
|
||||
if ( ! pCrv->IsClosed() && pCrv->GetTempProp() < 1000 * 50 * EPS_SMALL) {
|
||||
delete( pCrv) ;
|
||||
m_CrvLst.pop_back() ;
|
||||
}
|
||||
else
|
||||
break ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -871,14 +791,11 @@ VerifyAndAdjustSamePoint( ICurve* pCrv1, ICurve* pCrv2, int& nRes)
|
||||
return true ;
|
||||
}
|
||||
// sono in tolleranza, ma devo ricongiungere gli estremi
|
||||
Point3d ptS1, ptE2 ;
|
||||
if ( ! pCrv1->GetStartPoint( ptS1) || ! pCrv2->GetEndPoint( ptE2))
|
||||
return false ;
|
||||
nRes = 0 ;
|
||||
Point3d ptMid = 0.5 * ( ptP1 + ptP2) ;
|
||||
if ( AreSamePointApprox( ptS1, ptMid) || ! pCrv1->ModifyEnd( ptMid))
|
||||
if ( ! pCrv1->ModifyEnd( ptMid))
|
||||
nRes += 1 ;
|
||||
if ( AreSamePointApprox( ptMid, ptE2) || ! pCrv2->ModifyStart( ptMid))
|
||||
if ( ! pCrv2->ModifyStart( ptMid))
|
||||
nRes += 2 ;
|
||||
return true ;
|
||||
}
|
||||
@@ -905,14 +822,11 @@ VerifyAndAdjustInternalAngle( ICurve* pCrv1, ICurve* pCrv2, int& nRes)
|
||||
! intCC.GetIntersPointNearTo( 1, ptMid, ptNew2))
|
||||
return false ;
|
||||
// modifico le due curve sul punto medio di intersezione
|
||||
Point3d ptS1, ptE2 ;
|
||||
if ( ! pCrv1->GetStartPoint( ptS1) || ! pCrv2->GetEndPoint( ptE2))
|
||||
return false ;
|
||||
nRes = 0 ;
|
||||
Point3d ptNew = 0.5 * ( ptNew1 + ptNew2) ;
|
||||
if ( AreSamePointApprox( ptS1, ptNew) || ! pCrv1->ModifyEnd( ptNew))
|
||||
if ( ! pCrv1->ModifyEnd( ptNew))
|
||||
nRes += 1 ;
|
||||
if ( AreSamePointApprox( ptNew, ptE2) || ! pCrv2->ModifyStart( ptNew))
|
||||
if ( ! pCrv2->ModifyStart( ptNew))
|
||||
nRes += 2 ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
+291
-309
@@ -23,6 +23,7 @@
|
||||
#include "/EgtDev/Include/EGkPlane3d.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EGkPolygon3d.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -515,11 +516,8 @@ PolyLine::IsFlat( int& nRank, Point3d& ptCen, Vector3d& vtDir, double dToler) co
|
||||
// cerco le componenti principali (tramite PCA)
|
||||
Point3d ptP1, ptP2 ;
|
||||
PointsPCA ptsPCA ;
|
||||
for ( bool bFound = GetFirstLine( ptP1, ptP2) ; bFound ; bFound = GetNextLine( ptP1, ptP2)) {
|
||||
double dLen = Dist( ptP1, ptP2) ;
|
||||
ptsPCA.AddPoint( Media( ptP1, ptP2, 0.25), dLen / 2) ;
|
||||
ptsPCA.AddPoint( Media( ptP1, ptP2, 0.75), dLen / 2) ;
|
||||
}
|
||||
for ( bool bFound = GetFirstLine( ptP1, ptP2) ; bFound ; bFound = GetNextLine( ptP1, ptP2))
|
||||
ptsPCA.AddPoint( Media( ptP1, ptP2), Dist( ptP1, ptP2)) ;
|
||||
// recupero il rango, ovvero la dimensionalità dell'insieme di punti
|
||||
nRank = ptsPCA.GetRank() ;
|
||||
// se dimensione nulla, o non ci sono punti o sono tutti praticamente coincidenti
|
||||
@@ -602,10 +600,8 @@ PolyLine::IsClosedAndFlat( Plane3d& plPlane, double& dArea, double dToler) const
|
||||
PolygonPlane PolyPlane ;
|
||||
for ( bool bFound = GetFirstPoint( ptP) ; bFound ; bFound = GetNextPoint( ptP))
|
||||
PolyPlane.AddPoint( ptP) ;
|
||||
if ( ! PolyPlane.GetPlane( plPlane) || ! PolyPlane.GetArea( dArea)) {
|
||||
dArea = 0 ;
|
||||
return IsFlat( plPlane, dToler) ;
|
||||
}
|
||||
if ( ! PolyPlane.GetPlane( plPlane) || ! PolyPlane.GetArea( dArea))
|
||||
return false ;
|
||||
// Test each vertex to see if it is farther from plane than allowed max distance
|
||||
for ( bool bFound = GetFirstPoint( ptP) ; bFound ; bFound = GetNextPoint( ptP)) {
|
||||
double dDist = ( ( ptP - ORIG) * plPlane.GetVersN()) - plPlane.GetDist() ;
|
||||
@@ -835,11 +831,12 @@ PolyLine::MyChangeStart( int nPos)
|
||||
// solo per polilinee chiuse
|
||||
if ( ! IsClosed())
|
||||
return false ;
|
||||
// cancello l'ultimo punto ( coincide con il primo)
|
||||
// cancello ultimo punto ( coincide con primo)
|
||||
m_lUPoints.pop_back() ;
|
||||
// sposto la parte iniziale dei punti alla fine
|
||||
m_lUPoints.splice( m_lUPoints.end(), m_lUPoints, m_lUPoints.begin(), next( m_lUPoints.begin(), nPos)) ;
|
||||
// aggiungo il punto finale come copia dell'iniziale
|
||||
// sposto la metà iniziale dei punti alla fine
|
||||
for ( int i = 0 ; i < nPos ; ++ i)
|
||||
m_lUPoints.splice( m_lUPoints.end(), m_lUPoints, m_lUPoints.begin()) ;
|
||||
// aggiungo punto finale come copia dell'iniziale
|
||||
m_lUPoints.push_back( m_lUPoints.front()) ;
|
||||
|
||||
return true ;
|
||||
@@ -1302,340 +1299,325 @@ PolyLine::Trim( const Plane3d& plPlane, bool bInVsOut)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointPolyLine( const Point3d& ptP, const PolyLine& plPoly, double& dDist)
|
||||
{
|
||||
double dDummy ;
|
||||
return DistPointPolyLine( ptP, plPoly, dDist, dDummy) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointPolyLine( const Point3d& ptP, const PolyLine& plPoly, double& dDist, double& dMinDistPar)
|
||||
/*static*/ bool
|
||||
ChangePolyLineStart( const Point3d& ptNewStart, PolyLine& Loop, double dTol)
|
||||
{
|
||||
// La polilinea deve contenere almeno due punti
|
||||
if ( plPoly.GetPointNbr() < 2)
|
||||
return false ;
|
||||
// Ciclo sui punti della polilinea
|
||||
dDist = INFINITO ;
|
||||
int nSeg = -1 ;
|
||||
Point3d ptStart, ptEnd ;
|
||||
plPoly.GetFirstPoint( ptStart) ;
|
||||
while ( plPoly.GetNextPoint( ptEnd)) {
|
||||
++ nSeg ;
|
||||
// distanza del punto dal segmento della polilinea
|
||||
DistPointLine PointLineDistCalc( ptP, ptStart, ptEnd) ;
|
||||
double dPlDist ;
|
||||
PointLineDistCalc.GetDist( dPlDist) ;
|
||||
if ( dPlDist < dDist) {
|
||||
dDist = dPlDist ;
|
||||
PointLineDistCalc.GetParamAtMinDistPoint( dMinDistPar) ;
|
||||
dMinDistPar += nSeg ;
|
||||
// Rinomino la lista di punti della PolyLine.
|
||||
PNTULIST& LoopList = Loop.GetUPointList() ;
|
||||
// Ciclo sui segmenti del loop per cercare il tratto del loop chiuso più vicino al punto.
|
||||
double dMinSqDist = DBL_MAX ;
|
||||
auto itMinDist = LoopList.end() ;
|
||||
auto itSt = LoopList.begin() ;
|
||||
auto itEn = itSt ;
|
||||
++ itEn ;
|
||||
for ( ; itSt != LoopList.end() && itEn != LoopList.end() ; ++ itSt, ++ itEn) {
|
||||
// Estremi del segmento corrente del loop
|
||||
Point3d ptSegSt = itSt->first ;
|
||||
Point3d ptSegEn = itEn->first ;
|
||||
// Distanza del punto dal segmento del loop
|
||||
DistPointLine dDistCalc( ptNewStart, ptSegSt, ptSegEn) ;
|
||||
double dSqDist ;
|
||||
dDistCalc.GetSqDist( dSqDist) ;
|
||||
if ( dSqDist < dMinSqDist) {
|
||||
dMinSqDist = dSqDist ;
|
||||
itMinDist = itSt ;
|
||||
}
|
||||
// assegno nuovo inizio
|
||||
ptStart = ptEnd ;
|
||||
}
|
||||
// Se il punto non sta sul loop, errore
|
||||
if ( dMinSqDist > dTol * dTol)
|
||||
return false ;
|
||||
// Se il punto non sta su un vertice del segmento, lo aggiungo. Altrimenti non devo fare nulla.
|
||||
auto itNewPointSt = LoopList.begin() ;
|
||||
auto itNext = itMinDist ;
|
||||
++ itNext ;
|
||||
bool bOnStart = AreSamePointApprox( ptNewStart, itMinDist->first) ;
|
||||
bool bOnEnd = AreSamePointApprox( ptNewStart, itNext->first) ;
|
||||
itNewPointSt = LoopList.emplace( itNext, ptNewStart, 0) ;
|
||||
// Sposto i punti precedenti in coda.
|
||||
bool bStartRemoved = false ;
|
||||
auto it = LoopList.begin() ;
|
||||
while ( it != itNewPointSt) {
|
||||
if ( bStartRemoved) {
|
||||
LoopList.emplace_back( it->first, it->second) ;
|
||||
}
|
||||
bStartRemoved = true ;
|
||||
it = LoopList.erase( it) ;
|
||||
}
|
||||
// Se il punto inserito non coincide con l'inizio del segmento chiudo il loop.
|
||||
if ( ! bOnStart) {
|
||||
LoopList.emplace_back( ptNewStart, 0) ;
|
||||
// Se coincide con la fine tolgo il punto di fine che diviene inutile.
|
||||
if ( bOnEnd) {
|
||||
//LoopList.erase( itNext) ;
|
||||
auto itNewStart = LoopList.begin() ;
|
||||
++ itNewStart ;
|
||||
LoopList.erase( itNewStart) ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IsPointInsidePolyLine( const Point3d& ptP, const PolyLine& plPoly, double dToler)
|
||||
// nSegNum 0-based
|
||||
/*static*/ bool
|
||||
PointPositionOnPolyLine( const Point3d& ptPoint, /*const*/ PolyLine& Loop, int& nSegNum, double& dParOnSeg, double dTol)
|
||||
{
|
||||
// La polilinea deve essere chiusa e piatta, altrimenti non ha senso parlare di interno
|
||||
Plane3d plPlane ;
|
||||
double dArea ;
|
||||
if ( ! plPoly.IsClosedAndFlat( plPlane, dArea, 10 * EPS_SMALL))
|
||||
return false ;
|
||||
// Il punto deve giacere nel piano della polilinea
|
||||
if ( ! PointInPlaneEpsilon( ptP, plPlane, 10 * EPS_SMALL))
|
||||
return false ;
|
||||
// Riferimento alla lista dei punti
|
||||
PNTULIST& List = const_cast<PolyLine&>( plPoly).GetUPointList() ;
|
||||
// Ciclo sui segmenti della polilinea per cercare il segmento più vicino al punto
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
Point3d ptMinDist ;
|
||||
auto itMinDistEnd = List.end() ;
|
||||
auto itStart = List.begin() ;
|
||||
auto itEnd = next( itStart) ;
|
||||
for ( ; itEnd != List.end() ; ++ itStart, ++ itEnd) {
|
||||
// Distanza del punto dal segmento corrente
|
||||
DistPointLine dDistCalc( ptP, itStart->first, itEnd->first) ;
|
||||
// Rinomino la lista di punti della PolyLine.
|
||||
/*const*/ PNTULIST& LoopList = Loop.GetUPointList() ;
|
||||
// Ciclo sui segmenti del loop per cercare il tratto del loop chiuso più vicino al punto.
|
||||
nSegNum = - 1 ;
|
||||
double dMinSqDist = DBL_MAX ;
|
||||
int nS = 0 ;
|
||||
auto itMinDistSt = LoopList.end() ;
|
||||
auto itMinDistEn = itMinDistSt ;
|
||||
auto itSt = LoopList.begin() ;
|
||||
auto itEn = itSt ;
|
||||
++ itEn ;
|
||||
for ( ; itSt != LoopList.end() && itEn != LoopList.end() ; ++ itSt, ++ itEn, ++ nS) {
|
||||
// Estremi del segmento corrente del loop
|
||||
Point3d ptSegSt = itSt->first ;
|
||||
Point3d ptSegEn = itEn->first ;
|
||||
// Distanza del punto dal segmento del loop
|
||||
DistPointLine dDistCalc( ptPoint, ptSegSt, ptSegEn) ;
|
||||
double dSqDist ;
|
||||
if ( dDistCalc.GetSqDist( dSqDist) && dSqDist < dMinSqDist) {
|
||||
dDistCalc.GetSqDist( dSqDist) ;
|
||||
if ( dSqDist < dMinSqDist) {
|
||||
nSegNum = nS ;
|
||||
dMinSqDist = dSqDist ;
|
||||
dDistCalc.GetMinDistPoint( ptMinDist) ;
|
||||
itMinDistEnd = itEnd ;
|
||||
itMinDistSt = itSt ;
|
||||
itMinDistEn = itEn ;
|
||||
}
|
||||
}
|
||||
// Determino tangente di riferimento
|
||||
Vector3d vtTang ;
|
||||
// se minima distanza nell'estremo iniziale del segmento
|
||||
if ( AreSamePointApprox( ptMinDist, prev( itMinDistEnd)->first)) {
|
||||
// direzione del segmento
|
||||
Vector3d vtCurrTg = itMinDistEnd->first - prev( itMinDistEnd)->first ;
|
||||
vtCurrTg.Normalize() ;
|
||||
// direzione del segmento precedente
|
||||
Vector3d vtPrevTg ;
|
||||
if ( prev( itMinDistEnd) != List.begin())
|
||||
vtPrevTg = prev( itMinDistEnd)->first - prev( itMinDistEnd, 2)->first ;
|
||||
else
|
||||
vtPrevTg = prev( itMinDistEnd)->first - next( List.rbegin())->first ;
|
||||
vtPrevTg.Normalize() ;
|
||||
// tangente media
|
||||
vtTang = vtPrevTg + vtCurrTg ;
|
||||
vtTang.Normalize() ;
|
||||
}
|
||||
// se altrimenti minima distanza nell'estremo finale del segmento
|
||||
else if ( AreSamePointApprox( ptMinDist, itMinDistEnd->first)) {
|
||||
// direzione del segmento
|
||||
Vector3d vtCurrTg = itMinDistEnd->first - prev( itMinDistEnd)->first ;
|
||||
vtCurrTg.Normalize() ;
|
||||
// direzione del segmento successivo
|
||||
Vector3d vtNextTg ;
|
||||
if ( next( itMinDistEnd) != List.end())
|
||||
vtNextTg = next( itMinDistEnd)->first - itMinDistEnd->first ;
|
||||
else
|
||||
vtNextTg = next( List.begin())->first - itMinDistEnd->first ;
|
||||
vtNextTg.Normalize() ;
|
||||
// tangente media
|
||||
vtTang = vtCurrTg + vtNextTg ;
|
||||
vtTang.Normalize() ;
|
||||
}
|
||||
// altrimenti minima distanza con l'interno
|
||||
else {
|
||||
vtTang = itMinDistEnd->first - prev( itMinDistEnd)->first ;
|
||||
}
|
||||
// Determino la posizione del punto
|
||||
Vector3d vtDiff = ptP - ptMinDist ;
|
||||
Vector3d vtOut = vtTang ^ plPlane.GetVersN() ;
|
||||
vtOut.Normalize() ;
|
||||
return ( vtDiff * vtOut < -dToler) ;
|
||||
// Se il punto non sta sul loop, lo segnalo.
|
||||
if ( dMinSqDist > dTol * dTol)
|
||||
return false ;
|
||||
// Calcolo il parametro lungo il segmento.
|
||||
Vector3d vtSeg = itMinDistEn->first - itMinDistSt->first ;
|
||||
double dSegLen = vtSeg.Len() ;
|
||||
if ( dSegLen < EPS_SMALL)
|
||||
return false ;
|
||||
vtSeg /= dSegLen ;
|
||||
dParOnSeg = Clamp( ( ptPoint - itMinDistSt->first) * vtSeg, 0., dSegLen) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GetPointParamOnPolyLine( const Point3d& ptP, const PolyLine& plPoly, double dToler, double& dPar)
|
||||
/*static*/ bool
|
||||
IsPointInsidePolyLine( const Point3d& ptP, const PolyLine& plPoly)
|
||||
{
|
||||
// La polilinea deve contenere almeno due punti
|
||||
if ( plPoly.GetPointNbr() < 2)
|
||||
return false ;
|
||||
// Ciclo sui punti della polilinea
|
||||
int nSeg = -1 ;
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
dPar = -1 ;
|
||||
Point3d ptStart, ptEnd ;
|
||||
plPoly.GetFirstPoint( ptStart) ;
|
||||
while ( plPoly.GetNextPoint( ptEnd)) {
|
||||
// aggiorno l'indice
|
||||
++ nSeg ;
|
||||
// distanza del punto dal segmento della polilinea
|
||||
DistPointLine dDistCalc( ptP, ptStart, ptEnd) ;
|
||||
double dSqDist ;
|
||||
if ( dDistCalc.GetSqDist( dSqDist) && dSqDist < dMinSqDist) {
|
||||
dMinSqDist = dSqDist ;
|
||||
double dSegPar ;
|
||||
dDistCalc.GetParamAtMinDistPoint( dSegPar) ;
|
||||
dPar = nSeg + dSegPar ;
|
||||
}
|
||||
// assegno nuovo inizio
|
||||
ptStart = ptEnd ;
|
||||
}
|
||||
// Il punto è sulla linea se la sua distanza rispetta la tolleranza
|
||||
return ( dMinSqDist < dToler * dToler) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ChangePolyLineStart( PolyLine& plPoly, const Point3d& ptNewStart, double dToler)
|
||||
{
|
||||
// La polilinea deve essere chiusa
|
||||
// Se la PolyLine non è chiusa, il punto non può essere interno.
|
||||
if ( ! plPoly.IsClosed())
|
||||
return false ;
|
||||
// Riferimento alla lista dei punti
|
||||
PNTULIST& LoopList = const_cast<PolyLine&>( plPoly).GetUPointList() ;
|
||||
// Ciclo sui segmenti della polilinea per cercare il segmento più vicino al punto
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
auto itMinDistEnd = LoopList.end() ;
|
||||
auto itStart = LoopList.begin() ;
|
||||
auto itEnd = next( itStart) ;
|
||||
for ( ; itEnd != LoopList.end() ; ++ itStart, ++ itEnd) {
|
||||
// Distanza del punto dal segmento corrente
|
||||
DistPointLine dDistCalc( ptNewStart, itStart->first, itEnd->first) ;
|
||||
// Lista dei punti
|
||||
PolyLine& MyPlPoly = const_cast< PolyLine&>( plPoly) ;
|
||||
const PNTULIST& List = MyPlPoly.GetUPointList() ;
|
||||
// Ciclo sui segmenti della PolyLine per cercarne il tratto più vicino al punto.
|
||||
double dMinSqDist = DBL_MAX ;
|
||||
Point3d ptMinDist ;
|
||||
auto itMinDistSt = List.end() ;
|
||||
auto itSt = List.begin() ;
|
||||
auto itEn = itSt ;
|
||||
++ itEn ;
|
||||
for ( ; itSt != List.end() && itEn != List.end() ; ++ itSt, ++ itEn) {
|
||||
// Estremi del segmento corrente del loop
|
||||
Point3d ptSegSt = itSt->first ;
|
||||
Point3d ptSegEn = itEn->first ;
|
||||
// Distanza del punto dal segmento del loop
|
||||
DistPointLine dDistCalc( ptP, ptSegSt, ptSegEn) ;
|
||||
double dSqDist ;
|
||||
if ( dDistCalc.GetSqDist( dSqDist) && dSqDist < dMinSqDist) {
|
||||
dDistCalc.GetSqDist( dSqDist) ;
|
||||
if ( dSqDist < dMinSqDist) {
|
||||
dMinSqDist = dSqDist ;
|
||||
itMinDistEnd = itEnd ;
|
||||
dDistCalc.GetMinDistPoint( ptMinDist) ;
|
||||
itMinDistSt = itSt ;
|
||||
}
|
||||
}
|
||||
// Se il punto non sta sulla polilinea, non ha senso cambiare l'inizio
|
||||
if ( dMinSqDist > dToler * dToler)
|
||||
return false ;
|
||||
// Se il punto non coincide con un vertice, lo aggiungo
|
||||
auto itNewStart = LoopList.end() ;
|
||||
if ( AreSamePointApprox( ptNewStart, prev( itMinDistEnd)->first))
|
||||
itNewStart = prev( itMinDistEnd) ;
|
||||
else if ( AreSamePointApprox( ptNewStart, itMinDistEnd->first))
|
||||
itNewStart = itMinDistEnd ;
|
||||
else
|
||||
itNewStart = LoopList.emplace( itMinDistEnd, ptNewStart, 0) ;
|
||||
// Cancello l'ultimo punto ( coincide con il primo)
|
||||
LoopList.pop_back() ;
|
||||
// Sposto la parte iniziale dei punti alla fine
|
||||
LoopList.splice( LoopList.end(), LoopList, LoopList.begin(), itNewStart) ;
|
||||
// Aggiungo il punto finale come copia dell'iniziale
|
||||
LoopList.push_back( LoopList.front()) ;
|
||||
|
||||
return true ;
|
||||
// Termine del segmento di minima distanza.
|
||||
auto itMinDistEn = itMinDistSt ;
|
||||
++ itMinDistEn ;
|
||||
// Punto di minima distanza nell'estremo iniziale del segento
|
||||
if ( AreSamePointApprox( ptMinDist, itMinDistSt->first)) {
|
||||
auto itPrevSt = List.begin() ;
|
||||
if ( itMinDistSt == List.begin()) {
|
||||
auto itAuxNext = itPrevSt ;
|
||||
++ ( ++ itAuxNext) ;
|
||||
for ( ; itAuxNext != List.end() ; ++ itPrevSt, ++ itAuxNext)
|
||||
;
|
||||
}
|
||||
else {
|
||||
auto itAuxNext = itPrevSt ;
|
||||
++ itAuxNext ;
|
||||
for (; itAuxNext != itMinDistSt; ++itPrevSt, ++itAuxNext)
|
||||
;
|
||||
}
|
||||
Vector3d vtPrevTan = itMinDistSt->first - itPrevSt->first ;
|
||||
vtPrevTan.Normalize() ;
|
||||
Vector3d vtTan = itMinDistEn->first - itMinDistSt->first ;
|
||||
vtTan.Normalize() ;
|
||||
Polygon3d AuxPolygon ;
|
||||
AuxPolygon.FromPolyLine( plPoly) ;
|
||||
Vector3d vtPolyNorm = AuxPolygon.GetVersN() ;
|
||||
Vector3d vtPrevOut = vtPrevTan ^ vtPolyNorm ;
|
||||
Vector3d vtOut = vtTan ^ vtPolyNorm ;
|
||||
// Caso concavo
|
||||
if ( vtTan * vtPrevOut > 0) {
|
||||
Vector3d vtTest = ptP - ptMinDist ;
|
||||
if ( vtTest * vtPrevOut < 0 || vtTest * vtOut < 0)
|
||||
return true ;
|
||||
}
|
||||
// Caso convesso
|
||||
else {
|
||||
Vector3d vtTest = ptP - ptMinDist ;
|
||||
if ( vtTest * vtPrevOut < 0 && vtTest * vtOut < 0)
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// Punto di minima distanza nell'estremo finale del segento
|
||||
else if ( AreSamePointApprox( ptMinDist, itMinDistEn->first)) {
|
||||
auto itNextEn = itMinDistEn ;
|
||||
++ itNextEn ;
|
||||
if ( itNextEn == List.end()) {
|
||||
itNextEn = List.begin() ;
|
||||
++ itNextEn ;
|
||||
}
|
||||
Vector3d vtTan = itMinDistEn->first - itMinDistSt->first ;
|
||||
vtTan.Normalize() ;
|
||||
Vector3d vtNextTan = itNextEn->first - itMinDistEn->first ;
|
||||
vtNextTan.Normalize() ;
|
||||
Polygon3d AuxPolygon ;
|
||||
AuxPolygon.FromPolyLine( plPoly) ;
|
||||
Vector3d vtPolyNorm = AuxPolygon.GetVersN() ;
|
||||
Vector3d vtOut = vtTan ^ vtPolyNorm ;
|
||||
Vector3d vtNextOut = vtNextTan ^ vtPolyNorm ;
|
||||
// Caso concavo
|
||||
if ( vtNextTan * vtOut > 0) {
|
||||
Vector3d vtTest = ptP - ptMinDist ;
|
||||
if ( vtTest * vtOut < 0 || vtTest * vtNextOut < 0)
|
||||
return true ;
|
||||
}
|
||||
// Caso convesso
|
||||
else {
|
||||
Vector3d vtTest = ptP - ptMinDist ;
|
||||
if ( vtTest * vtOut < 0 && vtTest * vtNextOut < 0)
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// Punto di minima distanza interno al segmeno
|
||||
else {
|
||||
Vector3d vtP = ptP - itMinDistSt->first ;
|
||||
Vector3d vtTan = itMinDistEn->first - itMinDistSt->first ;
|
||||
vtTan.Normalize() ;
|
||||
Polygon3d AuxPolygon ;
|
||||
AuxPolygon.FromPolyLine( plPoly) ;
|
||||
Vector3d vtPolyNorm = AuxPolygon.GetVersN() ;
|
||||
Vector3d vtOut = vtTan ^ vtPolyNorm ;
|
||||
vtP -= ( vtP * vtTan) * vtTan ;
|
||||
if ( vtP * vtOut < - EPS_SMALL)
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SplitPolyLineAtPoint( const PolyLine& plPoly, const Point3d& ptP, double dToler, PolyLine& plPoly1, PolyLine& plPoly2)
|
||||
DistPointPolyLine( const Point3d& ptP, const PolyLine& plPoly, double& dPointPolyLineDist)
|
||||
{
|
||||
// La polilinea deve contenere almeno due punti
|
||||
if ( plPoly.GetPointNbr() < 2)
|
||||
if ( plPoly.GetPointNbr() == 0)
|
||||
return false ;
|
||||
// Riferimento alla lista dei punti
|
||||
const PNTULIST& LoopList = const_cast<PolyLine&>( plPoly).GetUPointList() ;
|
||||
// Ciclo sui segmenti della polilinea per cercare il segmento più vicino al punto
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
auto itMinDistEnd = LoopList.end() ;
|
||||
auto itStart = LoopList.begin() ;
|
||||
auto itEnd = next( itStart) ;
|
||||
for ( ; itEnd != LoopList.end() ; ++ itStart, ++ itEnd) {
|
||||
// Distanza del punto dal segmento corrente
|
||||
DistPointLine dDistCalc( ptP, itStart->first, itEnd->first) ;
|
||||
double dSqDist ;
|
||||
if ( dDistCalc.GetSqDist( dSqDist) && dSqDist < dMinSqDist) {
|
||||
dMinSqDist = dSqDist ;
|
||||
itMinDistEnd = itEnd ;
|
||||
}
|
||||
dPointPolyLineDist = DBL_MAX ;
|
||||
Point3d ptSt, ptEn ;
|
||||
bool bContinue = plPoly.GetFirstPoint( ptSt) && plPoly.GetNextPoint( ptEn) ;
|
||||
while ( bContinue) {
|
||||
double dPoinLineDist ;
|
||||
DistPointLine PointLineDistCalc( ptP, ptSt, ptEn) ;
|
||||
PointLineDistCalc.GetDist( dPoinLineDist) ;
|
||||
if ( dPoinLineDist < dPointPolyLineDist)
|
||||
dPointPolyLineDist = dPoinLineDist ;
|
||||
ptSt = ptEn ;
|
||||
bContinue = plPoly.GetNextPoint( ptEn) ;
|
||||
}
|
||||
// Se il punto non sta sulla polilinea, non ha senso spezzare
|
||||
if ( dMinSqDist > dToler * dToler)
|
||||
return false ;
|
||||
// Copio i punti opportuni nella prima parte
|
||||
PNTULIST& LoopList1 = plPoly1.GetUPointList() ;
|
||||
for ( auto it = LoopList.begin() ; it != itMinDistEnd ; ++ it)
|
||||
LoopList1.emplace_back( it->first, it->second) ;
|
||||
plPoly1.AddUPoint( 0, ptP) ;
|
||||
// Copio i punti opportuni nella seconda parte
|
||||
PNTULIST& LoopList2 = plPoly2.GetUPointList() ;
|
||||
for ( auto it = itMinDistEnd ; it != LoopList.end() ; ++ it)
|
||||
LoopList2.emplace_back( it->first, it->second) ;
|
||||
plPoly2.AddUPoint( 0, ptP, false) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIVECTOR& vPnt1, PNTIVECTOR& vPnt2, bool& bCommonInternalPoints)
|
||||
/*static*/ bool
|
||||
SplitPolyLineAtPoint( const Point3d& ptPoint, /*const*/ PolyLine& Loop, PolyLine& Loop1, PolyLine& Loop2, double dTol)
|
||||
{
|
||||
// controllo che le polyline abbiano almeno un punto
|
||||
int nPnt1 = PL1.GetPointNbr() ;
|
||||
int nPnt2 = PL2.GetPointNbr() ;
|
||||
if ( nPnt1 == 0 || nPnt2 == 0)
|
||||
// Rinomino la lista di punti della PolyLine.
|
||||
/*const*/ PNTULIST& LoopList = Loop.GetUPointList() ;
|
||||
// Ciclo sui segmenti del loop per cercare il tratto del loop chiuso più vicino al punto.
|
||||
double dMinSqDist = DBL_MAX ;
|
||||
auto itMinDistSt = LoopList.end() ;
|
||||
auto itSt = LoopList.begin() ;
|
||||
auto itEn = itSt ;
|
||||
++ itEn ;
|
||||
for ( ; itSt != LoopList.end() && itEn != LoopList.end() ; ++ itSt, ++ itEn) {
|
||||
// Estremi del segmento corrente del loop
|
||||
Point3d ptSegSt = itSt->first ;
|
||||
Point3d ptSegEn = itEn->first ;
|
||||
// Distanza del punto dal segmento del loop
|
||||
DistPointLine dDistCalc( ptPoint, ptSegSt, ptSegEn) ;
|
||||
double dSqDist ;
|
||||
dDistCalc.GetSqDist( dSqDist) ;
|
||||
if ( dSqDist < dMinSqDist) {
|
||||
dMinSqDist = dSqDist ;
|
||||
itMinDistSt = itSt ;
|
||||
}
|
||||
}
|
||||
// Se il punto non sta sul loop, lo segnalo.
|
||||
if ( dMinSqDist > dTol * dTol)
|
||||
return false ;
|
||||
|
||||
bCommonInternalPoints = false ; // indica la presenza di punti interni in comune tra le due polylines
|
||||
|
||||
vPnt1.reserve( PL1.GetPointNbr()) ;
|
||||
Point3d ptP1 ;
|
||||
bool bF1 = PL1.GetFirstPoint( ptP1) ;
|
||||
while ( bF1) {
|
||||
vPnt1.emplace_back( ptP1, -1) ;
|
||||
bF1 = PL1.GetNextPoint( ptP1) ;
|
||||
// Se il punto di stop sta su un vertice non devo aggiungerlo e il
|
||||
// punto di stop sarà uno degli estremi del segmento su cui giace.
|
||||
auto itStop = itMinDistSt ;
|
||||
auto itNext = itMinDistSt ;
|
||||
++ itNext ;
|
||||
if ( AreSamePointApprox( ptPoint, itStop->first))
|
||||
;
|
||||
else if ( AreSamePointApprox( ptPoint, itNext->first))
|
||||
itStop = itNext ;
|
||||
else {
|
||||
itStop = LoopList.emplace( itNext, ptPoint, 0.) ;
|
||||
}
|
||||
int nTotP1 = int( vPnt1.size()) ;
|
||||
|
||||
vPnt2.reserve( PL2.GetPointNbr()) ;
|
||||
Point3d ptP2 ;
|
||||
bool bF2 = PL2.GetFirstPoint( ptP2) ;
|
||||
while ( bF2) {
|
||||
vPnt2.emplace_back( ptP2, -1) ;
|
||||
bF2 = PL2.GetNextPoint( ptP2) ;
|
||||
// Creo i due loop
|
||||
PNTULIST& LoopList1 = Loop1.GetUPointList() ;
|
||||
PNTULIST& LoopList2 = Loop2.GetUPointList() ;
|
||||
for ( auto it = LoopList.begin() ; it != itStop ; ++ it) {
|
||||
LoopList1.emplace_back( it->first, it->second) ;
|
||||
}
|
||||
int nTotP2 = int( vPnt2.size()) ;
|
||||
|
||||
// calcoli per prima curva
|
||||
int nLastJ = 0 ;
|
||||
vPnt1[0].second = 0 ;
|
||||
|
||||
double dFirstDist, dFirstParMinDist ;
|
||||
DistPointPolyLine( vPnt1[0].first, PL2, dFirstDist, dFirstParMinDist) ;
|
||||
int nFirstMinJ = ( int)( dFirstParMinDist + 0.5) ;
|
||||
|
||||
for ( int i = 1 ; i < nTotP1 ; ++ i) {
|
||||
|
||||
double dDist = INFINITO ;
|
||||
double dMinDistPar = nLastJ ;
|
||||
for ( int j = max( nLastJ, 1) ; j < nTotP2 ; ++ j) {
|
||||
// distanza del punto dal segmento della polilinea
|
||||
DistPointLine PointLineDistCalc( vPnt1[i].first, vPnt2[j-1].first, vPnt2[j].first) ;
|
||||
double dPlDist ;
|
||||
if ( PointLineDistCalc.GetDist( dPlDist) && dPlDist < dDist) {
|
||||
dDist = dPlDist ;
|
||||
PointLineDistCalc.GetParamAtMinDistPoint( dMinDistPar) ;
|
||||
dMinDistPar += j - 1 ;
|
||||
}
|
||||
}
|
||||
int nMinJ = ( int)( dMinDistPar + 0.5) ;
|
||||
|
||||
// eventuale correzione per i primi punti ( da forzare nel vertice 0)
|
||||
if ( nLastJ == 0 && nFirstMinJ > 0.5 * nTotP2 && nMinJ >= nFirstMinJ)
|
||||
nMinJ = 0 ;
|
||||
|
||||
if ( nMinJ < nLastJ)
|
||||
nMinJ = nLastJ ;
|
||||
|
||||
// verifica se è un punto interno in comune con l'altra polyline
|
||||
if ( i < nTotP1 - 1 && dDist < EPS_SMALL && abs( dMinDistPar - floor( dMinDistPar + 0.5)) < EPS_SMALL)
|
||||
bCommonInternalPoints = true ;
|
||||
|
||||
vPnt1[i].second = nMinJ ;
|
||||
nLastJ = nMinJ ;
|
||||
LoopList1.emplace_back( itStop->first, itStop->second) ;
|
||||
for ( auto it = itStop ; it != LoopList.end() ; ++ it) {
|
||||
LoopList2.emplace_back( it->first, it->second) ;
|
||||
}
|
||||
|
||||
// calcoli per seconda curva
|
||||
int nLastI = 0 ;
|
||||
vPnt2[0].second = 0 ;
|
||||
|
||||
DistPointPolyLine( vPnt2[0].first, PL1, dFirstDist, dFirstParMinDist) ;
|
||||
int nFirstMinI = ( int)( dFirstParMinDist + 0.5) ;
|
||||
|
||||
for ( int j = 1 ; j < nTotP2 ; ++ j) {
|
||||
|
||||
double dDist = INFINITO ;
|
||||
double dMinDistPar = nLastI ;
|
||||
for ( int i = max( nLastI, 1) ; i < nTotP1 ; ++ i) {
|
||||
// distanza del punto dal segmento della polilinea
|
||||
DistPointLine PointLineDistCalc( vPnt2[j].first, vPnt1[i-1].first, vPnt1[i].first) ;
|
||||
double dPlDist ;
|
||||
PointLineDistCalc.GetDist( dPlDist) ;
|
||||
if ( dPlDist < dDist) {
|
||||
dDist = dPlDist ;
|
||||
PointLineDistCalc.GetParamAtMinDistPoint( dMinDistPar) ;
|
||||
dMinDistPar += i - 1 ;
|
||||
}
|
||||
}
|
||||
int nMinI = ( int)( dMinDistPar + 0.5) ;
|
||||
|
||||
// eventuale correzione per primi punti
|
||||
if ( nLastI == 0 && nFirstMinI > 0.5 * nTotP1 && nMinI >= nFirstMinI)
|
||||
nMinI = 0 ;
|
||||
|
||||
if ( nMinI < nLastI)
|
||||
nMinI = nLastI ;
|
||||
|
||||
if ( j < nTotP2 - 1 && dDist < EPS_SMALL && abs( dMinDistPar - floor( dMinDistPar + 0.5)) < EPS_SMALL)
|
||||
bCommonInternalPoints = true ;
|
||||
|
||||
vPnt2[j].second = nMinI ;
|
||||
nLastI = nMinI ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/*static*/ bool
|
||||
AddPolyLineToPolyLine( PolyLine& Poly, PolyLine& PolyToAdd, double dTol)
|
||||
{
|
||||
// Se la PolyLine a cui devo aggiungere l'altra è chiusa, non posso aggiungere nulla.
|
||||
if ( Poly.IsClosed())
|
||||
return false ;
|
||||
// Se la PolyLina che devo aggiungere è vuota, ho finito.
|
||||
PNTULIST& PolyToAddList = PolyToAdd.GetUPointList() ;
|
||||
if ( int( PolyToAddList.size()) == 0)
|
||||
return true ;
|
||||
// Se Poly non è vuota e la sua fine non coincide con l'inizio di PolyToAdd, non è possibile aggiungere nulla.
|
||||
Point3d ptLast ;
|
||||
Poly.GetLastPoint( ptLast) ;
|
||||
auto it = PolyToAddList.begin() ;
|
||||
if ( Poly.GetPointNbr() != 0 && ! AreSamePointEpsilon( it->first, ptLast, dTol))
|
||||
return false ;
|
||||
/*if ( Poly.GetPointNbr() == 0)
|
||||
Poly.AddUPoint( 0., it->first) ;
|
||||
++ it ;*/
|
||||
// Aggiungo i punti.
|
||||
for ( ; it != PolyToAddList.end() ; ++ it) {
|
||||
Poly.AddUPoint( 0., it->first) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@
|
||||
#include "CurveComposite.h"
|
||||
#include "SurfFlatRegion.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkPolygon3d.h"
|
||||
#include "/EgtDev/Include/EgkPolygon3d.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -187,7 +187,7 @@ Polygon3d::Trim( const Plane3d& plPlane, bool bInVsOut, bool bOnEq, bool bOnCt)
|
||||
DBLVECTOR vDist ;
|
||||
vDist.reserve( m_vVert.capacity()) ;
|
||||
for ( auto& ptP : m_vVert) {
|
||||
double dDist = DistPointPlane( ptP, plPlane) ;
|
||||
double dDist = ( ptP - ORIG) * plPlane.GetVersN() - plPlane.GetDist() ;
|
||||
if ( abs( dDist) < EPS_SMALL)
|
||||
++ nNbrOn ;
|
||||
else if ( dDist < 0)
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2017-2022
|
||||
//----------------------------------------------------------------------------
|
||||
// File : RemoveCurveDefects.cpp Data : 28.11.22 Versione : 2.4k6
|
||||
// Contenuto : Implementazione rimozione spikes di curva.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 02.10.17 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "GeoConst.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "RemoveCurveDefects.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
RemoveCurveSpikes( ICurveComposite* pCurve, double dLinTol)
|
||||
{
|
||||
// verifico validità curva
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
// verifico e sistemo tolleranza lineare
|
||||
dLinTol = max( dLinTol, EPS_SMALL) ;
|
||||
// recupero il numero di curve semplici componenti la composta
|
||||
int nCrvCount = pCurve->GetCurveCount() ;
|
||||
if ( nCrvCount < 2 || ( nCrvCount < 3 && pCurve->IsClosed()))
|
||||
return true ;
|
||||
// ciclo sulle curve elementari della composita
|
||||
int nStart = pCurve->IsClosed() ? 0 : 1 ;
|
||||
for ( int i = nStart ; i < nCrvCount ; ++ i) {
|
||||
// recupero due curve consecutive
|
||||
const ICurve* pPrevCrv = pCurve->GetCurve( ( i > 0 ? i - 1 : nCrvCount - 1)) ;
|
||||
const ICurve* pNextCrv = pCurve->GetCurve( i) ;
|
||||
// se sono entrambe rette
|
||||
if ( pPrevCrv->GetType() == CRV_LINE && pNextCrv->GetType() == CRV_LINE) {
|
||||
// recupero i punti estremi
|
||||
Point3d ptStart ; pPrevCrv->GetStartPoint( ptStart) ;
|
||||
Point3d ptMid ; pPrevCrv->GetEndPoint( ptMid) ;
|
||||
Point3d ptEnd ; pNextCrv->GetEndPoint( ptEnd) ;
|
||||
// recupero le direzioni negli estremi
|
||||
Vector3d vtPrev ; pPrevCrv->GetStartDir( vtPrev) ;
|
||||
Vector3d vtNext ; pNextCrv->GetStartDir( vtNext) ;
|
||||
// verifico se spike
|
||||
double dPrevDist, dNextDist ;
|
||||
if ( vtPrev * vtNext < cos( 175 * DEGTORAD) &&
|
||||
(( DistPointLine( ptStart, ptMid, ptEnd).GetDist( dPrevDist) && dPrevDist < dLinTol) ||
|
||||
( DistPointLine( ptEnd, ptStart, ptMid).GetDist( dNextDist) && dNextDist < dLinTol))) {
|
||||
// se spike ha base abbastanza larga, basta togliere uno dei due lati
|
||||
if ( SqDist( ptStart, ptEnd) > SQ_EPS_SMALL) {
|
||||
pCurve->RemoveJoint( i) ;
|
||||
-- nCrvCount ;
|
||||
-- i ;
|
||||
}
|
||||
// altrimenti bisogna togliere entrambi
|
||||
else {
|
||||
pCurve->RemoveJoint( i - 1) ;
|
||||
pCurve->RemoveJoint( i) ;
|
||||
nCrvCount -= 2 ;
|
||||
i = max( i - 2, nStart - 1) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// !!! Aggiungere la gestione degli altri tipi di curve !!!
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
RemoveCurveSmallZs( ICurveComposite* pCurve, double dLinTol)
|
||||
{
|
||||
// verifico validità curva
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
// verifico e sistemo tolleranza lineare
|
||||
dLinTol = max( dLinTol, EPS_SMALL) ;
|
||||
// recupero il numero di curve semplici componenti la composta
|
||||
int nCrvCount = pCurve->GetCurveCount() ;
|
||||
if ( nCrvCount < 2 || ( nCrvCount < 3 && pCurve->IsClosed()))
|
||||
return true ;
|
||||
// ciclo sulle curve elementari della composita
|
||||
int nStart = pCurve->IsClosed() ? 0 : 1 ;
|
||||
int nEnd = pCurve->IsClosed() ? nCrvCount : nCrvCount - 1 ;
|
||||
for ( int i = nStart ; i < nEnd ; ++ i) {
|
||||
// recupero tre curve consecutive
|
||||
const ICurve* pPrevCrv = pCurve->GetCurve( ( i > 0 ? i - 1 : nCrvCount - 1)) ;
|
||||
const ICurve* pCurrCrv = pCurve->GetCurve( i) ;
|
||||
const ICurve* pNextCrv = pCurve->GetCurve( ( i < nCrvCount - 1 ? i + 1 : 0)) ;
|
||||
// se la curva corrente è una retta
|
||||
if ( pCurrCrv->GetType() == CRV_LINE) {
|
||||
// recupero tre punti notevoli della curva
|
||||
Point3d ptStart ; pCurrCrv->GetStartPoint( ptStart) ;
|
||||
Point3d ptMid ; pCurrCrv->GetMidPoint( ptMid) ;
|
||||
Point3d ptEnd ; pCurrCrv->GetEndPoint( ptEnd) ;
|
||||
// recupero le direzioni negli estremi
|
||||
Vector3d vtPrev ; pPrevCrv->GetEndDir( vtPrev) ;
|
||||
Vector3d vtNext ; pNextCrv->GetStartDir( vtNext) ;
|
||||
// verifico se Small Z
|
||||
double dDistS, dDistM1, dDistM2, dDistE ;
|
||||
if ( vtPrev * vtNext > cos( 30 * DEGTORAD) &&
|
||||
(( DistPointCurve( ptStart, *pNextCrv).GetDist( dDistS) && dDistS < dLinTol) &&
|
||||
( DistPointCurve( ptMid, *pNextCrv).GetDist( dDistM1) && dDistM1 < dLinTol) &&
|
||||
( DistPointCurve( ptMid, *pPrevCrv).GetDist( dDistM2) && dDistM2 < dLinTol) &&
|
||||
( DistPointCurve( ptEnd, *pPrevCrv).GetDist( dDistE) && dDistE < dLinTol))) {
|
||||
// rimuovo il segmento
|
||||
if ( pCurve->RemoveJoint( i)) {
|
||||
-- nCrvCount ;
|
||||
-- nEnd ;
|
||||
-- i ;
|
||||
// porto il nuovo estremo sul punto medio
|
||||
pCurve->ModifyJoint( i + 1, ptMid) ;
|
||||
}
|
||||
// altrimenti devo rimuovere anche il successivo
|
||||
else if ( pCurve->RemoveJoint( i + 1) && pCurve->RemoveJoint( i)) {
|
||||
nCrvCount -= 2 ;
|
||||
nEnd -= 2 ;
|
||||
-- i ;
|
||||
// porto il nuovo estremo sul punto medio
|
||||
pCurve->ModifyJoint( i + 1, ptMid) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2017-2017
|
||||
//----------------------------------------------------------------------------
|
||||
// File : RemoveCurveSpikes.cpp Data : 02.10.17 Versione : 1.8j1
|
||||
// Contenuto : Implementazione rimozione spikes di curva.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 02.10.17 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "GeoConst.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "RemoveCurveSpikes.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
RemoveCurveSpikes( ICurveComposite* pCurve)
|
||||
{
|
||||
// verifico validità curva
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
// recupero il numero di curve semplici componenti la composta
|
||||
int nCrvCount = pCurve->GetCurveCount() ;
|
||||
if ( nCrvCount < 2 || ( nCrvCount < 3 && pCurve->IsClosed()))
|
||||
return true ;
|
||||
// ciclo sulle curve elementari della composita
|
||||
int nStart = pCurve->IsClosed() ? 0 : 1 ;
|
||||
for ( int i = nStart ; i < nCrvCount ; ++ i) {
|
||||
// recupero due curve consecutive
|
||||
const ICurve* pPrevCrv = pCurve->GetCurve( ( i > 0 ? i - 1 : nCrvCount - 1)) ;
|
||||
const ICurve* pNextCrv = pCurve->GetCurve( i) ;
|
||||
// se sono entrambe rette
|
||||
if ( pPrevCrv->GetType() == CRV_LINE && pNextCrv->GetType() == CRV_LINE) {
|
||||
// recupero i punti estremi
|
||||
Point3d ptStart ; pPrevCrv->GetStartPoint( ptStart) ;
|
||||
Point3d ptMid ; pPrevCrv->GetEndPoint( ptMid) ;
|
||||
Point3d ptEnd ; pNextCrv->GetEndPoint( ptEnd) ;
|
||||
// recupero le direzioni negli estremi
|
||||
Vector3d vtPrev ; pPrevCrv->GetStartDir( vtPrev) ;
|
||||
Vector3d vtNext ; pNextCrv->GetStartDir( vtNext) ;
|
||||
// verifico se spike
|
||||
double dPrevDist, dNextDist ;
|
||||
if ( vtPrev * vtNext < cos( 175 * DEGTORAD) &&
|
||||
(( DistPointLine( ptStart, ptMid, ptEnd).GetDist( dPrevDist) && dPrevDist < EPS_SMALL) ||
|
||||
( DistPointLine( ptEnd, ptStart, ptMid).GetDist( dNextDist) && dNextDist < EPS_SMALL))) {
|
||||
// se spike ha base abbastanza larga, basta togliere uno dei due lati
|
||||
if ( SqDist( ptStart, ptEnd) > SQ_EPS_SMALL) {
|
||||
pCurve->RemoveJoint( i) ;
|
||||
-- nCrvCount ;
|
||||
-- i ;
|
||||
}
|
||||
// altrimenti bisogna togliere entrambi
|
||||
else {
|
||||
pCurve->RemoveJoint( i - 1) ;
|
||||
pCurve->RemoveJoint( i) ;
|
||||
nCrvCount -= 2 ;
|
||||
i = max( i - 2, nStart - 1) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// !!! Aggiungere la gestione degli altri tipi di curve !!!
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -1,21 +1,20 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2017-2022
|
||||
//----------------------------------------------------------------------------
|
||||
// File : RemoveCurveDefects.h Data : 13.11.22 Versione : 2.4k2
|
||||
// Contenuto : Dichiarazione funzioni rimozione difetti curve.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 02.10.17 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool RemoveCurveSpikes( ICurveComposite* pCurve, double dLinTol = EPS_SMALL) ;
|
||||
bool RemoveCurveSmallZs( ICurveComposite* pCurve, double dLinTol = EPS_SMALL) ;
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2017-2017
|
||||
//----------------------------------------------------------------------------
|
||||
// File : RemoveCurveSpikes.h Data : 02.10.17 Versione : 1.8j1
|
||||
// Contenuto : Dichiarazione funzione rimozione spikes curve.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 02.10.17 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool RemoveCurveSpikes( ICurveComposite* pCurve) ;
|
||||
+33
-111
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2022
|
||||
// EgalTech 2015-2016
|
||||
//----------------------------------------------------------------------------
|
||||
// File : StmFromCurves.cpp Data : 08.12.22 Versione : 2.4l2
|
||||
// File : StmFromCurves.cpp Data : 11.08.16 Versione : 1.6t2
|
||||
// Contenuto : Implementazione di funzioni per creazione di superfici Stm
|
||||
// a partire da curve, con diversi metodi.
|
||||
//
|
||||
@@ -17,11 +17,10 @@
|
||||
#include "CurveArc.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "SurfFlatRegion.h"
|
||||
#include "AdjustLoops.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||
#include "/EgtDev/Include/EGkBiArcs.h"
|
||||
#include "/EgtDev/Include/EGkOffsetCurve.h"
|
||||
#include "/EgtDev/Include/EgkPolyLine.h"
|
||||
#include "/EgtDev/Include/EgkBiArcs.h"
|
||||
#include "/EgtDev/Include/EgkOffsetCurve.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <algorithm>
|
||||
@@ -136,33 +135,14 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b
|
||||
pCompo1->GetEndPoint( ptEnd) ;
|
||||
pCompo1->GetEndDir( vtEnd) ;
|
||||
pCompo1->GetMidPoint( ptMid) ;
|
||||
if ( AreSamePointEpsilon( ptStart, ptEnd, 2 * dRadius) && Dist( ptStart, ptMid) > 2 * dRadius && Dist( ptEnd, ptMid) > 2 * dRadius) {
|
||||
if ( AreSamePointEpsilon( ptStart, ptEnd, max( 0.1 * dRadius, 10 * EPS_SMALL))) {
|
||||
Point3d ptNew = Media( ptStart, ptEnd) ;
|
||||
pCompo1->ModifyStart( ptNew) ;
|
||||
pCompo1->ModifyEnd( ptNew) ;
|
||||
}
|
||||
else {
|
||||
// piano della curva
|
||||
Frame3d frLoc ;
|
||||
if ( ! AreSameVectorApprox( vtExtr, Z_AX))
|
||||
frLoc.Set( ptStart, vtExtr) ;
|
||||
// costruisco il biarco nel piano della curva
|
||||
ptStart.ToLoc( frLoc) ;
|
||||
ptEnd.ToLoc( frLoc) ;
|
||||
Vector3d vtELoc( vtEnd) ; vtELoc.ToLoc( frLoc) ;
|
||||
Vector3d vtSLoc( vtStart) ; vtSLoc.ToLoc( frLoc) ;
|
||||
double dAngEnd ; vtELoc.ToSpherical( nullptr, nullptr, &dAngEnd) ;
|
||||
double dAngStart ; vtSLoc.ToSpherical( nullptr, nullptr, &dAngStart) ;
|
||||
PtrOwner<ICurve> pClose( GetBiArc( ptEnd, dAngEnd, ptStart, dAngStart, 0.5)) ;
|
||||
// porto il biarco in globale
|
||||
pClose->ToGlob( frLoc) ;
|
||||
// aggiungo il biarco
|
||||
if ( ! IsNull( pClose))
|
||||
pCompo1->AddCurve( Release( pClose)) ;
|
||||
else
|
||||
pCompo1->Close() ;
|
||||
}
|
||||
if ( Dist( ptStart, ptEnd) <= 2 * dRadius && Dist( ptStart, ptMid) > 2 * dRadius && Dist( ptEnd, ptMid) > 2 * dRadius) {
|
||||
double dAngEnd ; vtEnd.ToSpherical( nullptr, nullptr, &dAngEnd) ;
|
||||
double dAngStart ; vtStart.ToSpherical( nullptr, nullptr, &dAngStart) ;
|
||||
PtrOwner<ICurve> pClose( GetBiArc( ptEnd, dAngEnd, ptStart, dAngStart, 0.5)) ;
|
||||
if ( ! IsNull( pClose))
|
||||
pCompo1->AddCurve( Release( pClose)) ;
|
||||
else
|
||||
pCompo1->Close() ;
|
||||
}
|
||||
// tipo di offset
|
||||
int nOffsType = ( bSquareMids ? ICurve::OFF_EXTEND : ICurve::OFF_FILLET) ;
|
||||
@@ -181,21 +161,15 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b
|
||||
if ( ! OffsCrv1.Make( pCompo1, dRadius, nOffsType))
|
||||
return nullptr ;
|
||||
ICurve* pOffs1 = OffsCrv1.GetLongerCurve() ;
|
||||
while ( pOffs1 != nullptr) {
|
||||
if ( pOffs1 != nullptr)
|
||||
SfrCntr.AddCurve( pOffs1) ;
|
||||
pOffs1 = OffsCrv1.GetLongerCurve() ;
|
||||
}
|
||||
|
||||
// offset della seconda curva a destra del raggio (è invertita rispetto alla precedente)
|
||||
OffsetCurve OffsCrv2 ;
|
||||
if ( ! OffsCrv2.Make( pCompo2, dRadius, nOffsType))
|
||||
return nullptr ;
|
||||
ICurve* pOffs2 = OffsCrv2.GetLongerCurve() ;
|
||||
while ( pOffs2 != nullptr) {
|
||||
if ( pOffs2 != nullptr)
|
||||
SfrCntr.AddCurve( pOffs2) ;
|
||||
pOffs2 = OffsCrv2.GetLongerCurve() ;
|
||||
}
|
||||
|
||||
// creo la regione
|
||||
return SfrCntr.GetSurf() ;
|
||||
}
|
||||
@@ -212,42 +186,24 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b
|
||||
PtrOwner<CurveComposite> pCompo2( pCompo1->Clone()) ;
|
||||
if ( IsNull( pCompo2) || ! pCompo2->Invert())
|
||||
return nullptr ;
|
||||
|
||||
// creo la regione
|
||||
SurfFlatRegionByContours SfrCntr( false, false) ;
|
||||
|
||||
// offset della prima curva a destra del raggio
|
||||
OffsetCurve OffsCrv1 ;
|
||||
if ( ! OffsCrv1.Make( pCompo1, dRadius, nOffsType))
|
||||
return nullptr ;
|
||||
ICurve* pOffs1 = OffsCrv1.GetLongerCurve() ;
|
||||
if ( pOffs1 == nullptr)
|
||||
return nullptr ;
|
||||
pCompo1->Clear() ;
|
||||
while ( pOffs1 != nullptr) {
|
||||
if ( pOffs1->IsClosed())
|
||||
SfrCntr.AddCurve( pOffs1) ;
|
||||
else
|
||||
pCompo1->AddCurve( pOffs1) ;
|
||||
pOffs1 = OffsCrv1.GetLongerCurve() ;
|
||||
if ( pOffs1 != nullptr) {
|
||||
pCompo1->Clear() ;
|
||||
pCompo1->AddCurve( pOffs1) ;
|
||||
}
|
||||
|
||||
// offset della seconda curva a destra del raggio
|
||||
OffsetCurve OffsCrv2 ;
|
||||
if ( ! OffsCrv2.Make( pCompo2, dRadius, nOffsType))
|
||||
return nullptr ;
|
||||
ICurve* pOffs2 = OffsCrv2.GetLongerCurve() ;
|
||||
if ( pOffs2 == nullptr)
|
||||
return nullptr ;
|
||||
pCompo2->Clear() ;
|
||||
while ( pOffs2 != nullptr) {
|
||||
if ( pOffs2->IsClosed())
|
||||
SfrCntr.AddCurve( pOffs2) ;
|
||||
else
|
||||
pCompo2->AddCurve( pOffs2) ;
|
||||
pOffs2 = OffsCrv2.GetLongerCurve() ;
|
||||
if ( pOffs2 != nullptr) {
|
||||
pCompo2->Clear() ;
|
||||
pCompo2->AddCurve( pOffs2) ;
|
||||
}
|
||||
|
||||
// se estremi squadrati
|
||||
if ( bSquareEnds) {
|
||||
// aggiungo alla prima curva una linea che la unisca alla seconda
|
||||
@@ -313,7 +269,8 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b
|
||||
if ( ! pCompo1->AddCurve( Release( pCompo2)))
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
// creo la regione
|
||||
SurfFlatRegionByContours SfrCntr( false, false) ;
|
||||
SfrCntr.AddCurve( Release( pCompo1)) ;
|
||||
return SfrCntr.GetSurf() ;
|
||||
}
|
||||
@@ -321,34 +278,13 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ISurfFlatRegion*
|
||||
GetSurfFlatRegionFromTriangle( const Triangle3d& Tria)
|
||||
GetSurfFlatRegionFromPolyLine( const PolyLine& ContourPolyLine)
|
||||
{
|
||||
// Creo la regione.
|
||||
PtrOwner<SurfFlatRegion> pSfr( CreateBasicSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfr))
|
||||
return nullptr ;
|
||||
// Creo curva composita.
|
||||
PtrOwner<CurveComposite> pLoop( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pLoop))
|
||||
return nullptr ;
|
||||
if ( ! pLoop->AddPoint( Tria.GetP( 0)) ||
|
||||
! pLoop->AddLine( Tria.GetP( 1)) ||
|
||||
! pLoop->AddLine( Tria.GetP( 2)) ||
|
||||
! pLoop->Close())
|
||||
return nullptr ;
|
||||
pSfr->AddExtLoop( Release( pLoop)) ;
|
||||
return Release( pSfr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ISurfFlatRegion*
|
||||
GetSurfFlatRegionFromPolyLine( const PolyLine& ContourPolyLine)
|
||||
{
|
||||
// Creo la regione.
|
||||
PtrOwner<SurfFlatRegion> pSfr( CreateBasicSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfr))
|
||||
return nullptr ;
|
||||
// Creo curva composita.
|
||||
// Creo curva composita.
|
||||
PtrOwner<CurveComposite> pLoop( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pLoop))
|
||||
return nullptr ;
|
||||
@@ -370,13 +306,13 @@ GetSurfFlatRegionFromPolyLine( const PolyLine& ContourPolyLine)
|
||||
ISurfFlatRegion*
|
||||
GetSurfFlatRegionFromPolyLineVector( const POLYLINEVECTOR& vContoursPolyLineVec)
|
||||
{
|
||||
// Creo la regione.
|
||||
// Creo la regione.
|
||||
PtrOwner<SurfFlatRegion> pSfr( CreateBasicSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfr))
|
||||
return nullptr ;
|
||||
// Ciclo sulle PolyLine.
|
||||
// Ciclo sulle PolyLine.
|
||||
for ( int nL = 0 ; nL < int( vContoursPolyLineVec.size()) ; ++ nL) {
|
||||
// Creo curva composita.
|
||||
// Creo curva composita.
|
||||
PtrOwner<CurveComposite> pLoop( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pLoop))
|
||||
return nullptr ;
|
||||
@@ -390,11 +326,11 @@ GetSurfFlatRegionFromPolyLineVector( const POLYLINEVECTOR& vContoursPolyLineVec)
|
||||
ptSt = ptEn ;
|
||||
bContinue = vContoursPolyLineVec[nL].GetNextPoint( ptEn) ;
|
||||
}
|
||||
// Loop esterno
|
||||
// Loop esterno
|
||||
if ( nL == 0) {
|
||||
pSfr->AddExtLoop( Release( pLoop)) ;
|
||||
}
|
||||
// Loop interno
|
||||
// Loop interno
|
||||
else {
|
||||
pSfr->AddIntLoop( Release( pLoop)) ;
|
||||
}
|
||||
@@ -427,20 +363,8 @@ SurfFlatRegionByContours::AddCurve( ICurve* pCrv)
|
||||
// verifico sia chiusa
|
||||
if ( ! pMyCrv->IsClosed())
|
||||
return false ;
|
||||
// verifico sia piana e imposto estrusione come normale al piano
|
||||
double dArea ;
|
||||
Plane3d plPlane ;
|
||||
if ( ! pMyCrv->GetArea( plPlane, dArea))
|
||||
return false ;
|
||||
pMyCrv->SetExtrusion( plPlane.GetVersN()) ;
|
||||
pMyCrv->SetThickness( 0) ;
|
||||
// rimuovo eventuali sovrapposizioni (calcolate nel suo piano)
|
||||
ICURVEPLIST CrvLst ;
|
||||
if ( ! AdjustLoops( Release( pMyCrv), CrvLst))
|
||||
return false ;
|
||||
// la/le inserisco nel vettore delle curve
|
||||
for ( auto& pSingCrv : CrvLst)
|
||||
m_vpCrv.push_back( pSingCrv) ;
|
||||
// la inserisco nel vettore delle curve
|
||||
m_vpCrv.push_back( Release( pMyCrv)) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -494,7 +418,6 @@ SurfFlatRegionByContours::GetSurf( void)
|
||||
if ( IsNull( pSfr))
|
||||
return nullptr ;
|
||||
// aggiungo le diverse curve
|
||||
bool bExtLoop = false ;
|
||||
bool bFirstCrv ;
|
||||
do {
|
||||
bFirstCrv = true ;
|
||||
@@ -513,7 +436,6 @@ SurfFlatRegionByContours::GetSurf( void)
|
||||
}
|
||||
// provo a inserirla
|
||||
if ( pSfr->AddExtLoop( Release( pCrv))) {
|
||||
bExtLoop = true ;
|
||||
bFirstCrv = false ;
|
||||
delete m_vpCrv[j] ;
|
||||
m_vpCrv[j] = nullptr ;
|
||||
@@ -538,7 +460,7 @@ SurfFlatRegionByContours::GetSurf( void)
|
||||
}
|
||||
} while ( m_bAllowedMultiChunk && ! bFirstCrv) ;
|
||||
// se non valida, errore
|
||||
if ( ! bExtLoop || ! pSfr->IsValid())
|
||||
if ( ! pSfr->IsValid())
|
||||
return nullptr ;
|
||||
// restituisco la superficie
|
||||
return Release( pSfr) ;
|
||||
|
||||
+2
-309
@@ -17,7 +17,7 @@
|
||||
#include "CurveLine.h"
|
||||
#include "CurveArc.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkOffsetCurve.h"
|
||||
#include "/EgtDev/Include/EgkOffsetCurve.h"
|
||||
#include "/EgtDev/Include/EGkStmFromCurves.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <algorithm>
|
||||
@@ -321,313 +321,6 @@ GetSurfTriMeshByScrewing( const ICurve* pCurve, const Point3d& ptAx, const Vecto
|
||||
return Release( pSTM) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static ISurfTriMesh*
|
||||
GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide, int nCapType, double dLinTol)
|
||||
{
|
||||
// verifico che la linea guida sia piana
|
||||
Plane3d plGuide ;
|
||||
if ( ! pGuide->IsFlat( plGuide, false, 10 * EPS_SMALL))
|
||||
return nullptr ;
|
||||
Vector3d vtNorm = plGuide.GetVersN() ;
|
||||
// determino se la guida è chiusa
|
||||
bool bGuideClosed = pGuide->IsClosed() ;
|
||||
// curve di offset
|
||||
OffsetCurve OffsCrvR ;
|
||||
if ( ! OffsCrvR.Make( pGuide, dDimH / 2, ICurve::OFF_FILLET) || OffsCrvR.GetCurveCount() == 0)
|
||||
return nullptr ;
|
||||
PtrOwner<ICurve> pCrvR( OffsCrvR.GetLongerCurve()) ;
|
||||
if ( IsNull( pCrvR))
|
||||
return nullptr ;
|
||||
OffsetCurve OffsCrvL ;
|
||||
if ( ! OffsCrvL.Make( pGuide, -dDimH / 2, ICurve::OFF_FILLET) || OffsCrvL.GetCurveCount() == 0)
|
||||
return nullptr ;
|
||||
PtrOwner<ICurve> pCrvL( OffsCrvL.GetLongerCurve()) ;
|
||||
if ( IsNull( pCrvL))
|
||||
return nullptr ;
|
||||
PtrOwner<ICurve> pCrvRb ;
|
||||
PtrOwner<ICurve> pCrvLb ;
|
||||
// costruisco le parti di superficie
|
||||
PtrOwner<ISurfTriMesh> pSrfTop( GetSurfTriMeshRuled( pCrvR, pCrvL, ISurfTriMesh::RLT_MINDIST, dLinTol)) ;
|
||||
if ( IsNull( pSrfTop))
|
||||
return nullptr ;
|
||||
PtrOwner<ISurfTriMesh> pSrfBot( pSrfTop->Clone()) ;
|
||||
if ( IsNull( pSrfBot))
|
||||
return nullptr ;
|
||||
pSrfBot->Translate( -dDimV * vtNorm) ;
|
||||
pSrfBot->Invert() ;
|
||||
PtrOwner<ISurfTriMesh> pSrfRgt( GetSurfTriMeshByExtrusion( pCrvR, -dDimV * vtNorm, false, dLinTol)) ;
|
||||
if ( IsNull( pSrfRgt))
|
||||
return nullptr ;
|
||||
pSrfRgt->Invert() ;
|
||||
PtrOwner<ISurfTriMesh> pSrfLft( GetSurfTriMeshByExtrusion( pCrvL, -dDimV * vtNorm, false, dLinTol)) ;
|
||||
if ( IsNull( pSrfLft))
|
||||
return nullptr ;
|
||||
// unisco le parti
|
||||
PtrOwner<ISurfTriMesh> pSTM( Release( pSrfTop)) ;
|
||||
pSTM->DoSewing( *pSrfRgt) ;
|
||||
pSTM->DoSewing( *pSrfLft) ;
|
||||
pSTM->DoSewing( *pSrfBot) ;
|
||||
// salvo tolleranza lineare usata e imposto angolo per smooth
|
||||
pSTM->SetLinearTolerance( dLinTol) ;
|
||||
pSTM->SetSmoothAngle( 20) ;
|
||||
// se guida aperta e tappi piatti
|
||||
if ( ! bGuideClosed && nCapType == RSCAP_FLAT) {
|
||||
// verifico che le due estremità siano chiuse e piatte
|
||||
POLYLINEVECTOR vPL ;
|
||||
if ( ! pSTM->GetLoops( vPL) || vPL.size() != 2)
|
||||
return nullptr ;
|
||||
Plane3d plEnds ; double dArea ;
|
||||
if ( ! vPL[0].IsClosedAndFlat( plEnds, dArea, 100 * EPS_SMALL))
|
||||
return nullptr ;
|
||||
if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 100 * EPS_SMALL))
|
||||
return nullptr ;
|
||||
// aggiungo il cap sull'inizio
|
||||
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
|
||||
if ( IsNull( pSci) || ! pSci->CreateByFlatContour( vPL[0]))
|
||||
return nullptr ;
|
||||
pSci->Invert() ;
|
||||
pSTM->DoSewing( *pSci) ;
|
||||
// aggiungo il cap sulla fine
|
||||
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
|
||||
if ( IsNull( pSce) || ! pSce->CreateByFlatContour( vPL[1]))
|
||||
return nullptr ;
|
||||
pSce->Invert() ;
|
||||
pSTM->DoSewing( *pSce) ;
|
||||
}
|
||||
// se altrimenti guida aperta e tappi arrotondati
|
||||
if ( ! bGuideClosed && ( nCapType == RSCAP_ROUND || nCapType == RSCAP_BEVEL)) {
|
||||
// verifico che le due estremità siano chiuse e piatte
|
||||
//POLYLINEVECTOR vPL ;
|
||||
//if ( ! pSTM->GetLoops( vPL) || vPL.size() != 2)
|
||||
// return nullptr ;
|
||||
//Plane3d plEnds ; double dArea ;
|
||||
//if ( ! vPL[0].IsClosedAndFlat( plEnds, dArea, 50 * EPS_SMALL))
|
||||
// return nullptr ;
|
||||
//if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 50 * EPS_SMALL))
|
||||
// return nullptr ;
|
||||
// step di rotazione per rispettare la tolleranza
|
||||
double dStepRotDeg = ( nCapType == RSCAP_BEVEL ? ANG_STRAIGHT / 4 : sqrt( 8 * dLinTol / dDimH) * RADTODEG) ;
|
||||
// aggiungo il cap sull'inizio
|
||||
Point3d ptStart ;
|
||||
pGuide->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ;
|
||||
pGuide->GetStartDir( vtStart) ;
|
||||
vtStart.Rotate( vtNorm, 0, 1) ;
|
||||
PolyLine PLStart ;
|
||||
PLStart.AddUPoint( 0, ptStart) ;
|
||||
PLStart.AddUPoint( 1, ptStart + dDimH / 2 * vtStart) ;
|
||||
PLStart.AddUPoint( 2, ptStart + dDimH / 2 * vtStart - dDimV * vtNorm) ;
|
||||
PLStart.AddUPoint( 3, ptStart - dDimV * vtNorm) ;
|
||||
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
|
||||
if ( IsNull( pSci) || ! pSci->CreateByScrewing( PLStart, ptStart, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||
return nullptr ;
|
||||
pSci->Invert() ;
|
||||
pSTM->DoSewing( *pSci) ;
|
||||
// aggiungo il cap sulla fine
|
||||
Point3d ptEnd ;
|
||||
pGuide->GetEndPoint( ptEnd) ;
|
||||
Vector3d vtEnd ;
|
||||
pGuide->GetEndDir( vtEnd) ;
|
||||
vtEnd.Rotate( vtNorm, 0, -1) ;
|
||||
PolyLine PLEnd ;
|
||||
PLEnd.AddUPoint( 0, ptEnd) ;
|
||||
PLEnd.AddUPoint( 1, ptEnd + dDimH / 2 * vtEnd) ;
|
||||
PLEnd.AddUPoint( 2, ptEnd + dDimH / 2 * vtEnd - dDimV * vtNorm) ;
|
||||
PLEnd.AddUPoint( 3, ptEnd - dDimV * vtNorm) ;
|
||||
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
|
||||
if ( IsNull( pSce) || ! pSce->CreateByScrewing( PLEnd, ptEnd, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||
return nullptr ;
|
||||
pSce->Invert() ;
|
||||
pSTM->DoSewing( *pSce) ;
|
||||
// elimino eventuali fessure
|
||||
//pSTM->Repair() ;
|
||||
}
|
||||
// restituisco la superficie
|
||||
return Release( pSTM) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static ISurfTriMesh*
|
||||
GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, double dBevelV, const ICurve* pGuide, int nCapType, double dLinTol)
|
||||
{
|
||||
// verifico che la linea guida sia piana
|
||||
Plane3d plGuide ;
|
||||
if ( ! pGuide->IsFlat( plGuide, false, 10 * EPS_SMALL))
|
||||
return nullptr ;
|
||||
// assegno la normale del piano
|
||||
Vector3d vtNorm = plGuide.GetVersN() ;
|
||||
// determino il punto centrale della sezione
|
||||
Point3d ptCen ;
|
||||
pGuide->GetStartPoint( ptCen) ;
|
||||
ptCen -= dDimV / 2 * vtNorm ;
|
||||
// determino se la guida è chiusa
|
||||
bool bGuideClosed = pGuide->IsClosed() ;
|
||||
// curve di offset
|
||||
OffsetCurve OffsCrvR ;
|
||||
if ( ! OffsCrvR.Make( pGuide, dDimH / 2 - dBevelH, ICurve::OFF_FILLET) || OffsCrvR.GetCurveCount() == 0)
|
||||
return nullptr ;
|
||||
PtrOwner<ICurve> pCrvR( OffsCrvR.GetLongerCurve()) ;
|
||||
if ( IsNull( pCrvR))
|
||||
return nullptr ;
|
||||
OffsetCurve OffsCrvL ;
|
||||
if ( ! OffsCrvL.Make( pGuide, -dDimH / 2 + dBevelH, ICurve::OFF_FILLET) || OffsCrvL.GetCurveCount() == 0)
|
||||
return nullptr ;
|
||||
PtrOwner<ICurve> pCrvL( OffsCrvL.GetLongerCurve()) ;
|
||||
if ( IsNull( pCrvL))
|
||||
return nullptr ;
|
||||
OffsetCurve OffsCrvRb ;
|
||||
if ( ! OffsCrvRb.Make( pGuide, dDimH / 2, ICurve::OFF_FILLET) || OffsCrvRb.GetCurveCount() == 0)
|
||||
return nullptr ;
|
||||
PtrOwner<ICurve> pCrvRb( OffsCrvRb.GetLongerCurve()) ;
|
||||
if ( IsNull( pCrvRb))
|
||||
return nullptr ;
|
||||
pCrvRb->Translate( - dBevelV * vtNorm) ;
|
||||
OffsetCurve OffsCrvLb ;
|
||||
if ( ! OffsCrvLb.Make( pGuide, -dDimH / 2, ICurve::OFF_FILLET) || OffsCrvLb.GetCurveCount() == 0)
|
||||
return nullptr ;
|
||||
PtrOwner<ICurve> pCrvLb( OffsCrvLb.GetLongerCurve()) ;
|
||||
if ( IsNull( pCrvLb))
|
||||
return nullptr ;
|
||||
pCrvLb->Translate( - dBevelV * vtNorm) ;
|
||||
// costruisco le parti di superficie
|
||||
PtrOwner<ISurfTriMesh> pSrfTop( GetSurfTriMeshRuled( pCrvR, pCrvL, ISurfTriMesh::RLT_MINDIST, dLinTol)) ;
|
||||
if ( IsNull( pSrfTop))
|
||||
return nullptr ;
|
||||
PtrOwner<ISurfTriMesh> pSrfBot( pSrfTop->Clone()) ;
|
||||
if ( IsNull( pSrfBot))
|
||||
return nullptr ;
|
||||
pSrfBot->Translate( -dDimV * vtNorm) ;
|
||||
pSrfBot->Invert() ;
|
||||
PtrOwner<ISurfTriMesh> pSrfTopR( GetSurfTriMeshRuled( pCrvRb, pCrvR, ISurfTriMesh::RLT_MINDIST, dLinTol)) ;
|
||||
if ( IsNull( pSrfTopR))
|
||||
return nullptr ;
|
||||
PtrOwner<ISurfTriMesh> pSrfBotR( pSrfTopR->Clone()) ;
|
||||
if ( IsNull( pSrfBotR))
|
||||
return nullptr ;
|
||||
pSrfBotR->Mirror( ptCen, vtNorm) ;
|
||||
PtrOwner<ISurfTriMesh> pSrfTopL( GetSurfTriMeshRuled( pCrvL, pCrvLb, ISurfTriMesh::RLT_MINDIST, dLinTol)) ;
|
||||
if ( IsNull( pSrfTopL))
|
||||
return nullptr ;
|
||||
PtrOwner<ISurfTriMesh> pSrfBotL( pSrfTopL->Clone()) ;
|
||||
if ( IsNull( pSrfBotL))
|
||||
return nullptr ;
|
||||
pSrfBotL->Mirror( ptCen, vtNorm) ;
|
||||
PtrOwner<ISurfTriMesh> pSrfRgt( GetSurfTriMeshByExtrusion( pCrvRb, ( -dDimV + 2 * dBevelV) * vtNorm, false, dLinTol)) ;
|
||||
if ( IsNull( pSrfRgt))
|
||||
return nullptr ;
|
||||
pSrfRgt->Invert() ;
|
||||
PtrOwner<ISurfTriMesh> pSrfLft( GetSurfTriMeshByExtrusion( pCrvLb, ( -dDimV + 2 * dBevelV) * vtNorm, false, dLinTol)) ;
|
||||
if ( IsNull( pSrfLft))
|
||||
return nullptr ;
|
||||
// unisco le parti
|
||||
PtrOwner<ISurfTriMesh> pSTM( Release( pSrfTop)) ;
|
||||
pSTM->DoSewing( *pSrfTopR) ;
|
||||
pSTM->DoSewing( *pSrfTopL) ;
|
||||
pSTM->DoSewing( *pSrfRgt) ;
|
||||
pSTM->DoSewing( *pSrfLft) ;
|
||||
pSTM->DoSewing( *pSrfBotR) ;
|
||||
pSTM->DoSewing( *pSrfBotL) ;
|
||||
pSTM->DoSewing( *pSrfBot) ;
|
||||
// salvo tolleranza lineare usata e imposto angolo per smooth
|
||||
pSTM->SetLinearTolerance( dLinTol) ;
|
||||
pSTM->SetSmoothAngle( 20) ;
|
||||
// se guida aperta e tappi piatti
|
||||
if ( ! bGuideClosed && nCapType == RSCAP_FLAT) {
|
||||
// verifico che le due estremità siano chiuse e piatte
|
||||
POLYLINEVECTOR vPL ;
|
||||
if ( ! pSTM->GetLoops( vPL) || vPL.size() != 2)
|
||||
return nullptr ;
|
||||
Plane3d plEnds ; double dArea ;
|
||||
if ( ! vPL[0].IsClosedAndFlat( plEnds, dArea, 50 * EPS_SMALL))
|
||||
return nullptr ;
|
||||
if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 50 * EPS_SMALL))
|
||||
return nullptr ;
|
||||
// aggiungo il cap sull'inizio
|
||||
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
|
||||
if ( IsNull( pSci) || ! pSci->CreateByFlatContour( vPL[0]))
|
||||
return nullptr ;
|
||||
pSci->Invert() ;
|
||||
pSTM->DoSewing( *pSci) ;
|
||||
// aggiungo il cap sulla fine
|
||||
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
|
||||
if ( IsNull( pSce) || ! pSce->CreateByFlatContour( vPL[1]))
|
||||
return nullptr ;
|
||||
pSce->Invert() ;
|
||||
pSTM->DoSewing( *pSce) ;
|
||||
}
|
||||
// se altrimenti guida aperta e tappi arrotondati
|
||||
if ( ! bGuideClosed && ( nCapType == RSCAP_ROUND || nCapType == RSCAP_BEVEL)) {
|
||||
// verifico che le due estremità siano chiuse e piatte
|
||||
//POLYLINEVECTOR vPL ;
|
||||
//if ( ! pSTM->GetLoops( vPL) || vPL.size() != 2)
|
||||
// return nullptr ;
|
||||
//Plane3d plEnds ; double dArea ;
|
||||
//if ( ! vPL[0].IsClosedAndFlat( plEnds, dArea, 50 * EPS_SMALL))
|
||||
// return nullptr ;
|
||||
//if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 50 * EPS_SMALL))
|
||||
// return nullptr ;
|
||||
// step di rotazione per rispettare il tipo o la tolleranza
|
||||
double dStepRotDeg = ( nCapType == RSCAP_BEVEL ? ANG_STRAIGHT / 4 : sqrt( 8 * dLinTol / dDimH) * RADTODEG) ;
|
||||
// aggiungo il cap sull'inizio
|
||||
Point3d ptStart ;
|
||||
pGuide->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ;
|
||||
pGuide->GetStartDir( vtStart) ;
|
||||
vtStart.Rotate( vtNorm, 0, 1) ;
|
||||
PolyLine PLStart ;
|
||||
PLStart.AddUPoint( 0, ptStart) ;
|
||||
PLStart.AddUPoint( 1, ptStart + ( dDimH / 2 - dBevelH) * vtStart) ;
|
||||
PLStart.AddUPoint( 2, ptStart + dDimH / 2 * vtStart - dBevelV * vtNorm) ;
|
||||
PLStart.AddUPoint( 3, ptStart + dDimH / 2 * vtStart - ( dDimV - dBevelV) * vtNorm) ;
|
||||
PLStart.AddUPoint( 4, ptStart + ( dDimH / 2 - dBevelH) * vtStart - dDimV * vtNorm) ;
|
||||
PLStart.AddUPoint( 5, ptStart - dDimV * vtNorm) ;
|
||||
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
|
||||
if ( IsNull( pSci) || ! pSci->CreateByScrewing( PLStart, ptStart, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||
return nullptr ;
|
||||
pSci->Invert() ;
|
||||
pSTM->DoSewing( *pSci) ;
|
||||
// aggiungo il cap sulla fine
|
||||
Point3d ptEnd ;
|
||||
pGuide->GetEndPoint( ptEnd) ;
|
||||
Vector3d vtEnd ;
|
||||
pGuide->GetEndDir( vtEnd) ;
|
||||
vtEnd.Rotate( vtNorm, 0, -1) ;
|
||||
PolyLine PLEnd ;
|
||||
PLEnd.AddUPoint( 0, ptEnd) ;
|
||||
PLEnd.AddUPoint( 1, ptEnd + ( dDimH / 2 - dBevelH) * vtEnd) ;
|
||||
PLEnd.AddUPoint( 2, ptEnd + dDimH / 2 * vtEnd - dBevelV * vtNorm) ;
|
||||
PLEnd.AddUPoint( 3, ptEnd + dDimH / 2 * vtEnd - ( dDimV - dBevelV) * vtNorm) ;
|
||||
PLEnd.AddUPoint( 4, ptEnd + ( dDimH / 2 - dBevelH) * vtEnd - dDimV * vtNorm) ;
|
||||
PLEnd.AddUPoint( 5, ptEnd - dDimV * vtNorm) ;
|
||||
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
|
||||
if ( IsNull( pSce) || ! pSce->CreateByScrewing( PLEnd, ptEnd, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||
return nullptr ;
|
||||
pSce->Invert() ;
|
||||
pSTM->DoSewing( *pSce) ;
|
||||
// elimino eventuali fessure
|
||||
//pSTM->Repair() ;
|
||||
}
|
||||
// restituisco la superficie
|
||||
return Release( pSTM) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
ISurfTriMesh*
|
||||
GetSurfTriMeshRectSwept( double dDimH, double dDimV, double dBevelH, double dBevelV, const ICurve* pGuide, int nCapType, double dLinTol)
|
||||
{
|
||||
// verifica parametri
|
||||
if ( pGuide == nullptr || dBevelH > 0.4 * dDimH || dBevelV > 0.4 * dDimV)
|
||||
return nullptr ;
|
||||
// determino se sezione squadrata o con smusso
|
||||
bool bSharp = ( dBevelH < 100 * EPS_SMALL || dBevelV < 100 * EPS_SMALL) ;
|
||||
// eseguo
|
||||
if ( bSharp)
|
||||
return GetSurfTriMeshSharpRectSwept( dDimH, dDimV, pGuide, nCapType, dLinTol) ;
|
||||
else
|
||||
return GetSurfTriMeshBeveledRectSwept( dDimH, dDimV, dBevelH, dBevelV, pGuide, nCapType, dLinTol) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
ISurfTriMesh*
|
||||
GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, double dLinTol)
|
||||
@@ -671,7 +364,7 @@ GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, d
|
||||
while ( bPoint) {
|
||||
// nuova curva
|
||||
OffsetCurve OffsCrv ;
|
||||
if ( ! OffsCrv.Make( pGuide, ptP.x, ICurve::OFF_FILLET) || OffsCrv.GetCurveCount() == 0)
|
||||
if ( ! OffsCrv.Make( pGuide, ptP.x, ICurve::OFF_FILLET) || OffsCrv.GetCurveCount() > 1)
|
||||
return nullptr ;
|
||||
PtrOwner<ICurve> pCurrCrv( OffsCrv.GetLongerCurve()) ;
|
||||
if ( IsNull( pCurrCrv))
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "/EgtDEv/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDEv/Include/EgkStringUtils3d.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user