EgtGeomKernel 1.5f6 :

- agg. intersezione linee-linee
- agg. alle curve metodi per passare da lunghezza a parametro e viceversa
- agg. metodi per creare curve composite come poligoni regolari
- corr. errore in triangulate con contorni CW
- agg. opportune funzioni a TSC.
This commit is contained in:
Dario Sassi
2014-06-24 07:05:43 +00:00
parent 4097bcd178
commit f119a5a1be
21 changed files with 1347 additions and 129 deletions
+179 -14
View File
@@ -33,6 +33,7 @@
#include "/EgtDev/Include/EgkCurveBezier.h"
#include "/EgtDev/Include/EgkCurveComposite.h"
#include "/EgtDev/Include/EgkDistPointCurve.h"
#include "/EgtDev/Include/EgkIntersCurveCurve.h"
#include "/EgtDev/Include/EgkSurfTriMesh.h"
#include "/EgtDev/Include/EgkExtText.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
@@ -41,8 +42,14 @@
using namespace std ;
//----------------------------------------------------------------------------
// Per Id di entità
static const int ID_SEL = -2 ;
static const int ID_NO = -3 ;
// Per tipo di costruzione di poligono
static const int POLYG_INSCR = 1 ;
static const int POLYG_CIRC = 2 ;
static const int POLYG_SIDE = 3 ;
//----------------------------------------------------------------------------
IGdbExecutor*
@@ -1523,9 +1530,30 @@ GdbExecutor::ExecuteCurveCompo( const string& sCmd2, const STRVECTOR& vsParams)
// creazione da split di curva semplice
else if ( sCmd2 == "S" || sCmd2 == "FROMSPLIT")
return CurveCompoFromSplit( vsParams) ;
// modifica per aggiunta di una curva
else if ( sCmd2 == "ADD" || sCmd2 == "ADDCURVE")
return CurveCompoAddCurve( vsParams) ;
// creazione come poligono inscritto
else if ( sCmd2 == "POLYGIN" || sCmd2 == "FROMPOLYGONINSCRIBED")
return CurveCompoFromPolygon( vsParams, POLYG_INSCR) ;
// creazione come poligono circoscritto
else if ( sCmd2 == "POLYGCIRC" || sCmd2 == "FROMPOLYGONCIRCUMSCRIBED")
return CurveCompoFromPolygon( vsParams, POLYG_CIRC) ;
// creazione come poligono dato il lato
else if ( sCmd2 == "POLYGSIDE" || sCmd2 == "FROMPOLYGONSIDE")
return CurveCompoFromPolygon( vsParams, POLYG_SIDE) ;
// modifica per aggiunta di una curva alla fine
else if ( sCmd2 == "AEC" || sCmd2 == "ADDENDCURVE")
return CurveCompoAddCurve( vsParams, true) ;
// modifica per aggiunta di una curva all'inizio
else if ( sCmd2 == "ASC" || sCmd2 == "ADDSTARTCURVE")
return CurveCompoAddCurve( vsParams, false) ;
// modifica per estrazione della curva finale
else if ( sCmd2 == "EEC" || sCmd2 == "EXTRACTENDCURVE")
return CurveCompoExtractCurve( vsParams, true) ;
// modifica per estrazione della curva iniziale
else if ( sCmd2 == "ESC" || sCmd2 == "EXTRACTSTARTCURVE")
return CurveCompoExtractCurve( vsParams, false) ;
// cambio punto di partenza (se chiusa)
else if ( sCmd2 == "CS" || sCmd2 == "CHANGESTART")
return CurveCompoChangeStart( vsParams) ;
// altrimenti errore
else
return false ;
@@ -1696,10 +1724,8 @@ GdbExecutor::CurveCompoFromSplit( const STRVECTOR& vsParams)
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
return false ;
// porto la curva composita dal riferimento della sorgente a quello di inserimento
if ( ! AreSameFrame( frSou, frDest)) {
pCrvCompo->ToGlob( frSou) ;
pCrvCompo->ToLoc( frDest) ;
}
if ( ! AreSameFrame( frSou, frDest))
pCrvCompo->LocToLoc( frSou, frDest) ;
// inserisco la curva composita nel DB
if ( AddGeoObj( vsParams[0], vsParams[1], Release( pCrvCompo))) {
@@ -1716,7 +1742,56 @@ GdbExecutor::CurveCompoFromSplit( const STRVECTOR& vsParams)
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveCompoAddCurve( const STRVECTOR& vsParams)
GdbExecutor::CurveCompoFromPolygon( const STRVECTOR& vsParams, int nType)
{
// 5 parametri : Id, IdParent, NumLati, ptP1, ptP2
if ( vsParams.size() != 5)
return false ;
// recupero il numero di lati
int nNumLati ;
if ( ! FromString( vsParams[2], nNumLati))
return false ;
// recupero il riferimento in cui è immerso
Frame3d frRef ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
return false ;
// recupero punto P1
Point3d ptP1 ;
if ( ! GetPointParam( vsParams[3], frRef, ptP1))
return false ;
// recupero punto P2
Point3d ptP2 ;
if ( ! GetPointParam( vsParams[4], frRef, ptP2))
return false ;
// creo la curva composita
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
if ( ! IsValid( pCrvCompo))
return false ;
// costruisco il poligono
switch ( nType) {
case POLYG_INSCR :
if ( ! pCrvCompo->PolygonCenterCorner( nNumLati, ptP1, ptP2))
return false ;
break ;
case POLYG_CIRC :
if ( ! pCrvCompo->PolygonCenterMidSide( nNumLati, ptP1, ptP2))
return false ;
break ;
case POLYG_SIDE :
if ( ! pCrvCompo->PolygonSide( nNumLati, ptP1, ptP2))
return false ;
break ;
default :
return false ;
break ;
}
// inserisco la linea nel DB
return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvCompo)) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveCompoAddCurve( const STRVECTOR& vsParams, bool bEndOrStart)
{
// per eventuale cancellazione curva da accodare
bool bErase ;
@@ -1737,7 +1812,7 @@ GdbExecutor::CurveCompoAddCurve( const STRVECTOR& vsParams)
if ( pCrvToAdd == nullptr)
return false ;
// eseguo l'accodamento
if ( ! pCrvComp->AddCurve( *pCrvToAdd))
if ( ! pCrvComp->AddCurve( *pCrvToAdd, bEndOrStart))
return false ;
// se richiesto, elimino la curva accodata
if ( bErase) {
@@ -1747,6 +1822,53 @@ GdbExecutor::CurveCompoAddCurve( const STRVECTOR& vsParams)
return true ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveCompoExtractCurve( const STRVECTOR& vsParams, bool bEndOrStart)
{
// 3 parametri : IdSou, IdDest, IdParent
if ( vsParams.size() != 3)
return false ;
// recupero la curva composita e il suo riferimento
int nIdCCompo = GetIdParam( vsParams[0]) ;
ICurveComposite* pCrvCompo = GetCurveComposite( m_pGDB->GetGeoObj( nIdCCompo)) ;
if ( pCrvCompo == nullptr)
return false ;
Frame3d frSou ;
if ( ! m_pGDB->GetGlobFrame( nIdCCompo, frSou))
return false ;
// estraggo la opportuna entità
ICurve* pCrv = pCrvCompo->RemoveFirstOrLastCurve( bEndOrStart) ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[2]), frDest))
return false ;
// porto la curva estratta dal riferimento della sorgente a quello di inserimento
if ( ! AreSameFrame( frSou, frDest))
pCrv->LocToLoc( frSou, frDest) ;
// inserisco la curva estratta nel DB
return AddGeoObj( vsParams[1], vsParams[2], pCrv) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::CurveCompoChangeStart( const STRVECTOR& vsParams)
{
// 2 parametri : Id, ParNewStart
if ( vsParams.size() != 2)
return false ;
// recupero la curva composita
ICurveComposite* pCrvComp = GetCurveComposite( m_pGDB->GetGeoObj( GetIdParam( vsParams[0]))) ;
if ( pCrvComp == nullptr)
return false ;
// recupero il parametro del nuovo inizio
double dParNewStart ;
if ( ! FromString( vsParams[1], dParNewStart))
return false ;
// eseguo il cambio di inizio
return pCrvComp->ChangeStartPoint( dParNewStart) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteSurfTriMesh( const string& sCmd2, const STRVECTOR& vsParams)
@@ -2871,7 +2993,40 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
return false ;
return ptP.LocToLoc( frEnt, frPnt) ;
}
//case 'I' : // punto di intersezione con un'altra curva
case 'I' : // punto di intersezione con un'altra curva
{
// secondo parametro : altra curva
int nIdEnt2 = GetIdParam( vsParams[1]) ;
const IGeoObj* pGObj2 = m_pGDB->GetGeoObj( nIdEnt2) ;
if ( pGObj2 == nullptr)
return false ;
// deve essere una curva
const ICurve* pCrv2 = GetCurve( pGObj2) ;
if ( pCrv2 == nullptr)
return false ;
// recupero il riferimento in cui è immersa
Frame3d frEnt2 ;
if ( ! m_pGDB->GetGlobFrame( nIdEnt2, frEnt2))
return false ;
// se il riferimento è diverso da quello della prima entità, devo trasformarla
PtrOwner<ICurve> crvTrans( nullptr) ;
if ( ! AreSameFrame( frEnt, frEnt2)) {
crvTrans.Set( pCrv2->Clone()) ;
if ( ! ::IsValid( crvTrans))
return false ;
crvTrans->LocToLoc( frEnt2, frEnt) ;
pCrv2 = ::Get( crvTrans) ;
}
// eventuale terzo parametro : punto di riferimento
Point3d ptRef ;
if ( vsParams.size() >= 3 && ! GetPointParam( vsParams[2], frEnt, ptRef))
return false ;
// calcolo il punto di intersezione sulla prima curva più vicino al punto di riferimento
IntersCurveCurve intCC( *pCrv, *pCrv2, true) ;
if ( ! intCC.GetIntersPointNearTo( 0, ptRef, ptP))
return false ;
return ptP.LocToLoc( frEnt, frPnt) ;
}
}
}
// se frame
@@ -3785,7 +3940,7 @@ GdbExecutor::ExecuteCopy( const string& sCmd2, const STRVECTOR& vsParams)
nIdNew = m_pGDB->CopyGlob( GetIdParam( vsParams[0]), nIdDest, GetIdParam( vsParams[2]), nSonBeforeAfter) ;
else
nIdNew = m_pGDB->Copy( GetIdParam( vsParams[0]), nIdDest, GetIdParam( vsParams[2]), nSonBeforeAfter) ;
// se IdDest da calcolare, può essere una variabili a cui cambiare il valore
// se IdDest da calcolare, può essere una variabile a cui cambiare il valore
if ( nIdDest == GDB_ID_NULL)
m_pParser->SetVariable( vsParams[1], nIdNew) ;
@@ -4215,11 +4370,11 @@ GdbExecutor::ExecuteInvertSurf( const string& sCmd2, const STRVECTOR& vsParams)
bool
GdbExecutor::ExecuteTrimCurve( const string& sCmd2, const STRVECTOR& vsParams)
{
enum SeLp { SL, EL, SP, EP} ;
enum SeLp { SL, EL, SP, EP, SEP} ;
// 2 parametri ( Nome, parametro)
if ( vsParams.size() != 2)
// almeno 2 parametri : Nome, parametro [, secondo parametro]
if ( vsParams.size() < 2)
return false ;
// recupero lista nomi
INTVECTOR vnNames ;
@@ -4239,6 +4394,8 @@ GdbExecutor::ExecuteTrimCurve( const string& sCmd2, const STRVECTOR& vsParams)
StEnLenPar = SP ;
else if ( sCmd2 == "ENDPAR" || sCmd2 == "EP")
StEnLenPar = EP ;
else if ( sCmd2 == "STARTENDPAR" || sCmd2 == "SEP")
StEnLenPar = SEP ;
else
return false ;
// esecuzione trim
@@ -4263,6 +4420,14 @@ GdbExecutor::ExecuteTrimCurve( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! pCurve->TrimEndAtParam( dPar))
return false ;
break ;
case SEP :
// ci deve essere un terzo parametro
double dPar2 ;
if ( vsParams.size() < 3 || ! FromString( vsParams[2], dPar2))
return false ;
if ( ! pCurve->TrimStartEndAtParam( dPar, dPar2))
return false ;
break ;
}
}
else