EgtGraphics 2.4h1 :

- in curve composite aggiunti punti intermedi su giunzioni interne tra componenti elementari.
This commit is contained in:
DarioS
2022-08-21 19:26:34 +02:00
parent 68434fba6f
commit 5e317faba6
9 changed files with 101 additions and 4 deletions
BIN
View File
Binary file not shown.
+1
View File
@@ -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 ;
+10
View File
@@ -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)
+1
View File
@@ -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 ;
+39
View File
@@ -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)
+1
View File
@@ -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 ;
+22
View File
@@ -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)
+1
View File
@@ -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 ;
+26 -4
View File
@@ -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 ;
}
}
//----------------------------------------------------------------------------
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 ;
}