Compare commits
131 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 10f9aeb870 | |||
| c088ac9a08 | |||
| 932f590b61 | |||
| df4188002a | |||
| 005f75a4ba | |||
| b5a74807ef | |||
| 56d7726a58 | |||
| 9db53c7ee3 | |||
| 43c511b86f | |||
| 7043b2b318 | |||
| 3c458e9187 | |||
| 3fc056af67 | |||
| 46dbd17d7b | |||
| 86395eb2d1 | |||
| 5fbc75e4bd | |||
| 3d326c9ca2 | |||
| 2a43eca91c | |||
| debf3d65ba | |||
| cfe3672f8b | |||
| 9dfe558a83 | |||
| cc312f1529 | |||
| d88de3576d | |||
| 9e1d183343 | |||
| 09665eda9f | |||
| 44d080eae9 | |||
| d5e1be8be2 | |||
| d96660e6d1 | |||
| d72f7b6299 | |||
| 1f77e00f34 | |||
| 5c222cc59f | |||
| 7ee7fea375 | |||
| 1c2b127a91 | |||
| 0e927d7294 | |||
| 0dc918880e | |||
| ac5fe3ac65 | |||
| a9d6a87317 | |||
| 650540e573 | |||
| 0ae7e1876b | |||
| 4e7501ed7f | |||
| 59f5c16c3b | |||
| 1280037d1d | |||
| c91c2a9720 | |||
| 7c44a6ec82 | |||
| 6277b2eaa8 | |||
| 92da41d421 | |||
| f7f30854a1 | |||
| 5eea981790 | |||
| f52608e15a | |||
| fbbb0739ee | |||
| 903f0c69bc | |||
| 2ca801e2ec | |||
| fc9312f0f2 | |||
| c2b36208e7 | |||
| b1e30147ea | |||
| 4903fcd9d2 | |||
| c3de378c7d | |||
| b818f5dcb2 | |||
| 6d2cc32568 | |||
| 9bee3fbb8f | |||
| cd303ff099 | |||
| c192d9a539 | |||
| fce40ffc38 | |||
| 5bd5efafb1 | |||
| d6fffd228e | |||
| b96daf4925 | |||
| c755406963 | |||
| 296b274190 | |||
| f378661948 | |||
| 37fc7b2164 | |||
| 91dca91153 | |||
| e30a2481a2 | |||
| 70f2f1cb01 | |||
| c158f8ac3e | |||
| a46fbb3f05 | |||
| b53a5adca4 | |||
| 7d6e3dc386 | |||
| f352ca0ae0 | |||
| 68d0198f3f | |||
| 0007121340 | |||
| a6e3c42340 | |||
| c0c01573ca | |||
| badbef94e6 | |||
| 610bd48747 | |||
| 2d5657a05a | |||
| 04b47e40b4 | |||
| 5bb1fdaed3 | |||
| a5714cc85d | |||
| 83a4c03979 | |||
| 058814a64b | |||
| 3c52ca3fef | |||
| 9ec04bff06 | |||
| fd2ba16258 | |||
| 18d7e471ae | |||
| d96ea77db7 | |||
| 041cbe4a8f | |||
| bfc6439dc0 | |||
| 4f16e8263a | |||
| b2bd8f7afe | |||
| cb0452a248 | |||
| b7a5123ba9 | |||
| 29c00caf4a | |||
| 73a65d8cf9 | |||
| 419d325409 | |||
| 349c515e3e | |||
| 69166fe585 | |||
| 8279e66cae | |||
| 1c34e40289 | |||
| e9c22b895b | |||
| ebda605497 | |||
| 06a69fa66b | |||
| 4daa62db97 | |||
| cb1edcf20a | |||
| d3d7f94c3a | |||
| 1aeb2809fa | |||
| 7cf933ec48 | |||
| f3346fd1f1 | |||
| 579bc5492c | |||
| 71ac2fde82 | |||
| 56d80f5bdd | |||
| 4704554728 | |||
| e4243a2df3 | |||
| 967f5aa795 | |||
| f0429aefa4 | |||
| c3b8677910 | |||
| 268983804e | |||
| 8c79bbb2b6 | |||
| 2d83c860f2 | |||
| 6a3fc0fd97 | |||
| 97fd05640b | |||
| 5d4b220dc7 | |||
| bca419ad63 |
+30
-5
@@ -149,11 +149,36 @@ MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
|
||||
}
|
||||
// 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 ;
|
||||
double dParA = vIccInfo[i].IciA[0].dU ;
|
||||
double dParB = vIccInfo[i].IciB[0].dU ;
|
||||
if ( abs( dParA - dEnd) < EPS_SMALL)
|
||||
swap( dParA, dParB) ;
|
||||
// verifico se uno dei due intervalli dà origine ad un tratto trascurabile
|
||||
PtrOwner<ICurve> pCrv1( pMyCrv->CopyParamRange( dParA, dParB)) ;
|
||||
PtrOwner<ICurve> pCrv2( pMyCrv->CopyParamRange( dParB, dParA)) ;
|
||||
double dArea1 = 0, dArea2 = 0 ;
|
||||
if ( ! IsNull( pCrv1))
|
||||
pCrv1->GetAreaXY( dArea1) ;
|
||||
if ( ! IsNull( pCrv2))
|
||||
pCrv2->GetAreaXY( dArea2) ;
|
||||
|
||||
if ( abs( dArea1) > 1e6 * abs( dArea2)) {
|
||||
// se il tratto dParB->dParA non è significativo
|
||||
inOk.Subtract( dStart, dParA) ;
|
||||
inOk.Subtract( dParB, dEnd) ;
|
||||
}
|
||||
else if ( abs( dArea2) > 1e6 * abs( dArea1)) {
|
||||
// se il tratto dParA->dParB non è siginificativo
|
||||
inOk.Subtract( dParA, dParB) ;
|
||||
}
|
||||
else {
|
||||
// se entrambe le regioni sono significative
|
||||
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 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ GetArcPntDirTgBezier( const Point3d& ptP, const Vector3d& vtDir, const CurveBezi
|
||||
return nullptr ;
|
||||
// calcolo la circonferenza tangente a questa approssimazione
|
||||
Point3d ptTg ;
|
||||
PtrOwner<ICurve> pCrv( GetCurve( GetArcPntDirTgCurve( ptP, vtDir, *pCrvCompo, ptNear, vtN, &ptTg))) ;
|
||||
PtrOwner<ICurve> pCrv( GetArcPntDirTgCurve( ptP, vtDir, *pCrvCompo, ptNear, vtN, &ptTg)) ;
|
||||
if ( IsNull( pCrv))
|
||||
return nullptr ;
|
||||
// porto il punto di tangenza della circonferenza esattamente sulla curva di Bezier
|
||||
@@ -330,7 +330,7 @@ GetArcPntDirTgCompo( const Point3d& ptP, const Vector3d& vtDir, const CurveCompo
|
||||
pCrv = crvCompo.GetNextCurve()) {
|
||||
// recupero la circonferenza tangente alla curva elementare
|
||||
Point3d ptTg ;
|
||||
PtrOwner<ICurve> pCrvTmp( GetCurve( GetArcPntDirTgCurve( ptP, vtDir, *pCrv, ptNear, vtN, &ptTg))) ;
|
||||
PtrOwner<ICurve> pCrvTmp( GetArcPntDirTgCurve( ptP, vtDir, *pCrv, ptNear, vtN, &ptTg)) ;
|
||||
if ( IsNull( pCrvTmp))
|
||||
continue ;
|
||||
// verifico se è la più vicina al punto desiderato
|
||||
|
||||
+23
-29
@@ -81,8 +81,7 @@ Attribs::Dump( const GeomDB& GDB, string& sOut, bool bMM, const char* szNewLine)
|
||||
}
|
||||
sOut += szNewLine ;
|
||||
// eventuali nome e stringhe informative
|
||||
STRLIST::const_iterator iIter ;
|
||||
for ( iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter)
|
||||
for ( auto iIter = m_slInfo.cbegin() ; iIter != m_slInfo.cend() ; ++ iIter)
|
||||
sOut += *iIter + szNewLine ;
|
||||
|
||||
return true ;
|
||||
@@ -101,7 +100,7 @@ Attribs::Save( NgeWriter& ngeOut) const
|
||||
// modo
|
||||
if ( ! ngeOut.WriteUchar( m_Data[MODE], ","))
|
||||
return false ;
|
||||
// stato (se SEL è convertito in ON)
|
||||
// stato (se SEL è convertito in ON)
|
||||
int nStat = (( m_Data[STATUS] > GDB_ST_ON) ? GDB_ST_ON : m_Data[STATUS]) ;
|
||||
if ( ! ngeOut.WriteUchar( nStat, ","))
|
||||
return false ;
|
||||
@@ -118,8 +117,7 @@ Attribs::Save( NgeWriter& ngeOut) const
|
||||
if ( ! ngeOut.WriteInt( int( m_slInfo.size()), ";", true))
|
||||
return false ;
|
||||
// stringhe di info
|
||||
STRLIST::const_iterator iIter ;
|
||||
for ( iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) {
|
||||
for ( auto iIter = m_slInfo.cbegin() ; iIter != m_slInfo.cend() ; ++ iIter) {
|
||||
if ( ! ngeOut.WriteString( *iIter, nullptr, true))
|
||||
return false ;
|
||||
}
|
||||
@@ -141,7 +139,7 @@ Attribs::Load( NgeReader& ngeIn)
|
||||
if ( ! ngeIn.ReadUchar( ucMode, ","))
|
||||
return false ;
|
||||
m_Data[MODE] = CLIP( ucMode, GDB_MD_STD, GDB_MD_HIDDEN) ;
|
||||
// stato (se SEL è convertito in ON)
|
||||
// stato (se SEL è convertito in ON)
|
||||
unsigned char ucStat ;
|
||||
if ( ! ngeIn.ReadUchar( ucStat, ","))
|
||||
return false ;
|
||||
@@ -177,7 +175,7 @@ Attribs::Load( NgeReader& ngeIn)
|
||||
bool
|
||||
Attribs::DataFromString( const string& sParam)
|
||||
{
|
||||
// il primo parametro è diviso in 4 parti
|
||||
// il primo parametro è diviso in 4 parti
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam, ",", vsParams) ;
|
||||
// 4 parti
|
||||
@@ -215,10 +213,9 @@ Attribs::SetName( const string& sName)
|
||||
if ( sName.empty() || ! IsValidVal( sName))
|
||||
return false ;
|
||||
|
||||
// può essere solo la prima stringa
|
||||
STRLIST::iterator iIter ;
|
||||
if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() &&
|
||||
FindKey( *iIter, NAME)) {
|
||||
// può essere solo la prima stringa
|
||||
auto iIter = m_slInfo.begin() ;
|
||||
if ( iIter != m_slInfo.end() && FindKey( *iIter, NAME)) {
|
||||
*iIter = NAME + EQUAL + sName ;
|
||||
return true ;
|
||||
}
|
||||
@@ -237,10 +234,9 @@ Attribs::SetName( const string& sName)
|
||||
bool
|
||||
Attribs::GetName( string& sName) const
|
||||
{
|
||||
// può essere solo la prima stringa
|
||||
STRLIST::const_iterator iIter ;
|
||||
if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() &&
|
||||
FindKey( *iIter, NAME)) {
|
||||
// può essere solo la prima stringa
|
||||
const auto iIter = m_slInfo.cbegin() ;
|
||||
if ( iIter != m_slInfo.cend() && FindKey( *iIter, NAME)) {
|
||||
sName = iIter->substr( NAME.length() + 1) ;
|
||||
return true ;
|
||||
}
|
||||
@@ -252,23 +248,18 @@ Attribs::GetName( string& sName) const
|
||||
bool
|
||||
Attribs::ExistsName( void) const
|
||||
{
|
||||
// può essere solo la prima stringa
|
||||
STRLIST::const_iterator iIter ;
|
||||
if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() &&
|
||||
FindKey( *iIter, NAME))
|
||||
return true ;
|
||||
|
||||
return false ;
|
||||
// può essere solo la prima stringa
|
||||
const auto iIter = m_slInfo.cbegin() ;
|
||||
return ( iIter != m_slInfo.cend() && FindKey( *iIter, NAME)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Attribs::RemoveName( void)
|
||||
{
|
||||
// può essere solo la prima stringa
|
||||
STRLIST::const_iterator iIter ;
|
||||
if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() &&
|
||||
FindKey( *iIter, NAME)) {
|
||||
// può essere solo la prima stringa
|
||||
const auto iIter = m_slInfo.cbegin() ;
|
||||
if ( iIter != m_slInfo.cend() && FindKey( *iIter, NAME)) {
|
||||
m_slInfo.pop_front() ;
|
||||
return true ;
|
||||
}
|
||||
@@ -285,11 +276,11 @@ Attribs::SetInfo( const string& sKey, const string& sVal)
|
||||
if ( ! IsValidKey( sKey) || sVal.empty() || ! IsValidVal( sVal))
|
||||
return false ;
|
||||
|
||||
// se è il nome
|
||||
// se è il nome
|
||||
if ( sKey == NAME)
|
||||
return SetName( sVal) ;
|
||||
|
||||
// se esiste già una stringa con quella chiave la sostituisco
|
||||
// se esiste già una stringa con quella chiave la sostituisco
|
||||
for ( auto iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) {
|
||||
if ( FindKey( *iIter, sKey)) {
|
||||
*iIter = sKey + EQUAL + sVal ;
|
||||
@@ -362,8 +353,11 @@ Attribs::GetAllInfo( STRVECTOR& vsInfo) const
|
||||
{
|
||||
// riservo spazio opportuno per il vettore delle stringhe
|
||||
vsInfo.clear() ;
|
||||
if ( (int) m_slInfo.size() == 0)
|
||||
|
||||
// se non ci sono info esco
|
||||
if ( m_slInfo.empty())
|
||||
return true ;
|
||||
|
||||
vsInfo.reserve( m_slInfo.size()) ;
|
||||
// recupero tutte le info tranne il nome (se presente sempre al primo posto)
|
||||
auto iIter = m_slInfo.cbegin() ;
|
||||
|
||||
+6
-6
@@ -14,10 +14,10 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "BiArcs.h"
|
||||
#include "CurveLine.h"
|
||||
#include "CurveArc.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkAngle.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
@@ -50,7 +50,7 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
|
||||
return nullptr ;
|
||||
|
||||
// preparo la curva composita per i biarchi
|
||||
PtrOwner<ICurveComposite> pBiArc( CreateCurveComposite()) ;
|
||||
PtrOwner<CurveComposite> pBiArc( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pBiArc))
|
||||
return nullptr ;
|
||||
|
||||
@@ -95,7 +95,7 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
|
||||
pBiArc.Set( GetBiArc( ptP0, dDir0Deg, ptP1, dDir1Deg, 0.5)) ;
|
||||
}
|
||||
else {
|
||||
CurveArc* pArc = GetBasicCurveArc( pJCrv) ;
|
||||
const CurveArc* pArc = GetBasicCurveArc( pJCrv) ;
|
||||
if ( pArc == nullptr)
|
||||
return nullptr ;
|
||||
double dU = -1 ;
|
||||
@@ -172,7 +172,7 @@ CalcJCurve( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dD
|
||||
|
||||
// se rotazione nulla, allora segmento di retta tra i due punti
|
||||
if ( abs( dAngDeg) < EPS_ANG_SMALL) {
|
||||
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
|
||||
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pLine) || ! pLine->Set( ptP0, ptP1))
|
||||
return nullptr ;
|
||||
// inverto per avere parametrizzazione crescente allontanandosi da Dir0 e avvicinandosi a Dir1
|
||||
@@ -194,7 +194,7 @@ CalcJCurve( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dD
|
||||
Vector3d vtStart = ptP0 - ptCen ;
|
||||
double dRad, dAngStart ;
|
||||
vtStart.ToSpherical( &dRad, nullptr, &dAngStart) ;
|
||||
PtrOwner<ICurveArc> pArc( CreateCurveArc()) ;
|
||||
PtrOwner<CurveArc> pArc( CreateBasicCurveArc()) ;
|
||||
if ( IsNull( pArc) || ! pArc->SetXY( ptCen, dRad, dAngStart, dAngDeg, ( ptP1.z - ptP0.z)))
|
||||
return nullptr ;
|
||||
double dDirStartDeg = dAngStart + ( dAngDeg > 0 ? ANG_RIGHT : - ANG_RIGHT) ;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2018-2018
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CAToolSurfTm.cpp Data : 08.05.18 Versione : 1.9e2
|
||||
// Contenuto : Implementazione della classe CAToolSurfTm.
|
||||
// File : CAvToolSurfTm.cpp Data : 08.05.18 Versione : 1.9e2
|
||||
// Contenuto : Implementazione della classe CAvToolSurfTm.
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
+13
-11
@@ -146,18 +146,20 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
|
||||
const Triangle3d& trTria, const Vector3d& vtMove)
|
||||
{
|
||||
// Non ha senso che il movimento sia in direzione "opposta" a quella dell'asse utensile
|
||||
if ( vtMove * vtToolAx < - EPS_ZERO)
|
||||
if ( vtMove * vtToolAx < - 10 * EPS_ZERO)
|
||||
return -1. ;
|
||||
// Se avvicinamento non devo fare nulla
|
||||
if ( vtMove * trTria.GetN() < - EPS_ZERO)
|
||||
return 0. ;
|
||||
return 0. ;
|
||||
// Tolleranza su dischi (parti piatte perpendicolari all'asse utensile)
|
||||
double dEpsilon = ( vtMove * vtToolAx > 0.5 ? 0 : EPS_SMALL) ;
|
||||
// se utensile cilindrico
|
||||
if ( tlTool.GetType() == Tool::CYLMILL) {
|
||||
// parametri geometrici
|
||||
double dHeigth = tlTool.GetHeigth() ;
|
||||
double dRadius = tlTool.GetRadius() ;
|
||||
// prima determino l'allontanamento del disco inferiore
|
||||
double dDist = CAvDiskTriangle( ptToolOrig - ( dHeigth - EPS_SMALL) * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
double dDist = CAvDiskTriangle( ptToolOrig - ( dHeigth - dEpsilon) * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
if ( dDist < - EPS_SMALL)
|
||||
return dDist ;
|
||||
// poi verifico quello del cilindro (tenendo conto di quanto è stata allontanato il disco)
|
||||
@@ -165,7 +167,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
|
||||
if ( dDist2 < - EPS_SMALL)
|
||||
return dDist2 ;
|
||||
// verifico quello del disco sopra
|
||||
double dDist3 = CAvDiskTriangle( ptToolOrig - EPS_SMALL * vtToolAx + ( dDist + dDist2) * vtMove, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
double dDist3 = CAvDiskTriangle( ptToolOrig - dEpsilon * vtToolAx + ( dDist + dDist2) * vtMove, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
if ( dDist3 < - EPS_SMALL)
|
||||
return dDist3 ;
|
||||
return ( dDist + dDist2 + dDist3) ;
|
||||
@@ -189,7 +191,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
|
||||
return dDist2 ;
|
||||
// verifico quello del disco sopra
|
||||
Point3d ptDiskUpOrig = ptCylOrig + dDist2 * vtMove ;
|
||||
double dDist3 = CAvDiskTriangle( ptDiskUpOrig - EPS_SMALL * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
double dDist3 = CAvDiskTriangle( ptDiskUpOrig - dEpsilon * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
if ( dDist3 < - EPS_SMALL)
|
||||
return dDist3 ;
|
||||
return ( dDist + dDist2 + dDist3) ;
|
||||
@@ -199,7 +201,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
|
||||
// parametri geometrici
|
||||
double dCylHeigth = tlTool.GetHeigth() - tlTool.GetTipHeigth() ;
|
||||
// prima determino l'allontanamento del disco inferiore
|
||||
double dDist = CAvDiskTriangle( ptToolOrig - ( tlTool.GetHeigth() - EPS_SMALL) * vtToolAx, vtToolAx, tlTool.GetTipRadius(),
|
||||
double dDist = CAvDiskTriangle( ptToolOrig - ( tlTool.GetHeigth() - dEpsilon) * vtToolAx, vtToolAx, tlTool.GetTipRadius(),
|
||||
trTria, vtMove) ;
|
||||
if ( dDist < - EPS_SMALL)
|
||||
return dDist ;
|
||||
@@ -220,7 +222,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
|
||||
return dDist3 ;
|
||||
// verifico quello del disco sopra
|
||||
Point3d ptDiskUpOrig = ptCylOrig + vtMove * dDist3 ;
|
||||
double dDist4 = CAvDiskTriangle( ptDiskUpOrig - EPS_SMALL * vtToolAx, vtToolAx, tlTool.GetRadius(), trTria, vtMove) ;
|
||||
double dDist4 = CAvDiskTriangle( ptDiskUpOrig - dEpsilon * vtToolAx, vtToolAx, tlTool.GetRadius(), trTria, vtMove) ;
|
||||
if ( dDist4 < - EPS_SMALL)
|
||||
return dDist4 ;
|
||||
return ( dDist + dDist2 + dDist3 + dDist4) ;
|
||||
@@ -247,7 +249,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
|
||||
double dMaxR = max( tlTool.GetRadius(), tlTool.GetTipRadius()) ;
|
||||
double dCylHeigth = tlTool.GetHeigth() - tlTool.GetTipHeigth() ;
|
||||
// prima determino l'allontanamento del disco inferiore
|
||||
double dDist = CAvDiskTriangle( ptToolOrig - ( tlTool.GetHeigth() - EPS_SMALL) * vtToolAx, vtToolAx, tlTool.GetTipRadius(),
|
||||
double dDist = CAvDiskTriangle( ptToolOrig - ( tlTool.GetHeigth() - dEpsilon) * vtToolAx, vtToolAx, tlTool.GetTipRadius(),
|
||||
trTria, vtMove) ;
|
||||
if ( dDist < - EPS_SMALL)
|
||||
return dDist ;
|
||||
@@ -266,7 +268,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
|
||||
return dDist3 ;
|
||||
// verifico quello del disco sopra
|
||||
Point3d ptDiskUpOrig = ptCylOrig + vtMove * dDist3 ;
|
||||
double dDist4 = CAvDiskTriangle( ptDiskUpOrig - EPS_SMALL * vtToolAx, vtToolAx, tlTool.GetRadius(), trTria, vtMove) ;
|
||||
double dDist4 = CAvDiskTriangle( ptDiskUpOrig - dEpsilon * vtToolAx, vtToolAx, tlTool.GetRadius(), trTria, vtMove) ;
|
||||
if ( dDist4 < - EPS_SMALL)
|
||||
return dDist4 ;
|
||||
return ( dDist + dDist2 + dDist3 + dDist4) ;
|
||||
@@ -299,10 +301,10 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
|
||||
double dRadius = max( ptStart.x, ptEnd.x) ;
|
||||
// Se disco verso il basso dell'utensile
|
||||
if ( ptStart.x > ptEnd.x)
|
||||
dDist2 = CAvDiskTriangle( ptCompOrig + EPS_SMALL * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
dDist2 = CAvDiskTriangle( ptCompOrig + dEpsilon * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
// Se disco verso l'alto
|
||||
else
|
||||
dDist2 = CAvDiskTriangle( ptCompOrig - EPS_SMALL * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
dDist2 = CAvDiskTriangle( ptCompOrig - dEpsilon * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
}
|
||||
else {
|
||||
// Verifiche curva precedente per eventuale tappo sopra
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ GetTwoGreater( int nVal0, int nVal1, int nVal2, int& nFirstMaxPos, int& nSecondM
|
||||
}
|
||||
else {
|
||||
nFirstMaxPos = 2 ;
|
||||
nSecondMaxPos = 1 ;
|
||||
nSecondMaxPos = 0 ;
|
||||
}
|
||||
}
|
||||
else if ( nVal0 > nVal2) {
|
||||
@@ -168,7 +168,7 @@ CDeTriaTria( const Triangle3d& trTriaA, const Triangle3d& trTriaB)
|
||||
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) ;
|
||||
DistLineLine LineLineDistCalcSecondB( ptLineP, vtLineV, 100., trTriaB.GetP( nSecondMaxPosB), vtSegSecondB, dSegLenSecondB, false) ;
|
||||
double dIntParEnB, dOtherParSecondB ;
|
||||
LineLineDistCalcSecondB.GetPositionsAtMinDistPoints( dIntParEnB, dOtherParSecondB) ;
|
||||
// Ordino i parametri lungo la retta di intersezione fra i piani
|
||||
|
||||
+3315
File diff suppressed because it is too large
Load Diff
+116
-6
@@ -22,6 +22,7 @@
|
||||
#include "GeoObjFactory.h"
|
||||
#include "NgeWriter.h"
|
||||
#include "NgeReader.h"
|
||||
#include "Voronoi.h"
|
||||
#include "/EgtDev/Include/EGkAngle.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkUiUnits.h"
|
||||
@@ -61,15 +62,14 @@ 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{0,0}, m_dTempParam{0.0, 0.0}, m_pVoronoiObj( nullptr)
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
CurveArc::~CurveArc( void)
|
||||
{
|
||||
ResetVoronoiObject() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -91,7 +91,9 @@ CurveArc::Set( const Point3d& ptCen, const Vector3d& vtN, double dRad,
|
||||
// sistemo i versori
|
||||
m_VtN.Normalize() ;
|
||||
m_VtS.Normalize() ;
|
||||
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -117,6 +119,8 @@ CurveArc::Set( const Point3d& ptCen, const Vector3d& vtN, double dRad)
|
||||
m_dDeltaN = 0 ;
|
||||
m_nStatus = TO_VERIFY ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -138,6 +142,8 @@ CurveArc::SetXY( const Point3d& ptCen, double dRad, double dAngIniDeg, double dA
|
||||
m_dDeltaN = dDeltaZ ;
|
||||
m_nStatus = TO_VERIFY ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -159,6 +165,8 @@ CurveArc::SetXY( const Point3d& ptCen, double dRad)
|
||||
m_dDeltaN = 0 ;
|
||||
m_nStatus = TO_VERIFY ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -221,6 +229,8 @@ CurveArc::Set3P( const Point3d& ptStart, const Point3d& ptOther, const Point3d&
|
||||
// non c'è DeltaN
|
||||
m_dDeltaN = 0 ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -268,6 +278,8 @@ CurveArc::Set2PNB( const Point3d& ptIni, const Point3d& ptFin, const Vector3d& v
|
||||
// calcolo l'angolo al centro
|
||||
m_dAngCenDeg = 4 * atan( dBulge) * RADTODEG ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -324,6 +336,8 @@ CurveArc::Set2PD( const Point3d& ptStart, const Point3d& ptEnd, double dDirStart
|
||||
m_dDeltaN = - m_dDeltaN ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -406,6 +420,8 @@ CurveArc::Set2PRS( const Point3d& ptStart, const Point3d& ptEnd, double dRad, bo
|
||||
( ! bCCW && m_dAngCenDeg > 0)))
|
||||
m_dAngCenDeg = - m_dAngCenDeg ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -460,6 +476,8 @@ CurveArc::SetCPA( const Point3d& ptCen, const Point3d& ptStart, double dAngCenDe
|
||||
// assegno l'angolo al centro
|
||||
m_dAngCenDeg = dAngCenDeg ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -515,7 +533,8 @@ CurveArc::SetC2P( const Point3d& ptCen, const Point3d& ptStart, const Point3d& p
|
||||
bool bDet ;
|
||||
if ( ! m_VtS.GetRotation( ( ptNearEnd - m_PtCen), m_VtN, m_dAngCenDeg, bDet) || ! bDet)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -584,6 +603,8 @@ CurveArc::CopyFrom( const CurveArc& caSrc)
|
||||
m_dThick = caSrc.m_dThick ;
|
||||
m_nTempProp[0] = caSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = caSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = caSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = caSrc.m_dTempParam[1] ;
|
||||
return Set( caSrc.m_PtCen, caSrc.m_VtN, caSrc.m_dRad,
|
||||
caSrc.m_VtS, caSrc.m_dAngCenDeg, caSrc.m_dDeltaN) ;
|
||||
}
|
||||
@@ -1261,7 +1282,9 @@ CurveArc::Invert( void)
|
||||
m_dAngCenDeg = - m_dAngCenDeg ;
|
||||
// l'incremento sulla normale inverte il segno
|
||||
m_dDeltaN = - m_dDeltaN ;
|
||||
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1295,6 +1318,8 @@ CurveArc::SimpleOffset( double dDist, int nType)
|
||||
// aggiorno il raggio
|
||||
m_dRad = dNewRad ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1339,6 +1364,8 @@ CurveArc::MyExtendedOffset( double dDist, bool bAll, int nType)
|
||||
// aggiorno il raggio
|
||||
m_dRad = dNewRad ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1411,6 +1438,8 @@ CurveArc::ModifyEnd( const Point3d& ptNewEnd)
|
||||
m_dDeltaN = arcAux.m_dDeltaN ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1496,6 +1525,8 @@ CurveArc::TrimStartAtLen( double dLenTrim)
|
||||
}
|
||||
}
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1523,6 +1554,8 @@ CurveArc::TrimEndAtLen( double dLenTrim)
|
||||
m_dDeltaN *= dLenTrim / dLen ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1566,6 +1599,8 @@ CurveArc::ExtendEndByLen( double dLenExt)
|
||||
else if ( abs( m_dAngCenDeg) > ANG_FULL)
|
||||
m_dAngCenDeg = _copysign( ANG_FULL, m_dAngCenDeg) ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1580,6 +1615,8 @@ CurveArc::Translate( const Vector3d& vtMove)
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1601,6 +1638,8 @@ CurveArc::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, dou
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1630,6 +1669,8 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
|
||||
// verifico non sia nulla
|
||||
if ( abs( dCoeffX) < EPS_ZERO || m_dRad * abs( dCoeffX) <= EPS_SMALL)
|
||||
return false ;
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
// scalo il centro e le dimensioni lineari
|
||||
@@ -1657,6 +1698,8 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
|
||||
// verifico non sia nulla
|
||||
if ( abs( dCoeffY) < EPS_ZERO || m_dRad * abs( dCoeffY) <= EPS_SMALL)
|
||||
return false ;
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
// scalo il centro e le dimensioni lineari
|
||||
@@ -1684,6 +1727,8 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
|
||||
// verifico non sia nulla
|
||||
if ( abs( dCoeffZ) < EPS_ZERO || m_dRad * abs( dCoeffZ) <= EPS_SMALL)
|
||||
return false ;
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
// scalo il centro e le dimensioni lineari
|
||||
@@ -1711,6 +1756,8 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
|
||||
// verifico non sia nulla
|
||||
if ( abs( dCoeffX) < EPS_ZERO || m_dRad * abs( dCoeffX) <= EPS_SMALL)
|
||||
return false ;
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
// scalo il centro e le dimensioni lineari
|
||||
@@ -1744,6 +1791,8 @@ CurveArc::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
if ( vtNorm.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1775,6 +1824,8 @@ CurveArc::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vt
|
||||
! AreSameOrOppositeVectorExact( m_VtN, vtNorm))
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1806,6 +1857,8 @@ CurveArc::ToGlob( const Frame3d& frRef)
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1831,6 +1884,8 @@ CurveArc::ToLoc( const Frame3d& frRef)
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1856,6 +1911,8 @@ CurveArc::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1879,6 +1936,8 @@ CurveArc::InvertN( void)
|
||||
m_dAngCenDeg = - m_dAngCenDeg ;
|
||||
m_dDeltaN = - m_dDeltaN ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1959,6 +2018,8 @@ CurveArc::ChangeRadius( double dNewRadius)
|
||||
// cambio il raggio
|
||||
m_dRad = dNewRadius ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1978,6 +2039,8 @@ CurveArc::ChangeDeltaN( double dNewDeltaN)
|
||||
// cambio il parametro
|
||||
m_dDeltaN = dNewDeltaN ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2001,6 +2064,8 @@ CurveArc::ChangeAngCenter( double dNewAngCenDeg)
|
||||
// cambio il parametro
|
||||
m_dAngCenDeg = dNewAngCenDeg ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2025,6 +2090,8 @@ CurveArc::ChangeStartPoint( double dU)
|
||||
if ( ! vtDir.Normalize())
|
||||
return false ;
|
||||
m_VtS = vtDir ;
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
return true ;
|
||||
@@ -2044,6 +2111,8 @@ CurveArc::ToExplementary( void)
|
||||
// basta prendere l'angolo al centro che completa il giro
|
||||
m_dAngCenDeg = - _copysign( ANG_FULL, m_dAngCenDeg) + m_dAngCenDeg ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2073,6 +2142,8 @@ CurveArc::Flip( void)
|
||||
m_VtS.Normalize() ;
|
||||
m_dAngCenDeg = - m_dAngCenDeg ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2187,3 +2258,42 @@ ArcApproxer::GetPoint( double& dU, Point3d& ptP)
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveArc::CalcVoronoiObject() const
|
||||
{
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// creo oggetto vroni con la curva
|
||||
m_pVoronoiObj = new( std::nothrow) Voronoi( this, false) ;
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Voronoi*
|
||||
CurveArc::GetVoronoiObject() const
|
||||
{
|
||||
if ( m_nStatus != OK)
|
||||
return nullptr ;
|
||||
|
||||
// se non è stato calcolato, lo calcolo
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
CalcVoronoiObject() ;
|
||||
|
||||
// restituisco Voronoi
|
||||
return m_pVoronoiObj ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
CurveArc::ResetVoronoiObject() const
|
||||
{
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
delete m_pVoronoiObj ;
|
||||
m_pVoronoiObj = nullptr ;
|
||||
}
|
||||
|
||||
+15
-3
@@ -19,6 +19,8 @@
|
||||
#include "GeoObjRW.h"
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
|
||||
class Voronoi ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
{
|
||||
@@ -54,6 +56,11 @@ class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // ICurve
|
||||
bool IsSimple( void) const override
|
||||
@@ -183,7 +190,7 @@ class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
|
||||
public :
|
||||
CurveArc( void) ;
|
||||
CurveArc( const CurveArc& caSrc)
|
||||
CurveArc( const CurveArc& caSrc) : m_pVoronoiObj( nullptr)
|
||||
{ if ( ! CopyFrom( caSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "CurveArc : copy constructor error")}
|
||||
CurveArc& operator =( const CurveArc& caSrc)
|
||||
@@ -192,11 +199,14 @@ class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
return *this ; }
|
||||
bool MyExtendedOffset( double dDist, bool bAll, int nType = OFF_FILLET) ;
|
||||
bool MyCalcPointParamPosiz( const Point3d& ptP, double& dU, int& nPos, double dLinTol) const ;
|
||||
Voronoi* GetVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
bool CopyFrom( const CurveArc& caSrc) ;
|
||||
bool Validate( void) ;
|
||||
bool GetDir( double dU, Vector3d& vtDir) const ;
|
||||
bool GetDir( double dU, Vector3d& vtDir) const ;
|
||||
bool CalcVoronoiObject( void) const ;
|
||||
void ResetVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
||||
@@ -212,7 +222,9 @@ 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[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
mutable Voronoi* m_pVoronoiObj ; // Voronoi
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+59
-17
@@ -19,6 +19,7 @@
|
||||
#include "CurveArc.h"
|
||||
#include "CurveBezier.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "Voronoi.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkUiUnits.h"
|
||||
@@ -522,7 +523,7 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
|
||||
}
|
||||
|
||||
// se periodica
|
||||
if ( cnData.bPeriodic) {
|
||||
if ( cnData.bPeriodic || ! cnData.bClamped) {
|
||||
// va trasformata in non-periodica (clamped)
|
||||
// bisogna aumentare la molteplicità dei nodi u_p-1 e u_(m-p+1) fino ad arrivare al grado della nurbs
|
||||
// e poi scartare nodi e punti fuori dalla regione clamped ( al di fuori della regione u_p-1 -> u_(m-p+1))
|
||||
@@ -540,9 +541,9 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
|
||||
vBW.resize( nDeg + 1) ;
|
||||
|
||||
// trovo il nodo di cui aumentare la molteplicità e ne calcolo la molteplicità
|
||||
int b = nU - nDeg - 1 +1;
|
||||
int b = nU - nDeg - 1 + 1 ;
|
||||
int i = b ;
|
||||
while ( abs( cnData.vU[b] - cnData.vU[b - 1]) < EPS_ZERO)
|
||||
while ( b > 0 && abs( cnData.vU[b] - cnData.vU[b - 1]) < EPS_ZERO)
|
||||
-- b ;
|
||||
int mult = min( i - b + 1, nDeg) ; // mi aspetto che sia 1, ma comunque sarà < nDeg
|
||||
// recupero i punti da modificare
|
||||
@@ -573,14 +574,11 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
|
||||
// procedo all'inserimento
|
||||
int L = 0 ;
|
||||
double alpha ;
|
||||
double num, den ;
|
||||
if ( mult < nDeg) {
|
||||
// inserisco il nodo r volte
|
||||
for ( int j = 1 ; j <= r ; ++ j) {
|
||||
L = b - nDeg + j ;
|
||||
for ( int i = 0; i <= r - j ; ++i) {
|
||||
num = (cnData.vU[b] - cnData.vU[L + i]) ;
|
||||
den = ( cnData.vU[i + b + 1] - cnData.vU[L + i]) ;
|
||||
alpha = (cnData.vU[b] - cnData.vU[L + i])/ ( cnData.vU[i + b + 1] - cnData.vU[L + i]) ;
|
||||
vBC[i] = alpha * vBC[i +1 ] + ( 1 - alpha) * vBC[i] ;
|
||||
if ( cnData.bRat) {
|
||||
@@ -597,7 +595,7 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
|
||||
}
|
||||
|
||||
// allungo il vettore dei nodi e sposto gli ultimi nodi
|
||||
cnData.vU.resize(nU + r) ;
|
||||
cnData.vU.resize( nU + r) ;
|
||||
for ( int p = nU - 1 ; p > b ; --p)
|
||||
cnData.vU[p + r] = cnData.vU[p] ;
|
||||
// aggiungo i nodi nuovi
|
||||
@@ -607,9 +605,9 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
|
||||
nCP = nCP + r ;
|
||||
|
||||
// aumento la molteplicità del punto u_p-1
|
||||
b = nDeg -1;
|
||||
b = nDeg - 1 ;
|
||||
i = b ;
|
||||
while ( abs( cnData.vU[b] - cnData.vU[b - 1]) < EPS_ZERO)
|
||||
while ( b > 0 && abs( cnData.vU[b] - cnData.vU[b - 1]) < EPS_ZERO)
|
||||
-- b ;
|
||||
mult = min( i - b + 1, nDeg) ; // mi aspetto che sia 1, ma comunque sarà < cnData.nDeg
|
||||
// recupero i punti da modificare
|
||||
@@ -720,11 +718,11 @@ NurbsToBezierCurve( const CNurbsData& cnData)
|
||||
}
|
||||
if ( ! bOk)
|
||||
return nullptr ;
|
||||
|
||||
|
||||
// se 1 solo intervallo, la Nurbs è già una curva di Bezier
|
||||
if ( nInt == 1) {
|
||||
// creo la curva di Bezier
|
||||
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
|
||||
PtrOwner<CurveBezier> pCrvBez( CreateBasicCurveBezier()) ;
|
||||
if ( IsNull( pCrvBez))
|
||||
return nullptr ;
|
||||
// la inizializzo
|
||||
@@ -748,7 +746,7 @@ NurbsToBezierCurve( const CNurbsData& cnData)
|
||||
}
|
||||
|
||||
// altrimenti è equivalente ad una curva composita, la creo
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo))
|
||||
return nullptr ;
|
||||
|
||||
@@ -779,7 +777,6 @@ NurbsToBezierCurve( const CNurbsData& cnData)
|
||||
int b = cnData.nDeg ;
|
||||
bool bPrevRejected = false ;
|
||||
// ciclo
|
||||
int n = 0 ; // debug
|
||||
while ( b < nU - 1) {
|
||||
int i = b ;
|
||||
while ( b < nU - 1 && abs( cnData.vU[b+1] - cnData.vU[b]) < EPS_ZERO)
|
||||
@@ -811,7 +808,7 @@ NurbsToBezierCurve( const CNurbsData& cnData)
|
||||
}
|
||||
|
||||
// costruisco la curva di Bezier e la inserisco nella curva composita
|
||||
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
|
||||
PtrOwner<CurveBezier> pCrvBez( CreateBasicCurveBezier()) ;
|
||||
if ( IsNull( pCrvBez))
|
||||
return nullptr ;
|
||||
// se precedente saltata
|
||||
@@ -847,8 +844,6 @@ NurbsToBezierCurve( const CNurbsData& cnData)
|
||||
pCrvBez.Reset() ;
|
||||
bPrevRejected = true ;
|
||||
}
|
||||
// debug
|
||||
++n ;
|
||||
// inizializzazioni per la prossima curva di Bezier
|
||||
if ( b < nU - 1) {
|
||||
if ( ! cnData.bRat) {
|
||||
@@ -875,7 +870,7 @@ NurbsToBezierCurve( const CNurbsData& cnData)
|
||||
// se la curva ha grado 1, manca da aggiungere l'ultimo tratto
|
||||
if ( cnData.nDeg == 1 ) {
|
||||
// costruisco la curva di Bezier e la inserisco nella curva composita
|
||||
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
|
||||
PtrOwner<CurveBezier> pCrvBez( CreateBasicCurveBezier()) ;
|
||||
if ( ! pCrvBez->Init( cnData.nDeg, cnData.bRat))
|
||||
return nullptr ;
|
||||
if ( ! cnData.bRat) {
|
||||
@@ -1045,3 +1040,50 @@ AdjustCurveSlope( ICurveComposite* pCrv, double dNini, double dNfin)
|
||||
pCrv->ModifyEnd( ptFin) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Voronoi*
|
||||
GetCurveVoronoi( const ICurve& crvC)
|
||||
{
|
||||
switch ( crvC.GetType()) {
|
||||
case CRV_LINE : return GetBasicCurveLine( &crvC)->GetVoronoiObject() ;
|
||||
case CRV_ARC : return GetBasicCurveArc( &crvC)->GetVoronoiObject() ;
|
||||
case CRV_BEZIER : return GetBasicCurveBezier( &crvC)->GetVoronoiObject() ;
|
||||
case CRV_COMPO : return GetBasicCurveComposite( &crvC)->GetVoronoiObject() ;
|
||||
}
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CalcCurveVoronoiDiagram( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, int nBound)
|
||||
{
|
||||
Voronoi* pVoronoiObj = GetCurveVoronoi( crvC) ;
|
||||
if ( pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
|
||||
return pVoronoiObj->CalcVoronoiDiagram( vCrvs, nBound) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CalcCurveMedialAxis( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, int nSide)
|
||||
{
|
||||
Voronoi* pVoronoiObj = GetCurveVoronoi( crvC) ;
|
||||
if ( pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
|
||||
return pVoronoiObj->CalcMedialAxis( vCrvs, nSide) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CalcCurveFatCurve( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, double dRadius, bool bSquareEnds, bool bSquareMids)
|
||||
{
|
||||
Voronoi* pVoronoiObj = GetCurveVoronoi( crvC) ;
|
||||
if ( pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
|
||||
return pVoronoiObj->CalcFatCurve( vCrvs, dRadius, bSquareEnds, bSquareMids) ;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
#include "/EgtDev/Include/EGkCurveAux.h"
|
||||
|
||||
class Voronoi ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool IsClosed( const ICurve& crvC) ;
|
||||
bool IsValidParam( const ICurve& crvC, double dPar, ICurve::Side nSide) ;
|
||||
@@ -31,3 +33,4 @@ bool CurveGetArea( const ICurve& crvC, Plane3d& plPlane, double& dArea) ;
|
||||
bool CurveDump( const ICurve& crvC, std::string& sOut, bool bMM, const char* szNewLine) ;
|
||||
bool CopyExtrusion( const ICurve* pSouCrv, ICurve* pDestCrv) ;
|
||||
bool CopyThickness( const ICurve* pSouCrv, ICurve* pDestCrv) ;
|
||||
Voronoi* GetCurveVoronoi( const ICurve& crvC) ;
|
||||
|
||||
+87
-9
@@ -26,6 +26,7 @@
|
||||
#include "PolynomialPoint3d.h"
|
||||
#include "Bernstein.h"
|
||||
#include "deCasteljau.h"
|
||||
#include "Voronoi.h"
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkUiUnits.h"
|
||||
@@ -45,15 +46,14 @@ 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{0,0}, m_dTempParam{0.0,0.0}, m_pVoronoiObj( nullptr)
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
CurveBezier::~CurveBezier( void)
|
||||
{
|
||||
ResetVoronoiObject() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -77,6 +77,8 @@ CurveBezier::Init( int nDeg, bool bIsRational)
|
||||
m_vWeCtrl.clear() ;
|
||||
m_nStatus = TO_VERIFY ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -101,6 +103,8 @@ CurveBezier::SetControlPoint( int nInd, const Point3d& ptCtrl)
|
||||
// annullo analisi presenza singolarità
|
||||
m_dParSing = - 2 ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -126,6 +130,8 @@ CurveBezier::SetControlPoint( int nInd, const Point3d& ptCtrl, double dW)
|
||||
// annullo analisi presenza singolarità
|
||||
m_dParSing = - 2 ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -287,6 +293,8 @@ CurveBezier::CopyFrom( const CurveBezier& cbSrc)
|
||||
m_dThick = cbSrc.m_dThick ;
|
||||
m_nTempProp[0] = cbSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = cbSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = cbSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = cbSrc.m_dTempParam[1] ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -440,9 +448,8 @@ CurveBezier::Validate( void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_nStatus == TO_VERIFY)
|
||||
m_nStatus = ( ( m_nDeg > 0 && m_vPtCtrl.size() > 0) ? OK : ERR) ;
|
||||
m_nStatus = ( ( m_nDeg >= 1 && m_vPtCtrl.size() >= 2) ? OK : ERR) ;
|
||||
|
||||
return ( m_nStatus == OK) ;
|
||||
}
|
||||
@@ -620,7 +627,7 @@ CurveBezier::GetMidPoint( Point3d& ptMid) const
|
||||
return false ;
|
||||
// determino il valore del parametro a metà lunghezza
|
||||
double dLen, dMid ;
|
||||
if ( ! GetLength( dLen) || ! GetParamAtLength( 0.5 * dLen, dMid))
|
||||
if ( ! GetLengthAtParam( 1, dLen) || ! GetParamAtLength( 0.5 * dLen, dMid))
|
||||
return false ;
|
||||
// calcolo il punto
|
||||
return GetPointD1D2( dMid, ptMid) ;
|
||||
@@ -657,7 +664,7 @@ CurveBezier::GetMidDir( Vector3d& vtDir) const
|
||||
return false ;
|
||||
// determino il valore del parametro a metà lunghezza
|
||||
double dLen, dMid ;
|
||||
if ( ! GetLength( dLen) || ! GetParamAtLength( 0.5 * dLen, dMid))
|
||||
if ( ! GetLengthAtParam( 1, dLen) || ! GetParamAtLength( 0.5 * dLen, dMid))
|
||||
return false ;
|
||||
// calcolo la direzione
|
||||
return ::GetTang( *this, dMid, FROM_MINUS, vtDir) ;
|
||||
@@ -1607,6 +1614,8 @@ CurveBezier::Invert( void)
|
||||
for ( int i = 0 ; i < nMid ; ++ i)
|
||||
swap( m_vPtCtrl[i], m_vPtCtrl[m_nDeg-i]) ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1624,6 +1633,8 @@ CurveBezier::ModifyStart( const Point3d& ptNewStart)
|
||||
// modifico il primo punto di controllo
|
||||
m_vPtCtrl[0] = ptNewStart ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1641,6 +1652,8 @@ CurveBezier::ModifyEnd( const Point3d& ptNewEnd)
|
||||
// modifico l'ultimo punto di controllo
|
||||
m_vPtCtrl[m_nDeg] = ptNewEnd ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1665,6 +1678,8 @@ CurveBezier::TrimStartAtParam( double dUTrim)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1689,6 +1704,8 @@ CurveBezier::TrimEndAtParam( double dUTrim)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1755,7 +1772,7 @@ CurveBezier::ExtendStartByLen( double dLenExt)
|
||||
return false ;
|
||||
// determino la lunghezza originale della curva
|
||||
double dLen ;
|
||||
if ( ! GetLength( dLen))
|
||||
if ( ! GetLengthAtParam( 1, dLen))
|
||||
return false ;
|
||||
// stimo il valore del parametro al nuovo punto iniziale
|
||||
double dUTrim = - dLenExt / dLen ;
|
||||
@@ -1789,6 +1806,9 @@ CurveBezier::ExtendStartByLen( double dLenExt)
|
||||
m_vWeCtrl[i] = vWeCtrl[i] ;
|
||||
}
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
return true ;
|
||||
@@ -1803,7 +1823,7 @@ CurveBezier::ExtendEndByLen( double dLenExt)
|
||||
return false ;
|
||||
// determino la lunghezza originale della curva
|
||||
double dLen ;
|
||||
if ( ! GetLength( dLen))
|
||||
if ( ! GetLengthAtParam( 1, dLen))
|
||||
return false ;
|
||||
// stimo il valore del parametro al nuovo punto finale
|
||||
double dUTrim = 1 + dLenExt / dLen ;
|
||||
@@ -1837,6 +1857,9 @@ CurveBezier::ExtendEndByLen( double dLenExt)
|
||||
m_vWeCtrl[i] = vWeCtrl[i] ;
|
||||
}
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
return true ;
|
||||
@@ -1850,6 +1873,8 @@ CurveBezier::Translate( const Vector3d& vtMove)
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1872,6 +1897,8 @@ CurveBezier::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng,
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1914,6 +1941,8 @@ CurveBezier::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double
|
||||
if ( ! bOk)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1943,6 +1972,8 @@ CurveBezier::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
if ( vtNorm.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1967,6 +1998,8 @@ CurveBezier::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d&
|
||||
if ( vtNorm.IsSmall() || vtDir.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1999,6 +2032,8 @@ CurveBezier::ToGlob( const Frame3d& frRef)
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2026,6 +2061,8 @@ CurveBezier::ToLoc( const Frame3d& frRef)
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2053,6 +2090,8 @@ CurveBezier::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2064,3 +2103,42 @@ CurveBezier::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveBezier::CalcVoronoiObject() const
|
||||
{
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// creo oggetto vroni con la curva
|
||||
m_pVoronoiObj = new( std::nothrow) Voronoi( this, false) ;
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Voronoi*
|
||||
CurveBezier::GetVoronoiObject() const
|
||||
{
|
||||
if ( m_nStatus != OK)
|
||||
return nullptr ;
|
||||
|
||||
// se non è stato calcolato, lo calcolo
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
CalcVoronoiObject() ;
|
||||
|
||||
// restituisco Voronoi
|
||||
return m_pVoronoiObj ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
CurveBezier::ResetVoronoiObject() const
|
||||
{
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
delete m_pVoronoiObj ;
|
||||
m_pVoronoiObj = nullptr ;
|
||||
}
|
||||
|
||||
+24
-13
@@ -19,7 +19,8 @@
|
||||
#include "DllMain.h"
|
||||
#include "GeoObjRW.h"
|
||||
#include "/EgtDev/Include/EGkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EgtNumCollection.h"
|
||||
|
||||
class Voronoi ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
@@ -56,6 +57,11 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // ICurve
|
||||
bool IsSimple( void) const override { return true ; }
|
||||
@@ -149,7 +155,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
|
||||
public :
|
||||
CurveBezier( void) ;
|
||||
CurveBezier( const CurveBezier& cbSrc)
|
||||
CurveBezier( const CurveBezier& cbSrc) : m_pVoronoiObj( nullptr)
|
||||
{ if ( ! CopyFrom( cbSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "CurveBezier : copy constructor error")}
|
||||
CurveBezier& operator =( const CurveBezier& cbSrc)
|
||||
@@ -158,6 +164,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
return *this ; }
|
||||
bool ApproxWithLines( int nStep, PolyLine& PL) const ;
|
||||
bool GetApproxLength( double& dLen) const ;
|
||||
Voronoi* GetVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
bool CopyFrom( const CurveBezier& cbSrc) ;
|
||||
@@ -174,23 +181,27 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
bool ApproxWithArcsXY(double dLinTol, double dAngTolDeg, PolyArc& PA) const;
|
||||
bool BiArcOrSplit(int nLev, PolyLine& PL, double dLinTol, double dAngTolDeg, PolyArc& PA) const;
|
||||
bool ToPowerBase( PolynomialPoint3d& pol3P) const ;
|
||||
bool ToPowerBase( PolynomialPoint3d& pol3Num, Polynomial& polDen) const ;
|
||||
bool ToPowerBase( PolynomialPoint3d& pol3Num, Polynomial& polDen) const ;
|
||||
bool CalcVoronoiObject( void) const ;
|
||||
void ResetVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
||||
static const int MAXDEG = 11 ;
|
||||
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
int m_nDeg ; // grado
|
||||
bool m_bRat ; // flag di razionale/polinomiale
|
||||
mutable double m_dParSing ; // eventuale parametro della singolarità (-1=no, -2=da calcolare)
|
||||
PNTVECTOR m_vPtCtrl ; // vettore dei punti di controllo
|
||||
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
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
int m_nDeg ; // grado
|
||||
bool m_bRat ; // flag di razionale/polinomiale
|
||||
mutable double m_dParSing ; // eventuale parametro della singolarità (-1=no, -2=da calcolare)
|
||||
PNTVECTOR m_vPtCtrl ; // vettore dei punti di controllo
|
||||
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
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
mutable Voronoi* m_pVoronoiObj ; // Voronoi
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+5
-5
@@ -14,10 +14,10 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CalcDerivate.h"
|
||||
#include "CurveBezier.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkCurveByInterp.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkBiArcs.h"
|
||||
#include "/EgtDev/Include/EGkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ CurveByInterp::GetCurve( int nMethod, int nType)
|
||||
// se richiesti biarchi
|
||||
if ( nType == BIARCS) {
|
||||
// creo la curva composita
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo))
|
||||
return nullptr ;
|
||||
// ciclo sugli intervalli
|
||||
@@ -83,13 +83,13 @@ CurveByInterp::GetCurve( int nMethod, int nType)
|
||||
// se richieste curve di Bezier cubiche
|
||||
if ( nType == CUBIC_BEZIERS) {
|
||||
// creo la curva composita
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo))
|
||||
return nullptr ;
|
||||
// ciclo sugli intervalli
|
||||
for ( int i = 1 ; i < int( m_vPnt.size()) ; ++ i) {
|
||||
// creo una curva di Bezier cubica per ogni intervallo
|
||||
PtrOwner<ICurveBezier> pCBez( CreateCurveBezier()) ;
|
||||
PtrOwner<CurveBezier> pCBez( CreateBasicCurveBezier()) ;
|
||||
if ( IsNull( pCBez))
|
||||
return nullptr ;
|
||||
pCBez->Init( 3, false) ;
|
||||
|
||||
+213
-30
@@ -26,6 +26,7 @@
|
||||
#include "GeoObjFactory.h"
|
||||
#include "NgeWriter.h"
|
||||
#include "NgeReader.h"
|
||||
#include "Voronoi.h"
|
||||
#include "/EgtDev/Include/EGkCurveByApprox.h"
|
||||
#include "/EgtDev/Include/EGkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
@@ -37,15 +38,17 @@
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static const double EPS_CONNECT = 0.01 * EPS_SMALL ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
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{0,0}, m_dTempParam{0.0,0.0}, m_pVoronoiObj( nullptr), m_Iter( m_CrvSmplS.end())
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -69,8 +72,12 @@ CurveComposite::Clear( void)
|
||||
m_ptStart = ORIG ;
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
m_dTempParam[0] = 0.0 ;
|
||||
m_dTempParam[1] = 0.0 ;
|
||||
m_Iter = m_CrvSmplS.end() ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -114,6 +121,8 @@ CurveComposite::AddCurve( const ICurve& cCrv, bool bEndOrStart, double dLinTol)
|
||||
}
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -141,6 +150,8 @@ CurveComposite::AddCurve( ICurve* pCrv, bool bEndOrStart, double dLinTol)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -163,6 +174,8 @@ CurveComposite::AddCurveByRelocate( CurveComposite& ccSrc, bool bEndOrStart, dou
|
||||
return false ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -205,7 +218,7 @@ CurveComposite::AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart, double dLinT
|
||||
// verifico sia in continuità con il finale attuale
|
||||
Point3d ptEnd ;
|
||||
GetEndPoint( ptEnd) ;
|
||||
if ( ! AreSamePointEpsilon( ptCrvStart, ptEnd, 0.01 * EPS_SMALL)) {
|
||||
if ( ! AreSamePointEpsilon( ptCrvStart, ptEnd, EPS_CONNECT)) {
|
||||
// se in tolleranza, modifico l'inizio dell'entità
|
||||
if ( SqDist( ptCrvStart, ptEnd) < ( dLinTol * dLinTol)) {
|
||||
// lunghezza della curva originale
|
||||
@@ -227,11 +240,18 @@ CurveComposite::AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart, double dLinT
|
||||
// verifico sia in continuità con l'iniziale attuale
|
||||
Point3d ptStart ;
|
||||
GetStartPoint( ptStart) ;
|
||||
if ( ! AreSamePointEpsilon( ptCrvEnd, ptStart, 0.01 * EPS_SMALL)) {
|
||||
if ( ! AreSamePointEpsilon( ptCrvEnd, ptStart, EPS_CONNECT)) {
|
||||
// se in tolleranza, modifico la fine dell'entità
|
||||
if ( SqDist( ptCrvEnd, ptStart) < ( dLinTol * dLinTol)) {
|
||||
// lunghezza della curva originale
|
||||
double dOldLen ; pCrv->GetLength( dOldLen) ;
|
||||
// eseguo modifica
|
||||
if ( ! pCrv->ModifyEnd( ptStart))
|
||||
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 ;
|
||||
@@ -248,7 +268,10 @@ CurveComposite::AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart, double dLinT
|
||||
// aggiorno lo stato
|
||||
m_nStatus = OK ;
|
||||
|
||||
return true ;
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
|
||||
return TestClosure() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -264,7 +287,7 @@ CurveComposite::Close( void)
|
||||
! GetEndPoint( ptEnd))
|
||||
return false ;
|
||||
// se distanza inferiore al limite ridotto, non faccio alcunché
|
||||
if ( AreSamePointEpsilon( ptStart, ptEnd, EPS_SMALL / 10))
|
||||
if ( AreSamePointEpsilon( ptStart, ptEnd, EPS_CONNECT))
|
||||
return true ;
|
||||
// se molto vicini li modifico
|
||||
if ( AreSamePointEpsilon( ptStart, ptEnd, 10 * EPS_SMALL)) {
|
||||
@@ -280,6 +303,9 @@ CurveComposite::Close( void)
|
||||
! AddSimpleCurve( Release( pLine)))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -323,6 +349,8 @@ CurveComposite::FromSplit( const ICurve& cCrv, int nParts)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -348,7 +376,7 @@ CurveComposite::FromPolyLine( const PolyLine& PL)
|
||||
if ( AreSamePointApprox( ptIni, ptFin))
|
||||
continue ;
|
||||
// creo il segmento di retta
|
||||
PtrOwner<ICurveLine> pCrvLine( CreateCurveLine()) ;
|
||||
PtrOwner<CurveLine> pCrvLine( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pCrvLine))
|
||||
return false ;
|
||||
// assegno i punti estremi
|
||||
@@ -564,6 +592,8 @@ CurveComposite::CopyFrom( const CurveComposite& ccSrc)
|
||||
m_dThick = ccSrc.m_dThick ;
|
||||
m_nTempProp[0] = ccSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = ccSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = ccSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = ccSrc.m_dTempParam[1] ;
|
||||
for ( auto& pCrv : ccSrc.m_CrvSmplS) {
|
||||
if ( ! AddCurve( *pCrv))
|
||||
return false ;
|
||||
@@ -582,6 +612,8 @@ CurveComposite::RelocateFrom( CurveComposite& ccSrc)
|
||||
m_dThick = ccSrc.m_dThick ;
|
||||
m_nTempProp[0] = ccSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = ccSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = ccSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = ccSrc.m_dTempParam[1] ;
|
||||
for ( ICurve* pCrv = ccSrc.RemoveFirstOrLastCurve( false) ;
|
||||
pCrv != nullptr ;
|
||||
pCrv = ccSrc.RemoveFirstOrLastCurve( false)) {
|
||||
@@ -805,8 +837,7 @@ CurveComposite::Validate( void)
|
||||
Point3d ptStart ;
|
||||
// ciclo su tutte le curve
|
||||
int nCount = 0 ;
|
||||
PCSD_CONST_ITER Iter ;
|
||||
for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter) {
|
||||
for ( auto Iter = m_CrvSmplS.cbegin() ; Iter != m_CrvSmplS.cend() ; ++Iter) {
|
||||
// verifico validità della curva e sua semplicità
|
||||
if ( ! (*Iter)->IsValid() || (*Iter)->GetType() == CRV_COMPO) {
|
||||
m_nStatus = ERR ;
|
||||
@@ -829,9 +860,32 @@ CurveComposite::Validate( void)
|
||||
m_nStatus = ( nCount > 0 ? OK : TO_VERIFY) ;
|
||||
}
|
||||
|
||||
// verifico chiusura
|
||||
TestClosure() ;
|
||||
|
||||
return ( m_nStatus == OK) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::TestClosure( void)
|
||||
{
|
||||
// se non è chiusa, esco subito
|
||||
if ( ! IsClosed())
|
||||
return true ;
|
||||
// verifico ed eventualmente aggiusto coincidenza punti estremi
|
||||
Point3d ptStart ; m_CrvSmplS.front()->GetStartPoint( ptStart) ;
|
||||
Point3d ptEnd ; m_CrvSmplS.back()->GetEndPoint( ptEnd) ;
|
||||
// se distanza superiore al limite ridotto forzo i punti a coincidere
|
||||
if ( ! AreSamePointEpsilon( ptStart, ptEnd, EPS_CONNECT)) {
|
||||
Point3d ptM = Media( ptStart, ptEnd) ;
|
||||
if ( ! m_CrvSmplS.front()->ModifyStart( ptM) ||
|
||||
! m_CrvSmplS.back()->ModifyEnd( ptM))
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::IsFlat( Plane3d& plPlane, bool bUseExtrusion, double dToler) const
|
||||
@@ -1161,8 +1215,7 @@ CurveComposite::GetLength( double& dLen) const
|
||||
|
||||
// ciclo di calcolo
|
||||
dLen = 0 ;
|
||||
PCSD_CONST_ITER Iter ;
|
||||
for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter) {
|
||||
for ( auto Iter = m_CrvSmplS.cbegin() ; Iter != m_CrvSmplS.cend() ; ++Iter) {
|
||||
double dLenCrvSmpl ;
|
||||
if ( (*Iter)->GetLength( dLenCrvSmpl))
|
||||
dLen += dLenCrvSmpl ;
|
||||
@@ -1188,8 +1241,7 @@ CurveComposite::GetLengthAtParam( double dU, double& dLen) const
|
||||
// ciclo di calcolo
|
||||
dLen = 0 ;
|
||||
double dUToGo = dU ;
|
||||
PCSD_CONST_ITER Iter ;
|
||||
for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter) {
|
||||
for ( auto Iter = m_CrvSmplS.cbegin() ; Iter != m_CrvSmplS.cend() ; ++Iter) {
|
||||
// dominio parametrico della curva semplice
|
||||
double dParStart, dParEnd ;
|
||||
(*Iter)->GetDomain( dParStart, dParEnd) ;
|
||||
@@ -1237,8 +1289,7 @@ CurveComposite::GetParamAtLength( double dLen, double& dU) const
|
||||
// ciclo di calcolo
|
||||
dU = 0 ;
|
||||
double dLenToGo = dLen ;
|
||||
PCSD_CONST_ITER Iter ;
|
||||
for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter) {
|
||||
for ( auto Iter = m_CrvSmplS.cbegin() ; Iter != m_CrvSmplS.cend() ; ++Iter) {
|
||||
// lunghezza della curva semplice
|
||||
double dCrvLen ;
|
||||
if ( ! (*Iter)->GetLength( dCrvLen))
|
||||
@@ -1618,6 +1669,8 @@ CurveComposite::Invert( void)
|
||||
// inverto l'ordine della lista
|
||||
reverse( m_CrvSmplS.begin(), m_CrvSmplS.end()) ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1672,6 +1725,8 @@ CurveComposite::ModifyStart( const Point3d& ptNewStart)
|
||||
if ( ! pCrv->ModifyStart( ptNewStart))
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1693,6 +1748,8 @@ CurveComposite::ModifyEnd( const Point3d& ptNewEnd)
|
||||
if ( ! pCrv->ModifyEnd( ptNewEnd))
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1943,8 +2000,10 @@ CurveComposite::ModifyJoint( int nU, const Point3d& ptNewJoint)
|
||||
// elimino la curva originale
|
||||
delete( pNextCrv) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2006,6 +2065,8 @@ CurveComposite::RemoveJoint( int nU)
|
||||
m_CrvSmplS.erase( m_CrvSmplS.begin() + nNextCrv) ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2091,6 +2152,8 @@ CurveComposite::MoveCurve( int nCrv, const Vector3d& vtMove)
|
||||
// traslo la curva corrente
|
||||
pCrv->Translate( vtMove) ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2124,6 +2187,8 @@ CurveComposite::ModifyCurveToArc( int nCrv, const Point3d& ptMid)
|
||||
// elimino la curva originale
|
||||
delete( pCrv) ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2160,6 +2225,8 @@ CurveComposite::ModifyCurveToLine( int nCrv)
|
||||
// elimino la curva originale
|
||||
delete( pCrv) ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2175,6 +2242,8 @@ CurveComposite::TrimStartAtParam( double dUTrim)
|
||||
if ( dUTrim < -EPS_PARAM || dUTrim > dMaxU - EPS_PARAM)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2216,6 +2285,8 @@ CurveComposite::TrimEndAtParam( double dUTrim)
|
||||
if ( dUTrim < EPS_PARAM || dUTrim > dMaxU + EPS_PARAM)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2360,6 +2431,8 @@ CurveComposite::TrimStartAtLen( double dLenTrim)
|
||||
}
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2423,6 +2496,8 @@ CurveComposite::TrimEndAtLen( double dLenTrim)
|
||||
}
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2446,6 +2521,8 @@ CurveComposite::ExtendStartByLen( double dLenExt)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
return true ;
|
||||
@@ -2473,6 +2550,8 @@ CurveComposite::ExtendEndByLen( double dLenExt)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
return true ;
|
||||
@@ -2485,6 +2564,9 @@ CurveComposite::Translate( const Vector3d& vtMove)
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2506,6 +2588,8 @@ CurveComposite::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAn
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2547,6 +2631,8 @@ CurveComposite::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, dou
|
||||
abs( vtDelta.z * dCoeffZ) < EPS_SMALL)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2617,6 +2703,8 @@ CurveComposite::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
if ( vtNorm.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2641,6 +2729,8 @@ CurveComposite::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector
|
||||
if ( vtNorm.IsSmall() || vtDir.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2678,6 +2768,8 @@ CurveComposite::ToGlob( const Frame3d& frRef)
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2706,6 +2798,8 @@ CurveComposite::ToLoc( const Frame3d& frRef)
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2734,6 +2828,8 @@ CurveComposite::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2847,6 +2943,8 @@ CurveComposite::RemoveFirstOrLastCurve( bool bLast)
|
||||
// la curva composita deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return nullptr ;
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
|
||||
// recupero la curva semplice iniziale o finale e la tolgo dalla lista
|
||||
if ( ! m_CrvSmplS.empty()) {
|
||||
@@ -2937,6 +3035,8 @@ CurveComposite::ArcsToBezierCurves( void)
|
||||
}
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2983,6 +3083,8 @@ CurveComposite::ArcsBezierCurvesToArcsPerpExtr( double dLinTol, double dAngTolDe
|
||||
}
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -3016,6 +3118,8 @@ CurveComposite::StraightArcsToLines( double dLinTol, double dAngTolDeg)
|
||||
}
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -3026,6 +3130,14 @@ CurveComposite::StraightArcsToLines( double dLinTol, double dAngTolDeg)
|
||||
static int
|
||||
MergeTwoCurves( ICurve* pCrvP, ICurve* pCrvC, double& dCurrLinTol, double dCosAngTol, bool bNeedSameProp)
|
||||
{
|
||||
// verifico compatibilità delle proprietà
|
||||
int nTpr0P = pCrvP->GetTempProp( 0) ;
|
||||
int nTpr0C = pCrvC->GetTempProp( 0) ;
|
||||
int nTpr1P = pCrvP->GetTempProp( 1) ;
|
||||
int nTpr1C = pCrvC->GetTempProp( 1) ;
|
||||
if ( bNeedSameProp && ( nTpr0P != nTpr0C || nTpr1P != nTpr1C))
|
||||
return 0 ;
|
||||
|
||||
// se precedente molto corta
|
||||
double dLenP ;
|
||||
if ( pCrvP->GetLength( dLenP) && dLenP < dCurrLinTol) {
|
||||
@@ -3045,14 +3157,7 @@ MergeTwoCurves( ICurve* pCrvP, ICurve* pCrvC, double& dCurrLinTol, double dCosAn
|
||||
Point3d ptEnd ;
|
||||
return ( pCrvC->GetEndPoint( ptEnd) && pCrvP->ModifyEnd( ptEnd) ? 1 : 0) ;
|
||||
}
|
||||
}
|
||||
// verifico compatibilità delle proprietà
|
||||
int nTpr0P = pCrvP->GetTempProp( 0) ;
|
||||
int nTpr0C = pCrvC->GetTempProp( 0) ;
|
||||
int nTpr1P = pCrvP->GetTempProp( 1) ;
|
||||
int nTpr1C = pCrvC->GetTempProp( 1) ;
|
||||
if ( bNeedSameProp && ( nTpr0P != nTpr0C || nTpr1P != nTpr1C))
|
||||
return 0 ;
|
||||
}
|
||||
// coefficiente deduzione tolleranza
|
||||
const double COEFF_TOL = 0.7 ;
|
||||
// se entrambe rette
|
||||
@@ -3220,17 +3325,26 @@ CurveComposite::MergeCurves( double dLinTol, double dAngTolDeg, bool bStartEnd,
|
||||
}
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::RemoveSmallParts( double dLinTol, double dAngTolDeg)
|
||||
{
|
||||
return ( RemoveCurveSmallParts( this, dLinTol)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::RemoveSmallDefects( double dLinTol, double dAngTolDeg, bool bAlsoSpikes)
|
||||
{
|
||||
return (( ! bAlsoSpikes || RemoveCurveSpikes( this, dLinTol)) && RemoveCurveSmallZs(this, dLinTol)) ;
|
||||
return (( ! bAlsoSpikes || RemoveCurveSpikes( this, dLinTol)) && RemoveCurveSmallZs( this, dLinTol)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -3553,7 +3667,7 @@ CurveComposite::IsATrapezoid( double dLinTol, Point3d& ptP, Vector3d& vtB1, Vect
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::SetCurveTempProp( int nCrv, int nProp, int nPropNum)
|
||||
CurveComposite::SetCurveTempProp( int nCrv, int nProp, int nPropInd)
|
||||
{
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
@@ -3562,13 +3676,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, nPropInd) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::GetCurveTempProp( int nCrv, int& nProp, int nPropNum) const
|
||||
CurveComposite::GetCurveTempProp( int nCrv, int& nProp, int nPropInd) const
|
||||
{
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
@@ -3577,6 +3691,75 @@ 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( nPropInd) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::SetCurveTempParam( int nCrv, double dParam, int nParamInd)
|
||||
{
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico che l'indice sia nei limiti
|
||||
if ( nCrv < 0 || nCrv >= int( m_CrvSmplS.size()))
|
||||
return false ;
|
||||
// eseguo assegnazione
|
||||
m_CrvSmplS[nCrv]->SetTempParam( dParam, nParamInd) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::GetCurveTempParam( int nCrv, double& dParam, int nParamInd) const
|
||||
{
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico che l'indice sia nei limiti
|
||||
if ( nCrv < 0 || nCrv >= int( m_CrvSmplS.size()))
|
||||
return false ;
|
||||
// eseguo recupero
|
||||
dParam = m_CrvSmplS[nCrv]->GetTempParam( nParamInd) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::CalcVoronoiObject() const
|
||||
{
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// creo oggetto vroni con la curva
|
||||
m_pVoronoiObj = new( std::nothrow) Voronoi( this, false) ;
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Voronoi*
|
||||
CurveComposite::GetVoronoiObject() const
|
||||
{
|
||||
if ( m_nStatus != OK)
|
||||
return nullptr ;
|
||||
|
||||
// se non è stato calcolato, lo calcolo
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
CalcVoronoiObject() ;
|
||||
|
||||
// restituisco Voronoi
|
||||
return m_pVoronoiObj ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
CurveComposite::ResetVoronoiObject() const
|
||||
{
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
delete m_pVoronoiObj ;
|
||||
m_pVoronoiObj = nullptr ;
|
||||
}
|
||||
|
||||
+35
-15
@@ -21,6 +21,8 @@
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include <deque>
|
||||
|
||||
class Voronoi ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
{
|
||||
@@ -53,9 +55,14 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // ICurve
|
||||
bool IsSimple( void) const override
|
||||
@@ -158,6 +165,7 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
bool ArcsBezierCurvesToArcsPerpExtr( double dLinTol, double dAngTolDeg) override ;
|
||||
bool StraightArcsToLines( double dLinTol, double dAngTolDeg) override ;
|
||||
bool MergeCurves( double dLinTol, double dAngTolDeg, bool bStartEnd = true, bool bNeedSameProp = false) override ;
|
||||
bool RemoveSmallParts( double dLinTol, double dAngTolDeg) override ;
|
||||
bool RemoveSmallDefects( double dLinTol, double dAngTolDeg, bool bAlsoSpikes = false) override ;
|
||||
bool RemoveUndercutOnY( double dLinTol, double dAngTolDeg) override ;
|
||||
bool IsAPoint( void) const override ;
|
||||
@@ -165,9 +173,11 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
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, int nPropInd = 0) override ;
|
||||
bool GetCurveTempProp( int nCrv, int& nProp, int nPropInd = 0) const override ;
|
||||
bool SetCurveTempParam( int nCrv, double dParam, int nParamInd = 0) override ;
|
||||
bool GetCurveTempParam( int nCrv, double& dParam, int nParamInd = 0) const override ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
bool Save( NgeWriter& ngeOut) const override ;
|
||||
@@ -175,7 +185,7 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
|
||||
public :
|
||||
CurveComposite( void) ;
|
||||
CurveComposite( const CurveComposite& ccSrc)
|
||||
CurveComposite( const CurveComposite& ccSrc) : m_pVoronoiObj( nullptr)
|
||||
{ if ( ! CopyFrom( ccSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "CurveComposite : copy constructor error") }
|
||||
CurveComposite& operator =( const CurveComposite& ccSrc)
|
||||
@@ -184,33 +194,38 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
return *this ; }
|
||||
bool RelocateFrom( CurveComposite& ccSrc) ;
|
||||
bool GetApproxLength( double& dLen) const ;
|
||||
Voronoi* GetVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
bool CopyFrom( const CurveComposite& ccSrc) ;
|
||||
bool Validate( void) ;
|
||||
bool TestClosure( void) ;
|
||||
bool AddCurveByRelocate( CurveComposite& ccSrc, bool bEndOrStart = true, double dLinTol = EPS_SMALL) ;
|
||||
bool AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart = true, double dLinTol = EPS_SMALL) ;
|
||||
bool GetIndSCurveAndLocPar( double dU, Side nS, int& nSCrv, double& dLocU) const ;
|
||||
bool SimpleOffsetXY( double dDist, int nType = OFF_FILLET) ;
|
||||
bool IsOneCircle( Point3d& ptCen, Vector3d& vtN, double& dRad, bool& bCCW) const ;
|
||||
bool IsOneCircle( Point3d& ptCen, Vector3d& vtN, double& dRad, bool& bCCW) const ;
|
||||
bool CalcVoronoiObject( void) const ;
|
||||
void ResetVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
||||
|
||||
private :
|
||||
typedef std::deque<ICurve*> PCRVSMPL_DEQUE ;
|
||||
typedef PCRVSMPL_DEQUE::iterator PCSD_ITER ;
|
||||
typedef PCRVSMPL_DEQUE::const_iterator PCSD_CONST_ITER ;
|
||||
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
PCRVSMPL_DEQUE m_CrvSmplS ; // deque di curve semplici
|
||||
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
|
||||
mutable PCSD_CONST_ITER m_Iter ; // iteratore
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
PCRVSMPL_DEQUE m_CrvSmplS ; // deque di curve semplici
|
||||
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
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
mutable Voronoi* m_pVoronoiObj ; // Voronoi
|
||||
mutable PCSD_CONST_ITER m_Iter ; // iteratore
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -250,6 +265,11 @@ inline CurveComposite* ConvertCurveToBasicComposite( IGeoObj* pGObj)
|
||||
if ( nProp != 0)
|
||||
pCrvCo->SetTempProp( nProp, i) ;
|
||||
}
|
||||
for ( int i = 0 ; i < 2 ; ++ i) {
|
||||
double dParam = pCrv->GetTempParam( i) ;
|
||||
if ( abs( dParam) > EPS_SMALL)
|
||||
pCrvCo->SetTempParam( dParam, i) ;
|
||||
}
|
||||
pCrvCo->AddCurve( pCrv) ;
|
||||
return pCrvCo ;
|
||||
}
|
||||
|
||||
+83
-3
@@ -18,6 +18,7 @@
|
||||
#include "GeoObjFactory.h"
|
||||
#include "NgeWriter.h"
|
||||
#include "NgeReader.h"
|
||||
#include "Voronoi.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
@@ -30,15 +31,15 @@ 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{0,0}, m_dTempParam{0.0,0.0}, m_pVoronoiObj( nullptr)
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
CurveLine::~CurveLine( void)
|
||||
{
|
||||
ResetVoronoiObject() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -50,6 +51,8 @@ CurveLine::Set( const Point3d& ptStart, const Point3d& ptEnd)
|
||||
m_PtEnd = ptEnd ;
|
||||
m_nStatus = TO_VERIFY ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -69,6 +72,8 @@ CurveLine::SetPVL( const Point3d& ptStart, const Vector3d& vtDir, double dLen)
|
||||
m_PtEnd = ptStart + vtDelta ;
|
||||
m_nStatus = TO_VERIFY ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -86,6 +91,8 @@ CurveLine::SetPDL( const Point3d& ptStart, double dDirAngDeg, double dLen)
|
||||
m_PtEnd = ptStart + vtDelta ;
|
||||
m_nStatus = TO_VERIFY ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -128,6 +135,8 @@ CurveLine::CopyFrom( const CurveLine& clSrc)
|
||||
m_dThick = clSrc.m_dThick ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = clSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = clSrc.m_dTempParam[1] ;
|
||||
return Set( clSrc.m_PtStart, clSrc.m_PtEnd) ;
|
||||
}
|
||||
|
||||
@@ -558,6 +567,8 @@ CurveLine::Invert( void)
|
||||
// inverto i punti estremi
|
||||
swap( m_PtStart, m_PtEnd) ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -589,6 +600,8 @@ CurveLine::SimpleOffset( double dDist, int nType)
|
||||
m_PtStart += vtDir * dDist ;
|
||||
m_PtEnd += vtDir * dDist ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -609,6 +622,8 @@ CurveLine::ModifyStart( const Point3d& ptNewStart)
|
||||
// assegno il nuovo inizio
|
||||
m_PtStart = ptNewStart ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -629,6 +644,8 @@ CurveLine::ModifyEnd( const Point3d& ptNewEnd)
|
||||
// assegno la nuova fine
|
||||
m_PtEnd = ptNewEnd ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -704,6 +721,8 @@ CurveLine::TrimStartAtLen( double dLenTrim)
|
||||
if ( dLenTrim > EPS_ZERO)
|
||||
m_PtStart = Media( m_PtStart, m_PtEnd, ( dLenTrim / dLen)) ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -728,6 +747,8 @@ CurveLine::TrimEndAtLen( double dLenTrim)
|
||||
if ( ( dLen - dLenTrim) > EPS_ZERO)
|
||||
m_PtEnd = Media( m_PtStart, m_PtEnd, ( dLenTrim / dLen)) ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -750,6 +771,8 @@ CurveLine::ExtendStartByLen( double dLenExt)
|
||||
// sposto il punto iniziale
|
||||
m_PtStart -= vtDir * dLenExt ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -772,6 +795,8 @@ CurveLine::ExtendEndByLen( double dLenExt)
|
||||
// sposto il punto finale
|
||||
m_PtEnd += vtDir * dLenExt ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -786,6 +811,8 @@ CurveLine::Translate( const Vector3d& vtMove)
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -807,6 +834,8 @@ CurveLine::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, do
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -838,6 +867,8 @@ CurveLine::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double d
|
||||
if ( AreSamePointApprox( ptNewStart, ptNewEnd))
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -867,6 +898,8 @@ CurveLine::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
if ( vtNorm.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -890,6 +923,8 @@ CurveLine::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& v
|
||||
if ( vtNorm.IsSmall() || vtDir.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -922,6 +957,8 @@ CurveLine::ToGlob( const Frame3d& frRef)
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -944,6 +981,8 @@ CurveLine::ToLoc( const Frame3d& frRef)
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -966,6 +1005,8 @@ CurveLine::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1001,3 +1042,42 @@ CurveLine::CalcPointParamPosiz( const Point3d& ptP, bool bOnXY, double& dU, int&
|
||||
nPos = ICurve::PP_MID ; // nell'interno
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveLine::CalcVoronoiObject() const
|
||||
{
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// creo oggetto vroni con la curva
|
||||
m_pVoronoiObj = new( std::nothrow) Voronoi( this, false) ;
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Voronoi*
|
||||
CurveLine::GetVoronoiObject() const
|
||||
{
|
||||
if ( m_nStatus != OK)
|
||||
return nullptr ;
|
||||
|
||||
// se non è stato calcolato, lo calcolo
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
CalcVoronoiObject() ;
|
||||
|
||||
// restituisco Voronoi
|
||||
return m_pVoronoiObj ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
CurveLine::ResetVoronoiObject() const
|
||||
{
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
delete m_pVoronoiObj ;
|
||||
m_pVoronoiObj = nullptr ;
|
||||
}
|
||||
|
||||
+21
-9
@@ -19,6 +19,8 @@
|
||||
#include "GeoObjRW.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
|
||||
class Voronoi ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class CurveLine : public ICurveLine, public IGeoObjRW
|
||||
{
|
||||
@@ -54,6 +56,11 @@ class CurveLine : public ICurveLine, public IGeoObjRW
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // ICurve
|
||||
bool IsSimple( void) const override
|
||||
@@ -143,29 +150,34 @@ class CurveLine : public ICurveLine, public IGeoObjRW
|
||||
|
||||
public :
|
||||
CurveLine( void) ;
|
||||
CurveLine( const CurveLine& clSrc)
|
||||
CurveLine( const CurveLine& clSrc) : m_pVoronoiObj( nullptr)
|
||||
{ if ( ! CopyFrom( clSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "CurveLine : copy constructor error") }
|
||||
CurveLine& operator =( const CurveLine& clSrc)
|
||||
{ if ( ! CopyFrom( clSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "CurveLine : copy error")
|
||||
return *this ; }
|
||||
Voronoi* GetVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
bool CopyFrom( const CurveLine& clSrc) ;
|
||||
bool Validate( void) ;
|
||||
bool Validate( void) ;
|
||||
bool CalcVoronoiObject( void) const ;
|
||||
void ResetVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
||||
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
Point3d m_PtStart ; // punto iniziale
|
||||
Point3d m_PtEnd ; // punto finale
|
||||
Vector3d m_VtExtr ; // vettore estrusione
|
||||
double m_dThick ; // spessore
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
Point3d m_PtStart ; // punto iniziale
|
||||
Point3d m_PtEnd ; // punto finale
|
||||
Vector3d m_VtExtr ; // vettore estrusione
|
||||
double m_dThick ; // spessore
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
mutable Voronoi* m_pVoronoiObj ; // Voronoi
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+4
-4
@@ -59,7 +59,7 @@ DistLineLine::DistLineLine( const Point3d& ptSt1, const Vector3d& vtD1, double d
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistLineLine::GetSqDist( double& dSqDist)
|
||||
DistLineLine::GetSqDist( double& dSqDist) const
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
@@ -70,7 +70,7 @@ DistLineLine::GetSqDist( double& dSqDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistLineLine::GetDist( double& dDist)
|
||||
DistLineLine::GetDist( double& dDist) const
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
@@ -83,7 +83,7 @@ DistLineLine::GetDist( double& dDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistLineLine::GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2)
|
||||
DistLineLine::GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) const
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
@@ -94,7 +94,7 @@ DistLineLine::GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistLineLine::GetPositionsAtMinDistPoints( double& dPos1, double& dPos2)
|
||||
DistLineLine::GetPositionsAtMinDistPoints( double& dPos1, double& dPos2) const
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
|
||||
+11
-11
@@ -28,16 +28,16 @@ class DistLineLine
|
||||
bool bIsSegment1 = true, bool bIsSegment2 = true) ;
|
||||
|
||||
public :
|
||||
bool GetSqDist( double& dSqDist) ;
|
||||
bool GetDist( double& dDist) ;
|
||||
bool IsEpsilon( double dTol) {
|
||||
double dSqDist ;
|
||||
return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ;
|
||||
}
|
||||
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 GetSqDist( double& dSqDist) const ;
|
||||
bool GetDist( double& dDist) const ;
|
||||
bool IsEpsilon( double dTol) const
|
||||
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
|
||||
bool IsSmall( void) const
|
||||
{ return IsEpsilon( EPS_SMALL) ; }
|
||||
bool IsZero( void) const
|
||||
{ return IsEpsilon( EPS_ZERO) ; }
|
||||
bool GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) const ;
|
||||
bool GetPositionsAtMinDistPoints( double& dPos1, double& dPos2) const ;
|
||||
|
||||
private :
|
||||
void Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen1,
|
||||
@@ -45,7 +45,7 @@ class DistLineLine
|
||||
bool bIsSegment1, bool bIsSegment2) ;
|
||||
private:
|
||||
double m_dSqDist ;
|
||||
double m_dDist ;
|
||||
mutable double m_dDist ;
|
||||
double m_dPos1 ;
|
||||
double m_dPos2 ;
|
||||
Point3d m_ptMinDist1 ;
|
||||
|
||||
+5
-6
@@ -122,14 +122,13 @@ DistPointArc::DistPointHelix( const Point3d& ptP, const ICurveArc& arArc)
|
||||
|
||||
// cerco la minima distanza per la polilinea
|
||||
MDCVECTOR vApproxMin ;
|
||||
MDCVECTOR::iterator Iter ;
|
||||
if ( ! CalcMinDistPointPolyLine( ptP, PL, dLinTol, vApproxMin))
|
||||
return ;
|
||||
|
||||
// raffino i punti trovati
|
||||
double dPolishedPar ;
|
||||
Point3d ptPolishedQ ;
|
||||
for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
|
||||
for ( auto Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
|
||||
// eseguo raffinamento
|
||||
if ( PolishMinDistPointCurve( ptP, arArc, *Iter, dPolishedPar, ptPolishedQ)) {
|
||||
(*Iter).dDist = Dist( ptP, ptPolishedQ) ;
|
||||
@@ -148,7 +147,7 @@ DistPointArc::DistPointHelix( const Point3d& ptP, const ICurveArc& arArc)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointArc::GetSqDist( double& dSqDist)
|
||||
DistPointArc::GetSqDist( double& dSqDist) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -159,7 +158,7 @@ DistPointArc::GetSqDist( double& dSqDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointArc::GetDist( double& dDist)
|
||||
DistPointArc::GetDist( double& dDist) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -170,7 +169,7 @@ DistPointArc::GetDist( double& dDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointArc::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
|
||||
DistPointArc::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -185,7 +184,7 @@ DistPointArc::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointArc::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
|
||||
DistPointArc::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
|
||||
+9
-8
@@ -27,17 +27,18 @@ class DistPointArc
|
||||
DistPointArc( const Point3d& ptP, const ICurveArc& arArc) ;
|
||||
|
||||
public :
|
||||
bool GetSqDist( double& dSqDist) ;
|
||||
bool GetDist( double& dDist) ;
|
||||
bool IsEpsilon( double dTol)
|
||||
bool GetSqDist( double& dSqDist) const ;
|
||||
bool GetDist( double& dDist) const ;
|
||||
bool IsEpsilon( double dTol) const
|
||||
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
|
||||
bool IsSmall( void)
|
||||
bool IsSmall( void) const
|
||||
{ return IsEpsilon( EPS_SMALL) ; }
|
||||
bool IsZero( void)
|
||||
bool IsZero( void) const
|
||||
{ return IsEpsilon( EPS_ZERO) ; }
|
||||
int GetNbrMinDist( void) { return (int) m_Info.size() ; }
|
||||
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) ;
|
||||
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) ;
|
||||
int GetNbrMinDist( void) const
|
||||
{ return (int) m_Info.size() ; }
|
||||
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const ;
|
||||
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const ;
|
||||
|
||||
private :
|
||||
DistPointArc( void) ;
|
||||
|
||||
+1
-4
@@ -156,13 +156,10 @@ bool
|
||||
FilterMinDistPointCurve( const Point3d& ptP, const ICurve& cCurve,
|
||||
const MDCVECTOR& vApproxMin, double& dMinDist, MDPCIVECTOR& Info)
|
||||
{
|
||||
MDCVECTOR::const_iterator Iter ;
|
||||
|
||||
|
||||
// determino i minimi raffinati da tenere
|
||||
bool bFound = false ;
|
||||
bool bLastOnEnd = false ; // flag per ultimo punto su fine del suo intervallo
|
||||
for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
|
||||
for ( auto Iter = vApproxMin.cbegin() ; Iter != vApproxMin.cend() ; ++Iter) {
|
||||
// altro punto con la stessa minima distanza
|
||||
if ( bFound && abs( (*Iter).dDist - dMinDist) < EPS_SMALL) {
|
||||
// se abbastanza lontano e non su bordi intervallino lo aggiungo
|
||||
|
||||
@@ -44,7 +44,6 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier&
|
||||
|
||||
// cerco la minima distanza per la polilinea
|
||||
MDCVECTOR vApproxMin ;
|
||||
MDCVECTOR::iterator Iter ;
|
||||
if ( ! CalcMinDistPointPolyLine( ptP, PL, dLinTol, vApproxMin))
|
||||
return ;
|
||||
|
||||
@@ -52,7 +51,7 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier&
|
||||
double dSingP ;
|
||||
if ( CrvBez.GetSingularParam( dSingP) == 0)
|
||||
dSingP = - 1 ;
|
||||
for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
|
||||
for ( auto Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
|
||||
// imposto flag per singolarità agli estremi
|
||||
(*Iter).bParMinSing = abs( (*Iter).dParMin - dSingP) < EPS_SMALL ;
|
||||
(*Iter).bParMaxSing = abs( (*Iter).dParMax - dSingP) < EPS_SMALL ;
|
||||
@@ -61,7 +60,7 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier&
|
||||
// raffino i punti trovati
|
||||
double dPolishedPar ;
|
||||
Point3d ptPolishedQ ;
|
||||
for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
|
||||
for ( auto Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
|
||||
// eseguo raffinamento
|
||||
if ( PolishMinDistPointCurve( ptP, CrvBez, *Iter, dPolishedPar, ptPolishedQ)) {
|
||||
(*Iter).dDist = Dist( ptP, ptPolishedQ) ;
|
||||
@@ -80,7 +79,7 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier&
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvBezier::GetSqDist( double& dSqDist)
|
||||
DistPointCrvBezier::GetSqDist( double& dSqDist) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -91,7 +90,7 @@ DistPointCrvBezier::GetSqDist( double& dSqDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvBezier::GetDist( double& dDist)
|
||||
DistPointCrvBezier::GetDist( double& dDist) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -102,7 +101,7 @@ DistPointCrvBezier::GetDist( double& dDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvBezier::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
|
||||
DistPointCrvBezier::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -117,7 +116,7 @@ DistPointCrvBezier::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvBezier::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
|
||||
DistPointCrvBezier::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
|
||||
@@ -27,17 +27,18 @@ class DistPointCrvBezier
|
||||
DistPointCrvBezier( const Point3d& ptP, const ICurveBezier& CrvBez) ;
|
||||
|
||||
public :
|
||||
bool GetSqDist( double& dSqDist) ;
|
||||
bool GetDist( double& dDist) ;
|
||||
bool IsEpsilon( double dTol)
|
||||
bool GetSqDist( double& dSqDist) const ;
|
||||
bool GetDist( double& dDist) const ;
|
||||
bool IsEpsilon( double dTol) const
|
||||
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
|
||||
bool IsSmall( void)
|
||||
bool IsSmall( void) const
|
||||
{ return IsEpsilon( EPS_SMALL) ; }
|
||||
bool IsZero( void)
|
||||
bool IsZero( void) const
|
||||
{ return IsEpsilon( EPS_ZERO) ; }
|
||||
int GetNbrMinDist( void) { return (int) m_Info.size() ; }
|
||||
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) ;
|
||||
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) ;
|
||||
int GetNbrMinDist( void) const
|
||||
{ return (int) m_Info.size() ; }
|
||||
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const ;
|
||||
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const ;
|
||||
|
||||
private :
|
||||
DistPointCrvBezier( void) ;
|
||||
|
||||
@@ -129,7 +129,7 @@ DistPointCrvComposite::DistPointCrvComposite( const Point3d& ptP, const ICurveCo
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvComposite::GetSqDist( double& dSqDist)
|
||||
DistPointCrvComposite::GetSqDist( double& dSqDist) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -140,7 +140,7 @@ DistPointCrvComposite::GetSqDist( double& dSqDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvComposite::GetDist( double& dDist)
|
||||
DistPointCrvComposite::GetDist( double& dDist) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -151,7 +151,7 @@ DistPointCrvComposite::GetDist( double& dDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvComposite::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
|
||||
DistPointCrvComposite::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -166,7 +166,7 @@ DistPointCrvComposite::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvComposite::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
|
||||
DistPointCrvComposite::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
|
||||
@@ -26,17 +26,18 @@ class DistPointCrvComposite
|
||||
DistPointCrvComposite( const Point3d& ptP, const ICurveComposite& CrvCompo) ;
|
||||
|
||||
public :
|
||||
bool GetSqDist( double& dSqDist) ;
|
||||
bool GetDist( double& dDist) ;
|
||||
bool IsEpsilon( double dTol)
|
||||
bool GetSqDist( double& dSqDist) const ;
|
||||
bool GetDist( double& dDist) const ;
|
||||
bool IsEpsilon( double dTol) const
|
||||
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
|
||||
bool IsSmall( void)
|
||||
bool IsSmall( void) const
|
||||
{ return IsEpsilon( EPS_SMALL) ; }
|
||||
bool IsZero( void)
|
||||
bool IsZero( void) const
|
||||
{ return IsEpsilon( EPS_ZERO) ; }
|
||||
int GetNbrMinDist( void) { return (int) m_Info.size() ; }
|
||||
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) ;
|
||||
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) ;
|
||||
int GetNbrMinDist( void) const
|
||||
{ return (int) m_Info.size() ; }
|
||||
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const ;
|
||||
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const ;
|
||||
|
||||
private :
|
||||
DistPointCrvComposite( void) ;
|
||||
|
||||
+9
-9
@@ -98,7 +98,7 @@ DistPointCurve::CrvCompositeCalculate( const Point3d& ptP, const ICurve& Curve)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetSqDist( double& dSqDist)
|
||||
DistPointCurve::GetSqDist( double& dSqDist) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -109,7 +109,7 @@ DistPointCurve::GetSqDist( double& dSqDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetDist( double& dDist)
|
||||
DistPointCurve::GetDist( double& dDist) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -120,7 +120,7 @@ DistPointCurve::GetDist( double& dDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
|
||||
DistPointCurve::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
|
||||
return false ;
|
||||
@@ -132,7 +132,7 @@ DistPointCurve::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetMinDistPoint( double dNearParam, Point3d& ptMinDist, int& nFlag)
|
||||
DistPointCurve::GetMinDistPoint( double dNearParam, Point3d& ptMinDist, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0 || m_Info.empty())
|
||||
return false ;
|
||||
@@ -166,7 +166,7 @@ DistPointCurve::GetMinDistPoint( double dNearParam, Point3d& ptMinDist, int& nFl
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
|
||||
DistPointCurve::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
|
||||
return false ;
|
||||
@@ -178,7 +178,7 @@ DistPointCurve::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetParamAtMinDistPoint( double dNearParam, double& dParam, int& nFlag)
|
||||
DistPointCurve::GetParamAtMinDistPoint( double dNearParam, double& dParam, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0 || m_Info.empty())
|
||||
return false ;
|
||||
@@ -209,7 +209,7 @@ DistPointCurve::GetParamAtMinDistPoint( double dNearParam, double& dParam, int&
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide)
|
||||
DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide) const
|
||||
{
|
||||
if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
|
||||
return false ;
|
||||
@@ -257,7 +257,7 @@ DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, int& nSide)
|
||||
DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, int& nSide) const
|
||||
{
|
||||
if ( m_dDist < 0 || m_Info.empty())
|
||||
return false ;
|
||||
@@ -278,7 +278,7 @@ DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, i
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetMinDistInfo( int nInd, MinDistPCInfo& aInfo)
|
||||
DistPointCurve::GetMinDistInfo( int nInd, MinDistPCInfo& aInfo) const
|
||||
{
|
||||
if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
|
||||
return false ;
|
||||
|
||||
+4
-4
@@ -95,7 +95,7 @@ DistPointLine::Calculate( const Point3d& ptP,
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointLine::GetSqDist( double& dSqDist)
|
||||
DistPointLine::GetSqDist( double& dSqDist) const
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
@@ -106,7 +106,7 @@ DistPointLine::GetSqDist( double& dSqDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointLine::GetDist( double& dDist)
|
||||
DistPointLine::GetDist( double& dDist) const
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
@@ -119,7 +119,7 @@ DistPointLine::GetDist( double& dDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointLine::GetMinDistPoint( Point3d& ptMinDist)
|
||||
DistPointLine::GetMinDistPoint( Point3d& ptMinDist) const
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
@@ -130,7 +130,7 @@ DistPointLine::GetMinDistPoint( Point3d& ptMinDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointLine::GetParamAtMinDistPoint( double& dParam)
|
||||
DistPointLine::GetParamAtMinDistPoint( double& dParam) const
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
|
||||
+9
-9
@@ -31,18 +31,18 @@ class DistPointLine
|
||||
const Point3d& ptIni, const Vector3d& vtDir, double dLen, bool bIsSegment = true) ;
|
||||
|
||||
public :
|
||||
bool GetSqDist( double& dSqDist) ;
|
||||
bool GetDist( double& dDist) ;
|
||||
bool IsEpsilon( double dTol)
|
||||
bool GetSqDist( double& dSqDist) const ;
|
||||
bool GetDist( double& dDist) const ;
|
||||
bool IsEpsilon( double dTol) const
|
||||
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
|
||||
bool IsSmall( void)
|
||||
bool IsSmall( void) const
|
||||
{ return IsEpsilon( EPS_SMALL) ; }
|
||||
bool IsZero( void)
|
||||
bool IsZero( void) const
|
||||
{ return IsEpsilon( EPS_ZERO) ; }
|
||||
int GetNbrMinDist( void)
|
||||
int GetNbrMinDist( void) const
|
||||
{ return (( m_dSqDist < 0) ? 0 : 1) ; }
|
||||
bool GetMinDistPoint( Point3d& ptMinDist) ;
|
||||
bool GetParamAtMinDistPoint( double& dParam) ;
|
||||
bool GetMinDistPoint( Point3d& ptMinDist) const ;
|
||||
bool GetParamAtMinDistPoint( double& dParam) const ;
|
||||
|
||||
private :
|
||||
DistPointLine( void) ;
|
||||
@@ -51,7 +51,7 @@ class DistPointLine
|
||||
|
||||
private :
|
||||
double m_dSqDist ;
|
||||
double m_dDist ;
|
||||
mutable double m_dDist ;
|
||||
double m_dParam ;
|
||||
Point3d m_ptMinDist ;
|
||||
} ;
|
||||
|
||||
+3
-3
@@ -176,7 +176,7 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointSurfTm::GetDist( double& dDist)
|
||||
DistPointSurfTm::GetDist( double& dDist) const
|
||||
{
|
||||
// Distanza non valida
|
||||
if ( m_dDist < -EPS_ZERO)
|
||||
@@ -188,7 +188,7 @@ DistPointSurfTm::GetDist( double& dDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointSurfTm::GetMinDistPoint( Point3d& ptMinDistPoint)
|
||||
DistPointSurfTm::GetMinDistPoint( Point3d& ptMinDistPoint) const
|
||||
{
|
||||
// Distanza non valida
|
||||
if ( m_dDist < -EPS_ZERO)
|
||||
@@ -200,7 +200,7 @@ DistPointSurfTm::GetMinDistPoint( Point3d& ptMinDistPoint)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointSurfTm::GetMinDistTriaIndex( int& nMinDistIndex)
|
||||
DistPointSurfTm::GetMinDistTriaIndex( int& nMinDistIndex) const
|
||||
{
|
||||
// Distanza non valida
|
||||
if ( m_dDist < -EPS_ZERO)
|
||||
|
||||
Binary file not shown.
+13
-1
@@ -238,7 +238,7 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
@@ -280,6 +280,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="Attribs.cpp" />
|
||||
<ClCompile Include="BBox3d.cpp" />
|
||||
<ClCompile Include="BiArcs.cpp" />
|
||||
<ClCompile Include="CalcPocketing.cpp" />
|
||||
<ClCompile Include="CAvSimpleSurfFrMove.cpp" />
|
||||
<ClCompile Include="CAvToolSurfTm.cpp" />
|
||||
<ClCompile Include="CAvToolTriangle.cpp" />
|
||||
@@ -308,12 +309,16 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="CurveByApprox.cpp" />
|
||||
<ClCompile Include="CurveByInterp.cpp" />
|
||||
<ClCompile Include="CurveCompositeOffset.cpp" />
|
||||
<ClCompile Include="PolygonElevation.cpp" />
|
||||
<ClCompile Include="Voronoi.cpp" />
|
||||
<ClInclude Include="..\Include\EGkCDeClosedSurfTmClosedSurfTm.h" />
|
||||
<ClInclude Include="..\Include\EGkCDeConeFrustumClosedSurfTm.h" />
|
||||
<ClInclude Include="..\Include\EGkCDeConvexTorusClosedSurfTm.h" />
|
||||
<ClInclude Include="..\Include\EGkCDeRectPrismoidClosedSurfTm.h" />
|
||||
<ClInclude Include="..\Include\EGkIntersLineBox.h" />
|
||||
<ClInclude Include="..\Include\EGkIntersPlaneBox.h" />
|
||||
<ClInclude Include="..\Include\EGkPolygonElevation.h" />
|
||||
<ClInclude Include="..\Include\EGkSubtractProjectedFacesOnStmFace.h" />
|
||||
<ClInclude Include="CDeBoxTria.h" />
|
||||
<ClInclude Include="CDeCapsTria.h" />
|
||||
<ClInclude Include="CDeConeFrustumTria.h" />
|
||||
@@ -342,6 +347,8 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="IntersPlaneTria.cpp" />
|
||||
<ClCompile Include="IntersSurfTmSurfTm.cpp" />
|
||||
<ClCompile Include="IntersTriaTria.cpp" />
|
||||
<ClCompile Include="OffsetAux.cpp" />
|
||||
<ClCompile Include="Tree.cpp" />
|
||||
<ClCompile Include="MedialAxis.cpp" />
|
||||
<ClCompile Include="OffsetCurve.cpp" />
|
||||
<ClCompile Include="DistPointArc.cpp" />
|
||||
@@ -397,9 +404,11 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="OffsetCurveOnX.cpp" />
|
||||
<ClCompile Include="Polygon3d.cpp" />
|
||||
<ClCompile Include="AdjustLoops.cpp" />
|
||||
<ClCompile Include="ProjectCurveSurfTm.cpp" />
|
||||
<ClCompile Include="RemoveCurveDefects.cpp" />
|
||||
<ClCompile Include="SelfIntersCurve.cpp" />
|
||||
<ClCompile Include="SfrCreate.cpp" />
|
||||
<ClCompile Include="SubtractProjectedFacesOnStmFace.cpp" />
|
||||
<ClCompile Include="SurfAux.cpp" />
|
||||
<ClCompile Include="SurfBezier.cpp" />
|
||||
<ClCompile Include="SurfFlatRegion.cpp" />
|
||||
@@ -440,6 +449,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="VolZmapGraphics.cpp" />
|
||||
<ClCompile Include="VolZmapVolume.cpp" />
|
||||
<ClCompile Include="VolZmap.cpp" />
|
||||
<ClInclude Include="Voronoi.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Include\EGkAngle.h" />
|
||||
@@ -610,6 +620,8 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="IntersLineSurfStd.h" />
|
||||
<ClInclude Include="IntersLineTria.h" />
|
||||
<ClInclude Include="IterManager.h" />
|
||||
<ClInclude Include="OffsetAux.h" />
|
||||
<ClInclude Include="Tree.h" />
|
||||
<ClInclude Include="Material.h" />
|
||||
<ClInclude Include="FontNfe.h" />
|
||||
<ClInclude Include="MC_Tables.h" />
|
||||
|
||||
@@ -46,6 +46,12 @@
|
||||
<Filter Include="File di origine\GeoCollision">
|
||||
<UniqueIdentifier>{865b76ee-b10d-41fc-861c-b48ce52fa277}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="File di origine\GeoProject">
|
||||
<UniqueIdentifier>{d96752da-1884-4a73-ba1b-5b20b606e469}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="File di origine\GeoElevation">
|
||||
<UniqueIdentifier>{4c6a9dc5-8fac-4ecd-bde6-3e37e056712e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Vector3d.cpp">
|
||||
@@ -471,6 +477,9 @@
|
||||
<ClCompile Include="MedialAxis.cpp">
|
||||
<Filter>File di origine\GeoOffset</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Tree.cpp">
|
||||
<Filter>File di origine\Base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IntersLineCyl.cpp">
|
||||
<Filter>File di origine\GeoInters</Filter>
|
||||
</ClCompile>
|
||||
@@ -480,9 +489,27 @@
|
||||
<ClCompile Include="IntersLineCaps.cpp">
|
||||
<Filter>File di origine\GeoInters</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ProjectCurveSurfTm.cpp">
|
||||
<Filter>File di origine\GeoProject</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SubtractProjectedFacesOnStmFace.cpp">
|
||||
<Filter>File di origine\GeoProject</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SurfAux.cpp">
|
||||
<Filter>File di origine\Geo</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CalcPocketing.cpp">
|
||||
<Filter>File di origine\GeoOffset</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="OffsetAux.cpp">
|
||||
<Filter>File di origine\GeoOffset</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Voronoi.cpp">
|
||||
<Filter>File di origine\Base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PolygonElevation.cpp">
|
||||
<Filter>File di origine\GeoElevation</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h">
|
||||
@@ -1115,6 +1142,9 @@
|
||||
<ClInclude Include="CDeCapsTria.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Tree.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="IntersLineCyl.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
@@ -1127,6 +1157,18 @@
|
||||
<ClInclude Include="SurfAux.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="OffsetAux.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkPolygonElevation.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkSubtractProjectedFacesOnStmFace.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Voronoi.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtGeomKernel.rc">
|
||||
|
||||
+297
-288
@@ -2,7 +2,7 @@
|
||||
// EgalTech 2019-2019
|
||||
//----------------------------------------------------------------------------
|
||||
// File : ExtDimension.cpp Data : 27.12.19 Versione : 2.2a1
|
||||
// Contenuto : Implementazione della classe Dimension (quota).
|
||||
// Contenuto : Implementazione della classe Dimension ( quota).
|
||||
//
|
||||
//
|
||||
//
|
||||
@@ -50,10 +50,9 @@ GEOOBJ_REGISTER( EXT_DIMENSION, NGE_E_DIM, ExtDimension) ;
|
||||
//----------------------------------------------------------------------------
|
||||
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_bLenIsMM( true), m_nDecDigit( STD_DECDIGIT), m_sFont( STD_FONT), m_dTextHeight( STD_TEXTHEIGHT),
|
||||
m_nTempProp{0,0}, m_dTempParam{0.0,0.0}
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -64,7 +63,7 @@ ExtDimension::~ExtDimension( void)
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtDimension::SetStyle( double dExtLineLen, double dArrowLen, double dTextDist, bool bLenIsMM,
|
||||
int nDecDigit, const string& sFont, double dTextHeight)
|
||||
int nDecDigit, const string& sFont, double dTextHeight)
|
||||
{
|
||||
m_dExtLineLen = max( dExtLineLen, MIN_EXTLINELEN) ;
|
||||
m_dArrowLen = max( dArrowLen, MIN_ARROWLEN) ;
|
||||
@@ -94,7 +93,7 @@ ExtDimension::SetLinear( const Point3d& ptP1, const Point3d& ptP2, const Point3d
|
||||
// verifico che i punti di misura non siano coincidenti
|
||||
if ( AreSamePointApprox( m_ptP1, m_ptP2))
|
||||
return false ;
|
||||
// direzione di riferimento (nel piano perpendicolare a vtN)
|
||||
// direzione di riferimento ( nel piano perpendicolare a vtN)
|
||||
m_vtDir = vtDir ;
|
||||
if ( m_vtDir.IsSmall())
|
||||
m_vtDir = m_ptP2 - m_ptP1 ;
|
||||
@@ -138,7 +137,7 @@ ExtDimension::SetLinear( const Point3d& ptP1, const Point3d& ptP2, const Point3d
|
||||
bool
|
||||
ExtDimension::SetRadial( const Point3d& ptCen, const Point3d& ptPos,
|
||||
const Vector3d& vtN, const string& sText)
|
||||
{
|
||||
{ // il punto m_ptP6 viene utilizzato per il centro
|
||||
// dichiaro quota non ancora determinata
|
||||
m_nType = DT_NONE ;
|
||||
// verifico la definizione del versore normale e del versore X
|
||||
@@ -146,25 +145,20 @@ ExtDimension::SetRadial( const Point3d& ptCen, const Point3d& ptPos,
|
||||
m_vtDir = ptPos - ptCen ;
|
||||
if ( ! m_vtN.Normalize() || ! m_vtDir.Normalize())
|
||||
return false ;
|
||||
|
||||
// porto i punti nel piano definito da ptCen e vtN
|
||||
m_ptP6 = ptCen ;
|
||||
m_ptPos = ptPos - ( ptPos - m_ptP6) * m_vtN * m_vtN ;
|
||||
m_ptP1 = ptCen ;
|
||||
m_ptPos = ptPos - ( ptPos - m_ptP5) * m_vtN * m_vtN ;
|
||||
m_ptP3 = m_ptP1 ;
|
||||
m_ptP5 = m_ptP1 ;
|
||||
m_ptP2 = m_ptPos ;
|
||||
m_ptP4 = m_ptPos ;
|
||||
m_ptP6 = m_ptPos ;
|
||||
|
||||
// verifico che i punti di misura non siano coincidenti
|
||||
if ( AreSamePointApprox( m_ptP5, m_ptPos))
|
||||
if ( AreSamePointApprox( m_ptP6, m_ptPos))
|
||||
return false ;
|
||||
|
||||
// assegnazione del testo
|
||||
// assegnazione del testo
|
||||
m_sText = sText ;
|
||||
// assegno il tipo
|
||||
// assegno il tipo
|
||||
m_nType = DT_RADIAL ;
|
||||
// imposto da calcolare
|
||||
// imposto da calcolare
|
||||
m_bToCalc = true ;
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -175,7 +169,7 @@ ExtDimension::SetRadial( const Point3d& ptCen, const Point3d& ptPos,
|
||||
bool
|
||||
ExtDimension::SetDiametral( const Point3d& ptCen, const Point3d& ptPos,
|
||||
const Vector3d& vtN, const string& sText)
|
||||
{
|
||||
{ // il punto m_ptP6 viene utilizzato per il centro
|
||||
// dichiaro quota non ancora determinata
|
||||
m_nType = DT_NONE ;
|
||||
// verifico la definizione del versore normale e del versore X
|
||||
@@ -183,26 +177,21 @@ ExtDimension::SetDiametral( const Point3d& ptCen, const Point3d& ptPos,
|
||||
m_vtDir = ptPos - ptCen ;
|
||||
if ( ! m_vtN.Normalize() || ! m_vtDir.Normalize())
|
||||
return false ;
|
||||
|
||||
// porto i punti nel piano definito da ptP1 e vtN
|
||||
m_ptPos = ptPos - ( ptPos - ptCen) * m_vtN * m_vtN ;
|
||||
// porto i punti nel piano definito da ptP6 e vtN
|
||||
m_ptP6 = ptCen ;
|
||||
m_ptPos = ptPos - ( ptPos - m_ptP6) * m_vtN * m_vtN ;
|
||||
m_ptP2 = m_ptPos ;
|
||||
m_ptP6 = m_ptPos ;
|
||||
m_ptP4 = m_ptPos ;
|
||||
// ottengo il punto diametralmente opposto a ptPos
|
||||
m_ptP1 = ptCen - ( m_ptPos - ptCen) ;
|
||||
m_ptP5 = m_ptP1 ;
|
||||
m_ptP3 = m_ptP1 ;
|
||||
|
||||
// verifico che i punti di misura non siano coincidenti
|
||||
if ( AreSamePointApprox( m_ptP5, m_ptPos))
|
||||
return false ;
|
||||
|
||||
// assegnazione del testo
|
||||
// assegnazione del testo
|
||||
m_sText = sText ;
|
||||
// assegno il tipo
|
||||
// assegno il tipo
|
||||
m_nType = DT_DIAMETRAL ;
|
||||
// imposto da calcolare
|
||||
// imposto da calcolare
|
||||
m_bToCalc = true ;
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -211,7 +200,7 @@ ExtDimension::SetDiametral( const Point3d& ptCen, const Point3d& ptPos,
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtDimension::SetAngular( const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptV, const Point3d& ptPos,
|
||||
ExtDimension::SetAngular( const Point3d& ptP1, const Point3d& ptV, const Point3d& ptP2, const Point3d& ptPos,
|
||||
const Vector3d& vtN, const string& sText)
|
||||
{
|
||||
// dichiaro quota non ancora determinata
|
||||
@@ -223,32 +212,25 @@ ExtDimension::SetAngular( const Point3d& ptP1, const Point3d& ptP2, const Point3
|
||||
// porto i punti nel piano definito da P1 e N
|
||||
m_ptP1 = ptP1 ;
|
||||
m_ptP2 = ptP2 - ( ptP2 - m_ptP1) * m_vtN * m_vtN ;
|
||||
m_ptP5 = ptV - ( ptV - m_ptP1) * m_vtN * m_vtN ;
|
||||
m_ptP6 = ptV - ( ptV - m_ptP1) * m_vtN * m_vtN ;
|
||||
m_ptPos = ptPos - ( ptPos - m_ptP1) * m_vtN * m_vtN ;
|
||||
// verifico che i punti di misura non siano coincidenti
|
||||
if ( AreSamePointApprox( m_ptP1, m_ptP2) || AreSamePointApprox( m_ptP1, m_ptP5) || AreSamePointApprox( m_ptP2, m_ptP5))
|
||||
if ( AreSamePointApprox( m_ptP1, m_ptP2) || AreSamePointApprox( m_ptP1, m_ptP6) || AreSamePointApprox( m_ptP2, m_ptP5))
|
||||
return false ;
|
||||
// calcolo le direzioni su cui giacciono i due lati dell'angolo
|
||||
Vector3d vtLine1 = m_ptP1 - m_ptP5 ;
|
||||
Vector3d vtLine2 = m_ptP2 - m_ptP5 ;
|
||||
double dLen1 = vtLine1.Len() ;
|
||||
double dLen2 = vtLine2.Len() ;
|
||||
if ( ! vtLine1.Normalize() || ! vtLine2.Normalize())
|
||||
return false ;
|
||||
// direzione di riferimento (nel piano perpendicolare a vtN)
|
||||
m_vtDir = m_ptPos - m_ptP5 ;
|
||||
// direzione di riferimento ( nel piano perpendicolare a vtN)
|
||||
m_vtDir = m_ptPos - m_ptP6 ;
|
||||
double dLenDir = m_vtDir.Len() ;
|
||||
|
||||
|
||||
// controllo se è testo o se è la misura
|
||||
double dHalfDist ;
|
||||
double dFactor ;
|
||||
if ( m_sCalcText.find( IS_MEASURE) != string::npos) {
|
||||
dHalfDist = GetTextHalfDist( m_ptPos) ;
|
||||
m_sCalcText = "300.00" ;
|
||||
double dHalfDist = GetTextHalfDist( m_ptPos) ;
|
||||
dFactor = 2.5 * dHalfDist ;
|
||||
m_sCalcText = "" ;
|
||||
}
|
||||
else {
|
||||
dHalfDist = GetTextHalfDist( m_ptPos) ;
|
||||
double dHalfDist = GetTextHalfDist( m_ptPos) ;
|
||||
dFactor = 2.5 * dHalfDist ;
|
||||
}
|
||||
// allungo m_vtDir se è troppo vicino al centro
|
||||
@@ -256,24 +238,26 @@ ExtDimension::SetAngular( const Point3d& ptP1, const Point3d& ptP2, const Point3
|
||||
Vector3d vtDir_n = m_vtDir ;
|
||||
if ( ! vtDir_n.Normalize())
|
||||
return false ;
|
||||
m_ptPos = m_ptP5 + dFactor * vtDir_n ;
|
||||
m_ptPos = m_ptP6 + dFactor * vtDir_n ;
|
||||
// ricalcolo m_vtDir
|
||||
m_vtDir = m_ptPos - m_ptP5 ;
|
||||
m_vtDir = m_ptPos - m_ptP6 ;
|
||||
dLenDir = m_vtDir.Len() ;
|
||||
}
|
||||
|
||||
// calcolo le direzioni su cui giacciono i due lati dell'angolo
|
||||
Vector3d vtLine1 = m_ptP1 - m_ptP6 ;
|
||||
Vector3d vtLine2 = m_ptP2 - m_ptP6 ;
|
||||
double dLen1 = vtLine1.Len() ;
|
||||
double dLen2 = vtLine2.Len() ;
|
||||
if ( ! vtLine1.Normalize() || ! vtLine2.Normalize())
|
||||
return false ;
|
||||
// segnalo se i punti che definiscono i lati sono più lontani dal centro di ptPos
|
||||
bool bPt1Close = false ;
|
||||
bool bPt2Close = false ;
|
||||
if ( dLenDir < dLen1)
|
||||
bPt1Close = true ;
|
||||
if ( dLenDir < dLen2)
|
||||
bPt2Close = true ;
|
||||
bool bPt1Close = ( dLenDir < dLen1 ? true : false) ;
|
||||
bool bPt2Close = ( dLenDir < dLen2 ? true : false) ;
|
||||
m_ptP5 = m_ptP1 + ( dLenDir - dLen1) * vtLine1 ;
|
||||
m_ptP6 = m_ptP2 + ( dLenDir - dLen2) * vtLine2 ;
|
||||
Point3d ptP5_bis = m_ptP2 + ( dLenDir - dLen2) * vtLine2 ;
|
||||
m_ptP3 = m_ptP5 + ( bPt1Close ? - vtLine1 : vtLine1) * m_dExtLineLen ;
|
||||
m_ptP4 = m_ptP6 + ( bPt2Close ? - vtLine2 : vtLine2) * m_dExtLineLen ;
|
||||
|
||||
m_ptP4 = ptP5_bis + ( bPt2Close ? - vtLine2 : vtLine2) * m_dExtLineLen ;
|
||||
|
||||
// assegnazione del testo
|
||||
m_sText = sText ;
|
||||
// assegno il tipo
|
||||
@@ -333,6 +317,7 @@ ExtDimension::CopyFrom( const ExtDimension& clSrc)
|
||||
m_sCalcText = clSrc.m_sCalcText ;
|
||||
m_ptCalcPos = clSrc.m_ptCalcPos ;
|
||||
m_bCalcArrowIn = clSrc.m_bCalcArrowIn ;
|
||||
m_bCalcTextOn = clSrc.m_bCalcTextOn ;
|
||||
m_ptCalcP7 = clSrc.m_ptCalcP7 ;
|
||||
m_ptCalcP8 = clSrc.m_ptCalcP8 ;
|
||||
m_dExtLineLen = clSrc.m_dExtLineLen ;
|
||||
@@ -344,6 +329,8 @@ ExtDimension::CopyFrom( const ExtDimension& clSrc)
|
||||
m_dTextHeight = clSrc.m_dTextHeight ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = clSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = clSrc.m_dTempParam[1] ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -379,15 +366,15 @@ ExtDimension::Dump( string& sOut, bool bMM, const char* szNewLine) const
|
||||
{
|
||||
// parametri
|
||||
sOut += GetSubType() + szNewLine ;
|
||||
sOut += "VN(" + ToString( m_vtN, 3) + ") " + szNewLine ;
|
||||
sOut += "VD(" + ToString( m_vtDir, 3) + ") " + szNewLine ;
|
||||
sOut += "P1(" + ToString( GetInUiUnits( m_ptP1, bMM), 3) + ") " + szNewLine ;
|
||||
sOut += "P2(" + ToString( GetInUiUnits( m_ptP2, bMM), 3) + ") " + szNewLine ;
|
||||
sOut += "P3(" + ToString( GetInUiUnits( m_ptP3, bMM), 3) + ") " + szNewLine ;
|
||||
sOut += "P4(" + ToString( GetInUiUnits( m_ptP4, bMM), 3) + ") " + szNewLine ;
|
||||
sOut += "P5(" + ToString( GetInUiUnits( m_ptP5, bMM), 3) + ") " + szNewLine ;
|
||||
sOut += "P6(" + ToString( GetInUiUnits( m_ptP6, bMM), 3) + ") " + szNewLine ;
|
||||
sOut += "Pos(" + ToString( GetInUiUnits( m_ptPos, bMM), 3) + ") " + szNewLine ;
|
||||
sOut += "VN( " + ToString( m_vtN, 3) + ") " + szNewLine ;
|
||||
sOut += "VD( " + ToString( m_vtDir, 3) + ") " + szNewLine ;
|
||||
sOut += "P1( " + ToString( GetInUiUnits( m_ptP1, bMM), 3) + ") " + szNewLine ;
|
||||
sOut += "P2( " + ToString( GetInUiUnits( m_ptP2, bMM), 3) + ") " + szNewLine ;
|
||||
sOut += "P3( " + ToString( GetInUiUnits( m_ptP3, bMM), 3) + ") " + szNewLine ;
|
||||
sOut += "P4( " + ToString( GetInUiUnits( m_ptP4, bMM), 3) + ") " + szNewLine ;
|
||||
sOut += "P5( " + ToString( GetInUiUnits( m_ptP5, bMM), 3) + ") " + szNewLine ;
|
||||
sOut += "P6( " + ToString( GetInUiUnits( m_ptP6, bMM), 3) + ") " + szNewLine ;
|
||||
sOut += "Pos( " + ToString( GetInUiUnits( m_ptPos, bMM), 3) + ") " + szNewLine ;
|
||||
sOut += "Txt=" + m_sText + szNewLine ;
|
||||
sOut += "El=" + ToString( GetInUiUnits( m_dExtLineLen, bMM), 3) +
|
||||
" Al=" + ToString( GetInUiUnits( m_dArrowLen, bMM), 3) +
|
||||
@@ -528,7 +515,7 @@ ExtDimension::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
|
||||
return true ;
|
||||
}
|
||||
else if ( m_nType == DT_RADIAL) {
|
||||
b3Loc.Set( m_ptP5) ;
|
||||
b3Loc.Set( m_ptP6) ;
|
||||
b3Loc.Add( m_ptPos) ;
|
||||
// ingombro del testo
|
||||
BBox3d b3Text ;
|
||||
@@ -537,7 +524,7 @@ ExtDimension::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
|
||||
return true ;
|
||||
}
|
||||
else if ( m_nType == DT_DIAMETRAL) {
|
||||
b3Loc.Set( m_ptP5) ;
|
||||
b3Loc.Set( m_ptP6) ;
|
||||
b3Loc.Add( m_ptPos) ;
|
||||
// ingombro del testo
|
||||
BBox3d b3Text ;
|
||||
@@ -551,6 +538,7 @@ ExtDimension::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
|
||||
b3Loc.Add( m_ptP3) ;
|
||||
b3Loc.Add( m_ptP4) ;
|
||||
b3Loc.Set( m_ptP5) ;
|
||||
b3Loc.Set( m_ptP6) ;
|
||||
b3Loc.Add( m_ptCalcP7) ;
|
||||
b3Loc.Add( m_ptCalcP8) ;
|
||||
// ingombro del testo
|
||||
@@ -574,7 +562,7 @@ ExtDimension::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
||||
Update() ;
|
||||
// se valido
|
||||
if ( m_nType == DT_LINEAR) {
|
||||
// ingombro dei punti (portati nel riferimento passato)
|
||||
// ingombro dei punti ( portati nel riferimento passato)
|
||||
Point3d ptFrP1 = m_ptP1 ;
|
||||
ptFrP1.ToGlob( frRef) ;
|
||||
b3Ref.Set( ptFrP1) ;
|
||||
@@ -600,8 +588,8 @@ ExtDimension::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
||||
return true ;
|
||||
}
|
||||
else if ( m_nType == DT_RADIAL) {
|
||||
// ingombro dei punti (portati nel riferimento passato)
|
||||
Point3d ptFrP5 = m_ptP5 ;
|
||||
// ingombro dei punti ( portati nel riferimento passato)
|
||||
Point3d ptFrP5 = m_ptP6 ;
|
||||
ptFrP5.ToGlob( frRef) ;
|
||||
b3Ref.Set( ptFrP5) ;
|
||||
Point3d ptFrPos = m_ptPos ;
|
||||
@@ -614,8 +602,8 @@ ExtDimension::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
||||
return true ;
|
||||
}
|
||||
else if ( m_nType == DT_DIAMETRAL) {
|
||||
// ingombro dei punti (portati nel riferimento passato)
|
||||
Point3d ptFrP5 = m_ptP5 ;
|
||||
// ingombro dei punti ( portati nel riferimento passato)
|
||||
Point3d ptFrP5 = m_ptP6 ;
|
||||
ptFrP5.ToGlob( frRef) ;
|
||||
b3Ref.Set( ptFrP5) ;
|
||||
Point3d ptFrPos = m_ptPos ;
|
||||
@@ -628,9 +616,6 @@ ExtDimension::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
||||
return true ;
|
||||
}
|
||||
else if ( m_nType == DT_ANGULAR) {
|
||||
Point3d ptFrP5 = m_ptP5 ;
|
||||
ptFrP5.ToGlob( frRef) ;
|
||||
b3Ref.Set( ptFrP5) ;
|
||||
Point3d ptFrP1 = m_ptP1 ;
|
||||
ptFrP1.ToGlob( frRef) ;
|
||||
b3Ref.Add( ptFrP1) ;
|
||||
@@ -643,6 +628,12 @@ ExtDimension::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
||||
Point3d ptFrP4 = m_ptP4 ;
|
||||
ptFrP4.ToGlob( frRef) ;
|
||||
b3Ref.Add( ptFrP4) ;
|
||||
Point3d ptFrP5 = m_ptP5 ;
|
||||
ptFrP5.ToGlob( frRef) ;
|
||||
b3Ref.Set( ptFrP5) ;
|
||||
Point3d ptFrP6 = m_ptP6 ;
|
||||
ptFrP6.ToGlob( frRef) ;
|
||||
b3Ref.Set( ptFrP6) ;
|
||||
Point3d ptFrP7 = m_ptCalcP7 ;
|
||||
ptFrP7.ToGlob( frRef) ;
|
||||
b3Ref.Add( ptFrP7) ;
|
||||
@@ -697,14 +688,14 @@ ExtDimension::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng,
|
||||
// se valido
|
||||
if ( m_nType >= DT_LINEAR && m_nType <= DT_ANGULAR) {
|
||||
return ( m_vtN.Rotate( vtAx, dCosAng, dSinAng) &&
|
||||
m_vtDir.Rotate( vtAx, dCosAng, dSinAng) &&
|
||||
m_ptP1.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
|
||||
m_ptP2.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
|
||||
m_ptP3.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
|
||||
m_ptP4.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
|
||||
m_ptP5.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
|
||||
m_ptP6.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
|
||||
m_ptPos.Rotate( ptAx, vtAx, dCosAng, dSinAng)) ;
|
||||
m_vtDir.Rotate( vtAx, dCosAng, dSinAng) &&
|
||||
m_ptP1.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
|
||||
m_ptP2.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
|
||||
m_ptP3.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
|
||||
m_ptP4.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
|
||||
m_ptP5.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
|
||||
m_ptP6.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
|
||||
m_ptPos.Rotate( ptAx, vtAx, dCosAng, dSinAng)) ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
@@ -738,6 +729,8 @@ ExtDimension::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, doubl
|
||||
return false ;
|
||||
if ( ! m_ptP2.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ))
|
||||
return false ;
|
||||
if ( ! m_ptP6.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ))
|
||||
return false ;
|
||||
if ( ! m_ptPos.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ))
|
||||
return false ;
|
||||
// ricalcolo completamente la quota
|
||||
@@ -745,11 +738,11 @@ ExtDimension::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, doubl
|
||||
case DT_LINEAR :
|
||||
return SetLinear( m_ptP1, m_ptP2, m_ptPos, m_vtN, m_vtDir, m_sText) ;
|
||||
case DT_RADIAL :
|
||||
return SetRadial( m_ptP5, m_ptPos, m_vtN, m_sText) ;
|
||||
return SetRadial( m_ptP6, m_ptPos, m_vtN, m_sText) ;
|
||||
case DT_DIAMETRAL :
|
||||
return SetDiametral( m_ptP5, m_ptPos, m_vtN, m_sText) ;
|
||||
return SetDiametral( m_ptP6, m_ptPos, m_vtN, m_sText) ;
|
||||
case DT_ANGULAR :
|
||||
return SetAngular( m_ptP5, m_ptP1, m_ptP2, m_ptPos, m_vtN, m_sText) ;
|
||||
return SetAngular( m_ptP1, m_ptP6, m_ptP2, m_ptPos, m_vtN, m_sText) ;
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
@@ -772,12 +765,12 @@ ExtDimension::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
|
||||
// se valido
|
||||
if ( m_nType >= DT_LINEAR && m_nType <= DT_ANGULAR) {
|
||||
// eseguo il mirror dei versori
|
||||
// eseguo il mirror dei versori
|
||||
if ( ! m_vtN.Mirror( vtNorm))
|
||||
return false ;
|
||||
if ( ! m_vtDir.Mirror( vtNorm))
|
||||
return false ;
|
||||
// eseguo il mirror dei punti
|
||||
// eseguo il mirror dei punti
|
||||
if ( ! m_ptP1.Mirror( ptOn, vtNorm))
|
||||
return false ;
|
||||
if ( ! m_ptP2.Mirror( ptOn, vtNorm))
|
||||
@@ -826,6 +819,8 @@ ExtDimension::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d
|
||||
return false ;
|
||||
if ( ! m_ptP2.Shear( ptOn, vtNorm, vtDir, dCoeff))
|
||||
return false ;
|
||||
if ( ! m_ptP6.Shear( ptOn, vtNorm, vtDir, dCoeff))
|
||||
return false ;
|
||||
if ( ! m_ptPos.Shear( ptOn, vtNorm, vtDir, dCoeff))
|
||||
return false ;
|
||||
// ricalcolo completamente la quota
|
||||
@@ -833,11 +828,11 @@ ExtDimension::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d
|
||||
case DT_LINEAR :
|
||||
return SetLinear( m_ptP1, m_ptP2, m_ptPos, m_vtN, m_vtDir, m_sText) ;
|
||||
case DT_RADIAL :
|
||||
return SetRadial( m_ptP5, m_ptPos, m_vtN, m_sText) ;
|
||||
return SetRadial( m_ptP6, m_ptPos, m_vtN, m_sText) ;
|
||||
case DT_DIAMETRAL :
|
||||
return SetDiametral( m_ptP5, m_ptPos, m_vtN, m_sText) ;
|
||||
return SetDiametral( m_ptP6, m_ptPos, m_vtN, m_sText) ;
|
||||
case DT_ANGULAR :
|
||||
return SetAngular( m_ptP5, m_ptP1, m_ptP2, m_ptPos, m_vtN, m_sText) ;
|
||||
return SetAngular( m_ptP1, m_ptP6, m_ptP2, m_ptPos, m_vtN, m_sText) ;
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
@@ -864,16 +859,16 @@ ExtDimension::ToGlob( const Frame3d& frRef)
|
||||
|
||||
// se valido
|
||||
if ( m_nType >= DT_LINEAR && m_nType <= DT_ANGULAR) {
|
||||
// trasformo punto e versori
|
||||
// trasformo punto e versori
|
||||
return ( m_vtN.ToGlob( frRef) &&
|
||||
m_vtDir.ToGlob( frRef) &&
|
||||
m_ptP1.ToGlob( frRef) &&
|
||||
m_ptP2.ToGlob( frRef) &&
|
||||
m_ptP3.ToGlob( frRef) &&
|
||||
m_ptP4.ToGlob( frRef) &&
|
||||
m_ptP5.ToGlob( frRef) &&
|
||||
m_ptP6.ToGlob( frRef) &&
|
||||
m_ptPos.ToGlob( frRef)) ;
|
||||
m_vtDir.ToGlob( frRef) &&
|
||||
m_ptP1.ToGlob( frRef) &&
|
||||
m_ptP2.ToGlob( frRef) &&
|
||||
m_ptP3.ToGlob( frRef) &&
|
||||
m_ptP4.ToGlob( frRef) &&
|
||||
m_ptP5.ToGlob( frRef) &&
|
||||
m_ptP6.ToGlob( frRef) &&
|
||||
m_ptPos.ToGlob( frRef)) ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
@@ -897,16 +892,16 @@ ExtDimension::ToLoc( const Frame3d& frRef)
|
||||
|
||||
// se valido
|
||||
if ( m_nType >= DT_LINEAR && m_nType <= DT_ANGULAR) {
|
||||
// trasformo punto e versori
|
||||
// trasformo punto e versori
|
||||
return ( m_vtN.ToLoc( frRef) &&
|
||||
m_vtDir.ToLoc( frRef) &&
|
||||
m_ptP1.ToLoc( frRef) &&
|
||||
m_ptP2.ToLoc( frRef) &&
|
||||
m_ptP3.ToLoc( frRef) &&
|
||||
m_ptP4.ToLoc( frRef) &&
|
||||
m_ptP5.ToLoc( frRef) &&
|
||||
m_ptP6.ToLoc( frRef) &&
|
||||
m_ptPos.ToLoc( frRef)) ;
|
||||
m_vtDir.ToLoc( frRef) &&
|
||||
m_ptP1.ToLoc( frRef) &&
|
||||
m_ptP2.ToLoc( frRef) &&
|
||||
m_ptP3.ToLoc( frRef) &&
|
||||
m_ptP4.ToLoc( frRef) &&
|
||||
m_ptP5.ToLoc( frRef) &&
|
||||
m_ptP6.ToLoc( frRef) &&
|
||||
m_ptPos.ToLoc( frRef)) ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
@@ -932,14 +927,14 @@ ExtDimension::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
if ( m_nType >= DT_LINEAR && m_nType <= DT_ANGULAR) {
|
||||
// trasformo punto e versori
|
||||
return ( m_vtN.ToGlob( frOri) && m_vtN.ToLoc( frDest) &&
|
||||
m_vtDir.ToGlob( frOri) && m_vtDir.ToLoc( frDest) &&
|
||||
m_ptP1.ToGlob( frOri) && m_ptP1.ToLoc( frDest) &&
|
||||
m_ptP2.ToGlob( frOri) && m_ptP2.ToLoc( frDest) &&
|
||||
m_ptP3.ToGlob( frOri) && m_ptP3.ToLoc( frDest) &&
|
||||
m_ptP4.ToGlob( frOri) && m_ptP4.ToLoc( frDest) &&
|
||||
m_ptP5.ToGlob( frOri) && m_ptP5.ToLoc( frDest) &&
|
||||
m_ptP6.ToGlob( frOri) && m_ptP6.ToLoc( frDest) &&
|
||||
m_ptPos.ToGlob( frOri) && m_ptPos.ToLoc( frDest)) ;
|
||||
m_vtDir.ToGlob( frOri) && m_vtDir.ToLoc( frDest) &&
|
||||
m_ptP1.ToGlob( frOri) && m_ptP1.ToLoc( frDest) &&
|
||||
m_ptP2.ToGlob( frOri) && m_ptP2.ToLoc( frDest) &&
|
||||
m_ptP3.ToGlob( frOri) && m_ptP3.ToLoc( frDest) &&
|
||||
m_ptP4.ToGlob( frOri) && m_ptP4.ToLoc( frDest) &&
|
||||
m_ptP5.ToGlob( frOri) && m_ptP5.ToLoc( frDest) &&
|
||||
m_ptP6.ToGlob( frOri) && m_ptP6.ToLoc( frDest) &&
|
||||
m_ptPos.ToGlob( frOri) && m_ptPos.ToLoc( frDest)) ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
@@ -992,7 +987,7 @@ ExtDimension::Update( void) const
|
||||
else
|
||||
m_ptCalcPos = m_ptCalcP8 + m_vtDir * dHalfDist ;
|
||||
}
|
||||
// dichiaro ricalcolo eseguito
|
||||
// dichiaro ricalcolo eseguito
|
||||
m_bToCalc = false ;
|
||||
return true ;
|
||||
}
|
||||
@@ -1011,21 +1006,27 @@ ExtDimension::Update( void) const
|
||||
ReplaceString( m_sCalcText, IS_MEASURE, sVal) ;
|
||||
}
|
||||
// punto di inserimento del testo
|
||||
m_ptCalcPos = ( m_ptP5 + m_ptP6) / 2 ;
|
||||
m_ptCalcPos = ( m_ptP5 + m_ptP2) / 2 ;
|
||||
// alzo il testo dalla linea di misura
|
||||
BBox3d b3Text ;
|
||||
if ( ! GetTextMyBBox( b3Text) && ! b3Text.IsEmpty())
|
||||
return false ;
|
||||
double dHeight = b3Text.GetMax().y - b3Text.GetMin().y ;
|
||||
Vector3d vtPerpDir = m_ptPos - m_ptP5 ;
|
||||
vtPerpDir.Normalize() ;
|
||||
if ( ! vtPerpDir.Rotate( m_vtN, 90))
|
||||
Vector3d vtPerpDir = m_ptPos - m_ptP6 ;
|
||||
if ( ! vtPerpDir.Normalize())
|
||||
return false ;
|
||||
// calcolo il frame dell'arco per valutare la posizione del testo
|
||||
Frame3d frRef ;
|
||||
if ( ! frRef.Set( m_ptP6, m_vtN))
|
||||
return false ;
|
||||
double dAngDeg = 0 ;
|
||||
if ( ! m_vtDir.GetAngle( frRef.VersX(), dAngDeg) || ! vtPerpDir.Rotate( m_vtN, ( dAngDeg < 90 ? 90 : -90)))
|
||||
return false ;
|
||||
m_ptCalcPos = m_ptCalcPos + 0.6 * dHeight * vtPerpDir ;
|
||||
// semidistanza di interruzione
|
||||
double dHalfDist = GetTextHalfDist( m_ptCalcPos) ;
|
||||
// lunghezza della linea di misura
|
||||
double dLen = ( m_ptP6 - m_ptP5).Len() ;
|
||||
double dLen = Dist( m_ptP1, m_ptP2) ;
|
||||
// determino come orientare le frecce e dove mettere il testo
|
||||
if ( dLen - 2 * m_dArrowLen >= 2 * dHalfDist) {
|
||||
m_bCalcArrowIn = true ;
|
||||
@@ -1038,7 +1039,7 @@ ExtDimension::Update( void) const
|
||||
m_bCalcArrowIn = false ;
|
||||
m_bCalcTextOn = true ;
|
||||
m_ptCalcP7 = m_ptP5 - m_vtDir * 2 * m_dArrowLen ;
|
||||
m_ptCalcP8 = m_ptP6 + m_vtDir * 2 * m_dArrowLen ;
|
||||
m_ptCalcP8 = m_ptP2 + m_vtDir * 2 * m_dArrowLen ;
|
||||
}
|
||||
// stanno fuori sia le frecce sia il testo
|
||||
else {
|
||||
@@ -1046,7 +1047,8 @@ ExtDimension::Update( void) const
|
||||
m_bCalcTextOn = false ;
|
||||
// metto la quotatura dal lato di ptPos
|
||||
Vector3d vtRad = m_ptPos - m_ptP5 ;
|
||||
vtRad.Normalize() ;
|
||||
if ( ! vtRad.Normalize())
|
||||
return false ;
|
||||
m_ptCalcPos = m_ptPos + vtRad * ( dHalfDist + 2 * m_dArrowLen) ;
|
||||
}
|
||||
// dichiaro ricalcolo eseguito
|
||||
@@ -1056,9 +1058,11 @@ ExtDimension::Update( void) const
|
||||
case DT_ANGULAR : {
|
||||
// angolo
|
||||
double dAngDeg, dAngDeg1, dAngDeg2 = 0 ;
|
||||
Vector3d vtLine1 = m_ptP1 - m_ptP5 ;
|
||||
Vector3d vtLine2 = m_ptP2 - m_ptP5 ;
|
||||
Vector3d vtLine3 = m_ptPos - m_ptP5 ;
|
||||
Vector3d vtLine1 = m_ptP1 - m_ptP6 ;
|
||||
Vector3d vtLine2 = m_ptP2 - m_ptP6 ;
|
||||
Vector3d vtLine3 = m_ptPos - m_ptP6 ;
|
||||
// calcolo gli angoli tra m_ptPos e i due punti che identificano i lati dell'angolo
|
||||
// per capire se sto calcolando l'angolo interno o esterno
|
||||
if ( ! vtLine1.GetAngle( vtLine2, dAngDeg) || ! vtLine1.GetAngle( vtLine3, dAngDeg1) || ! vtLine2.GetAngle( vtLine3, dAngDeg2))
|
||||
return false ;
|
||||
if ( dAngDeg < dAngDeg1 + dAngDeg2 - EPS_SMALL || dAngDeg > dAngDeg1 + dAngDeg2 + EPS_SMALL)
|
||||
@@ -1066,14 +1070,17 @@ ExtDimension::Update( void) const
|
||||
// testo
|
||||
m_sCalcText = m_sText ;
|
||||
if ( m_sCalcText.find( IS_MEASURE) != string::npos) {
|
||||
// calcolo gli angoli tra m_ptPos e i due punti che identificano i lati dell'angolo
|
||||
// per capire se sto calcolando l'angolo interno o esterno
|
||||
string sAngDeg = ToString( dAngDeg, m_nDecDigit) ;
|
||||
ReplaceString( m_sCalcText, IS_MEASURE, sAngDeg + "°") ;
|
||||
}
|
||||
// calcolo ptP5_bis
|
||||
double dLen2 = vtLine2.Len() ;
|
||||
if ( ! vtLine2.Normalize())
|
||||
return false ;
|
||||
Point3d ptP5_bis = m_ptP2 + ( m_vtDir.Len() - dLen2) * vtLine2 ;
|
||||
// calcolo l'arco su cui metterò la misura
|
||||
PtrOwner<CurveArc> pCrvPos( CreateBasicCurveArc()) ;
|
||||
if ( IsNull( pCrvPos) || ! pCrvPos->Set3P( m_ptP6, m_ptPos, m_ptP5, false))
|
||||
if ( IsNull( pCrvPos) || ! pCrvPos->Set3P( ptP5_bis, m_ptPos, m_ptP5, false))
|
||||
return false ;
|
||||
// punto di inserimento del testo
|
||||
pCrvPos->GetMidPoint( m_ptCalcPos) ;
|
||||
@@ -1084,15 +1091,14 @@ ExtDimension::Update( void) const
|
||||
if ( ! pCrvPos->GetLength( dLen))
|
||||
return false ;
|
||||
// calcolo anche lo spazio ad una distanza dal centro maggiorata
|
||||
double dLenPos = 0 ;
|
||||
double dDist = Dist( m_ptCalcPos, m_ptP5) ;
|
||||
dLenPos = dDist * dAngDeg * DEGTORAD ;
|
||||
// determino come orientare le frecce e dove mettere il testo
|
||||
double dU ;
|
||||
double dDist = Dist( m_ptCalcPos, m_ptP6) ;
|
||||
double dLenPos = dDist * dAngDeg * DEGTORAD ;
|
||||
// determino come orientare le frecce e dove mettere il testo
|
||||
// frecce e testo dentro
|
||||
if ( dLen - 2 * m_dArrowLen >= 2 * dHalfDist) {
|
||||
m_bCalcArrowIn = true ;
|
||||
m_bCalcTextOn = true ;
|
||||
double dU ;
|
||||
pCrvPos->GetParamAtLength( dLen / 2. + dHalfDist, dU) ;
|
||||
pCrvPos->GetPointD1D2( dU, ICurve::FROM_MINUS, m_ptCalcP7) ;
|
||||
pCrvPos->GetParamAtLength( dLen / 2. - dHalfDist, dU) ;
|
||||
@@ -1103,12 +1109,11 @@ ExtDimension::Update( void) const
|
||||
else if ( dLen > 2 * dHalfDist || ( dLen < 2 * dHalfDist && dLenPos > 2 * dHalfDist)) {
|
||||
m_bCalcArrowIn = false ;
|
||||
m_bCalcTextOn = true ;
|
||||
double dU ;
|
||||
pCrvPos->GetParamAtLength( dLen / 2. + dHalfDist, dU) ;
|
||||
pCrvPos->GetPointD1D2( dU, ICurve::FROM_MINUS, m_ptCalcP7) ;
|
||||
pCrvPos->GetParamAtLength( dLen / 2. - dHalfDist, dU) ;
|
||||
pCrvPos->GetPointD1D2( dU, ICurve::FROM_MINUS, m_ptCalcP8) ;
|
||||
//pCrvPosExt->GetStartPoint( m_ptCalcP8) ;
|
||||
//pCrvPosExt->GetEndPoint( m_ptCalcP7) ;
|
||||
if ( dLen < 2 * dHalfDist) {
|
||||
m_ptCalcPos += ( m_ptCalcPos - m_ptP5) ;
|
||||
m_bCalcTextOn = false ;
|
||||
@@ -1118,11 +1123,9 @@ ExtDimension::Update( void) const
|
||||
else {
|
||||
m_bCalcArrowIn = false ;
|
||||
m_bCalcTextOn = false ;
|
||||
//pCrvPosExt->GetStartPoint( m_ptCalcP8) ;
|
||||
//pCrvPosExt->GetEndPoint( m_ptCalcP7) ;
|
||||
vtLine1.Normalize() ;
|
||||
vtLine2.Normalize() ;
|
||||
if ( Dist( m_ptPos, m_ptP5) < Dist( m_ptPos, m_ptP6)) {
|
||||
if ( Dist( m_ptPos, m_ptP5) < Dist( m_ptPos, ptP5_bis)) {
|
||||
Vector3d vtDirEnd ;
|
||||
pCrvPos->GetEndDir( vtDirEnd) ;
|
||||
m_ptCalcPos = m_ptP5 + dHalfDist * ( vtDirEnd + vtLine1) ;
|
||||
@@ -1130,7 +1133,7 @@ ExtDimension::Update( void) const
|
||||
else {
|
||||
Vector3d vtDirStart ;
|
||||
pCrvPos->GetStartDir( vtDirStart) ;
|
||||
m_ptCalcPos = m_ptP6 + dHalfDist * ( - vtDirStart + vtLine2) ;
|
||||
m_ptCalcPos = ptP5_bis + dHalfDist * ( - vtDirStart + vtLine2) ;
|
||||
}
|
||||
}
|
||||
// dichiaro ricalcolo eseguito
|
||||
@@ -1155,12 +1158,18 @@ ExtDimension::GetMidPoint( Point3d& ptMid) const
|
||||
ptMid = ( m_ptP1 + m_ptP2) / 2;
|
||||
return true ;
|
||||
case DT_ANGULAR :
|
||||
{ PtrOwner<CurveArc> pCrvPos( CreateBasicCurveArc()) ;
|
||||
if ( ! pCrvPos->Set3P( m_ptP6, m_ptPos, m_ptP5, false))
|
||||
return false ;
|
||||
pCrvPos->GetMidPoint( ptMid) ;
|
||||
return true ;
|
||||
}
|
||||
{ // calcolo ptP5_bis
|
||||
Vector3d vtLine2 = m_ptP2 - m_ptP6 ;
|
||||
double dLen2 = vtLine2.Len() ;
|
||||
if ( ! vtLine2.Normalize())
|
||||
return false ;
|
||||
Point3d ptP5_bis = m_ptP2 + ( m_vtDir.Len() - dLen2) * vtLine2 ;
|
||||
Vector3d vtMid = ( ptP5_bis + m_ptP5) / 2 - m_ptP6 ;
|
||||
if ( ! vtMid.Normalize())
|
||||
return false ;
|
||||
ptMid = m_ptP6 + vtMid * m_vtDir.Len() ;
|
||||
return true;
|
||||
}
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
@@ -1180,7 +1189,7 @@ ExtDimension::GetCenterPoint( Point3d& ptCen) const
|
||||
case DT_RADIAL :
|
||||
case DT_DIAMETRAL :
|
||||
case DT_ANGULAR :
|
||||
ptCen = m_ptP5 ;
|
||||
ptCen = m_ptP6 ;
|
||||
return true ;
|
||||
default :
|
||||
return false ;
|
||||
@@ -1195,153 +1204,154 @@ ExtDimension::ApproxWithLines( double dLinTol, double dAngTolDeg, POLYLINELIST&
|
||||
Update() ;
|
||||
// se quota valida
|
||||
switch ( m_nType) {
|
||||
case DT_LINEAR : {
|
||||
// prima linea di riferimento
|
||||
case DT_LINEAR : {
|
||||
// prima linea di riferimento
|
||||
lstPL.emplace_back() ;
|
||||
lstPL.back().AddUPoint( 0, m_ptP1) ;
|
||||
lstPL.back().AddUPoint( 1, m_ptP3) ;
|
||||
// seconda linea di riferimento
|
||||
lstPL.emplace_back() ;
|
||||
lstPL.back().AddUPoint( 0, m_ptP2) ;
|
||||
lstPL.back().AddUPoint( 1, m_ptP4) ;
|
||||
// se non c'è testo, linea di misura intera
|
||||
if ( IsEmptyOrSpaces( m_sCalcText)) {
|
||||
lstPL.emplace_back() ;
|
||||
lstPL.back().AddUPoint(0, m_ptP1) ;
|
||||
lstPL.back().AddUPoint(1, m_ptP3) ;
|
||||
// seconda linea di riferimento
|
||||
lstPL.emplace_back() ;
|
||||
lstPL.back().AddUPoint(0, m_ptP2) ;
|
||||
lstPL.back().AddUPoint(1, m_ptP4) ;
|
||||
// se non c'è testo, linea di misura intera
|
||||
if ( IsEmptyOrSpaces(m_sCalcText)) {
|
||||
lstPL.emplace_back() ;
|
||||
lstPL.back().AddUPoint(0, m_ptP5) ;
|
||||
lstPL.back().AddUPoint(1, m_ptP6) ;
|
||||
}
|
||||
// altrimenti, linea di misura divisa in due parti
|
||||
else {
|
||||
// prima parte
|
||||
lstPL.emplace_back() ;
|
||||
lstPL.back().AddUPoint(0, m_ptP5) ;
|
||||
lstPL.back().AddUPoint(1, m_ptCalcP7) ;
|
||||
// seconda parte
|
||||
lstPL.emplace_back() ;
|
||||
lstPL.back().AddUPoint(0, m_ptP6) ;
|
||||
lstPL.back().AddUPoint(1, m_ptCalcP8) ;
|
||||
}
|
||||
// frecce
|
||||
lstPL.emplace_back() ;
|
||||
GetArrowHead(m_ptP5, ( m_bCalcArrowIn ? -m_vtDir : m_vtDir), lstPL.back()) ;
|
||||
lstPL.emplace_back() ;
|
||||
GetArrowHead(m_ptP6, ( m_bCalcArrowIn ? m_vtDir : -m_vtDir), lstPL.back()) ;
|
||||
// testo
|
||||
POLYLINELIST lstTxt;
|
||||
if ( ApproxTextWithLines(dLinTol, dAngTolDeg, lstTxt))
|
||||
lstPL.splice(lstPL.end(), lstTxt) ;
|
||||
return true ;
|
||||
lstPL.back().AddUPoint( 0, m_ptP5) ;
|
||||
lstPL.back().AddUPoint( 1, m_ptP6) ;
|
||||
}
|
||||
case DT_RADIAL :
|
||||
case DT_DIAMETRAL : {
|
||||
Vector3d vtRad = m_ptPos - m_ptP5 ;
|
||||
vtRad.Normalize() ;
|
||||
// prima linea di riferimento
|
||||
// altrimenti, linea di misura divisa in due parti
|
||||
else {
|
||||
// prima parte
|
||||
lstPL.emplace_back() ;
|
||||
lstPL.back().AddUPoint(0, m_ptP1) ;
|
||||
lstPL.back().AddUPoint(1, m_ptP2) ;
|
||||
// freccia
|
||||
lstPL.back().AddUPoint( 0, m_ptP5) ;
|
||||
lstPL.back().AddUPoint( 1, m_ptCalcP7) ;
|
||||
// seconda parte
|
||||
lstPL.emplace_back() ;
|
||||
GetArrowHead(m_ptP6, ( m_bCalcArrowIn ? vtRad : - vtRad), lstPL.back()) ;
|
||||
Point3d ptArrowTail ;
|
||||
if ( ! m_bCalcArrowIn) {
|
||||
lstPL.emplace_back() ;
|
||||
ptArrowTail = m_ptP6 + vtRad * m_dArrowLen * 2 ;
|
||||
lstPL.back().AddUPoint(0, m_ptP6) ;
|
||||
lstPL.back().AddUPoint(1, ptArrowTail) ;
|
||||
}
|
||||
if ( m_nType == DT_DIAMETRAL) {
|
||||
lstPL.emplace_back() ;
|
||||
GetArrowHead(m_ptP5, ( m_bCalcArrowIn ? - vtRad : vtRad), lstPL.back()) ;
|
||||
if ( ! m_bCalcArrowIn) {
|
||||
lstPL.emplace_back() ;
|
||||
ptArrowTail = m_ptP5 - vtRad * m_dArrowLen * 2 ;
|
||||
lstPL.back().AddUPoint(0, m_ptP5) ;
|
||||
lstPL.back().AddUPoint(1, ptArrowTail) ;
|
||||
}
|
||||
}
|
||||
// testo
|
||||
POLYLINELIST lstTxt;
|
||||
if ( ApproxTextWithLines(dLinTol, dAngTolDeg, lstTxt))
|
||||
lstPL.splice(lstPL.end(), lstTxt) ;
|
||||
return true ;
|
||||
lstPL.back().AddUPoint( 0, m_ptP6) ;
|
||||
lstPL.back().AddUPoint( 1, m_ptCalcP8) ;
|
||||
}
|
||||
case DT_ANGULAR : {
|
||||
// approssimerò l'arco con una polyline
|
||||
PolyLine plApprox ;
|
||||
// cerca nel geom kernel delle tolleranze standard
|
||||
double dLinTol = 0.01 ;
|
||||
double dAngTolDeg = 0.01 ;
|
||||
// prima linea di riferimento
|
||||
lstPL.emplace_back() ;
|
||||
lstPL.back().AddUPoint( 0, m_ptP1) ;
|
||||
lstPL.back().AddUPoint( 1, m_ptP3) ;
|
||||
// seconda linea di riferimento
|
||||
// frecce
|
||||
lstPL.emplace_back() ;
|
||||
GetArrowHead( m_ptP5, ( m_bCalcArrowIn ? -m_vtDir : m_vtDir), lstPL.back()) ;
|
||||
lstPL.emplace_back() ;
|
||||
GetArrowHead( m_ptP6, ( m_bCalcArrowIn ? m_vtDir : -m_vtDir), lstPL.back()) ;
|
||||
// testo
|
||||
POLYLINELIST lstTxt;
|
||||
if ( ApproxTextWithLines( dLinTol, dAngTolDeg, lstTxt))
|
||||
lstPL.splice( lstPL.end(), lstTxt) ;
|
||||
return true ;
|
||||
}
|
||||
case DT_RADIAL :
|
||||
case DT_DIAMETRAL : {
|
||||
// prima linea di riferimento
|
||||
lstPL.emplace_back() ;
|
||||
lstPL.back().AddUPoint( 0, m_ptP1) ;
|
||||
lstPL.back().AddUPoint( 1, m_ptP2) ;
|
||||
// freccia
|
||||
lstPL.emplace_back() ;
|
||||
Vector3d vtRad = m_ptPos - m_ptP6 ;
|
||||
vtRad.Normalize() ;
|
||||
GetArrowHead( m_ptP2, ( m_bCalcArrowIn ? vtRad : - vtRad), lstPL.back()) ;
|
||||
if ( ! m_bCalcArrowIn) {
|
||||
lstPL.emplace_back() ;
|
||||
Point3d ptArrowTail = m_ptP2 + vtRad * m_dArrowLen * 2 ;
|
||||
lstPL.back().AddUPoint( 0, m_ptP2) ;
|
||||
lstPL.back().AddUPoint( 1, m_ptP4) ;
|
||||
// curva per l'arco
|
||||
PtrOwner<CurveArc> pCrvPos( CreateBasicCurveArc()) ;
|
||||
if ( IsNull( pCrvPos))
|
||||
return false ;
|
||||
double dHalfDist = GetTextHalfDist( m_ptCalcPos) ;
|
||||
|
||||
// se non ho testo
|
||||
if ( IsEmptyOrSpaces( m_sCalcText)) {
|
||||
if ( ! pCrvPos->SetC2PN( m_ptP5, m_ptP6, m_ptP5, m_vtN) || ! pCrvPos->ApproxWithLines(dLinTol, dAngTolDeg, ICurve::APL_STD, plApprox))
|
||||
return false ;
|
||||
lstPL.emplace_back( plApprox) ;
|
||||
}
|
||||
// altrimenti, linea di misura divisa in due parti
|
||||
else {
|
||||
// prima parte
|
||||
if ( ! pCrvPos->SetC2PN( m_ptP5, m_ptP5, m_ptCalcP7, m_vtN) || ! pCrvPos->ApproxWithLines(dLinTol, dAngTolDeg, ICurve::APL_STD, plApprox))
|
||||
return false ;
|
||||
lstPL.emplace_back( plApprox) ;
|
||||
// seconda parte
|
||||
if ( ! pCrvPos->SetC2PN( m_ptP5, m_ptP6, m_ptCalcP8, m_vtN) || ! pCrvPos->ApproxWithLines(dLinTol, dAngTolDeg, ICurve::APL_STD, plApprox))
|
||||
return false ;
|
||||
lstPL.emplace_back( plApprox) ;
|
||||
}
|
||||
// frecce
|
||||
Vector3d vtStartDir ;
|
||||
Vector3d vtEndDir ;
|
||||
if ( ! pCrvPos->Set3P( m_ptP6, m_ptPos, m_ptP5, false))
|
||||
return false ;
|
||||
pCrvPos->GetStartDir( vtStartDir) ;
|
||||
pCrvPos->GetEndDir( vtEndDir) ;
|
||||
//storto la punta delle frecce su una direzione mediata tra l'arco e la perpendicolare al lato
|
||||
double dFactor = 1 / ( 0.6 * m_vtDir.Len()) ; // questo fattore dipende direttamente dalla distanza di m_ptPos dal centro e smorza lo scostamento
|
||||
Vector3d vtLine1 = m_ptP1 - m_ptP5 ;
|
||||
Vector3d vtLine2 = m_ptP2 - m_ptP5 ;
|
||||
vtLine1.Normalize() ;
|
||||
vtLine2.Normalize() ;
|
||||
// se però le frecce sono fuori non le storto e faccio le code dritte anziché curvilinee
|
||||
lstPL.back().AddUPoint( 1, ptArrowTail) ;
|
||||
}
|
||||
if ( m_nType == DT_DIAMETRAL) {
|
||||
lstPL.emplace_back() ;
|
||||
GetArrowHead( m_ptP5, ( m_bCalcArrowIn ? - vtRad : vtRad), lstPL.back()) ;
|
||||
if ( ! m_bCalcArrowIn) {
|
||||
Point3d ptArrowTail1, ptArrowTail2 ;
|
||||
ptArrowTail1 = m_ptP5 + vtEndDir * m_dArrowLen *2 ;
|
||||
lstPL.emplace_back() ;
|
||||
Point3d ptArrowTail = m_ptP5 - vtRad * m_dArrowLen * 2 ;
|
||||
lstPL.back().AddUPoint( 0, m_ptP5) ;
|
||||
lstPL.back().AddUPoint( 1, ptArrowTail1) ;
|
||||
ptArrowTail2 = m_ptP6 - vtStartDir * m_dArrowLen *2 ;
|
||||
lstPL.emplace_back() ;
|
||||
lstPL.back().AddUPoint( 0, m_ptP6) ;
|
||||
lstPL.back().AddUPoint( 1, ptArrowTail2) ;
|
||||
dFactor = 0 ;
|
||||
lstPL.back().AddUPoint( 1, ptArrowTail) ;
|
||||
}
|
||||
lstPL.emplace_back() ;
|
||||
GetArrowHead( m_ptP5, ( m_bCalcArrowIn ? vtEndDir : - vtEndDir) + vtLine1 * dFactor, lstPL.back()) ;
|
||||
lstPL.emplace_back() ;
|
||||
GetArrowHead( m_ptP6, ( m_bCalcArrowIn ? - vtStartDir : vtStartDir) + vtLine2 * dFactor, lstPL.back()) ;
|
||||
// testo
|
||||
POLYLINELIST lstTxt ;
|
||||
if ( ApproxTextWithLines( dLinTol, dAngTolDeg, lstTxt))
|
||||
lstPL.splice( lstPL.end(), lstTxt) ;
|
||||
return true ;
|
||||
}
|
||||
default:
|
||||
// testo
|
||||
POLYLINELIST lstTxt;
|
||||
if ( ApproxTextWithLines( dLinTol, dAngTolDeg, lstTxt))
|
||||
lstPL.splice( lstPL.end(), lstTxt) ;
|
||||
return true ;
|
||||
}
|
||||
case DT_ANGULAR : {
|
||||
// prima linea di riferimento
|
||||
lstPL.emplace_back() ;
|
||||
lstPL.back().AddUPoint( 0, m_ptP1) ;
|
||||
lstPL.back().AddUPoint( 1, m_ptP3) ;
|
||||
// seconda linea di riferimento
|
||||
lstPL.emplace_back() ;
|
||||
lstPL.back().AddUPoint( 0, m_ptP2) ;
|
||||
lstPL.back().AddUPoint( 1, m_ptP4) ;
|
||||
// curva per l'arco
|
||||
PtrOwner<CurveArc> pCrvPos( CreateBasicCurveArc()) ;
|
||||
if ( IsNull( pCrvPos))
|
||||
return false ;
|
||||
// calcolo ptP5_bis
|
||||
Vector3d vtLine2 = m_ptP2 - m_ptP6 ;
|
||||
double dLen2 = vtLine2.Len() ;
|
||||
if ( ! vtLine2.Normalize())
|
||||
return false ;
|
||||
Point3d ptP5_bis = m_ptP2 + ( m_vtDir.Len() - dLen2) * vtLine2 ;
|
||||
// approssimerò l'arco con una polyline
|
||||
PolyLine plApprox ;
|
||||
double dLinTol = 0.01 ;
|
||||
double dAngTolDeg = 0.01 ;
|
||||
// se non ho testo
|
||||
if ( IsEmptyOrSpaces( m_sCalcText) || ! m_bCalcTextOn) {
|
||||
if ( ! pCrvPos->SetC2PN( m_ptP6, ptP5_bis, m_ptP5, m_vtN) || ! pCrvPos->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plApprox))
|
||||
return false ;
|
||||
lstPL.emplace_back( plApprox) ;
|
||||
}
|
||||
// altrimenti, linea di misura divisa in due parti
|
||||
else {
|
||||
// prima parte
|
||||
if ( ! pCrvPos->SetC2PN( m_ptP6, m_ptP5, m_ptCalcP7, m_vtN) || ! pCrvPos->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plApprox))
|
||||
return false ;
|
||||
lstPL.emplace_back( plApprox) ;
|
||||
// seconda parte
|
||||
if ( ! pCrvPos->SetC2PN( m_ptP6, ptP5_bis, m_ptCalcP8, m_vtN) || ! pCrvPos->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plApprox))
|
||||
return false ;
|
||||
lstPL.emplace_back( plApprox) ;
|
||||
}
|
||||
// frecce
|
||||
if ( ! pCrvPos->Set3P( ptP5_bis, m_ptPos, m_ptP5, false))
|
||||
return false ;
|
||||
Vector3d vtStartDir ;
|
||||
Vector3d vtEndDir ;
|
||||
pCrvPos->GetStartDir( vtStartDir) ;
|
||||
pCrvPos->GetEndDir( vtEndDir) ;
|
||||
//storto la punta delle frecce su una direzione mediata tra l'arco e la perpendicolare al lato
|
||||
double dFactor = 1 / ( 0.6 * m_vtDir.Len()) ;// questo fattore dipende direttamente dalla distanza di m_ptPos dal centro e smorza lo scostamento
|
||||
// se però le frecce sono fuori non le storto e faccio le code dritte anziché curvilinee
|
||||
if ( ! m_bCalcArrowIn) {
|
||||
Point3d ptArrowTail1, ptArrowTail2 ;
|
||||
ptArrowTail1 = m_ptP5 + vtEndDir * m_dArrowLen *2 ;
|
||||
lstPL.emplace_back() ;
|
||||
lstPL.back().AddUPoint( 0, m_ptP5) ;
|
||||
lstPL.back().AddUPoint( 1, ptArrowTail1) ;
|
||||
ptArrowTail2 = ptP5_bis - vtStartDir * m_dArrowLen *2 ;
|
||||
lstPL.emplace_back() ;
|
||||
lstPL.back().AddUPoint( 0, ptP5_bis) ;
|
||||
lstPL.back().AddUPoint( 1, ptArrowTail2) ;
|
||||
dFactor = 0 ;
|
||||
}
|
||||
lstPL.emplace_back() ;
|
||||
Vector3d vtLine1 = m_ptP1 - m_ptP6 ;
|
||||
if ( ! vtLine1.Normalize())
|
||||
return false ;
|
||||
GetArrowHead( m_ptP5, ( m_bCalcArrowIn ? vtEndDir : - vtEndDir) + vtLine1 * dFactor, lstPL.back()) ;
|
||||
lstPL.emplace_back() ;
|
||||
GetArrowHead( ptP5_bis, ( m_bCalcArrowIn ? - vtStartDir : vtStartDir) + vtLine2 * dFactor, lstPL.back()) ;
|
||||
// testo
|
||||
POLYLINELIST lstTxt ;
|
||||
if ( ApproxTextWithLines( dLinTol, dAngTolDeg, lstTxt))
|
||||
lstPL.splice( lstPL.end(), lstTxt) ;
|
||||
return true ;
|
||||
}
|
||||
default:
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1419,12 +1429,11 @@ ExtDimension::ApproxTextWithLines( double dLinTol, double dAngTolDeg, POLYLINELI
|
||||
Frame3d frRef ;
|
||||
if ( ! frRef.Set( m_ptCalcPos, m_vtN))
|
||||
return false ;
|
||||
|
||||
// oriento il testo con il raggio/diametro, ma solo se il testo è dentro la circonferenza
|
||||
if ( ( m_nType == DT_RADIAL || m_nType == DT_DIAMETRAL) && m_bCalcTextOn) {
|
||||
double dAngDeg = 0 ;
|
||||
Vector3d vtRad = m_ptPos - m_ptP5 ;
|
||||
m_vtDir.GetAngle( vtRad, dAngDeg) ;
|
||||
if ( ! frRef.Set( m_ptCalcPos, m_vtN, ( dAngDeg > 90 ? - vtRad : vtRad)))
|
||||
m_vtDir.GetAngle( frRef.VersX(), dAngDeg) ;
|
||||
if ( ! frRef.Set( m_ptCalcPos, m_vtN, ( dAngDeg > 90 ? - m_vtDir : m_vtDir)))
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
+9
-3
@@ -55,6 +55,11 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // IExtDimension
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -66,7 +71,7 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
|
||||
const Vector3d& vtN, const std::string& sText) override ;
|
||||
bool SetDiametral( const Point3d& ptCen, const Point3d& ptPos,
|
||||
const Vector3d& vtN, const std::string& sText) override ;
|
||||
bool SetAngular( const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptV, const Point3d& ptPos,
|
||||
bool SetAngular( const Point3d& ptP1, const Point3d& ptV, const Point3d& ptP2, const Point3d& ptPos,
|
||||
const Vector3d& vtN, const std::string& sText) override ;
|
||||
const Vector3d& GetNormVersor( void) const override
|
||||
{ return m_vtN ; }
|
||||
@@ -140,7 +145,7 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
|
||||
Point3d m_ptP3 ; // terzo punto
|
||||
Point3d m_ptP4 ; // quarto punto
|
||||
Point3d m_ptP5 ; // quinto punto
|
||||
Point3d m_ptP6 ; // sesto punto
|
||||
Point3d m_ptP6 ; // sesto punto; nel caso delle quotature angolari � il centro
|
||||
Point3d m_ptPos ; // posizione ricevuta della quota
|
||||
std::string m_sText ; // testo della quota
|
||||
mutable bool m_bToCalc ; // flag dati effettivi da ricalcolare
|
||||
@@ -157,7 +162,8 @@ 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[2] ; // vettore propriet� temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+6
-5
@@ -35,10 +35,9 @@ 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_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
m_nWeight( 400), m_bItalic( false), m_dHeight( 10), m_dRatio( 1), m_dAddAdvance( 0),
|
||||
m_nTempProp{0,0}, m_dTempParam{0.0,0.0}
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -188,6 +187,8 @@ ExtText::CopyFrom( const ExtText& clSrc)
|
||||
m_nInsPos = clSrc.m_nInsPos ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = clSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = clSrc.m_dTempParam[1] ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -883,7 +884,7 @@ ExtText::GetAuxSurf( void) const
|
||||
// per ogni regione richiedo la superficie ausiliaria e la aggiungo a quella generale
|
||||
for ( const auto& pSfr : lstSfr) {
|
||||
// recupero la superficie trimesh
|
||||
PtrOwner<ISurfTriMesh> pStm( GetBasicSurfFlatRegion( pSfr)->CalcAuxSurf( LIN_TOL_STD, ANG_TOL_STD_DEG)) ;
|
||||
PtrOwner<SurfTriMesh> pStm( GetBasicSurfFlatRegion( pSfr)->CalcAuxSurf( LIN_TOL_STD, ANG_TOL_STD_DEG)) ;
|
||||
if ( pStm != nullptr) {
|
||||
Triangle3d Tria ;
|
||||
int nT = pStm->GetFirstTriangle( Tria) ;
|
||||
|
||||
@@ -55,6 +55,11 @@ class ExtText : public IExtText, public IGeoObjRW
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // IExtText
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -144,7 +149,8 @@ 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[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+22
-40
@@ -16,8 +16,8 @@
|
||||
#include "FontNfe.h"
|
||||
#include "FontAux.h"
|
||||
#include "FontConst.h"
|
||||
#include "GdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGkCurveAux.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
@@ -81,21 +81,19 @@ NfeFont::SetCurrFont( const string& sFont, int nWeight, bool bItalic,
|
||||
if ( ! m_pGDB->Load( sFont))
|
||||
return false ;
|
||||
// recupero i parametri generali del font (devono essere nel gruppo 1)
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
|
||||
if ( IsNull( pIter))
|
||||
GdbIterator iIter( m_pGDB) ;
|
||||
if ( ! iIter.GoTo( 1))
|
||||
return false ;
|
||||
if ( ! pIter->GoTo( 1))
|
||||
return false ;
|
||||
if ( ! pIter->GetInfo( NFE_H, m_dH) ||
|
||||
! pIter->GetInfo( NFE_HCAP, m_dHCap) ||
|
||||
! pIter->GetInfo( NFE_HX, m_dHx) ||
|
||||
! pIter->GetInfo( NFE_ASC, m_dAsc) ||
|
||||
! pIter->GetInfo( NFE_DESC, m_dDesc) ||
|
||||
! pIter->GetInfo( NFE_ADV, m_dAdv))
|
||||
if ( ! iIter.GetInfo( NFE_H, m_dH) ||
|
||||
! iIter.GetInfo( NFE_HCAP, m_dHCap) ||
|
||||
! iIter.GetInfo( NFE_HX, m_dHx) ||
|
||||
! iIter.GetInfo( NFE_ASC, m_dAsc) ||
|
||||
! iIter.GetInfo( NFE_DESC, m_dDesc) ||
|
||||
! iIter.GetInfo( NFE_ADV, m_dAdv))
|
||||
return false ;
|
||||
if ( m_dH < EPS_SMALL || m_dHCap < EPS_SMALL || m_dHx < EPS_SMALL)
|
||||
return false ;
|
||||
if ( ! pIter->GetInfo( NFE_ITALIC, m_dItalicShearCoeff))
|
||||
if ( ! iIter.GetInfo( NFE_ITALIC, m_dItalicShearCoeff))
|
||||
m_dItalicShearCoeff = NFE_ITALIC_STD_SHEAR_COEFF ;
|
||||
// aggiorno la path del font
|
||||
m_sFont = sFontUp ;
|
||||
@@ -161,11 +159,6 @@ NfeFont::GetXBox( const string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3
|
||||
if ( m_pGDB == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
|
||||
if ( IsNull( pIter))
|
||||
return false ;
|
||||
|
||||
// calcolo i fattori di scala
|
||||
double dScaY = m_dHeight / m_dHCap ;
|
||||
double dScaX = dScaY * m_dRatio ;
|
||||
@@ -229,9 +222,7 @@ NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const
|
||||
return false ;
|
||||
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
|
||||
if ( IsNull( pIter))
|
||||
return false ;
|
||||
GdbIterator iIter( m_pGDB) ;
|
||||
|
||||
// calcolo i fattori di scala
|
||||
double dScaY = m_dHeight / m_dHCap ;
|
||||
@@ -265,9 +256,9 @@ NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const
|
||||
if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP)
|
||||
nGroup = NFE_ERR_CHAR ;
|
||||
// ciclo sulle entità geometriche del carattere
|
||||
bool bIter = pIter->GoToFirstInGroup( nGroup) ;
|
||||
bool bIter = iIter.GoToFirstInGroup( nGroup) ;
|
||||
while ( bIter) {
|
||||
const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ;
|
||||
const ICurve* pCrv = GetCurve( iIter.GetGeoObj()) ;
|
||||
if ( pCrv != nullptr) {
|
||||
// copio la curva (trasformando eventuali archi in CurveBezier)
|
||||
ICurve* pCrvNew = CurveToNoArcsCurve( pCrv) ;
|
||||
@@ -281,7 +272,7 @@ NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const
|
||||
// inserisco in lista la nuova curva
|
||||
lstPC.push_back( pCrvNew) ;
|
||||
}
|
||||
bIter = pIter->GoToNext() ;
|
||||
bIter = iIter.GoToNext() ;
|
||||
}
|
||||
// recupero lo spostamento per il prossimo carattere
|
||||
double dAdvance ;
|
||||
@@ -314,9 +305,7 @@ NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doub
|
||||
return false ;
|
||||
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
|
||||
if ( IsNull( pIter))
|
||||
return false ;
|
||||
GdbIterator iIter( m_pGDB) ;
|
||||
|
||||
// controllo valore tolleranza lineare
|
||||
if ( dLinTol > FNT_MAX_LINTOL_TO_H * m_dHeight)
|
||||
@@ -354,9 +343,9 @@ NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doub
|
||||
if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP)
|
||||
nGroup = NFE_ERR_CHAR ;
|
||||
// ciclo sulle entità geometriche del carattere
|
||||
bool bIter = pIter->GoToFirstInGroup( nGroup) ;
|
||||
bool bIter = iIter.GoToFirstInGroup( nGroup) ;
|
||||
while ( bIter) {
|
||||
const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ;
|
||||
const ICurve* pCrv = GetCurve( iIter.GetGeoObj()) ;
|
||||
if ( pCrv != nullptr) {
|
||||
// copia temporanea della curva (trasformando eventuali archi in CurveBezier)
|
||||
PtrOwner<ICurve> pCrvNew( CurveToNoArcsCurve( pCrv)) ;
|
||||
@@ -371,7 +360,7 @@ NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doub
|
||||
lstPL.emplace_back() ;
|
||||
pCrvNew->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, lstPL.back()) ;
|
||||
}
|
||||
bIter = pIter->GoToNext() ;
|
||||
bIter = iIter.GoToNext() ;
|
||||
}
|
||||
// recupero lo spostamento per il prossimo carattere
|
||||
double dAdvance ;
|
||||
@@ -400,9 +389,7 @@ NfeFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, doubl
|
||||
return false ;
|
||||
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
|
||||
if ( IsNull( pIter))
|
||||
return false ;
|
||||
GdbIterator iIter( m_pGDB) ;
|
||||
|
||||
// controllo valore tolleranza lineare
|
||||
if ( dLinTol > FNT_MAX_LINTOL_TO_H * m_dHeight)
|
||||
@@ -440,9 +427,9 @@ NfeFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, doubl
|
||||
if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP)
|
||||
nGroup = NFE_ERR_CHAR ;
|
||||
// ciclo sulle entità geometriche del carattere
|
||||
bool bIter = pIter->GoToFirstInGroup( nGroup) ;
|
||||
bool bIter = iIter.GoToFirstInGroup( nGroup) ;
|
||||
while ( bIter) {
|
||||
const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ;
|
||||
const ICurve* pCrv = GetCurve( iIter.GetGeoObj()) ;
|
||||
if ( pCrv != nullptr) {
|
||||
// copia temporanea della curva (trasformando eventuali archi in CurveBezier)
|
||||
PtrOwner<ICurve> pCrvNew( CurveToNoArcsCurve( pCrv)) ;
|
||||
@@ -457,7 +444,7 @@ NfeFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, doubl
|
||||
lstPA.emplace_back() ;
|
||||
pCrv->ApproxWithArcs( dLinTol, dAngTolDeg, lstPA.back()) ;
|
||||
}
|
||||
bIter = pIter->GoToNext() ;
|
||||
bIter = iIter.GoToNext() ;
|
||||
}
|
||||
// recupero lo spostamento per il prossimo carattere
|
||||
double dAdvance ;
|
||||
@@ -484,11 +471,6 @@ NfeFont::GetTextLines( const string& sText, int nInsPos, PNTVECTOR& vPt, STRVECT
|
||||
if ( m_pGDB == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
|
||||
if ( IsNull( pIter))
|
||||
return false ;
|
||||
|
||||
// calcolo i fattori di scala
|
||||
double dScaY = m_dHeight / m_dHCap ;
|
||||
double dScaX = dScaY * m_dRatio ;
|
||||
|
||||
+11
-14
@@ -16,15 +16,15 @@
|
||||
#include "FontOs.h"
|
||||
#include "FontAux.h"
|
||||
#include "FontConst.h"
|
||||
#include "CurveLine.h"
|
||||
#include "CurveBezier.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "SurfFlatRegion.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGkCurveAux.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGnFileUtils.h"
|
||||
@@ -298,8 +298,7 @@ OsFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const
|
||||
if ( ! GetCharOutline( vCode[i], dAdvance, lstTmpPC))
|
||||
return false ;
|
||||
// lo trasformo opportunamente
|
||||
ICURVEPLIST::iterator iIter ;
|
||||
for ( iIter = lstTmpPC.begin() ; iIter != lstTmpPC.end() ; ++ iIter) {
|
||||
for ( auto iIter = lstTmpPC.begin() ; iIter != lstTmpPC.end() ; ++ iIter) {
|
||||
// trasformazioni
|
||||
(*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
|
||||
(*iIter)->Translate( vtMove) ;
|
||||
@@ -464,8 +463,7 @@ OsFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doubl
|
||||
if ( ! GetCharOutline( vCode[i], dAdvance, lstPC))
|
||||
return false ;
|
||||
// lo approssimo con segmenti di retta
|
||||
ICURVEPLIST::iterator iIter ;
|
||||
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
|
||||
for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
|
||||
// trasformazioni
|
||||
(*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
|
||||
(*iIter)->Translate( vtMove) ;
|
||||
@@ -478,7 +476,7 @@ OsFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doubl
|
||||
if ( vtMove.x > dMaxW)
|
||||
dMaxW = vtMove.x ;
|
||||
// ciclo di pulizia
|
||||
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter)
|
||||
for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter)
|
||||
delete (*iIter) ;
|
||||
lstPC.clear() ;
|
||||
}
|
||||
@@ -549,8 +547,7 @@ OsFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, double
|
||||
if ( ! GetCharOutline( vCode[i], dAdvance, lstPC))
|
||||
return false ;
|
||||
// lo approssimo con segmenti di arco e retta
|
||||
ICURVEPLIST::iterator iIter ;
|
||||
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
|
||||
for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
|
||||
// trasformazioni
|
||||
(*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
|
||||
(*iIter)->Translate( vtMove) ;
|
||||
@@ -563,7 +560,7 @@ OsFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, double
|
||||
if ( vtMove.x > dMaxW)
|
||||
dMaxW = vtMove.x ;
|
||||
// ciclo di pulizia
|
||||
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter)
|
||||
for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter)
|
||||
delete (*iIter) ;
|
||||
lstPC.clear() ;
|
||||
}
|
||||
@@ -730,7 +727,7 @@ OsFont::GetCharOutline( unsigned int nChar, double& dAdvance, ICURVEPLIST& lstPC
|
||||
if ( pHeader->dwType == TT_POLYGON_TYPE) {
|
||||
|
||||
// creo curva composita
|
||||
PtrOwner<ICurveComposite> pCCompo( CreateCurveComposite()) ;
|
||||
PtrOwner<CurveComposite> pCCompo( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCCompo))
|
||||
return false ;
|
||||
|
||||
@@ -823,7 +820,7 @@ OsFont::AddLineToCompo( ICurveComposite* pCCompo, const Point3d& ptStart, const
|
||||
return false ;
|
||||
|
||||
// creo retta, la imposto e la inserisco nella curva composita
|
||||
PtrOwner<ICurveLine> pCLine( CreateCurveLine()) ;
|
||||
PtrOwner<CurveLine> pCLine( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pCLine))
|
||||
return false ;
|
||||
if ( ! pCLine->Set( ptStart, ptEnd))
|
||||
@@ -844,7 +841,7 @@ OsFont::AddCBezierQuadToCompo( ICurveComposite* pCCompo,
|
||||
return false ;
|
||||
|
||||
// creo curva di Bezier quadratica, la imposto e la inserisco nella curva composita
|
||||
PtrOwner<ICurveBezier> pCBezier( CreateCurveBezier()) ;
|
||||
PtrOwner<CurveBezier> pCBezier( CreateBasicCurveBezier()) ;
|
||||
if ( IsNull( pCBezier))
|
||||
return false ;
|
||||
if ( ! pCBezier->Init( 2, false) ||
|
||||
|
||||
+55
-105
@@ -1423,8 +1423,7 @@ GdbExecutor::CurveArcChangeRadius( const STRVECTOR& vsParams)
|
||||
if ( ! GetLengthParam( vsParams[1], dNewRad))
|
||||
return false ;
|
||||
// esecuzione
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
// recupero l'arco
|
||||
ICurveArc* pCrvArc = GetCurveArc( m_pGDB->GetGeoObj( *Iter)) ;
|
||||
if ( pCrvArc == nullptr)
|
||||
@@ -1452,8 +1451,7 @@ GdbExecutor::CurveArcChangeDeltaN( const STRVECTOR& vsParams)
|
||||
if ( ! GetLengthParam( vsParams[1], dNewDeltaN))
|
||||
return false ;
|
||||
// esecuzione
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
// recupero l'arco
|
||||
ICurveArc* pCrvArc = GetCurveArc( m_pGDB->GetGeoObj( *Iter)) ;
|
||||
if ( pCrvArc == nullptr)
|
||||
@@ -1686,8 +1684,7 @@ GdbExecutor::CurveCompoMake( const STRVECTOR& vsParams)
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
|
||||
return false ;
|
||||
// esecuzione
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
// recupero la curva
|
||||
int nIdCrv = *Iter ;
|
||||
const ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nIdCrv)) ;
|
||||
@@ -1722,7 +1719,7 @@ GdbExecutor::CurveCompoMake( const STRVECTOR& vsParams)
|
||||
if ( AddGeoObj( vsParams[0], vsParams[1], Release( pCrvCompo))) {
|
||||
// se richiesto, cancello le curve originali
|
||||
if ( bErase) {
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( ! m_pGDB->Erase( *Iter))
|
||||
return false ;
|
||||
}
|
||||
@@ -2309,8 +2306,7 @@ GdbExecutor::SurfTriMeshByTriangleSoup( const STRVECTOR& vsParams)
|
||||
if ( ! StmFts.Start())
|
||||
return false ;
|
||||
// Recupero tutti i triangoli delle superfici sorgenti e li inserisco nella nuova
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
// recupero la superficie sorgente
|
||||
const ISurfTriMesh* pStmS = GetSurfTriMesh( m_pGDB->GetGeoObj( *Iter)) ;
|
||||
if ( pStmS == nullptr)
|
||||
@@ -2340,7 +2336,7 @@ GdbExecutor::SurfTriMeshByTriangleSoup( const STRVECTOR& vsParams)
|
||||
if ( AddGeoObj( vsParams[0], vsParams[1], pSTM)) {
|
||||
// se richiesto, cancello le curve originali
|
||||
if ( bErase) {
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( ! m_pGDB->Erase( *Iter))
|
||||
return false ;
|
||||
}
|
||||
@@ -2534,8 +2530,7 @@ GdbExecutor::SurfTriMeshDoCompacting( const STRVECTOR& vsParams)
|
||||
if ( ! GetNamesParam( vsParams[0], vnNames))
|
||||
return false ;
|
||||
// opero sui diversi oggetti
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
// recupero la superficie
|
||||
ISurfTriMesh* pStm = GetSurfTriMesh( m_pGDB->GetGeoObj( *Iter)) ;
|
||||
if ( pStm == nullptr)
|
||||
@@ -2572,8 +2567,7 @@ GdbExecutor::SurfTriMeshDoSewing( const STRVECTOR& vsParams)
|
||||
if ( ! GetNamesParam( vsParams[1], vnNames))
|
||||
return false ;
|
||||
// esecuzione
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
// recupero la superficie da cucire
|
||||
const ISurfTriMesh* pStmS = GetSurfTriMesh( m_pGDB->GetGeoObj( *Iter)) ;
|
||||
if ( pStmS == nullptr)
|
||||
@@ -2590,7 +2584,7 @@ GdbExecutor::SurfTriMeshDoSewing( const STRVECTOR& vsParams)
|
||||
}
|
||||
// se richiesto, cancello le superfici cucite alla prima
|
||||
if ( bErase) {
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter)
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter)
|
||||
m_pGDB->Erase( *Iter) ;
|
||||
}
|
||||
return true ;
|
||||
@@ -5432,8 +5426,7 @@ GdbExecutor::TextOutline( const STRVECTOR& vsParams)
|
||||
pTXT->GetOutline( lstPCRV) ;
|
||||
// inserisco le curve nel gruppo destinazione dopo aver sistemato il cambio di riferimento
|
||||
bool bOk = true ;
|
||||
ICURVEPLIST::iterator iIter ;
|
||||
for ( iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) {
|
||||
for ( auto iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) {
|
||||
(*iIter)->LocToLoc( frTXT, frDest) ;
|
||||
if ( m_pGDB->AddGeoObj( GDB_ID_NULL, nIdDest, (*iIter)) == GDB_ID_NULL) {
|
||||
delete (*iIter) ;
|
||||
@@ -5510,8 +5503,7 @@ GdbExecutor::GetNamesParam( const string& sParam, INTVECTOR& vnNames)
|
||||
// converto in interi
|
||||
vnNames.clear() ;
|
||||
vnNames.reserve( vsNames.size()) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
int nId = GetIdParam( *Iter) ;
|
||||
if ( nId != GDB_ID_SEL) {
|
||||
@@ -5538,8 +5530,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
|
||||
// divido in parti
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam, ",", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
// se 2 parti, allora Z = 0
|
||||
if ( vsParams.size() == 2) {
|
||||
@@ -5594,8 +5585,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
|
||||
// recupero i parametri associati
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam.substr( 3, sParam.length()-4), ",", "(", ")", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n") ;
|
||||
// ci deve essere almeno un parametro
|
||||
if ( vsParams.size() < 1)
|
||||
@@ -5747,8 +5737,7 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
// divido in parti
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam, ",", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
// se 2 parti, allora Z = 0
|
||||
if ( vsParams.size() == 2) {
|
||||
@@ -5778,8 +5767,7 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
// recupero i parametri associati
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam.substr( 3, sParam.length()-4), ",", "(", ")", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n") ;
|
||||
// ci deve essere almeno un parametro
|
||||
if ( vsParams.size() < 1)
|
||||
@@ -5962,8 +5950,7 @@ GdbExecutor::GetPointsParam( const string& sParam, const Frame3d& frPnt, PolyLin
|
||||
Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsPoints) ;
|
||||
// converto in punti
|
||||
PL.Clear() ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsPoints.begin() ; Iter != vsPoints.end() ; ++Iter) {
|
||||
for ( auto Iter = vsPoints.begin() ; Iter != vsPoints.end() ; ++Iter) {
|
||||
Trim( (*Iter), " \t\r\n") ;
|
||||
if ( GetIdParam( *Iter) == GDB_ID_SEL) {
|
||||
int nId = m_pGDB->GetFirstSelectedObj() ;
|
||||
@@ -5997,8 +5984,7 @@ GdbExecutor::GetPointWParam( const string& sParam, const Frame3d& frPnt, Point3d
|
||||
// divido in parti
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n") ;
|
||||
|
||||
// se 4 parti, sono 3 coordinate e un peso
|
||||
@@ -6037,8 +6023,7 @@ GdbExecutor::GetPointWsParam( const string& sParam, const Frame3d& frPnt, PolyAr
|
||||
Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsPointWs) ;
|
||||
// converto in punti
|
||||
PA.Clear() ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsPointWs.begin() ; Iter != vsPointWs.end() ; ++Iter) {
|
||||
for ( auto Iter = vsPointWs.begin() ; Iter != vsPointWs.end() ; ++Iter) {
|
||||
Trim( (*Iter), " \t\r\n") ;
|
||||
Point3d ptP ;
|
||||
double dBulge ;
|
||||
@@ -6059,8 +6044,7 @@ GdbExecutor::GetLengthParam( const string& sParam, double& dLen)
|
||||
// recupero i parametri associati
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam.substr( 1), ",", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
// ci deve essere almeno un parametro
|
||||
if ( vsParams.size() < 1)
|
||||
@@ -6082,8 +6066,7 @@ GdbExecutor::GetLengthParam( const string& sParam, double& dLen)
|
||||
// recupero i parametri associati
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam.substr( 1), ",", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
// ci deve essere almeno un parametro
|
||||
if ( vsParams.size() < 1)
|
||||
@@ -6118,8 +6101,7 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
|
||||
// recupero i parametri associati
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam.substr( 3, sParam.length()-4), ",", "(", ")", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n") ;
|
||||
// ci deve essere almeno un parametro
|
||||
if ( vsParams.size() < 1)
|
||||
@@ -6263,8 +6245,7 @@ GdbExecutor::GetFrameParam( const string& sParam, const Frame3d& frRef, Frame3d&
|
||||
// divido in parti ed elimino spazi iniziali/finali
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sTmp, ",", "(", ")", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n") ;
|
||||
// verifico siano 4 parti e le converto
|
||||
if ( vsParams.size() != 4)
|
||||
@@ -6291,8 +6272,7 @@ GdbExecutor::GetFrameParam( const string& sParam, const Frame3d& frRef, Frame3d&
|
||||
// divido in parti ed elimino spazi iniziali/finali
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sTmp, ",", "(", ")", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n") ;
|
||||
// se c'è un parametro è l'origine
|
||||
Point3d ptOrig ;
|
||||
@@ -6358,8 +6338,7 @@ GdbExecutor::GetColorParam( const string& sParam, bool& bByParent, Color& cCol)
|
||||
// divido in parti
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam, ",", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
// devono essere 3 o 4 parametri ( Red, Green, Blue [, Alpha])
|
||||
if ( vsParams.size() != 3 && vsParams.size() != 4)
|
||||
@@ -6387,8 +6366,7 @@ GdbExecutor::GetColorParam( const string& sParam, bool& bByParent, Color& cCol)
|
||||
// recupero i parametri associati
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam.substr( 1), ",", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
// ci deve essere un parametro
|
||||
if ( vsParams.size() != 1)
|
||||
@@ -6421,8 +6399,7 @@ GdbExecutor::GetMaterialParam( const string& sParam, bool& bByParent, int& nMat)
|
||||
// recupero i parametri associati
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam.substr( 1), ",", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
// ci deve essere un parametro
|
||||
if ( vsParams.size() != 1)
|
||||
@@ -6479,8 +6456,7 @@ GdbExecutor::ExecuteLevel( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
else
|
||||
return false ;
|
||||
// esecuzione impostazione livello
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( ! m_pGDB->SetLevel( *Iter, nLevel))
|
||||
return false ;
|
||||
}
|
||||
@@ -6511,8 +6487,7 @@ GdbExecutor::ExecuteMode( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
else
|
||||
return false ;
|
||||
// esecuzione impostazione modo
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( ! m_pGDB->SetMode( *Iter, nMode))
|
||||
return false ;
|
||||
}
|
||||
@@ -6543,8 +6518,7 @@ GdbExecutor::ExecuteStatus( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
else
|
||||
return false ;
|
||||
// esecuzione impostazione stato
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( ! m_pGDB->SetStatus( *Iter, nStat))
|
||||
return false ;
|
||||
}
|
||||
@@ -6565,8 +6539,7 @@ GdbExecutor::ExecuteSelect( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( ! GetNamesParam( vsParams[0], vnNames))
|
||||
return false ;
|
||||
// esecuzione selezione
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( ! m_pGDB->SelectObj( *Iter))
|
||||
return false ;
|
||||
}
|
||||
@@ -6610,8 +6583,7 @@ GdbExecutor::ExecuteSelect( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
nFilter = EXT_TEXT ;
|
||||
}
|
||||
// esecuzione selezione di tutti gli oggetti di ogni gruppo
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( ! m_pGDB->SelectGroupObjs( *Iter, nFilter))
|
||||
return false ;
|
||||
}
|
||||
@@ -6635,8 +6607,7 @@ GdbExecutor::ExecuteDeselect( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( ! GetNamesParam( vsParams[0], vnNames))
|
||||
return false ;
|
||||
// esecuzione deselezione
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( ! m_pGDB->DeselectObj( *Iter))
|
||||
return false ;
|
||||
}
|
||||
@@ -6652,8 +6623,7 @@ GdbExecutor::ExecuteDeselect( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( ! GetNamesParam( vsParams[0], vnNames))
|
||||
return false ;
|
||||
// esecuzione deselezione di tutti gli oggetti di ogni gruppo
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( ! m_pGDB->DeselectGroupObjs( *Iter))
|
||||
return false ;
|
||||
}
|
||||
@@ -6710,8 +6680,7 @@ GdbExecutor::MaterialColor( const STRVECTOR& vsParams)
|
||||
if ( ! GetColorParam( vsParams[1], bByParent, cCol))
|
||||
return false ;
|
||||
// esecuzione impostazione colore
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( bByParent) {
|
||||
if ( ! m_pGDB->SetMaterial( *Iter, GDB_MT_PARENT))
|
||||
return false ;
|
||||
@@ -6741,8 +6710,7 @@ GdbExecutor::MaterialMaterial( const STRVECTOR& vsParams)
|
||||
if ( ! GetMaterialParam( vsParams[1], bByParent, nMat))
|
||||
return false ;
|
||||
// esecuzione impostazione colore
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( bByParent) {
|
||||
if ( ! m_pGDB->SetMaterial( *Iter, GDB_MT_PARENT))
|
||||
return false ;
|
||||
@@ -6789,8 +6757,7 @@ GdbExecutor::ExecuteName( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( ! GetStringParam( vsParams[1], sName))
|
||||
return false ;
|
||||
// eseguo assegnazione nome
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( ! m_pGDB->SetName( *Iter, sName))
|
||||
return false ;
|
||||
}
|
||||
@@ -6806,8 +6773,7 @@ GdbExecutor::ExecuteName( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( ! GetNamesParam( vsParams[0], vnNames))
|
||||
return false ;
|
||||
// eseguo rimozione nome
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( ! m_pGDB->RemoveName( *Iter))
|
||||
return false ;
|
||||
}
|
||||
@@ -6839,8 +6805,7 @@ GdbExecutor::ExecuteInfo( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( ! GetStringParam( vsParams[2], sInfo))
|
||||
return false ;
|
||||
// eseguo assegnazione Info di data Key
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( ! m_pGDB->SetInfo( *Iter, sKey, sInfo))
|
||||
return false ;
|
||||
}
|
||||
@@ -6860,8 +6825,7 @@ GdbExecutor::ExecuteInfo( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( ! GetStringParam( vsParams[1], sKey))
|
||||
return false ;
|
||||
// eseguo rimozione nome Info di data Key
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( ! m_pGDB->RemoveInfo( *Iter, sKey))
|
||||
return false ;
|
||||
}
|
||||
@@ -7010,8 +6974,7 @@ GdbExecutor::ExecuteRelocate( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// recupero flag per globale
|
||||
bool bGlob = ( sCmd2 == "GLOB" || sCmd2 == "G") ;
|
||||
// esecuzione rilocazioni
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( bGlob) {
|
||||
if ( ! m_pGDB->RelocateGlob( *Iter, GetIdParam( vsParams[1]), nSonBeforeAfter))
|
||||
return false ;
|
||||
@@ -7036,8 +6999,7 @@ GdbExecutor::ExecuteErase( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( ! GetNamesParam( vsParams[0], vnNames))
|
||||
return false ;
|
||||
// esecuzione cancellazioni
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
if ( ! m_pGDB->Erase( *Iter))
|
||||
return false ;
|
||||
}
|
||||
@@ -7079,8 +7041,7 @@ GdbExecutor::ExecuteTranslate( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( ! GetVectorParam( vsParams[1], frRef, vtVN))
|
||||
return false ;
|
||||
// esecuzione traslazioni
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
switch ( nTraType) {
|
||||
case TRA_LOC :
|
||||
if ( ! m_pGDB->Translate( *Iter, vtVN))
|
||||
@@ -7144,8 +7105,7 @@ GdbExecutor::ExecuteRotate( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( ! FromString( vsParams[3], dAngDeg))
|
||||
return false ;
|
||||
// esecuzione rotazioni
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
switch ( nRotType) {
|
||||
case ROT_LOC :
|
||||
if ( ! m_pGDB->Rotate( *Iter, ptPC, vtVN, dAngDeg))
|
||||
@@ -7214,8 +7174,7 @@ GdbExecutor::ExecuteScale( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
! FromString( vsParams[4], dCoeffZ))
|
||||
return false ;
|
||||
// esecuzione scalature
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
switch ( nScaType) {
|
||||
case SCA_LOC :
|
||||
if ( ! m_pGDB->Scale( *Iter, frFrame, dCoeffX, dCoeffY, dCoeffZ))
|
||||
@@ -7273,8 +7232,7 @@ GdbExecutor::ExecuteMirror( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( ! GetVectorParam( vsParams[2], frRef, vtVN))
|
||||
return false ;
|
||||
// esecuzione specchiature
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
switch ( nMirType) {
|
||||
case MIR_LOC :
|
||||
if ( ! m_pGDB->Mirror( *Iter, ptPC, vtVN))
|
||||
@@ -7340,8 +7298,7 @@ GdbExecutor::ExecuteShear( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( ! FromString( vsParams[4], dCoeff))
|
||||
return false ;
|
||||
// esecuzione scorrimenti
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
switch ( nMirType) {
|
||||
case MIR_LOC :
|
||||
if ( ! m_pGDB->Shear( *Iter, ptPC, vtNorm, vtDir, dCoeff))
|
||||
@@ -7400,8 +7357,7 @@ GdbExecutor::CurveModifyInvert( const STRVECTOR& vsParams)
|
||||
if ( ! GetNamesParam( vsParams[0], vnNames))
|
||||
return false ;
|
||||
// esecuzione inversione curve
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
ICurve* pCurve = GetCurve( m_pGDB->GetGeoObj( *Iter)) ;
|
||||
if ( pCurve == nullptr || ! pCurve->Invert())
|
||||
return false ;
|
||||
@@ -7518,8 +7474,7 @@ GdbExecutor::CurveModifyTrim( const STRVECTOR& vsParams, int nTrimType)
|
||||
if ( ! FromString( vsParams[1], dPar))
|
||||
return false ;
|
||||
// esecuzione trim
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
ICurve* pCurve ;
|
||||
if ( ( pCurve = GetCurve( m_pGDB->GetGeoObj( *Iter))) != nullptr) {
|
||||
switch ( nTrimType) {
|
||||
@@ -7718,8 +7673,7 @@ GdbExecutor::CurveCopyByChain( const STRVECTOR& vsParams)
|
||||
// preparo i dati per il concatenamento
|
||||
ChainCurves chainC ;
|
||||
chainC.Init( bAllowInvert, dToler, int( vnNames.size())) ;
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
// recupero la curva e il suo riferimento
|
||||
ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( *Iter)) ;
|
||||
if ( pCrv == nullptr)
|
||||
@@ -7748,10 +7702,9 @@ GdbExecutor::CurveCopyByChain( const STRVECTOR& vsParams)
|
||||
if ( IsNull( pCrvCompo))
|
||||
return false ;
|
||||
// recupero le curve semplici e le inserisco nella curva composita
|
||||
INTVECTOR::iterator Iter2 ;
|
||||
for ( Iter2 = vIds.begin() ; Iter2 != vIds.end() ; ++Iter2) {
|
||||
int nId = abs( *Iter2) ;
|
||||
bool bInvert = ( *Iter2 < 0) ;
|
||||
for ( auto Iter = vIds.cbegin() ; Iter != vIds.cend() ; ++Iter) {
|
||||
int nId = abs( *Iter) ;
|
||||
bool bInvert = ( *Iter < 0) ;
|
||||
// recupero la curva e il suo riferimento
|
||||
ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nId)) ;
|
||||
if ( pCrv == nullptr)
|
||||
@@ -7806,8 +7759,7 @@ GdbExecutor::SurfModifyInvert( const STRVECTOR& vsParams)
|
||||
if ( ! GetNamesParam( vsParams[0], vnNames))
|
||||
return false ;
|
||||
// esecuzione inversione normale superficie
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
ISurf* pSurf = GetSurf( m_pGDB->GetGeoObj( *Iter)) ;
|
||||
if ( pSurf == nullptr || ! pSurf->Invert())
|
||||
return false ;
|
||||
@@ -8049,8 +8001,7 @@ GdbExecutor::ExecuteOutTsc( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( ! GetNamesParam( vsParams[0], vnNames))
|
||||
return false ;
|
||||
// esecuzione
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
// recupero l'oggetto ed eseguo l'output
|
||||
if ( ! OutGroupTsc( *Iter, nFlag))
|
||||
return false ;
|
||||
@@ -8073,8 +8024,7 @@ GdbExecutor::ExecuteOutTsc( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( ! GetNamesParam( vsParams[0], vnNames))
|
||||
return false ;
|
||||
// esecuzione
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
|
||||
// recupero l'oggetto ed eseguo l'output
|
||||
if ( ! m_OutTsc.PutGeoObj( m_pGDB->GetGeoObj( *Iter), nFlag))
|
||||
return false ;
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ GdbGroup::~GdbGroup( void)
|
||||
// nel sorgente aggiorno lista dei riferimenti
|
||||
INTVECTOR vnList ;
|
||||
pGdbObj->GetInfo( GDB_SI_LIST, vnList) ;
|
||||
INTVECTOR::const_iterator iFind = find( vnList.begin(), vnList.end(), m_nId) ;
|
||||
const auto iFind = find( vnList.begin(), vnList.end(), m_nId) ;
|
||||
if ( iFind != vnList.end())
|
||||
vnList.erase( iFind) ;
|
||||
if ( vnList.empty())
|
||||
|
||||
+2
-1
@@ -1468,7 +1468,8 @@ GdbIterator::SetInfo( const string& sKey, int nInfo)
|
||||
bool
|
||||
GdbIterator::SetInfo( const string& sKey, double dInfo)
|
||||
{
|
||||
return SetInfo( sKey, ToString( dInfo)) ;
|
||||
int nErr ;
|
||||
return ( SetInfo( sKey, ToString( dInfo, 6, &nErr)) && nErr == 0) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+2
-1
@@ -862,7 +862,8 @@ GdbObj::SetInfo( const string& sKey, int nInfo)
|
||||
bool
|
||||
GdbObj::SetInfo( const string& sKey, double dInfo)
|
||||
{
|
||||
return SetInfo( sKey, ToString( dInfo)) ;
|
||||
int nErr ;
|
||||
return ( SetInfo( sKey, ToString( dInfo, 6, &nErr)) && nErr == 0) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+3
-3
@@ -29,10 +29,8 @@ GEOOBJ_REGISTER( GEO_FRAME3D, NGE_G_FRM, GeoFrame3d) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GeoFrame3d::GeoFrame3d( void)
|
||||
: m_frF()
|
||||
: m_frF(), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -118,6 +116,8 @@ GeoFrame3d::CopyFrom( const GeoFrame3d& gfSrc)
|
||||
return true ;
|
||||
m_nTempProp[0] = gfSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = gfSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = gfSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = gfSrc.m_dTempParam[1] ;
|
||||
return Set( gfSrc.m_frF) ;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,11 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // IGeoFrame3d
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -97,6 +102,7 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Frame3d m_frF ; // oggetto
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+3
-3
@@ -28,10 +28,8 @@ GEOOBJ_REGISTER( GEO_PNT3D, NGE_G_PNT, GeoPoint3d) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GeoPoint3d::GeoPoint3d( void)
|
||||
: m_ptP()
|
||||
: m_ptP(), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -86,6 +84,8 @@ GeoPoint3d::CopyFrom( const GeoPoint3d& clSrc)
|
||||
return true ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = clSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = clSrc.m_dTempParam[1] ;
|
||||
return Set( clSrc.m_ptP) ;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,11 @@ class GeoPoint3d : public IGeoPoint3d, public IGeoObjRW
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // IGeoPoint3d
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -91,6 +96,7 @@ class GeoPoint3d : public IGeoPoint3d, public IGeoObjRW
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Point3d m_ptP ; // oggetto
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+3
-3
@@ -29,10 +29,8 @@ GEOOBJ_REGISTER( GEO_VECT3D, NGE_G_VEC, GeoVector3d) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GeoVector3d::GeoVector3d( void)
|
||||
: m_vtV()
|
||||
: m_vtV(), m_ptBase(), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -102,6 +100,8 @@ GeoVector3d::CopyFrom( const GeoVector3d& clSrc)
|
||||
return true ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = clSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = clSrc.m_dTempParam[1] ;
|
||||
return Set( clSrc.m_vtV, clSrc.m_ptBase) ;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,11 @@ class GeoVector3d : public IGeoVector3d, public IGeoObjRW
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // IGeoVector3d
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -106,6 +111,7 @@ class GeoVector3d : public IGeoVector3d, public IGeoObjRW
|
||||
Vector3d m_vtV ; // oggetto
|
||||
Point3d m_ptBase ; // punto base da cui tracciare il vettore
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+2
-1
@@ -2785,7 +2785,8 @@ GeomDB::SetInfo( int nId, const string& sKey, int nInfo)
|
||||
bool
|
||||
GeomDB::SetInfo( int nId, const string& sKey, double dInfo)
|
||||
{
|
||||
return SetInfo( nId, sKey, ToString( dInfo)) ;
|
||||
int nErr ;
|
||||
return ( SetInfo( nId, sKey, ToString( dInfo, 6, &nErr)) && nErr == 0) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -156,13 +156,13 @@ IntersParLinesSurfTm::IntersParLinesSurfTm( const Frame3d& frLines, const ISurfT
|
||||
bool
|
||||
IntersParLinesSurfTm::GetInters( const Point3d& ptL, double dLen, ILSIVECTOR& vInfo, bool bFinite) const
|
||||
{
|
||||
// verifico validità
|
||||
if ( ! m_bOk)
|
||||
return false ;
|
||||
// verifico parametro di ritorno
|
||||
if ( &vInfo == nullptr)
|
||||
return false ;
|
||||
vInfo.clear() ;
|
||||
// verifico validità
|
||||
if ( ! m_bOk)
|
||||
return false ;
|
||||
|
||||
// calcolo box linea (nel riferimento)
|
||||
BBox3d b3Line ;
|
||||
|
||||
+2
-4
@@ -26,8 +26,7 @@ class IterManager
|
||||
{
|
||||
public :
|
||||
bool IsGdbIteratorInList( GdbIterator* pIter)
|
||||
{ PGDBI_LIST::const_iterator Iter ;
|
||||
for ( Iter = m_IterList.begin() ; Iter != m_IterList.end() ; ++ Iter) {
|
||||
{ for ( auto Iter = m_IterList.cbegin() ; Iter != m_IterList.cend() ; ++ Iter) {
|
||||
if ( *Iter == pIter)
|
||||
return true ;
|
||||
}
|
||||
@@ -41,8 +40,7 @@ class IterManager
|
||||
catch (...) { return false ;}
|
||||
return true ; }
|
||||
bool RemoveGdbIterator( GdbIterator* pIter)
|
||||
{ PGDBI_LIST::iterator Iter ;
|
||||
for ( Iter = m_IterList.begin() ; Iter != m_IterList.end() ; ++ Iter) {
|
||||
{ for ( auto Iter = m_IterList.cbegin() ; Iter != m_IterList.cend() ; ++ Iter) {
|
||||
if ( *Iter == pIter) {
|
||||
m_IterList.erase( Iter) ;
|
||||
return true ;
|
||||
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2013
|
||||
//----------------------------------------------------------------------------
|
||||
// File : OffsetAux.cpp Data : 23.11.23 Versione : 2.5k5
|
||||
// Contenuto : Implementazione di alcune funzioni di utilità per gli offset delle curve.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 23.11.23 SP Creazione modulo spostando alcune funzioni da OffsetCurve.cpp.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "OffsetAux.h"
|
||||
#include "CurveArc.h"
|
||||
#include "CurveLine.h"
|
||||
#include "GeoConst.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IdentifyFillets( ICurveComposite* pCrvCo, double dDist)
|
||||
{
|
||||
// identifico le sottocurve di tipo fillet e assegno loro temp param 1.0 per riconoscerle nella funzione AdjustCurveFillets
|
||||
for ( int i = 0 ; i < pCrvCo->GetCurveCount() ; i ++) {
|
||||
// recupero la curva
|
||||
PtrOwner<ICurve> pCrv( pCrvCo->GetCurve(i)->Clone()) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
if ( IsFillet( pCrv, dDist))
|
||||
pCrvCo->SetCurveTempParam( i, 1.0) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IsFillet( ICurve* pCrv, double dDist)
|
||||
{
|
||||
// deve essere un arco
|
||||
if ( pCrv->GetType() != CRV_ARC)
|
||||
return false ;
|
||||
CurveArc* pArc = GetBasicCurveArc( pCrv) ;
|
||||
// deve avere raggio uguale alla distanza di offset
|
||||
if ( abs( pArc->GetRadius() - abs( dDist)) > EPS_SMALL)
|
||||
return false ;
|
||||
// deve essere CCW se offset a destra e CW se offset a sinistra
|
||||
return ( pArc->GetAngCenter() * dDist > 0) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
AdjustCurveFillets( ICurveComposite* pCrvCo, double dDist, int nType)
|
||||
{
|
||||
ICURVEPLIST CrvLst ;
|
||||
PtrOwner<ICurve> pCrv( pCrvCo->RemoveFirstOrLastCurve( false)) ;
|
||||
while ( ! IsNull( pCrv)) {
|
||||
// se identificato come fillet lo trasformo in smusso o estensione
|
||||
if ( pCrv->GetTempParam() > EPS_SMALL) {
|
||||
CurveComposite ccTemp ;
|
||||
ModifyFillet( pCrv, dDist, nType, ccTemp) ;
|
||||
// metto in lista le curve risultanti
|
||||
if ( ccTemp.GetCurveCount() > 0) {
|
||||
PtrOwner<ICurve> pCrv2( ccTemp.RemoveFirstOrLastCurve( false)) ;
|
||||
while ( ! IsNull( pCrv2)) {
|
||||
CrvLst.push_back( Release( pCrv2)) ;
|
||||
pCrv2.Set( ccTemp.RemoveFirstOrLastCurve( false)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// altrimenti salvo in lista
|
||||
else
|
||||
CrvLst.push_back( Release( pCrv)) ;
|
||||
// passo alla curva successiva
|
||||
pCrv.Set( pCrvCo->RemoveFirstOrLastCurve( false)) ;
|
||||
}
|
||||
// rimetto le curve nella composita
|
||||
for ( auto pCrv : CrvLst) {
|
||||
pCrvCo->AddCurve( pCrv) ;
|
||||
}
|
||||
// unisco tratti allineati
|
||||
pCrvCo->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ModifyFillet( ICurve* pCrv, double dDist, int nType, ICurveComposite& ccAux)
|
||||
{
|
||||
// la curva deve essere un arco
|
||||
CurveArc* pArc = GetBasicCurveArc( pCrv) ;
|
||||
if ( pArc == nullptr)
|
||||
return false ;
|
||||
|
||||
// angolo al centro dell'arco
|
||||
double dAngDeg = pArc->GetAngCenter() ;
|
||||
|
||||
// elimino dal tipo le parti estranee all'angolo esterno
|
||||
nType &= ( ICurve::OFF_FILLET | ICurve::OFF_CHAMFER | ICurve::OFF_EXTEND) ;
|
||||
|
||||
// se l'angolo esterno supera il retto, offset extend diventa offset chamfer
|
||||
if ( nType == ICurve::OFF_EXTEND && abs( dAngDeg) > ANG_RIGHT + EPS_ANG_SMALL)
|
||||
nType = ICurve::OFF_CHAMFER ;
|
||||
|
||||
// se angolo esterno molto piccolo, semplifico tutto
|
||||
const double SMALL_EXT_ANG = 1.0 ;
|
||||
bool bAngSmall = ( abs( dAngDeg) < SMALL_EXT_ANG) ;
|
||||
if ( bAngSmall)
|
||||
nType = ICurve::OFF_EXTEND ;
|
||||
|
||||
switch ( nType) {
|
||||
case ICurve::OFF_CHAMFER :
|
||||
{
|
||||
// lunghezza aggiuntiva in tangenza
|
||||
double dLen = abs( dDist) * tan( abs( dAngDeg) / 4 * DEGTORAD) ;
|
||||
// punti di costruzione smusso
|
||||
Point3d ptP1, ptP1a, ptP2a, ptP2 ;
|
||||
if ( ! pArc->GetStartPoint( ptP1) || ! pArc->GetEndPoint( ptP2))
|
||||
return false ;
|
||||
Vector3d vtDir1, vtDir2 ;
|
||||
if ( ! pArc->GetStartDir( vtDir1) || ! pArc->GetEndDir( vtDir2))
|
||||
return false ;
|
||||
ptP1a = ptP1 + vtDir1 * dLen ;
|
||||
ptP2a = ptP2 - vtDir2 * dLen ;
|
||||
// aggiungo una nuova linea
|
||||
PtrOwner<CurveLine> pLine1( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pLine1) || ! pLine1->Set( ptP1, ptP1a))
|
||||
return false ;
|
||||
if ( ! ccAux.AddCurve( Release( pLine1)))
|
||||
return false ;
|
||||
// tratto intermedio
|
||||
PtrOwner<CurveLine> pLine2( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pLine2) || ! pLine2->Set( ptP1a, ptP2a))
|
||||
return false ;
|
||||
if ( ! ccAux.AddCurve( Release( pLine2)))
|
||||
return false ;
|
||||
// aggiungo una nuova linea
|
||||
PtrOwner<CurveLine> pLine3( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pLine3) || ! pLine3->Set( ptP2a, ptP2))
|
||||
return false ;
|
||||
if ( ! ccAux.AddCurve( Release( pLine3)))
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
break ;
|
||||
case ICurve::OFF_EXTEND :
|
||||
{
|
||||
// lunghezza aggiuntiva in tangenza
|
||||
double dLen = abs( dDist) * tan( abs( dAngDeg) / 2 * DEGTORAD) ;
|
||||
// punti di costruzione estensione
|
||||
Point3d ptP1, ptPc, ptP2 ;
|
||||
if ( ! pArc->GetStartPoint( ptP1) || ! pArc->GetEndPoint( ptP2))
|
||||
return false ;
|
||||
Vector3d vtDir1, vtDir2 ;
|
||||
if ( ! pArc->GetStartDir( vtDir1) || ! pArc->GetEndDir( vtDir2))
|
||||
return false ;
|
||||
ptPc = ptP1 + vtDir1 * dLen ;
|
||||
// aggiungo una nuova linea
|
||||
PtrOwner<CurveLine> pLine1( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pLine1) || ! pLine1->Set( ptP1, ptPc))
|
||||
return false ;
|
||||
if ( ! ccAux.AddCurve( Release( pLine1)))
|
||||
return false ;
|
||||
// aggiungo una nuova linea
|
||||
PtrOwner<CurveLine> pLine2( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pLine2) || ! pLine2->Set( ptPc, ptP2))
|
||||
return false ;
|
||||
if ( ! ccAux.AddCurve( Release( pLine2)))
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2013
|
||||
//----------------------------------------------------------------------------
|
||||
// File : OffsetAux.h Data : 23.11.23 Versione : 2.5k5
|
||||
// Contenuto : Dichiarazione di alcune funzioni di utilità per gli offset delle curve.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 23.11.23 SP Creazione modulo spostando alcune funzioni da OffsetCurve.cpp.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
#include "CurveComposite.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool IdentifyFillets( ICurveComposite* pCrvCo, double dDist) ;
|
||||
bool IsFillet( ICurve* pCrv, double dDist) ;
|
||||
bool AdjustCurveFillets( ICurveComposite* pCrvCo, double dDist, int nType) ;
|
||||
bool ModifyFillet( ICurve* pCrv, double dDist, int nType, ICurveComposite& ccAux) ;
|
||||
+547
-619
File diff suppressed because it is too large
Load Diff
+14
-26
@@ -147,8 +147,7 @@ PolyArc::EraseLastUPoint( void)
|
||||
bool
|
||||
PolyArc::AddOffsetToU( double dOffset)
|
||||
{
|
||||
UPNTBLIST::iterator iter ;
|
||||
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
iter->dU += dOffset ;
|
||||
|
||||
return true ;
|
||||
@@ -173,8 +172,7 @@ PolyArc::ParamLinearTransform( double dStartU, double dEndU)
|
||||
else
|
||||
return false ;
|
||||
// eseguo la riparametrizzazione
|
||||
UPNTBLIST::iterator iter ;
|
||||
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
iter->dU = dStartU + dCoeff * ( iter->dU - dOriStartU) ;
|
||||
return true ;
|
||||
}
|
||||
@@ -183,8 +181,7 @@ PolyArc::ParamLinearTransform( double dStartU, double dEndU)
|
||||
bool
|
||||
PolyArc::SetElevation( double dZ)
|
||||
{
|
||||
UPNTBLIST::iterator iter ;
|
||||
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
iter->ptP.z = dZ ;
|
||||
|
||||
return true ;
|
||||
@@ -194,8 +191,7 @@ PolyArc::SetElevation( double dZ)
|
||||
bool
|
||||
PolyArc::AddElevation( double dZ)
|
||||
{
|
||||
UPNTBLIST::iterator iter ;
|
||||
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
iter->ptP.z += dZ ;
|
||||
|
||||
return true ;
|
||||
@@ -206,8 +202,7 @@ bool
|
||||
PolyArc::Translate( const Vector3d& vtMove)
|
||||
{
|
||||
// il vettore estrusione non subisce modifiche
|
||||
UPNTBLIST::iterator iter ;
|
||||
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
iter->ptP.Translate( vtMove) ;
|
||||
|
||||
return true ;
|
||||
@@ -218,8 +213,7 @@ bool
|
||||
PolyArc::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{
|
||||
m_vtExtr.Rotate( vtAx, dCosAng, dSinAng) ;
|
||||
UPNTBLIST::iterator iter ;
|
||||
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
iter->ptP.Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
|
||||
|
||||
return true ;
|
||||
@@ -230,8 +224,7 @@ bool
|
||||
PolyArc::Scale( const Frame3d& frRef, double dCoeff)
|
||||
{
|
||||
m_vtExtr.Scale( frRef, dCoeff, dCoeff, dCoeff) ;
|
||||
UPNTBLIST::iterator iter ;
|
||||
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
iter->ptP.Scale( frRef, dCoeff, dCoeff, dCoeff) ;
|
||||
|
||||
return true ;
|
||||
@@ -242,8 +235,7 @@ bool
|
||||
PolyArc::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
{
|
||||
m_vtExtr.Mirror( vtNorm) ;
|
||||
UPNTBLIST::iterator iter ;
|
||||
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) {
|
||||
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) {
|
||||
iter->ptP.Mirror( ptOn, vtNorm) ;
|
||||
iter->dB *= - 1 ;
|
||||
}
|
||||
@@ -256,8 +248,7 @@ bool
|
||||
PolyArc::ToGlob( const Frame3d& frRef)
|
||||
{
|
||||
m_vtExtr.ToGlob( frRef) ;
|
||||
UPNTBLIST::iterator iter ;
|
||||
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
iter->ptP.ToGlob( frRef) ;
|
||||
|
||||
return true ;
|
||||
@@ -268,8 +259,7 @@ bool
|
||||
PolyArc::ToLoc( const Frame3d& frRef)
|
||||
{
|
||||
m_vtExtr.ToLoc( frRef) ;
|
||||
UPNTBLIST::iterator iter ;
|
||||
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
iter->ptP.ToLoc( frRef) ;
|
||||
|
||||
return true ;
|
||||
@@ -284,8 +274,7 @@ PolyArc::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
return true ;
|
||||
// ciclo sui punti
|
||||
m_vtExtr.LocToLoc( frOri, frDest) ;
|
||||
UPNTBLIST::iterator iter ;
|
||||
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
|
||||
iter->ptP.LocToLoc( frOri, frDest) ;
|
||||
|
||||
return true ;
|
||||
@@ -319,8 +308,7 @@ PolyArc::Split( double dU, PolyArc& PA)
|
||||
// pulisco la polilinea destinazione
|
||||
PA.Clear() ;
|
||||
// ricerca del punto in cui dividere
|
||||
UPNTBLIST::const_iterator iter ;
|
||||
iter = m_lUPointBs.begin() ;
|
||||
auto iter = m_lUPointBs.begin() ;
|
||||
while ( iter != m_lUPointBs.end() && iter->dU < ( dU + EPS_PARAM))
|
||||
++ iter ;
|
||||
if ( iter == m_lUPointBs.end())
|
||||
@@ -585,7 +573,7 @@ PolyArc::Invert( bool bInvertU)
|
||||
// inverto la lista
|
||||
m_lUPointBs.reverse() ;
|
||||
// sposto il bulge all'estremo iniziale di ogni tratto (l'ultimo non conta) e lo inverto
|
||||
for ( UPNTBLIST::iterator iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) {
|
||||
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) {
|
||||
if ( next( iter) != m_lUPointBs.end())
|
||||
iter->dB = - next( iter)->dB ;
|
||||
else
|
||||
@@ -596,7 +584,7 @@ PolyArc::Invert( bool bInvertU)
|
||||
// recupero il primo valore di U che è il vecchio finale ed è il riferimento di inversione
|
||||
double dUfin = m_lUPointBs.front().dU ;
|
||||
// ciclo su tutti gli elementi
|
||||
for ( UPNTBLIST::iterator iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) {
|
||||
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) {
|
||||
iter->dU = dUfin - iter->dU ;
|
||||
}
|
||||
}
|
||||
|
||||
+17
-21
@@ -28,9 +28,8 @@ using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
PolyLine::PolyLine( void)
|
||||
: m_nRejected( 0), m_nTempProp{0,0}, m_iter( m_lUPoints.end())
|
||||
{
|
||||
m_nRejected = 0 ;
|
||||
m_iter = m_lUPoints.end() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -140,8 +139,7 @@ PolyLine::EraseLastUPoint( void)
|
||||
bool
|
||||
PolyLine::AddOffsetToU( double dOffset)
|
||||
{
|
||||
PNTULIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->second += dOffset ;
|
||||
|
||||
return true ;
|
||||
@@ -151,8 +149,7 @@ PolyLine::AddOffsetToU( double dOffset)
|
||||
bool
|
||||
PolyLine::Translate( const Vector3d& vtMove)
|
||||
{
|
||||
PNTULIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->first.Translate( vtMove) ;
|
||||
|
||||
return true ;
|
||||
@@ -162,8 +159,7 @@ PolyLine::Translate( const Vector3d& vtMove)
|
||||
bool
|
||||
PolyLine::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{
|
||||
PNTULIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->first.Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
|
||||
|
||||
return true ;
|
||||
@@ -173,8 +169,7 @@ PolyLine::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, dou
|
||||
bool
|
||||
PolyLine::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
{
|
||||
PNTULIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->first.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
|
||||
|
||||
return true ;
|
||||
@@ -184,8 +179,7 @@ PolyLine::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
|
||||
bool
|
||||
PolyLine::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
{
|
||||
PNTULIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->first.Mirror( ptOn, vtNorm) ;
|
||||
|
||||
return true ;
|
||||
@@ -195,8 +189,7 @@ PolyLine::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
bool
|
||||
PolyLine::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{
|
||||
PNTULIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->first.Shear( ptOn, vtNorm, vtDir, dCoeff) ;
|
||||
|
||||
return true ;
|
||||
@@ -206,8 +199,7 @@ PolyLine::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vt
|
||||
bool
|
||||
PolyLine::ToGlob( const Frame3d& frRef)
|
||||
{
|
||||
PNTULIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->first.ToGlob( frRef) ;
|
||||
|
||||
return true ;
|
||||
@@ -217,8 +209,7 @@ PolyLine::ToGlob( const Frame3d& frRef)
|
||||
bool
|
||||
PolyLine::ToLoc( const Frame3d& frRef)
|
||||
{
|
||||
PNTULIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->first.ToLoc( frRef) ;
|
||||
|
||||
return true ;
|
||||
@@ -232,8 +223,7 @@ PolyLine::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
// ciclo sui punti
|
||||
PNTULIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->first.LocToLoc( frOri, frDest) ;
|
||||
|
||||
return true ;
|
||||
@@ -655,6 +645,12 @@ PolyLine::GetAreaXY( double& dArea) const
|
||||
for ( bool bFound = GetFirstLine( ptIni, ptFin) ; bFound ; bFound = GetNextLine( ptIni, ptFin)) {
|
||||
dArea += ( ptIni.x - ptFin.x) * ( ptIni.y + ptFin.y) ; // projection on xy
|
||||
}
|
||||
// considero anche la linea tra l'ultimo e il primo punto perchè in alcuni casi potrebbero definire area
|
||||
// significativa anche se sono coincidenti per le nostre tolleranze
|
||||
ptIni = ptFin ;
|
||||
GetFirstPoint( ptFin) ;
|
||||
if ( ! AreSamePointExact( ptIni, ptFin))
|
||||
dArea += ( ptIni.x - ptFin.x) * ( ptIni.y + ptFin.y) ;
|
||||
dArea = 0.5 * dArea ;
|
||||
return true ;
|
||||
}
|
||||
@@ -684,7 +680,7 @@ PolyLine::GetMaxDistanceFromLine( const Point3d& ptLine, const Vector3d& vtLine,
|
||||
bool
|
||||
PolyLine::AdjustForMaxSegmentLen( double dMaxLen)
|
||||
{
|
||||
PNTULIST::iterator iter = m_lUPoints.begin() ;
|
||||
auto iter = m_lUPoints.begin() ;
|
||||
// se non ci sono punti, esco subito
|
||||
if ( iter == m_lUPoints.end())
|
||||
return false ;
|
||||
|
||||
@@ -471,6 +471,18 @@ Polygon3d::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Polygon3d::GetLocalBBox( BBox3d& b3Loc) const
|
||||
{
|
||||
// assegno il box in locale, scorrendo tutti i punti del contorno
|
||||
b3Loc.Reset() ;
|
||||
for ( const auto& ptP : m_vVert)
|
||||
b3Loc.Add( ptP) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Polygon3d::Invert( void)
|
||||
|
||||
@@ -0,0 +1,224 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2023-2023
|
||||
//----------------------------------------------------------------------------
|
||||
// File : PolygonElevation.cpp Data : 17.12.23 Versione : 2.5l3
|
||||
// Contenuto : Implementazione di funzioni per calcolo elevazione di
|
||||
// un poligono (faccia piana) in solidi di diverso tipo.
|
||||
//
|
||||
//
|
||||
// Modifiche : 17.12.23 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CurveLine.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineBox.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EGkPolygonElevation.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
PolygonElevationInBBox( const Polygon3d& pgFacet, const BBox3d& b3Box, bool bAcceptOutFacet, double& dElev)
|
||||
{
|
||||
// verifico validità del poligono e del box
|
||||
if ( ! pgFacet.IsValid() || b3Box.IsEmpty())
|
||||
return false ;
|
||||
|
||||
// se richiesto, verifico che la faccia sia contenuta nel box
|
||||
if ( ! bAcceptOutFacet) {
|
||||
BBox3d b3Fac ;
|
||||
if ( ! pgFacet.GetLocalBBox( b3Fac))
|
||||
return false ;
|
||||
BBox3d b3ExpBox = b3Box ; b3ExpBox.Expand( 100 * EPS_SMALL) ;
|
||||
if ( ! b3ExpBox.Encloses( b3Fac)) {
|
||||
dElev = -1 ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
// recupero centro, normale e contorno delle faccia poligonale
|
||||
Point3d ptCen = pgFacet.GetCentroid() ;
|
||||
Vector3d vtN = pgFacet.GetVersN() ;
|
||||
PolyLine PL = pgFacet.GetPolyLine() ;
|
||||
|
||||
// calcolo elevazione massima del contorno della faccia
|
||||
const double RAY_LEN = 100000 ;
|
||||
dElev = 0 ;
|
||||
Point3d ptP ;
|
||||
bool bFound = PL.GetFirstPoint( ptP) ;
|
||||
while ( bFound) {
|
||||
INTDBLVECTOR vInters ;
|
||||
IntersLineBox( ptP, vtN, RAY_LEN, b3Box, vInters, true) ;
|
||||
for ( int i = 0 ; i < int( vInters.size()) ; ++ i) {
|
||||
if ( i == 0 && ( vInters[i].first == ILBT_IN || vInters[i].first == ILBT_TG_INI)) {
|
||||
if ( ! bAcceptOutFacet && vInters[i].second > 100 * EPS_SMALL) {
|
||||
dElev = -1 ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
else if ( vInters[i].first == ILBT_OUT || vInters[i].first == ILBT_TG_FIN)
|
||||
dElev = max( dElev, vInters[i].second) ;
|
||||
}
|
||||
bFound = PL.GetNextPoint( ptP, true) ;
|
||||
}
|
||||
|
||||
// calcolo elevazione massima degli eventuali spigoli (e vertici) del box dalla parte positiva della faccia e che cadono in essa
|
||||
BIPNTVECTOR vEdges( 12) ;
|
||||
vEdges[0].first = b3Box.GetMin() ; vEdges[0].second = vEdges[0].first + b3Box.GetDimX() * X_AX ;
|
||||
vEdges[1].first = vEdges[0].second ; vEdges[1].second = vEdges[1].first + b3Box.GetDimY() * Y_AX ;
|
||||
vEdges[2].first = vEdges[1].second ; vEdges[2].second = vEdges[0].first + b3Box.GetDimY() * Y_AX ;
|
||||
vEdges[3].first = vEdges[2].second ; vEdges[3].second = vEdges[0].first ;
|
||||
vEdges[4].first = vEdges[0].first + b3Box.GetDimZ() * Z_AX ; vEdges[4].second = vEdges[0].second + b3Box.GetDimZ() * Z_AX ;
|
||||
vEdges[5].first = vEdges[1].first + b3Box.GetDimZ() * Z_AX ; vEdges[5].second = vEdges[1].second + b3Box.GetDimZ() * Z_AX ;
|
||||
vEdges[6].first = vEdges[2].first + b3Box.GetDimZ() * Z_AX ; vEdges[6].second = vEdges[2].second + b3Box.GetDimZ() * Z_AX ;
|
||||
vEdges[7].first = vEdges[3].first + b3Box.GetDimZ() * Z_AX ; vEdges[7].second = vEdges[3].second + b3Box.GetDimZ() * Z_AX ;
|
||||
vEdges[8].first = vEdges[0].first ; vEdges[8].second = vEdges[4].first ;
|
||||
vEdges[9].first = vEdges[1].first ; vEdges[9].second = vEdges[5].first ;
|
||||
vEdges[10].first = vEdges[2].first ; vEdges[10].second = vEdges[6].first ;
|
||||
vEdges[11].first = vEdges[3].first ; vEdges[11].second = vEdges[7].first ;
|
||||
// porto tutto nel riferimento intrinseco della faccia (già calcolato in quello del box)
|
||||
Frame3d frOcs ; frOcs.Set( ptCen, vtN) ;
|
||||
PL.ToLoc( frOcs) ;
|
||||
for ( int i = 0 ; i < int( vEdges.size()) ; ++ i) {
|
||||
vEdges[i].first.ToLoc( frOcs) ;
|
||||
vEdges[i].second.ToLoc( frOcs) ;
|
||||
}
|
||||
// calcolo la curva di loop
|
||||
CurveComposite ccLoop ;
|
||||
if ( ! ccLoop.FromPolyLine( PL))
|
||||
return false ;
|
||||
// eseguo i calcoli di elevazione
|
||||
for ( int i = 0 ; i < int( vEdges.size()) ; ++ i) {
|
||||
// se sta sul piano o sotto, lo salto
|
||||
if ( vEdges[i].first.z < EPS_SMALL && vEdges[i].second.z < EPS_SMALL)
|
||||
continue ;
|
||||
// calcolo il segmento di linea
|
||||
CurveLine clLine ;
|
||||
if ( ! clLine.Set( vEdges[i].first, vEdges[i].second))
|
||||
return false ;
|
||||
// l'elevazione va aggiornata con la massima Z delle eventuali intersezioni dell'edge con il loop
|
||||
IntersCurveCurve intLL( clLine, ccLoop) ;
|
||||
IntCrvCrvInfo aInfo ;
|
||||
for ( int j = 0 ; intLL.GetIntCrvCrvInfo( j, aInfo) ; ++ j) {
|
||||
dElev = max( dElev, aInfo.IciA[0].ptI.z) ;
|
||||
if ( aInfo.bOverlap)
|
||||
dElev = max( dElev, aInfo.IciA[1].ptI.z) ;
|
||||
// se prima intersezione va da interno ad esterno allora devo considerare il punto iniziale del segmento (vertice)
|
||||
if ( j == 0 && aInfo.IciA[0].nPrevTy == ICCT_IN)
|
||||
dElev = max( dElev, vEdges[i].first.z) ;
|
||||
// c'è anche il caso di ultima intersezione da esterno a interno, ma vertice già considerato nel caso precedente
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
PolygonElevationInClosedSurfTm( const Polygon3d& pgFacet, const ISurfTriMesh& CldStm, bool bAcceptOutFacet, double& dElev)
|
||||
{
|
||||
// verifico validità del poligono e della superficie
|
||||
if ( ! pgFacet.IsValid() || ! CldStm.IsValid() || ! CldStm.IsClosed())
|
||||
return false ;
|
||||
|
||||
// se superficie vuota
|
||||
if ( CldStm.IsEmpty()) {
|
||||
dElev = ( bAcceptOutFacet ? 0 : -1) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
// se richiesto, verifico sia contenuta nel box della superficie chiusa
|
||||
if ( ! bAcceptOutFacet) {
|
||||
BBox3d b3Fac ;
|
||||
if ( ! pgFacet.GetLocalBBox( b3Fac))
|
||||
return false ;
|
||||
BBox3d b3ExpCldStm ; CldStm.GetLocalBBox( b3ExpCldStm) ; b3ExpCldStm.Expand( 100 * EPS_SMALL) ;
|
||||
if ( ! b3ExpCldStm.Encloses( b3Fac)) {
|
||||
dElev = -1 ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
// recupero centro, normale e contorno delle faccia poligonale
|
||||
Point3d ptCen = pgFacet.GetCentroid() ;
|
||||
Vector3d vtN = pgFacet.GetVersN() ;
|
||||
PolyLine PL = pgFacet.GetPolyLine() ;
|
||||
|
||||
// calcolo elevazione massima del contorno della faccia
|
||||
const double RAY_LEN = 100000 ;
|
||||
dElev = 0 ;
|
||||
Point3d ptP ;
|
||||
bool bFound = PL.GetFirstPoint( ptP) ;
|
||||
while ( bFound) {
|
||||
ILSIVECTOR vInters ;
|
||||
IntersLineSurfTm( ptP, vtN, RAY_LEN, CldStm, vInters, true) ;
|
||||
for ( int i = 0 ; i < int( vInters.size()) ; ++ i) {
|
||||
const auto& Inters = vInters[i] ;
|
||||
if ( i == 0 && Inters.nILTT != ILTT_NO && Inters.dCosDN < -EPS_ZERO) {
|
||||
if ( ! bAcceptOutFacet && Inters.dU > 100 * EPS_SMALL) {
|
||||
dElev = -1 ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
else if ( ( Inters.nILTT == ILTT_VERT || Inters.nILTT == ILTT_EDGE || Inters.nILTT == ILTT_IN) && Inters.dCosDN > EPS_ZERO)
|
||||
dElev = max( dElev, Inters.dU) ;
|
||||
else if ( Inters.nILTT == ILTT_SEGM || Inters.nILTT == ILTT_SEGM_ON_EDGE)
|
||||
dElev = max( dElev, Inters.dU2) ;
|
||||
}
|
||||
bFound = PL.GetNextPoint( ptP, true) ;
|
||||
}
|
||||
// calcolo elevazione massima degli eventuali spigoli (e vertici) della superficie chiusa dalla parte positiva della faccia e che cadono in essa
|
||||
int nEdgeCnt = CldStm.GetEdgeCount() ;
|
||||
if ( nEdgeCnt < 0)
|
||||
return false ;
|
||||
BIPNTVECTOR vEdges ;
|
||||
vEdges.reserve( nEdgeCnt) ;
|
||||
for ( int i = 0 ; i < nEdgeCnt ; ++ i) {
|
||||
Point3d ptP1, ptP2 ; double dAng ;
|
||||
CldStm.GetEdge( i, ptP1, ptP2, dAng) ;
|
||||
vEdges.emplace_back( ptP1, ptP2) ;
|
||||
}
|
||||
// porto tutto nel riferimento intrinseco della faccia (già calcolato in quello della superficie chiusa)
|
||||
Frame3d frOcs ; frOcs.Set( ptCen, vtN) ;
|
||||
PL.ToLoc( frOcs) ;
|
||||
for ( int i = 0 ; i < int( vEdges.size()) ; ++ i) {
|
||||
vEdges[i].first.ToLoc( frOcs) ;
|
||||
vEdges[i].second.ToLoc( frOcs) ;
|
||||
}
|
||||
// calcolo la curva di loop
|
||||
CurveComposite ccLoop ;
|
||||
if ( ! ccLoop.FromPolyLine( PL))
|
||||
return false ;
|
||||
// eseguo i calcoli di elevazione
|
||||
for ( int i = 0 ; i < int( vEdges.size()) ; ++ i) {
|
||||
// se sta sul piano o sotto, lo salto
|
||||
if ( vEdges[i].first.z < EPS_SMALL && vEdges[i].second.z < EPS_SMALL)
|
||||
continue ;
|
||||
// calcolo il segmento di linea
|
||||
CurveLine clLine ;
|
||||
if ( ! clLine.Set( vEdges[i].first, vEdges[i].second))
|
||||
return false ;
|
||||
// l'elevazione va aggiornata con la massima Z delle eventuali intersezioni dell'edge con il loop
|
||||
IntersCurveCurve intLL( clLine, ccLoop) ;
|
||||
IntCrvCrvInfo aInfo ;
|
||||
for ( int j = 0 ; intLL.GetIntCrvCrvInfo( j, aInfo) ; ++ j) {
|
||||
dElev = max( dElev, aInfo.IciA[0].ptI.z) ;
|
||||
if ( aInfo.bOverlap)
|
||||
dElev = max( dElev, aInfo.IciA[1].ptI.z) ;
|
||||
// se prima intersezione va da interno ad esterno allora devo considerare il punto iniziale del segmento (vertice)
|
||||
if ( j == 0 && aInfo.IciA[0].nPrevTy == ICCT_IN)
|
||||
dElev = max( dElev, vEdges[i].first.z) ;
|
||||
// se ultima intersezione va da esterno a interno allora devo considerare il punto finale del segmento (vertice)
|
||||
else if ( j == intLL.GetIntersCount() - 1 && aInfo.IciA[ aInfo.bOverlap ? 1 : 0].nNextTy == ICCT_IN)
|
||||
dElev = max( dElev, vEdges[i].second.z) ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2023-2023
|
||||
//----------------------------------------------------------------------------
|
||||
// File : ProjectCurveSurfTm.cpp Data : 16.11.23 Versione : 2.5kh3
|
||||
// Contenuto : Implementazione funzioni proiezione curve su superficie Trimesh.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 31.08.23 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkProjectCurveSurfTm.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
PointsInTolerance( const PNT5AXVECTOR& vPt5ax, int nPrec, int nCurr, int nNext, double dSqTol)
|
||||
{
|
||||
for ( int i = nPrec + 1 ; i < nCurr ; ++ i) {
|
||||
double dSqDist ;
|
||||
if ( ! DistPointLine( vPt5ax[i].ptP, vPt5ax[nPrec].ptP, vPt5ax[nNext].ptP).GetSqDist( dSqDist) || dSqDist > dSqTol)
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ProjectCurveOnSurfTm( const ICurve& crCrv, const ISurfTriMesh& tmSurf, const Vector3d& vtDir, double dLinTol,
|
||||
PNT5AXVECTOR& vPt5ax)
|
||||
{
|
||||
// approssimo la curva con una polilinea entro la metà della tolleranza
|
||||
PolyLine PL ;
|
||||
if ( ! crCrv.ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
||||
return false ;
|
||||
const double MAX_SEG_LEN = 1 ;
|
||||
if ( ! PL.AdjustForMaxSegmentLen( MAX_SEG_LEN))
|
||||
return false ;
|
||||
|
||||
// Oggetto per calcolo massivo intersezioni tra linee di proiezione e superficie
|
||||
Frame3d frRefLine ;
|
||||
if ( ! frRefLine.Set( ORIG, vtDir))
|
||||
return false ;
|
||||
IntersParLinesSurfTm intPLSTM( frRefLine, tmSurf) ;
|
||||
|
||||
// Vettore locale dei punti risultanti
|
||||
PNT5AXVECTOR vMyPt5ax ;
|
||||
vMyPt5ax.reserve( PL.GetPointNbr()) ;
|
||||
|
||||
// proietto i punti della polilinea sulla superficie
|
||||
double dU ;
|
||||
Point3d ptP ;
|
||||
bool bFound = PL.GetFirstUPoint( &dU, &ptP) ;
|
||||
while ( bFound) {
|
||||
Point3d ptL = GetToLoc( ptP, frRefLine) ;
|
||||
ILSIVECTOR vIntRes ;
|
||||
intPLSTM.GetInters( ptL, 1, vIntRes, false) ;
|
||||
if ( vIntRes.size() > 0) {
|
||||
// calcolo il punto
|
||||
int nI = int( vIntRes.size()) - 1 ;
|
||||
Point3d ptInt ;
|
||||
if ( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE)
|
||||
ptInt = vIntRes[nI].ptI2 ;
|
||||
else
|
||||
ptInt = vIntRes[nI].ptI ;
|
||||
// calcolo la normale (si calcola smooth, in caso di errore si prende quella del triangolo)
|
||||
Triangle3dEx trTria ;
|
||||
if ( ! tmSurf.GetTriangle( vIntRes[nI].nT, trTria))
|
||||
return false ;
|
||||
Vector3d vtN ;
|
||||
double dU, dV, dW ;
|
||||
if ( BarycentricCoord( ptInt, trTria, dU, dV, dW))
|
||||
vtN = dU * trTria.GetVertexNorm( 0) + dV * trTria.GetVertexNorm( 1) + dW * trTria.GetVertexNorm( 2) ;
|
||||
if ( ! vtN.Normalize())
|
||||
vtN = trTria.GetN() ;
|
||||
// aggiungo al vettore dei proiettati
|
||||
vMyPt5ax.emplace_back( ptInt, vtN, dU, 1) ;
|
||||
}
|
||||
bFound = PL.GetNextUPoint( &dU, &ptP) ;
|
||||
}
|
||||
|
||||
// rimuovo i punti allineati entro la tolleranza
|
||||
double dSqTol = dLinTol * dLinTol ;
|
||||
int nPrec = 0 ;
|
||||
int nCurr = 1 ;
|
||||
int nNext = 2 ;
|
||||
while ( nNext < int( vMyPt5ax.size())) {
|
||||
bool bRemove = false ;
|
||||
// distanza del punto corrente dal segmento che unisce gli adiacenti
|
||||
DistPointLine dPL( vMyPt5ax[nCurr].ptP, vMyPt5ax[nPrec].ptP, vMyPt5ax[nNext].ptP) ;
|
||||
double dSqDist ;
|
||||
// se distanza inferiore a tolleranza lineare
|
||||
if ( dPL.GetSqDist( dSqDist) && dSqDist < dSqTol && PointsInTolerance( vMyPt5ax, nPrec, nCurr, nNext, dSqTol)) {
|
||||
// verifico se errore angolare inferiore a limite
|
||||
double dPar ; dPL.GetParamAtMinDistPoint( dPar) ;
|
||||
Vector3d vtNew = Media( vMyPt5ax[nPrec].vtDir, vMyPt5ax[nNext].vtDir, dPar) ;
|
||||
if ( vtNew.Normalize() && vtNew * vMyPt5ax[nCurr].vtDir > cos( 2 * DEGTORAD))
|
||||
bRemove = true ;
|
||||
}
|
||||
// se da eliminare
|
||||
if ( bRemove) {
|
||||
// dichiaro da eliminare il punto
|
||||
vMyPt5ax[nCurr].nFlag = -1 ;
|
||||
// avanzo con corrente e successivo
|
||||
nCurr = nNext ;
|
||||
++ nNext ;
|
||||
}
|
||||
// altrimenti da tenere
|
||||
else {
|
||||
// avanzo il terzetto di uno step
|
||||
nPrec = nCurr ;
|
||||
nCurr = nNext ;
|
||||
++ nNext ;
|
||||
}
|
||||
}
|
||||
|
||||
// copio i punti rimasti nel vettore di ritorno
|
||||
vPt5ax.clear() ;
|
||||
for ( const auto& Pt5ax : vMyPt5ax) {
|
||||
if ( Pt5ax.nFlag != -1)
|
||||
vPt5ax.emplace_back( Pt5ax) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -135,3 +135,73 @@ RemoveCurveSmallZs( ICurveComposite* pCurve, double dLinTol)
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
RemoveCurveSmallParts( 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 ;
|
||||
|
||||
// se aperta, verifico le due curve agli estremi
|
||||
if ( ! pCurve->IsClosed()) {
|
||||
// curva iniziale
|
||||
const ICurve* pFirstCrv = pCurve->GetFirstCurve() ;
|
||||
double dFirstLen ; pFirstCrv->GetLength( dFirstLen) ;
|
||||
if ( dFirstLen < dLinTol) {
|
||||
Point3d ptStart ; pFirstCrv->GetStartPoint( ptStart) ;
|
||||
delete( pCurve->RemoveFirstOrLastCurve( false)) ;
|
||||
pCurve->ModifyStart( ptStart) ;
|
||||
-- nCrvCount ;
|
||||
}
|
||||
// curva finale
|
||||
const ICurve* pLastCrv = pCurve->GetLastCurve() ;
|
||||
double dLastLen ; pLastCrv->GetLength( dLastLen) ;
|
||||
if ( dLastLen < dLinTol) {
|
||||
Point3d ptEnd ; pLastCrv->GetStartPoint( ptEnd) ;
|
||||
delete( pCurve->RemoveFirstOrLastCurve( true)) ;
|
||||
pCurve->ModifyEnd( ptEnd) ;
|
||||
-- nCrvCount ;
|
||||
}
|
||||
}
|
||||
|
||||
// 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 la curva corrente
|
||||
const ICurve* pCurrCrv = pCurve->GetCurve( i) ;
|
||||
// se la curva corrente è troppo corta
|
||||
double dLen ; pCurrCrv->GetLength( dLen) ;
|
||||
if ( dLen < dLinTol) {
|
||||
// recupero il punto medio della curva
|
||||
Point3d ptMid ; pCurrCrv->GetMidPoint( ptMid) ;
|
||||
// rimuovo il segmento
|
||||
if ( pCurve->RemoveJoint( i)) {
|
||||
// porto il nuovo estremo sul punto medio
|
||||
pCurve->ModifyJoint( i, ptMid) ;
|
||||
// aggiorno valore di i tenendo conto che ModifyJoint potrebbe modificare la curva precedente
|
||||
// che quindi va ricontrollata
|
||||
i = max( i - 2, nStart - 1) ;
|
||||
// aggiorno valore di nEnd ( ModifyJoint potrebbe aver rimosso la curva precedente e la successiva)
|
||||
nEnd = pCurve->GetCurveCount() - ( pCurve->IsClosed() ? 0 : 1) ;
|
||||
}
|
||||
// altrimenti rimuovo anche il successivo
|
||||
else if ( pCurve->RemoveJoint( i + 1)) {
|
||||
pCurve->RemoveJoint( i) ;
|
||||
pCurve->ModifyJoint( i, ptMid) ;
|
||||
i = max( i - 2, nStart - 1) ;
|
||||
nEnd = pCurve->GetCurveCount() - ( pCurve->IsClosed() ? 0 : 1) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2017-2022
|
||||
//----------------------------------------------------------------------------
|
||||
// File : RemoveCurveDefects.h Data : 13.11.22 Versione : 2.4k2
|
||||
// File : RemoveCurveDefects.h Data : 03.11.23 Versione : 2.5k1
|
||||
// Contenuto : Dichiarazione funzioni rimozione difetti curve.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 02.10.17 DS Creazione modulo.
|
||||
//
|
||||
// 03.11.23 DS Aggiunta RemoveCurveSmallParts.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -19,3 +19,4 @@
|
||||
//----------------------------------------------------------------------------
|
||||
bool RemoveCurveSpikes( ICurveComposite* pCurve, double dLinTol = EPS_SMALL) ;
|
||||
bool RemoveCurveSmallZs( ICurveComposite* pCurve, double dLinTol = EPS_SMALL) ;
|
||||
bool RemoveCurveSmallParts( ICurveComposite* pCurve, double dLinTol = EPS_SMALL) ;
|
||||
|
||||
+203
-181
@@ -19,6 +19,7 @@
|
||||
#include "SurfFlatRegion.h"
|
||||
#include "AdjustLoops.h"
|
||||
#include "GeoConst.h"
|
||||
#include "Voronoi.h"
|
||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||
#include "/EgtDev/Include/EGkBiArcs.h"
|
||||
#include "/EgtDev/Include/EGkOffsetCurve.h"
|
||||
@@ -114,9 +115,11 @@ GetSurfFlatRegionDisk( double dRadius)
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
ISurfFlatRegion*
|
||||
GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, bool bSquareMids)
|
||||
GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, bool bSquareMids, double dOffsLinTol)
|
||||
{
|
||||
// mi impossesso della curva
|
||||
// metodo di calcolo impostato da USE_VORONOI
|
||||
|
||||
// mi impossesso della curva
|
||||
PtrOwner<ICurve> pCurve( pCrv) ;
|
||||
if ( IsNull( pCurve))
|
||||
return nullptr ;
|
||||
@@ -124,200 +127,219 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b
|
||||
Vector3d vtExtr ; pCrv->GetExtrusion( vtExtr) ;
|
||||
if ( vtExtr.IsSmall())
|
||||
vtExtr = Z_AX ;
|
||||
PtrOwner<CurveComposite> pCompo1 ;
|
||||
if ( ! pCompo1.Set( ConvertCurveToBasicComposite( Release( pCurve))))
|
||||
return nullptr ;
|
||||
pCompo1->SetExtrusion( vtExtr) ;
|
||||
// se distanza tra gli estremi minore di due volte il raggio la chiudo, purchè curva abbastanza lunga
|
||||
Point3d ptStart, ptEnd, ptMid ;
|
||||
Vector3d vtStart, vtEnd ;
|
||||
pCompo1->GetStartPoint( ptStart) ;
|
||||
pCompo1->GetStartDir( vtStart) ;
|
||||
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)) ;
|
||||
// aggiungo il biarco
|
||||
if ( ! IsNull( pClose)) {
|
||||
// porto il biarco in globale
|
||||
pClose->ToGlob( frLoc) ;
|
||||
pCompo1->AddCurve( Release( pClose)) ;
|
||||
}
|
||||
else
|
||||
pCompo1->Close() ;
|
||||
}
|
||||
}
|
||||
// tipo di offset
|
||||
int nOffsType = ( bSquareMids ? ICurve::OFF_EXTEND : ICurve::OFF_FILLET) ;
|
||||
// se curva chiusa
|
||||
if ( pCompo1->IsClosed()) {
|
||||
// fondo le curve allineate
|
||||
pCompo1->MergeCurves( LIN_TOL_FINE, ANG_TOL_STD_DEG) ;
|
||||
// ne faccio una copia e la inverto
|
||||
PtrOwner<CurveComposite> pCompo2( pCompo1->Clone()) ;
|
||||
if ( IsNull( pCompo2) || ! pCompo2->Invert())
|
||||
return nullptr ;
|
||||
// per creare 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() ;
|
||||
while ( 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))
|
||||
// ----------------- CALCOLO STANDARD --------------------------------
|
||||
if ( ! USE_VORONOI) {
|
||||
PtrOwner<CurveComposite> pCompo1 ;
|
||||
if ( ! pCompo1.Set( ConvertCurveToBasicComposite( Release( pCurve))))
|
||||
return nullptr ;
|
||||
ICurve* pOffs2 = OffsCrv2.GetLongerCurve() ;
|
||||
while ( pOffs2 != nullptr) {
|
||||
SfrCntr.AddCurve( pOffs2) ;
|
||||
pOffs2 = OffsCrv2.GetLongerCurve() ;
|
||||
pCompo1->SetExtrusion( vtExtr) ;
|
||||
// se distanza tra gli estremi minore di due volte il raggio la chiudo, purchè curva abbastanza lunga
|
||||
Point3d ptStart, ptEnd, ptMid ;
|
||||
Vector3d vtStart, vtEnd ;
|
||||
pCompo1->GetStartPoint( ptStart) ;
|
||||
pCompo1->GetStartDir( vtStart) ;
|
||||
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)) ;
|
||||
// aggiungo il biarco
|
||||
if ( ! IsNull( pClose)) {
|
||||
// porto il biarco in globale
|
||||
pClose->ToGlob( frLoc) ;
|
||||
pCompo1->AddCurve( Release( pClose)) ;
|
||||
}
|
||||
else
|
||||
pCompo1->Close() ;
|
||||
}
|
||||
}
|
||||
|
||||
// creo la regione
|
||||
return SfrCntr.GetSurf() ;
|
||||
}
|
||||
// altrimenti
|
||||
else {
|
||||
// se richiesti estremi squadrati, la allungo del raggio alle due estremità
|
||||
if ( bSquareEnds) {
|
||||
pCompo1->ExtendStartByLen( dRadius) ;
|
||||
pCompo1->ExtendEndByLen( dRadius) ;
|
||||
}
|
||||
// fondo le curve allineate
|
||||
pCompo1->MergeCurves( LIN_TOL_FINE, ANG_TOL_STD_DEG) ;
|
||||
// ne faccio una copia e la inverto
|
||||
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())
|
||||
// tipo di offset
|
||||
int nOffsType = ( bSquareMids ? ICurve::OFF_EXTEND : ICurve::OFF_FILLET) ;
|
||||
// se curva chiusa
|
||||
if ( pCompo1->IsClosed()) {
|
||||
// fondo le curve allineate
|
||||
pCompo1->MergeCurves( LIN_TOL_FINE, ANG_TOL_STD_DEG) ;
|
||||
// ne faccio una copia e la inverto
|
||||
PtrOwner<CurveComposite> pCompo2( pCompo1->Clone()) ;
|
||||
if ( IsNull( pCompo2) || ! pCompo2->Invert())
|
||||
return nullptr ;
|
||||
// per creare la regione
|
||||
SurfFlatRegionByContours SfrCntr( false, false) ;
|
||||
// offset della prima curva a destra del raggio
|
||||
OffsetCurve OffsCrv1( dOffsLinTol) ;
|
||||
if ( ! OffsCrv1.Make( pCompo1, dRadius, nOffsType))
|
||||
return nullptr ;
|
||||
ICurve* pOffs1 = OffsCrv1.GetLongerCurve() ;
|
||||
while ( pOffs1 != nullptr) {
|
||||
SfrCntr.AddCurve( pOffs1) ;
|
||||
else
|
||||
pCompo1->AddCurve( pOffs1) ;
|
||||
pOffs1 = OffsCrv1.GetLongerCurve() ;
|
||||
}
|
||||
|
||||
// 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())
|
||||
pOffs1 = OffsCrv1.GetLongerCurve() ;
|
||||
}
|
||||
|
||||
// offset della seconda curva a destra del raggio (è invertita rispetto alla precedente)
|
||||
OffsetCurve OffsCrv2( dOffsLinTol) ;
|
||||
if ( ! OffsCrv2.Make( pCompo2, dRadius, nOffsType))
|
||||
return nullptr ;
|
||||
ICurve* pOffs2 = OffsCrv2.GetLongerCurve() ;
|
||||
while ( pOffs2 != nullptr) {
|
||||
SfrCntr.AddCurve( pOffs2) ;
|
||||
else
|
||||
pCompo2->AddCurve( pOffs2) ;
|
||||
pOffs2 = OffsCrv2.GetLongerCurve() ;
|
||||
pOffs2 = OffsCrv2.GetLongerCurve() ;
|
||||
}
|
||||
|
||||
// creo la regione
|
||||
return SfrCntr.GetSurf() ;
|
||||
}
|
||||
|
||||
// se estremi squadrati
|
||||
if ( bSquareEnds) {
|
||||
// aggiungo alla prima curva una linea che la unisca alla seconda
|
||||
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
||||
Point3d ptEnd1, ptStart2 ;
|
||||
if ( IsNull( pLine) ||
|
||||
! pCompo1->GetEndPoint( ptEnd1) ||
|
||||
! pCompo2->GetStartPoint( ptStart2) ||
|
||||
! pLine->Set( ptEnd1, ptStart2) ||
|
||||
! pCompo1->AddCurve( Release( pLine)))
|
||||
return nullptr ;
|
||||
// unisco le due curve composite e le chiudo
|
||||
if ( ! pCompo1->AddCurve( Release( pCompo2)) || ! pCompo1->Close())
|
||||
return nullptr ;
|
||||
}
|
||||
// altrimenti estremi arrotondati
|
||||
// altrimenti
|
||||
else {
|
||||
// aggiungo alla prima curva un arco che la unisca alla seconda
|
||||
PtrOwner<CurveArc> pArc1( CreateBasicCurveArc()) ;
|
||||
Point3d ptEnd1, ptStart2 ;
|
||||
Vector3d vtEnd1, vtStart2 ;
|
||||
if ( IsNull( pArc1) ||
|
||||
! pCompo1->GetEndPoint( ptEnd1) ||
|
||||
! pCompo1->GetEndDir( vtEnd1) ||
|
||||
! pCompo2->GetStartPoint( ptStart2) ||
|
||||
! pCompo2->GetStartDir( vtStart2))
|
||||
// se richiesti estremi squadrati, la allungo del raggio alle due estremità
|
||||
if ( bSquareEnds) {
|
||||
pCompo1->ExtendStartByLen( dRadius) ;
|
||||
pCompo1->ExtendEndByLen( dRadius) ;
|
||||
}
|
||||
// fondo le curve allineate
|
||||
pCompo1->MergeCurves( LIN_TOL_FINE, ANG_TOL_STD_DEG) ;
|
||||
// ne faccio una copia e la inverto
|
||||
PtrOwner<CurveComposite> pCompo2( pCompo1->Clone()) ;
|
||||
if ( IsNull( pCompo2) || ! pCompo2->Invert())
|
||||
return nullptr ;
|
||||
// verifico se arco tangente alla prima o alla seconda curva
|
||||
if ( AreSameVectorApprox( vtEnd1, vtEnd)) {
|
||||
if ( ! pArc1->Set2PVN( ptEnd1, ptStart2, vtEnd1, vtExtr) ||
|
||||
! pCompo1->AddCurve( Release( pArc1)))
|
||||
|
||||
// creo la regione
|
||||
SurfFlatRegionByContours SfrCntr( false, false) ;
|
||||
|
||||
// offset della prima curva a destra del raggio
|
||||
OffsetCurve OffsCrv1( dOffsLinTol) ;
|
||||
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() ;
|
||||
}
|
||||
|
||||
// offset della seconda curva a destra del raggio
|
||||
OffsetCurve OffsCrv2( dOffsLinTol) ;
|
||||
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() ;
|
||||
}
|
||||
|
||||
// se estremi squadrati
|
||||
if ( bSquareEnds) {
|
||||
// aggiungo alla prima curva una linea che la unisca alla seconda
|
||||
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
||||
Point3d ptEnd1, ptStart2 ;
|
||||
if ( IsNull( pLine) ||
|
||||
! pCompo1->GetEndPoint( ptEnd1) ||
|
||||
! pCompo2->GetStartPoint( ptStart2) ||
|
||||
! pLine->Set( ptEnd1, ptStart2) ||
|
||||
! pCompo1->AddCurve( Release( pLine)))
|
||||
return nullptr ;
|
||||
// unisco le due curve composite e le chiudo
|
||||
if ( ! pCompo1->AddCurve( Release( pCompo2)) || ! pCompo1->Close())
|
||||
return nullptr ;
|
||||
}
|
||||
// altrimenti estremi arrotondati
|
||||
else {
|
||||
if ( ! pArc1->Set2PVN( ptStart2, ptEnd1, -vtStart2, vtExtr) ||
|
||||
! pArc1->Invert() ||
|
||||
! pCompo1->AddCurve( Release( pArc1)))
|
||||
// aggiungo alla prima curva un arco che la unisca alla seconda
|
||||
PtrOwner<CurveArc> pArc1( CreateBasicCurveArc()) ;
|
||||
Point3d ptEnd1, ptStart2 ;
|
||||
Vector3d vtEnd1, vtStart2 ;
|
||||
if ( IsNull( pArc1) ||
|
||||
! pCompo1->GetEndPoint( ptEnd1) ||
|
||||
! pCompo1->GetEndDir( vtEnd1) ||
|
||||
! pCompo2->GetStartPoint( ptStart2) ||
|
||||
! pCompo2->GetStartDir( vtStart2))
|
||||
return nullptr ;
|
||||
// verifico se arco tangente alla prima o alla seconda curva
|
||||
if ( AreSameVectorApprox( vtEnd1, vtEnd)) {
|
||||
if ( ! pArc1->Set2PVN( ptEnd1, ptStart2, vtEnd1, vtExtr) ||
|
||||
! pCompo1->AddCurve( Release( pArc1)))
|
||||
return nullptr ;
|
||||
}
|
||||
else {
|
||||
if ( ! pArc1->Set2PVN( ptStart2, ptEnd1, -vtStart2, vtExtr) ||
|
||||
! pArc1->Invert() ||
|
||||
! pCompo1->AddCurve( Release( pArc1)))
|
||||
return nullptr ;
|
||||
}
|
||||
// aggiungo alla seconda curva un arco che la unisca alla prima
|
||||
PtrOwner<CurveArc> pArc2( CreateBasicCurveArc()) ;
|
||||
Point3d ptEnd2, ptStart1 ;
|
||||
Vector3d vtEnd2, vtStart1 ;
|
||||
if ( IsNull( pArc2) ||
|
||||
! pCompo2->GetEndPoint( ptEnd2) ||
|
||||
! pCompo2->GetEndDir( vtEnd2) ||
|
||||
! pCompo1->GetStartPoint( ptStart1) ||
|
||||
! pCompo1->GetStartDir( vtStart1))
|
||||
return nullptr ;
|
||||
// verifico se arco tangente alla seconda o alla prima curva
|
||||
if ( AreOppositeVectorApprox( vtEnd2, vtStart)) {
|
||||
if ( ! pArc2->Set2PVN( ptEnd2, ptStart1, vtEnd2, vtExtr) ||
|
||||
! pCompo2->AddCurve( Release( pArc2)))
|
||||
return nullptr ;
|
||||
}
|
||||
else {
|
||||
if ( ! pArc2->Set2PVN( ptStart1, ptEnd2, -vtStart1, vtExtr) ||
|
||||
! pArc2->Invert() ||
|
||||
! pCompo2->AddCurve( Release( pArc2)))
|
||||
return nullptr ;
|
||||
}
|
||||
// unisco le due curve composite
|
||||
if ( ! pCompo1->AddCurve( Release( pCompo2)))
|
||||
return nullptr ;
|
||||
}
|
||||
// aggiungo alla seconda curva un arco che la unisca alla prima
|
||||
PtrOwner<CurveArc> pArc2( CreateBasicCurveArc()) ;
|
||||
Point3d ptEnd2, ptStart1 ;
|
||||
Vector3d vtEnd2, vtStart1 ;
|
||||
if ( IsNull( pArc2) ||
|
||||
! pCompo2->GetEndPoint( ptEnd2) ||
|
||||
! pCompo2->GetEndDir( vtEnd2) ||
|
||||
! pCompo1->GetStartPoint( ptStart1) ||
|
||||
! pCompo1->GetStartDir( vtStart1))
|
||||
return nullptr ;
|
||||
// verifico se arco tangente alla seconda o alla prima curva
|
||||
if ( AreOppositeVectorApprox( vtEnd2, vtStart)) {
|
||||
if ( ! pArc2->Set2PVN( ptEnd2, ptStart1, vtEnd2, vtExtr) ||
|
||||
! pCompo2->AddCurve( Release( pArc2)))
|
||||
return nullptr ;
|
||||
}
|
||||
else {
|
||||
if ( ! pArc2->Set2PVN( ptStart1, ptEnd2, -vtStart1, vtExtr) ||
|
||||
! pArc2->Invert() ||
|
||||
! pCompo2->AddCurve( Release( pArc2)))
|
||||
return nullptr ;
|
||||
}
|
||||
// unisco le due curve composite
|
||||
if ( ! pCompo1->AddCurve( Release( pCompo2)))
|
||||
return nullptr ;
|
||||
|
||||
SfrCntr.AddCurve( Release( pCompo1)) ;
|
||||
return SfrCntr.GetSurf() ;
|
||||
}
|
||||
|
||||
SfrCntr.AddCurve( Release( pCompo1)) ;
|
||||
return SfrCntr.GetSurf() ;
|
||||
}
|
||||
|
||||
// ---------------------- CALCOLO CON VORONOI ------------------------------------
|
||||
else {
|
||||
// calcolo la fat curve con Voronoi
|
||||
ICURVEPOVECTOR vFatCurves ;
|
||||
if ( ! CalcCurveFatCurve( *pCurve, vFatCurves, dRadius, bSquareEnds, bSquareMids))
|
||||
return nullptr ;
|
||||
|
||||
// costruisco la superficie a partire dalle curve
|
||||
SurfFlatRegionByContours SfrCntr( false, false) ;
|
||||
for ( int i = 0 ; i < ( int)vFatCurves.size() ; i++)
|
||||
SfrCntr.AddCurve( Release( vFatCurves[i])) ;
|
||||
|
||||
return SfrCntr.GetSurf() ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+39
-29
@@ -18,6 +18,7 @@
|
||||
#include "CurveArc.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "SurfTriMesh.h"
|
||||
#include "Voronoi.h"
|
||||
#include "/EgtDev/Include/EGkOffsetCurve.h"
|
||||
#include "/EgtDev/Include/EGkStmFromCurves.h"
|
||||
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
|
||||
@@ -242,7 +243,7 @@ GetSurfTriMeshByRevolve( const ICurve* pCurve, const Point3d& ptAx, const Vector
|
||||
PL.Invert() ;
|
||||
}
|
||||
// creo e setto la superficie trimesh
|
||||
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
|
||||
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSTM) || ! pSTM->CreateByScrewing( PL, ptAx, vtAx, ANG_FULL, dStepRotDeg, 0))
|
||||
return nullptr ;
|
||||
// se superficie risultante chiusa, verifico che la normale sia verso l'esterno
|
||||
@@ -281,7 +282,7 @@ GetSurfTriMeshByScrewing( const ICurve* pCurve, const Point3d& ptAx, const Vecto
|
||||
return nullptr ;
|
||||
}
|
||||
// creo e setto la superficie trimesh
|
||||
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
|
||||
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSTM) || ! pSTM->CreateByScrewing( PL, ptAx, vtAx, dAngRotDeg, dStepRotDeg, dMove))
|
||||
return nullptr ;
|
||||
// se richiesti caps
|
||||
@@ -294,7 +295,7 @@ GetSurfTriMeshByScrewing( const ICurve* pCurve, const Point3d& ptAx, const Vecto
|
||||
// se sezione chiusa e piatta e non rivoluzione, posso aggiungere i tappi
|
||||
if ( bSectClosedFlat && ! bRevolved) {
|
||||
// aggiungo il cap sull'inizio
|
||||
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
|
||||
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSci) || ! pSci->CreateByFlatContour( PL))
|
||||
return nullptr ;
|
||||
pSTM->DoSewing( *pSci) ;
|
||||
@@ -304,7 +305,7 @@ GetSurfTriMeshByScrewing( const ICurve* pCurve, const Point3d& ptAx, const Vecto
|
||||
vtMove *= dMove ;
|
||||
PL.Translate( vtMove) ;
|
||||
PL.Rotate( ptAx, vtAx, dAngRotDeg) ;
|
||||
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
|
||||
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSce) || ! pSce->CreateByFlatContour( PL))
|
||||
return nullptr ;
|
||||
pSce->Invert() ;
|
||||
@@ -345,8 +346,6 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide,
|
||||
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))
|
||||
@@ -383,13 +382,13 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide,
|
||||
if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 100 * EPS_SMALL))
|
||||
return nullptr ;
|
||||
// aggiungo il cap sull'inizio
|
||||
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
|
||||
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSci) || ! pSci->CreateByFlatContour( vPL[0]))
|
||||
return nullptr ;
|
||||
pSci->Invert() ;
|
||||
pSTM->DoSewing( *pSci) ;
|
||||
// aggiungo il cap sulla fine
|
||||
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
|
||||
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSce) || ! pSce->CreateByFlatContour( vPL[1]))
|
||||
return nullptr ;
|
||||
pSce->Invert() ;
|
||||
@@ -410,7 +409,7 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide,
|
||||
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()) ;
|
||||
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSci) || ! pSci->CreateByScrewing( PLStart, ptStart, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||
return nullptr ;
|
||||
pSci->Invert() ;
|
||||
@@ -426,7 +425,7 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide,
|
||||
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()) ;
|
||||
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSce) || ! pSce->CreateByScrewing( PLEnd, ptEnd, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||
return nullptr ;
|
||||
pSce->Invert() ;
|
||||
@@ -440,6 +439,8 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide,
|
||||
static ISurfTriMesh*
|
||||
GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, double dBevelV, const ICurve* pGuide, int nCapType, double dLinTol)
|
||||
{
|
||||
// metodo di calcolo impostato da USE_VORONOI
|
||||
|
||||
// verifico che la linea guida sia piana
|
||||
Plane3d plGuide ;
|
||||
if ( ! pGuide->IsFlat( plGuide, false, 10 * EPS_SMALL))
|
||||
@@ -456,19 +457,28 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub
|
||||
const int NUM_OFFS = 4 ;
|
||||
OffsetCurve vOffsCrv[NUM_OFFS] ;
|
||||
double vDist[NUM_OFFS] = { dDimH / 2 - dBevelH, -dDimH / 2 + dBevelH, dDimH / 2, -dDimH / 2} ;
|
||||
future<bool> vRes[NUM_OFFS] ;
|
||||
for ( int i = 0 ; i < NUM_OFFS ; ++ i)
|
||||
vRes[i] = async( launch::async, &OffsetCurve::Make, &vOffsCrv[i], pGuide, vDist[i], ICurve::OFF_FILLET) ;
|
||||
bool bOk = true ;
|
||||
int nFin = 0 ;
|
||||
while ( nFin < NUM_OFFS) {
|
||||
for ( int i = 0 ; i < NUM_OFFS ; ++ i) {
|
||||
if ( vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) {
|
||||
bOk = vRes[i].get() && bOk ;
|
||||
++ nFin ;
|
||||
if ( ! USE_VORONOI) {
|
||||
future<bool> vRes[NUM_OFFS] ;
|
||||
for ( int i = 0 ; i < NUM_OFFS ; ++ i)
|
||||
vRes[i] = async( launch::async, &OffsetCurve::Make, &vOffsCrv[i], pGuide, vDist[i], ICurve::OFF_FILLET) ;
|
||||
bool bOk = true ;
|
||||
int nFin = 0 ;
|
||||
while ( nFin < NUM_OFFS) {
|
||||
for ( int i = 0 ; i < NUM_OFFS ; ++ i) {
|
||||
if ( vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) {
|
||||
bOk = vRes[i].get() && bOk ;
|
||||
++ nFin ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// se Voronoi non è possibile calcolare gli offset di una stessa curva in parallelo
|
||||
for ( int i = 0 ; i < NUM_OFFS && bOk ; ++ i)
|
||||
bOk = vOffsCrv[i].Make( pGuide, vDist[i], ICurve::OFF_FILLET) ;
|
||||
}
|
||||
|
||||
if ( ! bOk ||
|
||||
vOffsCrv[0].GetCurveCount() == 0 || vOffsCrv[1].GetCurveCount() == 0 ||
|
||||
vOffsCrv[2].GetCurveCount() == 0 || vOffsCrv[3].GetCurveCount() == 0)
|
||||
@@ -551,12 +561,12 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub
|
||||
if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 50 * EPS_SMALL))
|
||||
return nullptr ;
|
||||
// calcolo il cap sull'inizio
|
||||
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
|
||||
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSci) || ! pSci->CreateByFlatContour( vPL[0]))
|
||||
return nullptr ;
|
||||
pSci->Invert() ;
|
||||
// calcolo il cap sulla fine
|
||||
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
|
||||
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSce) || ! pSce->CreateByFlatContour( vPL[1]))
|
||||
return nullptr ;
|
||||
pSce->Invert() ;
|
||||
@@ -581,7 +591,7 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub
|
||||
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()) ;
|
||||
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSci) || ! pSci->CreateByScrewing( PLStart, ptStart, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||
return nullptr ;
|
||||
pSci->Invert() ;
|
||||
@@ -599,7 +609,7 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub
|
||||
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()) ;
|
||||
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSce) || ! pSce->CreateByScrewing( PLEnd, ptEnd, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||
return nullptr ;
|
||||
pSce->Invert() ;
|
||||
@@ -669,7 +679,7 @@ GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, d
|
||||
if ( ! PL.ToLoc( frStart) || ! PL.Flatten())
|
||||
return nullptr ;
|
||||
// calcolo la superficie
|
||||
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
|
||||
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSTM))
|
||||
return nullptr ;
|
||||
// salvo tolleranza lineare usata
|
||||
@@ -711,7 +721,7 @@ GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, d
|
||||
if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 100 * EPS_SMALL))
|
||||
return nullptr ;
|
||||
// aggiungo il cap sull'inizio
|
||||
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
|
||||
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSci) || ! pSci->CreateByFlatContour( PL))
|
||||
return nullptr ;
|
||||
pSci->ToGlob( frStart) ;
|
||||
@@ -724,7 +734,7 @@ GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, d
|
||||
pGuide->GetEndDir( vtEnd) ;
|
||||
frEnd.Set( ptEnd, -vtEnd, vtEnd ^ vtNorm) ;
|
||||
// aggiungo il cap sulla fine
|
||||
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
|
||||
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSce) || ! pSce->CreateByFlatContour( PL))
|
||||
return nullptr ;
|
||||
pSce->Invert() ;
|
||||
@@ -751,7 +761,7 @@ GetSurfTriMeshRuled( const Point3d& ptP, const ICurve* pCurve, double dLinTol)
|
||||
if ( ! pCurve->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
|
||||
return nullptr ;
|
||||
// creo e setto la superficie trimesh
|
||||
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
|
||||
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSTM) || ! pSTM->CreateByPointCurve( ptP, PL))
|
||||
return nullptr ;
|
||||
// salvo tolleranza lineare usata
|
||||
@@ -776,7 +786,7 @@ GetSurfTriMeshRuled( const ICurve* pCurve1, const ICurve* pCurve2, int nType, do
|
||||
if ( ! pCurve2->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL2))
|
||||
return nullptr ;
|
||||
// creo e setto la superficie trimesh
|
||||
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
|
||||
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSTM) || ! pSTM->CreateByTwoCurves( PL1, PL2, nType))
|
||||
return nullptr ;
|
||||
// salvo tolleranza lineare usata
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// File : StmFromTriangleSoup.cpp Data : 07.05.23 Versione : 2.5e2
|
||||
// Contenuto : Implementazione della classe StmFromTriangleSoup, per creare
|
||||
// una superficie trimesh da un insieme di triangoli
|
||||
// (può essere disordinato come STL o può essere una superficie).
|
||||
// (può essere disordinato come STL o può essere una superficie).
|
||||
//
|
||||
// Modifiche : 19.05.14 DS Creazione modulo.
|
||||
//
|
||||
@@ -53,7 +53,7 @@ StmFromTriangleSoup::AddTriangle( const Triangle3d& Tria)
|
||||
// ciclo sui tre vertici
|
||||
int nIdV[3] ;
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
// verifico se vertice già presente
|
||||
// verifico se vertice già presente
|
||||
int nId ;
|
||||
if ( ! m_VertGrid.Find( Tria.GetP( i), 2 * EPS_SMALL, nId)) {
|
||||
// aggiungo il vertice
|
||||
@@ -77,7 +77,7 @@ StmFromTriangleSoup::AddTriangle( const Triangle3d& Tria)
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
StmFromTriangleSoup::AddTriangle( const Point3d& ptP0, const Point3d& ptP1, const Point3d& ptP2,
|
||||
const double dU0, const double dV0,const double dU1, const double dV1,const double dU2, const double dV2)
|
||||
double dU0, double dV0, double dU1, double dV1, double dU2, double dV2)
|
||||
{
|
||||
// verifico inizializzazione
|
||||
if ( m_pSTM == nullptr)
|
||||
@@ -100,13 +100,13 @@ StmFromTriangleSoup::AddTriangle( const Point3d& ptP0, const Point3d& ptP1, cons
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
StmFromTriangleSoup::AddVertex( const Point3d& ptP, const double dU, const double dV)
|
||||
StmFromTriangleSoup::AddVertex( const Point3d& ptP, double dU, double dV)
|
||||
{
|
||||
// verifico se già presente
|
||||
// verifico se già presente
|
||||
int nId ;
|
||||
if ( m_VertGrid.Find( ptP, 2 * EPS_SMALL, nId))
|
||||
return nId ;
|
||||
// aggiungo il vertice
|
||||
// aggiungo il vertice
|
||||
if ( ( nId = m_pSTM->AddVertex( ptP, dU, dV)) == SVT_NULL)
|
||||
return SVT_NULL ;
|
||||
m_VertGrid.InsertPoint( ptP, nId) ;
|
||||
|
||||
+28
-26
@@ -26,34 +26,36 @@ using namespace std ;
|
||||
static SurfTriMesh*
|
||||
GetStandardSurfTriMeshBox( double dDimX, double dDimY, double dHeight)
|
||||
{
|
||||
// creo la polilinea del contorno della base
|
||||
PolyLine PL ;
|
||||
int nU = 0 ;
|
||||
PL.AddUPoint( nU, Point3d( 0, 0, 0)) ;
|
||||
PL.AddUPoint( ++ nU, Point3d( dDimX, 0, 0)) ;
|
||||
PL.AddUPoint( ++ nU, Point3d( dDimX, dDimY, 0)) ;
|
||||
PL.AddUPoint( ++ nU, Point3d( 0, dDimY, 0)) ;
|
||||
PL.AddUPoint( ++ nU, Point3d( 0, 0, 0)) ;
|
||||
if ( dHeight < 0)
|
||||
PL.Invert() ;
|
||||
// vettore altezza (estrusione)
|
||||
Vector3d vtExtr( 0, 0, dHeight) ;
|
||||
// creo e setto la superficie trimesh laterale
|
||||
// creo oggetto vuoto
|
||||
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pSTM) || ! pSTM->CreateByExtrusion( PL, vtExtr))
|
||||
if ( IsNull( pSTM))
|
||||
return nullptr ;
|
||||
// creo la prima superficie di estremità
|
||||
SurfTriMesh STM1 ;
|
||||
if ( ! STM1.CreateByFlatContour( PL))
|
||||
// assegno i vertici
|
||||
double dBotZ = 0, dTopZ = dHeight ;
|
||||
if ( dBotZ > dTopZ)
|
||||
swap( dBotZ, dTopZ) ;
|
||||
if ( pSTM->AddVertex( Point3d( 0, 0, dBotZ)) == SVT_NULL ||
|
||||
pSTM->AddVertex( Point3d( 0, 0, dTopZ)) == SVT_NULL ||
|
||||
pSTM->AddVertex( Point3d( dDimX, 0, dBotZ)) == SVT_NULL ||
|
||||
pSTM->AddVertex( Point3d( dDimX, 0, dTopZ)) == SVT_NULL ||
|
||||
pSTM->AddVertex( Point3d( dDimX, dDimY, dBotZ)) == SVT_NULL ||
|
||||
pSTM->AddVertex( Point3d( dDimX, dDimY, dTopZ)) == SVT_NULL ||
|
||||
pSTM->AddVertex( Point3d( 0, dDimY, dBotZ)) == SVT_NULL ||
|
||||
pSTM->AddVertex( Point3d( 0, dDimY, dTopZ)) == SVT_NULL)
|
||||
return nullptr ;
|
||||
// la copio
|
||||
SurfTriMesh STM2 = STM1 ;
|
||||
// inverto la prima superficie
|
||||
STM1.Invert() ;
|
||||
// traslo la seconda
|
||||
STM2.Translate( Vector3d( 0, 0, dHeight)) ;
|
||||
// le unisco alla superficie del fianco
|
||||
if ( ! pSTM->DoSewing( STM1) || ! pSTM->DoSewing( STM2))
|
||||
// definisco i triangoli
|
||||
int aVertId[12][3]{{ 1, 0, 2}, { 1, 2, 3},
|
||||
{ 3, 2, 4}, { 3, 4, 5},
|
||||
{ 5, 4, 6}, { 5, 6, 7},
|
||||
{ 7, 6, 0}, { 7, 0, 1},
|
||||
{ 0, 4, 2}, { 6, 4, 0},
|
||||
{ 1, 3, 5}, { 7, 1, 5}} ;
|
||||
for ( int i = 0 ; i < 12 ; ++ i) {
|
||||
if ( pSTM->AddTriangle( aVertId[i]) == SVT_NULL)
|
||||
return nullptr ;
|
||||
}
|
||||
// sistemo la topologia
|
||||
if ( ! pSTM->AdjustTopology())
|
||||
return nullptr ;
|
||||
// restituisco la superficie
|
||||
return Release( pSTM) ;
|
||||
@@ -255,7 +257,7 @@ GetSurfTriMeshPlaneInBox( const Plane3d& plPlane, const BBox3d& b3Box, bool bOnE
|
||||
if ( ! Polyg.FromPlaneTrimmedWithBox( plPlane, b3Box.GetMin(), b3Box.GetMax(), bOnEq, bOnCt))
|
||||
return nullptr ;
|
||||
// creo la trimesh con questo contorno
|
||||
PtrOwner<ISurfTriMesh> pStm( CreateSurfTriMesh()) ;
|
||||
PtrOwner<SurfTriMesh> pStm( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pStm) || ! pStm->CreateByFlatContour( Polyg.GetPolyLine()))
|
||||
return nullptr ;
|
||||
// restituisco la superficie
|
||||
|
||||
@@ -0,0 +1,731 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2023-2023
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EGkSubtractProjectedFacesOnStmFace.h Data : 26.09.23 Versione : 2.5j1
|
||||
// Contenuto : Dichiarazione della funzione per proiettare facce di TriMesh su una superficie di TriMesh.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 26.09.23 RE Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "DllMain.h"
|
||||
#include "GeoConst.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "SurfFlatRegion.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EGkCurveAux.h"
|
||||
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
|
||||
#include "/EgtDev/Include/EGkSubtractProjectedFacesOnStmFace.h"
|
||||
#include "/EgtDev/Include/EGkStmFromCurves.h"
|
||||
#include <array>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Proiezione sottrazione di facce di TriMesh su una faccia di TriMesh
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
ImproveCurve( CurveComposite* pCrvCompo, const Frame3d frface, const Plane3d plFace, bool& bSkip)
|
||||
{
|
||||
// controllo dei parametri
|
||||
if ( pCrvCompo == nullptr || ! pCrvCompo->IsValid() ||
|
||||
! frface.IsValid())
|
||||
return false ;
|
||||
|
||||
// 1) se la curva ha un'area o un perimetro troppo piccolo, la trascuro
|
||||
double dArea = SQ_EPS_SMALL , dLen = EPS_SMALL ;
|
||||
Plane3d plCrv ;
|
||||
if ( ! pCrvCompo->GetArea( plCrv, dArea) || ! pCrvCompo->GetLength( dLen))
|
||||
return false ;
|
||||
if ( dArea < 50000 * SQ_EPS_SMALL || dLen < 50 * EPS_SMALL) {
|
||||
bSkip = true ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
// 2) Merge per uniformità
|
||||
if ( ! pCrvCompo->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL))
|
||||
return false ;
|
||||
|
||||
// 3) Rimuoviamo Spikes o Curve a Z
|
||||
if ( ! pCrvCompo->RemoveSmallDefects( 150 * EPS_SMALL, 2 * ANG_TOL_STD_DEG, true))
|
||||
return false ;
|
||||
|
||||
// 4) Interpoliamo mediante Linee ed Archi
|
||||
PolyArc PA ;
|
||||
pCrvCompo->ToLoc( frface) ; // interpolazione nel piano XY
|
||||
pCrvCompo->ApproxWithArcsEx( 500 * EPS_SMALL, ANG_TOL_STD_DEG, 20.0, PA) ;
|
||||
pCrvCompo->Clear() ;
|
||||
pCrvCompo->FromPolyArc( PA) ;
|
||||
pCrvCompo->ToGlob( frface) ;
|
||||
|
||||
// le curve ricavate dalle TriMesh possono presentare dei piccoli errori di approssimazione che non le rendono
|
||||
// del tutto piane... per sicurezza le proietto sul piano creato
|
||||
double dS, dE ;
|
||||
pCrvCompo->GetDomain( dS, dE) ;
|
||||
PtrOwner<ICurve> pCrv_c( pCrvCompo->CopyParamRange( dS, dE)) ; // da CurveCompo a Curve
|
||||
if ( IsNull( pCrv_c) || ! pCrv_c->IsValid())
|
||||
return false ;
|
||||
PtrOwner<ICurve> pCrv_proj( ProjectCurveOnPlane( *pCrv_c, plFace)) ;
|
||||
// secondo controllo per l'area e il perimetro
|
||||
double dAreaCheck = SQ_EPS_SMALL, dLenCheck = EPS_SMALL ;
|
||||
Plane3d plCheck ;
|
||||
if ( ! IsNull( pCrv_proj) && pCrv_proj->IsClosed()) {
|
||||
pCrv_proj->GetArea( plCheck, dAreaCheck) ;
|
||||
pCrv_proj->GetLength( dLenCheck) ;
|
||||
if ( dAreaCheck < 50000 * SQ_EPS_SMALL || dLenCheck < 50 * EPS_SMALL) {
|
||||
bSkip = true ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
// sostituisco la curva ed esco
|
||||
pCrvCompo->Clear() ;
|
||||
pCrvCompo->CopyFrom( pCrv_proj) ;
|
||||
bSkip = false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
GetSfrByStm( const ISurfTriMesh* pStm, ISurfFlatRegion* pSfr, const Plane3d plFace)
|
||||
{
|
||||
// controllo validità dei parametri
|
||||
if ( pStm == nullptr || ! pStm->IsValid() || ! plFace.IsValid())
|
||||
return false ;
|
||||
|
||||
// creo un Frame per il sistema di Riferimento Locale
|
||||
Frame3d frFace ; frFace.Set( plFace.GetPoint(), plFace.GetVersN()) ;
|
||||
if ( ! frFace.IsValid())
|
||||
return false ;
|
||||
|
||||
// creo la FlatRegion da resitutiure
|
||||
SurfFlatRegionByContours SrfChunkDef ;
|
||||
|
||||
// recupero i Loop della TriMesh salvandoli in un vettore di PolyLine
|
||||
POLYLINEVECTOR vPl ;
|
||||
pStm->GetLoops( vPl) ;
|
||||
|
||||
// per ogni PolyLine...
|
||||
for ( int i = 0 ; i < ( int)vPl.size() ; ++ i) {
|
||||
// recupero la curva composita
|
||||
PolyLine PL = vPl[i] ;
|
||||
PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
|
||||
pCrvCompo->FromPolyLine( PL) ;
|
||||
|
||||
// sistemazione varie per la curva ( per creare i loops della FlatRegion)
|
||||
bool bSkip ; // flag per indicare se la curva è accettabile
|
||||
if ( ! ImproveCurve( pCrvCompo, frFace, plFace, bSkip))
|
||||
return false ;
|
||||
if ( ! bSkip)
|
||||
SrfChunkDef.AddCurve( Release( pCrvCompo)) ; // aggiungo la curva
|
||||
}
|
||||
|
||||
// recupero la FlatRegion ( controllandone la validità)
|
||||
PtrOwner<ISurfFlatRegion> pSrfByCurves( SrfChunkDef.GetSurf()) ;
|
||||
if ( IsNull( pSrfByCurves) || ! pSrfByCurves->IsValid() || pSrfByCurves->GetChunkCount() == 0)
|
||||
return true ;
|
||||
|
||||
// restituisco la FlatRegion
|
||||
pSfr->Clear() ;
|
||||
pSfr->CopyFrom( pSrfByCurves) ;
|
||||
return pSfr != nullptr && pSfr->IsValid() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
CheckSimpleOverlap( const ICurve* pCrv, const ICurveComposite* pCrvOri, int& nStat, double dToll)
|
||||
{
|
||||
// === controllo se una curva semplice è sufficientemente vicina ad una curva composita ===
|
||||
// controllo dei parametri
|
||||
if (( pCrv == nullptr || pCrvOri == nullptr || dToll < EPS_SMALL))
|
||||
return false ;
|
||||
nStat = 1 ; // 0 -> no overlap | 1 -> overlap
|
||||
|
||||
// prendo nMax + 1 punti sulla curva semplice...
|
||||
const double nMAX = 10.0 ;
|
||||
for ( int i = 0 ; i <= nMAX ; ++i) {
|
||||
double dPar = i / nMAX ;
|
||||
Point3d ptC ; pCrv->GetPointD1D2( dPar, ICurve::FROM_PLUS, ptC) ;
|
||||
if ( ! pCrvOri->IsPointOn( ptC, dToll)) { // se un punto non è vicino, esco
|
||||
nStat = 0 ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
SetTmpPropByOverlap( ICurveComposite* pCrvCheck, const int nInd, const ICurveComposite* pCrvOri, int& nStat,
|
||||
double dToll)
|
||||
{
|
||||
// === Data una sottocurva di una CurveComposite e un'altra composita con le proprietà impostate, spezzo la
|
||||
// sottocurva in tratti di TmpProps uniformi appropriati ===
|
||||
// controllo dei parametri
|
||||
if (( pCrvCheck == nullptr || pCrvOri == nullptr || nInd < 0 || nInd > pCrvCheck->GetCurveCount()
|
||||
|| dToll < EPS_SMALL))
|
||||
return false ;
|
||||
nStat = 1 ; // 0 -> no overlap | 1 -> overlap | 2 -> undefined
|
||||
|
||||
// ricavo la curva da controllare
|
||||
PtrOwner<ICurveComposite> pCrv( GetCurveComposite( pCrvCheck->CopyParamRange( nInd, nInd + 1))) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
|
||||
// controllo se la curva fa overlap ( mediante vicinanza)
|
||||
if ( ! CheckSimpleOverlap( pCrv, pCrvOri, nStat, dToll))
|
||||
return false ;
|
||||
if ( nStat == 0)
|
||||
return true ;
|
||||
|
||||
// ricavo i parametri sulla curva originale di vicinanza
|
||||
double dUS = 0 ; double dUE = 0 ;
|
||||
Point3d ptS ; pCrv->GetStartPoint( ptS) ;
|
||||
Point3d ptE ; pCrv->GetEndPoint( ptE) ;
|
||||
pCrvOri->GetParamAtPoint( ptS, dUS, dToll) ;
|
||||
pCrvOri->GetParamAtPoint( ptE, dUE, dToll) ;
|
||||
|
||||
// ricavo una approssimazione adeguata dei paramtri dUS e dUE
|
||||
int nRealDUS = ( int)floor( dUS) ;
|
||||
int nRealDUE = ( int)ceil( dUE) ;
|
||||
if ( ceil( dUS) - dUS < EPS_SMALL)
|
||||
nRealDUS = ( int)ceil( dUS) ;
|
||||
if ( dUE - floor( dUE) < EPS_SMALL)
|
||||
nRealDUE = ( int)floor( dUE) ;
|
||||
if ( nRealDUS == pCrvOri->GetCurveCount())
|
||||
nRealDUS = 0 ;
|
||||
|
||||
// controllo se la vicinanza è relativa a più curve sulla originale con stesse temp prop
|
||||
bool bHasAllSameProp = true ;
|
||||
int nProp_prec ; pCrvOri->GetCurveTempProp( nRealDUS, nProp_prec, 0) ;
|
||||
for ( int u = nRealDUS + 1 ; u < nRealDUE && bHasAllSameProp ; ++ u) {
|
||||
int nProp_act ;
|
||||
pCrvOri->GetCurveTempProp( u, nProp_act, 0) ;
|
||||
if ( nProp_prec != nProp_act)
|
||||
bHasAllSameProp = false ;
|
||||
}
|
||||
if ( bHasAllSameProp) { // se tutte le curve hanno tmpProp uguale...
|
||||
int nCrv = nRealDUS ;
|
||||
int nProp0 = 0 ; pCrvOri->GetCurveTempProp( nCrv, nProp0, 0) ;
|
||||
int nProp1 = 0 ; pCrvOri->GetCurveTempProp( nCrv, nProp1, 1) ;
|
||||
pCrvCheck->SetCurveTempProp( nInd, nProp0, 0) ;
|
||||
//pCrvCheck->SetCurveTempProp( nInd, nProp1, 1) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
// copio le sottocurve toccate
|
||||
PtrOwner<ICurveComposite> pCrvOriRange( CloneCurveComposite( pCrvOri)) ;
|
||||
if ( ! pCrvOriRange->TrimStartEndAtParam( floor( dUS), ceil( dUE)))
|
||||
pCrvOriRange->Clear() ;
|
||||
|
||||
if ( ! pCrvOriRange->IsValid()) {
|
||||
nStat = 2 ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
// curva finale da resitutire ( da semplice Curve a CurveComposite)
|
||||
PtrOwner<CurveComposite> pCrvFinal( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCrvFinal))
|
||||
return false ;
|
||||
|
||||
// per ogni sottocurva...
|
||||
double dUProjS = 0 ; double dUProjE = 0 ;
|
||||
for ( int u = 0 ; u < pCrvOriRange->GetCurveCount() ; ++ u) {
|
||||
|
||||
Point3d ptCrvOriE ;
|
||||
pCrvOriRange->GetPointD1D2( u + 1, ICurve::FROM_MINUS, ptCrvOriE) ;
|
||||
|
||||
if ( u == 0)
|
||||
dUProjS = 0 ;
|
||||
else
|
||||
dUProjS = dUProjE ;
|
||||
|
||||
if ( u == pCrvOriRange->GetCurveCount() - 1)
|
||||
dUProjE = 1 ;
|
||||
else
|
||||
pCrv->GetParamAtPoint( ptCrvOriE, dUProjE, dToll) ;
|
||||
|
||||
PtrOwner<CurveComposite> pCrvRange( GetBasicCurveComposite( pCrv->CopyParamRange( dUProjS, dUProjE))) ;
|
||||
if ( ! IsNull( pCrvRange) && pCrvRange->IsValid()) {
|
||||
int nProp0 = 0 ; pCrvOriRange->GetCurveTempProp( u, nProp0, 0) ;
|
||||
int nProp1 = -1 ; pCrvOriRange->GetCurveTempProp( u, nProp1, 1) ;
|
||||
pCrvRange->SetCurveTempProp( 0, nProp0, 0) ;
|
||||
pCrvRange->SetCurveTempProp( 0, nProp1, 1) ;
|
||||
pCrvFinal->AddCurve( Release( pCrvRange)) ;
|
||||
}
|
||||
else {
|
||||
nStat = 2 ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
// controllo che la CurveComposite ottenuta sia valida e coerente rispetto all'originale ...
|
||||
if ( pCrvFinal->GetCurveCount() > 0 && pCrvFinal->IsValid()) {
|
||||
Point3d ptSCheck ; Point3d ptECheck ;
|
||||
pCrvFinal->GetStartPoint( ptSCheck) ;
|
||||
pCrvFinal->GetEndPoint( ptECheck) ;
|
||||
if ( ! AreSamePointApprox( ptS, ptSCheck) || ! AreSamePointApprox( ptE, ptECheck))
|
||||
nStat = 2 ;
|
||||
}
|
||||
else
|
||||
nStat = 2 ;
|
||||
|
||||
// ritorno la curva modificata
|
||||
if ( nStat != 2) {
|
||||
pCrvFinal->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, true, true) ;
|
||||
PtrOwner<CurveComposite> pCrvToReturn( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCrvToReturn))
|
||||
return false ;
|
||||
|
||||
// primo tratto di curva della Composita iniziale
|
||||
PtrOwner<CurveComposite> pCrvA( GetBasicCurveComposite( pCrvCheck->CopyParamRange( 0, nInd))) ;
|
||||
if ( ! IsNull( pCrvA) && pCrvA->GetCurveCount() > 0 && pCrvA->IsValid()) {
|
||||
if ( ! pCrvToReturn->AddCurve( Release( pCrvA))) {
|
||||
nStat = 2 ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// tratto corrente di curva con proprietà impostate
|
||||
if ( ! pCrvToReturn->AddCurve( Release( pCrvFinal))) {
|
||||
nStat = 2 ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
// ultimo tratto di curva della Composita iniziale
|
||||
PtrOwner<CurveComposite> pCrvB( GetBasicCurveComposite( pCrvCheck->CopyParamRange( nInd + 1, pCrvCheck->GetCurveCount()))) ;
|
||||
if ( ! IsNull( pCrvB) && pCrvB->GetCurveCount() > 0 && pCrvB->IsValid())
|
||||
if( ! pCrvToReturn->AddCurve( Release( pCrvB))) {
|
||||
nStat = 2 ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if ( pCrvToReturn->GetCurveCount() > 0 && pCrvToReturn->IsValid()) {
|
||||
// imposto i parametri originali alla nuova curva
|
||||
double dThick ; pCrvCheck->GetThickness( dThick) ;
|
||||
Vector3d vtExtr ; pCrvCheck->GetExtrusion( vtExtr) ;
|
||||
int nProp0 = pCrvCheck->GetTempProp( 0) ;
|
||||
int nProp1 = pCrvCheck->GetTempProp( 1) ;
|
||||
pCrvCheck->Clear() ;
|
||||
pCrvCheck->AddCurve( Release( pCrvToReturn)) ;
|
||||
pCrvCheck->SetExtrusion( vtExtr ) ;
|
||||
pCrvCheck->SetThickness( dThick) ;
|
||||
pCrvCheck->SetTempProp( nProp0, 0) ;
|
||||
pCrvCheck->SetTempProp( nProp1, 1) ;
|
||||
}
|
||||
else
|
||||
nStat = 2 ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
GetOCCrvsWithProps( const ISurfTriMesh& StmOrig, int nFaceInd, ICRVCOMPOPOVECTOR& vCrvsWithTmpProps)
|
||||
{
|
||||
// === Data una TriMesh e una sua faccia, stabilire i lati aperti e chiusi dalle adiacenze ===
|
||||
// controllo validità dei parametri
|
||||
if ( ! StmOrig.IsValid())
|
||||
return false ;
|
||||
vCrvsWithTmpProps.clear() ;
|
||||
// recupero i contorni della faccia selezionata
|
||||
POLYLINEVECTOR vPL ;
|
||||
StmOrig.GetFacetLoops( nFaceInd, vPL) ;
|
||||
if ( vPL.empty())
|
||||
return false ;
|
||||
// recupero la normale esterna della faccia
|
||||
Vector3d vtN ;
|
||||
if ( ! StmOrig.GetFacetNormal( nFaceInd, vtN))
|
||||
return false ;
|
||||
// creo la curva a partire dai loop
|
||||
for ( int i = 0 ; i < int( vPL.size()) ; i++) {
|
||||
PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo) || ! pCrvCompo->FromPolyLine( vPL[i]) || ! pCrvCompo->IsValid())
|
||||
return false ;
|
||||
// imposto a 0 tutti i lati della pCrvCompo
|
||||
for ( int u = 0 ; u < pCrvCompo->GetCurveCount() ; ++ u)
|
||||
pCrvCompo->SetCurveTempProp( u, 0, 0) ;
|
||||
// determino eventuali lati aperti e aggiorno proprietà del contorno
|
||||
int nInd = 0 ;
|
||||
double dPar ;
|
||||
bool bFound = vPL[i].GetFirstU( dPar, true) ;
|
||||
while ( bFound) {
|
||||
// recupero il flag
|
||||
int nFlag = int( dPar) ;
|
||||
// se non c'è nulla di adiacente, lato aperto
|
||||
if ( nFlag == SVT_NULL) {
|
||||
pCrvCompo->SetCurveTempProp( nInd, 1, 0) ; // --> lato aperto
|
||||
pCrvCompo->SetCurveTempProp( nInd, -1, 1) ; // --> nessuna faccia adiacente
|
||||
}
|
||||
// altrimenti verifico se la faccia adiacente forma diedro convesso o concavo
|
||||
else {
|
||||
bool bAdjac ;
|
||||
Point3d ptP1, ptP2 ;
|
||||
double dAng ;
|
||||
if ( ! StmOrig.GetFacetsContact( nFaceInd, nFlag, bAdjac, ptP1, ptP2, dAng))
|
||||
dAng = - ANG_RIGHT ;
|
||||
if ( dAng > - EPS_ANG_SMALL) {
|
||||
pCrvCompo->SetCurveTempProp( nInd, 1, 0) ; // --> lato aperto
|
||||
pCrvCompo->SetCurveTempProp( nInd, -1, 1) ; // --> nessuna faccia adiacente
|
||||
}
|
||||
else
|
||||
// salvo come prop 1 la faccia adiacente
|
||||
pCrvCompo->SetCurveTempProp( nInd, nFlag, 1) ; // --> il lato chiuso è 0 per default
|
||||
}
|
||||
// passo al successivo
|
||||
++nInd ;
|
||||
bFound = vPL[i].GetNextU( dPar, true) ;
|
||||
}
|
||||
// assegno l'estrusione dalla normale alla faccia
|
||||
pCrvCompo->SetExtrusion( vtN) ;
|
||||
// unisco le eventuali parti allineate ( mantenendo le proprietà)
|
||||
pCrvCompo->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, true, true) ;
|
||||
// aggiorno la superficie con il loop
|
||||
vCrvsWithTmpProps.emplace_back( Release( pCrvCompo)) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
SewNewStmFacesWithTmpProps( const ISurfFlatRegion& SfrOCCurves, const Plane3d plFace, ISurfTriMesh* pStmFinal)
|
||||
{
|
||||
// controllo dei parametri
|
||||
if ( ! SfrOCCurves.IsValid())
|
||||
return false ;
|
||||
|
||||
// normale dell faccia
|
||||
Vector3d vtN = plFace.GetVersN() ;
|
||||
|
||||
// Creo la TriMesh derivante dai lati chiusi ( estrusione come la normale)
|
||||
// scorro tutti i Loop della FlatRegion cercando le curva che derivano da proiezioni
|
||||
for ( int c = 0 ; c < SfrOCCurves.GetChunkCount() ; ++ c) {
|
||||
for ( int l = 0 ; l < SfrOCCurves.GetLoopCount( c) ; ++ l) {
|
||||
// ricavo il Loop
|
||||
PtrOwner<CurveComposite> pCrvCompoLoop( ConvertCurveToBasicComposite( SfrOCCurves.GetLoop( c, l))) ;
|
||||
if ( IsNull( pCrvCompoLoop) || ! pCrvCompoLoop->IsValid())
|
||||
return false ;
|
||||
// scorro le sue sottocurve
|
||||
for ( int u = 0 ; u < pCrvCompoLoop->GetCurveCount() ; ++ u) {
|
||||
const ICurve* pCrv_u = pCrvCompoLoop->GetCurve( u) ;
|
||||
if ( pCrv_u == nullptr)
|
||||
return false ;
|
||||
if ( pCrv_u->GetTempProp( 0) == 0) {
|
||||
// se curve chiuse e derivante da una proeizione...
|
||||
PtrOwner<ISurfTriMesh> pStmCurrExtr( GetSurfTriMeshByExtrusion( pCrv_u, - 1 * vtN, false)) ;
|
||||
if ( IsNull( pStmCurrExtr) || ! pStmCurrExtr->IsValid())
|
||||
return false ;
|
||||
// controllo l'orientamento corretto della nuova faccia
|
||||
Vector3d vtNCurr ;
|
||||
if ( ! pStmCurrExtr->GetFacetNormal( 0, vtNCurr))
|
||||
return false ;
|
||||
double dAng ;
|
||||
if ( vtN.GetAngle( vtNCurr, dAng) && dAng > 0)
|
||||
pStmCurrExtr->Invert() ;
|
||||
// aggiungo alla superficie
|
||||
if ( ! pStmFinal->DoSewing( *pStmCurrExtr))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
AddClosedEdges( const ISurfTriMesh& StmOrig, int nFaceInd, const ISurfFlatRegion& pSfrOrig,
|
||||
const Plane3d plFace, ISurfTriMesh* pStmFinal)
|
||||
{
|
||||
// controllo validità dei parametri
|
||||
if ( ! StmOrig.IsValid() || pStmFinal == nullptr || ! pStmFinal->IsValid())
|
||||
return false ;
|
||||
|
||||
// creo un vettore di curve con Flag di lato aperto a partire dalla faccia originale
|
||||
ICRVCOMPOPOVECTOR vCrvWithTmpProps ;
|
||||
if ( ! GetOCCrvsWithProps( StmOrig, nFaceInd, vCrvWithTmpProps))
|
||||
return false ;
|
||||
|
||||
// creo la superficie finale da restituire
|
||||
SurfFlatRegionByContours SfrByC ;
|
||||
|
||||
// scorro tutti i loop della FlatRegion della superficie ottenuta dopo la proiezione
|
||||
for ( int c = 0 ; c < pSfrOrig.GetChunkCount() ; ++ c) {
|
||||
for ( int l = 0 ; l < pSfrOrig.GetLoopCount( c) ; ++ l) {
|
||||
// ricavo la curva composita associata al loop corrente
|
||||
PtrOwner<CurveComposite> pCrvCompoLoop( ConvertCurveToBasicComposite( pSfrOrig.GetLoop( c, l))) ;
|
||||
if ( IsNull( pCrvCompoLoop) || ! pCrvCompoLoop->IsValid())
|
||||
return false ;
|
||||
// scorro ogni curva del loop ottenuto
|
||||
for ( int u = 0 ; u < pCrvCompoLoop->GetCurveCount() ; ++ u) {
|
||||
bool bFound = false ;
|
||||
for ( int i = 0 ; i < int( vCrvWithTmpProps.size()) && !bFound ; ++ i) {
|
||||
int nStat = 0 ;
|
||||
if ( SetTmpPropByOverlap( pCrvCompoLoop, u, vCrvWithTmpProps[i], nStat, 50 * EPS_SMALL) && nStat == 1)
|
||||
bFound = true ;
|
||||
}
|
||||
// se overlap non trovato, allora la curva deriva da una proiezione, quindi chiusa
|
||||
if ( ! bFound) {
|
||||
pCrvCompoLoop->SetCurveTempProp( u, 0, 0) ; // <---- curva chiusa
|
||||
pCrvCompoLoop->SetCurveTempProp( u, -2, 1) ; // <---- derivante da proiezione
|
||||
}
|
||||
}
|
||||
// inserisco la curva con le proprietà definite
|
||||
SfrByC.AddCurve( Release( pCrvCompoLoop)) ;
|
||||
}
|
||||
}
|
||||
|
||||
// recupero la FlatRegion con le curve impostate
|
||||
PtrOwner<ISurfFlatRegion> pSfrWithTmpProps( SfrByC.GetSurf()) ;
|
||||
if ( IsNull( pSfrWithTmpProps) || ! pSfrWithTmpProps->IsValid())
|
||||
return false ;
|
||||
|
||||
// creo la TriMesh finale da restituire ed esco
|
||||
return SewNewStmFacesWithTmpProps( *pSfrWithTmpProps, plFace, pStmFinal) ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SubtractProjectedFacesOnStmFace( const ISurfTriMesh& Stm, int nFaceInd, ISURFTMPOVECTOR& vStmOthers, bool bOCFlag,
|
||||
bool& bExistProjection, ISurfTriMesh*& pStmRes, int& nNewFaceNbr)
|
||||
{
|
||||
// verifico validità della superificie originale
|
||||
if ( ! Stm.IsValid())
|
||||
return false ;
|
||||
|
||||
// ricavo la faccia su cui togliere le proiezioni
|
||||
PtrOwner<ISurfTriMesh> pStm_face( Stm.CloneFacet( nFaceInd)) ;
|
||||
if ( IsNull( pStm_face) || ! pStm_face->IsValid())
|
||||
return false ;
|
||||
|
||||
// imposto valori di ritorno di default
|
||||
bExistProjection = false ;
|
||||
nNewFaceNbr = 1 ;
|
||||
pStmRes = CreateSurfTriMesh() ;
|
||||
pStmRes->CopyFrom( pStm_face) ;
|
||||
|
||||
// dimensione dei vettori passati come parametri
|
||||
int nVStm_size = ( int)vStmOthers.size() ;
|
||||
bool bIsSize0 = ( nVStm_size == 0) ;
|
||||
if ( bIsSize0) {
|
||||
// se il vettore delle Trimesh dal proiettare è vuoto, la proeizione è fatta con le altre facce delle TriMesh
|
||||
PtrOwner<ISurfTriMesh> pStmNoSelFace( Stm.Clone()) ;
|
||||
if ( IsNull( pStmNoSelFace) || ! pStmNoSelFace->IsValid())
|
||||
return false ;
|
||||
// se la superficie ha solo una faccia e cerco di toglierla, allora non devo proiettare nulla...
|
||||
if ( pStmNoSelFace->GetFacetCount() == 1)
|
||||
return true ; // il flag BOCFlag non importa, ho tutti lati aperti
|
||||
// rimuovo la faccia da proiettare
|
||||
if ( ! pStmNoSelFace->RemoveFacet( nFaceInd))
|
||||
return false ;
|
||||
// controllo la validità di questa operazione
|
||||
if ( IsNull( pStmNoSelFace) || ! pStmNoSelFace->IsValid())
|
||||
return false ;
|
||||
// modifico il vettore delle TriMesh e delle loro facce
|
||||
vStmOthers.emplace_back( Release( pStmNoSelFace)) ;
|
||||
nVStm_size = 1 ;
|
||||
// NB. E' adottata questa strategia per evitare di proiettare un numero elevato di facce dovuto alla presenza
|
||||
// di archi; calcolo la GetSilhouette dell'intero contorno e non come unione delle singole facce proiettate
|
||||
}
|
||||
|
||||
// creo il sistema di riferimento ( inerente alla faccia selezionata)
|
||||
Point3d ptORIG ;
|
||||
Vector3d vtN ;
|
||||
if ( ! pStm_face->GetCentroid( ptORIG) || // ricavo origine
|
||||
! pStm_face->GetFacetNormal( 0, vtN)) // ricavo normale
|
||||
return false ;
|
||||
Frame3d frFace ; frFace.Set( ptORIG, vtN) ;
|
||||
if ( ! frFace.IsValid())
|
||||
return false ;
|
||||
|
||||
// creo un piano passante per la faccia selezionata ( di normale inversa per il taglio)
|
||||
// ( tutto ciò che sta nel semipiano negativo della faccia selezionata, non viene proiettato ma tagliato)
|
||||
Plane3d plFace ;
|
||||
plFace.Set( ptORIG, -vtN) ;
|
||||
if ( ! plFace.IsValid())
|
||||
return false ;
|
||||
|
||||
// ricavo il Box3D della faccia selezionata nel frame della faccia stessa
|
||||
Frame3d frH = frFace ; frH.Invert() ;
|
||||
BBox3d BBoxSelFace ;
|
||||
if ( ! pStm_face->GetBBox( frH, BBoxSelFace))
|
||||
return false ;
|
||||
|
||||
// superficie finale della proeizione
|
||||
PtrOwner<SurfFlatRegion> pSfr_proj( CreateBasicSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfr_proj))
|
||||
return false ;
|
||||
bool bExistProj = false ; // flag per indicare se almeno un triangolo è stato proiettato
|
||||
|
||||
// scorro le parti di superfici da proiettare...
|
||||
for ( int t = 0 ; t < nVStm_size ; ++ t) {
|
||||
|
||||
// TriMesh da proiettare
|
||||
PtrOwner<SurfTriMesh> pStm_CurrProj( CloneBasicSurfTriMesh( vStmOthers[t])) ;
|
||||
if ( IsNull( pStm_CurrProj) || ! pStm_CurrProj->IsValid())
|
||||
return false ;
|
||||
|
||||
// rimuovo dalla TriMesh tutte le facce che sono perpendicolari e tutte le facce il cui Box3D nel piano di
|
||||
// proeizione non fa overlap con quello della faccia selezionata
|
||||
|
||||
// scorro tutte le facce da proiettare
|
||||
PtrOwner<SurfTriMesh> pStmForProj_noPerpFaces( CreateBasicSurfTriMesh()) ;
|
||||
StmFromTriangleSoup StmFts ; StmFts.Start() ;
|
||||
for ( int f = 0 ; f < pStm_CurrProj->GetFacetCount() ; ++ f) {
|
||||
Vector3d vtN_curr ;
|
||||
// se perpendicolari alla faccia selezionata, le trascuro
|
||||
if ( pStm_CurrProj->GetFacetNormal( f, vtN_curr) && abs( vtN_curr * vtN) > 5 * EPS_SMALL) {
|
||||
BBox3d BBoxFace_f ;
|
||||
if ( ! pStm_CurrProj->GetFacetBBox( f, frH, BBoxFace_f))
|
||||
return false ;
|
||||
// se non c'è OverlapXY tra i due Box3D, la trascuro
|
||||
if ( BBoxSelFace.OverlapsXY( BBoxFace_f)) {
|
||||
PtrOwner<SurfTriMesh> pStm_Currface( pStm_CurrProj->CloneFacet( f)) ;
|
||||
if ( IsNull( pStm_Currface) || ! pStm_Currface->IsValid())
|
||||
return false ;
|
||||
Triangle3d Tria ;
|
||||
int nT = pStm_Currface->GetFirstTriangle( Tria) ;
|
||||
while ( nT != SVT_NULL) {
|
||||
// inserisco il triangolo nella nuova superficie
|
||||
StmFts.AddTriangle( Tria) ;
|
||||
// passo al triangolo successivo
|
||||
nT = pStm_Currface->GetNextTriangle( nT, Tria) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
StmFts.End() ;
|
||||
pStmForProj_noPerpFaces.Set( GetBasicSurfTriMesh( StmFts.GetSurf())) ;
|
||||
// se la nuova superficie da proittare non contiene nulla, allora passo alla successiva
|
||||
if ( ! pStmForProj_noPerpFaces->IsValid())
|
||||
continue ;
|
||||
// ricostruisco la nuova superificie semplificata da proiettare
|
||||
if ( ! pStmForProj_noPerpFaces->Repair() ||
|
||||
! pStm_CurrProj.Set( Release( pStmForProj_noPerpFaces)) ||
|
||||
IsNull( pStm_CurrProj) ||
|
||||
! pStm_CurrProj->IsValid())
|
||||
return false ;
|
||||
|
||||
// taglio la superficie con il piano creato ( la proiezione esclude le parti nel semipiano negativo)
|
||||
// controllo la validità di questa operazione ( la faccia potrebbe essere tutta nel semipiano negativo)
|
||||
if ( ! pStm_CurrProj->Cut( plFace, true))
|
||||
return false ;
|
||||
if ( IsNull( pStm_CurrProj) || ! pStm_CurrProj->IsValid() || pStm_CurrProj->GetTriangleCount() == 0)
|
||||
continue ;
|
||||
|
||||
// recupero la PolyLine della Silhouette
|
||||
POLYLINEVECTOR vPL ;
|
||||
if ( ! pStm_CurrProj->GetSilhouette( vtN, 100 * EPS_SMALL, vPL, true))
|
||||
return false ;
|
||||
|
||||
// converto le curve in composite
|
||||
// NB. Potrei ottenere più curve, quindi creo la FlatRegion associata
|
||||
SurfFlatRegionByContours sfrBCProj_face ;
|
||||
bool bValidCurrProj = false ;
|
||||
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
|
||||
PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo))
|
||||
return false ;
|
||||
pCrvCompo->FromPolyLine( vPL[i]) ;
|
||||
bool bSkip = true ; // flag per indicare se la curva è valida
|
||||
if ( ! ImproveCurve( pCrvCompo, frFace, plFace, bSkip))
|
||||
return false ;
|
||||
// se curva ammissibile, creo la sua FlatRegion
|
||||
if ( ! bSkip) {
|
||||
bValidCurrProj = true ;
|
||||
sfrBCProj_face.AddCurve( Release( pCrvCompo)) ;
|
||||
bExistProj = true ;
|
||||
}
|
||||
}
|
||||
// se proeizione non valida, allora passo all'entità successiva
|
||||
if ( ! bValidCurrProj)
|
||||
continue ;
|
||||
|
||||
// ricavo la FlatRegion associata alla proiezione delle faccia
|
||||
PtrOwner<ISurfFlatRegion> pSfr_proj_faceCurr( sfrBCProj_face.GetSurf()) ;
|
||||
if ( IsNull( pSfr_proj_faceCurr) || ! pSfr_proj_faceCurr->IsValid())
|
||||
return false ;
|
||||
|
||||
// inverto se necessario
|
||||
if ( AreOppositeVectorApprox( pSfr_proj_faceCurr->GetNormVersor(), vtN))
|
||||
pSfr_proj_faceCurr->Invert() ;
|
||||
|
||||
// la sommo alla regione di proeizione globale
|
||||
if ( ! pSfr_proj->IsValid() || pSfr_proj->GetChunkCount() == 0)
|
||||
pSfr_proj.Set( GetBasicSurfFlatRegion( Release( pSfr_proj_faceCurr))) ;
|
||||
else
|
||||
if ( ! pSfr_proj->Add( *pSfr_proj_faceCurr))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// se non c'è nulla da proiettare e flag bOCFlag false, allora esco
|
||||
if ( ! bExistProj && ! bOCFlag)
|
||||
return true ;
|
||||
|
||||
// FlatRegion associata alla faccia della TriMesh selezionata
|
||||
PtrOwner<SurfFlatRegion> pSfr_face( CreateBasicSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfr_face) || ! GetSfrByStm( pStm_face, pSfr_face, plFace) || ! pSfr_face->IsValid())
|
||||
return false ;
|
||||
// per sicurezza controllo la coerenza con le normali ( per fare la sottrazione)
|
||||
if ( AreOppositeVectorApprox( pSfr_face->GetNormVersor(), vtN))
|
||||
pSfr_face->Invert() ;
|
||||
|
||||
// superficie finale da restituire
|
||||
PtrOwner<SurfTriMesh> pStm_final( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pStm_final))
|
||||
return false ;
|
||||
|
||||
// *** se la proiezione esiste...
|
||||
if ( bExistProj) {
|
||||
// controllo validità della FlatRegion di proiezione globale
|
||||
if ( IsNull( pSfr_proj) || ! pSfr_proj->IsValid())
|
||||
return false ;
|
||||
// ho una proiezione ...
|
||||
bExistProjection = true ;
|
||||
// per sicurezza controllo la coerenza con le normali ( per fare la sottrazione)
|
||||
if ( AreOppositeVectorApprox( pSfr_proj->GetNormVersor(), vtN))
|
||||
pSfr_proj->Invert() ;
|
||||
// sottraggo le FlatRegions ( FlatRegion della faccia selezionata \ FlatRegion proiezione)
|
||||
if ( ! pSfr_face->Subtract( *pSfr_proj))
|
||||
return false ;
|
||||
// controllo validità della sottrazione
|
||||
if ( IsNull( pSfr_face) || ! pSfr_face->IsValid() || pSfr_face->GetChunkCount() == 0) {
|
||||
// la proiezione copre completamente la faccia selezionata
|
||||
delete( pStmRes) ;
|
||||
pStmRes = nullptr ;
|
||||
nNewFaceNbr = 0 ;
|
||||
return true ;
|
||||
}
|
||||
// aggiorno il numero di facce creato
|
||||
nNewFaceNbr = pSfr_face->GetChunkCount() ;
|
||||
}
|
||||
|
||||
// riconverto la FlatRegion in TriMesh ( per restituirla)
|
||||
const SurfTriMesh* pStm_tmp = pSfr_face->GetAuxSurf() ;
|
||||
if ( pStm_tmp == nullptr || ! pStm_tmp->IsValid())
|
||||
return false ;
|
||||
pStm_final.Set( pStm_tmp->Clone()) ;
|
||||
if ( IsNull( pStm_final) || ! pStm_final->IsValid())
|
||||
return false ;
|
||||
|
||||
// se richiesto aggiugno delle facce sui lati chiusi
|
||||
if ( bOCFlag)
|
||||
if ( ! AddClosedEdges( Stm, nFaceInd, *pSfr_face, plFace, pStm_final))
|
||||
return false ;
|
||||
|
||||
// assegno i valori di ritorno della funzione ed esco
|
||||
pStmRes->CopyFrom( pStm_final) ;
|
||||
return pStmRes->IsValid() && pStmRes->GetTriangleCount() > 0 ;
|
||||
}
|
||||
|
||||
+36
-97
@@ -19,10 +19,10 @@
|
||||
#include "CurveArc.h"
|
||||
#include "CurveBezier.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "SurfBezier.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EGkSurf.h"
|
||||
#include "/EgtDev/Include/EGkSurfAux.h"
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -31,7 +31,7 @@ NurbsSurfaceCanonicalize( SNurbsSurfData& snData)
|
||||
{
|
||||
// per rendere una superficie non periodica devo recuperare i punti di controllo, suddivisi in isoparametriche lungo una direzione
|
||||
// e applicare la trasformazione ad ogni isoparametrica, sostituendola poi a quella originale. ( si mantiene il numero di punti)
|
||||
if ( snData.bPeriodicU ) {
|
||||
if ( snData.bPeriodicU || ! snData.bClampedU) {
|
||||
bool bIsRational = snData.bRat ;
|
||||
// vettore dei nodi
|
||||
DBLVECTOR vU ;
|
||||
@@ -68,7 +68,7 @@ NurbsSurfaceCanonicalize( SNurbsSurfData& snData)
|
||||
}
|
||||
snData.bPeriodicU = false ;
|
||||
}
|
||||
if ( snData.bPeriodicV ) {
|
||||
if ( snData.bPeriodicV || ! snData.bClampedV) {
|
||||
bool bIsRational = snData.bRat ;
|
||||
// vettore dei nodi
|
||||
DBLVECTOR vV ;
|
||||
@@ -113,20 +113,6 @@ NurbsSurfaceCanonicalize( SNurbsSurfData& snData)
|
||||
ISurf*
|
||||
NurbsToBezierSurface(const SNurbsSurfData& snData)
|
||||
{
|
||||
//INTVECTOR vInt_sub( 10) ;
|
||||
//INTMATRIX vInt( 10, vInt_sub) ;
|
||||
//for ( int i = 0 ; i < 10 ; ++i ) {
|
||||
// for ( int j = 0 ; j < 10 ; ++j ) {
|
||||
// vInt[i][j] = i + 10 * j ;
|
||||
// }
|
||||
//}
|
||||
//vInt_sub.resize( 20) ;
|
||||
//vInt[0].resize( 20) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// la superficie Nurbs deve essere in forma canonica
|
||||
if ( snData.bPeriodicU || snData.bPeriodicV || snData.bExtraKnotes )
|
||||
return nullptr ;
|
||||
@@ -139,8 +125,6 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
//// numero degli intervalli
|
||||
//int nInt = nU - 2 * snData.nDeg + 1 ;
|
||||
// verifico le condizioni agli estremi sui nodi (i primi nDeg nodi e gli ultimi nDeg nodi devono essere uguali tra loro)
|
||||
bool bOk = true ;
|
||||
// direzione U
|
||||
@@ -164,49 +148,15 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
|
||||
if ( ! bOk)
|
||||
return nullptr ;
|
||||
|
||||
//// se 1 solo intervallo, la Nurbs ? gi? una curva di Bezier
|
||||
//if ( nInt == 1) {
|
||||
// // creo la curva di Bezier
|
||||
// PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
|
||||
// if ( IsNull( pCrvBez))
|
||||
// return nullptr ;
|
||||
// // la inizializzo
|
||||
// if ( ! pCrvBez->Init( snData.nDeg, snData.bRat))
|
||||
// return nullptr ;
|
||||
// for ( int i = 0 ; i <= snData.nDeg ; ++ i) {
|
||||
// if ( ! snData.bRat) {
|
||||
// if ( ! pCrvBez->SetControlPoint( i, snData.vCP[i]))
|
||||
// return nullptr ;
|
||||
// }
|
||||
// else {
|
||||
// if ( ! pCrvBez->SetControlPoint( i, snData.vCP[i], snData.vW[i]))
|
||||
// return nullptr ;
|
||||
// }
|
||||
// }
|
||||
// // se non ? una curva ma un punto, la invalido
|
||||
// if ( pCrvBez->IsAPoint())
|
||||
// pCrvBez->Init( snData.nDeg, snData.bRat) ;
|
||||
// // restituisco la curva
|
||||
// return Release( pCrvBez) ;
|
||||
//}
|
||||
|
||||
|
||||
// algoritmo 5.7 del libro "The NURBS book"//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// creazione delle strips nella direzione U ( trasformo le curve iso con U costante in bezier)
|
||||
int a = snData.nDegU - 1 ;
|
||||
int b = snData.nDegU ;
|
||||
int nb = 0 ; // numero di strisce in U ( lunghezza con U costante)
|
||||
//PNTVECTOR vBC ;
|
||||
//vBC.resize( snData.nCPV * snData.nDegU) ;
|
||||
//for (int row = 0 ; row < snData.nCPV ; ++row ) {
|
||||
// for ( int i = 0 ; i <= snData.nDegU ; ++i ) {
|
||||
// vBC[nDegU*row + i] = ( snData.vCP[nCPU*row + i]) ;
|
||||
// }
|
||||
//}
|
||||
vector<Point3d> vCPV( snData.nCPV) ;
|
||||
vector< vector<Point3d>> mBC (snData.nDegU + 1,vCPV ) ;
|
||||
vector< vector<Point3d>> mBC_next (snData.nDegU - 1, vCPV) ;
|
||||
vector< vector<Point3d>> mPC_strip(snData.nDegU + 1, vCPV) ; // matrice che verr? ingrandita e conterr? la superficie met? bezier e met? NURBS
|
||||
vector< vector<Point3d>> mPC_strip(snData.nDegU + 1, vCPV) ; // matrice che verrà ingrandita e conterrà la superficie metà bezier e metà NURBS
|
||||
DBLVECTOR vV_W( snData.nCPV) ;
|
||||
vector<DBLVECTOR> mW( snData.nDegU + 1, vV_W) ;
|
||||
vector<DBLVECTOR> mW_next( snData.nDegU - 1, vV_W) ;
|
||||
@@ -230,11 +180,7 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
|
||||
}
|
||||
|
||||
bool bRef = false ;
|
||||
// se la superficie ? lineare nel parametro U allora ? gi? in forma di Bezier in questo parametro
|
||||
if ( b == nU - 1 ) {
|
||||
nb = 1 ;
|
||||
}
|
||||
while ( b < nU - 1) { // qui correggo un probabile errore, mettendo nU anzich? nCPV, come indicato nell'algoritmo
|
||||
while ( snData.nDegU != 1 ? b < nU - 1 : b < nU) { // qui correggo un probabile errore, mettendo nU anziché nCPV, come indicato nell'algoritmo
|
||||
int i = b ;
|
||||
while ( b < nU - 1 && abs( snData.vU[b+1] - snData.vU[b]) < EPS_ZERO)
|
||||
++ b ;
|
||||
@@ -249,11 +195,6 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
|
||||
for ( int j = 1 ; j <= snData.nDegU - mult ; ++j ) {
|
||||
int save = r - j ;
|
||||
int s = mult + j ;
|
||||
//for ( int row = 0 ; row < snData.nCPV ; ++row) {
|
||||
// for ( int k = snData.nDegU ; k >= s ; --k ) {
|
||||
// vBC[nCPU*row + k] = vAlpha[k-s]*vBC[nCPU*row + k] + ( 1 - vAlfa[k-s]) * vBC[nCPU*row + k - 1]
|
||||
// }
|
||||
//}
|
||||
if ( ! snData.bRat ) {
|
||||
for ( int k = snData.nDegU ; k >= s ; --k ) {
|
||||
for ( int row = 0 ; row < snData.nCPV ; ++row) {
|
||||
@@ -318,14 +259,17 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
|
||||
}
|
||||
|
||||
if ( b < nU - 1 ) {
|
||||
for ( int i = snData.nDegU - mult ; i <= snData.nDegU ; ++ i) {
|
||||
for (int row = 0 ; row < snData.nCPV ; ++ row ) {
|
||||
mBC[i][row] = snData.mCP[b - snData.nDegU + i + 1][row] ;
|
||||
}
|
||||
}
|
||||
if ( snData.bRat ) {
|
||||
if ( ! snData.bRat ) {
|
||||
for ( int i = snData.nDegU - mult ; i <= snData.nDegU ; ++ i) {
|
||||
for (int row = 0 ; row < snData.nCPV ; ++ row ) {
|
||||
mBC[i][row] = snData.mCP[b - snData.nDegU + i + 1][row] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for ( int i = snData.nDegU - mult ; i <= snData.nDegU ; ++ i) {
|
||||
for (int row = 0 ; row < snData.nCPV ; ++ row ) {
|
||||
mBC[i][row] = snData.mCP[b - snData.nDegU + i + 1][row] * snData.mW[b - snData.nDegU + i + 1][row] ;
|
||||
mW[i][row] = snData.mW[b - snData.nDegU + i + 1][row] ;
|
||||
}
|
||||
}
|
||||
@@ -333,6 +277,10 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
|
||||
a = b ;
|
||||
++b ;
|
||||
}
|
||||
else if ( snData.nDegU == 1 && b < nU) {
|
||||
a = b ;
|
||||
++b ;
|
||||
}
|
||||
}
|
||||
|
||||
// se non ho raffinato allora tutti i nodi avevano gi? molteplicit? massima. Converto direttamente in Bezier la dir U
|
||||
@@ -356,8 +304,6 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
|
||||
}
|
||||
}
|
||||
}
|
||||
// devo vedere quante patch ci stanno prendendo i punti che ci sono
|
||||
//nb = (snData.nCPU - 1) / snData.nDegU ;
|
||||
}
|
||||
else
|
||||
nCPU_ref = snData.nDegU * nb + 1 ; // numero dei punti di controllo in U dopo il raffinamento
|
||||
@@ -395,11 +341,7 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
|
||||
}
|
||||
|
||||
bRef = false ;
|
||||
// se la superficie ? lineare nel parametro V allora ? gi? in forma di Bezier in questo parametro
|
||||
if ( b == nV - 1 ) {
|
||||
nc = 1 ;
|
||||
}
|
||||
while ( b < nV - 1) {
|
||||
while ( snData.nDegV != 1 ? b < nV - 1 : b < nV) { // qui correggo un probabile errore, mettendo nU anziché nCPV, come indicato nell'algoritmo
|
||||
int i = b ;
|
||||
while ( b < nV - 1 && abs( snData.vV[b+1] - snData.vV[b]) < EPS_ZERO)
|
||||
++ b ;
|
||||
@@ -414,11 +356,6 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
|
||||
for ( int j = 1 ; j <= snData.nDegV - mult ; ++j ) {
|
||||
int save = r - j ;
|
||||
int s = mult + j ;
|
||||
//for ( int row = 0 ; row < snData.nCPV ; ++row) {
|
||||
// for ( int k = snData.nDegU ; k >= s ; --k ) {
|
||||
// vBC[nCPU*row + k] = vAlpha1[k-s]*vBC[nCPU*row + k] + ( 1 - vAlpha1[k-s]) * vBC[nCPU*row + k - 1]
|
||||
// }
|
||||
//}
|
||||
if ( ! snData.bRat) {
|
||||
for ( int k = 0 ; k < nCPU_ref ; ++k) {
|
||||
for ( int row = snData.nDegV ; row >= s ; --row ) {
|
||||
@@ -444,7 +381,7 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
|
||||
else {
|
||||
for ( int i = 0 ; i < nCPU_ref ; ++i) {
|
||||
m_BC1_next[i][save] = m_BC1[i][snData.nDegV] ;
|
||||
mW1_next[save] = mW1[snData.nDegV] ;
|
||||
mW1_next[i][save] = mW1[i][snData.nDegV] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -490,16 +427,17 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
|
||||
}
|
||||
|
||||
if ( b < nV - 1) {
|
||||
for (int i = 0 ; i < nCPU_ref ; ++ i ) {
|
||||
for ( int row = snData.nDegV - mult ; row <= snData.nDegV ; ++ row) {
|
||||
//m_BC1[i][row] = snData.mCP[i][b - snData.nDegV + row + 1] ;
|
||||
m_BC1[i][row] = mPC_strip[i][b - snData.nDegV + row + 1] ;
|
||||
}
|
||||
}
|
||||
if ( snData.bRat ) {
|
||||
if ( ! snData.bRat) {
|
||||
for (int i = 0 ; i < nCPU_ref ; ++ i ) {
|
||||
for ( int row = snData.nDegV - mult ; row <= snData.nDegV ; ++ row) {
|
||||
//mW1[i][row] = snData.mW[i][b - snData.nDegV + row + 1] ;
|
||||
m_BC1[i][row] = mPC_strip[i][b - snData.nDegV + row + 1] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int i = 0 ; i < nCPU_ref ; ++ i ) {
|
||||
for ( int row = snData.nDegV - mult ; row <= snData.nDegV ; ++ row) {
|
||||
m_BC1[i][row] = mPC_strip[i][b - snData.nDegV + row + 1] * mW_strip[i][b - snData.nDegV + row + 1] ;
|
||||
mW1[i][row] = mW_strip[i][b - snData.nDegV + row + 1] ;
|
||||
}
|
||||
}
|
||||
@@ -507,7 +445,10 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
|
||||
a = b ;
|
||||
++b ;
|
||||
}
|
||||
|
||||
else if ( snData.nDegV == 1 && b < nV) {
|
||||
a = b ;
|
||||
++b ;
|
||||
}
|
||||
}
|
||||
// se non ho raffinato allora aggiungo direttamente alle matrici della superficie totale
|
||||
int nCPV_ref ; // numero dei punti di controllo in V dopo il raffinamento
|
||||
@@ -532,14 +473,12 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
|
||||
}
|
||||
}
|
||||
}
|
||||
// devo vedere quante patch ci stanno prendendo i punti che ci sono
|
||||
//nc = (snData.nCPV - 1) / snData.nDegV ;
|
||||
}
|
||||
else
|
||||
nCPV_ref = snData.nDegV * nc + 1 ;
|
||||
|
||||
// finalmente setto la superficie di bezier totale divisa in nb patch in U e nc patch in V
|
||||
PtrOwner<ISurfBezier> pSrfBz( CreateSurfBezier()) ;
|
||||
PtrOwner<SurfBezier> pSrfBz( CreateBasicSurfBezier()) ;
|
||||
if ( IsNull( pSrfBz))
|
||||
return nullptr ;
|
||||
pSrfBz->Init(snData.nDegU, snData.nDegV, nb, nc, snData.bRat) ;
|
||||
@@ -553,9 +492,9 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
|
||||
else {
|
||||
for ( int i = 0 ; i < nCPU_ref; ++ i) {
|
||||
for (int j = 0 ; j < nCPV_ref; ++j) {
|
||||
pSrfBz->SetControlPoint( i + nCPU_ref * j, mPC_tot[i][j] / mW_tot[i][j], mW_tot[i][j]) ;
|
||||
pSrfBz->SetControlPoint( i + nCPU_ref * j, mPC_tot[i][j] /*/ mW_tot[i][j]*/, mW_tot[i][j]) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Release( pSrfBz) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,20 +14,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkSurfAux.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//bool IsClosed( const ICurve& crvC) ;
|
||||
//bool IsValidParam( const ICurve& crvC, double dPar, ICurve::Side nSide) ;
|
||||
//bool IsStartParam( const ICurve& crvC, double dPar) ;
|
||||
//bool IsEndParam( const ICurve& crvC, double dPar) ;
|
||||
//bool GetNearestExtremityToPoint( const Point3d& ptP, const ICurve& Curve, bool& bStart) ;
|
||||
//bool MoveParamToAvoidTg( double& dU, ICurve::Side nSide, const ICurve& Curve) ;
|
||||
//bool GetTang( const ICurve& crvC, double dU, ICurve::Side nS, Vector3d& vtTang) ;
|
||||
//bool GetPointTang( const ICurve& crvC, double dU, ICurve::Side nS, Point3d& ptPos, Vector3d& vtTang) ;
|
||||
//bool GetPointDiffGeom( const ICurve& crvC, double dU, ICurve::Side nS, CrvPointDiffGeom& oDiffG) ;
|
||||
//bool ImproveCurveParamAtPoint( double& dU, const Point3d& ptP, const ICurve* pCrv) ;
|
||||
//bool CurveGetAreaXY( const ICurve& crvC, double& dArea) ;
|
||||
//bool CurveGetArea( const ICurve& crvC, Plane3d& plPlane, double& dArea) ;
|
||||
//bool CurveDump( const ICurve& crvC, std::string& sOut, bool bMM, const char* szNewLine) ;
|
||||
//bool CopyExtrusion( const ICurve* pSouCrv, ICurve* pDestCrv) ;
|
||||
//bool CopyThickness( const ICurve* pSouCrv, ICurve* pDestCrv) ;
|
||||
|
||||
+268
-116
@@ -20,6 +20,9 @@
|
||||
#include "Bernstein.h"
|
||||
#include "CurveBezier.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "Tree.h"
|
||||
#include "Triangulate.h"
|
||||
#include "SurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
@@ -33,12 +36,10 @@ using namespace std ;
|
||||
GEOOBJ_REGISTER( SRF_BEZIER, NGE_S_BEZ, SurfBezier) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
SurfBezier::SurfBezier(void)
|
||||
SurfBezier::SurfBezier( void)
|
||||
: m_pSTM( nullptr), m_nStatus( TO_VERIFY), m_nDegU(), m_nDegV(), m_nSpanU(), m_nSpanV(), m_bRat( false),
|
||||
m_bTrimmed( false), m_pTrimReg( nullptr)
|
||||
m_bTrimmed( false), m_pTrimReg( nullptr), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -53,7 +54,7 @@ SurfBezier::~SurfBezier( void)
|
||||
bool
|
||||
SurfBezier::Init( int nDegU, int nDegV, int nSpanU, int nSpanV, bool bIsRational)
|
||||
{
|
||||
// verifico validità grado
|
||||
// verifico validit� grado
|
||||
if ( nDegU < 1 || nDegU > MAXDEG || nDegV < 1 || nDegV > MAXDEG || nSpanU < 1 || nSpanV < 1)
|
||||
return false ;
|
||||
|
||||
@@ -85,7 +86,7 @@ SurfBezier::Init( int nDegU, int nDegV, int nSpanU, int nSpanV, bool bIsRational
|
||||
bool
|
||||
SurfBezier::SetControlPoint( int nInd, const Point3d& ptCtrl)
|
||||
{
|
||||
// verifico validità indice
|
||||
// verifico validit� indice
|
||||
if ( m_nStatus != OK || m_bRat || nInd < 0 || nInd >= GetDim())
|
||||
return false ;
|
||||
|
||||
@@ -107,7 +108,7 @@ SurfBezier::SetControlPoint( int nInd, const Point3d& ptCtrl)
|
||||
bool
|
||||
SurfBezier::SetControlPoint( int nInd, const Point3d& ptCtrl, double dW)
|
||||
{
|
||||
// verifico validità, razionalità e indice
|
||||
// verifico validit�, razionalit� e indice
|
||||
if ( m_nStatus != OK || ! m_bRat || nInd < 0 || nInd >= GetDim())
|
||||
return false ;
|
||||
|
||||
@@ -144,11 +145,20 @@ SurfBezier::SetTrimRegion( const ISurfFlatRegion& sfrTrimReg)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
SurfFlatRegion*
|
||||
SurfBezier::GetTrimRegion( void) const
|
||||
{
|
||||
if ( ! m_bTrimmed || m_pTrimReg == nullptr )
|
||||
return nullptr ;
|
||||
return m_pTrimReg ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfBezier::GetInfo( int& nDegU, int& nDegV, int& nSpanU, int& nSpanV, bool& bIsRat, bool& bTrimmed) const
|
||||
{
|
||||
// verifico validità superficie
|
||||
// verifico validit� superficie
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// restituisco gradi e flag di razionale
|
||||
@@ -165,7 +175,7 @@ SurfBezier::GetInfo( int& nDegU, int& nDegV, int& nSpanU, int& nSpanV, bool& bIs
|
||||
const Point3d&
|
||||
SurfBezier::GetControlPoint( int nInd, bool* pbOk) const
|
||||
{
|
||||
// verifico validità e indice
|
||||
// verifico validit� e indice
|
||||
if ( m_nStatus != OK || nInd < 0 || nInd >= GetDim()) {
|
||||
if ( pbOk != NULL)
|
||||
*pbOk = false ;
|
||||
@@ -181,7 +191,7 @@ SurfBezier::GetControlPoint( int nInd, bool* pbOk) const
|
||||
double
|
||||
SurfBezier::GetControlWeight( int nInd, bool* pbOk) const
|
||||
{
|
||||
// verifico validità, razionalità e indice
|
||||
// verifico validit�, razionalit� e indice
|
||||
if ( m_nStatus != OK || ! m_bRat || nInd < 0 || nInd >= GetDim()) {
|
||||
if ( pbOk != NULL)
|
||||
*pbOk = false ;
|
||||
@@ -219,8 +229,9 @@ SurfBezier::GetArea( double& dArea) const
|
||||
// inizio con area nulla
|
||||
dArea = 0 ;
|
||||
// calcolo l'area
|
||||
if ( ! GetAuxSurf())
|
||||
return false ;
|
||||
if ( m_pSTM == nullptr)
|
||||
if ( ! GetAuxSurf())
|
||||
return false ;
|
||||
return m_pSTM->GetArea( dArea) ;
|
||||
}
|
||||
|
||||
@@ -234,8 +245,9 @@ SurfBezier::GetCentroid( Point3d& ptCen) const
|
||||
// inizio con centro nell'origine
|
||||
ptCen = ORIG ;
|
||||
// calcolo il baricentro
|
||||
if ( ! GetAuxSurf())
|
||||
return false ;
|
||||
if ( m_pSTM == nullptr)
|
||||
if ( ! GetAuxSurf())
|
||||
return false ;
|
||||
return m_pSTM->GetCentroid( ptCen) ;
|
||||
}
|
||||
|
||||
@@ -491,7 +503,7 @@ SurfBezier::GetPointNrmD1D2( double dU, double dV, Side nUs, Side nVs,
|
||||
if ( vtN.Normalize())
|
||||
return true ;
|
||||
|
||||
// se solo una delle due derivate è piccola, mi sposto lungo il relativo parametro e uso le tangenti
|
||||
// se solo una delle due derivate � piccola, mi sposto lungo il relativo parametro e uso le tangenti
|
||||
if ( pvtDerU->Len() < EPS_SMALL && pvtDerV->Len() > 10 * EPS_SMALL) {
|
||||
double dCoeff = ( dU - 1000 * EPS_PARAM < 0. ? 1 : -1) ;
|
||||
double dUm = dU + 1000 * EPS_PARAM * dCoeff ;
|
||||
@@ -568,8 +580,14 @@ SurfBezier::CopyFrom( const SurfBezier& sbSrc)
|
||||
m_vPtCtrl = sbSrc.m_vPtCtrl ;
|
||||
if ( sbSrc.m_bRat)
|
||||
m_vWeCtrl = sbSrc.m_vWeCtrl ;
|
||||
if ( sbSrc.m_bTrimmed) {
|
||||
m_bTrimmed = true ;
|
||||
m_pTrimReg = sbSrc.m_pTrimReg->Clone() ;
|
||||
}
|
||||
m_nTempProp[0] = sbSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = sbSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = sbSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = sbSrc.m_dTempParam[1] ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -592,7 +610,7 @@ SurfBezier::GetTitle( void) const
|
||||
bool
|
||||
SurfBezier::Dump( string& sOut, bool bMM, const char* szNewLine) const
|
||||
{
|
||||
// verifico validità superficie
|
||||
// verifico validit� superficie
|
||||
if ( m_nStatus != OK)
|
||||
sOut += string( "Status=Invalid") + szNewLine ;
|
||||
// area
|
||||
@@ -725,7 +743,8 @@ SurfBezier::Load( NgeReader& ngeIn)
|
||||
}
|
||||
}
|
||||
// se trimmata, lettura della regione
|
||||
if ( m_bTrimmed) {
|
||||
if ( bTrimmed) {
|
||||
m_bTrimmed = true ;
|
||||
// creo l'oggetto
|
||||
ResetTrimRegion() ;
|
||||
m_pTrimReg = CreateBasicSurfFlatRegion() ;
|
||||
@@ -733,7 +752,7 @@ SurfBezier::Load( NgeReader& ngeIn)
|
||||
return false ;
|
||||
// ne leggo i dati
|
||||
IGeoObjRW* pGObjRW = dynamic_cast<IGeoObjRW*>( m_pTrimReg) ;
|
||||
if ( pGObjRW == nullptr || pGObjRW->Load( ngeIn))
|
||||
if ( pGObjRW == nullptr || ! pGObjRW->Load( ngeIn))
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -766,8 +785,9 @@ SurfBezier::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
|
||||
// deve essere preciso
|
||||
else {
|
||||
// verifico esistenza trimesh associata
|
||||
if ( ! GetAuxSurf())
|
||||
return false ;
|
||||
if ( m_pSTM == nullptr)
|
||||
if ( ! GetAuxSurf())
|
||||
return false ;
|
||||
// calcolo il box della trimesh
|
||||
return m_pSTM->GetLocalBBox( b3Loc, nFlag) ;
|
||||
}
|
||||
@@ -789,8 +809,9 @@ SurfBezier::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
||||
// deve essere preciso
|
||||
else {
|
||||
// verifico esistenza trimesh associata
|
||||
if ( ! GetAuxSurf())
|
||||
return false ;
|
||||
if ( m_pSTM == nullptr)
|
||||
if ( ! GetAuxSurf())
|
||||
return false ;
|
||||
// calcolo il box della trimesh
|
||||
return m_pSTM->GetBBox( frRef, b3Ref, nFlag) ;
|
||||
}
|
||||
@@ -822,7 +843,7 @@ SurfBezier::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, d
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità dell'asse di rotazione
|
||||
// verifico validit� dell'asse di rotazione
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
|
||||
@@ -878,7 +899,7 @@ SurfBezier::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità del piano di specchiatura
|
||||
// verifico validit� del piano di specchiatura
|
||||
if ( vtNorm.IsSmall())
|
||||
return false ;
|
||||
|
||||
@@ -901,7 +922,7 @@ SurfBezier::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d&
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità dei parametri
|
||||
// verifico validit� dei parametri
|
||||
if ( vtNorm.IsSmall() || vtDir.IsSmall())
|
||||
return false ;
|
||||
|
||||
@@ -923,11 +944,11 @@ SurfBezier::ToGlob( const Frame3d& frRef)
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità del frame
|
||||
// verifico validit� del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se frame identità, non devo fare alcunché
|
||||
// se frame identit�, non devo fare alcunch�
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
@@ -949,11 +970,11 @@ SurfBezier::ToLoc( const Frame3d& frRef)
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità del frame
|
||||
// verifico validit� del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se frame identità, non devo fare alcunché
|
||||
// se frame identit�, non devo fare alcunch�
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
@@ -975,11 +996,11 @@ SurfBezier::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità dei frame
|
||||
// verifico validit� dei frame
|
||||
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se i due riferimenti coincidono, non devo fare alcunché
|
||||
// se i due riferimenti coincidono, non devo fare alcunch�
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
|
||||
@@ -1006,28 +1027,23 @@ SurfBezier::Invert( void)
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// inverto
|
||||
PNTVECTOR vPtCtrl = m_vPtCtrl ;
|
||||
int l = 0 ;
|
||||
for ( int i = 0 ; i <= m_nDegU ; ++ i) {
|
||||
for ( int j = 0 ; j <= m_nDegV ; ++ j) {
|
||||
int k = i + ( m_nDegU + 1) * j ;
|
||||
m_vPtCtrl[l] = vPtCtrl[k] ;
|
||||
++ l ;
|
||||
// inverto i punti del parametro U
|
||||
PNTVECTOR vPtCtrl_inv( m_vPtCtrl.size()) ;
|
||||
|
||||
for ( int j = 0 ; j < m_nDegV * m_nSpanV + 1; ++j) {
|
||||
for ( int i = 0 ; i < m_nDegU * m_nSpanU + 1; ++i) {
|
||||
vPtCtrl_inv[ i + j * ( m_nDegU * m_nSpanU + 1)] = m_vPtCtrl[ ( m_nDegU * m_nSpanU - i) + j * ( m_nDegU * m_nSpanU + 1)] ;
|
||||
}
|
||||
}
|
||||
if ( m_bRat) {
|
||||
DBLVECTOR vWeCtrl = m_vWeCtrl ;
|
||||
int lr = 0 ;
|
||||
for ( int i = 0 ; i <= m_nDegU ; ++ i) {
|
||||
for ( int j = 0 ; j <= m_nDegV ; ++ j) {
|
||||
int k = i + ( m_nDegU + 1) * j ;
|
||||
m_vWeCtrl[lr] = vWeCtrl[k] ;
|
||||
++ lr ;
|
||||
}
|
||||
}
|
||||
m_vPtCtrl = vPtCtrl_inv ;
|
||||
|
||||
if ( m_bTrimmed) {
|
||||
// inverto la flat region di trim
|
||||
//( la specchio rispetto all'asse verticale)
|
||||
Point3d pt( m_nSpanU * SBZ_TREG_COEFF/2, 0, 0) ;
|
||||
Vector3d vt( 1, 0, 0) ;
|
||||
m_pTrimReg->Mirror( pt, vt) ;
|
||||
}
|
||||
swap( m_nDegU, m_nDegV) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -1218,39 +1234,62 @@ SurfBezier::GetCurveOnV( double dU) const
|
||||
CurveComposite*
|
||||
SurfBezier::GetLoop( int nLoop) const
|
||||
{
|
||||
// Se superficie completa, basta concatenare le 4 isoparametriche di bordo
|
||||
if ( ! m_bTrimmed) {
|
||||
// Esiste solo il loop esterno
|
||||
if ( nLoop != 0)
|
||||
// Il primo loop sono le 4 isoparametriche di bordo concatenate
|
||||
if ( ! m_bTrimmed ) {
|
||||
if ( nLoop != 0 )
|
||||
return nullptr ;
|
||||
// Loop
|
||||
// Loop
|
||||
PtrOwner<CurveComposite> pLoop( CreateBasicCurveComposite()) ;
|
||||
// prima curva isoparametrica in U con V=0
|
||||
// prima curva isoparametrica in U con V=0
|
||||
PtrOwner<CurveComposite> pCrvCoU0( GetCurveOnU( 0)) ;
|
||||
if ( ! IsNull( pCrvCoU0) && ! pCrvCoU0->IsAPoint())
|
||||
pLoop->AddCurve( Release( pCrvCoU0)) ;
|
||||
// seconda curva isoparametrica in V con U=m_nSpanU
|
||||
// seconda curva isoparametrica in V con U=m_nSpanU
|
||||
PtrOwner<CurveComposite> pCrvCoV1( GetCurveOnV( m_nSpanU)) ;
|
||||
if ( ! IsNull( pCrvCoV1) && ! pCrvCoV1->IsAPoint())
|
||||
pLoop->AddCurve( Release( pCrvCoV1)) ;
|
||||
// terza curva isoparametrica in U con V=m_nSpanV invertita
|
||||
// terza curva isoparametrica in U con V=m_nSpanV invertita
|
||||
PtrOwner<CurveComposite> pCrvCoU1( GetCurveOnU( m_nSpanV)) ;
|
||||
if ( ! IsNull( pCrvCoU1) && ! pCrvCoU1->IsAPoint()) {
|
||||
pCrvCoU1->Invert() ;
|
||||
pLoop->AddCurve( Release( pCrvCoU1)) ;
|
||||
}
|
||||
// quarta curva isoparametrica in V con U=0 invertita
|
||||
// quarta curva isoparametrica in V con U=0 invertita
|
||||
PtrOwner<CurveComposite> pCrvCoV0( GetCurveOnV( 0)) ;
|
||||
if ( ! IsNull( pCrvCoV0) && ! pCrvCoV0->IsAPoint()) {
|
||||
pCrvCoV0->Invert() ;
|
||||
pLoop->AddCurve( Release( pCrvCoV0)) ;
|
||||
}
|
||||
// se loop chiuso lo restituisco, altrimenti errore
|
||||
// se loop chiuso lo restituisco, altrimenti errore
|
||||
return ( pLoop->IsClosed() ? Release( pLoop) : nullptr) ;
|
||||
}
|
||||
// altrimenti trimmata, per ora non gestita
|
||||
else
|
||||
return nullptr ;
|
||||
// la superficie � trimmata, quindi devo cercare nei vari chunck il loop corrispondente
|
||||
else {
|
||||
if ( nLoop > m_pTrimReg->GetChunkCount())
|
||||
return nullptr ;
|
||||
else {
|
||||
int nLoopCount = 0 ;
|
||||
int nChunck = 0, nLoopLoc = 0;
|
||||
INTVECTOR nLoopCountPerChunck ;
|
||||
for ( int i = 0 ; i < m_pTrimReg->GetChunkCount() && nLoopCount != nLoop ; ++ i) {
|
||||
int nLoopCountLoc = 0 ;
|
||||
for ( int j = 0 ; j < m_pTrimReg->GetLoopCount( i) ; ++ j) {
|
||||
++ nLoopCountLoc ;
|
||||
++ nLoopCount ;
|
||||
if ( nLoopCount != nLoop ) {
|
||||
nChunck = i ;
|
||||
nLoopLoc = j ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
nLoopCountPerChunck.push_back( nLoopCountLoc) ;
|
||||
}
|
||||
if ( nLoopCount < nLoop )
|
||||
return nullptr ;
|
||||
PtrOwner<CurveComposite> pLoop( GetBasicCurveComposite( m_pTrimReg->GetLoop( nChunck, nLoopLoc))) ;
|
||||
return Release( pLoop) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1372,6 +1411,82 @@ SurfBezier::GetCurveOnVApproxLen( double dU) const
|
||||
return 0 ;
|
||||
return dLen ;
|
||||
}
|
||||
//
|
||||
////----------------------------------------------------------------------------
|
||||
//const SurfTriMesh*
|
||||
//SurfBezier::GetAuxSurf( void) const
|
||||
//{
|
||||
// // la superficie deve essere validata
|
||||
// if ( m_nStatus != OK) {
|
||||
// ResetAuxSurf() ;
|
||||
// return nullptr ;
|
||||
// }
|
||||
// // se gi� calcolata, la restituisco
|
||||
// if ( m_pSTM != nullptr)
|
||||
// return m_pSTM ;
|
||||
// // costruttore della superficie
|
||||
// StmFromTriangleSoup stmSoup ;
|
||||
// if ( ! stmSoup.Start())
|
||||
// return nullptr ;
|
||||
// // definisco il numero degli step in U e in V
|
||||
// double dMaxLenU = 0 ;
|
||||
// for ( int j = 0 ; j <= m_nDegV * m_nSpanV ; ++ j)
|
||||
// dMaxLenU = max( dMaxLenU, GetCurveOnUApproxLen( double( j) / m_nDegV)) ;
|
||||
// int nStepU = GetSteps( m_nDegU, m_nSpanU, dMaxLenU, 2) ;
|
||||
// double dMaxLenV = 0 ;
|
||||
// for ( int i = 0 ; i <= m_nDegU * m_nSpanU ; ++ i)
|
||||
// dMaxLenV = max( dMaxLenV, GetCurveOnVApproxLen( double( i) / m_nDegU)) ;
|
||||
// int nStepV = GetSteps( m_nDegV, m_nSpanV, dMaxLenV, 2) ;
|
||||
// // prima curva isoparametrica (potrebbe essere un solo punto)
|
||||
// PolyLine PL1 ;
|
||||
// GetCurveOnU( 0, nStepU, PL1) ;
|
||||
// bool bSingle1 = ( PL1.GetPointNbr() == 1) ;
|
||||
// // ciclo sulle isoparametriche
|
||||
// for ( int i = 1 ; i <= nStepV ; ++ i) {
|
||||
// // seconda curva isoparametrica (con tanti punti quanti la prima, oppure uno solo)
|
||||
// double dV = double( i) * m_nSpanV / nStepV ;
|
||||
// PolyLine PL2 ;
|
||||
// GetCurveOnU( dV, nStepU, PL2) ;
|
||||
// bool bSingle2 = ( PL2.GetPointNbr() == 1) ;
|
||||
// // inserisco i triangoli della striscia nel costruttore della TriMesh
|
||||
// Point3d ptP1c, ptP2c ;
|
||||
// Point3d ptP1n, ptP2n ;
|
||||
// bool bNext = PL1.GetFirstPoint( ptP1c) && PL2.GetFirstPoint( ptP2c) ;
|
||||
// if ( bNext) {
|
||||
// if ( bSingle1 && bSingle2)
|
||||
// bNext = false ;
|
||||
// if ( bSingle1)
|
||||
// ptP1n = ptP1c ;
|
||||
// else
|
||||
// bNext = bNext && PL1.GetNextPoint( ptP1n) ;
|
||||
// if ( bSingle2)
|
||||
// ptP2n = ptP2c ;
|
||||
// else
|
||||
// bNext = bNext && PL2.GetNextPoint( ptP2n) ;
|
||||
// }
|
||||
// while ( bNext) {
|
||||
// // eventuale primo triangolo (con base sui correnti e vertice su P2 successivo)
|
||||
// if ( ! AreSamePointApprox( ptP1c, ptP2c))
|
||||
// stmSoup.AddTriangle( ptP2c, ptP1c, ptP2n) ;
|
||||
// // eventuale secondo triangolo (con vertice su P1 corrente e base sui successivi)
|
||||
// if ( ! AreSamePointApprox( ptP1n, ptP2n))
|
||||
// stmSoup.AddTriangle( ptP1c, ptP1n, ptP2n) ;
|
||||
// // passo alla successiva coppia
|
||||
// ptP1c = ptP1n ;
|
||||
// ptP2c = ptP2n ;
|
||||
// bNext = ( bSingle1 || PL1.GetNextPoint( ptP1n)) && ( bSingle2 || PL2.GetNextPoint( ptP2n)) ;
|
||||
// }
|
||||
// // salvo isoparametrica PL2 in PL1
|
||||
// PL1.GetUPointList().swap( PL2.GetUPointList()) ;
|
||||
// bSingle1 = bSingle2 ;
|
||||
// }
|
||||
// // la completo
|
||||
// if ( ! stmSoup.End())
|
||||
// return nullptr ;
|
||||
// // la salvo
|
||||
// m_pSTM = GetBasicSurfTriMesh( stmSoup.GetSurf()) ;
|
||||
// return m_pSTM ;
|
||||
//}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const SurfTriMesh*
|
||||
@@ -1382,73 +1497,110 @@ SurfBezier::GetAuxSurf( void) const
|
||||
ResetAuxSurf() ;
|
||||
return nullptr ;
|
||||
}
|
||||
// se già calcolata, la restituisco
|
||||
// se gi� calcolata, la restituisco
|
||||
if ( m_pSTM != nullptr)
|
||||
return m_pSTM ;
|
||||
|
||||
// costruttore della superficie
|
||||
POLYLINEMATRIX vvPL ;
|
||||
//POLYLINEVECTOR vPL ; // per usare i polygon basic
|
||||
Tree Tree( this, true) ;
|
||||
BIPNTVECTOR vTrees ;
|
||||
Tree.GetIndependentTrees( vTrees) ;
|
||||
bool bTest = false ; // per debug
|
||||
for ( int i = 0 ; i < (int) vTrees.size() ; ++ i) {
|
||||
Point3d ptMin = std::get<0>( vTrees[i]) ;
|
||||
Point3d ptMax = std::get<1>( vTrees[i]) ;
|
||||
Tree.SetSurf( this, true, ptMin, ptMax) ;
|
||||
if ( bTest) {
|
||||
Tree.BuildTree_test() ; // per debug
|
||||
//Tree.BuildTree( 5 * LIN_TOL_FINE, 1) ; // per debug
|
||||
Tree.SetTestMode() ;
|
||||
}
|
||||
else {
|
||||
Tree.BuildTree( 5 * LIN_TOL_FINE, 0.1) ;
|
||||
}
|
||||
Tree.GetPolygons( vvPL) ;
|
||||
|
||||
//Tree.GetPolygonsBasic( vPL) ; // per usare i polygon basic
|
||||
}
|
||||
//// per usare i polygon basic//////////////////////
|
||||
//for (int k = 0 ; k < (int)vPL.size(); ++k) {
|
||||
// vvPL.emplace_back() ;
|
||||
// vvPL.back().push_back(vPL[k]) ;
|
||||
//}
|
||||
//// per usare i polygon basic///////////////////
|
||||
|
||||
// qui non sarebbe male stampare un messaggio di errore nel log se avevo un'area da disegnare ma non sono usciti dei poligoni
|
||||
if ( int(vvPL.size()) == 0)
|
||||
LOG_DBG_ERR( GetEGkLogger(), "ERROR : Bezier Surface couldn't be triangulated, hence wasn't drawn") ;
|
||||
|
||||
StmFromTriangleSoup stmSoup ;
|
||||
if ( ! stmSoup.Start())
|
||||
return nullptr ;
|
||||
// definisco il numero degli step in U e in V
|
||||
double dMaxLenU = 0 ;
|
||||
for ( int j = 0 ; j <= m_nDegV * m_nSpanV ; ++ j)
|
||||
dMaxLenU = max( dMaxLenU, GetCurveOnUApproxLen( double( j) / m_nDegV)) ;
|
||||
int nStepU = GetSteps( m_nDegU, m_nSpanU, dMaxLenU, 2) ;
|
||||
double dMaxLenV = 0 ;
|
||||
for ( int i = 0 ; i <= m_nDegU * m_nSpanU ; ++ i)
|
||||
dMaxLenV = max( dMaxLenV, GetCurveOnVApproxLen( double( i) / m_nDegU)) ;
|
||||
int nStepV = GetSteps( m_nDegV, m_nSpanV, dMaxLenV, 2) ;
|
||||
// prima curva isoparametrica (potrebbe essere un solo punto)
|
||||
PolyLine PL1 ;
|
||||
GetCurveOnU( 0, nStepU, PL1) ;
|
||||
bool bSingle1 = ( PL1.GetPointNbr() == 1) ;
|
||||
// ciclo sulle isoparametriche
|
||||
for ( int i = 1 ; i <= nStepV ; ++ i) {
|
||||
// seconda curva isoparametrica (con tanti punti quanti la prima, oppure uno solo)
|
||||
double dV = double( i) * m_nSpanV / nStepV ;
|
||||
PolyLine PL2 ;
|
||||
GetCurveOnU( dV, nStepU, PL2) ;
|
||||
bool bSingle2 = ( PL2.GetPointNbr() == 1) ;
|
||||
// inserisco i triangoli della striscia nel costruttore della TriMesh
|
||||
Point3d ptP1c, ptP2c ;
|
||||
Point3d ptP1n, ptP2n ;
|
||||
bool bNext = PL1.GetFirstPoint( ptP1c) && PL2.GetFirstPoint( ptP2c) ;
|
||||
if ( bNext) {
|
||||
if ( bSingle1 && bSingle2)
|
||||
bNext = false ;
|
||||
if ( bSingle1)
|
||||
ptP1n = ptP1c ;
|
||||
else
|
||||
bNext = bNext && PL1.GetNextPoint( ptP1n) ;
|
||||
if ( bSingle2)
|
||||
ptP2n = ptP2c ;
|
||||
else
|
||||
bNext = bNext && PL2.GetNextPoint( ptP2n) ;
|
||||
|
||||
// prendo i punti di ogni polyline dell'albero, li triangolo e li porto in 3d
|
||||
for ( POLYLINEVECTOR vPL : vvPL) {
|
||||
PNTVECTOR vPnt ;
|
||||
INTVECTOR vTria ;
|
||||
Triangulate Tri ;
|
||||
if ( ! Tri.Make( vPL, vPnt, vTria))
|
||||
return nullptr ;
|
||||
|
||||
// porto i punti in 3d
|
||||
PNTVECTOR vPnt3d ;
|
||||
for ( int i = 0 ; i < int( vPnt.size()) ; ++ i) {
|
||||
Point3d pt3d ;
|
||||
if ( ! GetPointD1D2( vPnt[i].x / SBZ_TREG_COEFF, vPnt[i].y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3d))
|
||||
return nullptr ;
|
||||
vPnt3d.push_back( pt3d) ;
|
||||
}
|
||||
while ( bNext) {
|
||||
// eventuale primo triangolo (con base sui correnti e vertice su P2 successivo)
|
||||
if ( ! AreSamePointApprox( ptP1c, ptP2c))
|
||||
stmSoup.AddTriangle( ptP2c, ptP1c, ptP2n) ;
|
||||
// eventuale secondo triangolo (con vertice su P1 corrente e base sui successivi)
|
||||
if ( ! AreSamePointApprox( ptP1n, ptP2n))
|
||||
stmSoup.AddTriangle( ptP1c, ptP1n, ptP2n) ;
|
||||
// passo alla successiva coppia
|
||||
ptP1c = ptP1n ;
|
||||
ptP2c = ptP2n ;
|
||||
bNext = ( bSingle1 || PL1.GetNextPoint( ptP1n)) && ( bSingle2 || PL2.GetNextPoint( ptP2n)) ;
|
||||
int nTria = int( vTria.size()) / 3 ;
|
||||
for ( int i = 0 ; i < nTria ; ++i) {
|
||||
if ( ! stmSoup.AddTriangle( vPnt3d[vTria[3*i]], vPnt3d[vTria[3*i+1]], vPnt3d[vTria[3*i+2]],
|
||||
vPnt[vTria[3*i]].x, vPnt[vTria[3*i]].y,
|
||||
vPnt[vTria[3*i+1]].x, vPnt[vTria[3*i+1]].y,
|
||||
vPnt[vTria[3*i+2]].x, vPnt[vTria[3*i+2]].y))
|
||||
return nullptr ;
|
||||
}
|
||||
// salvo isoparametrica PL2 in PL1
|
||||
PL1.GetUPointList().swap( PL2.GetUPointList()) ;
|
||||
bSingle1 = bSingle2 ;
|
||||
}
|
||||
// la completo
|
||||
}
|
||||
|
||||
// la salvo
|
||||
if ( ! stmSoup.End())
|
||||
return nullptr ;
|
||||
// la salvo
|
||||
m_pSTM = GetBasicSurfTriMesh( stmSoup.GetSurf()) ;
|
||||
|
||||
return m_pSTM ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfBezier::GetLeaves( vector<tuple<int, Point3d, Point3d>>& vLeaves) const
|
||||
{
|
||||
Tree Tree( this, true) ;
|
||||
BIPNTVECTOR vTrees ;
|
||||
Tree.GetIndependentTrees( vTrees) ;
|
||||
for ( int i = 0 ; i < int( vTrees.size()) ; ++ i) {
|
||||
Point3d ptMin = get<0>( vTrees[i]) ;
|
||||
Point3d ptMax = get<1>( vTrees[i]) ;
|
||||
Tree.SetSurf( this, true, ptMin, ptMax) ;
|
||||
bool bTest = false ; // per debug
|
||||
if ( bTest) {
|
||||
Tree.BuildTree_test() ; // per debug
|
||||
//Tree.BuildTree( 5 * LIN_TOL_FINE, 1) ; // per debug
|
||||
}
|
||||
else {
|
||||
Tree.BuildTree( 5 * LIN_TOL_FINE, 0.1) ;
|
||||
}
|
||||
vector<Cell> vCells ;
|
||||
Tree.GetLeaves( vCells) ;
|
||||
for ( int k = 0 ; k < int( vCells.size()) ; ++ k) {
|
||||
vLeaves.emplace_back( vCells[k].m_nId, vCells[k].GetBottomLeft(), vCells[k].GetTopRight()) ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
SurfBezier::ResetAuxSurf( void) const
|
||||
|
||||
+9
-1
@@ -58,6 +58,11 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // ISurf
|
||||
bool IsSimple( void) const override
|
||||
@@ -83,6 +88,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
{ return SetControlPoint( GetInd( nIndU, nIndV), ptCtrl, dW) ; }
|
||||
bool SetControlPoint( int nInd, const Point3d& ptCtrl, double dW) override ;
|
||||
bool SetTrimRegion( const ISurfFlatRegion& sfrTrimReg) override ;
|
||||
SurfFlatRegion* GetTrimRegion( void) const override ;
|
||||
bool GetInfo( int& nDegU, int& nDegV, int& nSpanU, int& nSpanV, bool& bIsRat, bool& bTrimmed) const override ;
|
||||
const Point3d& GetControlPoint( int nIndU, int nIndV, bool* pbOk) const override
|
||||
{ return GetControlPoint( GetInd( nIndU, nIndV), pbOk) ; }
|
||||
@@ -105,6 +111,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
bool GetControlCurveOnU( int nIndV, PolyLine& plCtrlU) const override ;
|
||||
bool GetControlCurveOnV( int nIndU, PolyLine& plCtrlV) const override ;
|
||||
const SurfTriMesh* GetAuxSurf( void) const override ;
|
||||
bool GetLeaves( std::vector<std::tuple<int, Point3d, Point3d>>& vLeaves) const override ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
@@ -166,7 +173,8 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
PNTVECTOR m_vPtCtrl ; // vettore dei punti di controllo
|
||||
DBLVECTOR m_vWeCtrl ; // vettore dei pesi di controllo
|
||||
SurfFlatRegion* m_pTrimReg ; // eventuale regione di trim
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+71
-246
@@ -22,6 +22,7 @@
|
||||
#include "CurveLine.h"
|
||||
#include "AdjustLoops.h"
|
||||
#include "GeoConst.h"
|
||||
#include "Voronoi.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkUiUnits.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
@@ -34,10 +35,8 @@ GEOOBJ_REGISTER( SRF_FLATRGN, NGE_S_FRG, SurfFlatRegion) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
SurfFlatRegion::SurfFlatRegion( void)
|
||||
: m_pSTM( nullptr), m_nStatus( TO_VERIFY)
|
||||
: m_pSTM( nullptr), m_nStatus( TO_VERIFY), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}, m_pVoronoiObj( nullptr)
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -60,10 +59,14 @@ SurfFlatRegion::Clear( void)
|
||||
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
m_dTempParam[0] = 0.0 ;
|
||||
m_dTempParam[1] = 0.0 ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
ResetAuxSurf() ;
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -193,6 +196,8 @@ SurfFlatRegion::AddSimpleExtLoop( ICurve* pCrv)
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -329,6 +334,8 @@ SurfFlatRegion::AddSimpleIntLoop( ICurve* pCrv)
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -403,6 +410,8 @@ SurfFlatRegion::CopyFrom( const SurfFlatRegion& sfrSrc)
|
||||
m_vExtInd = sfrSrc.m_vExtInd ;
|
||||
m_nTempProp[0] = sfrSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = sfrSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = sfrSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = sfrSrc.m_dTempParam[1] ;
|
||||
m_nStatus = sfrSrc.m_nStatus ;
|
||||
return ( m_nStatus == OK && ! m_vpLoop.empty()) ;
|
||||
}
|
||||
@@ -613,6 +622,8 @@ SurfFlatRegion::Translate( const Vector3d& vtMove)
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// traslo il riferimento
|
||||
m_frF.Translate( vtMove) ;
|
||||
return true ;
|
||||
@@ -632,6 +643,8 @@ SurfFlatRegion::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAn
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
|
||||
// ruoto il riferimento
|
||||
return m_frF.Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
|
||||
@@ -651,6 +664,8 @@ SurfFlatRegion::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, dou
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
|
||||
// se scalatura non uniforme, sostituisco eventuali archi con curve di Bezier
|
||||
if ( abs( dCoeffX - dCoeffY) > EPS_SMALL || abs( dCoeffX - dCoeffZ) > EPS_SMALL) {
|
||||
@@ -704,6 +719,8 @@ SurfFlatRegion::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
|
||||
// parziale mirror del riferimento (non può essere completa)
|
||||
Frame3d frTrasf = m_frF ;
|
||||
@@ -752,6 +769,8 @@ SurfFlatRegion::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
|
||||
// se il piano di scorrimento non coincide con XY intrinseco, converto eventuali archi in curve di Bezier
|
||||
if ( ! AreSameOrOppositeVectorExact( m_frF.VersZ(), vtNorm)) {
|
||||
@@ -824,6 +843,8 @@ SurfFlatRegion::ToGlob( const Frame3d& frRef)
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
|
||||
// trasformo il riferimento
|
||||
return m_frF.ToGlob( frRef) ; ;
|
||||
@@ -847,6 +868,8 @@ SurfFlatRegion::ToLoc( const Frame3d& frRef)
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
|
||||
// trasformo il riferimento
|
||||
return m_frF.ToLoc( frRef) ; ;
|
||||
@@ -870,6 +893,8 @@ SurfFlatRegion::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
|
||||
// trasformo il riferimento
|
||||
return m_frF.LocToLoc( frOri, frDest) ; ;
|
||||
@@ -1400,250 +1425,50 @@ SurfFlatRegion::GetChunkSimpleClassification( int nChunk, const ISurfFlatRegion&
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
bool
|
||||
SurfFlatRegion::GetZigZagInfill( double dStep, bool bStepCorrection, bool bInvert, ICRVCOMPOPOVECTOR& vpCrvs) const
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfFlatRegion::CalcVoronoiObject() const
|
||||
{
|
||||
// ingombro della regione
|
||||
BBox3d b3Pocket ;
|
||||
GetLocalBBox( b3Pocket) ;
|
||||
Point3d ptMin ; double dDimX, dDimY, dDimZ ;
|
||||
b3Pocket.GetMinDim( ptMin, dDimX, dDimY, dDimZ) ;
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// lunghezza dei contorni
|
||||
DBLVECTOR vLen( m_vpLoop.size()) ;
|
||||
for ( size_t i = 0 ; i < vLen.size() ; i++)
|
||||
m_vpLoop[i]->GetLength( vLen[i]) ;
|
||||
|
||||
// passi in Y
|
||||
double dYStep = dStep ;
|
||||
int nYStep = static_cast<int>( floor( dDimY / dStep)) ;
|
||||
int nRef = 0 ;
|
||||
if ( bStepCorrection) {
|
||||
// se permesso, lo modifico per coprire uniformemente la regione
|
||||
nYStep = static_cast<int>( ceil( ( dDimY - 30 * EPS_SMALL) / dStep)) ;
|
||||
dYStep = ( nYStep > 0 ? ( dDimY - 30 * EPS_SMALL) / nYStep : 0) ;
|
||||
nRef = ( ( nYStep + ( bInvert ? 0 : 1)) % 2) ;
|
||||
}
|
||||
|
||||
// tratto valido
|
||||
struct Section {
|
||||
bool bActive ;
|
||||
Point3d ptS ;
|
||||
Point3d ptE ;
|
||||
double dOs ;
|
||||
double dOe ;
|
||||
size_t nIdxS ; // indice del loop a cui appartiene ptS
|
||||
size_t nIdxE ; // indice del loop a cui appartiene ptE
|
||||
} ;
|
||||
// raccolta di tratti
|
||||
typedef vector<vector<Section>> VECVECSECT ;
|
||||
|
||||
VECVECSECT vvSec ;
|
||||
vvSec.resize( nYStep + 1) ;
|
||||
|
||||
// calcolo le linee di svuotatura
|
||||
int nCount = 0 ;
|
||||
for ( int i = 0 ; i <= nYStep ; ++ i) {
|
||||
// determino senso
|
||||
bool bPlus = (( i % 2) == nRef) ;
|
||||
// definisco correzione per essere sicura di poter fare primo e ultimo step
|
||||
double dCorr = 0 ;
|
||||
if ( i == 0)
|
||||
dCorr = 10 * EPS_SMALL ;
|
||||
else if ( i == nYStep)
|
||||
dCorr = - 10 * EPS_SMALL ;
|
||||
// definisco la linea
|
||||
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
||||
const double EXP_LEN = 1.0 ;
|
||||
Point3d ptStart( ptMin.x - EXP_LEN, ptMin.y + dCorr + i * dYStep, ptMin.z + dDimZ) ;
|
||||
if ( IsNull( pLine) || ! pLine->SetPVL( ptStart, X_AX , dDimX + 2 * EXP_LEN)) {
|
||||
return false ;
|
||||
}
|
||||
|
||||
// calcolo la classificazione della curva rispetto alla regione
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( ! GetCurveClassification( *pLine, EPS_SMALL, ccClass))
|
||||
return false ;
|
||||
|
||||
// determino gli intervalli di curva da conservare
|
||||
Intervals inOk ;
|
||||
for ( auto& ccOne : ccClass) {
|
||||
if ( ccOne.nClass == CRVC_IN || ccOne.nClass == CRVC_ON_P || ccOne.nClass == CRVC_ON_M)
|
||||
inOk.Add( ccOne.dParS, ccOne.dParE) ;
|
||||
}
|
||||
// inserisco i tratti validi (secondo X+ i pari, secondo X- i dispari)
|
||||
double dParS, dParE ;
|
||||
bool bFound = ( bPlus ? inOk.GetFirst( dParS, dParE) : inOk.GetLast( dParE, dParS)) ;
|
||||
while ( bFound) {
|
||||
// determino i dati della sezione
|
||||
Section Sect ;
|
||||
Sect.bActive = true ;
|
||||
pLine->GetPointD1D2( dParS, ICurve::FROM_PLUS, Sect.ptS) ;
|
||||
pLine->GetPointD1D2( dParE, ICurve::FROM_MINUS, Sect.ptE) ;
|
||||
|
||||
// porto i punti nel riferimento della curva
|
||||
if ( ! AreSameFrame( m_frF, GLOB_FRM)) {
|
||||
Sect.ptS.ToLoc( m_frF) ;
|
||||
Sect.ptE.ToLoc( m_frF) ;
|
||||
}
|
||||
|
||||
// cerco la curva della regione che passa per ptS
|
||||
bool bCrvFound = false ;
|
||||
for ( size_t k = 0 ; ! bCrvFound && k < m_vpLoop.size() ; k++) {
|
||||
bCrvFound = m_vpLoop[k]->GetParamAtPoint( Sect.ptS, Sect.dOs, 10 * EPS_SMALL) ;
|
||||
if ( bCrvFound)
|
||||
Sect.nIdxS = k ;
|
||||
}
|
||||
if ( ! bCrvFound)
|
||||
return false ;
|
||||
|
||||
// cerco la curva della regione che passa per ptE
|
||||
bCrvFound = false ;
|
||||
for ( size_t k = 0 ; ! bCrvFound && k < m_vpLoop.size() ; k++) {
|
||||
bCrvFound = m_vpLoop[k]->GetParamAtPoint( Sect.ptE, Sect.dOe, 10 * EPS_SMALL) ;
|
||||
if ( bCrvFound)
|
||||
Sect.nIdxE = k ;
|
||||
}
|
||||
if ( ! bCrvFound)
|
||||
return false ;
|
||||
|
||||
// inserisco nel contenitore
|
||||
vvSec[i].emplace_back( Sect) ;
|
||||
++ nCount ;
|
||||
// recupero intervallo successivo
|
||||
bFound = ( bPlus ? inOk.GetNext( dParS, dParE) : inOk.GetPrev( dParE, dParS)) ;
|
||||
}
|
||||
}
|
||||
|
||||
// dominio del contorno
|
||||
DBLVECTOR vUmax( m_vpLoop.size()) ;
|
||||
DBLVECTOR vUmin( m_vpLoop.size()) ;
|
||||
DBLVECTOR vUspan( m_vpLoop.size()) ;
|
||||
for ( size_t i = 0 ; i < m_vpLoop.size() ; i++) {
|
||||
m_vpLoop[i]->GetDomain( vUmin[i], vUmax[i]) ;
|
||||
vUspan[i] = vUmax[i] - vUmin[i] ;
|
||||
}
|
||||
|
||||
// creo i percorsi di svuotatura
|
||||
vpCrvs.reserve( nCount) ;
|
||||
int nI = -1, nJ = -1 ;
|
||||
while ( true) {
|
||||
// se sezione non valida
|
||||
if ( nI < 0 || nJ < 0) {
|
||||
// ricerco la prima valida
|
||||
for ( int k = 0 ; k < int( vvSec.size()) && nI < 0 ; ++ k) {
|
||||
for ( int l = 0 ; l < int( vvSec[k].size()) && nJ < 0 ; ++ l) {
|
||||
if ( vvSec[k][l].bActive) {
|
||||
nI = k ;
|
||||
nJ = l ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// se trovata, creo nuova curva composita
|
||||
if ( nI >= 0 && nJ >= 0) {
|
||||
// creo la curva
|
||||
vpCrvs.emplace_back( CreateCurveComposite()) ;
|
||||
// aggiungo punto iniziale
|
||||
vpCrvs.back()->AddPoint( vvSec[nI][nJ].ptS) ;
|
||||
}
|
||||
// altrimenti, esco
|
||||
else
|
||||
break ;
|
||||
}
|
||||
// determino senso
|
||||
bool bPlus = (( nI % 2) == nRef) ;
|
||||
// aggiungo la sezione alla curva
|
||||
Section& Sec = vvSec[nI][nJ] ;
|
||||
Sec.bActive = false ;
|
||||
vpCrvs.back()->AddLine( vvSec[nI][nJ].ptE) ;
|
||||
// cerco nella stessa fila o in quella successiva sezione successiva raccordabile tramite il contorno
|
||||
double dUstart = Sec.dOe ;
|
||||
double dUref = ( bPlus ? INFINITO : - INFINITO) ;
|
||||
int nNextI = -1 ;
|
||||
int nNextJ = -1 ;
|
||||
int li = nJ + 1 ;
|
||||
for ( int k = nI ; k <= nI + 1 && k < int( vvSec.size()) ; ++ k) {
|
||||
for ( int l = li ; l < int( vvSec[k].size()) ; ++ l) {
|
||||
if ( ! vvSec[k][l].bActive)
|
||||
continue ;
|
||||
// la nuova sezione deve partire dalla stessa curva su cui ci si è fermati
|
||||
if ( vvSec[k][l].nIdxS != Sec.nIdxE)
|
||||
continue ;
|
||||
double dU = vvSec[k][l].dOs ;
|
||||
if ( bPlus) {
|
||||
if ( dU < dUstart)
|
||||
dU += vUspan[Sec.nIdxE] ;
|
||||
if ( dU < dUref) {
|
||||
dUref = dU ;
|
||||
nNextI = k ;
|
||||
nNextJ = l ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( dU > dUstart)
|
||||
dU -= vUspan[Sec.nIdxE] ;
|
||||
if ( dU > dUref) {
|
||||
dUref = dU ;
|
||||
nNextI = k ;
|
||||
nNextJ = l ;
|
||||
}
|
||||
}
|
||||
}
|
||||
li = 0 ;
|
||||
}
|
||||
// se trovato, aggiungo il tratto di contorno e continuo
|
||||
if ( nNextI != -1) {
|
||||
PtrOwner<ICurve> pCopy ;
|
||||
size_t idx = vvSec[nNextI][nNextJ].nIdxS ;
|
||||
if ( bPlus) {
|
||||
if ( dUref > vUmax[idx])
|
||||
dUref -= vUspan[idx] ;
|
||||
pCopy.Set( m_vpLoop[idx]->CopyParamRange( dUstart, dUref)) ;
|
||||
if ( ! IsNull( pCopy)) {
|
||||
double dCLen ; pCopy->GetLength( dCLen) ;
|
||||
if ( dCLen > 0.5 * vLen[idx]) {
|
||||
pCopy.Set( m_vpLoop[idx]->CopyParamRange( dUref, dUstart)) ;
|
||||
if ( ! IsNull( pCopy))
|
||||
pCopy->Invert() ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( dUref < vUmin[idx])
|
||||
dUref += vUspan[idx] ;
|
||||
pCopy.Set( m_vpLoop[idx]->CopyParamRange( dUref, dUstart)) ;
|
||||
if ( ! IsNull( pCopy)) {
|
||||
pCopy->Invert() ;
|
||||
double dCLen ; pCopy->GetLength( dCLen) ;
|
||||
if ( dCLen > 0.5 * vLen[idx])
|
||||
pCopy.Set( m_vpLoop[idx]->CopyParamRange( dUstart, dUref)) ;
|
||||
}
|
||||
}
|
||||
BBox3d b3Copy ;
|
||||
if ( ! IsNull( pCopy))
|
||||
pCopy->GetBBox( m_frF, b3Copy) ;
|
||||
if ( ! b3Copy.IsEmpty() && ( b3Copy.GetMax().y - b3Copy.GetMin().y) < dYStep + 10 * EPS_SMALL) {
|
||||
vpCrvs.back()->AddCurve( Release( pCopy)) ;
|
||||
nI = nNextI ;
|
||||
nJ = nNextJ ;
|
||||
}
|
||||
else {
|
||||
nI = -1 ;
|
||||
nJ = -1 ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
nI = -1 ;
|
||||
nJ = -1 ;
|
||||
}
|
||||
}
|
||||
|
||||
// porto le curve calcolate nel riferimento globale
|
||||
if ( ! AreSameFrame( m_frF, GLOB_FRM)) {
|
||||
for ( int i = 0 ; i < ( int) vpCrvs.size() ; i++)
|
||||
vpCrvs[i]->ToGlob( m_frF) ;
|
||||
}
|
||||
// creo oggetto vroni con la superficie
|
||||
m_pVoronoiObj = new( std::nothrow) Voronoi( this, false) ;
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
SurfFlatRegion::ResetVoronoiObject() const
|
||||
{
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
delete m_pVoronoiObj ;
|
||||
m_pVoronoiObj = nullptr ;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool
|
||||
SurfFlatRegion::CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound) const
|
||||
{
|
||||
// verifico se è stato calcolato
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
if ( ! CalcVoronoiObject())
|
||||
return false ;
|
||||
|
||||
return m_pVoronoiObj->CalcVoronoiDiagram( vCrvs, nBound) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfFlatRegion::CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) const
|
||||
{
|
||||
// verifico se è stato calcolato
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
if ( ! CalcVoronoiObject())
|
||||
return false ;
|
||||
|
||||
return m_pVoronoiObj->CalcMedialAxis( vCrvs, nSide) ;
|
||||
}
|
||||
|
||||
+18
-4
@@ -22,6 +22,8 @@
|
||||
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
||||
#include <deque>
|
||||
|
||||
class Voronoi ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
|
||||
{
|
||||
@@ -57,6 +59,11 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // ISurf
|
||||
bool IsSimple( void) const override
|
||||
@@ -81,6 +88,7 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
|
||||
bool Subtract( const ISurfFlatRegion& Other) override ;
|
||||
bool Intersect( const ISurfFlatRegion& Other) override ;
|
||||
bool Offset( double dDist, int nType) override ;
|
||||
SurfFlatRegion* CreateOffsetSurf( double dDist, int nType) const override ;
|
||||
bool GetGrossArea( double& dArea) const override ;
|
||||
const Point3d& GetPlanePoint( void) const override
|
||||
{ return m_frF.Orig() ; }
|
||||
@@ -95,7 +103,8 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
|
||||
bool GetChunkCentroid( int nChunk, Point3d& ptCen) const override ;
|
||||
bool GetCurveClassification( const ICurve& Crv, double dLenMin, CRVCVECTOR& ccClass) const override ;
|
||||
int GetChunkSimpleClassification( int nChunk, const ISurfFlatRegion& Other, int nOthChunk) const override ; // compare only outsides
|
||||
bool GetZigZagInfill( double dStep, bool bStepCorrection, bool bInvert, ICRVCOMPOPOVECTOR& vpCrvs) const override ;
|
||||
bool CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound = 3) const override ;
|
||||
bool CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) const override ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
@@ -104,7 +113,7 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
|
||||
|
||||
public :
|
||||
SurfFlatRegion( void) ;
|
||||
SurfFlatRegion( const SurfFlatRegion& stSrc) : m_pSTM( nullptr)
|
||||
SurfFlatRegion( const SurfFlatRegion& stSrc) : m_pSTM( nullptr), m_pVoronoiObj( nullptr)
|
||||
{ if ( ! CopyFrom( stSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "SurfFlatRegion : copy constructor error") }
|
||||
SurfFlatRegion& operator =( const SurfFlatRegion& stSrc)
|
||||
@@ -138,7 +147,9 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
|
||||
int nType1, bool bInvert1, int nType2, bool bInvert2, PCRV_DEQUE& vpCurve) ;
|
||||
static bool MyChainCurves( PCRV_DEQUE& vpCurve, PCRV_DEQUE& vpLoop) ;
|
||||
static SurfFlatRegion* MyNewSurfFromLoops( PCRV_DEQUE& vpLoop) ;
|
||||
static bool MyTestAndDelete( PCRV_DEQUE& vpCrv) ;
|
||||
static bool MyTestAndDelete( PCRV_DEQUE& vpCrv) ;
|
||||
bool CalcVoronoiObject( void) const ;
|
||||
void ResetVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
@@ -147,7 +158,10 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
|
||||
Frame3d m_frF ; // riferimento intrinseco
|
||||
PCRV_DEQUE m_vpLoop ; // deque delle curve che formano i loop
|
||||
INTVECTOR m_vExtInd ; // indice dei loop esterni nel precedente vettore
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
mutable Voronoi* m_pVoronoiObj ; // Voronoi
|
||||
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -103,6 +103,8 @@ SurfFlatRegion::Add( const ISurfFlatRegion& Other)
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -191,6 +193,8 @@ SurfFlatRegion::Subtract( const ISurfFlatRegion& Other)
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -279,6 +283,8 @@ SurfFlatRegion::Intersect( const ISurfFlatRegion& Other)
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -363,6 +369,9 @@ SurfFlatRegion::MyChainCurves( PCRV_DEQUE& vpCurve, PCRV_DEQUE& vpLoop)
|
||||
if ( ! bOk)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// pulisco
|
||||
pCrvCompo->RemoveSmallParts( 2 * EPS_SMALL, EPS_ANG_SMALL) ;
|
||||
// aggiorno il nuovo punto vicino
|
||||
if ( pCrvCompo->GetCurveCount() > 0)
|
||||
pCrvCompo->GetEndPoint( ptNearStart) ;
|
||||
|
||||
+185
-91
@@ -16,11 +16,188 @@
|
||||
#include "GeoConst.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "SurfFlatRegion.h"
|
||||
#include "Voronoi.h"
|
||||
#include "/EgtDev/Include/EGkOffsetCurve.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
SurfFlatRegion*
|
||||
SurfFlatRegion::CreateOffsetSurf( double dDist, int nType) const
|
||||
{
|
||||
// restituisce la superficie offsettata senza modificare la superficie corrente. In caso di errore restituisce nullptr
|
||||
|
||||
// metodo di calcolo impostato da USE_VORONOI
|
||||
|
||||
// recupero il numero dei chunk
|
||||
int nChunk = GetChunkCount() ;
|
||||
if ( nChunk == 0)
|
||||
return nullptr ;
|
||||
|
||||
// se offset nullo, la nuova regione è la copia di quella attuale
|
||||
if ( abs( dDist) < 10 * EPS_SMALL)
|
||||
return this->Clone() ;
|
||||
|
||||
// creo una nuova regione
|
||||
PtrOwner<SurfFlatRegion> pSfr( CreateBasicSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfr))
|
||||
return nullptr ;
|
||||
|
||||
// -------------------- OFFSET STANDARD -------------------------------------
|
||||
if ( ! USE_VORONOI) {
|
||||
bool bFirstRegion = true ;
|
||||
// ciclo sui chunk
|
||||
for ( int i = 0 ; i < nChunk ; ++ i) {
|
||||
// creo la regione del chunk
|
||||
PtrOwner<SurfFlatRegion> pSfrChk( new( nothrow) SurfFlatRegion) ;
|
||||
if ( IsNull( pSfrChk))
|
||||
return nullptr ;
|
||||
bool bFirstCurve = true ;
|
||||
// ciclo sui loop di ogni chunk
|
||||
int nLoop = GetLoopCount( i) ;
|
||||
for ( int j = 0 ; j < nLoop ; ++ j) {
|
||||
// recupero il loop
|
||||
ICurve* pLoop = GetMyLoop( i, j) ;
|
||||
if ( pLoop == nullptr)
|
||||
return nullptr ;
|
||||
// ne eseguo l'offset
|
||||
OffsetCurve OffsCrv ;
|
||||
bool bOk = OffsCrv.Make( pLoop, dDist, nType) ;
|
||||
// recupero le curve di offset
|
||||
PtrOwner<ICurve> pOffs( OffsCrv.GetLongerCurve()) ;
|
||||
while ( bOk && ! IsNull( pOffs)) {
|
||||
if ( pOffs->GetType() == CRV_COMPO) {
|
||||
CurveComposite* pOffsCompo = GetBasicCurveComposite( pOffs) ;
|
||||
// assegno proprietà
|
||||
pOffsCompo->SetTempProp( j, 1) ;
|
||||
for ( int k = 0 ; k < pOffsCompo->GetCurveCount() ; ++k)
|
||||
pOffsCompo->SetCurveTempProp( k, j, 1) ;
|
||||
// unisco parti allineate
|
||||
if ( ! pOffsCompo->MergeCurves( 10 * EPS_SMALL, ANG_TOL_STD_DEG, true))
|
||||
return nullptr ;
|
||||
}
|
||||
else
|
||||
pOffs->SetTempProp( j, 1) ;
|
||||
// se prima curva esterna, è il primo contorno esterno della nuova regione
|
||||
if ( j == 0 && bFirstCurve) {
|
||||
if ( ! pSfrChk->AddExtLoop( Release( pOffs)))
|
||||
return nullptr ;
|
||||
bFirstCurve = false ;
|
||||
}
|
||||
// altrimenti aggiungo o sottraggo la regione della curva alla nuova regione
|
||||
else if ( ! bFirstCurve) {
|
||||
// verifico se loop interno o esterno
|
||||
double dArea ;
|
||||
if ( ! pOffs->GetAreaXY( dArea))
|
||||
return nullptr ;
|
||||
bool bExtLoop = ( dArea > 0) ;
|
||||
// se loop interno, inverto la curva
|
||||
if ( ! bExtLoop)
|
||||
pOffs->Invert() ;
|
||||
// creo la regione
|
||||
PtrOwner<SurfFlatRegion> pSfr2( new( nothrow) SurfFlatRegion) ;
|
||||
if ( IsNull( pSfr2) || ! pSfr2->AddExtLoop( Release( pOffs)))
|
||||
return nullptr ;
|
||||
// se era loop esterno, lo aggiungo alla nuova regione
|
||||
if ( bExtLoop) {
|
||||
if ( ! pSfrChk->Add( *pSfr2))
|
||||
return nullptr ;
|
||||
}
|
||||
// altrimenti loop interno, lo sottraggo alla nuova regione
|
||||
else {
|
||||
if ( ! pSfrChk->Subtract( *pSfr2))
|
||||
return nullptr ;
|
||||
}
|
||||
}
|
||||
// passo alla successiva
|
||||
pOffs.Set( OffsCrv.GetLongerCurve()) ;
|
||||
}
|
||||
}
|
||||
// se regione di chunk valida
|
||||
if ( ! bFirstCurve) {
|
||||
// se prima regione di chunk, ne sposto i dati nella nuova regione
|
||||
if ( bFirstRegion) {
|
||||
pSfr->m_vExtInd = pSfrChk->m_vExtInd ;
|
||||
pSfr->m_vpLoop = pSfrChk->m_vpLoop ;
|
||||
for ( auto& pLoop : pSfrChk->m_vpLoop)
|
||||
pLoop = nullptr ;
|
||||
pSfr->m_nStatus = pSfrChk->m_nStatus ;
|
||||
bFirstRegion = false ;
|
||||
}
|
||||
// altrimenti la aggiungo alla nuova regione
|
||||
else {
|
||||
if ( ! pSfr->Add( *pSfrChk))
|
||||
return nullptr ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------- OFFSET CON VORONOI -------------------------------------
|
||||
else {
|
||||
// verifico se oggetto Voronoi della superficie è definito
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
CalcVoronoiObject() ;
|
||||
|
||||
// calcolo offset
|
||||
ICURVEPOVECTOR vOffs ;
|
||||
if ( ! m_pVoronoiObj->CalcOffset( vOffs, dDist, nType))
|
||||
return nullptr ;
|
||||
|
||||
if ( vOffs.size() > 0) {
|
||||
BOOLVECTOR vbAddOrSub( vOffs.size(), true) ;
|
||||
int nFirstId = -1 ;
|
||||
for ( int i = 0 ; i < ( int)vOffs.size() ; i ++) {
|
||||
// porto nel frame della flat region
|
||||
vOffs[i]->ToLoc( m_frF) ;
|
||||
// calcolo orientamento della curva
|
||||
double dAreaXY ;
|
||||
if ( ! vOffs[i]->GetAreaXY( dAreaXY))
|
||||
return nullptr ;
|
||||
vbAddOrSub[i] = ( dAreaXY > SQ_EPS_SMALL) ;
|
||||
// verifico se è il primo loop esterno
|
||||
if ( nFirstId == -1 && vbAddOrSub[i])
|
||||
nFirstId = i ;
|
||||
}
|
||||
|
||||
// inizializzo la superficie
|
||||
if ( nFirstId != -1 && ! pSfr->AddExtLoop( Release( vOffs[nFirstId])))
|
||||
return nullptr ;
|
||||
if ( pSfr->IsValid()) {
|
||||
|
||||
for ( int i = 0 ; i < ( int)vOffs.size() ; i ++) {
|
||||
// verifico non sia il primo loop esterno
|
||||
if ( i == nFirstId)
|
||||
continue ;
|
||||
// costruisco la superficie associata
|
||||
PtrOwner<SurfFlatRegion> pSrfCrv( CreateBasicSurfFlatRegion()) ;
|
||||
if ( IsNull( pSrfCrv) || ! pSrfCrv->AddExtLoop( Release( vOffs[i])))
|
||||
return nullptr ;
|
||||
if ( ! pSrfCrv->IsValid())
|
||||
continue ;
|
||||
|
||||
// aggiungo o sottraggo
|
||||
if ( vbAddOrSub[i]) {
|
||||
if ( ! pSfr->Add( *pSrfCrv))
|
||||
return nullptr ;
|
||||
}
|
||||
else {
|
||||
pSrfCrv->Invert() ;
|
||||
if ( ! pSfr->Subtract( *pSrfCrv))
|
||||
return nullptr ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pSfr->ToGlob( m_frF) ;
|
||||
return Release( pSfr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfFlatRegion::Offset( double dDist, int nType)
|
||||
@@ -29,99 +206,15 @@ SurfFlatRegion::Offset( double dDist, int nType)
|
||||
int nChunk = GetChunkCount() ;
|
||||
if ( nChunk == 0)
|
||||
return false ;
|
||||
// se offset nullo, non devo fare alcunché
|
||||
|
||||
// se offset nullo, non devo fare alcunchè
|
||||
if ( abs( dDist) < 10 * EPS_SMALL)
|
||||
return true ;
|
||||
// creo una nuova regione
|
||||
PtrOwner<SurfFlatRegion> pSfr( new( nothrow) SurfFlatRegion) ;
|
||||
return this->Clone() ;
|
||||
|
||||
// calcolo la superficie di offset
|
||||
PtrOwner<SurfFlatRegion> pSfr( CreateOffsetSurf( dDist, nType)) ;
|
||||
if ( IsNull( pSfr))
|
||||
return false ;
|
||||
bool bFirstRegion = true ;
|
||||
// ciclo sui chunk
|
||||
for ( int i = 0 ; i < nChunk ; ++ i) {
|
||||
// creo la regione del chunk
|
||||
PtrOwner<SurfFlatRegion> pSfrChk( new( nothrow) SurfFlatRegion) ;
|
||||
if ( IsNull( pSfrChk))
|
||||
return false ;
|
||||
bool bFirstCurve = true ;
|
||||
// ciclo sui loop di ogni chunk
|
||||
int nLoop = GetLoopCount( i) ;
|
||||
for ( int j = 0 ; j < nLoop ; ++ j) {
|
||||
// recupero il loop
|
||||
ICurve* pLoop = GetMyLoop( i, j) ;
|
||||
if ( pLoop == nullptr)
|
||||
return false ;
|
||||
// ne eseguo l'offset
|
||||
OffsetCurve OffsCrv ;
|
||||
bool bOk = OffsCrv.Make( pLoop, dDist, nType) ;
|
||||
// recupero le curve di offset
|
||||
PtrOwner<ICurve> pOffs( OffsCrv.GetLongerCurve()) ;
|
||||
while ( bOk && ! IsNull( pOffs)) {
|
||||
if ( pOffs->GetType() == CRV_COMPO) {
|
||||
CurveComposite* pOffsCompo = GetBasicCurveComposite( pOffs) ;
|
||||
// assegno proprietà
|
||||
pOffsCompo->SetTempProp( j, 1) ;
|
||||
for ( int k = 0 ; k < pOffsCompo->GetCurveCount() ; ++k)
|
||||
pOffsCompo->SetCurveTempProp( k, j, 1) ;
|
||||
// unisco parti allineate
|
||||
if ( ! pOffsCompo->MergeCurves( 10 * EPS_SMALL, ANG_TOL_STD_DEG, true))
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
pOffs->SetTempProp( j, 1) ;
|
||||
// se prima curva esterna, è il primo contorno esterno della nuova regione
|
||||
if ( j == 0 && bFirstCurve) {
|
||||
if ( ! pSfrChk->AddExtLoop( Release( pOffs)))
|
||||
return false ;
|
||||
bFirstCurve = false ;
|
||||
}
|
||||
// altrimenti aggiungo o sottraggo la regione della curva alla nuova regione
|
||||
else if ( ! bFirstCurve) {
|
||||
// verifico se loop interno o esterno
|
||||
double dArea ;
|
||||
if ( ! pOffs->GetAreaXY( dArea))
|
||||
return false ;
|
||||
bool bExtLoop = ( dArea > 0) ;
|
||||
// se loop interno, inverto la curva
|
||||
if ( ! bExtLoop)
|
||||
pOffs->Invert() ;
|
||||
// creo la regione
|
||||
PtrOwner<SurfFlatRegion> pSfr2( new( nothrow) SurfFlatRegion) ;
|
||||
if ( IsNull( pSfr2) || ! pSfr2->AddExtLoop( Release( pOffs)))
|
||||
return false ;
|
||||
// se era loop esterno, lo aggiungo alla nuova regione
|
||||
if ( bExtLoop) {
|
||||
if ( ! pSfrChk->Add( *pSfr2))
|
||||
return false ;
|
||||
}
|
||||
// altrimenti loop interno, lo sottraggo alla nuova regione
|
||||
else {
|
||||
if ( ! pSfrChk->Subtract( *pSfr2))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// passo alla successiva
|
||||
pOffs.Set( OffsCrv.GetLongerCurve()) ;
|
||||
}
|
||||
}
|
||||
// se regione di chunk valida
|
||||
if ( ! bFirstCurve) {
|
||||
// se prima regione di chunk, ne sposto i dati nella nuova regione
|
||||
if ( bFirstRegion) {
|
||||
pSfr->m_vExtInd = pSfrChk->m_vExtInd ;
|
||||
pSfr->m_vpLoop = pSfrChk->m_vpLoop ;
|
||||
for ( auto& pLoop : pSfrChk->m_vpLoop)
|
||||
pLoop = nullptr ;
|
||||
pSfr->m_nStatus = pSfrChk->m_nStatus ;
|
||||
bFirstRegion = false ;
|
||||
}
|
||||
// altrimenti la aggiungo alla nuova regione
|
||||
else {
|
||||
if ( ! pSfr->Add( *pSfrChk))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pulisco la superficie corrente
|
||||
for ( auto& pLoop : m_vpLoop)
|
||||
@@ -138,5 +231,6 @@ SurfFlatRegion::Offset( double dDist, int nType)
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
ResetVoronoiObject() ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
+113
-194
@@ -41,13 +41,11 @@ GEOOBJ_REGISTER( SRF_TRIMESH, NGE_S_TRM, SurfTriMesh) ;
|
||||
//----------------------------------------------------------------------------
|
||||
SurfTriMesh::SurfTriMesh( void)
|
||||
: m_nStatus( TO_VERIFY), m_dLinTol( STM_STD_LIN_TOL), m_dBoundaryAng( STM_STD_BOUNDARY_ANG),
|
||||
m_dSmoothAng( STM_STD_SMOOTH_ANG), m_bOriented( false), m_bClosed( false), m_bFaceted( false),
|
||||
m_nTimeStamp( 0), m_nMaxTFlag( 0), m_nParts( -1), m_pHGrd3d( nullptr)
|
||||
m_dSmoothAng( STM_STD_SMOOTH_ANG), m_bOriented( false), m_bClosed( false), m_bFaceted( false), m_bFacEdged( false),
|
||||
m_nTimeStamp( 0), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}, m_nMaxTFlag( 0), m_nParts( -1), m_pHGrd3d( nullptr)
|
||||
{
|
||||
m_dCosBndAng = cos( m_dBoundaryAng * DEGTORAD) ;
|
||||
m_dCosSmAng = cos( m_dSmoothAng * DEGTORAD) ;
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -66,7 +64,7 @@ SurfTriMesh::Init( int nNumVert, int nNumTria, int nNumFacet)
|
||||
// se superficie vuota
|
||||
if ( nNumVert == 0 && nNumTria == 0 && nNumFacet == 0)
|
||||
return true ;
|
||||
// verifico validità parametri
|
||||
// verifico validità parametri
|
||||
if ( nNumVert < 3 || nNumTria < 1)
|
||||
return false ;
|
||||
// prealloco la memoria
|
||||
@@ -96,6 +94,7 @@ SurfTriMesh::Clear( void)
|
||||
m_bOriented = false ;
|
||||
m_bClosed = false ;
|
||||
m_bFaceted = false ;
|
||||
m_bFacEdged = false ;
|
||||
m_vVert.clear() ;
|
||||
m_vTria.clear() ;
|
||||
m_vFacet.clear() ;
|
||||
@@ -107,7 +106,7 @@ SurfTriMesh::Clear( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
SurfTriMesh::AddVertex( const Point3d& ptVert, const double dU, const double dV)
|
||||
SurfTriMesh::AddVertex( const Point3d& ptVert, double dU, double dV)
|
||||
{
|
||||
// imposto ricalcolo
|
||||
m_nStatus = TO_VERIFY ;
|
||||
@@ -117,9 +116,9 @@ SurfTriMesh::AddVertex( const Point3d& ptVert, const double dU, const double dV)
|
||||
// inserisco il vertice
|
||||
try { m_vVert.emplace_back( ptVert) ;}
|
||||
catch(...) { return SVT_NULL ;}
|
||||
// ne determino l'indice
|
||||
// ne determino l'indice
|
||||
int nId = int( m_vVert.size() - 1) ;
|
||||
// aggiugo le coordinate corrispondenti allo spazio parametrico
|
||||
// aggiugo le coordinate corrispondenti allo spazio parametrico
|
||||
m_vVert[nId].dU = dU ;
|
||||
m_vVert[nId].dV = dV ;
|
||||
return nId ;
|
||||
@@ -129,17 +128,22 @@ SurfTriMesh::AddVertex( const Point3d& ptVert, const double dU, const double dV)
|
||||
bool
|
||||
SurfTriMesh::MoveVertex( int nInd, const Point3d& ptNewVert)
|
||||
{
|
||||
// verifico validità indice
|
||||
// verifico validità indice
|
||||
if ( nInd < 0 || nInd >= int( m_vVert.size()))
|
||||
return false ;
|
||||
// verifico non sia già cancellato
|
||||
// verifico non sia già cancellato
|
||||
if ( m_vVert[nInd].nIdTria == SVT_DEL)
|
||||
return false ;
|
||||
// se non c'è spostamento, posso uscire
|
||||
if ( AreSamePointExact( m_vVert[nInd].ptP, ptNewVert))
|
||||
return true ;
|
||||
// sposto il vertice
|
||||
m_vVert[nInd].ptP = ptNewVert ;
|
||||
// imposto ricalcolo
|
||||
m_nStatus = TO_VERIFY ;
|
||||
m_nParts = - 1 ;
|
||||
m_bFaceted = false ;
|
||||
m_bFacEdged = false ;
|
||||
m_OGrMgr.Reset() ;
|
||||
ResetHashGrids3d() ;
|
||||
// per aggiornare completamente la superficie chiamare DoCompacting
|
||||
@@ -257,14 +261,14 @@ SurfTriMesh::RemoveTriangle( int nId)
|
||||
// verifico esistenza del triangolo
|
||||
if ( nId < 0 || nId >= GetTriangleSize())
|
||||
return false ;
|
||||
// verifico se già cancellato
|
||||
// verifico se già cancellato
|
||||
if ( m_vTria[nId].nIdVert[0] == SVT_DEL)
|
||||
return true ;
|
||||
// aggiorno eventuali riferimenti dei vertici
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
// indice vertice
|
||||
int nV = m_vTria[nId].nIdVert[i] ;
|
||||
// se vertice non c'è passo al prossimo
|
||||
// se vertice non c'è passo al prossimo
|
||||
if ( nV < 0 || nV >= int( m_vVert.size()))
|
||||
continue ;
|
||||
if ( m_vVert[nV].nIdTria == nId) {
|
||||
@@ -282,7 +286,7 @@ SurfTriMesh::RemoveTriangle( int nId)
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
// indice triangolo adiacente
|
||||
int nAdjT = m_vTria[nId].nIdAdjac[i] ;
|
||||
// se triangolo adiacente non c'è passo al prossimo
|
||||
// se triangolo adiacente non c'è passo al prossimo
|
||||
if ( nAdjT == SVT_NULL || m_vTria[nAdjT].nIdVert[0] == SVT_DEL)
|
||||
continue ;
|
||||
// ne sistemo la contro-adiacenza
|
||||
@@ -293,9 +297,10 @@ SurfTriMesh::RemoveTriangle( int nId)
|
||||
}
|
||||
// dichiaro cancellato il triangolo
|
||||
m_vTria[nId].nIdVert[0] = SVT_DEL ;
|
||||
// invalido calcolo facce
|
||||
// invalido calcolo facce e loro bordi
|
||||
m_bFaceted = false ;
|
||||
// invalido calcolo connettività
|
||||
m_bFacEdged = false ;
|
||||
// invalido calcolo connettività
|
||||
m_nParts = - 1 ;
|
||||
return true ;
|
||||
}
|
||||
@@ -361,7 +366,7 @@ SurfTriMesh::GetCentroid( Point3d& ptCen) const
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// se la superficie è chiusa, calcolo il centroide del solido
|
||||
// se la superficie è chiusa, calcolo il centroide del solido
|
||||
if ( IsClosed()) {
|
||||
// applico le formule di R. Nurnberg Imperial College London ad ogni faccia
|
||||
Triangle3d Tria ;
|
||||
@@ -500,13 +505,6 @@ SurfTriMesh::GetFirstVertex( Point3d& ptP) const
|
||||
return GetNextVertex( SVT_NULL, ptP) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
SurfTriMesh::GetFirstVertexParam( int nId, double& dU, double& dV) const
|
||||
{
|
||||
return GetNextVertexParam( SVT_NULL, dU, dV) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
SurfTriMesh::GetNextVertex( int nId, Point3d& ptP) const
|
||||
@@ -515,8 +513,8 @@ SurfTriMesh::GetNextVertex( int nId, Point3d& ptP) const
|
||||
do {
|
||||
nId ++ ;
|
||||
} while ( nId < GetVertexSize() && m_vVert[nId].nIdTria == SVT_DEL) ;
|
||||
// se oltrepassata fine
|
||||
if ( nId >= GetVertexSize())
|
||||
// se indice non valido
|
||||
if ( nId < 0 || nId >= GetVertexSize())
|
||||
return SVT_NULL ;
|
||||
// recupero i dati
|
||||
ptP = m_vVert[nId].ptP ;
|
||||
@@ -524,24 +522,6 @@ SurfTriMesh::GetNextVertex( int nId, Point3d& ptP) const
|
||||
return nId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
SurfTriMesh::GetNextVertexParam( int nId, double& dU, double& dV) const
|
||||
{
|
||||
// cerco il primo successivo valido
|
||||
do {
|
||||
nId ++ ;
|
||||
} while ( nId < GetVertexSize() && m_vVert[nId].nIdTria == SVT_DEL) ;
|
||||
// se oltrepassata fine
|
||||
if ( nId >= GetVertexSize())
|
||||
return SVT_NULL ;
|
||||
// recupero i dati
|
||||
dU = m_vVert[nId].dU ;
|
||||
dV = m_vVert[nId].dV ;
|
||||
// ritorno indice triangolo corrente
|
||||
return nId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::GetTriangle( int nId, int nIdVert[3]) const
|
||||
@@ -571,8 +551,8 @@ SurfTriMesh::GetNextTriangle( int nId, int nIdVert[3]) const
|
||||
do {
|
||||
nId ++ ;
|
||||
} while ( nId < GetTriangleSize() && m_vTria[nId].nIdVert[0] == SVT_DEL) ;
|
||||
// se oltrepassata fine
|
||||
if ( nId >= GetTriangleSize())
|
||||
// se indice non valido
|
||||
if ( nId < 0 || nId >= GetTriangleSize())
|
||||
return SVT_NULL ;
|
||||
// recupero i dati
|
||||
nIdVert[0] = m_vTria[nId].nIdVert[0] ;
|
||||
@@ -613,8 +593,8 @@ SurfTriMesh::GetNextTriangle( int nId, Triangle3d& Tria) const
|
||||
do {
|
||||
nId ++ ;
|
||||
} while ( nId < GetTriangleSize() && m_vTria[nId].nIdVert[0] == SVT_DEL) ;
|
||||
// se oltrepassata fine
|
||||
if ( nId >= GetTriangleSize())
|
||||
// se indice non valido
|
||||
if ( nId < 0 || nId >= GetTriangleSize())
|
||||
return SVT_NULL ;
|
||||
// recupero i dati
|
||||
Tria.Set( m_vVert[m_vTria[nId].nIdVert[0]].ptP,
|
||||
@@ -659,8 +639,8 @@ SurfTriMesh::GetNextTriangle( int nId, Triangle3dEx& Tria) const
|
||||
do {
|
||||
nId ++ ;
|
||||
} while ( nId < GetTriangleSize() && m_vTria[nId].nIdVert[0] == SVT_DEL) ;
|
||||
// se oltrepassata fine
|
||||
if ( nId >= GetTriangleSize())
|
||||
// se indice non valido
|
||||
if ( nId < 0 || nId >= GetTriangleSize())
|
||||
return SVT_NULL ;
|
||||
// recupero i dati
|
||||
Tria.Set( m_vVert[m_vTria[nId].nIdVert[0]].ptP,
|
||||
@@ -774,13 +754,13 @@ SurfTriMesh::GetTriangleBoundaryEdges( int nId, TriFlags3d& TFlags) const
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
// indice triangolo adiacente al lato
|
||||
int nT = m_vTria[nId].nIdAdjac[i] ;
|
||||
// se già definite le facce, verifico indice faccia
|
||||
// se già definite le facce, verifico indice faccia
|
||||
if ( m_bFaceted) {
|
||||
TFlags.bFlag[i] = ( nT == SVT_NULL || m_vTria[nId].nIdFacet != m_vTria[nT].nIdFacet) ;
|
||||
}
|
||||
// altrimenti verifico con le normali
|
||||
else
|
||||
// se non c'è triangolo adiacente o se forma un angolo oltre il limite, il lato è un contorno
|
||||
// se non c'è triangolo adiacente o se forma un angolo oltre il limite, il lato è un contorno
|
||||
TFlags.bFlag[i] = ( nT == SVT_NULL || m_vTria[nId].vtN * m_vTria[nT].vtN < m_dCosBndAng) ;
|
||||
}
|
||||
|
||||
@@ -864,7 +844,7 @@ SurfTriMesh::GetTriangleSmoothNormal( int nT, int nV, Vector3d& vtN) const
|
||||
if ( nPos == -1)
|
||||
return false ;
|
||||
|
||||
// medio le normali, finché non incontro degli spigoli
|
||||
// medio le normali, finch� non incontro degli spigoli
|
||||
vtN = m_vTria[nT].vtN ;
|
||||
// parto dal triangolo e vado in direzione positiva
|
||||
int nLim = nPos ;
|
||||
@@ -895,7 +875,7 @@ SurfTriMesh::GetTriangleSmoothNormal( int nT, int nV, Vector3d& vtN) const
|
||||
SurfTriMesh*
|
||||
SurfTriMesh::CloneTriangle( int nT) const
|
||||
{
|
||||
// verifico validità superficie ed esistenza del triangolo
|
||||
// verifico validit� superficie ed esistenza del triangolo
|
||||
if ( ! IsValid() || nT < 0 || nT >= GetTriangleSize() || m_vTria[nT].nIdVert[0] == SVT_DEL)
|
||||
return nullptr ;
|
||||
|
||||
@@ -1002,7 +982,7 @@ SurfTriMesh::GetLoops( POLYLINEVECTOR& vPL) const
|
||||
if ( ! MarchAlongLoop( nT, 1, m_nTimeStamp, vPL.back()))
|
||||
return false ;
|
||||
}
|
||||
// se il lato 0 è di contorno
|
||||
// se il lato 0 � di contorno
|
||||
else if ( nAdjT[0] == SVT_NULL) {
|
||||
// ho trovato l'inizio di un loop
|
||||
vPL.emplace_back() ;
|
||||
@@ -1014,7 +994,7 @@ SurfTriMesh::GetLoops( POLYLINEVECTOR& vPL) const
|
||||
if ( ! MarchAlongLoop( nT, 1, m_nTimeStamp, vPL.back()))
|
||||
return false ;
|
||||
}
|
||||
// se il lato 1 è di contorno
|
||||
// se il lato 1 � di contorno
|
||||
else if ( nAdjT[1] == SVT_NULL) {
|
||||
// ho trovato l'inizio di un loop
|
||||
vPL.emplace_back() ;
|
||||
@@ -1026,7 +1006,7 @@ SurfTriMesh::GetLoops( POLYLINEVECTOR& vPL) const
|
||||
if ( ! MarchAlongLoop( nT, 2, m_nTimeStamp, vPL.back()))
|
||||
return false ;
|
||||
}
|
||||
// se il lato 2 è di contorno
|
||||
// se il lato 2 � di contorno
|
||||
else if ( nAdjT[2] == SVT_NULL) {
|
||||
// ho trovato l'inizio di un loop
|
||||
vPL.emplace_back() ;
|
||||
@@ -1038,7 +1018,7 @@ SurfTriMesh::GetLoops( POLYLINEVECTOR& vPL) const
|
||||
if ( ! MarchAlongLoop( nT, 0, m_nTimeStamp, vPL.back()))
|
||||
return false ;
|
||||
}
|
||||
// altrimenti non c'è contorno
|
||||
// altrimenti non c'� contorno
|
||||
else {
|
||||
// marco il triangolo come verificato
|
||||
m_vTria[nT].nTemp = m_nTimeStamp ;
|
||||
@@ -1083,10 +1063,10 @@ SurfTriMesh::MarchOneTria( int& nT, int& nV, int nTimeStamp,
|
||||
return false ;
|
||||
// vertice di fine adiacenza e indice del successivo lato
|
||||
int nAdjV = Next( nAdjS) ;
|
||||
// verifico se il lato successivo è un bordo
|
||||
// verifico se il lato successivo � un bordo
|
||||
int nNextT = m_vTria[nAdjT].nIdAdjac[nAdjV] ;
|
||||
if ( nNextT == SVT_NULL) {
|
||||
// se già recuperato
|
||||
// se gi� recuperato
|
||||
if ( m_vTria[nAdjT].nTemp == nTimeStamp) {
|
||||
bEnd = true ;
|
||||
return true ;
|
||||
@@ -1112,7 +1092,7 @@ SurfTriMesh::MarchOneTria( int& nT, int& nV, int nTimeStamp,
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR& vPL) const
|
||||
SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR& vPL, bool bAllTria) const
|
||||
{
|
||||
// Verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
@@ -1133,93 +1113,27 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR&
|
||||
GetBBox( frBox, b3Box) ;
|
||||
frOCS.Translate( b3Box.GetMin().z * frOCS.VersZ()) ;
|
||||
|
||||
#if 0
|
||||
// *** 1° Sfruttando le adiacenze ***
|
||||
// Non funziona perchè genera loop con anelli
|
||||
// Copio la superficie
|
||||
PtrOwner<SurfTriMesh> pStm( Clone()) ;
|
||||
if ( IsNull( pStm))
|
||||
return false ;
|
||||
|
||||
// Elimino i triangoli con normale non equiversa alla direzione scelta
|
||||
for ( int i = 0 ; i < int( pStm->m_vTria.size()) ; ++ i) {
|
||||
// se già cancellato, passo oltre
|
||||
if ( pStm->m_vTria[i].nIdVert[0] == SVT_DEL)
|
||||
continue ;
|
||||
// verifico la normale
|
||||
if ( pStm->m_vTria[i].vtN * vtVers < EPS_ZERO)
|
||||
pStm->RemoveTriangle( i) ;
|
||||
}
|
||||
// dichiaro facce non calcolate
|
||||
pStm->m_bFaceted = false ;
|
||||
|
||||
// Proietto la superficie
|
||||
pStm->Scale( frOCS, 1, 1, 0) ;
|
||||
|
||||
// Recupero i loop della nuova superficie
|
||||
POLYLINEVECTOR vMyPL ;
|
||||
if ( pStm->GetLoops( vMyPL)) {
|
||||
// calcolo la regione della superficie proiettata
|
||||
bool bOk = true ;
|
||||
PtrOwner<ISurfFlatRegion> pSfr ;
|
||||
for ( int i = 0 ; i < int( vMyPL.size()) && bOk ; ++ i) {
|
||||
// Regione di un loop
|
||||
PtrOwner<ISurfFlatRegion> pSfrPart( GetSurfFlatRegionFromPolyLine( vMyPL[i])) ;
|
||||
if ( ! IsNull( pSfrPart)) {
|
||||
pSfrPart->Offset( dTol, ICurve::OFF_FILLET) ;
|
||||
if ( IsNull( pSfr))
|
||||
if ( pSfrPart->GetNormVersor() * vtVers > 0)
|
||||
bOk = pSfr.Set( pSfrPart) ;
|
||||
else
|
||||
bOk = false ;
|
||||
else {
|
||||
if ( pSfrPart->GetNormVersor() * vtVers > 0)
|
||||
bOk = pSfr->Add( *pSfrPart) ;
|
||||
else {
|
||||
pSfrPart->Invert() ;
|
||||
bOk = pSfr->Subtract( *pSfrPart) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
bOk = false ;
|
||||
}
|
||||
// Verifico esistenza della regione
|
||||
if ( bOk && ! IsNull( pSfr)) {
|
||||
// Effettuo contro-offset
|
||||
pSfr->Offset( -dTol, ICurve::OFF_EXTEND) ;
|
||||
// Recupero i contorni della regione
|
||||
for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) {
|
||||
for ( int j = 0 ; j < pSfr->GetLoopCount( i) ; ++ j) {
|
||||
PolyLine PL ;
|
||||
if ( pSfr->ApproxLoopWithLines( i, j, LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
||||
vPL.emplace_back( PL) ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
vPL.clear() ;
|
||||
#endif
|
||||
|
||||
// *** 2° Mediante unione delle regioni dei triangoli proiettati ***
|
||||
// Ottengo la Silhouette come unione delle regioni dei triangoli proiettati
|
||||
// calcolo la regione dei triangoli proiettati
|
||||
PtrOwner<ISurfFlatRegion> pSfr ;
|
||||
PtrOwner<SurfFlatRegion> pSfr ;
|
||||
Triangle3d Tria ;
|
||||
int nT = GetFirstTriangle( Tria) ;
|
||||
while ( nT != SVT_NULL) {
|
||||
// verifico la normale e il triangolo proiettato
|
||||
if ( Tria.GetN() * vtVers > EPS_ZERO &&
|
||||
if ( ( ( bAllTria && abs( Tria.GetN() * vtVers) > EPS_ZERO) ||
|
||||
( ! bAllTria && Tria.GetN() * vtVers > EPS_ZERO)) &&
|
||||
Tria.Scale( frOCS, 1, 1, 0) && Tria.GetSqMinHeight() > SQ_EPS_SMALL) {
|
||||
PtrOwner<ISurfFlatRegion> pSfrTria( GetSurfFlatRegionFromTriangle( Tria)) ;
|
||||
PtrOwner<SurfFlatRegion> pSfrTria( GetBasicSurfFlatRegion( GetSurfFlatRegionFromTriangle( Tria))) ;
|
||||
if ( ! IsNull( pSfrTria)) {
|
||||
if ( bAllTria && Tria.GetN() * vtVers < 0)
|
||||
pSfrTria->Invert() ;
|
||||
pSfrTria->Offset( dTol, ICurve::OFF_FILLET) ;
|
||||
if ( IsNull( pSfr))
|
||||
pSfr.Set( pSfrTria) ;
|
||||
else
|
||||
pSfr->Add( *pSfrTria) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// passo al successivo
|
||||
nT = GetNextTriangle( nT, Tria) ;
|
||||
}
|
||||
@@ -1286,14 +1200,18 @@ SurfTriMesh::CopyFrom( const SurfTriMesh& stmSrc)
|
||||
m_bOriented = stmSrc.m_bOriented ;
|
||||
m_bClosed = stmSrc.m_bClosed ;
|
||||
m_bFaceted = stmSrc.m_bFaceted ;
|
||||
m_bFacEdged = stmSrc.m_bFacEdged ;
|
||||
m_vVert = stmSrc.m_vVert ;
|
||||
m_vTria = stmSrc.m_vTria ;
|
||||
m_vFacet = stmSrc.m_vFacet ;
|
||||
m_vFacEdge = stmSrc.m_vFacEdge ;
|
||||
m_nTimeStamp = stmSrc.m_nTimeStamp ;
|
||||
m_nTempProp[0] = stmSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = stmSrc.m_nTempProp[1] ;
|
||||
m_nMaxTFlag = stmSrc.m_nMaxTFlag ;
|
||||
m_nParts = stmSrc.m_nParts ;
|
||||
m_dTempParam[0] = stmSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = stmSrc.m_dTempParam[1] ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -1329,7 +1247,7 @@ SurfTriMesh::Dump( string& sOut, bool bMM, const char* szNewLine) const
|
||||
// segnalo eventuale incongruenza di orientamento
|
||||
if ( ! m_bOriented)
|
||||
sOut += string( "Inconsistent Orientation") + szNewLine ;
|
||||
// segnalo numero di parti se più di una
|
||||
// segnalo numero di parti se più di una
|
||||
int nParts = GetPartCount() ;
|
||||
if ( nParts > 1)
|
||||
sOut += string( "Parts =") + ToString( nParts) + szNewLine ;
|
||||
@@ -1559,7 +1477,7 @@ SurfTriMesh::Validate( bool bCorrect)
|
||||
|
||||
// Verifico che i triangoli riferiti dalle facce esistano
|
||||
for ( int i = 0 ; i < GetFacetSize() && m_nStatus == OK && m_bFaceted ; ++ i) {
|
||||
// verifico validità triangolo riferito
|
||||
// verifico validità triangolo riferito
|
||||
if ( m_vFacet[i] <= SVT_NULL ||
|
||||
m_vFacet[i] >= GetTriangleSize() ||
|
||||
m_vTria[ m_vFacet[i]].nIdVert[0] == SVT_DEL)
|
||||
@@ -1714,7 +1632,7 @@ SurfTriMesh::AdjustAdjacencies( void)
|
||||
bool
|
||||
SurfTriMesh::AdjustOrientations( void)
|
||||
{
|
||||
// se non ci sono almeno 2 triangoli è inutile fare test
|
||||
// se non ci sono almeno 2 triangoli è inutile fare test
|
||||
if ( m_vTria.size() < 2) {
|
||||
m_bOriented = true ;
|
||||
return true ;
|
||||
@@ -1758,7 +1676,7 @@ SurfTriMesh::AdjustTriaOrientation( TRINTDEQUE& S3iQ)
|
||||
S3iQ.pop_front() ;
|
||||
// assegno time stamp al triangolo
|
||||
m_vTria[nT].nTemp = m_nTimeStamp ;
|
||||
// se c'è triangolo di riferimento, devo verificare se da invertire
|
||||
// se c'è triangolo di riferimento, devo verificare se da invertire
|
||||
if ( nRefT != SVT_NULL) {
|
||||
// cerco indice half-edge in comune
|
||||
int nE = 0 ;
|
||||
@@ -1776,7 +1694,7 @@ SurfTriMesh::AdjustTriaOrientation( TRINTDEQUE& S3iQ)
|
||||
bool bOk = true ;
|
||||
for ( int j = 0 ; j < 3 ; ++ j) {
|
||||
int nAdjT = m_vTria[nT].nIdAdjac[j] ;
|
||||
// se non c'è adiacenza o va sul triangolo di provenienza
|
||||
// se non c'è adiacenza o va sul triangolo di provenienza
|
||||
if ( nAdjT == SVT_NULL || nAdjT == nRefT)
|
||||
;
|
||||
// la verifico
|
||||
@@ -1831,15 +1749,16 @@ SurfTriMesh::TestSealing( void)
|
||||
bool
|
||||
SurfTriMesh::AdjustTopology( void)
|
||||
{
|
||||
// se non è rimasto alcunché di valido, pulisco tutto ed esco
|
||||
// se non è rimasto alcunché di valido, pulisco tutto ed esco
|
||||
if ( GetVertexCount() < 3 || GetTriangleCount() < 1) {
|
||||
Clear() ;
|
||||
m_bOriented = true ;
|
||||
m_bClosed = true ;
|
||||
return true ;
|
||||
}
|
||||
// dichiaro sfaccettatura da ricalcolare
|
||||
// dichiaro sfaccettatura e relativi bordi da ricalcolare
|
||||
m_bFaceted = false ;
|
||||
m_bFacEdged = false ;
|
||||
// invalido calcolo connessione
|
||||
m_nParts = - 1 ;
|
||||
// verifica indici
|
||||
@@ -1848,7 +1767,7 @@ SurfTriMesh::AdjustTopology( void)
|
||||
// verifica adiacenze
|
||||
if ( ! AdjustAdjacencies())
|
||||
return false ;
|
||||
// verifica continuità orientazione
|
||||
// verifica continuità orientazione
|
||||
if ( ! AdjustOrientations())
|
||||
return false ;
|
||||
// verifica chiusura
|
||||
@@ -1886,7 +1805,7 @@ SurfTriMesh::PackVertices( void)
|
||||
vVId.push_back( SVT_DEL) ;
|
||||
}
|
||||
}
|
||||
// se non c'è stata compattazione, esco
|
||||
// se non c'è stata compattazione, esco
|
||||
if ( nFirstFree == SVT_NULL)
|
||||
return true ;
|
||||
// lunghezza vettore indici vertici
|
||||
@@ -1901,7 +1820,7 @@ SurfTriMesh::PackVertices( void)
|
||||
// salto i triangoli cancellati
|
||||
if ( vOId[0] == SVT_DEL)
|
||||
continue ;
|
||||
// verifico la validità degli indici
|
||||
// verifico la validità degli indici
|
||||
if ( vOId[0] < 0 || vOId[0] >= nVIdSize ||
|
||||
vOId[1] < 0 || vOId[1] >= nVIdSize ||
|
||||
vOId[2] < 0 || vOId[2] >= nVIdSize)
|
||||
@@ -1941,7 +1860,7 @@ SurfTriMesh::PackTriangles( void)
|
||||
vTId.push_back( SVT_DEL) ;
|
||||
}
|
||||
}
|
||||
// se non c'è stata compattazione, esco
|
||||
// se non c'è stata compattazione, esco
|
||||
if ( nFirstFree == SVT_NULL)
|
||||
return true ;
|
||||
// Invalido HashGrid
|
||||
@@ -1955,7 +1874,7 @@ SurfTriMesh::PackTriangles( void)
|
||||
// salto vertice cancellato
|
||||
if ( nOId == SVT_DEL)
|
||||
continue ;
|
||||
// verifico la validità dell'indice
|
||||
// verifico la validità dell'indice
|
||||
if ( nOId < 0 || nOId >= nTIdSize)
|
||||
return false ;
|
||||
// aggiorno
|
||||
@@ -1985,7 +1904,7 @@ SurfTriMesh::PackTriangles( void)
|
||||
// salto le facets non valide
|
||||
if ( m_vFacet[nId] == SVT_DEL)
|
||||
continue ;
|
||||
// verifico validità indice a triangolo
|
||||
// verifico validità indice a triangolo
|
||||
if ( m_vFacet[nId] < 0 || m_vFacet[nId] >= nTIdSize)
|
||||
return false ;
|
||||
// aggiorno
|
||||
@@ -2087,7 +2006,7 @@ SurfTriMesh::CreateByExtrusion( const PolyLine& PL, const Vector3d& vtExtr)
|
||||
m_OGrMgr.Reset() ;
|
||||
ResetHashGrids3d() ;
|
||||
|
||||
// verifico se la polilinea è chiusa
|
||||
// verifico se la polilinea è chiusa
|
||||
bool bClosed = PL.IsClosed() ;
|
||||
|
||||
// costruisco la mesh
|
||||
@@ -2120,7 +2039,7 @@ SurfTriMesh::CreateByExtrusion( const PolyLine& PL, const Vector3d& vtExtr)
|
||||
}
|
||||
// se curva chiusa, aggiungo gli ultimi due triangoli
|
||||
if ( bClosed) {
|
||||
// non devo aggiungere i vertici, perchè coincidono con quelli iniziali
|
||||
// non devo aggiungere i vertici, perchè coincidono con quelli iniziali
|
||||
// aggiungo i due triangoli relativi
|
||||
nIdV[0] = nV ;
|
||||
nIdV[1] = nV - 1 ;
|
||||
@@ -2139,7 +2058,7 @@ SurfTriMesh::CreateByExtrusion( const PolyLine& PL, const Vector3d& vtExtr)
|
||||
bool
|
||||
SurfTriMesh::CreateByPointCurve( const Point3d& ptP, const PolyLine& PL)
|
||||
{
|
||||
// verifico validità punto/polilinea
|
||||
// verifico validità punto/polilinea
|
||||
bool bClosed = PL.IsClosed() ;
|
||||
// se chiusa, la polilinea deve avere almeno 3 punti
|
||||
if ( bClosed) {
|
||||
@@ -2183,7 +2102,7 @@ SurfTriMesh::CreateByPointCurve( const Point3d& ptP, const PolyLine& PL)
|
||||
// aggiorno indice punto precedente su curva
|
||||
nIdV[1] = nIdV[2] ;
|
||||
}
|
||||
// se chiusa aggiungo l'ultimo triangolo (non il vertice perchè è il primo della curva)
|
||||
// se chiusa aggiungo l'ultimo triangolo (non il vertice perchè è il primo della curva)
|
||||
if ( bClosed) {
|
||||
nIdV[2] = 1 ;
|
||||
// inserisco il triangolo A2p -> A1p -> A1s
|
||||
@@ -2275,7 +2194,7 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR
|
||||
}
|
||||
// ciclo sui punti
|
||||
while ( bNext1 || bNext2) {
|
||||
// se non c'è V2s oppure c'è nuovo V1s e la diagonale più corta è V2p -> V1s
|
||||
// se non c'è V2s oppure c'è nuovo V1s e la diagonale più corta è V2p -> V1s
|
||||
if ( ! bNext2 || ( bNext1 && ( nP1s == vPnt2[nP2p].second || vPnt1[nP1s].second == nP2p))) {
|
||||
// inserisco il vertice V1s (se ultimo e curve chiuse, prendo il primo)
|
||||
if ( nP1s == nTotP1 - 1 && bClosed)
|
||||
@@ -2297,7 +2216,7 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR
|
||||
nV1p = nV1s ; nP1p = nP1s ; ++ nP1s ;
|
||||
bNext1 = ( nP1s < nTotP1) ;
|
||||
}
|
||||
// altrimenti è V1p -> V2s
|
||||
// altrimenti è V1p -> V2s
|
||||
else {
|
||||
// inserisco il vertice V2s (se ultimo e curve chiuse, prendo il primo)
|
||||
if ( nP2s == nTotP2 - 1 && bClosed)
|
||||
@@ -2324,7 +2243,7 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR
|
||||
|
||||
// altrimenti rigata con parametrizzazione sincrona sulle due curve
|
||||
else {
|
||||
// verifico validità polilinee (devono avere almeno 2 punti e non coincidere se non agli estremi aperti)
|
||||
// verifico validità polilinee (devono avere almeno 2 punti e non coincidere se non agli estremi aperti)
|
||||
if ( ! VerifyPolylinesForTwoCurves( PL1, PL2))
|
||||
return false ;
|
||||
|
||||
@@ -2449,7 +2368,7 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR
|
||||
if ( bNext2)
|
||||
dA2s = ( dU2s - dU2F) / dDeltaU2 ;
|
||||
}
|
||||
// se non c'è dA2s oppure c'è nuovo dA1s e la diagonale più corta è dA2p -> dA1s
|
||||
// se non c'è dA2s oppure c'è nuovo dA1s e la diagonale più corta è dA2p -> dA1s
|
||||
else if ( ! bNext2 || ( bNext1 && ( dA1s - dA2p) <= ( dA2s - dA1p) + EPS_PARAM)) {
|
||||
// inserisco il vertice A1s
|
||||
if ( ( nV1s = AddVertex( ptP1s)) == SVT_NULL)
|
||||
@@ -2473,7 +2392,7 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR
|
||||
if ( bNext1)
|
||||
dA1s = ( dU1s - dU1F) / dDeltaU1 ;
|
||||
}
|
||||
// altrimenti è dA1p -> dA2s
|
||||
// altrimenti è dA1p -> dA2s
|
||||
else {
|
||||
// inserisco il vertice A2s
|
||||
if ( ( nV2s = AddVertex( ptP2s)) == SVT_NULL)
|
||||
@@ -2502,7 +2421,7 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR
|
||||
if ( bClosed) {
|
||||
dA1s = 1 ;
|
||||
dA2s = 1 ;
|
||||
// se la diagonale più corta è dA2p -> dA1s = 0
|
||||
// se la diagonale più corta è dA2p -> dA1s = 0
|
||||
if ( ( dA1s - dA2p) <= ( dA2s - dA1p) + EPS_PARAM) {
|
||||
// inserisco il triangolo A2p -> A1p -> A1s = 0
|
||||
nIdV[0] = nV2p ;
|
||||
@@ -2517,7 +2436,7 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR
|
||||
if ( AddTriangle( nIdV) == SVT_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti è dA1p -> dA2s = 1
|
||||
// altrimenti è dA1p -> dA2s = 1
|
||||
else {
|
||||
// inserisco il triangolo A2p -> A1p -> A2s = 1
|
||||
nIdV[0] = nV2p ;
|
||||
@@ -2592,7 +2511,7 @@ SurfTriMesh::VerifyPolylinesForTwoCurves( const PolyLine& PL1, const PolyLine& P
|
||||
return false ;
|
||||
// verifiche sui punti successivi (non sugli ultimi)
|
||||
while ( bNext1 || bNext2) {
|
||||
// se c'è nuovo dA1s e la diagonale più corta è dA2p -> dA1s oppure non c'è dA2s
|
||||
// se c'è nuovo dA1s e la diagonale più corta è dA2p -> dA1s oppure non c'è dA2s
|
||||
if ( ( bNext1 && ( dA1s - dA2p) <= ( dA2s - dA1p) + EPS_PARAM) || ! bNext2) {
|
||||
// verifico se coincidono
|
||||
if ( AreSamePointApprox( ptP2p, ptP1s))
|
||||
@@ -2603,7 +2522,7 @@ SurfTriMesh::VerifyPolylinesForTwoCurves( const PolyLine& PL1, const PolyLine& P
|
||||
if ( bNext1)
|
||||
dA1s = ( dU1s - dU1F) / dDeltaU1 ;
|
||||
}
|
||||
// altrimenti è dA1p -> dA2s = 1
|
||||
// altrimenti è dA1p -> dA2s = 1
|
||||
else {
|
||||
// verifico se coincidono
|
||||
if ( AreSamePointApprox( ptP1p, ptP2s))
|
||||
@@ -2707,7 +2626,7 @@ AdjustPolylineForRevolution( PolyLine& PL, const Point3d& ptAx, const Vector3d&
|
||||
plTrim.Translate( DIST_SIC * vtTrN) ;
|
||||
PL.Trim( plTrim, false) ;
|
||||
|
||||
// Se polilinea risultante è aperta con estremità molto vicine all'asse le porto su questo
|
||||
// Se polilinea risultante è aperta con estremità molto vicine all'asse le porto su questo
|
||||
if ( ! PL.IsClosed()) {
|
||||
// verifico l'inizio
|
||||
double dUStart ;
|
||||
@@ -2785,7 +2704,7 @@ SurfTriMesh::CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Ve
|
||||
m_OGrMgr.Reset() ;
|
||||
ResetHashGrids3d() ;
|
||||
|
||||
// verifico se la polilinea è chiusa
|
||||
// verifico se la polilinea è chiusa
|
||||
bool bClosed = MyPL.IsClosed() ;
|
||||
|
||||
// costruisco la mesh
|
||||
@@ -2806,7 +2725,7 @@ SurfTriMesh::CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Ve
|
||||
// verifico se il punto giace sull'asse e vi sta fisso
|
||||
bool bPrevOnAx = bOnlyRev && DistPointLine( ptP, ptAx, vtAx, 1, false).IsSmall() ;
|
||||
int nVPrevOnAx = nV ;
|
||||
// se non è fisso sull'asse, inserisco le copie ruotate
|
||||
// se non è fisso sull'asse, inserisco le copie ruotate
|
||||
if ( ! bPrevOnAx) {
|
||||
for ( int i = 1 ; i <= nStep ; ++i) {
|
||||
ptP.Rotate( ptAx, vtAx, dCosStepRot, dSinStepRot) ;
|
||||
@@ -2828,7 +2747,7 @@ SurfTriMesh::CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Ve
|
||||
bool bOnAx = bOnlyRev && DistPointLine( ptP, ptAx, vtAx, 1, false).IsSmall() ;
|
||||
// ciclo sugli step
|
||||
for ( int i = 1 ; i <= nStep ; ++i) {
|
||||
// se non è fisso sull'asse, inserisco le copie ruotate
|
||||
// se non è fisso sull'asse, inserisco le copie ruotate
|
||||
if ( ! bOnAx) {
|
||||
ptP.Rotate( ptAx, vtAx, dCosStepRot, dSinStepRot) ;
|
||||
if ( ! bOnlyRev)
|
||||
@@ -2837,8 +2756,8 @@ SurfTriMesh::CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Ve
|
||||
return false ;
|
||||
++ nV ;
|
||||
}
|
||||
// per i controlli già fatti non è possibile avere contemp. prec e corr su asse
|
||||
// se il precedente è sull'asse, aggiungo un solo triangolo
|
||||
// per i controlli già fatti non è possibile avere contemp. prec e corr su asse
|
||||
// se il precedente è sull'asse, aggiungo un solo triangolo
|
||||
if ( bPrevOnAx) {
|
||||
nIdV[0] = nVPrevOnAx ;
|
||||
nIdV[1] = nV ;
|
||||
@@ -2846,7 +2765,7 @@ SurfTriMesh::CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Ve
|
||||
if ( AddTriangle( nIdV) == SVT_NULL)
|
||||
return false ;
|
||||
}
|
||||
// se il corrente è sull'asse, aggiungo un solo triangolo
|
||||
// se il corrente è sull'asse, aggiungo un solo triangolo
|
||||
else if ( bOnAx) {
|
||||
nIdV[0] = nV - ( nStep + 2) + i ;
|
||||
nIdV[1] = nIdV[0] + 1 ;
|
||||
@@ -2866,8 +2785,8 @@ SurfTriMesh::CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Ve
|
||||
}
|
||||
// se rivoluzione completa, aggiungo i due triangoli di chiusura
|
||||
if ( bFullRev) {
|
||||
// per i controlli già fatti non è possibile avere contemp. prec e corr su asse
|
||||
// se il precedente è sull'asse, aggiungo un solo triangolo
|
||||
// per i controlli già fatti non è possibile avere contemp. prec e corr su asse
|
||||
// se il precedente è sull'asse, aggiungo un solo triangolo
|
||||
if ( bPrevOnAx) {
|
||||
nIdV[0] = nVPrevOnAx ;
|
||||
nIdV[1] = nV - nStep ;
|
||||
@@ -2875,7 +2794,7 @@ SurfTriMesh::CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Ve
|
||||
if ( AddTriangle( nIdV) == SVT_NULL)
|
||||
return false ;
|
||||
}
|
||||
// se il corrente è sull'asse, aggiungo un solo triangolo
|
||||
// se il corrente è sull'asse, aggiungo un solo triangolo
|
||||
else if ( bOnAx) {
|
||||
nIdV[0] = nV - 1 ;
|
||||
nIdV[1] = nV - ( nStep + 1) ;
|
||||
@@ -2898,7 +2817,7 @@ SurfTriMesh::CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Ve
|
||||
// altrimenti ultimo punto di polilinea chiusa
|
||||
if ( bClosed) {
|
||||
for ( int i = 1 ; i <= nStep ; ++i) {
|
||||
// non devo aggiungere i vertici, perchè coincidono con quelli iniziali
|
||||
// non devo aggiungere i vertici, perchè coincidono con quelli iniziali
|
||||
// aggiungo triangolo in basso a sinistra
|
||||
nIdV[0] = nV - nStep + i - 1 ; nIdV[1] = nV - nStep + i ; nIdV[2] = i ;
|
||||
if ( AddTriangle( nIdV) == SVT_NULL)
|
||||
@@ -2934,7 +2853,7 @@ SurfTriMesh::AddBiTriangle( const int nIdVert[4])
|
||||
// | |
|
||||
// 1 -> 2
|
||||
int nIdV[3] ;
|
||||
// se la diagonale 0->2 è uguale o più corta della 1->3
|
||||
// se la diagonale 0->2 è uguale o più corta della 1->3
|
||||
if ( SqDist( m_vVert[nIdVert[0]].ptP, m_vVert[nIdVert[2]].ptP) <=
|
||||
SqDist( m_vVert[nIdVert[1]].ptP, m_vVert[nIdVert[3]].ptP) + EPS_SMALL) {
|
||||
// triangolo 0->1->2
|
||||
@@ -2995,14 +2914,14 @@ SurfTriMesh::DoCompacting( double dTol)
|
||||
}
|
||||
// recupero la posizione geometrica del vertice
|
||||
Point3d ptP = m_vVert[nId].ptP ;
|
||||
// se non c'è già un vertice con la stessa posizione lo inserisco nel grid
|
||||
// se non c'è già un vertice con la stessa posizione lo inserisco nel grid
|
||||
int nAliasId ;
|
||||
if ( ! VertGrid.Find( ptP, dTol, nAliasId)) {
|
||||
VertGrid.InsertPoint( ptP, nId) ;
|
||||
// salvo l'Id nel vettore di reindirizzo
|
||||
vVId.push_back( nId) ;
|
||||
}
|
||||
// c'è un vertice coincidente
|
||||
// c'è un vertice coincidente
|
||||
else {
|
||||
// salvo l'Id alias nel vettore di reindirizzo
|
||||
vVId.push_back( nAliasId) ;
|
||||
@@ -3021,7 +2940,7 @@ SurfTriMesh::DoCompacting( double dTol)
|
||||
int vOId[3]{ m_vTria[nId].nIdVert[0],
|
||||
m_vTria[nId].nIdVert[1],
|
||||
m_vTria[nId].nIdVert[2]} ;
|
||||
// verifico la validità degli indici
|
||||
// verifico la validità degli indici
|
||||
if ( vOId[0] < 0 || vOId[0] >= nVIdSize ||
|
||||
vOId[1] < 0 || vOId[1] >= nVIdSize ||
|
||||
vOId[2] < 0 || vOId[2] >= nVIdSize)
|
||||
@@ -3030,7 +2949,7 @@ SurfTriMesh::DoCompacting( double dTol)
|
||||
m_vTria[nId].nIdVert[0] = vVId[vOId[0]] ;
|
||||
m_vTria[nId].nIdVert[1] = vVId[vOId[1]] ;
|
||||
m_vTria[nId].nIdVert[2] = vVId[vOId[2]] ;
|
||||
// se due vertici coincidono o la normale non è calcolabile, cancello il triangolo
|
||||
// se due vertici coincidono o la normale non è calcolabile, cancello il triangolo
|
||||
if ( m_vTria[nId].nIdVert[0] == m_vTria[nId].nIdVert[1] ||
|
||||
m_vTria[nId].nIdVert[0] == m_vTria[nId].nIdVert[2] ||
|
||||
m_vTria[nId].nIdVert[1] == m_vTria[nId].nIdVert[2] ||
|
||||
@@ -3093,7 +3012,7 @@ SurfTriMesh::DoSewing( const ISurfTriMesh& stmOther, const Frame3d& frOther, dou
|
||||
Point3d ptOP = pOther->m_vVert[nOId].ptP ;
|
||||
// la porto nel riferimento della prima superficie
|
||||
ptOP.ToGlob( frOther) ;
|
||||
// se non c'è già un vertice con la stessa posizione lo inserisco
|
||||
// se non c'è già un vertice con la stessa posizione lo inserisco
|
||||
int nNewId ;
|
||||
if ( ! VertGrid.Find( ptOP, dTol, nNewId)) {
|
||||
if ( ( nNewId = AddVertex( ptOP)) == SVT_NULL)
|
||||
@@ -3115,7 +3034,7 @@ SurfTriMesh::DoSewing( const ISurfTriMesh& stmOther, const Frame3d& frOther, dou
|
||||
// salto i triangoli cancellati
|
||||
if ( vOId[0] == SVT_DEL)
|
||||
continue ;
|
||||
// verifico la validità degli indici
|
||||
// verifico la validità degli indici
|
||||
if ( vOId[0] < 0 || vOId[0] >= nVIdSize ||
|
||||
vOId[1] < 0 || vOId[1] >= nVIdSize ||
|
||||
vOId[2] < 0 || vOId[2] >= nVIdSize)
|
||||
@@ -3167,7 +3086,7 @@ SurfTriMesh::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità del frame
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
// assegno il box nel riferimento
|
||||
@@ -3212,7 +3131,7 @@ SurfTriMesh::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng,
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico validità dell'asse di rotazione
|
||||
// verifico validità dell'asse di rotazione
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
|
||||
@@ -3278,7 +3197,7 @@ SurfTriMesh::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double
|
||||
bool bRecalc = ( abs( dCoeffX) < EPS_ZERO || abs( dCoeffY) < EPS_ZERO || abs( dCoeffZ) < EPS_ZERO) ;
|
||||
for ( int i = 0 ; i < GetTriangleSize() ; ++ i) {
|
||||
if ( m_vTria[i].nIdVert[0] != SVT_DEL) {
|
||||
// se c'è mirror, devo invertire la faccia
|
||||
// se c'è mirror, devo invertire la faccia
|
||||
if ( bMirror)
|
||||
InvertTriangle( i) ;
|
||||
// aggiorno la normale
|
||||
@@ -3300,7 +3219,7 @@ SurfTriMesh::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double
|
||||
bool
|
||||
SurfTriMesh::InvertTriangle( int nT)
|
||||
{
|
||||
// controllo validità triangolo
|
||||
// controllo validità triangolo
|
||||
if ( ! ExistsTriangle( nT))
|
||||
return true ;
|
||||
// scambio di due vertici
|
||||
@@ -3316,10 +3235,10 @@ SurfTriMesh::InvertTriangle( int nT)
|
||||
bool
|
||||
SurfTriMesh::CalcTriangleNormal( int nT)
|
||||
{
|
||||
// controllo validità triangolo
|
||||
// controllo validità triangolo
|
||||
if ( m_vTria[nT].nIdVert[0] == SVT_DEL)
|
||||
return true ;
|
||||
// controllo validità vertici riferiti dal triangolo
|
||||
// controllo validità vertici riferiti dal triangolo
|
||||
if ( m_vTria[nT].nIdVert[0] < 0 ||
|
||||
m_vTria[nT].nIdVert[0] >= GetVertexSize() ||
|
||||
m_vVert[m_vTria[nT].nIdVert[0]].nIdTria == SVT_DEL ||
|
||||
@@ -3348,7 +3267,7 @@ SurfTriMesh::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità del piano di specchiatura
|
||||
// verifico validità del piano di specchiatura
|
||||
if ( vtNorm.IsSmall())
|
||||
return false ;
|
||||
|
||||
@@ -3380,7 +3299,7 @@ SurfTriMesh::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d&
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità dei parametri
|
||||
// verifico validità dei parametri
|
||||
if ( vtNorm.IsSmall() || vtDir.IsSmall())
|
||||
return false ;
|
||||
|
||||
@@ -3411,11 +3330,11 @@ SurfTriMesh::ToGlob( const Frame3d& frRef)
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità del frame
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se frame identità, non devo fare alcunché
|
||||
// se frame identità, non devo fare alcunché
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
@@ -3445,11 +3364,11 @@ SurfTriMesh::ToLoc( const Frame3d& frRef)
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità del frame
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se frame identità, non devo fare alcunché
|
||||
// se frame identità, non devo fare alcunché
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
@@ -3479,11 +3398,11 @@ SurfTriMesh::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità dei frame
|
||||
// verifico validità dei frame
|
||||
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se i due riferimenti coincidono, non devo fare alcunché
|
||||
// se i due riferimenti coincidono, non devo fare alcunché
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
|
||||
@@ -3540,7 +3459,7 @@ SurfTriMesh::ResetHashGrids3d( void) const
|
||||
bool
|
||||
SurfTriMesh::VerifyHashGrids3d( void) const
|
||||
{
|
||||
// se già calcolato, non devo fare altro
|
||||
// se già calcolato, non devo fare altro
|
||||
if ( m_pHGrd3d != nullptr)
|
||||
return true ;
|
||||
// alloco
|
||||
@@ -3611,7 +3530,7 @@ SurfTriMesh::VerifyConnection( void) const
|
||||
// ciclo sui triangoli
|
||||
m_nParts = 0 ;
|
||||
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
|
||||
// salto triangoli cancellati o già assegnati
|
||||
// salto triangoli cancellati o gi� assegnati
|
||||
if ( m_vTria[i].nIdVert[0] == SVT_DEL ||
|
||||
m_vTria[i].nPart != SVT_NULL)
|
||||
continue ;
|
||||
|
||||
+81
-64
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2023
|
||||
//----------------------------------------------------------------------------
|
||||
// File : SurfTriMesh.h Data : 07.07.23 Versione : 2.5g1
|
||||
// File : SurfTriMesh.h Data : 09.12.23 Versione : 2.5l2
|
||||
// Contenuto : Dichiarazione della classe Superficie TriMesh.
|
||||
//
|
||||
//
|
||||
@@ -27,19 +27,22 @@ class SurfFlatRegion ;
|
||||
// Classe Vertice
|
||||
class StmVert
|
||||
{
|
||||
public :
|
||||
StmVert( void) : ptP(), dU( -1), dV( -1), nIdTria( SVT_NULL), nFlag( 0), nTemp( 0) {}
|
||||
StmVert( const Point3d& ptQ) : ptP( ptQ), dU( -1), dV( -1), nIdTria( SVT_NULL), nFlag( 0), nTemp( 0) {}
|
||||
StmVert( const Point3d& ptQ, int nIdT, int nF) : ptP( ptQ), dU( -1), dV( -1), nIdTria( nIdT), nFlag( nF), nTemp( 0) {}
|
||||
public :
|
||||
Point3d ptP ;
|
||||
double dU ; // parametro riferito alle coordinate del punto nello spazio parametrico ( nSpanU x 1000) ( nSpanV x 1000)
|
||||
// della sup di Bezier // -1 se non definito
|
||||
double dV ; // parametro riferito alle coordinate del punto nello spazio parametrico ( nSpanU x 1000) ( nSpanV x 1000)
|
||||
// della sup di Bezier // -1 se non definito
|
||||
int nIdTria ;
|
||||
int nFlag ;
|
||||
mutable int nTemp ;
|
||||
public :
|
||||
StmVert( void)
|
||||
: ptP(), dU( SVT_NULL), dV( SVT_NULL), nIdTria( SVT_NULL), nFlag( 0), nTemp( 0) {}
|
||||
StmVert( const Point3d& ptQ)
|
||||
: ptP( ptQ), dU( SVT_NULL), dV( SVT_NULL), nIdTria( SVT_NULL), nFlag( 0), nTemp( 0) {}
|
||||
StmVert( const Point3d& ptQ, int nIdT, int nF)
|
||||
: ptP( ptQ), dU( SVT_NULL), dV( SVT_NULL), nIdTria( nIdT), nFlag( nF), nTemp( 0) {}
|
||||
public :
|
||||
Point3d ptP ;
|
||||
double dU ; // parametro riferito alle coordinate del punto nello spazio parametrico ( nSpanU x 1000) ( nSpanV x 1000)
|
||||
// della sup di Bezier // -1 se non definito
|
||||
double dV ; // parametro riferito alle coordinate del punto nello spazio parametrico ( nSpanU x 1000) ( nSpanV x 1000)
|
||||
// della sup di Bezier // -1 se non definito
|
||||
int nIdTria ;
|
||||
int nFlag ;
|
||||
mutable int nTemp ;
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -47,19 +50,18 @@ public :
|
||||
class StmTria
|
||||
{
|
||||
public :
|
||||
StmTria( void) : vtN(), nIdFacet( SVT_NULL), nTFlag( 0), nEFlag( 0), nPart( SVT_NULL), nTemp( 0)
|
||||
{ nIdVert[0] = SVT_NULL ; nIdVert[1] = SVT_NULL ; nIdVert[2] = SVT_NULL ;
|
||||
nIdAdjac[0] = SVT_NULL ; nIdAdjac[1] = SVT_NULL ; nIdAdjac[2] = SVT_NULL ; }
|
||||
StmTria( const int nIdV[3]) : vtN(), nIdFacet( SVT_NULL), nTFlag( 0), nEFlag( 0), nPart( SVT_NULL), nTemp( 0)
|
||||
{ nIdVert[0] = nIdV[0] ; nIdVert[1] = nIdV[1] ; nIdVert[2] = nIdV[2] ;
|
||||
nIdAdjac[0] = SVT_NULL ; nIdAdjac[1] = SVT_NULL ; nIdAdjac[2] = SVT_NULL ; }
|
||||
StmTria( const int nIdV[3], int nTF) : vtN(), nIdFacet( SVT_NULL), nTFlag( nTF), nEFlag( 0), nPart( SVT_NULL), nTemp( 0)
|
||||
{ nIdVert[0] = nIdV[0] ; nIdVert[1] = nIdV[1] ; nIdVert[2] = nIdV[2] ;
|
||||
nIdAdjac[0] = SVT_NULL ; nIdAdjac[1] = SVT_NULL ; nIdAdjac[2] = SVT_NULL ; }
|
||||
StmTria( void)
|
||||
: nIdVert{ SVT_NULL, SVT_NULL, SVT_NULL}, nIdAdjac{ SVT_NULL, SVT_NULL, SVT_NULL}, nETempFlag{ 0, 0, 0},
|
||||
vtN(), nIdFacet( SVT_NULL), nTFlag( 0), nEFlag( 0), nPart( SVT_NULL), nTemp( 0), nTempPart{ 0} {}
|
||||
StmTria( const int nIdV[3])
|
||||
: nIdVert{ nIdV[0], nIdV[1], nIdV[2]}, nIdAdjac{ SVT_NULL, SVT_NULL, SVT_NULL}, nETempFlag{ 0, 0, 0},
|
||||
vtN(), nIdFacet( SVT_NULL), nTFlag( 0), nEFlag( 0), nPart( SVT_NULL), nTemp( 0), nTempPart{ 0} {}
|
||||
StmTria( const int nIdV[3], int nTF)
|
||||
: nIdVert{ nIdV[0], nIdV[1], nIdV[2]}, nIdAdjac{ SVT_NULL, SVT_NULL, SVT_NULL}, nETempFlag{ 0, 0, 0},
|
||||
vtN(), nIdFacet( SVT_NULL), nTFlag( nTF), nEFlag( 0), nPart( SVT_NULL), nTemp( 0), nTempPart{ 0} {}
|
||||
StmTria( const int nIdV[3], const int nIdA[3], const Vector3d& vtV, int nTF, int nEF)
|
||||
: vtN( vtV), nIdFacet( SVT_NULL), nTFlag( nTF), nEFlag( nEF), nPart( SVT_NULL), nTemp( 0)
|
||||
{ nIdVert[0] = nIdV[0] ; nIdVert[1] = nIdV[1] ; nIdVert[2] = nIdV[2] ;
|
||||
nIdAdjac[0] = nIdA[0] ; nIdAdjac[1] = nIdA[1] ; nIdAdjac[2] = nIdA[2] ; }
|
||||
: nIdVert{ nIdV[0], nIdV[1], nIdV[2]}, nIdAdjac{ nIdA[0], nIdA[1], nIdA[2]}, nETempFlag{ 0, 0, 0},
|
||||
vtN( vtV), nIdFacet( SVT_NULL), nTFlag( nTF), nEFlag( nEF), nPart( SVT_NULL), nTemp( 0), nTempPart{ 0} {}
|
||||
public :
|
||||
int nIdVert[3] ;
|
||||
int nIdAdjac[3] ;
|
||||
@@ -73,11 +75,27 @@ class StmTria
|
||||
mutable int nTempPart ;
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Classe Facet Edge
|
||||
class StmFacEdge
|
||||
{
|
||||
public :
|
||||
StmFacEdge( void)
|
||||
: nIdVert{ SVT_NULL, SVT_NULL}, nIdFacAdj{ SVT_NULL, SVT_NULL}, dIntAng{ 0} {}
|
||||
StmFacEdge( int nV1, int nV2, int nFl, int nFr, double dA)
|
||||
: nIdVert{ nV1, nV2}, nIdFacAdj{ nFl, nFr}, dIntAng{ dA} {}
|
||||
public :
|
||||
int nIdVert[2] ;
|
||||
int nIdFacAdj[2] ;
|
||||
double dIntAng ;
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Classe di tre interi per code di elaborazione sui triangoli (senza iterazioni)
|
||||
struct Stm3Int {
|
||||
Stm3Int( int nI, int nJ, int nK) : nI1( nI), nI2( nJ), nI3( nK) {}
|
||||
int nI1 ; int nI2 ; int nI3 ;
|
||||
Stm3Int( int nI, int nJ, int nK)
|
||||
: nI1( nI), nI2( nJ), nI3( nK) {}
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -102,16 +120,10 @@ typedef std::unordered_map< int, TRIA3DVECTOR> TRIA3DVECTORMAP ;
|
||||
struct LineFacetClass {
|
||||
Point3d ptSt, ptEn ;
|
||||
int nTypeA, nTypeB ;
|
||||
LineFacetClass( void) {
|
||||
nTypeA = 0 ;
|
||||
nTypeB = 0 ;
|
||||
}
|
||||
LineFacetClass( const Point3d& ptS, const Point3d& ptE, int nTpA, int nTpB) {
|
||||
ptSt = ptS ;
|
||||
ptEn = ptE ;
|
||||
nTypeA = nTpA ;
|
||||
nTypeB = nTpB ;
|
||||
}
|
||||
LineFacetClass( void)
|
||||
: nTypeA{ 0}, nTypeB{ 0} {}
|
||||
LineFacetClass( const Point3d& ptS, const Point3d& ptE, int nTpA, int nTpB)
|
||||
: ptSt{ ptS}, ptEn{ ptE}, nTypeA{ nTpA}, nTypeB{ nTpB} {}
|
||||
} ;
|
||||
typedef std::vector<LineFacetClass> LineFacetClassVector ;
|
||||
|
||||
@@ -124,18 +136,11 @@ struct IntersInnSeg {
|
||||
Point3d ptSt ;
|
||||
Point3d ptEn ;
|
||||
Vector3d vtOuter ;
|
||||
IntersInnSeg( void) {
|
||||
;
|
||||
}
|
||||
IntersInnSeg( const Point3d& ptS, const Point3d& ptE) {
|
||||
ptSt = ptS ;
|
||||
ptEn = ptE ;
|
||||
}
|
||||
IntersInnSeg( const Point3d& ptS, const Point3d& ptE, const Vector3d& vtO) {
|
||||
ptSt = ptS ;
|
||||
ptEn = ptE ;
|
||||
vtOuter = vtO ;
|
||||
}
|
||||
IntersInnSeg( void) {}
|
||||
IntersInnSeg( const Point3d& ptS, const Point3d& ptE)
|
||||
: ptSt{ ptS}, ptEn{ ptE} {}
|
||||
IntersInnSeg( const Point3d& ptS, const Point3d& ptE, const Vector3d& vtO)
|
||||
: ptSt{ ptS}, ptEn{ ptE}, vtOuter{ vtO} {}
|
||||
} ;
|
||||
typedef std::vector<IntersInnSeg> IntersInnChain ;
|
||||
typedef std::vector<IntersInnChain> INNCHAINVECTOR ;
|
||||
@@ -145,11 +150,8 @@ struct IntersEdge {
|
||||
Point3d ptSt ;
|
||||
Point3d ptEn ;
|
||||
INTVECTOR vOthFacetIndex ;
|
||||
IntersEdge( const Point3d& ptS, const Point3d& ptE, const INTVECTOR& vOFI) {
|
||||
ptSt = ptS;
|
||||
ptEn = ptE;
|
||||
vOthFacetIndex = vOFI ;
|
||||
}
|
||||
IntersEdge( const Point3d& ptS, const Point3d& ptE, const INTVECTOR& vOFI)
|
||||
: ptSt{ ptS}, ptEn{ ptE}, vOthFacetIndex{ vOFI} {}
|
||||
} ;
|
||||
typedef std::vector<IntersEdge> IntersEdgeVec ;
|
||||
typedef std::unordered_map<int, IntersEdgeVec> INTERSEDGEMAP ;
|
||||
@@ -195,6 +197,11 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // ISurf
|
||||
bool IsSimple( void) const override
|
||||
@@ -219,7 +226,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
{ m_dSmoothAng = std::max( dSmoothAngDeg, EPS_ANG_SMALL) ;
|
||||
m_dCosSmAng = cos( m_dSmoothAng * DEGTORAD) ;
|
||||
m_OGrMgr.Reset() ; }
|
||||
int AddVertex( const Point3d& ptVert, const double dU = -1 , const double dV = -1) override ;
|
||||
int AddVertex( const Point3d& ptVert, double dU = -1, double dV = -1) override ;
|
||||
bool MoveVertex( int nInd, const Point3d& ptNewVert) override ;
|
||||
int AddTriangle( const int nIdVert[3], int nTFlag = 0) override ;
|
||||
bool RemoveTriangle( int nId) override ;
|
||||
@@ -250,9 +257,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
bool GetVertex( int nId, Point3d& ptP) const override ;
|
||||
bool GetVertexParam( int nId, double& dU, double& dV) const override ;
|
||||
int GetFirstVertex( Point3d& ptP) const override ;
|
||||
int GetFirstVertexParam( int nId, double& dU, double& dV) const override ;
|
||||
int GetNextVertex( int nId, Point3d& ptP) const override ;
|
||||
int GetNextVertexParam( int nId, double& dU, double& dV) const override ;
|
||||
bool GetTriangle( int nId, int nIdVert[3]) const override ;
|
||||
int GetFirstTriangle( int nIdVert[3]) const override ;
|
||||
int GetNextTriangle( int nId, int nIdVert[3]) const override ;
|
||||
@@ -268,7 +273,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
bool GetTriangleSmoothNormals( int nId, TriNormals3d& TNrms) const override ;
|
||||
SurfTriMesh* CloneTriangle( int nT) const override ;
|
||||
bool GetLoops( POLYLINEVECTOR& vPL) const override ;
|
||||
bool GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR& vPL) const override ;
|
||||
bool GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR& vPL, bool bAllTria = false) const override ;
|
||||
int GetFacetCount( void) const override ;
|
||||
int GetFacetSize( void) const override
|
||||
{ return int( m_vFacet.size()) ; }
|
||||
@@ -288,6 +293,12 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
bool SwapFacets( int nF1, int nF2) override ;
|
||||
bool GetFacetLocalBBox( int nF, BBox3d& b3Loc, int nFlag = BBF_STANDARD) const override ;
|
||||
bool GetFacetBBox( int nF, const Frame3d& frRef, BBox3d& b3Ref, int nFlag = BBF_STANDARD) const override ;
|
||||
int GetEdgeCount( void) const override ;
|
||||
int GetEdgeSize( void) const override
|
||||
{ return int( m_vFacEdge.size()) ; }
|
||||
bool GetEdge( int nInd, int& nV1, int& nV2, int& nFl, int& nFr, double& dAng) const override ;
|
||||
bool GetEdge( int nInd, Point3d& ptP1, Point3d& ptP2, double& dAng) const override ;
|
||||
bool GetEdges( ICURVEPOVECTOR& vpCurve) const override ;
|
||||
bool Cut( const Plane3d& plPlane, bool bSaveOnEq) override ;
|
||||
bool GeneralizedCut( const ICurve& cvCurve, bool bSaveOnEq) override ;
|
||||
bool Add( const ISurfTriMesh& Other) override ;
|
||||
@@ -331,9 +342,10 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
bool SetTempInt( int nId, int nTempInt) const ;
|
||||
|
||||
private :
|
||||
typedef std::vector<StmVert> VERTVECTOR ;
|
||||
typedef std::vector<StmTria> TRIAVECTOR ;
|
||||
typedef std::deque<Stm3Int> TRINTDEQUE ;
|
||||
typedef std::vector<StmVert> VERTVECTOR ;
|
||||
typedef std::vector<StmTria> TRIAVECTOR ;
|
||||
typedef std::vector<StmFacEdge> FACEDGEVECTOR ;
|
||||
typedef std::deque<Stm3Int> TRINTDEQUE ;
|
||||
|
||||
private :
|
||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
||||
@@ -372,6 +384,8 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
bool VerifyAdjacTriaFacet( INTVECTOR& vT) const ;
|
||||
bool MarchAlongFacetLoop( int nF, int nT, int nV, int nTimeStamp, PolyLine& PL) const ;
|
||||
bool MarchOneFacetTria( int nF, int& nT, int& nV, int nTimeStamp, PolyLine& PL, bool& bEnd) const ;
|
||||
bool VerifyFacetEdging( void) const ;
|
||||
bool UpdateFacetEdging( void) ;
|
||||
void ResetHashGrids3d( void) const ;
|
||||
bool VerifyHashGrids3d( void) const ;
|
||||
bool VerifyConnection( void) const ;
|
||||
@@ -399,14 +413,17 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
double m_dCosBndAng ; // coseno dell'angolo limite per considerare un lato un contorno
|
||||
double m_dSmoothAng ; // angolo limite per mediare le normali (in gradi)
|
||||
double m_dCosSmAng ; // coseno dell'angolo limite per mediare le normali
|
||||
bool m_bOriented ; // la superficie è orientata consistentemente in tutte le sue parti
|
||||
bool m_bOriented ; // la superficie è orientata consistentemente in tutte le sue parti
|
||||
bool m_bClosed ; // la superficie racchiude un volume
|
||||
bool m_bFaceted ; // flag di validità della sfaccettatura
|
||||
bool m_bFaceted ; // flag di validità della sfaccettatura
|
||||
bool m_bFacEdged ; // flag di validità dei bordi della sfaccettatura
|
||||
VERTVECTOR m_vVert ; // vettore dei vertici
|
||||
TRIAVECTOR m_vTria ; // vettore dei triangoli
|
||||
INTVECTOR m_vFacet ; // vettore delle sfaccettature
|
||||
FACEDGEVECTOR m_vFacEdge ; // vettore degli edge delle sfaccettature
|
||||
mutable int m_nTimeStamp ; // orologio locale
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
int m_nMaxTFlag ; // massimo valore dei TFlag dei triangoli
|
||||
mutable int m_nParts ; // numero di parti connesse (-1 se da calcolare)
|
||||
mutable HashGrids3d* m_pHGrd3d ; // Hash Grid 3d nel suo riferimento
|
||||
|
||||
+115
-20
@@ -1272,6 +1272,7 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
|
||||
RetriangulationForBooleanOperation( LineMapB, AmbiguosB, SurfB, bModif) ;
|
||||
|
||||
// Se i triangoli delle superfici non si intersecano, una delle due è totalmente interna o esterna all'altra.
|
||||
// non mi basta fare un controllo sulle bbox perché non so come sono orientate le superfici e che potrebbero anche non essere chiuse
|
||||
bool bRetriangulated = true ;
|
||||
if ( ! bModif && ( int( AmbiguosA.size()) == 0 || int( AmbiguosB.size()) == 0)) {
|
||||
bRetriangulated = false ;
|
||||
@@ -1280,7 +1281,7 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
|
||||
int nCurVert = GetFirstVertex( ptFirstV) ;
|
||||
int nInOutNum = 0 ;
|
||||
while ( nInOutNum == 0 && nCurVert != SVT_NULL) {
|
||||
int nTriaNum = - 1 ;
|
||||
INTVECTOR vnTriaNum ;
|
||||
double dMinDist = DBL_MAX ;
|
||||
for ( int nTB = 0 ; nTB < nTriaNumB ; ++ nTB) {
|
||||
// Se il triangolo B non è valido, continuo
|
||||
@@ -1288,18 +1289,66 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
|
||||
if ( ! SurfB.GetTriangle( nTB, trTriaB) || ! trTriaB.Validate( true))
|
||||
continue ;
|
||||
double dDist ;
|
||||
if ( DistPointTriangle( ptFirstV, trTriaB).GetDist( dDist) && dDist < dMinDist) {
|
||||
nTriaNum = nTB ;
|
||||
dMinDist = dDist ;
|
||||
// potrei trovare più triangolo equidistanti, li salvo tutti
|
||||
if ( DistPointTriangle( ptFirstV, trTriaB).GetDist( dDist)) {
|
||||
if ( abs(dDist - dMinDist) < EPS_SMALL)
|
||||
vnTriaNum.push_back( nTB) ;
|
||||
else if ( dDist < dMinDist){
|
||||
vnTriaNum.clear() ;
|
||||
vnTriaNum.push_back( nTB) ;
|
||||
dMinDist = dDist ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( nTriaNum >= 0) {
|
||||
if ( ! vnTriaNum.empty()) {
|
||||
Triangle3d trTriaB ;
|
||||
SurfB.GetTriangle( nTriaNum, trTriaB) ;
|
||||
if ( ( ptFirstV - trTriaB.GetP(0)) * trTriaB.GetN() < - EPS_SMALL)
|
||||
nInOutNum = 1 ;
|
||||
else if ( ( ptFirstV - trTriaB.GetP(0)) * trTriaB.GetN() > EPS_SMALL)
|
||||
nInOutNum = - 1 ;
|
||||
bool bSame = true ;
|
||||
// controllo se rispetto a questi triangoli il punto risulta sempre fuori o sempre dentro
|
||||
for ( int nTriaNum : vnTriaNum) {
|
||||
SurfB.GetTriangle( nTriaNum, trTriaB) ;
|
||||
if ( ( ptFirstV - trTriaB.GetP(0)) * trTriaB.GetN() < - EPS_SMALL) {
|
||||
if ( nInOutNum == 0)
|
||||
nInOutNum = 1 ;
|
||||
else if (nInOutNum == -1) {
|
||||
bSame = false ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
else if ( ( ptFirstV - trTriaB.GetP(0)) * trTriaB.GetN() > EPS_SMALL) {
|
||||
if ( nInOutNum == 0)
|
||||
nInOutNum = -1 ;
|
||||
else if (nInOutNum == 1) {
|
||||
bSame = false ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// se le informazioni date dalle normali dei triangoli non sono concordi valuto il triangolo più vicino
|
||||
// e ricalcolo l'informazione che mi dà la sua normale
|
||||
if ( ! bSame ) {
|
||||
Point3d ptBar_tot ;
|
||||
for (int nTriaNum : vnTriaNum) {
|
||||
SurfB.GetTriangle( nTriaNum, trTriaB) ;
|
||||
ptBar_tot += trTriaB.GetCentroid();
|
||||
}
|
||||
ptBar_tot /= (int)vnTriaNum.size() ;
|
||||
for (int nTriaNum : vnTriaNum) {
|
||||
SurfB.GetTriangle( nTriaNum, trTriaB) ;
|
||||
Point3d ptInters1, ptInters2 ;
|
||||
int nInters = IntersLineTria(ptFirstV, ptBar_tot, trTriaB, ptInters1, ptInters2, true) ;
|
||||
if (nInters == ILTT_NO)
|
||||
continue ;
|
||||
else if ( nInters == ILTT_IN ) {
|
||||
if ( ( ptFirstV - trTriaB.GetP(0)) * trTriaB.GetN() < - EPS_SMALL)
|
||||
nInOutNum = 1 ;
|
||||
else if ( ( ptFirstV - trTriaB.GetP(0)) * trTriaB.GetN() > EPS_SMALL)
|
||||
nInOutNum = -1 ;
|
||||
break ;
|
||||
}
|
||||
else
|
||||
nInOutNum = 0 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( nInOutNum == 0) {
|
||||
nCurVert = GetNextVertex( nVertNum, ptFirstV) ;
|
||||
@@ -1313,7 +1362,7 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
|
||||
nCurVert = SurfB.GetFirstVertex( ptFirstV) ;
|
||||
nInOutNum = 0 ;
|
||||
while ( nInOutNum == 0 && nCurVert != SVT_NULL) {
|
||||
int nTriaNum = - 1 ;
|
||||
INTVECTOR vnTriaNum ;
|
||||
double dMinDist = DBL_MAX ;
|
||||
for ( int nTA = 0 ; nTA < nTriaNumA ; ++ nTA) {
|
||||
// Se il triangolo A non è valido, continuo
|
||||
@@ -1323,19 +1372,65 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
|
||||
DistPointTriangle DistCalculator( ptFirstV, trTriaA) ;
|
||||
double dDist ;
|
||||
DistCalculator.GetDist( dDist) ;
|
||||
if ( dDist < dMinDist) {
|
||||
nTriaNum = nTA ;
|
||||
dMinDist = dDist ;
|
||||
// potrei trovare più triangolo equidistanti, li salvo tutti
|
||||
if ( DistPointTriangle( ptFirstV, trTriaA).GetDist( dDist)) {
|
||||
if ( abs(dDist - dMinDist) < EPS_SMALL)
|
||||
vnTriaNum.push_back( nTA) ;
|
||||
else if ( dDist < dMinDist){
|
||||
vnTriaNum.clear() ;
|
||||
vnTriaNum.push_back( nTA) ;
|
||||
dMinDist = dDist ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( nTriaNum >= 0) {
|
||||
if ( ! vnTriaNum.empty()) {
|
||||
Triangle3d trTriaA ;
|
||||
GetTriangle( nTriaNum, trTriaA) ;
|
||||
if ( ( ptFirstV - trTriaA.GetP( 0)) * trTriaA.GetN() < - EPS_SMALL) {
|
||||
nInOutNum = 1 ;
|
||||
bool bSame = true ;
|
||||
// controllo se rispetto a questi triangoli il punto risulta sempre fuori o sempre dentro
|
||||
for ( int nTriaNum : vnTriaNum) {
|
||||
GetTriangle( nTriaNum, trTriaA) ;
|
||||
if ( ( ptFirstV - trTriaA.GetP(0)) * trTriaA.GetN() < - EPS_SMALL) {
|
||||
if ( nInOutNum == 0)
|
||||
nInOutNum = 1 ;
|
||||
else if (nInOutNum == -1) {
|
||||
bSame = false ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
else if ( ( ptFirstV - trTriaA.GetP(0)) * trTriaA.GetN() > EPS_SMALL) {
|
||||
if ( nInOutNum == 0)
|
||||
nInOutNum = -1 ;
|
||||
else if (nInOutNum == 1) {
|
||||
bSame = false ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( ( ptFirstV - trTriaA.GetP(0)) * trTriaA.GetN() > EPS_SMALL) {
|
||||
nInOutNum = - 1 ;
|
||||
// se le informazioni date dalle normali dei triangoli non sono concordi valuto il triangolo più vicino
|
||||
// e ricalcolo l'informazione che mi dà la sua normale
|
||||
if ( ! bSame ) {
|
||||
Point3d ptBar_tot ;
|
||||
for (int nTriaNum : vnTriaNum) {
|
||||
GetTriangle( nTriaNum, trTriaA) ;
|
||||
ptBar_tot += trTriaA.GetCentroid();
|
||||
}
|
||||
ptBar_tot /= (int)vnTriaNum.size() ;
|
||||
for (int nTriaNum : vnTriaNum) {
|
||||
GetTriangle( nTriaNum, trTriaA) ;
|
||||
Point3d ptInters1, ptInters2 ;
|
||||
int nInters = IntersLineTria(ptFirstV, ptBar_tot, trTriaA, ptInters1, ptInters2, true) ;
|
||||
if (nInters == ILTT_NO)
|
||||
continue ;
|
||||
else if ( nInters == ILTT_IN ) {
|
||||
if ( ( ptFirstV - trTriaA.GetP(0)) * trTriaA.GetN() < - EPS_SMALL)
|
||||
nInOutNum = 1 ;
|
||||
else if ( ( ptFirstV - trTriaA.GetP(0)) * trTriaA.GetN() > EPS_SMALL)
|
||||
nInOutNum = -1 ;
|
||||
break ;
|
||||
}
|
||||
else
|
||||
nInOutNum = 0 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( nInOutNum == 0) {
|
||||
|
||||
+163
-6
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2015
|
||||
// EgalTech 2015-2023
|
||||
//----------------------------------------------------------------------------
|
||||
// File : SurfTriMeshFaceting.cpp Data : 25.02.15 Versione : 1.6b
|
||||
// File : SurfTriMeshFaceting.cpp Data : 09.12.23 Versione : 2.5l2
|
||||
// Contenuto : Implementazione della classe Superfici TriMesh.
|
||||
//
|
||||
//
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "SurfTriMesh.h"
|
||||
#include "GeoConst.h"
|
||||
#include "PolygonPlane.h"
|
||||
#include "CurveLine.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <array>
|
||||
#include <set>
|
||||
@@ -44,6 +45,7 @@ SurfTriMesh::UpdateFaceting( void)
|
||||
m_vFacet.clear() ;
|
||||
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i)
|
||||
m_vTria[i].nIdFacet = SVT_NULL ;
|
||||
m_bFacEdged = false ;
|
||||
|
||||
// indice faccia corrente
|
||||
int nFacet = -1 ;
|
||||
@@ -84,8 +86,8 @@ SurfTriMesh::UpdateFaceting( void)
|
||||
LOG_ERROR( GetEGkLogger(), "SurfTM : UpdateFaceting error")
|
||||
|
||||
// calcolo facce piane effettuato
|
||||
m_bFaceted = true ;
|
||||
return true ;
|
||||
m_bFaceted = bOk ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -138,7 +140,7 @@ SurfTriMesh::UpdateTriaFaceting( int nRefT, int nFacet, const Plane3d& plPlane,
|
||||
}
|
||||
}
|
||||
if ( nV == SVT_NULL)
|
||||
return false ;
|
||||
return true ;
|
||||
double dTol = max( min( m_dLinTol, 20 * EPS_SMALL), 2 * EPS_SMALL) ;
|
||||
if ( ! PointInPlaneEpsilon( m_vVert[m_vTria[nT].nIdVert[nV]].ptP, plPlane, dTol))
|
||||
return true ;
|
||||
@@ -729,7 +731,7 @@ SurfTriMesh::CloneFacet( int nF) const
|
||||
int nIdV[3] ;
|
||||
for ( int j = 0 ; j < 3 ; ++ j) {
|
||||
// verifico se vertice già presente
|
||||
VVMAP::iterator it = PntMap.find( m_vTria[nT].nIdVert[j]) ;
|
||||
const auto it = PntMap.find( m_vTria[nT].nIdVert[j]) ;
|
||||
if ( it == PntMap.end()) {
|
||||
// aggiungo il vertice
|
||||
if ( ( nIdV[j] = pSTM->AddVertex( m_vVert[m_vTria[nT].nIdVert[j]].ptP)) == SVT_NULL)
|
||||
@@ -858,3 +860,158 @@ SurfTriMesh::GetFacetBBox( int nF, const Frame3d& frRef, BBox3d& b3Ref, int nFla
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::VerifyFacetEdging( void) const
|
||||
{
|
||||
if ( m_bFacEdged)
|
||||
return true ;
|
||||
return (const_cast<SurfTriMesh*>(this))->UpdateFacetEdging() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::UpdateFacetEdging( void)
|
||||
{
|
||||
// reset degli Edge
|
||||
m_bFacEdged = false ;
|
||||
m_vFacEdge.clear() ;
|
||||
|
||||
// verifico validità sfaccettatura
|
||||
if ( ! VerifyFaceting())
|
||||
return false ;
|
||||
|
||||
// reset flag temporaneo di edge dei triangoli
|
||||
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
|
||||
m_vTria[i].nETempFlag[0] = 0 ;
|
||||
m_vTria[i].nETempFlag[1] = 0 ;
|
||||
m_vTria[i].nETempFlag[2] = 0 ;
|
||||
}
|
||||
|
||||
// ricostruisco gli edge delle facce
|
||||
for ( int nT = 0 ; nT < int( m_vTria.size()) ; ++ nT) {
|
||||
StmTria& Tria = m_vTria[nT] ;
|
||||
// salto triangoli cancellati
|
||||
if ( Tria.nIdVert[0] == SVT_DEL)
|
||||
continue ;
|
||||
// ciclo sui lati del triangolo
|
||||
for ( int nE = 0 ; nE < 3 ; ++ nE) {
|
||||
int nE2 = ( nE + 1) % 3 ;
|
||||
int nTAdj = Tria.nIdAdjac[nE] ;
|
||||
if ( Tria.nETempFlag[nE] == 0) {
|
||||
if ( nTAdj == SVT_NULL) {
|
||||
m_vFacEdge.emplace_back( Tria.nIdVert[nE], Tria.nIdVert[nE2], Tria.nIdFacet, SVT_NULL, 0.) ;
|
||||
}
|
||||
else if ( Tria.nIdFacet != m_vTria[nTAdj].nIdFacet) {
|
||||
// calcolo l'angolo tra le facce ( 0 = allineate, > 0 convesse, < 0 concave)
|
||||
Vector3d vtN1 = Tria.vtN ;
|
||||
Vector3d vtN2 = m_vTria[nTAdj].vtN ;
|
||||
Vector3d vtCm = m_vVert[Tria.nIdVert[nE2]].ptP - m_vVert[Tria.nIdVert[nE]].ptP ;
|
||||
double dAng ;
|
||||
bool bDet ;
|
||||
if ( ! vtN1.GetRotation( vtN2, vtCm, dAng, bDet) || ! bDet)
|
||||
dAng = 0 ;
|
||||
// inserisco in lista
|
||||
m_vFacEdge.emplace_back( Tria.nIdVert[nE], Tria.nIdVert[nE2], Tria.nIdFacet, m_vTria[nTAdj].nIdFacet, dAng) ;
|
||||
// marco i due semi edge
|
||||
int nEAdj = 0 ;
|
||||
if ( m_vTria[nTAdj].nIdAdjac[1] == nT)
|
||||
nEAdj = 1 ;
|
||||
else if ( m_vTria[nTAdj].nIdAdjac[2] == nT)
|
||||
nEAdj = 2 ;
|
||||
Tria.nETempFlag[nE] = 1 ;
|
||||
m_vTria[nTAdj].nETempFlag[nEAdj] = 1 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// calcolo bordo delle facce piane effettuato
|
||||
m_bFacEdged = true ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
SurfTriMesh::GetEdgeCount( void) const
|
||||
{
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return -1 ;
|
||||
// verifico stato bordi sfaccettatura
|
||||
if ( ! VerifyFacetEdging())
|
||||
return -1 ;
|
||||
// restituisco il numero
|
||||
return int( m_vFacEdge.size()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::GetEdge( int nInd, int& nV1, int& nV2, int& nFl, int& nFr, double& dAng) const
|
||||
{
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico stato bordi sfaccettatura
|
||||
if ( ! VerifyFacetEdging())
|
||||
return false ;
|
||||
// verifico la validità dell'indice
|
||||
if ( nInd < 0 || nInd > int( m_vFacEdge.size()))
|
||||
return SVT_NULL ;
|
||||
// recupero i dati
|
||||
nV1 = m_vFacEdge[nInd].nIdVert[0] ;
|
||||
nV2 = m_vFacEdge[nInd].nIdVert[1] ;
|
||||
nFl = m_vFacEdge[nInd].nIdFacAdj[0] ;
|
||||
nFr = m_vFacEdge[nInd].nIdFacAdj[1] ;
|
||||
dAng = m_vFacEdge[nInd].dIntAng ;
|
||||
// ritorno indice edge corrente
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::GetEdge( int nInd, Point3d& ptP1, Point3d& ptP2, double& dAng) const
|
||||
{
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico stato bordi sfaccettatura
|
||||
if ( ! VerifyFacetEdging())
|
||||
return false ;
|
||||
// verifico la validità dell'indice
|
||||
if ( nInd < 0 || nInd > int( m_vFacEdge.size()))
|
||||
return SVT_NULL ;
|
||||
// recupero i dati
|
||||
ptP1 = m_vVert[m_vFacEdge[nInd].nIdVert[0]].ptP ;
|
||||
ptP2 = m_vVert[m_vFacEdge[nInd].nIdVert[1]].ptP ;
|
||||
dAng = m_vFacEdge[nInd].dIntAng ;
|
||||
// ritorno indice edge corrente
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::GetEdges( ICURVEPOVECTOR& vpCurve) const
|
||||
{
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico stato bordi sfaccettatura
|
||||
if ( ! VerifyFacetEdging())
|
||||
return false ;
|
||||
// ciclo sugli edge, creo le curve e le assegno al parametro da restituire
|
||||
for ( int nE = 0 ; nE < int( m_vFacEdge.size()) ; ++ nE) {
|
||||
Point3d ptS, ptE ;
|
||||
if ( ! GetVertex( m_vFacEdge[nE].nIdVert[0], ptS) ||
|
||||
! GetVertex( m_vFacEdge[nE].nIdVert[1], ptE))
|
||||
return false ;
|
||||
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pLine) || ! pLine->Set( ptS, ptE))
|
||||
continue ;
|
||||
pLine->SetTempParam( m_vFacEdge[nE].dIntAng) ;
|
||||
vpCurve.emplace_back( Release( pLine)) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -254,16 +254,19 @@ SurfTriMesh::RemoveTJunctions( bool& bModified)
|
||||
static bool
|
||||
IsVertex( PNTULIST& PointList, PNTULIST::const_iterator itCurr)
|
||||
{
|
||||
// se la lista contiene meno di tre punti, test inutili
|
||||
if ( PointList.size() < 3)
|
||||
return false ;
|
||||
// recupero il punto precedente
|
||||
PNTULIST::const_iterator itPrev ;
|
||||
if ( itCurr == PointList.begin())
|
||||
itPrev = prev( PointList.end(), 2) ;
|
||||
if ( itCurr == PointList.cbegin())
|
||||
itPrev = prev( PointList.cend(), 2) ;
|
||||
else
|
||||
itPrev = prev( itCurr) ;
|
||||
// recupero il punto successivo
|
||||
auto itNext = next( itCurr) ;
|
||||
if ( itNext == PointList.end())
|
||||
itNext = next( PointList.begin()) ;
|
||||
if ( itNext == PointList.cend())
|
||||
itNext = next( PointList.cbegin()) ;
|
||||
// se cambia faccia adiacente tra prima e dopo, va bene
|
||||
if ( itPrev->second != itCurr->second)
|
||||
return true ;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2022
|
||||
// EgalTech 2015-2023
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Tool.cpp Data : 04.07.18 Versione : 2.4f3
|
||||
// File : Tool.cpp Data : 08.09.23 Versione : 2.5i1
|
||||
// Contenuto : Implementazione della classe Tool
|
||||
//
|
||||
//
|
||||
@@ -87,6 +87,8 @@ Tool::SetStdTool( const string& sToolName, double dH, double dR, double dCornR,
|
||||
if ( dH < EPS_SMALL || dR < EPS_SMALL || dCornR < - EPS_SMALL)
|
||||
return false ;
|
||||
|
||||
bool bApproxWithLines = false ;
|
||||
|
||||
// utensile cilindrico
|
||||
if ( dCornR < EPS_SMALL) {
|
||||
m_nType = CYLMILL ;
|
||||
@@ -126,9 +128,8 @@ Tool::SetStdTool( const string& sToolName, double dH, double dR, double dCornR,
|
||||
m_Outline.AddLine( pt2);
|
||||
m_Outline.AddArcTg( pt3) ;
|
||||
m_Outline.AddLine( pt4) ;
|
||||
// se da approosimare
|
||||
if ( m_bApproxWithLines)
|
||||
return SetGenTool( sToolName, &m_Outline, nToolNum) ;
|
||||
// se da approssimare
|
||||
bApproxWithLines = m_bApproxWithLines ;
|
||||
}
|
||||
// utensile sferico
|
||||
else {
|
||||
@@ -151,7 +152,7 @@ Tool::SetStdTool( const string& sToolName, double dH, double dR, double dCornR,
|
||||
}
|
||||
|
||||
// eventuali sistemazioni per altezza tagliente
|
||||
if ( ModifyForCutterHeight())
|
||||
if ( ModifyForCutterHeight() || bApproxWithLines)
|
||||
return SetGenTool( sToolName, &m_Outline, nToolNum) ;
|
||||
else
|
||||
return true ;
|
||||
@@ -381,7 +382,7 @@ Tool::SetSawTool( const string& sToolName, double dH, double dR,
|
||||
}
|
||||
// altrimenti con raggio corner
|
||||
else {
|
||||
double dCR = Clamp( dCornR, 0., dThick / 2) ;
|
||||
double dCR = Clamp( dCornR, 0., min( dThick / 2, dR - 10 * EPS_SMALL)) ;
|
||||
// creazione profilo
|
||||
m_Outline.AddPoint( pt0) ;
|
||||
m_Outline.AddLine( pt1) ;
|
||||
@@ -410,7 +411,7 @@ Tool::SetSawTool( const string& sToolName, double dH, double dR,
|
||||
}
|
||||
// altrimenti con raggio corner
|
||||
else {
|
||||
double dCR = Clamp( dCornR, 0., dThick / 2) ;
|
||||
double dCR = Clamp( dCornR, 0., min( dThick / 2, dR - 10 * EPS_SMALL)) ;
|
||||
// creazione profilo
|
||||
m_Outline.AddPoint( pt0) ;
|
||||
m_Outline.AddLine( pt3 - X_AX * dCR) ;
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2023
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Tree.h Data : 21.04.23 Versione :
|
||||
// Contenuto : Implementazione della classe Cell di un albero binario Tree.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 21.04.23 DB Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "SurfBezier.h"
|
||||
#include "GeoConst.h"
|
||||
#include "CurveLine.h"
|
||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||
#include <map>
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
struct Inters {
|
||||
int nIn ;
|
||||
PNTVECTOR vpt ;
|
||||
int nOut ;
|
||||
bool bCCW ;
|
||||
int nChunk ;
|
||||
// riordino le intersezioni per lato in senso antiorario dal top
|
||||
// se ho pi� intersezioni che entrano in un lato le riordino considerando che percorro i lati in senso antiorario a partire da ptTR
|
||||
bool operator < ( Inters& b)
|
||||
{
|
||||
// trovo in che ordine stanno i due strat, tenendo conto anche della possibilit� che siano vertici
|
||||
INTVECTOR vEdges = { 7, 0, 4, 1, 5, 2, 6, 3} ;
|
||||
const auto iter1 = find( vEdges.begin(), vEdges.end(), nIn) ;
|
||||
int nPos1 = std::distance( vEdges.begin(), iter1) ;
|
||||
const auto iter2 = find( vEdges.begin(), vEdges.end(), b.nIn) ;
|
||||
int nPos2 = std::distance( vEdges.begin(), iter2) ;
|
||||
// se sono loop interni li ordino in modo decrescente rispetto all'area
|
||||
bool bEqIn = ( nIn == b.nIn) ;
|
||||
double dAreaA = 0 , dAreaB = 0 ;
|
||||
if ( bEqIn && nIn == -1) {
|
||||
PolyLine pl ;
|
||||
for ( int k = 0 ; k < (int)vpt.size(); ++ k)
|
||||
pl.AddUPoint( k, vpt[k]) ;
|
||||
pl.Close() ;
|
||||
pl.GetAreaXY( dAreaA) ;
|
||||
pl.Clear() ;
|
||||
for ( int k = 0 ; k < (int)b.vpt.size(); ++ k)
|
||||
pl.AddUPoint( k, b.vpt[k]) ;
|
||||
pl.Close() ;
|
||||
pl.GetAreaXY( dAreaB) ;
|
||||
}
|
||||
// se nIn � un vertice sistemo il valore
|
||||
int nEdgeIn = nIn ;
|
||||
if ( nIn > 3)
|
||||
nEdgeIn = nIn - 4 ;
|
||||
return ( nPos1 < nPos2 ||
|
||||
( bEqIn && nEdgeIn == -1 && abs( dAreaA) > abs( dAreaB)) ||
|
||||
( bEqIn && nEdgeIn == 0 && vpt[0].x > b.vpt[0].x) ||
|
||||
( bEqIn && nEdgeIn == 1 && vpt[0].y > b.vpt[0].y) ||
|
||||
( bEqIn && nEdgeIn == 2 && vpt[0].x < b.vpt[0].x) ||
|
||||
( bEqIn && nEdgeIn == 3 && vpt[0].y < b.vpt[0].y)) ;
|
||||
}
|
||||
bool operator == ( Inters& b)
|
||||
{
|
||||
return AreSamePointExact( vpt[0], b.vpt[0]) ;
|
||||
}
|
||||
bool operator != ( Inters& b)
|
||||
{
|
||||
return ! AreSamePointExact( vpt[0], b.vpt[0]) ;
|
||||
}
|
||||
} ;
|
||||
// nIn e nOut sono flag che indicano da quale lato ho l'ingresso e l'uscita a partire dal lato top in senso antiorario
|
||||
// oltre il 3 sono le celle adiacenti in diagonale al vertice-> 4 corrisponde al ptTl e da l� in senso antiorario
|
||||
// -1 se la curva � sempre dentro la cella
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class Cell
|
||||
{
|
||||
// Edge 0 ( Top)
|
||||
// Edge 4 ( NW) __________________ Edge 7 ( NE)
|
||||
// | |
|
||||
// | |
|
||||
// Edge 1 ( Left) | | Edge 3 ( Right)
|
||||
// | |
|
||||
// | |
|
||||
// |_________________|
|
||||
// Edge 5 ( SW) Edge 2 (Bottom) Edge 6 ( SE)
|
||||
public :
|
||||
~Cell( void) {}
|
||||
Cell( void)
|
||||
: m_nId( -1),m_nTop ( -2), m_nBottom( -2), m_nLeft( -2), m_nRight ( -2), m_nParent( -2), m_nDepth( 0),
|
||||
m_nChild1( -2), m_nChild2( -2), m_nFlag( -1), m_nFlag2( 0), m_nRightEdgeIn( -1), m_bOnLeftEdge( false), m_bOnTopEdge( false),
|
||||
m_ptPbl( ORIG), m_ptPtr( SBZ_TREG_COEFF, SBZ_TREG_COEFF, 0), m_bProcessed( false), m_bSplitVert( true)
|
||||
{
|
||||
Point3d ptTr ( 1 * SBZ_TREG_COEFF, 1 * SBZ_TREG_COEFF) ;
|
||||
m_ptPtr = ptTr ;
|
||||
}
|
||||
Cell( const Point3d& ptBL, const Point3d& ptTR)
|
||||
: m_nId( -1),m_nTop ( -2), m_nBottom( -2), m_nLeft( -2), m_nRight ( -2), m_nParent( -2), m_nDepth( 0),
|
||||
m_nChild1( -2), m_nChild2( -2), m_nFlag( -1), m_nFlag2( 0), m_nRightEdgeIn( -1), m_bOnLeftEdge( false), m_bOnTopEdge( false),
|
||||
m_ptPbl( ptBL), m_ptPtr( ptTR), m_bProcessed( false), m_bSplitVert( true) {}
|
||||
bool IsSame( const Cell& cOtherCell) const
|
||||
{ return ( m_nId == cOtherCell.m_nId) ; }
|
||||
void SetBottomLeft( const Point3d& ptBL)
|
||||
{ m_ptPbl = ptBL ; }
|
||||
void SetTopRight( const Point3d& ptTR)
|
||||
{ m_ptPtr = ptTR ; }
|
||||
void SetSplitDirVert( bool bVert)
|
||||
{ m_bSplitVert = bVert ; }
|
||||
void SetParent( int nParent)
|
||||
{ m_nParent = nParent ; }
|
||||
Point3d GetBottomLeft( void) const
|
||||
{ return m_ptPbl ; }
|
||||
Point3d GetTopRight( void) const
|
||||
{ return m_ptPtr ; }
|
||||
double GetSplitValue( void) const
|
||||
{ return m_dSplit ; }
|
||||
bool IsSplitVert( void) const // se true la cella verrebbe splittata verticalmente, senn� orizzontalmente
|
||||
{ return m_bSplitVert ; }
|
||||
bool IsLeaf( void) const // flag che indica se la cella ha figli o se � una foglia
|
||||
{ return ( m_nChild1 == -2 && m_nChild2 == -2) ; }
|
||||
bool IsProcessed( void) const // flag che indica se tutti i figli della cella, se ce ne sono, sono stati processati
|
||||
{ return m_bProcessed ; }
|
||||
void SetProcessed( bool bProcessed = true)
|
||||
{ m_bProcessed = bProcessed ; }
|
||||
static bool minorX( const Cell& c1, const Cell& c2)
|
||||
{ return c1.m_ptPbl.x < c2.m_ptPbl.x ; }
|
||||
static bool minorY( const Cell& c1, const Cell& c2)
|
||||
{ return c1.m_ptPbl.y < c2.m_ptPbl.y ; }
|
||||
|
||||
public :
|
||||
int m_nId ; // Id della cella
|
||||
int m_nTop ; // cella adiacente al lato top
|
||||
int m_nBottom ; // cella adiacente al lato bottom
|
||||
int m_nLeft ; // cella adiacente al lato left
|
||||
int m_nRight ; // cella adiacente al lato right
|
||||
int m_nParent ; // cella genitore
|
||||
int m_nDepth ; // profondit� della cella rispetto a root
|
||||
double m_dSplit ; // parametro a cui � stata splittata la cella
|
||||
int m_nChild1 ; // prima cella figlio
|
||||
int m_nChild2 ; // seconda cella figlio
|
||||
int m_nFlag ; // falg che indica la caratterizzazione della cella rispetto ai loop di trim
|
||||
// 0 esterna, 1 intersecata, 2 contiene un loop, 3 intersecata e contenente un loop, 4 contenuta in un loop
|
||||
int m_nFlag2 ; // falg che indica se la cella � stata attraversata durante l'ultima fase del labelling
|
||||
int m_nRightEdgeIn ; // 0 right edge fuori, 1 right edge dentro, 2 met� e met�
|
||||
bool m_bOnLeftEdge ; // flag che indica se la cella � sul lato sinistro ( per superfici chiuse sul parametro U)
|
||||
bool m_bOnTopEdge ; // flag che indica se la cella � sul lato top ( per superfici chiuse sul parametro V)
|
||||
std::vector<Inters> m_vInters ; // vettore delle intersezioni della cella con i loop di trim
|
||||
// ogni elemento del vettore � l'insieme dei punti che caratterizza un atrtaversamento della cella
|
||||
|
||||
private :
|
||||
Point3d m_ptPbl ; // punto bottom left
|
||||
Point3d m_ptPtr ; // punto top right
|
||||
bool m_bProcessed ; // flag che indica se la cella � stata processata
|
||||
bool m_bSplitVert ; // flag che indica in quale direzione � stata divisa la cella
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class Tree
|
||||
{
|
||||
public :
|
||||
~Tree( void) ;
|
||||
Tree( void) ;
|
||||
Tree ( const SurfBezier* pSrfBz, bool bSplitPatches = true, const Point3d& ptMin = ORIG, const Point3d& ptMax = ORIG) ;
|
||||
void SetSurf( const SurfBezier* pSrfBz, bool bSplitPatches = true, const Point3d& ptMin = ORIG, const Point3d& ptMax = ORIG) ;
|
||||
bool GetIndependentTrees( BIPNTVECTOR& vTrees) ; // calcolo la suddivisione della superficie solo sulle singole bbox dei loop di trim ( unendo quelli vicini)
|
||||
bool BuildTree( double dLinTol = LIN_TOL_STD, double dSideMin = 1, double dSideMax = INFINITO) ; // dSideMax � il massimo per la dimensione maggiore di un triangolo della trimesh
|
||||
// dSideMin � lunghezza minima del lato di una cella nello spazio reale
|
||||
bool BuildTree_test( double dLinTol = LIN_TOL_STD, double dSideMin = 1, double dSideMax = INFINITO) ;
|
||||
bool GetPolygons( POLYLINEMATRIX& vPolygons) ;
|
||||
bool GetPolygonsBasic( POLYLINEVECTOR& vPolygons) ; // restituisce il poligono corrispondente ad ogni cella foglia dell'albero
|
||||
// ad ogni poligono sono stati aggiunti tutti i vertici dei vicini posizionati sui suoi lati
|
||||
bool GetLeaves ( std::vector<Cell>& vLeaves) const ;
|
||||
void SetTestMode( void) { m_bTestMode = true ;} ;
|
||||
|
||||
private :
|
||||
bool Split( int nId, double dSplitValue) ; // funzione di split di una cella al parametro indicato nella direzione data da bVert
|
||||
bool Split( int nId) ; // funzione di split di una cella dell'albero a met� nella direzione data da bVert
|
||||
void Balance( void) ; // creo rami in modo che tutte tutte le foglie abbiano come adiacenti foglie ad una profondit� di +- 1
|
||||
int GetHeightLeaves( int nId, INTVECTOR& vnLeaves, int d = 0) const ; // altezza del subtree a partire dal nodo nId
|
||||
int GetDepth( int nId, int nRef) const ; // livello del nodo nId
|
||||
void GetTopNeigh( int nId, INTVECTOR& vTopNeighs) const ; // restituisce le celle foglie che sono adiacenti al lato top
|
||||
void GetBottomNeigh( int nId, INTVECTOR& vBottomNeighs) const ; // restituisce le celle foglie che sono adiacenti al lato bottom
|
||||
void GetLeftNeigh( int nId, INTVECTOR& vLeftNeighs) const ; // restituisce le celle foglie che sono adiacenti al lato left
|
||||
void GetRightNeigh( int nId, INTVECTOR& vRightNeighs) const ; // restituisce le celle foglie che sono adiacenti al lato right
|
||||
void GetRootNeigh( int nEdge, INTVECTOR& vNeigh) ; // restituisce le foglie dell'albero che sono adiacenti al lato nEdge, numerato a partire dal top ( 0) in senso antiorario
|
||||
void ResetTree( void) ; // resetto m_bProcessed a false per tutti i nodi dell'albero
|
||||
INTVECTOR FindCell( const Point3d& ptToAssign, const CurveLine& cl, bool bRecurs = false) const ; // dato un punto, trova la cella foglia a cui appartiene
|
||||
INTVECTOR FindCell( const Point3d& ptToAssign, const CurveLine& cl, INTVECTOR vCells, bool bRecurs = false) const ; // dato un punto, trova la cella foglia a cui appartiene
|
||||
bool TraceLoopLabelCell( const POLYLINEVECTOR& vplPolygons) ; // tracing dei loop e labelling delle celle
|
||||
bool FindInters( int& nId, const CurveLine& clTrim, PNTVECTOR& vptInters, bool bFirstInters = true) ; // trova le intersezioni tra una cella e una linea di trim
|
||||
// resituisce l'id della cella verso cui la curva di trim esce e il vettore delle intersezioni per la cella successiva con il primo punto
|
||||
bool CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, INTVECTOR& vToCheck, int& nPoly, INTVECTOR& vnParentChunk, const PolyLine& plCell) ;
|
||||
bool CreateIslandAndHoles( int nLeafId, POLYLINEMATRIX& vPolygons, int& nPoly, INTVECTOR& vnParentChunk) ;
|
||||
bool CheckIfBefore( const PolyLine& pl, int nEdge) const ;
|
||||
bool CheckIfBefore( const Inters& inA) const ;
|
||||
bool CheckIfBefore( int nEdge1, const Point3d& ptP1, int nEdge2, const Point3d& ptP2) const ; // punto 1 su edge 1 e punto 2 su edge 2, rispetto al lato 3
|
||||
bool CheckIfBefore( int nEdge, const Point3d& ptP1, const Point3d& ptP2, int nEdge2 = -1) const ; // entrambi i punti sullo stesso lato, nEdge. nEdge2 serve come backup, in caso nEdge sia un vertice.
|
||||
bool AreSameEdge( int nEdge1, int nEdge2) const ;
|
||||
bool AddVertex( int nId, const PNTMATRIX& vEdgeVertex, PolyLine& plTrimmedPoly, int& c, const Point3d& ptToAdd) const ;
|
||||
bool SetRightEdgeIn( int nId) ;
|
||||
bool CategorizeCell( int nId) ;
|
||||
bool CheckIfBetween( const Inters& inA, const Inters& inB) const ;
|
||||
bool OnWhichEdge( int nId, const Point3d& ptToAssign, int& nEdge) const ;
|
||||
|
||||
private :
|
||||
const SurfBezier* m_pSrfBz ; // superficie di bezier
|
||||
DBLVECTOR m_vDim ; // distanze tra i vertici della superficie di bezier in 3d in ordine antiorario a partire da ptP00
|
||||
bool m_bTrimmed ; // superficie trimmata
|
||||
INTMATRIX m_vChunk ; // elenco dei loop divisi per chunk
|
||||
std::map<int,int> m_mChunk ;
|
||||
ICURVEPOVECTOR m_vLoop ; // curve di loop
|
||||
std::vector<std::tuple<PolyLine,bool>> m_vPlApprox ;
|
||||
bool m_bBilinear ; // superficie bilineare
|
||||
bool m_bMulti ; // superficie multi-patch
|
||||
bool m_bClosedU ; // superficie chiusa lungo il parametro U
|
||||
bool m_bClosedV ; // superficie chiusa lungo il parametro V
|
||||
bool m_bSplitPatches ; // flag che indica se le patches sono state divise prima della creazione dell'albero
|
||||
int m_nDegU ; // grado della superficie nel parametro U
|
||||
int m_nDegV ; // grado della superficie nel parametro V
|
||||
int m_nSpanU ;
|
||||
int m_nSpanV ;
|
||||
POLYLINEMATRIX m_vPolygons ; // matrice dei poligoni del tree
|
||||
std::map<int,Cell> m_mTree ; // mappa che contiene tutti i nodi e le foglie dell'albero. -2 � puntatore Null e -1 � root
|
||||
std::map<int,PNTVECTOR> m_mVert ; // mappa che contiene tutti i vertici 3d delle celle del tree. L'Id � lo stesso che la cella ha in m_mTree
|
||||
INTVECTOR m_vnLeaves ; // vettore delle foglie
|
||||
INTVECTOR m_vnParents ; // vettore delle celle ottenute dalla divisione preliminare in singole patch
|
||||
bool m_bTestMode ; // bool che indica se la test mode è attiva
|
||||
} ;
|
||||
+12
-5
@@ -34,7 +34,7 @@ GEOOBJ_REGISTER( VOL_ZMAP, NGE_V_ZMP, VolZmap) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
VolZmap::VolZmap(void)
|
||||
: m_nStatus( TO_VERIFY), m_dStep( 10.0), m_nMapNum( 0), m_nShape( GENERIC), m_nVoxNumPerBlock( N_VOXBLOCK),
|
||||
: m_nStatus( TO_VERIFY), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}, m_dStep( 10.0), m_nMapNum( 0), m_nShape( GENERIC), m_nVoxNumPerBlock( N_VOXBLOCK),
|
||||
m_nDexVoxRatio( 1), m_nNumBlock( 0), m_nConnectedCompoCount( 0), m_nCurrTool( -1),
|
||||
m_dToolLinTol( LIN_TOL_STD), m_dToolAngTolDeg( ANG_TOL_APPROX_DEG)
|
||||
{
|
||||
@@ -46,8 +46,6 @@ VolZmap::VolZmap(void)
|
||||
m_dMaxZ[i] = 0 ;
|
||||
m_nFracLin[i] = 0 ;
|
||||
}
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
m_vTool.resize( 1) ;
|
||||
m_nCurrTool = 0 ;
|
||||
}
|
||||
@@ -78,6 +76,8 @@ VolZmap::Clear( void)
|
||||
m_dStep = EPS_SMALL ;
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
m_dTempParam[0] = 0.0 ;
|
||||
m_dTempParam[1] = 0.0 ;
|
||||
m_vTool.resize( 1) ;
|
||||
m_nCurrTool = 0 ;
|
||||
m_dToolLinTol = LIN_TOL_STD ;
|
||||
@@ -148,6 +148,8 @@ VolZmap::CopyFrom( const VolZmap& vzmSrc)
|
||||
m_nStatus = vzmSrc.m_nStatus ;
|
||||
m_nTempProp[0] = vzmSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = vzmSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = vzmSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = vzmSrc.m_dTempParam[1] ;
|
||||
|
||||
// dimensiono membri legati ai blocchi
|
||||
m_BlockToUpdate = vzmSrc.m_BlockToUpdate ;
|
||||
@@ -208,7 +210,7 @@ VolZmap::Dump( string& sOut, bool bMM, const char* szNewLine) const
|
||||
}
|
||||
sOut += szNewLine ;
|
||||
// passo
|
||||
sOut += "Step=" + ToString( GetInUiUnits( m_dStep, bMM), 3) + szNewLine ;
|
||||
sOut += "Step=" + ToString( GetInUiUnits( m_dStep, bMM), 6) + szNewLine ;
|
||||
// dimensioni
|
||||
if ( m_nMapNum == 1)
|
||||
sOut += "Dim=" + ToString( m_nDim[0]) +
|
||||
@@ -1984,6 +1986,11 @@ VolZmap::CalcBlockNum( void)
|
||||
if ( m_nMapNum == 1) {
|
||||
m_nFracLin[2] = 1 ;
|
||||
m_nNumBlock = m_nFracLin[0] * m_nFracLin[1] * m_nFracLin[2] ;
|
||||
m_BlockToUpdate.clear() ;
|
||||
m_BlockToUpdate.resize( m_nNumBlock, true) ;
|
||||
m_BlockUpdatingCounter.clear() ;
|
||||
m_BlockUpdatingCounter.resize( m_nNumBlock, 0) ;
|
||||
m_SingleMapTria.resize( m_nNumBlock) ;
|
||||
return true ;
|
||||
}
|
||||
// Calcolo il numero di voxel lungo Z
|
||||
@@ -1995,7 +2002,7 @@ VolZmap::CalcBlockNum( void)
|
||||
m_BlockToUpdate.clear() ;
|
||||
m_BlockToUpdate.resize( m_nNumBlock, true) ;
|
||||
m_BlockUpdatingCounter.clear() ;
|
||||
m_BlockUpdatingCounter.resize( m_nNumBlock + ( m_nMapNum == 1 ? 0 : 1), 0) ;
|
||||
m_BlockUpdatingCounter.resize( m_nNumBlock + 1, 0) ;
|
||||
|
||||
// Dimensiono raccolta di voxel, triangoli di feature tra blocchi e di segnalatori di materiale fra voxel
|
||||
m_InterBlockVox.resize( m_nNumBlock) ;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2020
|
||||
// EgalTech 2015-2023
|
||||
//----------------------------------------------------------------------------
|
||||
// File : VolZmap.h Data : 12.05.19 Versione : 2.2k1
|
||||
// File : VolZmap.h Data : 12.09.23 Versione : 2.5i1
|
||||
// Contenuto : Dichiarazione della classe Volume Zmap.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 22.01.15 DS Creazione modulo.
|
||||
//
|
||||
// 12.09.23 DS Aggiunto metodo IsTriDexel.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -65,6 +65,11 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // IVolZmap
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -77,6 +82,8 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
bool GetBlockTriangles( int nBlock, TRIA3DEXVECTOR& vTria) const override ;
|
||||
bool GetEdges( ICURVEPOVECTOR& vpCurve) const override ;
|
||||
bool GetVolume( double& dVol) const override ;
|
||||
bool IsTriDexel( void) const override
|
||||
{ return m_nMapNum == 3 ; }
|
||||
bool GetDexelLines( int nDir, int nPos1, int nPos2, POLYLINELIST& lstPL) const override ;
|
||||
int GetResolution( void) const override
|
||||
{ return m_nDexVoxRatio ; }
|
||||
@@ -408,6 +415,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
double m_dStep ; // passo delle griglie
|
||||
int m_nMapNum ; // numero di griglie ( 1 o 3)
|
||||
Frame3d m_MapFrame ; // riferimento intrinseco dello Zmap
|
||||
|
||||
+10
-7
@@ -1930,9 +1930,12 @@ VolZmap::AvoidSurfTm( const ISurfTriMesh& tmSurf, double dSafeDist, bool bPrecis
|
||||
}
|
||||
// Intersezione della linea con triangolo eventualmente offsettato
|
||||
Point3d ptInt, ptInt2 ;
|
||||
if ( IntersLineTria( ptT, vtK, 1, trNewTria, ptInt, ptInt2, false) != IntLineTriaType::ILTT_NO) {
|
||||
int nIntLnTr = IntersLineTria( ptT, vtK, 1, trNewTria, ptInt, ptInt2, false) ;
|
||||
if ( nIntLnTr != ILTT_NO) {
|
||||
double dZmin = ( ptInt - ptT) * vtK ;
|
||||
double dZmax = ( ptInt2 - ptT) * vtK ;
|
||||
double dZmax = dZmin ;
|
||||
if ( nIntLnTr == ILTT_SEGM || nIntLnTr == ILTT_SEGM_ON_EDGE)
|
||||
dZmax = ( ptInt2 - ptT) * vtK ;
|
||||
for ( int nIndex = 0 ; nIndex < nSize ; nIndex += 1) {
|
||||
if ( dZmax > m_Values[0][nPos][nIndex].dMin - EPS_SMALL &&
|
||||
dZmin < m_Values[0][nPos][nIndex].dMax + EPS_SMALL)
|
||||
@@ -2068,14 +2071,14 @@ VolZmap::IntersLineCylinder( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
int nBasInt = 0 ;
|
||||
if ( abs( vtV.z) > EPS_ZERO) {
|
||||
// le linee tangenti al cilindro non sono considerate intersecanti
|
||||
double EpsRad = ( vtV.IsZeroXY() ? - EPS_SMALL : EPS_SMALL) ;
|
||||
double dEpsRad = ( vtV.IsZeroXY() ? - EPS_SMALL : EPS_SMALL) ;
|
||||
ptInt1 = ptP + ( ( 0 - ptP.z) / vtV.z) * vtV ;
|
||||
if ( ptInt1.x * ptInt1.x + ptInt1.y * ptInt1.y < dRad * dRad + 2 * dRad * EpsRad) {
|
||||
if ( ptInt1.x * ptInt1.x + ptInt1.y * ptInt1.y < dRad * dRad + 2 * dRad * dEpsRad) {
|
||||
nBasInt += 1 ;
|
||||
vtN1 = Z_AX ;
|
||||
}
|
||||
ptInt2 = ptP + ( ( dH - ptP.z) / vtV.z) * vtV ;
|
||||
if ( ptInt2.x * ptInt2.x + ptInt2.y * ptInt2.y < dRad * dRad + 2 * dRad * EpsRad) {
|
||||
if ( ptInt2.x * ptInt2.x + ptInt2.y * ptInt2.y < dRad * dRad + 2 * dRad * dEpsRad) {
|
||||
nBasInt += 2 ;
|
||||
vtN2 = - Z_AX ;
|
||||
}
|
||||
@@ -2196,12 +2199,12 @@ VolZmap::IntersLineConus( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
// Determino le eventuali intersezioni con le due basi a quota minima e massima (solo se linea non parallela ad esse)
|
||||
int nBasInt = 0 ;
|
||||
if ( abs( vtV.z) > EPS_ZERO) {
|
||||
ptInt1 = ptP + ( ( dMinH - ptP.z) / vtV.z) * vtV ;
|
||||
ptInt1 = ptP + ( ( dMinH + dEpsLow - ptP.z) / vtV.z) * vtV ;
|
||||
if ( ptInt1.x * ptInt1.x + ptInt1.y * ptInt1.y < dMinRad * dMinRad + 2 * dMinRad * dTan * dEpsLow) {
|
||||
nBasInt += 1 ;
|
||||
vtN1 = Z_AX ;
|
||||
}
|
||||
ptInt2 = ptP + ( ( dMaxH - ptP.z) / vtV.z) * vtV ;
|
||||
ptInt2 = ptP + ( ( dMaxH + dEpsUp - ptP.z) / vtV.z) * vtV ;
|
||||
if ( ptInt2.x * ptInt2.x + ptInt2.y * ptInt2.y < dMaxRad * dMaxRad + 2 * dMaxRad * dTan * dEpsUp) {
|
||||
nBasInt += 2 ;
|
||||
vtN2 = - Z_AX ;
|
||||
|
||||
+6
-2
@@ -4569,6 +4569,10 @@ VolZmap::Remove( FlatVoxelContainer& VoxCont, int nI, int nJ, int nK) const
|
||||
bool
|
||||
VolZmap::GetEdges( ICURVEPOVECTOR& vpCurve) const
|
||||
{
|
||||
// Se mappa singola, non calcolabili
|
||||
if ( m_nMapNum == 1)
|
||||
return false ;
|
||||
|
||||
// Garantisco grafica aggiornata
|
||||
UpdateTripleMapGraphics() ;
|
||||
|
||||
@@ -4666,7 +4670,7 @@ VolZmap::GetEdges( ICURVEPOVECTOR& vpCurve) const
|
||||
INTVECTOR vId ;
|
||||
while ( chainC.GetChainFromNear( ptNear, true, vId)) {
|
||||
// creo una curva composita
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo))
|
||||
return false ;
|
||||
// recupero gli estremi dei segmenti, creo le linee e le inserisco nella composita
|
||||
@@ -4674,7 +4678,7 @@ VolZmap::GetEdges( ICURVEPOVECTOR& vpCurve) const
|
||||
// creo un segmento di retta
|
||||
int nInd = abs( vId[i]) - 1 ;
|
||||
bool bInvert = ( vId[i] < 0) ;
|
||||
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
|
||||
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pLine) || ! pLine->Set( vBpt[nInd].first, vBpt[nInd].second))
|
||||
continue ;
|
||||
if ( bInvert)
|
||||
|
||||
+317
-314
@@ -18,8 +18,8 @@
|
||||
#include "CurveArc.h"
|
||||
#include "VolZmap.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EgtPerfCounter.h"
|
||||
#include <future>
|
||||
|
||||
@@ -501,9 +501,9 @@ VolZmap::MillingStep( int nCurrTool,
|
||||
m_nCurrTool = nCurrTool ;
|
||||
Tool& CurrTool = m_vTool[m_nCurrTool] ;
|
||||
|
||||
// Se non è definito l'utensile, non devo fare alcunchè
|
||||
// Se non è definito l'utensile, non posso fare alcunchè
|
||||
if ( CurrTool.GetType() == Tool::UNDEF)
|
||||
return true ;
|
||||
return false ;
|
||||
// Controllo definizione vettori direzione
|
||||
if ( vtDs.IsSmall() || vtDe.IsSmall())
|
||||
return false ;
|
||||
@@ -520,21 +520,15 @@ VolZmap::MillingStep( int nCurrTool,
|
||||
m_nConnectedCompoCount = - 1 ;
|
||||
|
||||
// Punti e vettori descriventi il moto nel sistema intrinseco dello Zmap
|
||||
Point3d ptPLs = ptPs ;
|
||||
ptPLs.ToLoc( m_MapFrame) ;
|
||||
Point3d ptPLe = ptPe ;
|
||||
ptPLe.ToLoc( m_MapFrame) ;
|
||||
Vector3d vtDLs = vtDs ;
|
||||
vtDLs.ToLoc( m_MapFrame) ;
|
||||
Point3d ptPLs = GetToLoc( ptPs, m_MapFrame) ;
|
||||
Point3d ptPLe = GetToLoc( ptPe, m_MapFrame) ;
|
||||
Vector3d vtDLs = GetToLoc( vtDs, m_MapFrame) ;
|
||||
vtDLs.Normalize() ;
|
||||
Vector3d vtDLe = vtDe ;
|
||||
vtDLe.ToLoc( m_MapFrame) ;
|
||||
Vector3d vtDLe = GetToLoc( vtDe, m_MapFrame) ;
|
||||
vtDLe.Normalize() ;
|
||||
Vector3d vtALs = vtAs ;
|
||||
vtALs.ToLoc( m_MapFrame) ;
|
||||
Vector3d vtALs = GetToLoc( vtAs, m_MapFrame) ;
|
||||
vtALs.Normalize() ;
|
||||
Vector3d vtALe = vtAe ;
|
||||
vtALe.ToLoc( m_MapFrame) ;
|
||||
Vector3d vtALe = GetToLoc( vtAe, m_MapFrame) ;
|
||||
vtALe.Normalize() ;
|
||||
|
||||
//static PerformanceCounter Counter ;
|
||||
@@ -566,7 +560,7 @@ VolZmap::MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, co
|
||||
const Point3d& ptPe, const Vector3d& vtDe, const Vector3d& vtAe)
|
||||
{
|
||||
// Divido il movimento in tratti con direzione utensile costante
|
||||
const double ANG_STEP = 0.5 ;
|
||||
const double ANG_STEP = 0.02 ;
|
||||
double dAngDeg ; vtDs.GetAngle( vtDe, dAngDeg) ;
|
||||
int nStepCnt = int( abs( dAngDeg) / ANG_STEP) + 1 ;
|
||||
bool bOk = true ;
|
||||
@@ -600,7 +594,15 @@ VolZmap::MillingTranslationStep( const Point3d& ptPs, const Point3d& ptPe, const
|
||||
Vector3d vtLs[N_MAPS] ;
|
||||
Vector3d vtALs[N_MAPS] ;
|
||||
InitializePointsAndVectors( ptPs, ptPe, vtD, vtA, ptLs, ptLe, vtLs, vtALs) ;
|
||||
// Ciclo sulle mappe
|
||||
// Ciclo sulle mappe (scommentare solo per DEBUG)
|
||||
//{
|
||||
// bool bOk = true ;
|
||||
// for ( int i = 0 ; i < m_nMapNum ; ++ i) {
|
||||
// bOk = SelectMotion( i, ptLs[i], ptLe[i], vtLs[i], vtALs[i]) && bOk ;
|
||||
// }
|
||||
// return true ;
|
||||
//}
|
||||
// Ciclo sulle mappe
|
||||
vector< future<bool>> vRes ;
|
||||
vRes.resize( m_nMapNum) ;
|
||||
for ( int i = 0 ; i < m_nMapNum ; ++ i) {
|
||||
@@ -616,7 +618,7 @@ VolZmap::MillingTranslationStep( const Point3d& ptPs, const Point3d& ptPe, const
|
||||
}
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -669,21 +671,16 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons
|
||||
if ( vtMove.SqLenXY() < EPS_SMALL * EPS_SMALL) {
|
||||
switch ( CurrTool.GetType()) {
|
||||
case Tool::GEN :
|
||||
GenTool_ZDrilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return GenTool_ZDrilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::CYLMILL :
|
||||
case Tool::BALLMILL :
|
||||
CylBall_ZDrilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return CylBall_ZDrilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::CONEMILL :
|
||||
Conus_ZDrilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return Conus_ZDrilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::MORTISER :
|
||||
Mrt_ZDrilling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
break ;
|
||||
return Mrt_ZDrilling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
case Tool::CHISEL :
|
||||
Chs_ZDrilling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
break ;
|
||||
return Chs_ZDrilling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -691,21 +688,16 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons
|
||||
else if ( abs( vtMove.z) < EPS_SMALL) {
|
||||
switch ( CurrTool.GetType()) {
|
||||
case Tool::GEN :
|
||||
GenTool_ZMilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return GenTool_ZMilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::CYLMILL :
|
||||
case Tool::BALLMILL :
|
||||
CylBall_ZPerp( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return CylBall_ZPerp( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::CONEMILL :
|
||||
Conus_ZPerp( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return Conus_ZPerp( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::MORTISER :
|
||||
Mrt_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
break ;
|
||||
return Mrt_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
case Tool::CHISEL :
|
||||
Chs_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
break ;
|
||||
return Chs_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -713,18 +705,14 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons
|
||||
else {
|
||||
switch ( CurrTool.GetType()) {
|
||||
case Tool::GEN :
|
||||
GenTool_ZMilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return GenTool_ZMilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::CYLMILL :
|
||||
case Tool::BALLMILL :
|
||||
CylBall_ZMilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return CylBall_ZMilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::CONEMILL :
|
||||
Conus_ZMilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return Conus_ZMilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::MORTISER :
|
||||
Mrt_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
break ;
|
||||
return Mrt_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -743,62 +731,48 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons
|
||||
if ( dSqLOrt < EPS_SMALL * EPS_SMALL) {
|
||||
switch ( CurrTool.GetType()) {
|
||||
case Tool::GEN :
|
||||
GenTool_Drilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return GenTool_Drilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::CYLMILL :
|
||||
case Tool::BALLMILL :
|
||||
CylBall_XYDrilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return CylBall_XYDrilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::CONEMILL :
|
||||
Conus_XYDrilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return Conus_XYDrilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::MORTISER :
|
||||
Mrt_Drilling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
break ;
|
||||
return Mrt_Drilling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
case Tool::CHISEL :
|
||||
Chs_Drilling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
break ;
|
||||
return Chs_Drilling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
}
|
||||
}
|
||||
// Fresatura con vettore movimento perpendicolare all'utensile
|
||||
else if ( dSqLLong < EPS_SMALL * EPS_SMALL) {
|
||||
switch ( CurrTool.GetType()) {
|
||||
case Tool::GEN :
|
||||
GenTool_Milling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return GenTool_Milling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::CYLMILL :
|
||||
case Tool::BALLMILL :
|
||||
CylBall_XYPerp( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return CylBall_XYPerp( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::CONEMILL :
|
||||
// Usiamo la generica per via dell'intsabilità di Conus_XYPerp
|
||||
//Conus_XYPerp( i, ptLs[i], ptLe[i], vtLs[i]) ;
|
||||
Conus_Milling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
//return Conus_XYPerp( i, ptLs[i], ptLe[i], vtLs[i]) ;
|
||||
return Conus_Milling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::MORTISER :
|
||||
Mrt_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
break ;
|
||||
return Mrt_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
case Tool::CHISEL :
|
||||
Chs_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
break ;
|
||||
return Chs_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
}
|
||||
}
|
||||
// Fresatura con vettore movimento generico rispetto all'utensile
|
||||
else {
|
||||
switch ( CurrTool.GetType()) {
|
||||
case Tool::GEN :
|
||||
GenTool_Milling( nGrid, ptLs, ptLe, vtL);
|
||||
break ;
|
||||
return GenTool_Milling( nGrid, ptLs, ptLe, vtL);
|
||||
case Tool::CYLMILL :
|
||||
case Tool::BALLMILL :
|
||||
CylBall_XYMilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return CylBall_XYMilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::CONEMILL :
|
||||
Conus_XYMilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return Conus_XYMilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::MORTISER :
|
||||
Mrt_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
break ;
|
||||
return Mrt_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -816,48 +790,39 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons
|
||||
if ( dSqLOrt < EPS_SMALL * EPS_SMALL) {
|
||||
switch ( CurrTool.GetType()) {
|
||||
case Tool::GEN :
|
||||
GenTool_Drilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return GenTool_Drilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::CYLMILL :
|
||||
case Tool::BALLMILL :
|
||||
CylBall_Drilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return CylBall_Drilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::CONEMILL :
|
||||
Conus_Drilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return Conus_Drilling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::MORTISER :
|
||||
Mrt_Drilling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
break ;
|
||||
return Mrt_Drilling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
case Tool::CHISEL :
|
||||
Chs_Drilling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
break ;
|
||||
return Chs_Drilling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
}
|
||||
}
|
||||
// Fresatura con vettore movimento generico rispetto all'utensile
|
||||
else {
|
||||
switch ( CurrTool.GetType()) {
|
||||
case Tool::GEN :
|
||||
GenTool_Milling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return GenTool_Milling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::CYLMILL :
|
||||
case Tool::BALLMILL :
|
||||
CylBall_Milling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return CylBall_Milling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::CONEMILL :
|
||||
Conus_Milling( nGrid, ptLs, ptLe, vtL) ;
|
||||
break ;
|
||||
return Conus_Milling( nGrid, ptLs, ptLe, vtL) ;
|
||||
case Tool::MORTISER :
|
||||
Mrt_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
break ;
|
||||
return Mrt_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
case Tool::CHISEL :
|
||||
// ammesso solo movimento perpendicolare all'asse utensile
|
||||
if ( dSqLLong < EPS_SMALL * EPS_SMALL)
|
||||
Chs_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
return Chs_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
@@ -3222,13 +3187,13 @@ VolZmap::GenTool_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, con
|
||||
const ICurveLine* pLine = GetCurveLine( pCurve) ;
|
||||
Point3d ptStart = pLine->GetStart() ;
|
||||
Point3d ptEnd = pLine->GetEnd() ;
|
||||
int nNormNum = pLine->GetTempProp();
|
||||
Vector3d vtNormSt, vtNormEn;
|
||||
int nNormNum = pLine->GetTempProp() ;
|
||||
Vector3d vtNormSt, vtNormEn ;
|
||||
if ( nNormNum != 0) {
|
||||
vtNormSt = vArcNorm[nNormNum - 1] ;
|
||||
vtNormEn = vArcNorm[nNormNum] ;
|
||||
vtNormSt.ToLoc(frNormFrame);
|
||||
vtNormEn.ToLoc(frNormFrame);
|
||||
vtNormSt.ToLoc( frNormFrame) ;
|
||||
vtNormEn.ToLoc( frNormFrame) ;
|
||||
}
|
||||
// Ne determino l'altezza
|
||||
dHeight = abs( ptStart.y - ptEnd.y) ;
|
||||
@@ -3243,7 +3208,7 @@ VolZmap::GenTool_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, con
|
||||
bTapT = false ;
|
||||
}
|
||||
// verifiche curva successiva per eventuale tappo sotto
|
||||
bool bTapB = false ;
|
||||
bool bTapB = true ;
|
||||
const ICurve* pNextCurve = ToolProfile.GetCurve( ++ i) ;
|
||||
if ( pNextCurve != nullptr && pNextCurve->GetType() == CRV_LINE) {
|
||||
const ICurveLine* pOthLine = GetCurveLine( pNextCurve) ;
|
||||
@@ -3258,21 +3223,21 @@ VolZmap::GenTool_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, con
|
||||
if ( dRadius > 10 * EPS_SMALL)
|
||||
CompCyl_Milling( nGrid, ptI, ptF, vtToolDir, dHeight, dRadius, bTapB, bTapT, CurrTool.GetToolNum()) ;
|
||||
}
|
||||
// Se X crescente, è un cono con vettore equiverso a quello dell'utensile
|
||||
// se altrimenti X decrescente, è un cono con vettore equiverso a quello dell'utensile
|
||||
else if ( ptStart.x > ptEnd.x) {
|
||||
double dMaxRad = ptStart.x ;
|
||||
double dMinRad = ptEnd.x ;
|
||||
CompConus_Milling( nGrid, ptI, ptF, vtToolDir, dHeight, dMaxRad, dMinRad,
|
||||
bTapB, bTapT, vtNormSt, vtNormEn, CurrTool.GetToolNum()) ;
|
||||
}
|
||||
// Se X decrescente, è un cono con vettore opposto a quello dell'utensile
|
||||
else if ( ptStart.x < ptEnd.x) {
|
||||
// altrimenti X crescente, è un cono con vettore opposto a quello dell'utensile
|
||||
else {
|
||||
double dMaxRad = ptEnd.x ;
|
||||
double dMinRad = ptStart.x ;
|
||||
Point3d ptIn = ptI - vtToolDir * dHeight ;
|
||||
Point3d ptFn = ptIn + vtMove ;
|
||||
vtNormEn.z *= -1 ;
|
||||
vtNormSt.z *= -1 ;
|
||||
vtNormEn.z = -vtNormEn.z ;
|
||||
vtNormSt.z = -vtNormSt.z ;
|
||||
CompConus_Milling( nGrid, ptIn, ptFn, - vtToolDir, dHeight, dMaxRad, dMinRad,
|
||||
bTapT, bTapB, vtNormEn, vtNormSt, CurrTool.GetToolNum()) ;
|
||||
}
|
||||
@@ -4287,7 +4252,23 @@ VolZmap::CompCyl_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE,
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static Vector3d
|
||||
AdjustConeNormal( const Point3d& ptInt, const Vector3d& vtN, const Point3d& ptV, const Vector3d& vtToolDir,
|
||||
double dMinRad, double dDeltaR, const Vector3d& vtArcNormMinR, const Vector3d& vtArcNormMaxR)
|
||||
{
|
||||
if ( AreSameOrOppositeVectorEpsilon( vtN, vtToolDir, 0.1 * EPS_SMALL))
|
||||
return vtN ;
|
||||
Vector3d vtL = ( ptInt - ptV) - (( ptInt - ptV) * vtToolDir) * vtToolDir ;
|
||||
double dL = vtL.Len() ;
|
||||
vtL /= dL ;
|
||||
Vector3d vtOriginalN = ( ( dDeltaR - dL + dMinRad) / dDeltaR) * vtArcNormMinR + ((dL - dMinRad) / dDeltaR) * vtArcNormMaxR ;
|
||||
Vector3d vtNewN = - vtOriginalN.z * vtToolDir - vtOriginalN.x * vtL ;
|
||||
vtNewN.Normalize() ;
|
||||
return vtNewN ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::CompConus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir,
|
||||
@@ -4303,8 +4284,10 @@ VolZmap::CompConus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
double dDeltaR = dMaxRad - dMinRad ;
|
||||
|
||||
// Studio simmetrie
|
||||
Point3d ptI = ( vtToolDir * ( ptE - ptS) > 0 ? ptS : ptE) ;
|
||||
Point3d ptF = ( vtToolDir * ( ptE - ptS) > 0 ? ptE : ptS) ;
|
||||
Point3d ptI = ptS ;
|
||||
Point3d ptF = ptE ;
|
||||
if ( vtToolDir * ( ptE - ptS) <= 0)
|
||||
swap( ptI, ptF) ;
|
||||
|
||||
double dL = ( dMaxRad * dHei) / dDeltaR ;
|
||||
double dl = dL - dHei ;
|
||||
@@ -4366,7 +4349,8 @@ VolZmap::CompConus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
Point3d ptFacet135( 0, 0, dLenZ) ;
|
||||
Point3d ptFacet246( dLenX + dDeltaX, dLenY + dDeltaY, - dLenZ - dDeltaZ) ;
|
||||
|
||||
Vector3d vtUmv = vtMove ; vtUmv.Normalize() ;
|
||||
// Necessità ricalcolo normali (perchè variabili per approx curve)
|
||||
bool bRecalNorm = ( ! vtArcNormMaxR.IsSmall() && ! vtArcNormMinR.IsSmall()) ;
|
||||
|
||||
if ( dRatio * dTan <= 1) {
|
||||
|
||||
@@ -4381,219 +4365,256 @@ VolZmap::CompConus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
// Cono iniziale
|
||||
ConusFrame.ChangeOrig( ptV) ;
|
||||
if ( IntersLineConus( ptC, Z_AX, ConusFrame, dTan, dl, dL, bTapB, bTapT, ptInt1, vtN1, ptInt2, vtN2)) {
|
||||
if ( ! ( vtArcNormMaxR.IsSmall() || vtArcNormMinR.IsSmall())) {
|
||||
if ( ! AreSameOrOppositeVectorEpsilon( vtN1, vtToolDir, 0.1 * EPS_SMALL)) {
|
||||
Vector3d vtL1 = ptInt1 - ptV ;
|
||||
vtL1 -= ( vtL1 * vtToolDir) * vtToolDir ;
|
||||
double dL1 = vtL1.Len() ;
|
||||
vtL1 /= dL1 ;
|
||||
Vector3d vtOriginalN1 = ( ( dDeltaR - dL1 + dMinRad) / dDeltaR) * vtArcNormMinR + ((dL1 - dMinRad) / dDeltaR) * vtArcNormMaxR;
|
||||
vtOriginalN1.Normalize() ;
|
||||
vtN1 = - vtOriginalN1.z * vtToolDir - vtOriginalN1.x * vtL1 ;
|
||||
vtN1.Normalize() ;
|
||||
}
|
||||
if ( ! AreSameOrOppositeVectorEpsilon( vtN2, vtToolDir, 0.1 * EPS_SMALL)) {
|
||||
Vector3d vtL2 = ptInt2 - ptV ;
|
||||
vtL2 -= ( vtL2 * vtToolDir) * vtToolDir ;
|
||||
double dL2 = vtL2.Len() ;
|
||||
vtL2 /= dL2 ;
|
||||
Vector3d vtOriginalN2 = ( ( dDeltaR - dL2 + dMinRad) / dDeltaR) * vtArcNormMinR + ( ( dL2 - dMinRad) / dDeltaR) * vtArcNormMaxR ;
|
||||
vtOriginalN2.Normalize() ;
|
||||
vtN2 = - vtOriginalN2.z * vtToolDir - vtOriginalN2.x * vtL2 ;
|
||||
vtN2.Normalize() ;
|
||||
}
|
||||
if ( bRecalNorm) {
|
||||
vtN1 = AdjustConeNormal( ptInt1, vtN1, ptV, vtToolDir, dMinRad, dDeltaR, vtArcNormMinR, vtArcNormMaxR) ;
|
||||
vtN2 = AdjustConeNormal( ptInt2, vtN2, ptV, vtToolDir, dMinRad, dDeltaR, vtArcNormMinR, vtArcNormMaxR) ;
|
||||
}
|
||||
SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ;
|
||||
}
|
||||
|
||||
|
||||
// Cono finale
|
||||
ConusFrame.ChangeOrig( ptV + vtMove) ;
|
||||
if ( IntersLineConus( ptC, Z_AX, ConusFrame, dTan, dl, dL, bTapB, bTapT, ptInt1, vtN1, ptInt2, vtN2)) {
|
||||
if ( ! ( vtArcNormMaxR.IsSmall() || vtArcNormMinR.IsSmall())) {
|
||||
if ( ! AreSameOrOppositeVectorEpsilon( vtN1, vtToolDir, 0.1 * EPS_SMALL)) {
|
||||
Vector3d vtL1 = ptInt1 - ptV - vtMove ;
|
||||
vtL1 -= ( vtL1 * vtToolDir) * vtToolDir ;
|
||||
double dL1 = vtL1.Len() ;
|
||||
vtL1 /= dL1 ;
|
||||
Vector3d vtOriginalN1 = ( ( dDeltaR - dL1 + dMinRad) / dDeltaR) * vtArcNormMinR + ( ( dL1 - dMinRad) / dDeltaR) * vtArcNormMaxR ;
|
||||
vtOriginalN1.Normalize() ;
|
||||
vtN1 = - vtOriginalN1.z * vtToolDir - vtOriginalN1.x * vtL1 ;
|
||||
vtN1.Normalize() ;
|
||||
}
|
||||
if ( ! AreSameOrOppositeVectorEpsilon(vtN2, vtToolDir, 0.1 * EPS_SMALL)) {
|
||||
Vector3d vtL2 = ptInt2 - ptV - vtMove ;
|
||||
vtL2 -= (vtL2 * vtToolDir) * vtToolDir;
|
||||
double dL2 = vtL2.Len() ;
|
||||
vtL2 /= dL2 ;
|
||||
Vector3d vtOriginalN2 = ( ( dDeltaR - dL2 + dMinRad) / dDeltaR) * vtArcNormMinR + ( ( dL2 - dMinRad) / dDeltaR) * vtArcNormMaxR ;
|
||||
vtOriginalN2.Normalize() ;
|
||||
vtN2 = - vtOriginalN2.z * vtToolDir - vtOriginalN2.x * vtL2 ;
|
||||
vtN2.Normalize() ;
|
||||
}
|
||||
if ( bRecalNorm) {
|
||||
vtN1 = AdjustConeNormal( ptInt1, vtN1, ptV + vtMove, vtToolDir, dMinRad, dDeltaR, vtArcNormMinR, vtArcNormMaxR) ;
|
||||
vtN2 = AdjustConeNormal( ptInt2, vtN2, ptV + vtMove, vtToolDir, dMinRad, dDeltaR, vtArcNormMinR, vtArcNormMaxR) ;
|
||||
}
|
||||
SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ;
|
||||
}
|
||||
|
||||
// Solido interno
|
||||
Point3d ptPoly = ptC ;
|
||||
Vector3d vtPoly = Z_AX ;
|
||||
Point3d ptPoly = GetToLoc( ptC, PolyFrame) ;
|
||||
Vector3d vtPoly = GetToLoc( Z_AX, PolyFrame) ;
|
||||
|
||||
ptPoly.ToLoc( PolyFrame) ;
|
||||
vtPoly.ToLoc( PolyFrame) ;
|
||||
// Intervallo di intersezione (infinito) e normali (nulle)
|
||||
bool bValid = true ;
|
||||
double dPar1 = -INFINITO ;
|
||||
double dPar2 = +INFINITO ;
|
||||
vtN1 = V_NULL ;
|
||||
vtN2 = V_NULL ;
|
||||
|
||||
Point3d ptPoly1 = ptPoly + ( ( ( ptFacet135 - ptPoly) * vtNs) / ( vtPoly * vtNs)) * vtPoly ;
|
||||
Point3d ptPoly2 = ptPoly + ( ( ( ptFacet246 - ptPoly) * vtNd) / ( vtPoly * vtNd)) * vtPoly ;
|
||||
Point3d ptPoly3 = ptPoly + ( ( ( ptFacet135 - ptPoly) * vtIF) / ( vtPoly * vtIF)) * vtPoly ;
|
||||
Point3d ptPoly4 = ptPoly + ( ( ( ptFacet246 - ptPoly) * vtIF) / ( vtPoly * vtIF)) * vtPoly ;
|
||||
Point3d ptPoly5 = ptPoly + ( ( ( ptFacet135 - ptPoly) * vtUD) / ( vtPoly * vtUD)) * vtPoly ;
|
||||
Point3d ptPoly6 = ptPoly + ( ( ( ptFacet246 - ptPoly) * vtUD) / ( vtPoly * vtUD)) * vtPoly ;
|
||||
|
||||
int nIntNum = 0 ;
|
||||
|
||||
// Intersezione con la prima faccia
|
||||
if ( abs( vtPoly * vtNs) > COS_ORTO_ANG_ZERO) {
|
||||
if ( dLenY * ptPoly1.x >= dLenX * ptPoly1.y &&
|
||||
dLenY * ( ptPoly1.x - dDeltaX) <= dLenX * ( ptPoly1.y - dDeltaY) &&
|
||||
dDeltaX * ptPoly1.y >= dDeltaY * ptPoly1.x &&
|
||||
dDeltaX * ( ptPoly1.y - dLenY) <= dDeltaY * ( ptPoly1.x - dLenX)) {
|
||||
ptInt1 = ptPoly1 ;
|
||||
vtN1 = - vtNs ;
|
||||
if ( ! ( vtArcNormMaxR.IsSmall() || vtArcNormMinR.IsSmall())) {
|
||||
Vector3d vtRadial( 0, dMinRad * dCos, dMinRad * dSin) ;
|
||||
vtRadial.Normalize() ;
|
||||
Vector3d vtOrigMaxR = - vtArcNormMaxR.x * vtRadial - vtArcNormMaxR.z * X_AX ;
|
||||
Vector3d vtOrigMinR = - vtArcNormMinR.x * vtRadial - vtArcNormMinR.z * X_AX ;
|
||||
vtOrigMaxR.Normalize() ;
|
||||
vtOrigMinR.Normalize() ;
|
||||
vtN1 = ( ( dDeltaZ - ptInt1.z + dLenZ) / dDeltaZ) * vtOrigMinR + ( ( ptInt1.z - dLenZ) / dDeltaZ) * vtOrigMaxR ;
|
||||
vtN1.Normalize() ;
|
||||
// Verifica con facce iniziale e finale
|
||||
if ( bValid) {
|
||||
// Distanza con segno del punto di riferimento del dexel dal piano delle facce iniziale e finale
|
||||
double dDistI = ( ptPoly - ptFacet135) * -vtIF ;
|
||||
double dDistF = ( ptPoly - ptFacet246) * vtIF ;
|
||||
// Se dexel non parallelo alle facce
|
||||
if ( abs( vtPoly * vtIF) > COS_ORTO_ANG_ZERO) {
|
||||
// posizione parametrica delle intersezioni
|
||||
double dParI = -dDistI / ( vtPoly * -vtIF) ;
|
||||
double dParF = -dDistF / ( vtPoly * vtIF) ;
|
||||
// se intervallo tra intersezioni praticamente nullo
|
||||
if ( abs( dParI - dParF) < EPS_ZERO)
|
||||
bValid = false ;
|
||||
// altrimenti
|
||||
else {
|
||||
if ( dParI < dParF) {
|
||||
dPar1 = dParI ;
|
||||
vtN1 = vtIF ;
|
||||
dPar2 = dParF ;
|
||||
vtN2 = -vtIF ;
|
||||
}
|
||||
else {
|
||||
dPar1 = dParF ;
|
||||
vtN1 = -vtIF ;
|
||||
dPar2 = dParI ;
|
||||
vtN2 = vtIF ;
|
||||
}
|
||||
}
|
||||
++ nIntNum ;
|
||||
}
|
||||
// altrimenti praticamente parallelo
|
||||
else {
|
||||
// se esterno ad almeno uno invalida tutto
|
||||
if ( dDistI > 0 || dDistF > 0)
|
||||
bValid = false ;
|
||||
// altrimenti non cambia niente
|
||||
}
|
||||
}
|
||||
// Intersezione con la seconda faccia
|
||||
if ( abs( vtPoly * vtNd) > COS_ORTO_ANG_ZERO) {
|
||||
if ( dLenY * ptPoly2.x >= dLenX * ptPoly2.y &&
|
||||
dLenY * ( ptPoly2.x - dDeltaX) <= dLenX * ( ptPoly2.y - dDeltaY) &&
|
||||
dDeltaX * ptPoly2.y >= dDeltaY * ptPoly2.x &&
|
||||
dDeltaX * ( ptPoly2.y - dLenY) <= dDeltaY * ( ptPoly2.x - dLenX)) {
|
||||
|
||||
if ( nIntNum == 0) {
|
||||
ptInt1 = ptPoly2 ;
|
||||
vtN1 = - vtNd ;
|
||||
if ( ! ( vtArcNormMaxR.IsSmall() || vtArcNormMinR.IsSmall())) {
|
||||
Vector3d vtRadial( 0, dMinRad * dCos, - dMinRad * dSin) ;
|
||||
// Verifica con facce sopra e sotto
|
||||
if ( bValid) {
|
||||
// Distanza con segno del punto di riferimento del dexel dal piano delle facce sopra e sotto
|
||||
double dDistU = ( ptPoly - ptFacet246) * -vtUD ;
|
||||
double dDistD = ( ptPoly - ptFacet135) * vtUD ;
|
||||
// Se dexel non parallelo alle facce
|
||||
if ( abs( vtPoly * vtUD) > COS_ORTO_ANG_ZERO) {
|
||||
// posizione parametrica delle intersezioni
|
||||
double dParU = -dDistU / ( vtPoly * -vtUD) ;
|
||||
double dParD = -dDistD / ( vtPoly * vtUD) ;
|
||||
// se intervallo tra intersezioni praticamente nullo
|
||||
if ( abs( dParU - dParD) < EPS_ZERO)
|
||||
bValid = false ;
|
||||
// altrimenti
|
||||
else {
|
||||
if ( dParU < dParD) {
|
||||
if ( dParD < dPar1 + EPS_ZERO || dParU > dPar2 - EPS_ZERO)
|
||||
bValid = false ;
|
||||
else {
|
||||
if ( dParU > dPar1) {
|
||||
dPar1 = dParU ;
|
||||
vtN1 = vtUD ;
|
||||
}
|
||||
if ( dParD < dPar2) {
|
||||
dPar2 = dParD ;
|
||||
vtN2 = -vtUD ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( dParU < dPar1 + EPS_ZERO || dParD > dPar2 - EPS_ZERO)
|
||||
bValid = false ;
|
||||
else {
|
||||
if ( dParD > dPar1) {
|
||||
dPar1 = dParD ;
|
||||
vtN1 = -vtUD ;
|
||||
}
|
||||
if ( dParU < dPar2) {
|
||||
dPar2 = dParU ;
|
||||
vtN2 = vtUD ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// altrimenti praticamente parallelo
|
||||
else {
|
||||
// se esterno ad almeno uno invalida tutto
|
||||
if ( dDistU > 0 || dDistD > 0)
|
||||
bValid = false ;
|
||||
// altrimenti non cambia niente
|
||||
}
|
||||
}
|
||||
|
||||
// Taglio con la faccia sinistra
|
||||
if ( bValid) {
|
||||
// Distanza con segno del punto di riferimento del dexel dal piano della faccia sinistra
|
||||
double dDistS = ( ptPoly - ptFacet135) * vtNs ;
|
||||
// Se dexel non parallelo alla faccia
|
||||
if ( abs( vtPoly * vtNs) > COS_ORTO_ANG_ZERO) {
|
||||
// posizione parametrica della intersezione
|
||||
double dParS = -dDistS / ( vtPoly * vtNs) ;
|
||||
// verifico limitazioni su inizio e fine dell'intervallo
|
||||
int nLimit = 0 ;
|
||||
// se limita inizio
|
||||
if ( vtPoly * vtNs < 0) {
|
||||
// se oltre la fine, invalida tutto
|
||||
if ( dParS > dPar2 - EPS_ZERO)
|
||||
bValid = false ;
|
||||
// se altrimenti solo oltre inizio, riduce
|
||||
else if ( dParS >= dPar1) {
|
||||
dPar1 = dParS ;
|
||||
nLimit = 1 ;
|
||||
}
|
||||
}
|
||||
// altrimenti limita fine
|
||||
else {
|
||||
// se prima dell'inizio, invalida tutto
|
||||
if ( dParS < dPar1 + EPS_ZERO)
|
||||
bValid = false ;
|
||||
// se altrimenti solo prima della fine, riduce
|
||||
else if ( dParS <= dPar2) {
|
||||
dPar2 = dParS ;
|
||||
nLimit = 2 ;
|
||||
}
|
||||
}
|
||||
// se limita, devo aggiornare la normale
|
||||
if ( nLimit != 0) {
|
||||
Vector3d vtNewN = -vtNs ;
|
||||
if ( bRecalNorm) {
|
||||
Vector3d vtRadial( 0, dMinRad * dCos, dMinRad * dSin) ;
|
||||
vtRadial.Normalize() ;
|
||||
Vector3d vtOrigMaxR = - vtArcNormMaxR.x * vtRadial - vtArcNormMaxR.z * X_AX ;
|
||||
Vector3d vtOrigMinR = - vtArcNormMinR.x * vtRadial - vtArcNormMinR.z * X_AX ;
|
||||
vtOrigMaxR.Normalize() ;
|
||||
vtOrigMinR.Normalize() ;
|
||||
vtN1 = ( ( dDeltaZ - abs( ptInt1.z) + dLenZ) / dDeltaZ) * vtOrigMinR + ( ( abs( ptInt1.z) - dLenZ) / dDeltaZ) * vtOrigMaxR ;
|
||||
vtN1.Normalize() ;
|
||||
Point3d ptInt = ptPoly + dParS * vtPoly ;
|
||||
vtNewN = ( ( dDeltaZ - ptInt.z + dLenZ) / dDeltaZ) * vtOrigMinR + ( ( ptInt.z - dLenZ) / dDeltaZ) * vtOrigMaxR ;
|
||||
vtNewN.Normalize() ;
|
||||
}
|
||||
++ nIntNum ;
|
||||
}
|
||||
else if ( ( ptInt1 - ptPoly2).SqLen() > SQ_EPS_SMALL) {
|
||||
ptInt2 = ptPoly2 ;
|
||||
vtN2 = - vtNd ;
|
||||
if ( ! ( vtArcNormMaxR.IsSmall() || vtArcNormMinR.IsSmall())) {
|
||||
if ( nLimit == 1)
|
||||
vtN1 = vtNewN ;
|
||||
else
|
||||
vtN2 = vtNewN ;
|
||||
}
|
||||
}
|
||||
// altrimenti praticamente parallelo
|
||||
else {
|
||||
// se esterno invalida tutto
|
||||
if ( dDistS > 0)
|
||||
bValid = false ;
|
||||
// altrimenti non cambia niente
|
||||
}
|
||||
}
|
||||
|
||||
// Taglio con la faccia destra
|
||||
if ( bValid) {
|
||||
// Distanza con segno del punto di riferimento del dexel dal piano della faccia destra
|
||||
double dDistD = ( ptPoly - ptFacet246) * vtNd ;
|
||||
// Se dexel non parallelo alla faccia
|
||||
if ( abs( vtPoly * vtNd) > COS_ORTO_ANG_ZERO) {
|
||||
// posizione parametrica della intersezione
|
||||
double dParD = -dDistD / ( vtPoly * vtNd) ;
|
||||
// verifico limitazioni su inizio e fine dell'intervallo
|
||||
int nLimit = 0 ;
|
||||
// se limita inizio
|
||||
if ( vtPoly * vtNd < 0) {
|
||||
// se oltre la fine, invalida tutto
|
||||
if ( dParD > dPar2 - EPS_ZERO)
|
||||
bValid = false ;
|
||||
// se altrimenti solo oltre inizio, riduce
|
||||
else if ( dParD >= dPar1) {
|
||||
dPar1 = dParD ;
|
||||
nLimit = 1 ;
|
||||
}
|
||||
}
|
||||
// altrimenti limita fine
|
||||
else {
|
||||
// se prima dell'inizio, invalida tutto
|
||||
if ( dParD < dPar1 + EPS_ZERO)
|
||||
bValid = false ;
|
||||
// se altrimenti solo prima della fine, riduce
|
||||
else if ( dParD <= dPar2) {
|
||||
dPar2 = dParD ;
|
||||
nLimit = 2 ;
|
||||
}
|
||||
}
|
||||
// se limita, devo aggiornare la normale
|
||||
if ( nLimit != 0) {
|
||||
Vector3d vtNewN = -vtNd ;
|
||||
if ( bRecalNorm) {
|
||||
Vector3d vtRadial( 0, dMinRad * dCos, -dMinRad * dSin) ;
|
||||
vtRadial.Normalize() ;
|
||||
Vector3d vtOrigMaxR = -vtArcNormMaxR.x * vtRadial - vtArcNormMaxR.z * X_AX ;
|
||||
Vector3d vtOrigMinR = -vtArcNormMinR.x * vtRadial - vtArcNormMinR.z * X_AX ;
|
||||
Vector3d vtOrigMaxR = - vtArcNormMaxR.x * vtRadial - vtArcNormMaxR.z * X_AX ;
|
||||
Vector3d vtOrigMinR = - vtArcNormMinR.x * vtRadial - vtArcNormMinR.z * X_AX ;
|
||||
vtOrigMaxR.Normalize() ;
|
||||
vtOrigMinR.Normalize() ;
|
||||
vtN2 = ( ( dDeltaZ - abs( ptInt2.z) + dLenZ) / dDeltaZ) * vtOrigMinR + ( ( abs( ptInt2.z) - dLenZ) / dDeltaZ) * vtOrigMaxR ;
|
||||
vtN2.Normalize() ;
|
||||
Point3d ptInt = ptPoly + dParD * vtPoly ;
|
||||
vtNewN = ( ( dDeltaZ - abs( ptInt.z) + dLenZ) / dDeltaZ) * vtOrigMinR + ( ( abs( ptInt.z) - dLenZ) / dDeltaZ) * vtOrigMaxR ;
|
||||
vtNewN.Normalize() ;
|
||||
}
|
||||
++ nIntNum ;
|
||||
if ( nLimit == 1)
|
||||
vtN1 = vtNewN ;
|
||||
else
|
||||
vtN2 = vtNewN ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Intersezione con la terza faccia
|
||||
if ( abs( vtPoly * vtIF) > COS_ORTO_ANG_ZERO) {
|
||||
if ( nIntNum < 2 &&
|
||||
ptPoly3.x >= 0 && ptPoly3.x <= dDeltaX &&
|
||||
dDeltaX * abs( ptPoly3.z) < dDeltaX * dLenZ + dDeltaZ * ptPoly3.x) {
|
||||
|
||||
if ( nIntNum == 0) {
|
||||
ptInt1 = ptPoly3 ;
|
||||
vtN1 = vtIF ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
else if ( ( ptInt1 - ptPoly3).SqLen() > SQ_EPS_SMALL) {
|
||||
ptInt2 = ptPoly3 ;
|
||||
vtN2 = vtIF ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
// altrimenti praticamente parallelo
|
||||
else {
|
||||
// se esterno invalida tutto
|
||||
if ( dDistD > 0)
|
||||
bValid = false ;
|
||||
// altrimenti non cambia niente
|
||||
}
|
||||
}
|
||||
|
||||
// Intersezione con la quarta faccia
|
||||
if ( abs( vtPoly * vtIF) > COS_ORTO_ANG_ZERO) {
|
||||
if ( nIntNum < 2 &&
|
||||
ptPoly4.x >= dLenX && ptPoly4.x <= dLenX + dDeltaX &&
|
||||
dDeltaX * abs( ptPoly4.z) < dDeltaX * dLenZ + dDeltaZ * ( ptPoly4.x - dLenX)) {
|
||||
|
||||
if ( nIntNum == 0) {
|
||||
ptInt1 = ptPoly4 ;
|
||||
vtN1 = - vtIF ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
else if ( ( ptInt1 - ptPoly4).SqLen() > SQ_EPS_SMALL) {
|
||||
ptInt2 = ptPoly4 ;
|
||||
vtN2 = - vtIF ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Intersezione con la quinta faccia
|
||||
if ( abs( vtPoly * vtUD) > COS_ORTO_ANG_ZERO) {
|
||||
if ( nIntNum < 2 &&
|
||||
ptPoly5.y >= 0 && ptPoly5.y <= dLenY &&
|
||||
abs( ptPoly5.z) <= dLenZ) {
|
||||
|
||||
if ( nIntNum == 0) {
|
||||
ptInt1 = ptPoly5 ;
|
||||
vtN1 = - vtUD ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
else if ( ( ptInt1 - ptPoly5).SqLen() > SQ_EPS_SMALL) {
|
||||
ptInt2 = ptPoly5 ;
|
||||
vtN2 = - vtUD ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Intersezione con la sesta faccia
|
||||
if ( abs( vtPoly * vtUD) > COS_ORTO_ANG_ZERO) {
|
||||
if ( nIntNum < 2 &&
|
||||
ptPoly6.y >= dDeltaY && ptPoly6.y <= dLenY + dDeltaY &&
|
||||
abs( ptPoly6.z) <= dLenZ + dDeltaZ) {
|
||||
|
||||
if ( nIntNum == 0) {
|
||||
ptInt1 = ptPoly6;
|
||||
vtN1 = vtUD ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
else if ( ( ptInt1 - ptPoly6).SqLen() > SQ_EPS_SMALL) {
|
||||
ptInt2 = ptPoly6;
|
||||
vtN2 = vtUD ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Se il poliedro è attraversato taglio
|
||||
if ( nIntNum == 2) {
|
||||
|
||||
// Riporto le intersezioni nel sistema griglia
|
||||
ptInt1.ToGlob( PolyFrame) ;
|
||||
// Se rimasto qualcosa lo sottraggo al dexel
|
||||
if ( bValid) {
|
||||
// Punti di intersezione e normali nel sistema griglia
|
||||
ptInt1 = ptC + dPar1 * Z_AX ;
|
||||
vtN1.ToGlob( PolyFrame) ;
|
||||
ptInt2.ToGlob( PolyFrame) ;
|
||||
ptInt2 = ptC + dPar2 * Z_AX ;
|
||||
vtN2.ToGlob( PolyFrame) ;
|
||||
|
||||
// Eseguo sottrazione
|
||||
SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ;
|
||||
}
|
||||
|
||||
@@ -4631,27 +4652,9 @@ VolZmap::CompConus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
// Cono
|
||||
ConusFrame.ChangeOrig( ptV) ;
|
||||
if ( IntersLineConus( ptC, Z_AX, ConusFrame, dTan, dl, dL, bTapB, true, ptInt1, vtN1, ptInt2, vtN2)) {
|
||||
if ( ! ( vtArcNormMaxR.IsSmall() || vtArcNormMinR.IsSmall())) {
|
||||
if ( ! AreSameOrOppositeVectorEpsilon( vtN1, vtToolDir, 0.1 * EPS_SMALL)) {
|
||||
Vector3d vtL1 = ptInt1 - ptV ;
|
||||
vtL1 -= ( vtL1 * vtToolDir) * vtToolDir ;
|
||||
double dL1 = vtL1.Len() ;
|
||||
vtL1 /= dL1 ;
|
||||
Vector3d vtOriginalN1 = ( ( dDeltaR - dL1 + dMinRad) / dDeltaR) * vtArcNormMinR + ( ( dL1 - dMinRad) / dDeltaR) * vtArcNormMaxR ;
|
||||
vtOriginalN1.Normalize() ;
|
||||
vtN1 = - vtOriginalN1.z * vtToolDir - vtOriginalN1.x * vtL1 ;
|
||||
vtN1.Normalize() ;
|
||||
}
|
||||
if ( ! AreSameOrOppositeVectorEpsilon( vtN2, vtToolDir, 0.1 * EPS_SMALL)) {
|
||||
Vector3d vtL2 = ptInt2 - ptV ;
|
||||
vtL2 -= ( vtL2 * vtToolDir) * vtToolDir ;
|
||||
double dL2 = vtL2.Len() ;
|
||||
vtL2 /= dL2 ;
|
||||
Vector3d vtOriginalN2 = ( ( dDeltaR - dL2 + dMinRad) / dDeltaR) * vtArcNormMinR + ( ( dL2 - dMinRad) / dDeltaR) * vtArcNormMaxR ;
|
||||
vtOriginalN2.Normalize() ;
|
||||
vtN2 = - vtOriginalN2.z * vtToolDir - vtOriginalN2.x * vtL2 ;
|
||||
vtN2.Normalize() ;
|
||||
}
|
||||
if ( bRecalNorm) {
|
||||
vtN1 = AdjustConeNormal( ptInt1, vtN1, ptV, vtToolDir, dMinRad, dDeltaR, vtArcNormMinR, vtArcNormMaxR) ;
|
||||
vtN2 = AdjustConeNormal( ptInt2, vtN2, ptV, vtToolDir, dMinRad, dDeltaR, vtArcNormMinR, vtArcNormMaxR) ;
|
||||
}
|
||||
SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ;
|
||||
}
|
||||
@@ -4876,7 +4879,7 @@ VolZmap::TestCompoBBox( int nGrid, const Point3d& ptP1, const Point3d& ptP2, con
|
||||
// I punti e i vettori devono essere nel sistema di riferimento opportuno
|
||||
|
||||
// Controllo sull'ammissibilità del numero di griglia
|
||||
if ( nGrid < 0 || nGrid > 2)
|
||||
if ( nGrid < 0 || nGrid > 2)
|
||||
return false ;
|
||||
|
||||
// BBox dello Zmap
|
||||
@@ -4939,10 +4942,10 @@ VolZmap::TestParaBBox( int nGrid, const Point3d& ptS, const Point3d& ptE, const
|
||||
return false ;
|
||||
|
||||
// Limiti su indici
|
||||
nStI = ( dMinX < EPS_SMALL ? 0 : static_cast<int> ( dMinX / m_dStep)) ;
|
||||
nEnI = ( dMaxX > dMaxXValue - EPS_SMALL ? nMaxNx - 1 : static_cast<int> ( dMaxX / m_dStep)) ;
|
||||
nStJ = ( dMinY < EPS_SMALL ? 0 : static_cast<int> ( dMinY / m_dStep)) ;
|
||||
nEnJ = ( dMaxY > dMaxYValue - EPS_SMALL ? nMaxNy - 1 : static_cast<int> ( dMaxY / m_dStep)) ;
|
||||
|
||||
nStI = ( dMinX < EPS_SMALL ? 0 : int( dMinX / m_dStep)) ;
|
||||
nEnI = ( dMaxX > dMaxXValue - EPS_SMALL ? nMaxNx - 1 : int( dMaxX / m_dStep)) ;
|
||||
nStJ = ( dMinY < EPS_SMALL ? 0 : int( dMinY / m_dStep)) ;
|
||||
nEnJ = ( dMaxY > dMaxYValue - EPS_SMALL ? nMaxNy - 1 : int ( dMaxY / m_dStep)) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
+908
@@ -0,0 +1,908 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2023
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Voronoi.cpp Data : 23.11.23 Versione : 2.5k5
|
||||
// Contenuto : Classe per Voronoi con libreria VRONI.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 23.11.23 SP Creazione modulo.
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "GeoConst.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "CurveArc.h"
|
||||
#include "CurveLine.h"
|
||||
#include "CurveBezier.h"
|
||||
#include "SurfFlatRegion.h"
|
||||
#include "OffsetAux.h"
|
||||
#include "RemoveCurveDefects.h"
|
||||
#include "Voronoi.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Voronoi::Voronoi( const ICurve* pCrv, bool bAllowAdd)
|
||||
: m_vroni( nullptr), m_nBound( VORONOI_STD_BOUND), m_bVDComputed( false), m_bAllowAdd( true)
|
||||
{
|
||||
// tento di aggiungere la curva
|
||||
if ( ! AddCurve( pCrv))
|
||||
Clear() ;
|
||||
m_bAllowAdd = bAllowAdd ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Voronoi::Voronoi( const ISurfFlatRegion* pSfr, bool bAllowAdd)
|
||||
: m_vroni( nullptr), m_nBound( VORONOI_STD_BOUND), m_bVDComputed( false), m_bAllowAdd( true)
|
||||
{
|
||||
// tento di aggiungere la superficie
|
||||
if ( ! AddSurfFlatRegion( pSfr))
|
||||
Clear() ;
|
||||
m_bAllowAdd = bAllowAdd ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Voronoi::~Voronoi( void)
|
||||
{
|
||||
Clear() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::Clear( void)
|
||||
{
|
||||
// pulizia oggetto vroni
|
||||
if ( m_vroni != nullptr)
|
||||
delete m_vroni ;
|
||||
m_vroni = nullptr ;
|
||||
|
||||
// ciclo di pulizia delle curve associate
|
||||
for ( auto pCrv : m_vpCrvs)
|
||||
delete pCrv ;
|
||||
m_vpCrvs.clear() ;
|
||||
|
||||
m_nBound = VORONOI_STD_BOUND ;
|
||||
m_bVDComputed = false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::AddCurve( const ICurve* pCrv)
|
||||
{
|
||||
if ( ! m_bAllowAdd)
|
||||
return false ;
|
||||
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
|
||||
// verifico se è una linea
|
||||
int nType = pCrv->GetType() ;
|
||||
bool bIsLine = ( nType == CRV_LINE) ;
|
||||
if ( nType == CRV_COMPO) {
|
||||
const CurveComposite* pCompo = GetBasicCurveComposite( pCrv) ;
|
||||
Point3d ptStart, ptEnd ;
|
||||
if ( pCompo != nullptr && pCompo->IsALine( 10 * EPS_SMALL, ptStart, ptEnd))
|
||||
bIsLine = true ;
|
||||
}
|
||||
|
||||
// verifico sia piana e trovo piano su cui giace
|
||||
Plane3d plPlane ;
|
||||
if ( bIsLine) {
|
||||
// linea è sicuramente piana. Scelgo piano definito dall'estrusione ( se definita)
|
||||
Point3d ptS ; pCrv->GetStartPoint( ptS) ;
|
||||
Vector3d vtExtr ; pCrv->GetExtrusion( vtExtr) ;
|
||||
if ( ! vtExtr.IsSmall())
|
||||
plPlane.Set( ptS, vtExtr) ;
|
||||
else
|
||||
plPlane.Set( ptS, Z_AX) ;
|
||||
}
|
||||
else {
|
||||
if ( ! pCrv->IsFlat( plPlane, false, 10 * EPS_SMALL))
|
||||
return false ;
|
||||
}
|
||||
|
||||
if ( m_vpCrvs.size() == 0) {
|
||||
// se prima curva considerata assegno il frame al Voronoi
|
||||
m_Frame.Set( plPlane.GetPoint(), plPlane.GetVersN()) ;
|
||||
}
|
||||
else {
|
||||
// altrimenti verifico sia complanare ad eventuali curve già presenti
|
||||
if ( ! AreSameOrOppositeVectorApprox( m_Frame.VersZ(), plPlane.GetVersN()) || ! PointInPlaneApprox( m_Frame.Orig(), plPlane))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// verifico se oggetto vroni è stato inizializzato
|
||||
if ( m_vroni == nullptr) {
|
||||
m_vroni = new( nothrow) vroniObject() ;
|
||||
m_vroni->apiInitializeProgram() ;
|
||||
}
|
||||
|
||||
// creo una copia della curva e la porto in locale
|
||||
PtrOwner<ICurve> pCrvLoc( pCrv->Clone()) ;
|
||||
pCrvLoc->ToLoc( m_Frame) ;
|
||||
|
||||
// aggiungo la curva in locale all'oggetto vroni
|
||||
if ( ! AddCurveToVroni( pCrvLoc))
|
||||
return false ;
|
||||
|
||||
// aggiorno il box complessivo
|
||||
BBox3d bBox ;
|
||||
pCrvLoc->GetLocalBBox( bBox) ;
|
||||
m_bBox.Add( bBox) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::AddSurfFlatRegion( const ISurfFlatRegion* pSfr)
|
||||
{
|
||||
if ( ! m_bAllowAdd)
|
||||
return false ;
|
||||
|
||||
if ( pSfr == nullptr)
|
||||
return false ;
|
||||
|
||||
// recupero il piano
|
||||
Point3d ptCen ; pSfr->GetCentroid( ptCen) ;
|
||||
Vector3d vtN = pSfr->GetNormVersor() ;
|
||||
if ( m_vpCrvs.size() == 0) {
|
||||
// assegno il frame al Voronoi
|
||||
m_Frame.Set( ptCen, vtN) ;
|
||||
}
|
||||
else {
|
||||
// verifico sia complanare ad eventuali curve già presenti
|
||||
Plane3d plPlane ;
|
||||
plPlane.Set( ptCen, pSfr->GetNormVersor()) ;
|
||||
if ( ! AreSameOrOppositeVectorApprox( m_Frame.VersZ(), pSfr->GetNormVersor()) || ! PointInPlaneApprox( m_Frame.Orig(), plPlane))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// verifico se oggetto vroni è stato inizializzato
|
||||
if ( m_vroni == nullptr) {
|
||||
m_vroni = new( nothrow) vroniObject() ;
|
||||
m_vroni->apiInitializeProgram() ;
|
||||
}
|
||||
|
||||
// aggiungo le curve di loop
|
||||
for ( int i = 0 ; i < pSfr->GetChunkCount() ; i ++) {
|
||||
for ( int j = 0 ; j < pSfr->GetLoopCount( i) ; j ++) {
|
||||
PtrOwner<ICurve> pCrvLoc( pSfr->GetLoop( i, j)) ;
|
||||
pCrvLoc->ToLoc( m_Frame) ;
|
||||
if ( ! AddCurveToVroni( pCrvLoc))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
// aggiorno il box complessivo
|
||||
BBox3d bBox ;
|
||||
Frame3d frSrf = m_Frame ;
|
||||
frSrf.Invert() ;
|
||||
pSfr->GetBBox( frSrf, bBox) ;
|
||||
m_bBox.Add( bBox) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::AddCurveToVroni( const ICurve* pCrv)
|
||||
{
|
||||
int nLoopId = m_vpCrvs.size() ;
|
||||
|
||||
// aggiungo il punto iniziale
|
||||
Point3d ptStart ;
|
||||
if ( ! pCrv->GetStartPoint( ptStart))
|
||||
return false ;
|
||||
int nCrv = m_vroni->HandlePnt( ptStart.x, ptStart.y, {nLoopId, 0}) ;
|
||||
|
||||
// aggiungo la parte rimanente della curva
|
||||
switch ( pCrv->GetType()) {
|
||||
case CRV_LINE :
|
||||
m_vpCrvs.emplace_back( pCrv->Clone()) ;
|
||||
return AddLineToVroni( GetCurveLine( pCrv), nCrv, nLoopId) ;
|
||||
case CRV_ARC :
|
||||
m_vpCrvs.emplace_back( pCrv->Clone()) ;
|
||||
return AddArcToVroni( GetCurveArc( pCrv), nCrv, nLoopId) ;
|
||||
case CRV_COMPO :
|
||||
return AddCompoToVroni( GetCurveComposite( pCrv), nCrv, nLoopId) ;
|
||||
case CRV_BEZIER :
|
||||
return AddBezierToVroni( GetCurveBezier( pCrv), nCrv, nLoopId) ;
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::AddLineToVroni( const ICurveLine* pLine, int& nVroniCrv, int nLoopId, int nCrvId, Point3d ptEnd)
|
||||
{
|
||||
if ( pLine == nullptr)
|
||||
return false ;
|
||||
if ( ! ptEnd.IsValid()) {
|
||||
// recupero end point
|
||||
if ( ! pLine->GetEndPoint( ptEnd))
|
||||
return false ;
|
||||
}
|
||||
|
||||
m_vroni->AddSeg( &nVroniCrv, ptEnd.x, ptEnd.y, {nLoopId, nCrvId}) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::AddArcToVroni( const ICurveArc* pArc, int& nVroniCrv, int nLoopId, int nCrvId, Point3d ptEnd)
|
||||
{
|
||||
if ( pArc == nullptr)
|
||||
return false ;
|
||||
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
int nArcSiteType = ( dAngCen > 0 ? ARC : -ARC ) ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
if ( AreOppositeVectorApprox( vtN, Z_AX))
|
||||
nArcSiteType *= -1 ;
|
||||
|
||||
if ( pArc->IsACircle()) {
|
||||
// spezzo arco in due parti
|
||||
Point3d ptM ;
|
||||
if ( ! pArc->GetMidPoint( ptM))
|
||||
return false ;
|
||||
m_vroni->AddArc( &nVroniCrv, ptM.x, ptM.y, ptCen.x, ptCen.y, nArcSiteType, {nLoopId, nCrvId}) ;
|
||||
// impogno che punto finale coincida con lo start ( per tolleranze vroni)
|
||||
Point3d ptStart ; pArc->GetStartPoint( ptStart) ;
|
||||
m_vroni->AddArc( &nVroniCrv, ptStart.x, ptStart.y, ptCen.x, ptCen.y, nArcSiteType, {nLoopId, nCrvId}) ;
|
||||
}
|
||||
else {
|
||||
if ( ! ptEnd.IsValid()) {
|
||||
// recupero end point dalla curva
|
||||
if ( ! pArc->GetEndPoint( ptEnd))
|
||||
return false ;
|
||||
}
|
||||
m_vroni->AddArc( &nVroniCrv, ptEnd.x, ptEnd.y, ptCen.x, ptCen.y, nArcSiteType, {nLoopId, nCrvId}) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::AddCompoToVroni( const ICurveComposite* pCompo, int& nVroniCrv, int nLoopId)
|
||||
{
|
||||
if ( pCompo == nullptr)
|
||||
return false ;
|
||||
|
||||
PtrOwner<CurveComposite> pCopy( CloneBasicCurveComposite( pCompo)) ;
|
||||
if ( IsNull( pCopy))
|
||||
return false ;
|
||||
|
||||
// verifico che la curva sia fatta solo da rette e archi che giacciono nel piano XY ( estrusione deve essere Z+)
|
||||
Vector3d vtExtr ; pCopy->GetExtrusion( vtExtr) ;
|
||||
pCopy->SetExtrusion( Z_AX) ;
|
||||
if ( ! pCopy->ArcsBezierCurvesToArcsPerpExtr( 10 * EPS_SMALL, ANG_TOL_STD_DEG))
|
||||
return false ;
|
||||
pCopy->SetExtrusion( vtExtr) ;
|
||||
|
||||
// aggiungo tutte le sottocurve
|
||||
bool bClosed = pCopy->IsClosed() ;
|
||||
for ( int i = 0 ; i < pCopy->GetCurveCount() ; i++) {
|
||||
Point3d ptForcedEnd = P_INVALID ;
|
||||
|
||||
// se curva è chiusa, forzo l'end point a coincidere con lo start ( per le tolleranze di vroni)
|
||||
if ( i == pCopy->GetCurveCount() - 1 && bClosed)
|
||||
pCompo->GetStartPoint( ptForcedEnd) ;
|
||||
|
||||
// aggiungo
|
||||
const ICurve* pCrv = pCopy->GetCurve( i) ;
|
||||
int nType = pCrv->GetType() ;
|
||||
if ( nType == CRV_LINE)
|
||||
AddLineToVroni( GetCurveLine( pCrv), nVroniCrv, nLoopId, i, ptForcedEnd) ;
|
||||
else if ( nType == CRV_ARC)
|
||||
AddArcToVroni( GetCurveArc( pCrv), nVroniCrv, nLoopId, i, ptForcedEnd) ;
|
||||
}
|
||||
|
||||
// aggiungo al vettore di curve
|
||||
m_vpCrvs.emplace_back( Release( pCopy)) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::AddBezierToVroni( const ICurveBezier* pBezier, int& nVroniCrv, int nLoopId)
|
||||
{
|
||||
if ( pBezier == nullptr)
|
||||
return false ;
|
||||
|
||||
// riconduco al caso di curva composita
|
||||
PtrOwner<CurveComposite> pCompo( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCompo))
|
||||
return false ;
|
||||
PolyArc PA ;
|
||||
if ( ! pBezier->ApproxWithArcsEx( LIN_TOL_STD, ANG_TOL_STD_DEG, LIN_FEA_LEN_STD, PA) || ! pCompo->FromPolyArc( PA))
|
||||
return false ;
|
||||
|
||||
Vector3d vtExtr ; pBezier->GetExtrusion( vtExtr) ;
|
||||
pCompo->SetExtrusion( vtExtr) ;
|
||||
|
||||
return AddCompoToVroni( pCompo, nVroniCrv, nLoopId) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
Voronoi::GetCurve( int nId) const
|
||||
{
|
||||
// verifico validità indice
|
||||
if ( nId < 0 || nId > ( int)m_vpCrvs.size() - 1)
|
||||
return nullptr ;
|
||||
// ne faccio una copia
|
||||
ICurve* pCrv = m_vpCrvs[nId]->Clone() ;
|
||||
if ( pCrv == nullptr)
|
||||
return nullptr ;
|
||||
// la porto nel riferimento globale
|
||||
pCrv->ToGlob( m_Frame) ;
|
||||
return pCrv ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::CalcVoronoi( int nBound)
|
||||
{
|
||||
// se già stato calcolato con lo stesso bound non devo fare nulla
|
||||
if ( m_bVDComputed && nBound == m_nBound)
|
||||
return true ;
|
||||
|
||||
// se già stato calcolato reset dei dati
|
||||
if ( m_bVDComputed)
|
||||
m_vroni->ResetVoronoiDiagram() ;
|
||||
|
||||
// calcolo
|
||||
m_nBound = nBound ;
|
||||
m_bVDComputed = true ;
|
||||
string sTmp = "" ;
|
||||
m_vroni->apiComputeVD( false, true, false, m_nBound, 0, 0, &sTmp[0], false, false, false, &sTmp[0], true) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
Voronoi::GetBisectorCurve( int i)
|
||||
{
|
||||
if ( i >= m_vroni->GetNumberOfEdges())
|
||||
return nullptr ;
|
||||
|
||||
// identifico il tipo di bisettore
|
||||
int nType = m_vroni->GetBisectorType( i) ;
|
||||
|
||||
// linea
|
||||
if ( nType == BisectorType::LINE) {
|
||||
// recupero i dati del bisettore da vroni
|
||||
Point3d ptS, ptE ;
|
||||
double dParS, dParE ;
|
||||
m_vroni->GetLinearBisectorData( i, ptS.v, ptE.v, dParS, dParE) ;
|
||||
// creo la linea
|
||||
CurveLine* pLine = CreateBasicCurveLine() ;
|
||||
if ( pLine == nullptr)
|
||||
return nullptr ;
|
||||
pLine->Set( ptS, ptE) ;
|
||||
pLine->SetTempParam( dParS, 0) ;
|
||||
pLine->SetTempParam( dParE, 1) ;
|
||||
pLine->ToGlob( m_Frame) ;
|
||||
return pLine ;
|
||||
}
|
||||
|
||||
// degenerate hyperellipse ( arco)
|
||||
else if ( nType == BisectorType::DEGENERATE_HYPERELL) {
|
||||
// recupero i dati del bisettore da vroni
|
||||
Point3d ptS, ptE, ptC ;
|
||||
double dParS, dParE ;
|
||||
m_vroni->GetDegenerateHyperEllipticBisectorData( i, ptS.v, ptE.v, ptC.v, dParS, dParE) ;
|
||||
// creo arco
|
||||
CurveArc* pArc = CreateBasicCurveArc() ;
|
||||
if ( pArc == nullptr)
|
||||
return nullptr ;
|
||||
pArc->SetC2P( ptC, ptS, ptE) ;
|
||||
pArc->SetTempParam( dParS, 0) ;
|
||||
pArc->SetTempParam( dParS, 1) ;
|
||||
pArc->ToGlob( m_Frame) ;
|
||||
return pArc ;
|
||||
}
|
||||
|
||||
// bisettore generico
|
||||
else if ( nType != BisectorType::NONE) {
|
||||
// approssimo linearmente il bisettore
|
||||
int nPoints = m_vroni->GetApproxedBisectorPointsNbr( i) ;
|
||||
if ( nPoints < 2)
|
||||
return nullptr ;
|
||||
|
||||
CurveComposite* pCompo = CreateBasicCurveComposite() ;
|
||||
if ( pCompo == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
// punto iniziale
|
||||
Point3d pt ;
|
||||
double dParS ;
|
||||
m_vroni->GetApproxedBisectorPoint( i, 0, pt.v, dParS) ;
|
||||
pCompo->AddPoint( pt) ;
|
||||
int nCrvCount = 0 ;
|
||||
|
||||
double dParPrev = dParS ;
|
||||
for ( int j = 1 ; j < nPoints ; j ++) {
|
||||
double dPar ;
|
||||
m_vroni->GetApproxedBisectorPoint( i, j, pt.v, dPar) ;
|
||||
if ( pCompo->AddLine( pt)) {
|
||||
// setto i parametri sulla sottocurva
|
||||
pCompo->SetCurveTempParam( nCrvCount, dParPrev, 0) ;
|
||||
pCompo->SetCurveTempParam( nCrvCount, dPar, 1) ;
|
||||
// aggiorno parametro precedente
|
||||
dParPrev = dPar ;
|
||||
nCrvCount ++ ;
|
||||
}
|
||||
}
|
||||
|
||||
// setto parametri sulla curva
|
||||
pCompo->SetTempParam( dParS, 0) ;
|
||||
pCompo->SetTempParam( dParPrev, 1) ;
|
||||
|
||||
pCompo->ToGlob( m_Frame) ;
|
||||
return pCompo ;
|
||||
}
|
||||
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound)
|
||||
{
|
||||
vCrvs.clear() ;
|
||||
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
// verifico se necessario calcolo Voronoi
|
||||
if ( ! m_bVDComputed || nBound != m_nBound)
|
||||
CalcVoronoi( nBound) ;
|
||||
|
||||
for ( int i = 4 ; i < m_vroni->GetNumberOfEdges() ; i ++) {
|
||||
// recupero la curva del bisettore
|
||||
PtrOwner<ICurve> pCrv( GetBisectorCurve( i)) ;
|
||||
if ( ! IsNull( pCrv) && pCrv->IsValid())
|
||||
vCrvs.emplace_back( Release( pCrv)) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide)
|
||||
{
|
||||
vCrvs.clear() ;
|
||||
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
if ( ! m_bVDComputed)
|
||||
CalcVoronoi() ;
|
||||
|
||||
// lato per il medial axis
|
||||
bool bLeft = true ;
|
||||
bool bRight = true ;
|
||||
if ( nSide == WMAT_LEFT)
|
||||
bRight = false ;
|
||||
else if ( nSide == WMAT_RIGHT)
|
||||
bLeft = false ;
|
||||
|
||||
// calcolo medial axis
|
||||
m_vroni->apiComputeWMAT( false, 0.0, 0.0, false, bLeft, bRight) ;
|
||||
|
||||
for ( int i = 4 ; i < m_vroni->GetNumberOfEdges() ; i ++) {
|
||||
// verifico se il lato appartiene al medial axis
|
||||
if ( m_vroni->IsWMATEdge( i)) {
|
||||
PtrOwner<ICurve> pCrv( GetBisectorCurve( i)) ;
|
||||
if ( ! IsNull( pCrv) && pCrv->IsValid())
|
||||
vCrvs.emplace_back( Release( pCrv)) ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::CalcOffset( ICURVEPOVECTOR& vOffs, double dOffs, int nType)
|
||||
{
|
||||
vOffs.clear() ;
|
||||
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
// verifico se curve sono coerenti per calcolo dell'offset
|
||||
if ( ! VerifyCurvesValidityForOffset())
|
||||
return false ;
|
||||
|
||||
// se offset nullo restituisco direttamente le curve
|
||||
if ( abs( dOffs) < EPS_SMALL) {
|
||||
for ( auto pCrv : m_vpCrvs)
|
||||
vOffs.emplace_back( pCrv->Clone()) ;
|
||||
}
|
||||
|
||||
bool bClosed = m_vpCrvs[0]->IsClosed() ;
|
||||
|
||||
// stabilisco lato offset
|
||||
bool bRightOffs = true ;
|
||||
bool bLeftOffs = true ;
|
||||
if ( bClosed) {
|
||||
bRightOffs = ( dOffs > EPS_SMALL ? true : false) ;
|
||||
bLeftOffs = ( dOffs < - EPS_SMALL ? true : false) ;
|
||||
}
|
||||
|
||||
// calcolo offset
|
||||
ICRVCOMPOPLIST OffsList ;
|
||||
if ( ! CalcVroniOffset( OffsList, abs( dOffs), bRightOffs, bLeftOffs))
|
||||
return false ;
|
||||
|
||||
// sistemo le curve di offset calcolate con vroni
|
||||
for ( auto pCrv : OffsList) {
|
||||
|
||||
// aggiustamento per curva aperta
|
||||
if ( ! bClosed)
|
||||
AdjustOpenOffsetCurve( *pCrv, dOffs) ;
|
||||
|
||||
if ( pCrv->IsValid()) {
|
||||
// eventuale inversione
|
||||
if ( dOffs > EPS_SMALL)
|
||||
pCrv->Invert() ;
|
||||
|
||||
if ( bClosed) {
|
||||
// forzo chiusura della curva per evitare piccole imprecisioni
|
||||
pCrv->Close() ;
|
||||
// sistemo il punto di inizio
|
||||
AdjustOffsetStart( *pCrv) ;
|
||||
}
|
||||
|
||||
// sistemo i raccordi
|
||||
if ( ( nType & ICurve::OFF_CHAMFER) != 0 || ( nType & ICurve::OFF_EXTEND) != 0) {
|
||||
IdentifyFillets( pCrv, dOffs) ;
|
||||
AdjustCurveFillets( pCrv, dOffs, nType) ;
|
||||
}
|
||||
// porto nel frame globale
|
||||
pCrv->ToGlob( m_Frame) ;
|
||||
// unisco le parti allineate
|
||||
pCrv->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG, true, true) ;
|
||||
// aggiungo al vettore finale
|
||||
vOffs.emplace_back( pCrv) ;
|
||||
}
|
||||
else
|
||||
delete pCrv ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::CalcFatCurve( ICURVEPOVECTOR& vCrvs, double dOffs, bool bSquareEnds, bool bSquareMids)
|
||||
{
|
||||
vCrvs.clear() ;
|
||||
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
// se offset nullo errore
|
||||
if ( abs( dOffs) < EPS_SMALL)
|
||||
return false ;
|
||||
|
||||
ICRVCOMPOPLIST OffsList ;
|
||||
if ( ! CalcVroniOffset( OffsList, abs( dOffs), true, true))
|
||||
return false ;
|
||||
|
||||
// sistemo le curve di offset calcolate con vroni
|
||||
bool bClosed = m_vpCrvs[0]->IsClosed() ;
|
||||
for ( auto pCrvOffs : OffsList) {
|
||||
|
||||
// eventuale inversione
|
||||
if ( dOffs > EPS_SMALL)
|
||||
pCrvOffs->Invert() ;
|
||||
|
||||
// sistemo i raccordi
|
||||
if ( bClosed && bSquareMids) {
|
||||
// se curva è chiusa tutti i raccordi rispondono a bSquareMids
|
||||
IdentifyFillets( pCrvOffs, dOffs) ;
|
||||
AdjustCurveFillets( pCrvOffs, dOffs, ICurve::OFF_EXTEND) ;
|
||||
}
|
||||
else if ( ! bClosed && ( bSquareMids || bSquareEnds)) {
|
||||
// se curva è aperta devo distinguere i raccordi interni da quelli relativi agli estremi e
|
||||
// modificare solo quelli richiesti
|
||||
for ( int j = 0 ; j < pCrvOffs->GetCurveCount() ; j ++) {
|
||||
int nOrigCrv ; pCrvOffs->GetCurveTempProp( j, nOrigCrv) ;
|
||||
double dTmpParam ; pCrvOffs->GetCurveTempParam( j, dTmpParam) ;
|
||||
if ( nOrigCrv == 0 && ( ( bSquareMids && dTmpParam < EPS_SMALL) || ( bSquareEnds && dTmpParam > EPS_SMALL)))
|
||||
pCrvOffs->SetCurveTempParam( j, 1) ;
|
||||
else
|
||||
pCrvOffs->SetCurveTempParam( j, 0) ;
|
||||
}
|
||||
AdjustCurveFillets( pCrvOffs, dOffs, ICurve::OFF_EXTEND) ;
|
||||
}
|
||||
|
||||
// porto nel frame globale
|
||||
pCrvOffs->ToGlob( m_Frame) ;
|
||||
// unisco le parti allineate
|
||||
pCrvOffs->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG, true, true) ;
|
||||
// aggiungo al vettore finale
|
||||
vCrvs.emplace_back( pCrvOffs) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs, bool bRightOffs, bool bLeftOffs)
|
||||
{
|
||||
OffsList.clear() ;
|
||||
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
int nOrigCrvCnt = 1 ;
|
||||
if ( m_vpCrvs[0]->GetType() == CRV_COMPO) {
|
||||
const CurveComposite * pOrigCompo = GetBasicCurveComposite( m_vpCrvs[0]) ;
|
||||
if ( pOrigCompo == nullptr)
|
||||
return false ;
|
||||
nOrigCrvCnt = pOrigCompo->GetCurveCount() ;
|
||||
}
|
||||
|
||||
// reset di eventuali offset precedenti
|
||||
m_vroni->apiResetOffsetData() ;
|
||||
|
||||
// verifico necessario calcolo o ricalcolo di Voronoi
|
||||
UpdateVoronoi( dOffs) ;
|
||||
|
||||
string sTmp = "" ;
|
||||
m_vroni->apiComputeOff( false, &sTmp[0], false, false, dOffs, 0.0, false, bLeftOffs, bRightOffs) ;
|
||||
int nOffsCnt = m_vroni->GetOffsetCount() ;
|
||||
if ( nOffsCnt == 0) {
|
||||
// se non ho ottenuto offset ritento con valore leggermente diverso per le tolleranze di vroni
|
||||
m_vroni->apiResetOffsetData() ;
|
||||
m_vroni->apiComputeOff( false, &sTmp[0], false, false, dOffs - VRONI_OFFS_TOL, 0.0, false, bLeftOffs, bRightOffs) ;
|
||||
nOffsCnt = m_vroni->GetOffsetCount() ;
|
||||
}
|
||||
|
||||
// recupero le curve di offset da vroni
|
||||
for ( int i = 0 ; i < nOffsCnt ; i++) {
|
||||
PtrOwner<CurveComposite> pCrvOffs ( CreateBasicCurveComposite()) ;
|
||||
int nCrvCnt = m_vroni->GetOffsetCurveCount( i) ; // numero di sottocurve
|
||||
|
||||
for ( int j = 0 ; j < nCrvCnt ; j ++) {
|
||||
// recupero la sottocurva da vroni
|
||||
Point3d ptS, ptE, ptC ;
|
||||
int nType ;
|
||||
int nOrigCrv, nOrigLoop, nOrigPnt ; // sito
|
||||
m_vroni->GetOffsetCurve( i, j, nType, ptS.v, ptE.v, ptC.v, nOrigLoop, nOrigCrv, nOrigPnt) ;
|
||||
|
||||
if ( j == 0)
|
||||
pCrvOffs->AddPoint( ptS) ;
|
||||
|
||||
bool bOk = false ;
|
||||
if ( nType == t_site::SEG)
|
||||
bOk = pCrvOffs->AddLine( ptE) ;
|
||||
else {
|
||||
PtrOwner<CurveArc> pArc( CreateBasicCurveArc()) ;
|
||||
pArc->Set2PRS( ptS, ptE, Dist( ptC, ptS), nType == CCW) ;
|
||||
bOk = pCrvOffs->AddCurve( Release( pArc)) ;
|
||||
}
|
||||
|
||||
// se la curva è stata aggiunta
|
||||
if ( bOk) {
|
||||
// setto come info la sottocurva da cui si è generata
|
||||
int nCurrCrvId = pCrvOffs->GetCurveCount() - 1 ;
|
||||
pCrvOffs->SetCurveTempProp( nCurrCrvId, nOrigCrv + 1, 0) ;
|
||||
pCrvOffs->SetCurveTempProp( nCurrCrvId, nOrigLoop, 1) ;
|
||||
// verifico se è raccordo relativo agli estremi della curva
|
||||
if ( nOrigCrv == -1 && ( nOrigPnt == 0 || nOrigPnt == nOrigCrvCnt))
|
||||
pCrvOffs->SetCurveTempParam( nCurrCrvId, 1.0, 0) ;
|
||||
}
|
||||
}
|
||||
|
||||
// rimuovo tratti di lunghezza inferiore a 5 * EPS_SMALL
|
||||
RemoveCurveSmallParts( pCrvOffs, 5 * EPS_SMALL) ;
|
||||
|
||||
// aggiungo la curva alla lista degli offset
|
||||
if ( ! IsNull( pCrvOffs) && pCrvOffs->IsValid())
|
||||
OffsList.push_back( Release( pCrvOffs)) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::UpdateVoronoi( double dOffs)
|
||||
{
|
||||
double dNeededBound = abs( dOffs) / 0.49 / sqrt( m_bBox.GetDimX() * m_bBox.GetDimX() + m_bBox.GetDimY() * m_bBox.GetDimY()) ;
|
||||
if ( ! m_bVDComputed || dNeededBound > m_nBound) {
|
||||
// aggiorno il valore del bound
|
||||
int nBound = ( int)( ceil( dNeededBound) + 0.5) ;
|
||||
// calcolo il nuovo diagramma
|
||||
CalcVoronoi( nBound) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::VerifyCurvesValidityForOffset()
|
||||
{
|
||||
if ( m_vpCrvs.size() == 1)
|
||||
return true ;
|
||||
|
||||
// se ho più curve, devono essere tutte chiuse
|
||||
for ( auto pCrv : m_vpCrvs) {
|
||||
if ( ! pCrv->IsClosed())
|
||||
return false ;
|
||||
}
|
||||
|
||||
// verifico se gli orientamenti delle curve sono coerenti
|
||||
DBLVECTOR vArea( m_vpCrvs.size()) ;
|
||||
double dRefArea = 0.0 ;
|
||||
for ( int i = 0 ; i < ( int)m_vpCrvs.size() ; i ++) {
|
||||
m_vpCrvs[i]->GetAreaXY( vArea[i]) ;
|
||||
if ( abs( vArea[i]) > abs( dRefArea))
|
||||
dRefArea = vArea[i] ;
|
||||
}
|
||||
bool bRefCCW = ( dRefArea > EPS_SMALL) ;
|
||||
|
||||
for ( int i = 0 ; i < ( int)vArea.size() ; i++) {
|
||||
|
||||
// se curva con orientamento principale verifico sia esterna a tutte le altre curve con orientamento principale
|
||||
if ( vArea[i] * dRefArea > EPS_SMALL) {
|
||||
for ( int j = i + 1 ; j < ( int)vArea.size() ; j++) {
|
||||
if ( vArea[i] * vArea[j] > EPS_SMALL) {
|
||||
IntersCurveCurve ccInt( *m_vpCrvs[i], *m_vpCrvs[j]) ;
|
||||
int nRes = ccInt.GetRegionCurveClassification() ;
|
||||
if ( ( bRefCCW && nRes != CCREGC_OUT) || ( ! bRefCCW && nRes != CCREGC_IN1))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// se curva con orientamento diverso dal principale verifico sia contenuta in una curva con orientamento principale
|
||||
else if ( vArea[i] * dRefArea < - EPS_SMALL) {
|
||||
bool bInside = false ;
|
||||
for ( int j = 0 ; j < ( int)vArea.size() ; j++) {
|
||||
if ( j != i && vArea[j] * dRefArea > EPS_SMALL) {
|
||||
IntersCurveCurve ccInt( *m_vpCrvs[i], *m_vpCrvs[j]) ;
|
||||
int nRes = ccInt.GetRegionCurveClassification() ;
|
||||
if ( ( bRefCCW && nRes == CCREGC_IN1) || ( ! bRefCCW && nRes == CCREGC_OUT)) {
|
||||
bInside = true ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! bInside)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::AdjustOpenOffsetCurve( ICurveComposite& pCompo, double dOffs)
|
||||
{
|
||||
int nSideRef = dOffs < EPS_SMALL ? MDS_LEFT : MDS_RIGHT ;
|
||||
|
||||
// recupero i raccordi relativi agli estremi della curva aperta
|
||||
INTVECTOR vJunctions ;
|
||||
for ( int i = 0 ; i < pCompo.GetCurveCount() ; i++) {
|
||||
double dParTmp ;
|
||||
pCompo.GetCurveTempParam( i, dParTmp) ;
|
||||
if ( dParTmp > EPS_SMALL)
|
||||
vJunctions.push_back( i) ;
|
||||
}
|
||||
|
||||
if ( vJunctions.size() == 0) {
|
||||
// verifico se si trova dal lato corretto
|
||||
int nSide = GetOffsetCurveSide( pCompo, 0) ;
|
||||
if ( nSide != nSideRef)
|
||||
// se lato errato, tutta la curva va cancellata
|
||||
pCompo.Clear() ;
|
||||
}
|
||||
else if ( vJunctions.size() == 2) {
|
||||
// recupero i due tratti di curva
|
||||
PtrOwner<CurveComposite> pCompo1( ConvertCurveToBasicComposite( pCompo.CopyParamRange( vJunctions[0] + 1, vJunctions[1]))) ;
|
||||
PtrOwner<CurveComposite> pCompo2( ConvertCurveToBasicComposite( pCompo.CopyParamRange( vJunctions[1] + 1, vJunctions[0]))) ;
|
||||
pCompo.Clear() ;
|
||||
if ( ! IsNull( pCompo1) && pCompo1->IsValid()) {
|
||||
int nSide = GetOffsetCurveSide( *pCompo1, 0) ;
|
||||
if ( nSide == nSideRef)
|
||||
pCompo.CopyFrom( pCompo1) ;
|
||||
else if ( ! IsNull( pCompo2) && pCompo2->IsValid())
|
||||
pCompo.CopyFrom( pCompo2) ;
|
||||
}
|
||||
else if ( ! IsNull( pCompo2) && pCompo2->IsValid()) {
|
||||
int nSide = GetOffsetCurveSide( *pCompo2, 0) ;
|
||||
if ( nSide == nSideRef)
|
||||
pCompo.CopyFrom( pCompo2) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// mi posiziono dopo la junction
|
||||
pCompo.ChangeStartPoint( vJunctions[0] + 1) ;
|
||||
delete( pCompo.RemoveFirstOrLastCurve()) ;
|
||||
// verifico validità della curva
|
||||
int nSide = GetOffsetCurveSide( pCompo, 0) ;
|
||||
if ( nSide == nSideRef) {
|
||||
// scorro fino alla prima curva non valida ed elimino la curva da quel punto fino alla fine
|
||||
for ( int i = 1 ; i < pCompo.GetCurveCount() ; i++) {
|
||||
int nSide = GetOffsetCurveSide( pCompo, i) ;
|
||||
if ( nSide != nSideRef)
|
||||
pCompo.TrimEndAtParam( i) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// elimino finchè non trovo una curva valida
|
||||
while( nSide != nSideRef && pCompo.IsValid()) {
|
||||
delete( pCompo.RemoveFirstOrLastCurve( false)) ;
|
||||
if ( pCompo.IsValid())
|
||||
nSide = GetOffsetCurveSide( pCompo, 0) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int
|
||||
Voronoi::GetOffsetCurveSide( const ICurveComposite& pOffs, int nCrv)
|
||||
{
|
||||
Point3d ptM ; pOffs.GetCurve( nCrv)->GetMidPoint(ptM) ;
|
||||
int nOrigCrv ; pOffs.GetCurveTempProp( nCrv, nOrigCrv) ;
|
||||
|
||||
const ICurve* pCrvRef = m_vpCrvs[0] ;
|
||||
// se ha una sottocurva di riferimento
|
||||
if ( nOrigCrv != 0 && m_vpCrvs[0]->GetType() == CRV_COMPO) {
|
||||
const CurveComposite* pCompoOrig = GetBasicCurveComposite( m_vpCrvs[0]) ;
|
||||
if ( pCompoOrig != nullptr)
|
||||
pCrvRef = pCompoOrig->GetCurve( nOrigCrv - 1) ;
|
||||
}
|
||||
|
||||
DistPointCurve distPC( ptM, *pCrvRef) ;
|
||||
int nSide = MDS_ON ;
|
||||
distPC.GetSideAtMinDistPoint( 0, Z_AX, nSide) ;
|
||||
return nSide ;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::AdjustOffsetStart( ICurveComposite& pCrv)
|
||||
{
|
||||
for ( int i = 0 ; i < pCrv.GetCurveCount() ; i++) {
|
||||
// cerco il tratto associato alla prima curva originale
|
||||
int nProp ; pCrv.GetCurveTempProp( i, nProp) ;
|
||||
if ( nProp == 1) {
|
||||
pCrv.ChangeStartPoint( i) ;
|
||||
break ;
|
||||
}
|
||||
// oppure un raccordo di junction
|
||||
double dParam ; pCrv.GetCurveTempParam( i, dParam) ;
|
||||
if ( abs( dParam - 1) < EPS_SMALL) {
|
||||
pCrv.ChangeStartPoint( i + 1) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2023
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Voronoi.h Data : 23.11.23 Versione : 2.5k5
|
||||
// Contenuto : Dichiarazione della classe Voronoi con libreria VRONI
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 23.11.23 SP Creazione modulo.
|
||||
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkFrame3d.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/EGkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Extern/vroni/Include/vroni_object.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static const bool USE_VORONOI = true ;
|
||||
static const int VORONOI_STD_BOUND = 3 ;
|
||||
static const double VRONI_OFFS_TOL = 1e-9 ;
|
||||
|
||||
//-------------------------- Forward Definitions -------------------------------
|
||||
class ISurfFlatRegion ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class Voronoi
|
||||
{
|
||||
public :
|
||||
// costanti per il lato del medial axis
|
||||
enum WMATSide { WMAT_BOTHSIDES = 0,
|
||||
WMAT_LEFT = 1,
|
||||
WMAT_RIGHT = 2} ;
|
||||
public :
|
||||
Voronoi( void)
|
||||
: m_vroni( nullptr), m_nBound( VORONOI_STD_BOUND), m_bVDComputed( false), m_bAllowAdd( true) {} ;
|
||||
Voronoi( const ICurve* pCrv, bool bAllowAdd) ;
|
||||
Voronoi( const ISurfFlatRegion* pSfr, bool bAllowAdd) ;
|
||||
~Voronoi( void) ;
|
||||
|
||||
public :
|
||||
bool AddCurve( const ICurve* pCrv) ;
|
||||
bool AddSurfFlatRegion( const ISurfFlatRegion* pSfr) ;
|
||||
ICurve* GetCurve( int nId) const ;
|
||||
int GetCurveCount( void) const
|
||||
{ return m_vpCrvs.size() ; } ;
|
||||
bool CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound = VORONOI_STD_BOUND) ;
|
||||
bool CalcOffset( ICURVEPOVECTOR& vOffs, double dOffs, int nType) ;
|
||||
bool CalcFatCurve( ICURVEPOVECTOR& vOffs, double dOffs, bool bSquareEnds, bool bSquareMids) ;
|
||||
bool CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) ;
|
||||
|
||||
private :
|
||||
bool Clear( void) ;
|
||||
bool IsValid( void) const
|
||||
{ return m_vroni != nullptr ; } ;
|
||||
bool AddCurveToVroni( const ICurve * pCrv) ;
|
||||
bool AddLineToVroni( const ICurveLine* pLine, int& nVroniCrv, int nLoopId, int nCrvId = 0, Point3d ptForcedEnd = P_INVALID) ;
|
||||
bool AddArcToVroni( const ICurveArc* pArc, int& nVroniCrv, int nLoopId, int nCrvId = 0, Point3d ptForcedEnd = P_INVALID) ;
|
||||
bool AddCompoToVroni( const ICurveComposite* pCompo, int& nCrv, int nLoopId) ;
|
||||
bool AddBezierToVroni( const ICurveBezier* pBezier, int& nVroniCrv, int nLoopId) ;
|
||||
|
||||
bool CalcVoronoi( int nBound = VORONOI_STD_BOUND) ;
|
||||
bool CalcVroniOffset( ICRVCOMPOPLIST& vOffs, double dOffs, bool bRightOffs, bool bLeftOffs) ;
|
||||
bool UpdateVoronoi( double dOffs) ;
|
||||
bool VerifyCurvesValidityForOffset( void) ;
|
||||
bool AdjustOpenOffsetCurve( ICurveComposite& pCompo, double dOffs) ;
|
||||
bool AdjustOffsetStart( ICurveComposite& pCompo) ;
|
||||
int GetOffsetCurveSide( const ICurveComposite& pOffs, int nCrv) ;
|
||||
ICurve* GetBisectorCurve( int i) ;
|
||||
|
||||
private :
|
||||
vroniObject* m_vroni ; // oggetto base della libreria vroni
|
||||
Frame3d m_Frame ; // frame in cui è espresso l'oggetto vroni
|
||||
int m_nBound ; // bound associato al diagramma di Voronoi corrente
|
||||
CICURVEPVECTOR m_vpCrvs ; // curve associate al Voronoi ( espresse rispetto a m_Frame)
|
||||
BBox3d m_bBox ; // box degli oggetti associati al Voronoi
|
||||
bool m_bVDComputed ; // indica se il diagramma di Voronoi è stato calcolato
|
||||
bool m_bAllowAdd ; // indica se possibile aggiungere altre curve/superifici dopo aver creato l'oggetto Voronoi
|
||||
} ;
|
||||
@@ -263,11 +263,8 @@ void Earcut<N>::earcutLinked(Node* ear, int pass) {
|
||||
Node* prev;
|
||||
Node* next;
|
||||
|
||||
int iterations = 0;
|
||||
|
||||
// iterate through ears, slicing them one by one
|
||||
while (ear->prev != ear->next) {
|
||||
iterations++;
|
||||
prev = ear->prev;
|
||||
next = ear->next;
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "/EgtDev/Include/EgtLibVer.h"
|
||||
|
||||
#pragma comment(lib, EGTEXTDIR "zlib/Lib/zlib" EGTLIBVER ".lib")
|
||||
#pragma comment(lib, EGTEXTDIR "vroni/Lib/vroni" EGTLIBVER ".lib")
|
||||
#pragma comment(lib, EGTLIBDIR "EgtGeneral" EGTLIBVER ".lib")
|
||||
#pragma comment(lib, EGTLIBDIR "EgtNumKernel" EGTLIBVER ".lib")
|
||||
#pragma comment(lib, EGTLIBDIR "SEgtLock" EGTLIBVER ".lib")
|
||||
|
||||
Reference in New Issue
Block a user