From 8f53f1959d9d478a4d670c508398cc82d03b21af Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 28 Jul 2014 16:18:06 +0000 Subject: [PATCH] EgtGraphics 1.5g2 : - prevista grafica ausiliaria per curve, visualizzabile da flag. --- EgtGraphics.rc | Bin 11390 -> 11390 bytes ObjEGrGraphics.h | 8 +-- ObjNewGraphics.cpp | 28 ++++++--- ObjNewGraphics.h | 17 ++--- ObjOldGraphics.cpp | 35 ++++++++--- ObjOldGraphics.h | 16 ++--- Scene.h | 5 ++ SceneGeom.cpp | 154 +++++++++++++++++++++++++++++++-------------- 8 files changed, 181 insertions(+), 82 deletions(-) diff --git a/EgtGraphics.rc b/EgtGraphics.rc index b62de0c051070d65b979277313a0b80dd89d34d8..dc58c95e824f7007bf4232c87d11770773f36daa 100644 GIT binary patch delta 81 zcmewt@h@V-H#SD2&G%&mnSs F+yK2>8_xg$ delta 81 zcmewt@h@V-H#SDY&G%&mnSs F+yJ~O8^-_u diff --git a/ObjEGrGraphics.h b/ObjEGrGraphics.h index a38b674..fc4d4ab 100644 --- a/ObjEGrGraphics.h +++ b/ObjEGrGraphics.h @@ -34,12 +34,12 @@ class ObjEGrGraphics : public IObjGraphics virtual bool AddMaterial( const Color& colAmb, const Color& colDiff, const Color& colSpec, float fShin) = 0 ; virtual bool AddBackMaterial( const Color& colAmbDiff) = 0 ; - virtual bool AddPoint( const Point3d& ptP) = 0 ; - virtual bool AddPolyLine( const PolyLine& PL) = 0 ; - virtual bool StartTriangles( int nNum) = 0 ; + virtual bool AddPoint( const Point3d& ptP, bool bAux = false) = 0 ; + virtual bool AddPolyLine( const PolyLine& PL, bool bAux = false) = 0 ; + virtual bool StartTriangles( int nNum, bool bAux = false) = 0 ; virtual bool AddTriangle( const Triangle3d& Tria, const TriNormals3d& TNrms) = 0 ; virtual bool EndTriangles( void) = 0 ; - virtual bool Draw( int nStat, int nMark) = 0 ; + virtual bool Draw( int nStat, int nMark, bool ShowAux) = 0 ; } ; //---------------------------------------------------------------------------- diff --git a/ObjNewGraphics.cpp b/ObjNewGraphics.cpp index c58ff98..81b2c19 100644 --- a/ObjNewGraphics.cpp +++ b/ObjNewGraphics.cpp @@ -81,7 +81,7 @@ ObjNewGraphics::AddBackMaterial( const Color& colAmbDiff) //---------------------------------------------------------------------------- bool -ObjNewGraphics::AddPoint( const Point3d& ptP) +ObjNewGraphics::AddPoint( const Point3d& ptP, bool bAux) { if ( m_pScene == nullptr || ! m_pScene->MakeCurrent()) return false ; @@ -107,7 +107,7 @@ ObjNewGraphics::AddPoint( const Point3d& ptP) glEnableClientState( GL_VERTEX_ARRAY) ; glBindVertexArray( 0) ; // aggiungo i dati in lista - AddVerts( GL_POINTS, nCount, nVaoId, nVboId) ; + AddVerts( GL_POINTS, nCount, nVaoId, nVboId, bAux) ; // dichiaro valida la grafica m_bValid = true ; @@ -116,7 +116,7 @@ ObjNewGraphics::AddPoint( const Point3d& ptP) //---------------------------------------------------------------------------- bool -ObjNewGraphics::AddPolyLine( const PolyLine& PL) +ObjNewGraphics::AddPolyLine( const PolyLine& PL, bool bAux) { if ( m_pScene == nullptr || ! m_pScene->MakeCurrent()) return false ; @@ -147,7 +147,7 @@ ObjNewGraphics::AddPolyLine( const PolyLine& PL) glEnableClientState( GL_VERTEX_ARRAY) ; glBindVertexArray( 0) ; // aggiungo i dati in lista - AddVerts( GL_LINE_STRIP, nCount, nVaoId, nVboId) ; + AddVerts( GL_LINE_STRIP, nCount, nVaoId, nVboId, bAux) ; // dichiaro valida la grafica m_bValid = true ; @@ -156,7 +156,7 @@ ObjNewGraphics::AddPolyLine( const PolyLine& PL) //---------------------------------------------------------------------------- bool -ObjNewGraphics::StartTriangles( int nNum) +ObjNewGraphics::StartTriangles( int nNum, bool bAux) { if ( m_pScene == nullptr || ! m_pScene->MakeCurrent()) return false ; @@ -180,7 +180,7 @@ ObjNewGraphics::StartTriangles( int nNum) // 3 float per le coordinate e 3 per la normale glBufferData( GL_ARRAY_BUFFER, 6 * nNum * SIZEV3F, NULL, GL_STATIC_DRAW) ; // aggiungo i dati in lista - AddVerts( GL_TRIANGLES, 0, nVaoId, nVboId) ; + AddVerts( GL_TRIANGLES, 0, nVaoId, nVboId, bAux) ; // dichiaro modo triangoli m_nCurrMode = GL_TRIANGLES ; return true ; @@ -235,7 +235,7 @@ ObjNewGraphics::EndTriangles( void) //---------------------------------------------------------------------------- bool -ObjNewGraphics::Draw( int nStat, int nMark) +ObjNewGraphics::Draw( int nStat, int nMark, bool bShowAux) { if ( m_pScene == nullptr || ! m_pScene->MakeCurrent()) return false ; @@ -263,6 +263,13 @@ ObjNewGraphics::Draw( int nStat, int nMark) glBindVertexArray( 0) ; } break ; + case NgAtom::VERTS_A : + if ( bShowAux && iIter->m_nCount > 0 && iIter->m_nVaoId != 0) { + glBindVertexArray( iIter->m_nVaoId) ; + glDrawArrays( iIter->m_nMode, 0, iIter->m_nCount) ; + glBindVertexArray( 0) ; + } + break ; case NgAtom::COLOR : glColor4fv( iIter->m_fCol) ; break ; @@ -308,6 +315,13 @@ ObjNewGraphics::Draw( int nStat, int nMark) glBindVertexArray( 0) ; } break ; + case NgAtom::VERTS_A : + if ( bShowAux && iIter->m_nCount > 0 && iIter->m_nVaoId != 0) { + glBindVertexArray( iIter->m_nVaoId) ; + glDrawArrays( iIter->m_nMode, 0, iIter->m_nCount) ; + glBindVertexArray( 0) ; + } + break ; // non si impostano i colori, si usa quello di marcatura } } diff --git a/ObjNewGraphics.h b/ObjNewGraphics.h index f0c3b77..7c8f4ac 100644 --- a/ObjNewGraphics.h +++ b/ObjNewGraphics.h @@ -24,7 +24,8 @@ class NgAtom { NgAtom( void) : m_nType( NONE), m_nMode( 0), m_nCount( 0), m_nVaoId( 0), m_nVboId( 0) {} public : - enum GrType { NONE = 0, VERTS = 1, COLOR = 2, MAT_A = 3, MAT_D = 4, MAT_S = 5, MAT_SH = 6, MAT_B = 7} ; + enum GrType { NONE = 0, VERTS = 1, VERTS_A = 2, COLOR = 3, + MAT_A = 4, MAT_D = 5, MAT_S = 6, MAT_SH = 7, MAT_B = 8} ; public : GrType m_nType ; @@ -69,12 +70,12 @@ class ObjNewGraphics : public ObjEGrGraphics virtual bool AddMaterial( const Color& colAmb, const Color& colDiff, const Color& colSpec, float fShin) ; virtual bool AddBackMaterial( const Color& colAmbDiff) ; - virtual bool AddPoint( const Point3d& ptP) ; - virtual bool AddPolyLine( const PolyLine& PL) ; - virtual bool StartTriangles( int nNum) ; + virtual bool AddPoint( const Point3d& ptP, bool bAux = false) ; + virtual bool AddPolyLine( const PolyLine& PL, bool bAux = false) ; + virtual bool StartTriangles( int nNum, bool bAux = false) ; virtual bool AddTriangle( const Triangle3d& Tria, const TriNormals3d& TNrms) ; virtual bool EndTriangles( void) ; - virtual bool Draw( int nStat, int nMark) ; + virtual bool Draw( int nStat, int nMark, bool bShowAux) ; public : ObjNewGraphics( void) : m_pScene( nullptr), m_bValid( false) {} @@ -85,9 +86,9 @@ class ObjNewGraphics : public ObjEGrGraphics { try { m_ngaList.push_back( nga) ; } catch(...) { return false ; } return true ; } - bool AddVerts( int nMode, int nCount, unsigned int nVaoId, unsigned int nVboId) + bool AddVerts( int nMode, int nCount, unsigned int nVaoId, unsigned int nVboId, bool bAux = false) { NgAtom nga ; - nga.m_nType = NgAtom::VERTS ; + nga.m_nType = ( bAux ? NgAtom::VERTS_A : NgAtom::VERTS) ; nga.m_nMode = nMode ; nga.m_nCount = nCount ; nga.m_nVaoId = nVaoId ; nga.m_nVboId = nVboId ; return AddNgAtom( nga) ; } @@ -106,7 +107,7 @@ class ObjNewGraphics : public ObjEGrGraphics Scene* m_pScene ; // puntatore alla scena bool m_bValid ; // flag int m_nCurrMode ; // modo corrente - NGALIST m_ngaList ; // lista di atomi per nuova grafica + NGALIST m_ngaList ; // liste di atomi per nuova grafica } ; //---------------------------------------------------------------------------- diff --git a/ObjOldGraphics.cpp b/ObjOldGraphics.cpp index eb198da..fee8ef2 100644 --- a/ObjOldGraphics.cpp +++ b/ObjOldGraphics.cpp @@ -74,13 +74,13 @@ ObjOldGraphics::AddBackMaterial( const Color& colAmbDiff) //---------------------------------------------------------------------------- bool -ObjOldGraphics::AddPoint( const Point3d& ptP) +ObjOldGraphics::AddPoint( const Point3d& ptP, bool bAux) { // modo corrente deve essere nullo if ( m_nCurrMode != GL_NONE) return false ; // start - AddStart( GL_POINTS) ; + AddStart( GL_POINTS, bAux) ; // inserisco il nuovo vertice AddVert3f( ptP) ; // fine @@ -93,13 +93,13 @@ ObjOldGraphics::AddPoint( const Point3d& ptP) //---------------------------------------------------------------------------- bool -ObjOldGraphics::AddPolyLine( const PolyLine& PL) +ObjOldGraphics::AddPolyLine( const PolyLine& PL, bool bAux) { // modo corrente deve essere nullo if ( m_nCurrMode != GL_NONE) return false ; // start - AddStart( GL_LINE_STRIP) ; + AddStart( GL_LINE_STRIP, bAux) ; // inserisco i nuovi vertici Point3d ptP ; for ( bool bFound = PL.GetFirstPoint( ptP) ; bFound ; bFound = PL.GetNextPoint( ptP)) @@ -114,13 +114,13 @@ ObjOldGraphics::AddPolyLine( const PolyLine& PL) //---------------------------------------------------------------------------- bool -ObjOldGraphics::StartTriangles( int nNum) +ObjOldGraphics::StartTriangles( int nNum, bool bAux) { // modo corrente deve essere nullo if ( m_nCurrMode != GL_NONE) return false ; // inizio emissione triangoli - AddStart( GL_TRIANGLES) ; + AddStart( GL_TRIANGLES, bAux) ; m_nCurrMode = GL_TRIANGLES ; return true ; } @@ -158,7 +158,7 @@ ObjOldGraphics::EndTriangles( void) //---------------------------------------------------------------------------- bool -ObjOldGraphics::Draw( int nStat, int nMark) +ObjOldGraphics::Draw( int nStat, int nMark, bool bShowAux) { // se vuoto non faccio alcunché if ( m_ogaList.size() == 0) @@ -173,20 +173,29 @@ ObjOldGraphics::Draw( int nStat, int nMark) } // ciclo di disegno + bool bStartA ; OGALIST::iterator iIter ; for ( iIter = m_ogaList.begin() ; iIter != m_ogaList.end() ; ++ iIter) { switch ( iIter->m_nType) { case OgAtom::START : glBegin( iIter->m_nMode) ; break ; + case OgAtom::START_A : + bStartA = true ; + if ( bShowAux) + glBegin( iIter->m_nMode) ; + break ; case OgAtom::END : + bStartA = false ; glEnd() ; break ; case OgAtom::VERT : - glVertex3fv( iIter->m_fVal) ; + if ( ! bStartA || bShowAux) + glVertex3fv( iIter->m_fVal) ; break ; case OgAtom::NORMAL : - glNormal3fv( iIter->m_fVal) ; + if ( ! bStartA || bShowAux) + glNormal3fv( iIter->m_fVal) ; break ; case OgAtom::COLOR : glColor4fv( iIter->m_fVal) ; @@ -223,16 +232,24 @@ ObjOldGraphics::Draw( int nStat, int nMark) glColor4f( colMark.GetRed(), colMark.GetGreen(), colMark.GetBlue(), colMark.GetAlpha()) ; // ciclo di disegno + bool bStartA ; OGALIST::iterator iIter ; for ( iIter = m_ogaList.begin() ; iIter != m_ogaList.end() ; ++ iIter) { switch ( iIter->m_nType) { case OgAtom::START : glBegin( iIter->m_nMode) ; break ; + case OgAtom::START_A : + bStartA = true ; + if ( bShowAux) + glBegin( iIter->m_nMode) ; + break ; case OgAtom::END : + bStartA = false ; glEnd() ; break ; case OgAtom::VERT : + if ( ! bStartA || bShowAux) glVertex3fv( iIter->m_fVal) ; break ; // non si imposta la normale sono solo curve diff --git a/ObjOldGraphics.h b/ObjOldGraphics.h index b09a668..7117c49 100644 --- a/ObjOldGraphics.h +++ b/ObjOldGraphics.h @@ -27,8 +27,8 @@ class OgAtom { OgAtom( void) : m_nType( NONE), m_fX( 0), m_fY( 0), m_fZ( 0), m_fW( 1) {} public : - enum GrType { NONE = 0, START = 1, END = 2, VERT = 3, NORMAL = 4, - COLOR = 5, MAT_A = 6, MAT_D = 7, MAT_S = 8, MAT_SH = 9, MAT_B = 10} ; + enum GrType { NONE = 0, START = 1, START_A = 2, END = 3, VERT = 4, NORMAL = 5, + COLOR = 6, MAT_A = 7, MAT_D = 8, MAT_S = 9, MAT_SH = 10, MAT_B = 11} ; public : GrType m_nType ; @@ -73,12 +73,12 @@ class ObjOldGraphics : public ObjEGrGraphics virtual bool AddMaterial( const Color& colAmb, const Color& colDiff, const Color& colSpec, float fShin) ; virtual bool AddBackMaterial( const Color& colAmbDiff) ; - virtual bool AddPoint( const Point3d& ptP) ; - virtual bool AddPolyLine( const PolyLine& PL) ; - virtual bool StartTriangles( int nNum) ; + virtual bool AddPoint( const Point3d& ptP, bool bAux = false) ; + virtual bool AddPolyLine( const PolyLine& PL, bool bAux = false) ; + virtual bool StartTriangles( int nNum, bool bAux = false) ; virtual bool AddTriangle( const Triangle3d& Tria, const TriNormals3d& TNrms) ; virtual bool EndTriangles( void) ; - virtual bool Draw( int nStat, int nMark) ; + virtual bool Draw( int nStat, int nMark, bool bShowAux) ; public : ObjOldGraphics( void) : m_pScene( nullptr), m_nCurrMode( GL_NONE), m_bValid( false) {} @@ -88,9 +88,9 @@ class ObjOldGraphics : public ObjEGrGraphics { try { m_ogaList.push_back( oga) ; } catch(...) { return false ; } return true ; } - bool AddStart( int nMode) + bool AddStart( int nMode, bool bAux = false) { OgAtom oga ; - oga.m_nType = OgAtom::START ; + oga.m_nType = ( bAux ? OgAtom::START_A : OgAtom::START) ; oga.m_nMode = nMode ; return AddOgAtom( oga) ; } bool AddEnd( void) diff --git a/Scene.h b/Scene.h index c17d982..faca43b 100644 --- a/Scene.h +++ b/Scene.h @@ -77,6 +77,10 @@ class Scene : public IEGrScene return true ; } virtual int GetShowMode( void) { return m_nShowMode ;} + virtual void SetShowCurveDirection( bool bShow) + { m_bShowCurveDirection = bShow ; } + virtual bool GetShowCurveDirection( void) + { return m_bShowCurveDirection ; } // Geometry virtual bool SetExtension( const BBox3d& b3Ext) ; virtual bool UpdateExtension( void) ; @@ -137,6 +141,7 @@ class Scene : public IEGrScene Color m_colBackBottom ; // colore di sfondo in basso int m_nShowMode ; // modo di visualizzazione (wireframe, hiddenline, shading) + bool m_bShowCurveDirection ; // flag di visualizzazione direzione curve IGeomDB* m_pGeomDB ; // puntatore al DB geometrico Color m_colDef ; // colore di default diff --git a/SceneGeom.cpp b/SceneGeom.cpp index da5df17..aef09b0 100644 --- a/SceneGeom.cpp +++ b/SceneGeom.cpp @@ -24,6 +24,7 @@ #include "/EgtDev/Include/EGkGeoVector3d.h" #include "/EgtDev/Include/EGkGeoPoint3d.h" #include "/EgtDev/Include/EGkCurve.h" +#include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EGkSurfTriMesh.h" #include "/EgtDev/Include/EGkExtText.h" #include "/EgtDev/Include/EGkGdbFunct.h" @@ -33,43 +34,10 @@ using namespace std ; //------------------------------ Constants ----------------------------------- const int OGLMAT_DIM = 16 ; - -//---------------------------------------------------------------------------- -bool -FrameToOpenGlMatrix( const Frame3d& frFrame, double Matrix[OGLMAT_DIM]) -{ - if ( frFrame.GetType() == Frame3d::ERR) - return false ; - - Matrix[0] = frFrame.VersX().x ; - Matrix[1] = frFrame.VersX().y ; - Matrix[2] = frFrame.VersX().z ; - Matrix[3] = 0 ; - Matrix[4] = frFrame.VersY().x ; - Matrix[5] = frFrame.VersY().y ; - Matrix[6] = frFrame.VersY().z ; - Matrix[7] = 0 ; - Matrix[8] = frFrame.VersZ().x ; - Matrix[9] = frFrame.VersZ().y ; - Matrix[10] = frFrame.VersZ().z ; - Matrix[11] = 0 ; - Matrix[12] = frFrame.Orig().x ; - Matrix[13] = frFrame.Orig().y ; - Matrix[14] = frFrame.Orig().z ; - Matrix[15] = 1 ; - - return true ; -} - -//---------------------------------------------------------------------------- -ObjEGrGraphics* -CreateObjEGrGraphics( bool bNewWay) -{ - if ( bNewWay) - return ( new ObjNewGraphics) ; - else - return ( new ObjOldGraphics) ; -} +//------------------------------ Local functions ----------------------------- +static bool FrameToOpenGlMatrix( const Frame3d& frFrame, double Matrix[OGLMAT_DIM]) ; +static ObjEGrGraphics* CreateObjEGrGraphics( bool bNewWay) ; +static bool CalcCurveTipArrow( const PolyLine& plCrv, PolyLine& plArr) ; //---------------------------------------------------------------------------- bool @@ -174,10 +142,11 @@ Scene::DrawGroup( const IGdbIterator& iIter, int nPass, MdStMk cParent) bool Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj) { - // recupero l'oggetto geometrico + // recupero l'oggetto geometrico e il suo tipo IGeoObj* pGeoObj = (const_cast(&iIter))->GetGeoObj() ; if ( pGeoObj == nullptr) return false ; + int nGeoType = pGeoObj->GetType() ; // se non esiste grafica associata, la creo if ( pGeoObj->GetObjGraphics() == nullptr) { @@ -191,8 +160,6 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj) // se la grafica associata non è valida la ricalcolo ObjEGrGraphics* pGraphics = GetObjEGrGraphics( pGeoObj) ; if ( ! pGraphics->IsValid()) { - // leggo il tipo di oggetto geometrico - int nGeoType = pGeoObj->GetType() ; // recupero il colore Color cCol ; if ( ! iIter.GetCalcMaterial( cCol)) @@ -246,10 +213,17 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj) return false ; // calcolo la grafica PolyLine PL ; - pCurve->ApproxWithLines( 0.01, 5, PL) ; + pCurve->ApproxWithLines( 0.005, 5, PL) ; pGraphics->Clear() ; pGraphics->AddColor( cCol) ; pGraphics->AddPolyLine( PL) ; + // eventuali segni ausiliari (frecce,...) + Point3d ptStart ; + if ( PL.GetFirstPoint( ptStart)) + pGraphics->AddPoint( ptStart, true) ; + PolyLine PLA ; + if ( CalcCurveTipArrow( PL, PLA)) + pGraphics->AddPolyLine( PLA, true) ; } // se superficie trimesh else if ( nGeoType == SRF_TRIMESH) { @@ -299,22 +273,25 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj) // se hiddenline if ( m_nShowMode == SM_HIDDENLINE) { // in prima passata disegno solo le superfici - if ( nPass == 1 && ( pGeoObj->GetType() & GEO_SURF) == 0) + if ( nPass == 1 && ( nGeoType & GEO_SURF) == 0) return true ; } // se shading if ( m_nShowMode == SM_SHADING) { // in prima passata disegno solo le superfici - if ( nPass == 1 && ( pGeoObj->GetType() & GEO_SURF) == 0) + if ( nPass == 1 && ( nGeoType & GEO_SURF) == 0) return true ; // in seconda passata disegno solo dimensioni 0 e curve - if ( nPass == 2 && ( pGeoObj->GetType() & GEO_SURF) != 0) + if ( nPass == 2 && ( nGeoType & GEO_SURF) != 0) return true ; } - // visualizzo la grafica associata - return pGraphics->Draw( siObj.nStat, siObj.nMark) ; + // se richiesto, visualizzo la grafica associata + bool bShowAux = false ; + if ( ( nGeoType & GEO_CURVE) != 0 && m_bShowCurveDirection) + bShowAux = true ; + return pGraphics->Draw( siObj.nStat, siObj.nMark, bShowAux) ; } //---------------------------------------------------------------------------- @@ -353,3 +330,88 @@ Scene::DeleteObjGraphicsGroup( int nId) return true ; } + +//------------------------------ Local functions ----------------------------- +//---------------------------------------------------------------------------- +static bool +FrameToOpenGlMatrix( const Frame3d& frFrame, double Matrix[OGLMAT_DIM]) +{ + if ( frFrame.GetType() == Frame3d::ERR) + return false ; + + Matrix[0] = frFrame.VersX().x ; + Matrix[1] = frFrame.VersX().y ; + Matrix[2] = frFrame.VersX().z ; + Matrix[3] = 0 ; + Matrix[4] = frFrame.VersY().x ; + Matrix[5] = frFrame.VersY().y ; + Matrix[6] = frFrame.VersY().z ; + Matrix[7] = 0 ; + Matrix[8] = frFrame.VersZ().x ; + Matrix[9] = frFrame.VersZ().y ; + Matrix[10] = frFrame.VersZ().z ; + Matrix[11] = 0 ; + Matrix[12] = frFrame.Orig().x ; + Matrix[13] = frFrame.Orig().y ; + Matrix[14] = frFrame.Orig().z ; + Matrix[15] = 1 ; + + return true ; +} + +//---------------------------------------------------------------------------- +static ObjEGrGraphics* +CreateObjEGrGraphics( bool bNewWay) +{ + if ( bNewWay) + return ( new ObjNewGraphics) ; + else + return ( new ObjOldGraphics) ; +} + +//---------------------------------------------------------------------------- +static bool +CalcCurveTipArrow( const PolyLine& plCrv, PolyLine& plArr) +{ + // pulisco la polilinea per la freccia + plArr.Clear() ; + // verifico effettiva esistenza della polilinea approssimante la curva + if ( plCrv.GetLineNbr() < 1) + return false ; + // recupero dati ultimo tratto della curva + double dU1, dU2 ; + Point3d ptTip, ptPrev ; + if ( ! plCrv.GetLastULine( &dU1, &ptPrev, &dU2, &ptTip)) + return false ; + Vector3d vtDir = ptTip - ptPrev ; + double dLen = vtDir.Len() ; + if ( dLen < EPS_SMALL) + return false ; + vtDir /= dLen ; + double dLenRef = 0 ; + if ( ( dU2 - dU1) > 100 * EPS_PARAM) + dLenRef = dLen / ( dU2 - dU1) ; + // lunghezza della freccia + const double MAX_LEN_ARR = 3 ; + const double MIN_LEN_ARR = 0.1 ; + const double LEN_COEFF = 0.25 ; + double dLenArr = LEN_COEFF * dLenRef ; + if ( dLenArr > MAX_LEN_ARR) + dLenArr = MAX_LEN_ARR ; + else if ( dLenArr < MIN_LEN_ARR) + dLenArr = MIN_LEN_ARR ; + // disegno freccia + const double A_WIDTH_COEFF = 0.3 ; + Frame3d frF ; + frF.Set( ptTip, vtDir) ; + plArr.AddUPoint( 0, ptTip) ; + Point3d ptP1 = ORIG + Vector3d( A_WIDTH_COEFF, 0, -1) * dLenArr ; + ptP1.ToGlob( frF) ; + plArr.AddUPoint( 1, ptP1) ; + Point3d ptP2 = ORIG + Vector3d( -A_WIDTH_COEFF, 0, -1) * dLenArr ; + ptP2.ToGlob( frF) ; + plArr.AddUPoint( 2, ptP2) ; + plArr.AddUPoint( 3, ptTip) ; + + return true ; +}