EgtGeomKernel 1.5g1 :
- alle curve aggiunto il metodo CopyParamRange (per curve chiuse ammatte range che passano dal punto di chiusura) - trasformato il metodo Copy di tutti gli oggetti geometrici in CopyFrom - a TSC aggiunte funzioni CopyCurveByParamRange e SplitCurveByClass - migliorata gestione intersezioni sovrapposte - aggiunta classificazione parti di curva (IN,OUT,ONP,ONM) da intersezioni con altra curva chiusa.
This commit is contained in:
+41
-4
@@ -14,12 +14,14 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CurveArc.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "DistPointArc.h"
|
||||
#include "GeoConst.h"
|
||||
#include "GeoObjFactory.h"
|
||||
#include "NgeWriter.h"
|
||||
#include "NgeReader.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <new>
|
||||
|
||||
using namespace std ;
|
||||
@@ -416,7 +418,7 @@ CurveArc::Clone( void) const
|
||||
// alloco oggetto
|
||||
CurveArc* pCrv = new(nothrow) CurveArc ;
|
||||
if ( pCrv != nullptr) {
|
||||
if ( ! pCrv->Copy( *this)) {
|
||||
if ( ! pCrv->CopyFrom( *this)) {
|
||||
delete pCrv ;
|
||||
return nullptr ;
|
||||
}
|
||||
@@ -427,17 +429,17 @@ CurveArc::Clone( void) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveArc::Copy( const IGeoObj* pGObjSrc)
|
||||
CurveArc::CopyFrom( const IGeoObj* pGObjSrc)
|
||||
{
|
||||
const CurveArc* pCA = dynamic_cast<const CurveArc*>( pGObjSrc) ;
|
||||
if ( pCA == nullptr)
|
||||
return false ;
|
||||
return Copy( *pCA) ;
|
||||
return CopyFrom( *pCA) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveArc::Copy( const CurveArc& caSrc)
|
||||
CurveArc::CopyFrom( const CurveArc& caSrc)
|
||||
{
|
||||
if ( &caSrc == this)
|
||||
return true ;
|
||||
@@ -845,6 +847,37 @@ CurveArc::ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) cons
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
CurveArc::CopyParamRange( double dUStart, double dUEnd) const
|
||||
{
|
||||
// i parametri start ed end devono essere compresi nel dominio parametrico della curva
|
||||
if ( dUStart < - EPS_PARAM || dUStart > 1 + EPS_PARAM ||
|
||||
dUEnd < - EPS_PARAM || dUEnd > 1 + EPS_PARAM)
|
||||
return nullptr ;
|
||||
// se il parametro start supera quello di end
|
||||
if ( dUStart > dUEnd - EPS_PARAM) {
|
||||
// se curva aperta, il trim la cancella completamente quindi non resta alcunchè
|
||||
if ( ! IsClosed())
|
||||
return nullptr ;
|
||||
// se curva chiusa, il trim si avvolge attorno al punto di giunzione
|
||||
else {
|
||||
// eseguo la copia sulla curva composita equivalente
|
||||
CurveComposite cCompo ;
|
||||
cCompo.CopyFrom( this) ;
|
||||
return cCompo.CopyParamRange( dUStart, dUEnd) ;
|
||||
}
|
||||
}
|
||||
// creo l'arco copia
|
||||
PtrOwner<CurveArc> pCopy( Clone()) ;
|
||||
if ( ! ::IsValid( pCopy))
|
||||
return nullptr ;
|
||||
// eseguo il trim
|
||||
if ( ! pCopy->TrimStartEndAtParam( dUStart, dUEnd))
|
||||
return nullptr ;
|
||||
return ( ::Release( pCopy)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveArc::Invert( void)
|
||||
@@ -944,6 +977,10 @@ CurveArc::TrimEndAtParam( double dUTrim)
|
||||
bool
|
||||
CurveArc::TrimStartEndAtParam( double dUStartTrim, double dUEndTrim)
|
||||
{
|
||||
// i parametri start ed end devono essere compresi nel dominio parametrico della curva
|
||||
if ( dUStartTrim < - EPS_PARAM || dUStartTrim > 1 + EPS_PARAM ||
|
||||
dUEndTrim < - EPS_PARAM || dUEndTrim > 1 + EPS_PARAM)
|
||||
return false ;
|
||||
// verifico che i trim non cancellino interamente la curva
|
||||
if ( dUStartTrim > dUEndTrim - EPS_PARAM)
|
||||
return false ;
|
||||
|
||||
+4
-4
@@ -85,6 +85,7 @@ class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
return ::GetPointDiffGeom( *this, dU, nS, oDiffG) ; }
|
||||
virtual bool IsPointOn( const Point3d& ptP, double dTol = EPS_SMALL) const ;
|
||||
virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) const ;
|
||||
virtual ICurve* CopyParamRange( double dUStart, double dUEnd) const ;
|
||||
virtual bool Invert( void) ;
|
||||
virtual bool Offset( double dDist, int nSide, int nType = OFF_FILLET) ;
|
||||
virtual bool TrimStartAtParam( double dUTrim) ;
|
||||
@@ -94,7 +95,7 @@ class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
virtual bool TrimEndAtLen( double dLenTrim) ;
|
||||
|
||||
public : // ICurveArc
|
||||
virtual bool Copy( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool CopyFrom( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool Set( const Point3d& ptCen, const Vector3d& vtN, double dRad,
|
||||
const Vector3d& vtS, double dAngCenDeg, double dDeltaN) ;
|
||||
virtual bool Set( const Point3d& ptCen, const Vector3d& vtN, double dRad) ;
|
||||
@@ -137,13 +138,12 @@ class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
public :
|
||||
CurveArc( void) ;
|
||||
const CurveArc& operator =( const CurveArc& caSrc)
|
||||
{ if ( ! Copy( caSrc))
|
||||
{ if ( ! CopyFrom( caSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "CurveArc : copy error")
|
||||
return *this ; }
|
||||
|
||||
private :
|
||||
bool Copy( const CurveArc& caSrc) ;
|
||||
bool Copy( const ICurveArc& caSrc) ;
|
||||
bool CopyFrom( const CurveArc& caSrc) ;
|
||||
bool Validate( void) ;
|
||||
bool GetDir( double dU, Vector3d& vtDir) const ;
|
||||
|
||||
|
||||
+41
-4
@@ -14,6 +14,7 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CurveBezier.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "DistPointCrvBezier.h"
|
||||
#include "GeoConst.h"
|
||||
#include "DistPointLine.h"
|
||||
@@ -24,6 +25,7 @@
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/ENkPolynomial.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <new>
|
||||
|
||||
using namespace std ;
|
||||
@@ -271,7 +273,7 @@ CurveBezier::Clone( void) const
|
||||
// alloco oggetto
|
||||
CurveBezier* pCrv = new(nothrow) CurveBezier ;
|
||||
if ( pCrv != nullptr) {
|
||||
if ( ! pCrv->Copy( *this)) {
|
||||
if ( ! pCrv->CopyFrom( *this)) {
|
||||
delete pCrv ;
|
||||
return nullptr ;
|
||||
}
|
||||
@@ -282,17 +284,17 @@ CurveBezier::Clone( void) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveBezier::Copy( const IGeoObj* pGObjSrc)
|
||||
CurveBezier::CopyFrom( const IGeoObj* pGObjSrc)
|
||||
{
|
||||
const CurveBezier* pCB = dynamic_cast<const CurveBezier*>( pGObjSrc) ;
|
||||
if ( pCB == nullptr)
|
||||
return false ;
|
||||
return Copy( *pCB) ;
|
||||
return CopyFrom( *pCB) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveBezier::Copy( const CurveBezier& cbSrc)
|
||||
CurveBezier::CopyFrom( const CurveBezier& cbSrc)
|
||||
{
|
||||
if ( &cbSrc == this)
|
||||
return true ;
|
||||
@@ -1218,6 +1220,37 @@ CurveBezier::ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) c
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
CurveBezier::CopyParamRange( double dUStart, double dUEnd) const
|
||||
{
|
||||
// i parametri start ed end devono essere compresi nel dominio parametrico della curva
|
||||
if ( dUStart < - EPS_PARAM || dUStart > 1 + EPS_PARAM ||
|
||||
dUEnd < - EPS_PARAM || dUEnd > 1 + EPS_PARAM)
|
||||
return nullptr ;
|
||||
// se il parametro start supera quello di end
|
||||
if ( dUStart > dUEnd - EPS_PARAM) {
|
||||
// se curva aperta, il trim la cancella completamente quindi non resta alcunchè
|
||||
if ( ! IsClosed())
|
||||
return nullptr ;
|
||||
// se curva chiusa, il trim si avvolge attorno al punto di giunzione
|
||||
else {
|
||||
// eseguo la copia sulla curva composita equivalente
|
||||
CurveComposite cCompo ;
|
||||
cCompo.CopyFrom( this) ;
|
||||
return cCompo.CopyParamRange( dUStart, dUEnd) ;
|
||||
}
|
||||
}
|
||||
// creo la curva di Bezier copia
|
||||
PtrOwner<CurveBezier> pCopy( Clone()) ;
|
||||
if ( ! ::IsValid( pCopy))
|
||||
return nullptr ;
|
||||
// eseguo il trim
|
||||
if ( ! pCopy->TrimStartEndAtParam( dUStart, dUEnd))
|
||||
return nullptr ;
|
||||
return ( ::Release( pCopy)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveBezier::Invert( void)
|
||||
@@ -1312,6 +1345,10 @@ CurveBezier::TrimEndAtParam( double dUTrim)
|
||||
bool
|
||||
CurveBezier::TrimStartEndAtParam( double dUStartTrim, double dUEndTrim)
|
||||
{
|
||||
// i parametri start ed end devono essere compresi nel dominio parametrico della curva
|
||||
if ( dUStartTrim < - EPS_PARAM || dUStartTrim > 1 + EPS_PARAM ||
|
||||
dUEndTrim < - EPS_PARAM || dUEndTrim > 1 + EPS_PARAM)
|
||||
return false ;
|
||||
// verifico che i trim non cancellino interamente la curva
|
||||
if ( dUStartTrim > dUEndTrim - EPS_PARAM)
|
||||
return false ;
|
||||
|
||||
+4
-3
@@ -87,6 +87,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
return ::GetPointDiffGeom( *this, dU, nS, oDiffG) ; }
|
||||
virtual bool IsPointOn( const Point3d& ptP, double dTol = EPS_SMALL) const ;
|
||||
virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) const ;
|
||||
virtual ICurve* CopyParamRange( double dUStart, double dUEnd) const ;
|
||||
virtual bool Invert( void) ;
|
||||
virtual bool Offset( double dDist, int nSide, int nType = OFF_FILLET)
|
||||
{ return false ; }
|
||||
@@ -97,7 +98,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
virtual bool TrimEndAtLen( double dLenTrim) ;
|
||||
|
||||
public : // ICurveBezier
|
||||
virtual bool Copy( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool CopyFrom( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool Init( int nDeg, bool bIsRational) ;
|
||||
virtual bool SetControlPoint( int nInd, const Point3d& ptCtrl) ;
|
||||
virtual bool SetControlPoint( int nInd, const Point3d& ptCtrl, double dW) ;
|
||||
@@ -119,12 +120,12 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
public :
|
||||
CurveBezier( void) ;
|
||||
const CurveBezier& operator =( const CurveBezier& cbSrc)
|
||||
{ if ( ! Copy( cbSrc))
|
||||
{ if ( ! CopyFrom( cbSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "CurveBezier : copy error")
|
||||
return *this ; }
|
||||
|
||||
private :
|
||||
bool Copy( const CurveBezier& cbSrc) ;
|
||||
bool CopyFrom( const CurveBezier& cbSrc) ;
|
||||
bool Validate( void) ;
|
||||
bool GetPointD1D2( double dU, Point3d& ptPos,
|
||||
Vector3d* pvtDer1 = nullptr, Vector3d* pvtDer2 = nullptr) const ;
|
||||
|
||||
+80
-6
@@ -438,7 +438,7 @@ CurveComposite::Clone( void) const
|
||||
// alloco oggetto
|
||||
CurveComposite* pCrv = new(nothrow) CurveComposite ;
|
||||
if ( pCrv != nullptr) {
|
||||
if ( ! pCrv->Copy( *this)) {
|
||||
if ( ! pCrv->CopyFrom( *this)) {
|
||||
delete pCrv ;
|
||||
return nullptr ;
|
||||
}
|
||||
@@ -449,17 +449,25 @@ CurveComposite::Clone( void) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::Copy( const IGeoObj* pGObjSrc)
|
||||
CurveComposite::CopyFrom( const IGeoObj* pGObjSrc)
|
||||
{
|
||||
// se sorgente è una curva composita
|
||||
const CurveComposite* pCC = dynamic_cast<const CurveComposite*>( pGObjSrc) ;
|
||||
if ( pCC == nullptr)
|
||||
return false ;
|
||||
return Copy( *pCC) ;
|
||||
if ( pCC != nullptr)
|
||||
return CopyFrom( *pCC) ;
|
||||
// se sorgente è un'altro tipo di curva
|
||||
const ICurve* pCrv = dynamic_cast<const ICurve*>( pGObjSrc) ;
|
||||
if ( pCrv != nullptr) {
|
||||
Clear() ;
|
||||
return AddCurve( *pCrv) ;
|
||||
}
|
||||
// altrimenti errroe
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::Copy( const CurveComposite& ccSrc)
|
||||
CurveComposite::CopyFrom( const CurveComposite& ccSrc)
|
||||
{
|
||||
if ( &ccSrc == this)
|
||||
return true ;
|
||||
@@ -972,6 +980,48 @@ CurveComposite::ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
CurveComposite::CopyParamRange( double dUStart, double dUEnd) const
|
||||
{
|
||||
// i parametri start ed end devono essere compresi nel dominio parametrico della curva
|
||||
if ( dUStart < - EPS_PARAM || dUStart > m_nCounter + EPS_PARAM ||
|
||||
dUEnd < - EPS_PARAM || dUEnd > m_nCounter + EPS_PARAM)
|
||||
return nullptr ;
|
||||
// se il parametro start supera quello di end
|
||||
if ( dUStart > dUEnd - EPS_PARAM) {
|
||||
// se curva aperta, il trim la cancella completamente quindi non resta alcunchè
|
||||
if ( ! m_bClosed)
|
||||
return nullptr ;
|
||||
// se curva chiusa, il trim si avvolge attorno al punto di giunzione
|
||||
else
|
||||
// incremento il parametro finale della dimensione del dominio parametrico originale della curva
|
||||
dUEnd += m_nCounter ;
|
||||
}
|
||||
// determino gli indici della prima e dell'ultima curva da copiare
|
||||
int nIdStart = static_cast<int>( floor( dUStart)) ;
|
||||
int nIdEnd = static_cast<int>( ceil( dUEnd)) ;
|
||||
// creo la curva composita copia
|
||||
PtrOwner<CurveComposite> pCopy( new CurveComposite()) ;
|
||||
if ( ! ::IsValid( pCopy))
|
||||
return nullptr ;
|
||||
// eseguo la copia delle sole curve semplici necessarie
|
||||
for ( int i = nIdStart ; i < nIdEnd ; ++ i) {
|
||||
// quando supero il numero di curve nella composita originale riparto dall'inizio
|
||||
int j = i % m_nCounter ;
|
||||
// accodo la curva alla copia
|
||||
if ( ! pCopy->AddCurve( *(m_CrvSmplS[j])))
|
||||
return nullptr ;
|
||||
}
|
||||
// aggiorno i parametri di trim, tenendo conto delle curve semplici saltate all'inizio
|
||||
dUStart -= nIdStart ;
|
||||
dUEnd -= nIdStart ;
|
||||
// eseguo il trim della copia
|
||||
if ( ! pCopy->TrimStartEndAtParam( dUStart, dUEnd))
|
||||
return nullptr ;
|
||||
return ( ::Release( pCopy)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::Invert( void)
|
||||
@@ -1108,9 +1158,33 @@ CurveComposite::TrimEndAtParam( double dUTrim)
|
||||
bool
|
||||
CurveComposite::TrimStartEndAtParam( double dUStartTrim, double dUEndTrim)
|
||||
{
|
||||
// i parametri start ed end devono essere compresi nel dominio parametrico della curva
|
||||
if ( dUStartTrim < - EPS_PARAM || dUStartTrim > m_nCounter + EPS_PARAM ||
|
||||
dUEndTrim < - EPS_PARAM || dUEndTrim > m_nCounter + EPS_PARAM)
|
||||
return false ;
|
||||
// verifico che i trim non cancellino interamente la curva
|
||||
if ( dUStartTrim > dUEndTrim - EPS_PARAM)
|
||||
return false ;
|
||||
#if 0
|
||||
// se il parametro start supera quello di end
|
||||
if ( dUStartTrim > dUEndTrim - EPS_PARAM) {
|
||||
// se curva aperta, il trim la cancella completamente quindi errore
|
||||
if ( ! m_bClosed)
|
||||
return false ;
|
||||
// se curva chiusa, il trim interessa il punto di giunzione
|
||||
else {
|
||||
// calcolo il minimo numero di curve da accodare per coprire il range esteso
|
||||
int nNumCrv = static_cast<int>( ceil( dUEndTrim)) ;
|
||||
// incremento il parametro finale della dimensione del dominio parametrico originale della curva
|
||||
dUEndTrim += m_nCounter ;
|
||||
// eseguo accodamento delle curve
|
||||
for ( int i = 0 ; i < nNumCrv ; ++ i) {
|
||||
if ( ! AddCurve( *(m_CrvSmplS[i])))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// per parametro start : determino la curva di appartenenza e il valore locale del parametro
|
||||
int nCs ;
|
||||
double dUcs ;
|
||||
|
||||
+4
-3
@@ -86,6 +86,7 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
return ::GetPointDiffGeom( *this, dU, nS, oDiffG) ; }
|
||||
virtual bool IsPointOn( const Point3d& ptP, double dTol = EPS_SMALL) const ;
|
||||
virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) const ;
|
||||
virtual ICurve* CopyParamRange( double dUStart, double dUEnd) const ;
|
||||
virtual bool Invert( void) ;
|
||||
virtual bool Offset( double dDist, int nSide, int nType = OFF_FILLET)
|
||||
{ return false ; }
|
||||
@@ -96,7 +97,7 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
virtual bool TrimEndAtLen( double dLenTrim) ;
|
||||
|
||||
public : // ICurveComposite
|
||||
virtual bool Copy( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool CopyFrom( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool Clear( void) ;
|
||||
virtual bool AddCurve( const ICurve& cCrv, bool bEndOrStart = true) ;
|
||||
virtual bool AddCurve( ICurve* pCrv, bool bEndOrStart = true) ;
|
||||
@@ -125,12 +126,12 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
public :
|
||||
CurveComposite( void) ;
|
||||
const CurveComposite& operator =( const CurveComposite& ccSrc)
|
||||
{ if ( ! Copy( ccSrc))
|
||||
{ if ( ! CopyFrom( ccSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "CurveComposite : copy error")
|
||||
return *this ; }
|
||||
|
||||
private :
|
||||
bool Copy( const CurveComposite& ccSrc) ;
|
||||
bool CopyFrom( const CurveComposite& ccSrc) ;
|
||||
bool Validate( void) ;
|
||||
bool AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart = true) ;
|
||||
bool GetIndSCurveAndLocPar( double dU, Side nS, int& nSCrv, double& dLocU) const ;
|
||||
|
||||
+30
-5
@@ -19,6 +19,7 @@
|
||||
#include "NgeWriter.h"
|
||||
#include "NgeReader.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <new>
|
||||
|
||||
using namespace std ;
|
||||
@@ -95,7 +96,7 @@ CurveLine::Clone( void) const
|
||||
// alloco oggetto
|
||||
CurveLine* pCrv = new(nothrow) CurveLine ;
|
||||
if ( pCrv != nullptr) {
|
||||
if ( ! pCrv->Copy( *this)) {
|
||||
if ( ! pCrv->CopyFrom( *this)) {
|
||||
delete pCrv ;
|
||||
return nullptr ;
|
||||
}
|
||||
@@ -106,17 +107,17 @@ CurveLine::Clone( void) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveLine::Copy( const IGeoObj* pGObjSrc)
|
||||
CurveLine::CopyFrom( const IGeoObj* pGObjSrc)
|
||||
{
|
||||
const CurveLine* pCL = dynamic_cast<const CurveLine*>( pGObjSrc) ;
|
||||
if ( pCL == nullptr)
|
||||
return false ;
|
||||
return Copy( *pCL) ;
|
||||
return CopyFrom( *pCL) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveLine::Copy( const CurveLine& clSrc)
|
||||
CurveLine::CopyFrom( const CurveLine& clSrc)
|
||||
{
|
||||
if ( &clSrc == this)
|
||||
return true ;
|
||||
@@ -421,10 +422,30 @@ CurveLine::ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) con
|
||||
// inserisco gli estremi
|
||||
PL.AddUPoint( 0, m_PtStart) ;
|
||||
PL.AddUPoint( 1, m_PtEnd) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
CurveLine::CopyParamRange( double dUStart, double dUEnd) const
|
||||
{
|
||||
// i parametri start ed end devono essere compresi nel dominio parametrico della curva
|
||||
if ( dUStart < - EPS_PARAM || dUStart > 1 + EPS_PARAM ||
|
||||
dUEnd < - EPS_PARAM || dUEnd > 1 + EPS_PARAM)
|
||||
return nullptr ;
|
||||
// se il parametro start supera quello di end, essendo la linea una curva aperta, errore
|
||||
if ( dUStart > dUEnd - EPS_PARAM)
|
||||
return nullptr ;
|
||||
// creo la linea copia
|
||||
PtrOwner<CurveLine> pCopy( Clone()) ;
|
||||
if ( ! ::IsValid( pCopy))
|
||||
return nullptr ;
|
||||
// eseguo il trim
|
||||
if ( ! pCopy->TrimStartEndAtParam( dUStart, dUEnd))
|
||||
return nullptr ;
|
||||
return ( ::Release( pCopy)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveLine::Invert( void)
|
||||
@@ -507,6 +528,10 @@ CurveLine::TrimEndAtParam( double dUTrim)
|
||||
bool
|
||||
CurveLine::TrimStartEndAtParam( double dUStartTrim, double dUEndTrim)
|
||||
{
|
||||
// i parametri start ed end devono essere compresi nel dominio parametrico della curva
|
||||
if ( dUStartTrim < - EPS_PARAM || dUStartTrim > 1 + EPS_PARAM ||
|
||||
dUEndTrim < - EPS_PARAM || dUEndTrim > 1 + EPS_PARAM)
|
||||
return false ;
|
||||
// verifico che i trim non cancellino interamente la curva
|
||||
if ( dUStartTrim > dUEndTrim - EPS_PARAM)
|
||||
return false ;
|
||||
|
||||
+4
-3
@@ -85,6 +85,7 @@ class CurveLine : public ICurveLine, public IGeoObjRW
|
||||
return ::GetPointDiffGeom( *this, dU, nS, oDiffG) ; }
|
||||
virtual bool IsPointOn( const Point3d& ptP, double dTol = EPS_SMALL) const ;
|
||||
virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) const ;
|
||||
virtual ICurve* CopyParamRange( double dUStart, double dUEnd) const ;
|
||||
virtual bool Invert( void) ;
|
||||
virtual bool Offset( double dDist, int nSide, int nType = OFF_FILLET) ;
|
||||
virtual bool TrimStartAtParam( double dUTrim) ;
|
||||
@@ -94,7 +95,7 @@ class CurveLine : public ICurveLine, public IGeoObjRW
|
||||
virtual bool TrimEndAtLen( double dLenTrim) ;
|
||||
|
||||
public : // ICurveLine
|
||||
virtual bool Copy( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool CopyFrom( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool Set( const Point3d& ptStart, const Point3d& ptEnd) ;
|
||||
virtual bool SetPVL( const Point3d& ptStart, const Vector3d& vtDir, double dLen) ;
|
||||
virtual bool SetPDL( const Point3d& ptStart, double dDirAngDeg, double dLen) ;
|
||||
@@ -111,12 +112,12 @@ class CurveLine : public ICurveLine, public IGeoObjRW
|
||||
public :
|
||||
CurveLine( void) ;
|
||||
const CurveLine& operator =( const CurveLine& clSrc)
|
||||
{ if ( ! Copy( clSrc))
|
||||
{ if ( ! CopyFrom( clSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "CurveLine : copy error")
|
||||
return *this ; }
|
||||
|
||||
private :
|
||||
bool Copy( const CurveLine& clSrc) ;
|
||||
bool CopyFrom( const CurveLine& clSrc) ;
|
||||
bool Validate( void) ;
|
||||
|
||||
private :
|
||||
|
||||
Binary file not shown.
+4
-4
@@ -137,7 +137,7 @@ ExtText::Clone( void) const
|
||||
// alloco oggetto
|
||||
ExtText* pGPt = new(nothrow) ExtText ;
|
||||
if ( pGPt != nullptr) {
|
||||
if ( ! pGPt->Copy( *this)) {
|
||||
if ( ! pGPt->CopyFrom( *this)) {
|
||||
delete pGPt ;
|
||||
return nullptr ;
|
||||
}
|
||||
@@ -148,17 +148,17 @@ ExtText::Clone( void) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Copy( const IGeoObj* pGObjSrc)
|
||||
ExtText::CopyFrom( const IGeoObj* pGObjSrc)
|
||||
{
|
||||
const ExtText* pTxt = dynamic_cast<const ExtText*>( pGObjSrc) ;
|
||||
if ( pTxt == nullptr)
|
||||
return false ;
|
||||
return Copy( *pTxt) ;
|
||||
return CopyFrom( *pTxt) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Copy( const ExtText& clSrc)
|
||||
ExtText::CopyFrom( const ExtText& clSrc)
|
||||
{
|
||||
if ( &clSrc == this)
|
||||
return true ;
|
||||
|
||||
@@ -51,7 +51,7 @@ class ExtText : public IExtText, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
|
||||
public : // IExtText
|
||||
virtual bool Copy( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool CopyFrom( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool Set( const std::string& sText, const Point3d& ptP, double dAngDeg, double dH) ;
|
||||
virtual bool Set( const std::string& sText, const Point3d& ptP, double dAngDeg,
|
||||
const std::string& sFont, int nW, bool bItl, double dH, double dRat, double dAddAdv,
|
||||
@@ -103,12 +103,12 @@ class ExtText : public IExtText, public IGeoObjRW
|
||||
public :
|
||||
ExtText( void) ;
|
||||
const ExtText& operator =( const ExtText& gpSrc)
|
||||
{ if ( ! Copy( gpSrc))
|
||||
{ if ( ! CopyFrom( gpSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "ExtText : copy error")
|
||||
return *this ; }
|
||||
|
||||
private :
|
||||
bool Copy( const ExtText& gpSrc) ;
|
||||
bool CopyFrom( const ExtText& gpSrc) ;
|
||||
|
||||
private :
|
||||
static const int MAX_FONT_LEN = 125 ;
|
||||
|
||||
+155
-8
@@ -120,10 +120,14 @@ GdbExecutor::GdbExecutor( void)
|
||||
m_ExecMgr.Insert( "SHEAR", &GdbExecutor::ExecuteShear) ;
|
||||
m_ExecMgr.Insert( "INVC", &GdbExecutor::ExecuteInvertCurve) ;
|
||||
m_ExecMgr.Insert( "INVERTCURVE", &GdbExecutor::ExecuteInvertCurve) ;
|
||||
m_ExecMgr.Insert( "COPYC", &GdbExecutor::ExecuteCopyCurve) ;
|
||||
m_ExecMgr.Insert( "COPYCURVE", &GdbExecutor::ExecuteCopyCurve) ;
|
||||
m_ExecMgr.Insert( "INVS", &GdbExecutor::ExecuteInvertSurf) ;
|
||||
m_ExecMgr.Insert( "INVERTSURF", &GdbExecutor::ExecuteInvertSurf) ;
|
||||
m_ExecMgr.Insert( "TRC", &GdbExecutor::ExecuteTrimCurve) ;
|
||||
m_ExecMgr.Insert( "TRIMCURVE", &GdbExecutor::ExecuteTrimCurve) ;
|
||||
m_ExecMgr.Insert( "SPC", &GdbExecutor::ExecuteSplitCurve) ;
|
||||
m_ExecMgr.Insert( "SPLITCURVE", &GdbExecutor::ExecuteSplitCurve) ;
|
||||
m_ExecMgr.Insert( "NEW", &GdbExecutor::ExecuteNew) ;
|
||||
m_ExecMgr.Insert( "LOAD", &GdbExecutor::ExecuteLoad) ;
|
||||
m_ExecMgr.Insert( "SAVE", &GdbExecutor::ExecuteSave) ;
|
||||
@@ -726,7 +730,7 @@ GdbExecutor::CurveLineTgTwoArcs( const STRVECTOR& vsParams)
|
||||
PtrOwner<ICurveArc> pArc2Loc( CreateCurveArc()) ;
|
||||
if ( ! IsValid( pArc2Loc))
|
||||
return false ;
|
||||
pArc2Loc->Copy( pArc2) ;
|
||||
pArc2Loc->CopyFrom( pArc2) ;
|
||||
pArc2Loc->LocToLoc( frArc2, frArc1) ;
|
||||
// recupero il secondo punto vicino e lo porto nel riferimento del primo arco
|
||||
Point3d ptNear2 ;
|
||||
@@ -2642,7 +2646,7 @@ GdbExecutor::TextOutline( const STRVECTOR& vsParams)
|
||||
ICURVEPLIST::iterator iIter ;
|
||||
for ( iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) {
|
||||
(*iIter)->LocToLoc( frTXT, frDest) ;
|
||||
if ( ! m_pGDB->AddGeoObj( GDB_ID_NULL, nIdDest, (*iIter))) {
|
||||
if ( m_pGDB->AddGeoObj( GDB_ID_NULL, nIdDest, (*iIter)) == GDB_ID_NULL) {
|
||||
delete (*iIter) ;
|
||||
bOk = false ;
|
||||
}
|
||||
@@ -2712,12 +2716,21 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
// verifico siano 3 parti e le converto
|
||||
if ( vsParams.size() != 3)
|
||||
// se 2 parti, allora Z = 0
|
||||
if ( vsParams.size() == 2) {
|
||||
vtV.z = 0 ;
|
||||
return ( FromString( vsParams[0], vtV.x) &&
|
||||
FromString( vsParams[1], vtV.y)) ;
|
||||
}
|
||||
// se 3 parti
|
||||
else if ( vsParams.size() == 3) {
|
||||
return ( FromString( vsParams[0], vtV.x) &&
|
||||
FromString( vsParams[1], vtV.y) &&
|
||||
FromString( vsParams[2], vtV.z)) ;
|
||||
}
|
||||
// altrimenti errore
|
||||
else
|
||||
return false ;
|
||||
return ( FromString( vsParams[0], vtV.x) &&
|
||||
FromString( vsParams[1], vtV.y) &&
|
||||
FromString( vsParams[2], vtV.z)) ;
|
||||
}
|
||||
// se altrimenti vettore predefinito X_AX
|
||||
else if ( sParam == "X_AX") {
|
||||
@@ -4350,7 +4363,7 @@ GdbExecutor::ExecuteShear( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
bool
|
||||
GdbExecutor::ExecuteInvertCurve( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// 1 parametro ( Nome/i)
|
||||
// 1 parametro : Id/s
|
||||
if ( vsParams.size() != 1)
|
||||
return false ;
|
||||
// recupero lista nomi
|
||||
@@ -4368,6 +4381,50 @@ GdbExecutor::ExecuteInvertCurve( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecuteCopyCurve( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
if ( sCmd2 == "PR" || sCmd2 == "PARAMRANGE")
|
||||
return CopyCurveByParamRange( vsParams) ;
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::CopyCurveByParamRange( const STRVECTOR& vsParams)
|
||||
{
|
||||
// 5 parametri : IdCrv, IdDest, IdGroupDest, StartPar, EndPar
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero la curva sorgente
|
||||
int nIdCrv = GetIdParam( vsParams[0]) ;
|
||||
const ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nIdCrv)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
// recupero il suo riferimento
|
||||
Frame3d frCrv ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdCrv, frCrv))
|
||||
return false ;
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frDest ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[2]), frDest))
|
||||
return false ;
|
||||
// recupero i parametri del range
|
||||
double dUStart, dUEnd ;
|
||||
if ( ! FromString( vsParams[3], dUStart) ||
|
||||
! FromString( vsParams[4], dUEnd))
|
||||
return false ;
|
||||
// copio la parte di curva che interessa e la porto nel riferimento del gruppo destinazione
|
||||
PtrOwner<ICurve> pCopy( pCrv->CopyParamRange( dUStart, dUEnd)) ;
|
||||
if ( ! ::IsValid( pCopy))
|
||||
return false ;
|
||||
pCopy->LocToLoc( frCrv, frDest) ;
|
||||
// la inserisco nel gruppo
|
||||
return AddGeoObj( vsParams[1], vsParams[2], ::Release( pCopy)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecuteInvertSurf( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
@@ -4461,6 +4518,96 @@ GdbExecutor::ExecuteTrimCurve( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecuteSplitCurve( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
if ( sCmd2 == "C" || sCmd2 == "CLASS")
|
||||
return SplitCurveByClass( vsParams) ;
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::SplitCurveByClass( const STRVECTOR& vsParams)
|
||||
{
|
||||
// 6 parametri : IdCurve, IdClosedCurve, IdGroupIn, IdGroupOut, IdGroupOnP, IdGroupOnM
|
||||
if ( vsParams.size() != 6)
|
||||
return false ;
|
||||
// recupero l'indice delle due curve
|
||||
int nIdCrv = GetIdParam( vsParams[0]) ;
|
||||
int nIdCloCrv = GetIdParam( vsParams[1]) ;
|
||||
// verifico siano due curve
|
||||
const ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nIdCrv)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
const ICurve* pCloCrv = GetCurve( m_pGDB->GetGeoObj( nIdCloCrv)) ;
|
||||
if ( pCloCrv == nullptr)
|
||||
return false ;
|
||||
// verifico che la seconda sia chiusa
|
||||
if ( ! pCloCrv->IsClosed())
|
||||
return false ;
|
||||
// recupero i riferimenti in cui sono immerse
|
||||
Frame3d frCrv ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdCrv, frCrv))
|
||||
return false ;
|
||||
Frame3d frCloCrv ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdCloCrv, frCloCrv))
|
||||
return false ;
|
||||
// se i riferimenti sono diversi, porto la seconda curva nel riferimento della prima
|
||||
PtrOwner<ICurve> crvTrans( nullptr) ;
|
||||
if ( ! AreSameFrame( frCrv, frCloCrv)) {
|
||||
crvTrans.Set( pCloCrv->Clone()) ;
|
||||
if ( ! ::IsValid( crvTrans))
|
||||
return false ;
|
||||
crvTrans->LocToLoc( frCloCrv, frCrv) ;
|
||||
pCloCrv = ::Get( crvTrans) ;
|
||||
}
|
||||
// calcolo le intersezioni tra le due curve
|
||||
IntersCurveCurve intCC( *pCrv, *pCloCrv, true) ;
|
||||
// recupero la classificazione della prima curva
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( ! intCC.GetCurveClassification( 0, ccClass))
|
||||
return false ;
|
||||
// recupero gli indici dei gruppi destinazione e i loro riferimenti
|
||||
const int N_GRP = 4 ;
|
||||
int nIdGrp[N_GRP] ; // 0->IN, 1->OUT, 2->ON_P, 3->ON_M
|
||||
Frame3d frGrp[N_GRP] ;
|
||||
for ( int j = 0 ; j < N_GRP ; ++ j) {
|
||||
nIdGrp[j] = GetIdParam( vsParams[j+2]) ;
|
||||
if ( nIdGrp[j] >= GDB_ID_ROOT && ! m_pGDB->GetGroupGlobFrame( nIdGrp[j], frGrp[j]))
|
||||
return false ;
|
||||
}
|
||||
// copio gli split nei diversi gruppi
|
||||
for ( int i = 0 ; i < int( ccClass.size()) ; ++ i) {
|
||||
// recupero indice di gruppo
|
||||
int nGrp ;
|
||||
switch ( ccClass[i].nClass) {
|
||||
case CRVC_IN : nGrp = 0 ; break ;
|
||||
case CRVC_OUT : nGrp = 1 ; break ;
|
||||
case CRVC_ON_P : nGrp = 2 ; break ;
|
||||
case CRVC_ON_M : nGrp = 3 ; break ;
|
||||
default : return false ;
|
||||
}
|
||||
// se gruppo non richiesto, vado oltre
|
||||
if ( nIdGrp[nGrp] < GDB_ID_ROOT)
|
||||
continue ;
|
||||
// se curva praticamente nulla, vado oltre
|
||||
if ( fabs( ccClass[i].dParS - ccClass[i].dParE) < 10 * EPS_PARAM)
|
||||
continue ;
|
||||
// copio la parte di curva che interessa e la porto nel riferimento del gruppo
|
||||
PtrOwner<ICurve> pSplit( pCrv->CopyParamRange( ccClass[i].dParS, ccClass[i].dParE)) ;
|
||||
if ( ! ::IsValid( pSplit))
|
||||
return false ;
|
||||
pSplit->LocToLoc( frCrv, frGrp[nGrp]) ;
|
||||
// la inserisco nel gruppo
|
||||
if ( m_pGDB->AddGeoObj( GDB_ID_NULL, nIdGrp[nGrp], ::Release( pSplit)) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecuteNew( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
|
||||
@@ -133,8 +133,12 @@ class GdbExecutor : public IGdbExecutor
|
||||
bool ExecuteMirror( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteShear( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteInvertCurve( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteCopyCurve( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool CopyCurveByParamRange( const STRVECTOR& vsParams) ;
|
||||
bool ExecuteInvertSurf( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteTrimCurve( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteSplitCurve( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool SplitCurveByClass( const STRVECTOR& vsParams) ;
|
||||
bool ExecuteNew( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteLoad( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteSave( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
|
||||
+2
-5
@@ -45,16 +45,13 @@ GdbGeo::~GdbGeo( void)
|
||||
GdbGeo*
|
||||
GdbGeo::Clone( int nId, IdManager& IdMgr) const
|
||||
{
|
||||
GdbGeo* pGdbGeo ;
|
||||
|
||||
|
||||
// alloco oggetto Gdb
|
||||
pGdbGeo = new(nothrow) GdbGeo ;
|
||||
GdbGeo* pGdbGeo = new(nothrow) GdbGeo ;
|
||||
if ( pGdbGeo == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
// copio dati oggetto Gdb
|
||||
pGdbGeo->GdbObj::Copy( this) ;
|
||||
pGdbGeo->GdbObj::CopyFrom( this) ;
|
||||
|
||||
// assegno nuovo Id
|
||||
pGdbGeo->m_nId = nId ;
|
||||
|
||||
+2
-3
@@ -59,13 +59,12 @@ GdbGroup*
|
||||
GdbGroup::Clone( int nId, IdManager& IdMgr) const
|
||||
{
|
||||
// alloco gruppo Gdb
|
||||
GdbGroup* pGdbGroup ;
|
||||
pGdbGroup = new(nothrow) GdbGroup ;
|
||||
GdbGroup* pGdbGroup = new(nothrow) GdbGroup ;
|
||||
if ( pGdbGroup == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
// copio dati oggetto Gdb
|
||||
pGdbGroup->GdbObj::Copy( this) ;
|
||||
pGdbGroup->GdbObj::CopyFrom( this) ;
|
||||
|
||||
// assegno nuovo Id
|
||||
pGdbGroup->m_nId = nId ;
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ GdbObj::~GdbObj( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbObj::Copy( const GdbObj* pSou)
|
||||
GdbObj::CopyFrom( const GdbObj* pSou)
|
||||
{
|
||||
// elimino eventuali attributi pre-esistenti
|
||||
if ( m_pAttribs != nullptr)
|
||||
|
||||
@@ -47,7 +47,7 @@ class GdbObj
|
||||
|
||||
public :
|
||||
GdbObj( void) ;
|
||||
bool Copy( const GdbObj* pSou) ;
|
||||
bool CopyFrom( const GdbObj* pSou) ;
|
||||
|
||||
public :
|
||||
bool SaveAttribs( NgeWriter& ngeOut) const ;
|
||||
|
||||
+4
-4
@@ -86,7 +86,7 @@ GeoFrame3d::Clone( void) const
|
||||
// alloco oggetto
|
||||
GeoFrame3d* pGFr = new(nothrow) GeoFrame3d ;
|
||||
if ( pGFr != nullptr) {
|
||||
if ( ! pGFr->Copy( *this)) {
|
||||
if ( ! pGFr->CopyFrom( *this)) {
|
||||
delete pGFr ;
|
||||
return nullptr ;
|
||||
}
|
||||
@@ -97,17 +97,17 @@ GeoFrame3d::Clone( void) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeoFrame3d::Copy( const IGeoObj* pGObjSrc)
|
||||
GeoFrame3d::CopyFrom( const IGeoObj* pGObjSrc)
|
||||
{
|
||||
const GeoFrame3d* pGFr = dynamic_cast<const GeoFrame3d*>( pGObjSrc) ;
|
||||
if ( pGFr == nullptr)
|
||||
return false ;
|
||||
return Copy( *pGFr) ;
|
||||
return CopyFrom( *pGFr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeoFrame3d::Copy( const GeoFrame3d& gfSrc)
|
||||
GeoFrame3d::CopyFrom( const GeoFrame3d& gfSrc)
|
||||
{
|
||||
if ( &gfSrc == this)
|
||||
return true ;
|
||||
|
||||
+3
-3
@@ -61,7 +61,7 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
|
||||
public : // IGeoFrame3d
|
||||
virtual bool Copy( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool CopyFrom( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool Set( const Point3d& ptOrig, const Vector3d& vtDirX,
|
||||
const Vector3d& vtDirY, const Vector3d& vtDirZ) ;
|
||||
virtual bool Set( const Point3d& ptOrig, const Point3d& ptOnX, const Point3d& ptNearY) ;
|
||||
@@ -80,12 +80,12 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW
|
||||
public :
|
||||
GeoFrame3d( void) ;
|
||||
inline const GeoFrame3d& operator =( const GeoFrame3d& gfSrc)
|
||||
{ if ( ! Copy( gfSrc))
|
||||
{ if ( ! CopyFrom( gfSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "GeoFrame3d : copy error")
|
||||
return *this ; }
|
||||
|
||||
private :
|
||||
bool Copy( const GeoFrame3d& gfSrc) ;
|
||||
bool CopyFrom( const GeoFrame3d& gfSrc) ;
|
||||
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
|
||||
+4
-4
@@ -56,7 +56,7 @@ GeoPoint3d::Clone( void) const
|
||||
// alloco oggetto
|
||||
GeoPoint3d* pGPt = new(nothrow) GeoPoint3d ;
|
||||
if ( pGPt != nullptr) {
|
||||
if ( ! pGPt->Copy( *this)) {
|
||||
if ( ! pGPt->CopyFrom( *this)) {
|
||||
delete pGPt ;
|
||||
return nullptr ;
|
||||
}
|
||||
@@ -67,17 +67,17 @@ GeoPoint3d::Clone( void) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeoPoint3d::Copy( const IGeoObj* pGObjSrc)
|
||||
GeoPoint3d::CopyFrom( const IGeoObj* pGObjSrc)
|
||||
{
|
||||
const GeoPoint3d* pGP = dynamic_cast<const GeoPoint3d*>( pGObjSrc) ;
|
||||
if ( pGP == nullptr)
|
||||
return false ;
|
||||
return Copy( *pGP) ;
|
||||
return CopyFrom( *pGP) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeoPoint3d::Copy( const GeoPoint3d& clSrc)
|
||||
GeoPoint3d::CopyFrom( const GeoPoint3d& clSrc)
|
||||
{
|
||||
if ( &clSrc == this)
|
||||
return true ;
|
||||
|
||||
+3
-3
@@ -59,7 +59,7 @@ class GeoPoint3d : public IGeoPoint3d, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
|
||||
public : // IGeoPoint3d
|
||||
virtual bool Copy( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool CopyFrom( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool Set( const Point3d& ptP) ;
|
||||
virtual const Point3d& GetPoint( void) const
|
||||
{ return m_ptP ; }
|
||||
@@ -72,12 +72,12 @@ class GeoPoint3d : public IGeoPoint3d, public IGeoObjRW
|
||||
public :
|
||||
GeoPoint3d( void) ;
|
||||
const GeoPoint3d& operator =( const GeoPoint3d& gpSrc)
|
||||
{ if ( ! Copy( gpSrc))
|
||||
{ if ( ! CopyFrom( gpSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "GeoPoint3d : copy error")
|
||||
return *this ; }
|
||||
|
||||
private :
|
||||
bool Copy( const GeoPoint3d& gpSrc) ;
|
||||
bool CopyFrom( const GeoPoint3d& gpSrc) ;
|
||||
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
|
||||
+4
-4
@@ -72,7 +72,7 @@ GeoVector3d::Clone( void) const
|
||||
// alloco oggetto
|
||||
GeoVector3d* pGVt = new(nothrow) GeoVector3d ;
|
||||
if ( pGVt != nullptr) {
|
||||
if ( ! pGVt->Copy( *this)) {
|
||||
if ( ! pGVt->CopyFrom( *this)) {
|
||||
delete pGVt ;
|
||||
return nullptr ;
|
||||
}
|
||||
@@ -83,17 +83,17 @@ GeoVector3d::Clone( void) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeoVector3d::Copy( const IGeoObj* pGObjSrc)
|
||||
GeoVector3d::CopyFrom( const IGeoObj* pGObjSrc)
|
||||
{
|
||||
const GeoVector3d* pGV = dynamic_cast<const GeoVector3d*>( pGObjSrc) ;
|
||||
if ( pGV == nullptr)
|
||||
return false ;
|
||||
return Copy( *pGV) ;
|
||||
return CopyFrom( *pGV) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeoVector3d::Copy( const GeoVector3d& clSrc)
|
||||
GeoVector3d::CopyFrom( const GeoVector3d& clSrc)
|
||||
{
|
||||
if ( &clSrc == this)
|
||||
return true ;
|
||||
|
||||
+3
-3
@@ -60,7 +60,7 @@ class GeoVector3d : public IGeoVector3d, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
|
||||
public : // IGeoVector3d
|
||||
virtual bool Copy( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool CopyFrom( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool Set( const Vector3d& vtV) ;
|
||||
virtual bool Set( const Vector3d& vtV, const Point3d& ptBase) ;
|
||||
virtual const Vector3d& GetVector( void) const
|
||||
@@ -78,12 +78,12 @@ class GeoVector3d : public IGeoVector3d, public IGeoObjRW
|
||||
public :
|
||||
GeoVector3d( void) ;
|
||||
inline const GeoVector3d& operator =( const GeoVector3d& gvSrc)
|
||||
{ if ( ! Copy( gvSrc))
|
||||
{ if ( ! CopyFrom( gvSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "GeoVector3d : copy error")
|
||||
return *this ; }
|
||||
|
||||
private :
|
||||
bool Copy( const GeoVector3d& gvSrc) ;
|
||||
bool CopyFrom( const GeoVector3d& gvSrc) ;
|
||||
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
|
||||
+102
-45
@@ -22,18 +22,53 @@ using namespace std ;
|
||||
bool
|
||||
SortGreater( const IntCrvCrvInfo& aInfo1, const IntCrvCrvInfo& aInfo2)
|
||||
{
|
||||
double dU1 = ( aInfo1.bOverlap ? 0.5 * ( aInfo1.IciA[0].dU + aInfo1.IciA[1].dU) : aInfo1.IciA[0].dU) ;
|
||||
double dU2 = ( aInfo2.bOverlap ? 0.5 * ( aInfo2.IciA[0].dU + aInfo2.IciA[1].dU) : aInfo2.IciA[0].dU) ;
|
||||
double dU1, dU2 ;
|
||||
// determino il primo termine del confronto
|
||||
dU1 = aInfo1.IciA[0].dU ;
|
||||
if ( aInfo1.bOverlap) {
|
||||
// caso normale
|
||||
if ( aInfo1.IciA[0].dU < aInfo1.IciA[1].dU)
|
||||
dU1 = 0.5 * ( aInfo1.IciA[0].dU + aInfo1.IciA[1].dU) ;
|
||||
// a cavallo di fine / inizio
|
||||
else
|
||||
dU1 = aInfo1.IciA[0].dU + SPAN_PARAM ;
|
||||
}
|
||||
// determino il secondo termine del confronto
|
||||
dU2 = aInfo2.IciA[0].dU ;
|
||||
if ( aInfo2.bOverlap) {
|
||||
// caso normale
|
||||
if ( aInfo2.IciA[0].dU < aInfo2.IciA[1].dU)
|
||||
dU2 = 0.5 * ( aInfo2.IciA[0].dU + aInfo2.IciA[1].dU) ;
|
||||
// a cavallo di fine / inizio
|
||||
else
|
||||
dU2 = aInfo2.IciA[0].dU + SPAN_PARAM ;
|
||||
}
|
||||
|
||||
return ( dU2 > dU1 + EPS_PARAM) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
bool
|
||||
SameParamsAB( const ICurveComposite& CCompoA, const IntCrvCrvInfo& Icci1,
|
||||
const ICurveComposite& CCompoB, const IntCrvCrvInfo& Icci2)
|
||||
{
|
||||
int k = ( Icci1.bOverlap ? 1 : 0) ; // del precedente si prende il secondo se overlap
|
||||
if ( fabs( Icci1.IciA[k].dU - Icci2.IciA[0].dU) > 0.1 * SPAN_PARAM &&
|
||||
( ! CCompoA.IsClosed() || fabs( fabs( Icci1.IciA[k].dU - Icci2.IciA[0].dU) - CCompoA.GetCurveNumber()) > 0.1 * SPAN_PARAM))
|
||||
return false ;
|
||||
if ( fabs( Icci1.IciB[k].dU - Icci2.IciB[0].dU) > 0.1 * SPAN_PARAM &&
|
||||
( ! CCompoB.IsClosed() || fabs( fabs( Icci1.IciB[k].dU - Icci2.IciB[0].dU) - CCompoB.GetCurveNumber()) > 0.1 * SPAN_PARAM))
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static void
|
||||
MediaParamPoints( IntCrvInfo& Ici1, IntCrvInfo& Ici2)
|
||||
{
|
||||
// medio i parametri e i punti
|
||||
// per non mediare i parametri tra gli estremi di curva chiusa
|
||||
if ( fabs( Ici1.dU - Ici2.dU) < HSPAN_PARAM) {
|
||||
if ( fabs( Ici1.dU - Ici2.dU) < 0.1 * SPAN_PARAM) {
|
||||
Ici1.dU = 0.5 * ( Ici1.dU + Ici2.dU) ;
|
||||
Ici2.dU = Ici1.dU ;
|
||||
}
|
||||
@@ -44,7 +79,7 @@ MediaParamPoints( IntCrvInfo& Ici1, IntCrvInfo& Ici2)
|
||||
//----------------------------------------------------------------------------
|
||||
// Prev della curva B ma tenendo conto della direzione di A
|
||||
// => se controverse va preso Next
|
||||
int
|
||||
static int
|
||||
GetCrvBDirAPrev( IntCrvCrvInfo& Icci)
|
||||
{
|
||||
// non è overlap, è il prev del primo punto
|
||||
@@ -60,7 +95,7 @@ GetCrvBDirAPrev( IntCrvCrvInfo& Icci)
|
||||
//----------------------------------------------------------------------------
|
||||
// Next della curva B ma tenendo conto della direzione di A
|
||||
// => se controverse va preso Prev
|
||||
int
|
||||
static int
|
||||
GetCrvBDirANext( IntCrvCrvInfo& Icci)
|
||||
{
|
||||
// non è overlap, è il next del primo punto
|
||||
@@ -74,7 +109,7 @@ GetCrvBDirANext( IntCrvCrvInfo& Icci)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
static bool
|
||||
CalcATypeFromDisk( const ICurveComposite& CCompoA, double dUA, ICurve::Side nSideA,
|
||||
const ICurveComposite& CCompoB, double dUB, int& nType)
|
||||
{
|
||||
@@ -137,7 +172,7 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
for ( const ICurve* pCrvB = CCompoB.GetFirstCurve() ;
|
||||
pCrvB != nullptr ;
|
||||
pCrvB = CCompoB.GetNextCurve(), ++ nCountB) {
|
||||
// eseguo l'intersezione di queste curve elementari
|
||||
// eseguo l'intersezione di queste curve semplici
|
||||
IntersCurveCurve intCC( *pCrvA, *pCrvB) ;
|
||||
// ne recupero i risultati
|
||||
int nCurrInters = intCC.GetNumInters() ;
|
||||
@@ -164,24 +199,17 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
|
||||
// sistemazione di intersezioni coincidenti
|
||||
for ( int i = 0 ; i < m_nNumInters ; ++ i) {
|
||||
// calcolo indice precedente
|
||||
int j = i - 1 ;
|
||||
if ( i == 0) {
|
||||
// se prima curva aperta, salto alla prossima
|
||||
if ( ! CCompoA.IsClosed())
|
||||
continue ;
|
||||
// è chiusa quindi prendo l'ultima
|
||||
j = m_nNumInters - 1 ;
|
||||
}
|
||||
// se i due indici coincidono, c'è una sola intersezione e posso uscire
|
||||
for ( int j = 0 ; j < m_nNumInters ; ++ j) {
|
||||
// se i due indici coincidono, passo oltre
|
||||
if ( i == j)
|
||||
break ;
|
||||
continue ;
|
||||
// calcolo sottoindici
|
||||
int ki = 0 ; // del successivo si prende sempre il primo
|
||||
int kj = ( m_Info[j].bOverlap ? 1 : 0) ; // del precedente si prende il secondo se overlap
|
||||
// verifico se precedente e corrente si riferiscono alla stessa intersezione (10 * EPS_SMALL)
|
||||
if ( SqDist( m_Info[i].IciA[ki].ptI, m_Info[j].IciA[kj].ptI) < ( 100 * EPS_SMALL * EPS_SMALL) &&
|
||||
SqDist( m_Info[i].IciB[ki].ptI, m_Info[j].IciB[kj].ptI) < ( 100 * EPS_SMALL * EPS_SMALL)) {
|
||||
SqDist( m_Info[i].IciB[ki].ptI, m_Info[j].IciB[kj].ptI) < ( 100 * EPS_SMALL * EPS_SMALL) &&
|
||||
SameParamsAB( CCompoA, m_Info[j], CCompoB, m_Info[i])) {
|
||||
// caso DET-NULL -> NULL-DET per prima curva
|
||||
if ( m_Info[j].IciA[kj].nPrevTy != ICCT_NULL && m_Info[j].IciA[kj].nNextTy == ICCT_NULL &&
|
||||
m_Info[i].IciA[ki].nPrevTy == ICCT_NULL && m_Info[i].IciA[ki].nNextTy != ICCT_NULL) {
|
||||
@@ -217,10 +245,13 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
if ( m_Info[j].bOverlap && m_Info[i].bOverlap)
|
||||
continue ;
|
||||
// cancello un singolo
|
||||
int k = ( ! m_Info[i].bOverlap ? i : j) ;
|
||||
m_Info.erase( m_Info.begin() + k) ;
|
||||
-- i ;
|
||||
-- m_nNumInters ;
|
||||
if ( m_Info[i].bOverlap) {
|
||||
EraseOtherInfo( i, j) ;
|
||||
}
|
||||
else {
|
||||
EraseCurrentInfo( i, j) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
// caso NULL-DET -> DET-NULL per prima curva (possibile su inizio/fine di curva chiusa)
|
||||
else if ( m_Info[j].IciA[kj].nPrevTy == ICCT_NULL && m_Info[j].IciA[kj].nNextTy != ICCT_NULL &&
|
||||
@@ -259,10 +290,13 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
if ( m_Info[j].bOverlap && m_Info[i].bOverlap)
|
||||
continue ;
|
||||
// cancello un singolo
|
||||
int k = ( ! m_Info[i].bOverlap ? i : j) ;
|
||||
m_Info.erase( m_Info.begin() + k) ;
|
||||
-- i ;
|
||||
-- m_nNumInters ;
|
||||
if ( m_Info[i].bOverlap) {
|
||||
EraseOtherInfo( i, j) ;
|
||||
}
|
||||
else {
|
||||
EraseCurrentInfo( i, j) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
// caso DET-NULL -> NULL-DET per seconda curva
|
||||
else if ( m_Info[j].IciB[kj].nPrevTy != ICCT_NULL && m_Info[j].IciB[kj].nNextTy == ICCT_NULL &&
|
||||
@@ -301,10 +335,13 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
if ( m_Info[j].bOverlap && m_Info[i].bOverlap)
|
||||
continue ;
|
||||
// cancello un singolo
|
||||
int k = ( ! m_Info[i].bOverlap ? i : j) ;
|
||||
m_Info.erase( m_Info.begin() + k) ;
|
||||
-- i ;
|
||||
-- m_nNumInters ;
|
||||
if ( m_Info[i].bOverlap) {
|
||||
EraseOtherInfo( i, j) ;
|
||||
}
|
||||
else {
|
||||
EraseCurrentInfo( i, j) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
// caso NULL-DET -> DET-NULL per seconda curva (possibile su inizio/fine di curva chiusa)
|
||||
else if ( m_Info[j].IciB[kj].nPrevTy == ICCT_NULL && m_Info[j].IciB[kj].nNextTy != ICCT_NULL &&
|
||||
@@ -343,29 +380,27 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
if ( m_Info[j].bOverlap && m_Info[i].bOverlap)
|
||||
continue ;
|
||||
// cancello un singolo
|
||||
int k = ( ! m_Info[i].bOverlap ? i : j) ;
|
||||
m_Info.erase( m_Info.begin() + k) ;
|
||||
-- i ;
|
||||
-- m_nNumInters ;
|
||||
if ( m_Info[i].bOverlap) {
|
||||
EraseOtherInfo( i, j) ;
|
||||
}
|
||||
else {
|
||||
EraseCurrentInfo( i, j) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
// caso NULL-NULL per corrente di prima curva
|
||||
else if ( m_Info[i].IciA[ki].nPrevTy == ICCT_NULL && m_Info[i].IciA[ki].nNextTy == ICCT_NULL) {
|
||||
// cancello l'intersezione corrente (non aggiunge nulla rispetto alla precedente)
|
||||
m_Info.erase( m_Info.begin() + i) ;
|
||||
-- i ;
|
||||
-- m_nNumInters ;
|
||||
EraseCurrentInfo( i, j) ;
|
||||
break ;
|
||||
}
|
||||
// caso NULL-NULL per precedente di prima curva
|
||||
else if ( m_Info[j].IciA[kj].nPrevTy == ICCT_NULL && m_Info[j].IciA[kj].nNextTy == ICCT_NULL) {
|
||||
// cancello l'intersezione precedente (non aggiunge nulla rispetto alla corrente)
|
||||
m_Info.erase( m_Info.begin() + j) ;
|
||||
if ( j < i)
|
||||
i -= 2 ;
|
||||
else
|
||||
-- i ;
|
||||
-- m_nNumInters ;
|
||||
EraseOtherInfo( i, j) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// verifico se sono rimaste delle intersezioni di tipo non definito e cerco di risolverle
|
||||
@@ -502,3 +537,25 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersCrvCompoCrvCompo::EraseCurrentInfo( int& nIndCurr, int& nIndOther)
|
||||
{
|
||||
m_Info.erase( m_Info.begin() + nIndCurr) ;
|
||||
-- nIndCurr ;
|
||||
-- m_nNumInters ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersCrvCompoCrvCompo::EraseOtherInfo( int& nIndCurr, int& nIndOther)
|
||||
{
|
||||
m_Info.erase( m_Info.begin() + nIndOther) ;
|
||||
if ( nIndOther < nIndCurr)
|
||||
-- nIndCurr ;
|
||||
-- nIndOther ;
|
||||
-- m_nNumInters ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ class IntersCrvCompoCrvCompo
|
||||
|
||||
private :
|
||||
IntersCrvCompoCrvCompo( void) ;
|
||||
bool EraseCurrentInfo( int& nIndCurr, int& nIndOther) ;
|
||||
bool EraseOtherInfo( int& nIndCurr, int& nIndOther) ;
|
||||
|
||||
private :
|
||||
bool m_bOverlaps ;
|
||||
@@ -45,3 +47,6 @@ class IntersCrvCompoCrvCompo
|
||||
ICCIVECTOR m_Info ;
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Per ordinare le info di intersezione secondo il parametro crescente (con stable_sort)
|
||||
bool SortGreater( const IntCrvCrvInfo& aInfo1, const IntCrvCrvInfo& aInfo2) ;
|
||||
|
||||
+224
-17
@@ -15,17 +15,20 @@
|
||||
#include "stdafx.h"
|
||||
#include "IntersLineLine.h"
|
||||
#include "IntersCrvCompoCrvCompo.h"
|
||||
#include "CurveLine.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurveCurve.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGtPointerOwner.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
IntersCurveCurve::IntersCurveCurve( const ICurve& Curve1, const ICurve& Curve2, bool bIsSegment)
|
||||
IntersCurveCurve::IntersCurveCurve( const ICurve& CurveA, const ICurve& CurveB, bool bAreSegments)
|
||||
{
|
||||
// Le intersezioni sono calcolate nel piano XY locale.
|
||||
// Il flag bIsSegment vale solo per linee.
|
||||
// Il flag bAreSegments vale solo per intersezione tra due linee e riguarda entrambe.
|
||||
|
||||
// reset
|
||||
m_bOverlaps = false ;
|
||||
@@ -34,17 +37,18 @@ IntersCurveCurve::IntersCurveCurve( const ICurve& Curve1, const ICurve& Curve2,
|
||||
m_pCurve[1] = nullptr ;
|
||||
|
||||
// chiamo calcolatore opportuno
|
||||
switch ( Curve1.GetType()) {
|
||||
switch ( CurveA.GetType()) {
|
||||
case CRV_LINE :
|
||||
switch ( Curve2.GetType()) {
|
||||
switch ( CurveB.GetType()) {
|
||||
case CRV_LINE :
|
||||
LineLineCalculate( Curve1, Curve2, bIsSegment) ;
|
||||
LineLineCalculate( CurveA, CurveB, bAreSegments) ;
|
||||
break ;
|
||||
case CRV_ARC :
|
||||
break ;
|
||||
case CRV_BEZ :
|
||||
break ;
|
||||
case CRV_COMPO :
|
||||
LineCrvCompoCalculate( CurveA, CurveB) ;
|
||||
break ;
|
||||
}
|
||||
break ;
|
||||
@@ -53,30 +57,31 @@ IntersCurveCurve::IntersCurveCurve( const ICurve& Curve1, const ICurve& Curve2,
|
||||
case CRV_BEZ :
|
||||
break ;
|
||||
case CRV_COMPO :
|
||||
switch ( Curve2.GetType()) {
|
||||
switch ( CurveB.GetType()) {
|
||||
case CRV_LINE :
|
||||
CrvCompoLineCalculate( CurveA, CurveB) ;
|
||||
break ;
|
||||
case CRV_ARC :
|
||||
break ;
|
||||
case CRV_BEZ :
|
||||
break ;
|
||||
case CRV_COMPO :
|
||||
CrvCompoCrvCompoCalculate( Curve1, Curve2) ;
|
||||
CrvCompoCrvCompoCalculate( CurveA, CurveB) ;
|
||||
break ;
|
||||
}
|
||||
break ;
|
||||
}
|
||||
|
||||
// salvo i puntatori alle curve
|
||||
m_pCurve[0] = &Curve1 ;
|
||||
m_pCurve[1] = &Curve2 ;
|
||||
m_pCurve[0] = &CurveA ;
|
||||
m_pCurve[1] = &CurveB ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
IntersCurveCurve::LineLineCalculate( const ICurve& Curve1, const ICurve& Curve2, bool bIsSegment)
|
||||
IntersCurveCurve::LineLineCalculate( const ICurve& CurveA, const ICurve& CurveB, bool bAreSegments)
|
||||
{
|
||||
IntersLineLine intLnLn( *GetCurveLine( &Curve1), *GetCurveLine( &Curve2), bIsSegment) ;
|
||||
IntersLineLine intLnLn( *GetCurveLine( &CurveA), *GetCurveLine( &CurveB), bAreSegments) ;
|
||||
|
||||
if ( intLnLn.m_nNumInters > 0) {
|
||||
m_bOverlaps = intLnLn.m_bOverlaps ;
|
||||
@@ -88,9 +93,31 @@ IntersCurveCurve::LineLineCalculate( const ICurve& Curve1, const ICurve& Curve2,
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
IntersCurveCurve::CrvCompoCrvCompoCalculate( const ICurve& Curve1, const ICurve& Curve2)
|
||||
IntersCurveCurve::LineCrvCompoCalculate( const ICurve& CurveA, const ICurve& CurveB)
|
||||
{
|
||||
IntersCrvCompoCrvCompo intCcCc( *GetCurveComposite( &Curve1), *GetCurveComposite( &Curve2)) ;
|
||||
// trasformo la linea in curva composita
|
||||
CurveComposite crvCompo ;
|
||||
crvCompo.CopyFrom( &CurveA) ;
|
||||
// eseguo l'intersezione tra curve composite
|
||||
CrvCompoCrvCompoCalculate( crvCompo, CurveB) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
IntersCurveCurve::CrvCompoLineCalculate( const ICurve& CurveA, const ICurve& CurveB)
|
||||
{
|
||||
// trasformo la linea in curva composita
|
||||
CurveComposite crvCompo ;
|
||||
crvCompo.CopyFrom( &CurveB) ;
|
||||
// eseguo l'intersezione tra curve composite
|
||||
CrvCompoCrvCompoCalculate( CurveA, crvCompo) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
IntersCurveCurve::CrvCompoCrvCompoCalculate( const ICurve& CurveA, const ICurve& CurveB)
|
||||
{
|
||||
IntersCrvCompoCrvCompo intCcCc( *GetCurveComposite( &CurveA), *GetCurveComposite( &CurveB)) ;
|
||||
|
||||
if ( intCcCc.m_nNumInters > 0) {
|
||||
m_bOverlaps = intCcCc.m_bOverlaps ;
|
||||
@@ -160,12 +187,9 @@ IntersCurveCurve::GetIntersPointNearTo( int nCrv, const Point3d& ptNear, Point3d
|
||||
if ( ! m_Info[i].bCBOverEq)
|
||||
swap( dUStartTrim, dUEndTrim) ;
|
||||
}
|
||||
// !!! sistemare per curva chiusa con tratto che attraversa fine/inizio !!!
|
||||
PtrOwner<ICurve> pCrv( m_pCurve[nCrv]->Clone()) ;
|
||||
PtrOwner<ICurve> pCrv( m_pCurve[nCrv]->CopyParamRange( dUStartTrim, dUEndTrim)) ;
|
||||
if ( ! ::IsValid( pCrv))
|
||||
continue ;
|
||||
if ( ! pCrv->TrimStartEndAtParam( dUStartTrim, dUEndTrim))
|
||||
continue ;
|
||||
// cerco il punto
|
||||
int nFlag ;
|
||||
Point3d ptP ;
|
||||
@@ -183,3 +207,186 @@ IntersCurveCurve::GetIntersPointNearTo( int nCrv, const Point3d& ptNear, Point3d
|
||||
|
||||
return bFound ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersCurveCurve::GetCurveClassification( int nCrv, CRVCVECTOR& ccClass)
|
||||
{
|
||||
// pulisco vettore classificazioni
|
||||
ccClass.clear() ;
|
||||
|
||||
// verifico definizione delle due curve
|
||||
if ( m_pCurve[0] == nullptr || m_pCurve[1] == nullptr)
|
||||
return false ;
|
||||
|
||||
// se richiesta classificazione della curva A
|
||||
if ( nCrv == 0) {
|
||||
// la curva rispetto a cui si classifica deve essere chiusa
|
||||
if ( ! m_pCurve[1]->IsClosed())
|
||||
return false ;
|
||||
// se esiste almeno una intersezione
|
||||
if ( m_nNumInters >= 1)
|
||||
return CalcCurveClassification( m_pCurve[0], m_Info, ccClass) ;
|
||||
// altrimenti la curva è completamente interna oppure completamente esterna
|
||||
else
|
||||
return CalcCurveInOrOut( m_pCurve[0], m_pCurve[1], ccClass) ;
|
||||
}
|
||||
// se richiesta classificazione della curva B
|
||||
else if ( nCrv == 1) {
|
||||
// la curva rispetto a cui si classifica deve essere chiusa
|
||||
if ( ! m_pCurve[0]->IsClosed())
|
||||
return false ;
|
||||
// devo scambiare opportunamente le info di intersezione tra A e B
|
||||
// copia temporanea delle info di intersezione
|
||||
ICCIVECTOR InfoTmp = m_Info ;
|
||||
// eseguo lo scambio
|
||||
for ( int i = 0 ; i < m_nNumInters ; ++ i) {
|
||||
// scambio le informazioni tra A e B
|
||||
swap( InfoTmp[i].IciA[0], InfoTmp[i].IciB[0]) ;
|
||||
swap( InfoTmp[i].IciA[1], InfoTmp[i].IciB[1]) ;
|
||||
// riordino eventuali sovrapposizioni controverse
|
||||
if ( InfoTmp[i].bOverlap && ! InfoTmp[i].bCBOverEq) {
|
||||
swap( InfoTmp[i].IciA[0], InfoTmp[i].IciA[1]) ;
|
||||
swap( InfoTmp[i].IciB[0], InfoTmp[i].IciB[1]) ;
|
||||
}
|
||||
}
|
||||
// ordino le intersezioni secondo l'ordine crescente del parametro della prima curva
|
||||
stable_sort( InfoTmp.begin(), InfoTmp.end(), SortGreater) ;
|
||||
// se esiste almeno una intersezione
|
||||
if ( m_nNumInters >= 1)
|
||||
return CalcCurveClassification( m_pCurve[1], InfoTmp, ccClass) ;
|
||||
// altrimenti la curva è completamente interna oppure completamente esterna
|
||||
else
|
||||
return CalcCurveInOrOut( m_pCurve[1], m_pCurve[0], ccClass) ;
|
||||
}
|
||||
// altrimenti errore
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersCurveCurve::CalcCurveClassification( const ICurve* pCurve, const ICCIVECTOR& Info, CRVCVECTOR& ccClass)
|
||||
{
|
||||
// numero intersezioni
|
||||
int nNumInters = int( Info.size()) ;
|
||||
if ( nNumInters < 1)
|
||||
return false ;
|
||||
// recupero il dominio parametrico della curva in esame
|
||||
double dStartPar, dEndPar ;
|
||||
if ( pCurve == nullptr || ! pCurve->GetDomain( dStartPar, dEndPar))
|
||||
return false ;
|
||||
// recupero la classificazione all'inizio della curva
|
||||
int nLastTy = ICCT_NULL ;
|
||||
double dCurrPar = dStartPar ;
|
||||
// se è chiusa, recupero come finisce
|
||||
if ( pCurve->IsClosed()) {
|
||||
if ( ! Info[nNumInters-1].bOverlap)
|
||||
nLastTy = Info[nNumInters-1].IciA[0].nNextTy ;
|
||||
else {
|
||||
nLastTy = Info[nNumInters-1].IciA[1].nNextTy ;
|
||||
// se attraversa il punto di giunzione (parametro di fine minore di quello di inizio)
|
||||
if ( Info[nNumInters-1].IciA[1].dU < Info[nNumInters-1].IciA[0].dU) {
|
||||
dCurrPar = Info[nNumInters-1].IciA[1].dU ;
|
||||
dEndPar = dCurrPar ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// costruisco il vettore delle classificazioni
|
||||
for ( int i = 0 ; i < nNumInters ; ++ i) {
|
||||
// se è definito un tratto precedente
|
||||
if ( Info[i].IciA[0].dU > dCurrPar + EPS_PARAM) {
|
||||
// verifico che la definizione sul tratto sia omogenea e valida
|
||||
int nPrevTy = Info[i].IciA[0].nPrevTy ;
|
||||
if ( ( nLastTy != ICCT_NULL && nPrevTy != nLastTy) ||
|
||||
nPrevTy == ICCT_NULL || nPrevTy == ICCT_ON)
|
||||
return false ;
|
||||
// assegno i dati
|
||||
CrvClass segClass ;
|
||||
segClass.dParS = dCurrPar ;
|
||||
segClass.dParE = Info[i].IciA[0].dU ;
|
||||
segClass.nClass = (( nPrevTy == ICCT_IN) ? CRVC_IN : CRVC_OUT) ;
|
||||
ccClass.push_back( segClass) ;
|
||||
// salvo dati correnti
|
||||
dCurrPar = Info[i].IciA[0].dU ;
|
||||
nLastTy = Info[i].IciA[0].nNextTy ;
|
||||
}
|
||||
// se è definito un tratto in sovrapposizione
|
||||
if ( Info[i].bOverlap) {
|
||||
// assegno i dati
|
||||
CrvClass segClass ;
|
||||
segClass.dParS = dCurrPar ;
|
||||
segClass.dParE = Info[i].IciA[1].dU ;
|
||||
segClass.nClass = ( Info[i].bCBOverEq ? CRVC_ON_P : CRVC_ON_M) ;
|
||||
ccClass.push_back( segClass) ;
|
||||
// salvo dati correnti
|
||||
dCurrPar = Info[i].IciA[1].dU ;
|
||||
nLastTy = Info[i].IciA[1].nNextTy ;
|
||||
}
|
||||
}
|
||||
// eventuale tratto finale rimasto
|
||||
if ( dCurrPar < dEndPar - EPS_PARAM) {
|
||||
// verifico che la definizione sul tratto sia valida
|
||||
if ( nLastTy == ICCT_NULL || nLastTy == ICCT_ON)
|
||||
return false ;
|
||||
// assegno i dati
|
||||
CrvClass segClass ;
|
||||
segClass.dParS = dCurrPar ;
|
||||
segClass.dParE = dEndPar ;
|
||||
segClass.nClass = (( nLastTy == ICCT_IN) ? CRVC_IN : CRVC_OUT) ;
|
||||
ccClass.push_back( segClass) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersCurveCurve::CalcCurveInOrOut( const ICurve* pCurveA, const ICurve* pCurveB, CRVCVECTOR& ccClass)
|
||||
{
|
||||
// recupero il dominio parametrico della curva A
|
||||
double dStartPar, dEndPar ;
|
||||
if ( ! pCurveA->GetDomain( dStartPar, dEndPar))
|
||||
return false ;
|
||||
// se i box delle due curve non interferiscono è sicuramente esterna
|
||||
BBox3d boxCrvA, boxCrvB ;
|
||||
if ( ! pCurveA->GetLocalBBox( boxCrvA) ||
|
||||
! pCurveB->GetLocalBBox( boxCrvB))
|
||||
return false ;
|
||||
if ( ! boxCrvA.OverlapsXY( boxCrvB)) {
|
||||
// assegno i dati
|
||||
CrvClass segClass ;
|
||||
segClass.dParS = dStartPar ;
|
||||
segClass.dParE = dEndPar ;
|
||||
segClass.nClass = CRVC_OUT ;
|
||||
ccClass.push_back( segClass) ;
|
||||
return true ;
|
||||
}
|
||||
// intersezione tra una semiretta parallela a X dal punto iniziale della curva A e la curva B
|
||||
// costruisco la linea
|
||||
Point3d ptStart ;
|
||||
if ( ! pCurveA->GetStartPoint( ptStart))
|
||||
return false ;
|
||||
double dLen = boxCrvB.GetMax().x - boxCrvB.GetMin().x + 1. ;
|
||||
CurveLine clLine ;
|
||||
if ( ! clLine.SetPDL( ptStart, 0, dLen))
|
||||
return false ;
|
||||
// calcolo l'intersezione
|
||||
IntersCurveCurve iCC( clLine, *pCurveB) ;
|
||||
// dichiaro la curva esterna per default
|
||||
int nClass = CRVC_OUT ;
|
||||
// se c'è almeno una intersezione
|
||||
if ( iCC.GetNumInters() > 0) {
|
||||
// se quanto precede la prima intersezione è interno, allora la curva è interna
|
||||
IntCrvCrvInfo aInfo ;
|
||||
iCC.GetIntCrvCrvInfo( 0, aInfo) ;
|
||||
if ( aInfo.IciA[0].nPrevTy == ICCT_IN)
|
||||
nClass = CRVC_IN ;
|
||||
}
|
||||
// assegno i dati
|
||||
CrvClass segClass ;
|
||||
segClass.dParS = dStartPar ;
|
||||
segClass.dParE = dEndPar ;
|
||||
segClass.nClass = nClass ;
|
||||
ccClass.push_back( segClass) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
+4
-4
@@ -324,7 +324,7 @@ SurfTriMesh::Clone( void) const
|
||||
// alloco oggetto
|
||||
SurfTriMesh* pStm = new(nothrow) SurfTriMesh ;
|
||||
if ( pStm != nullptr) {
|
||||
if ( ! pStm->Copy( *this)) {
|
||||
if ( ! pStm->CopyFrom( *this)) {
|
||||
delete pStm ;
|
||||
return nullptr ;
|
||||
}
|
||||
@@ -335,17 +335,17 @@ SurfTriMesh::Clone( void) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::Copy( const IGeoObj* pGObjSrc)
|
||||
SurfTriMesh::CopyFrom( const IGeoObj* pGObjSrc)
|
||||
{
|
||||
const SurfTriMesh* pStm = dynamic_cast<const SurfTriMesh*>( pGObjSrc) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
return Copy( *pStm) ;
|
||||
return CopyFrom( *pStm) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::Copy( const SurfTriMesh& stmSrc)
|
||||
SurfTriMesh::CopyFrom( const SurfTriMesh& stmSrc)
|
||||
{
|
||||
if ( &stmSrc == this)
|
||||
return true ;
|
||||
|
||||
+3
-3
@@ -93,7 +93,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
virtual bool Invert( void) ;
|
||||
|
||||
public : // ISurfTriMesh
|
||||
virtual bool Copy( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool CopyFrom( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool Init( int nNumVert, int nNumTria) ;
|
||||
virtual void SetLinearTolerance( double dLinTol)
|
||||
{ m_dLinTol = std::max( dLinTol, EPS_SMALL) ; }
|
||||
@@ -137,12 +137,12 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
public :
|
||||
SurfTriMesh( void) ;
|
||||
const SurfTriMesh& operator =( const SurfTriMesh& stSrc)
|
||||
{ if ( ! Copy( stSrc))
|
||||
{ if ( ! CopyFrom( stSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "SurfTriMesh : copy error")
|
||||
return *this ; }
|
||||
|
||||
private :
|
||||
bool Copy( const SurfTriMesh& clSrc) ;
|
||||
bool CopyFrom( const SurfTriMesh& clSrc) ;
|
||||
bool Validate( void) ;
|
||||
bool AdjustAdjacencies( void) ;
|
||||
bool AdjustOrientations( int nLev, bool& bSomeWrong) ;
|
||||
|
||||
Reference in New Issue
Block a user