diff --git a/EgtGraphics.rc b/EgtGraphics.rc index e470297..14a6602 100644 Binary files a/EgtGraphics.rc and b/EgtGraphics.rc differ diff --git a/ObjEGrGraphics.h b/ObjEGrGraphics.h index b2be407..54115dd 100644 --- a/ObjEGrGraphics.h +++ b/ObjEGrGraphics.h @@ -38,6 +38,7 @@ class ObjEGrGraphics : public IObjGraphics const Color& colSpec, float fShin) = 0 ; virtual bool AddBackMaterial( const Color& colAmbDiff) = 0 ; virtual bool AddPoint( const Point3d& ptP, bool bAux = false) = 0 ; + virtual bool AddPoints( const PNTVECTOR& vPnt, bool bAux = false) = 0 ; virtual bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) = 0 ; virtual bool AddPolyLine( const PolyLine& PL, bool bAux = false) = 0 ; virtual bool StartTriangles( int nNum, bool bAux = false) = 0 ; diff --git a/ObjMultiGraphics.cpp b/ObjMultiGraphics.cpp index a8a7556..4b18894 100644 --- a/ObjMultiGraphics.cpp +++ b/ObjMultiGraphics.cpp @@ -115,6 +115,16 @@ ObjMultiGraphics::AddPoint( const Point3d& ptP, bool bAux) return m_vOEGR[m_nCurr]->AddPoint( ptP, bAux) ; } +//---------------------------------------------------------------------------- +bool +ObjMultiGraphics::AddPoints( const PNTVECTOR& vPnt, bool bAux) +{ + if ( m_nCurr < 0 || m_nCurr >= int( m_vOEGR.size())) + return false ; + m_bValid = true ; + return m_vOEGR[m_nCurr]->AddPoints( vPnt, bAux) ; +} + //---------------------------------------------------------------------------- bool ObjMultiGraphics::AddLines( const PNTVECTOR& vPnt, bool bAux) diff --git a/ObjMultiGraphics.h b/ObjMultiGraphics.h index 6c0375d..3e7315d 100644 --- a/ObjMultiGraphics.h +++ b/ObjMultiGraphics.h @@ -37,6 +37,7 @@ class ObjMultiGraphics : public ObjEGrGraphics const Color& colSpec, float fShin) override ; bool AddBackMaterial( const Color& colAmbDiff) override ; bool AddPoint( const Point3d& ptP, bool bAux = false) override ; + bool AddPoints( const PNTVECTOR& vPnt, bool bAux = false) override ; bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) override ; bool AddPolyLine( const PolyLine& PL, bool bAux = false) override ; bool StartTriangles( int nNum, bool bAux = false) override ; diff --git a/ObjNewGraphics.cpp b/ObjNewGraphics.cpp index 26ca8c9..e6a11a2 100644 --- a/ObjNewGraphics.cpp +++ b/ObjNewGraphics.cpp @@ -116,6 +116,45 @@ ObjNewGraphics::AddPoint( const Point3d& ptP, bool bAux) return true ; } +//---------------------------------------------------------------------------- +bool +ObjNewGraphics::AddPoints( const PNTVECTOR& vPnt, bool bAux) +{ + if ( m_pScene == nullptr || ! m_pScene->MakeCurrent()) + return false ; + // definisco i buffer per la scheda grafica e vi inserisco i nuovi vertici + unsigned int nVaoId ; + glGenVertexArrays( 1, &nVaoId) ; + if ( nVaoId == 0) + return false ; + glBindVertexArray( nVaoId) ; + unsigned int nVboId ; + glGenBuffers( 1, &nVboId) ; + if ( nVboId == 0) { + glBindVertexArray( 0) ; + glDeleteVertexArrays( 1, &nVaoId) ; + return false ; + } + glBindBuffer( GL_ARRAY_BUFFER, nVboId) ; + int nCount = int( vPnt.size()) ; + glBufferData( GL_ARRAY_BUFFER, nCount * SIZEV3F, NULL, GL_STATIC_DRAW) ; + Vert3f v3V ; + for ( int i = 0 ; i < nCount ; ++ i) { + v3V.Set( vPnt[i]) ; + glBufferSubData( GL_ARRAY_BUFFER, i * SIZEV3F, SIZEV3F, &v3V) ; + m_b3Loc.Add( vPnt[i]) ; + } + glVertexPointer( 3, GL_FLOAT, 0, ((void*)(0))) ; + glEnableClientState( GL_VERTEX_ARRAY) ; + glBindVertexArray( 0) ; + // aggiungo i dati in lista + AddVerts( GL_POINTS, nCount, nVaoId, nVboId, bAux) ; + // dichiaro valida la grafica + m_bValid = true ; + + return true ; +} + //---------------------------------------------------------------------------- bool ObjNewGraphics::AddLines( const PNTVECTOR& vPnt, bool bAux) diff --git a/ObjNewGraphics.h b/ObjNewGraphics.h index 7ec7727..74f267c 100644 --- a/ObjNewGraphics.h +++ b/ObjNewGraphics.h @@ -71,6 +71,7 @@ class ObjNewGraphics : public ObjEGrGraphics const Color& colSpec, float fShin) override ; bool AddBackMaterial( const Color& colAmbDiff) override ; bool AddPoint( const Point3d& ptP, bool bAux = false) override ; + bool AddPoints( const PNTVECTOR& vPnt, bool bAux = false) override ; bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) override ; bool AddPolyLine( const PolyLine& PL, bool bAux = false) override ; bool StartTriangles( int nNum, bool bAux = false) override ; diff --git a/ObjOldGraphics.cpp b/ObjOldGraphics.cpp index e6e8f4f..4238357 100644 --- a/ObjOldGraphics.cpp +++ b/ObjOldGraphics.cpp @@ -97,6 +97,28 @@ ObjOldGraphics::AddPoint( const Point3d& ptP, bool bAux) return true ; } +//---------------------------------------------------------------------------- +bool +ObjOldGraphics::AddPoints( const PNTVECTOR& vPnt, bool bAux) +{ + // modo corrente deve essere nullo + if ( m_nCurrMode != GL_NONE) + return false ; + // start + AddStart( GL_POINTS, bAux) ; + // inserisco i vertici + aggiorno bbox + for ( int i = 0 ; i < int( vPnt.size()) ; ++ i) { + AddVert3f( vPnt[i]) ; + m_b3Loc.Add( vPnt[i]) ; + } + // fine + AddEnd() ; + // dichiaro valida la grafica + m_bValid = true ; + + return true ; +} + //---------------------------------------------------------------------------- bool ObjOldGraphics::AddLines( const PNTVECTOR& vPnt, bool bAux) diff --git a/ObjOldGraphics.h b/ObjOldGraphics.h index e071391..3d99e4f 100644 --- a/ObjOldGraphics.h +++ b/ObjOldGraphics.h @@ -76,6 +76,7 @@ class ObjOldGraphics : public ObjEGrGraphics const Color& colSpec, float fShin) override ; bool AddBackMaterial( const Color& colAmbDiff) override ; bool AddPoint( const Point3d& ptP, bool bAux = false) override ; + bool AddPoints( const PNTVECTOR& vPnt, bool bAux = false) override ; bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) override ; bool AddPolyLine( const PolyLine& PL, bool bAux = false) override ; bool StartTriangles( int nNum, bool bAux = false) override ; diff --git a/SceneGeom.cpp b/SceneGeom.cpp index f2c0061..96cd2f6 100644 --- a/SceneGeom.cpp +++ b/SceneGeom.cpp @@ -43,7 +43,8 @@ using namespace std ; static ObjEGrGraphics* CreateObjEGrGraphics( int nCount, bool bNewWay) ; static bool CalcCurveTailMark( const Vector3d& vtRef, const PolyLine& plCrv, PolyLine& plMark) ; static bool CalcCurveTipArrow( const Vector3d& vtRef, const PolyLine& plCrv, PolyLine& plArr) ; -static bool CalcConnectingLines( const PolyLine& plCrv, const Vector3d& vtTh, bool bDense, PNTVECTOR& vPnt) ; +static bool CalcCurveConnectingLines( const PolyLine& plCrv, const Vector3d& vtTh, bool bDense, PNTVECTOR& vPnt) ; +static bool CalcCurveJoints( const ICurve* pCurve, PNTVECTOR& vPnt) ; //---------------------------------------------------------------------------- bool @@ -331,6 +332,9 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj) PolyLine PLA ; if ( CalcCurveTipArrow( vtRef, PL, PLA)) pGraphics->AddPolyLine( PLA, true) ; + PNTVECTOR vPnt ; + if ( CalcCurveJoints( pCurve, vPnt)) + pGraphics->AddPoints( vPnt, true) ; // eventuale spessore double dTh ; Vector3d vtExtr ; @@ -339,7 +343,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj) // segmenti di raccordo PNTVECTOR vPnt ; bool bDense = ( nGeoType == CRV_ARC || nGeoType == CRV_BEZIER) ; - if ( CalcConnectingLines( PL, dTh * vtExtr, bDense, vPnt)) + if ( CalcCurveConnectingLines( PL, dTh * vtExtr, bDense, vPnt)) pGraphics->AddLines( vPnt) ; // percorso traslato PL.Translate( dTh * vtExtr) ; @@ -966,7 +970,7 @@ CalcCurveTipArrow( const Vector3d& vtRef, const PolyLine& plCrv, PolyLine& plArr //---------------------------------------------------------------------------- static bool -CalcConnectingLines( const PolyLine& plCrv, const Vector3d& vtTh, bool bDense, PNTVECTOR& vPnt) +CalcCurveConnectingLines( const PolyLine& plCrv, const Vector3d& vtTh, bool bDense, PNTVECTOR& vPnt) { // assegno coefficiente double dDelta = ( bDense ? 0.25 : 1) ; @@ -984,4 +988,22 @@ CalcConnectingLines( const PolyLine& plCrv, const Vector3d& vtTh, bool bDense, P } } return true ; -} \ No newline at end of file +} + +//---------------------------------------------------------------------------- +static bool +CalcCurveJoints( const ICurve* pCurve, PNTVECTOR& vPnt) +{ + // pulisco il vettore dei punti + vPnt.clear() ; + // recupero il dominio della curva + double dParS = 0, dParE = 1 ; + pCurve->GetDomain( dParS, dParE) ; + // recupero i punti intermedi + for ( double dPar = dParS + 1 ; dPar < dParE - EPS_PARAM ; dPar += 1) { + Point3d ptP ; + if ( pCurve->GetPointD1D2( dPar, ICurve::FROM_MINUS, ptP)) + vPnt.push_back( ptP) ; + } + return true ; +}