EgtGeomKernel :

- aggiunta delle coordintae U e V ai vertici delle TriMesh.
This commit is contained in:
Daniele Bariletti
2023-10-02 14:55:04 +02:00
parent 381a137604
commit eccf683ef4
3 changed files with 78 additions and 27 deletions
+13 -12
View File
@@ -76,37 +76,38 @@ StmFromTriangleSoup::AddTriangle( const Triangle3d& Tria)
//----------------------------------------------------------------------------
bool
StmFromTriangleSoup::AddTriangle( const Point3d& ptP0, const Point3d& ptP1, const Point3d& ptP2)
StmFromTriangleSoup::AddTriangle( const Point3d& ptP0, const Point3d& ptP1, const Point3d& ptP2,
const double dU0, const double dV0,const double dU1, const double dV1,const double dU2, const double dV2)
{
// verifico inizializzazione
// verifico inizializzazione
if ( m_pSTM == nullptr)
return false ;
// ciclo sui tre vertici
// ciclo sui tre vertici
int nIdV[3] ;
if ( ( nIdV[0] = AddVertex( ptP0)) == SVT_NULL)
if ( ( nIdV[0] = AddVertex( ptP0, dU0, dV0)) == SVT_NULL)
return false ;
if ( ( nIdV[1] = AddVertex( ptP1)) == SVT_NULL)
if ( ( nIdV[1] = AddVertex( ptP1, dU1, dV1)) == SVT_NULL)
return false ;
if ( ( nIdV[2] = AddVertex( ptP2)) == SVT_NULL)
if ( ( nIdV[2] = AddVertex( ptP2, dU2, dV2)) == SVT_NULL)
return false ;
// se i vertici sono tutti diversi tra loro, inserisco il triangolo
// se i vertici sono tutti diversi tra loro, inserisco il triangolo
if ( nIdV[0] != nIdV[1] && nIdV[0] != nIdV[2] && nIdV[1] != nIdV[2]) {
if ( m_pSTM->AddTriangle( nIdV) == SVT_NULL)
return false ;
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
int
StmFromTriangleSoup::AddVertex( const Point3d& ptP)
StmFromTriangleSoup::AddVertex( const Point3d& ptP, const double dU, const double dV)
{
// verifico se già presente
// verifico se già presente
int nId ;
if ( m_VertGrid.Find( ptP, 2 * EPS_SMALL, nId))
return nId ;
// aggiungo il vertice
if ( ( nId = m_pSTM->AddVertex( ptP)) == SVT_NULL)
// aggiungo il vertice
if ( ( nId = m_pSTM->AddVertex( ptP, dU, dV)) == SVT_NULL)
return SVT_NULL ;
m_VertGrid.InsertPoint( ptP, nId) ;
return nId ;
+48 -5
View File
@@ -107,18 +107,22 @@ SurfTriMesh::Clear( void)
//----------------------------------------------------------------------------
int
SurfTriMesh::AddVertex( const Point3d& ptVert)
SurfTriMesh::AddVertex( const Point3d& ptVert, const double dU, const double dV)
{
// imposto ricalcolo
// imposto ricalcolo
m_nStatus = TO_VERIFY ;
m_nParts = - 1 ;
m_OGrMgr.Reset() ;
ResetHashGrids3d() ;
// inserisco il vertice
// inserisco il vertice
try { m_vVert.emplace_back( ptVert) ;}
catch(...) { return SVT_NULL ;}
// ne determino l'indice
return int( m_vVert.size() - 1) ;
// ne determino l'indice
int nId = int( m_vVert.size() - 1) ;
// aggiugo le coordinate corrispondenti allo spazio parametrico
m_vVert[nId].dU = dU ;
m_vVert[nId].dV = dV ;
return nId ;
}
//----------------------------------------------------------------------------
@@ -475,6 +479,20 @@ SurfTriMesh::GetVertex( int nId, Point3d& ptP) const
return true ;
}
//----------------------------------------------------------------------------
bool
SurfTriMesh::GetVertexParam( int nId, double& dU, double& dV) const
{
// verifico esistenza del vertice
if ( nId < 0 || nId >= GetVertexSize() || m_vVert[nId].nIdTria == SVT_DEL)
return false ;
// recupero i dati
dU = m_vVert[nId].dU ;
dV = m_vVert[nId].dV ;
return true ;
}
//----------------------------------------------------------------------------
int
SurfTriMesh::GetFirstVertex( Point3d& ptP) const
@@ -482,6 +500,13 @@ SurfTriMesh::GetFirstVertex( Point3d& ptP) const
return GetNextVertex( SVT_NULL, ptP) ;
}
//----------------------------------------------------------------------------
int
SurfTriMesh::GetFirstVertexParam( int nId, double& dU, double& dV) const
{
return GetNextVertexParam( SVT_NULL, dU, dV) ;
}
//----------------------------------------------------------------------------
int
SurfTriMesh::GetNextVertex( int nId, Point3d& ptP) const
@@ -499,6 +524,24 @@ SurfTriMesh::GetNextVertex( int nId, Point3d& ptP) const
return nId ;
}
//----------------------------------------------------------------------------
int
SurfTriMesh::GetNextVertexParam( int nId, double& dU, double& dV) const
{
// cerco il primo successivo valido
do {
nId ++ ;
} while ( nId < GetVertexSize() && m_vVert[nId].nIdTria == SVT_DEL) ;
// se oltrepassata fine
if ( nId >= GetVertexSize())
return SVT_NULL ;
// recupero i dati
dU = m_vVert[nId].dU ;
dV = m_vVert[nId].dV ;
// ritorno indice triangolo corrente
return nId ;
}
//----------------------------------------------------------------------------
bool
SurfTriMesh::GetTriangle( int nId, int nIdVert[3]) const
+17 -10
View File
@@ -27,15 +27,19 @@ class SurfFlatRegion ;
// Classe Vertice
class StmVert
{
public :
StmVert( void) : ptP(), nIdTria( SVT_NULL), nFlag( 0), nTemp( 0) {}
StmVert( const Point3d& ptQ) : ptP( ptQ), nIdTria( SVT_NULL), nFlag( 0), nTemp( 0) {}
StmVert( const Point3d& ptQ, int nIdT, int nF) : ptP( ptQ), nIdTria( nIdT), nFlag( nF), nTemp( 0) {}
public :
Point3d ptP ;
int nIdTria ;
int nFlag ;
mutable int nTemp ;
public :
StmVert( void) : ptP(), dU( -1), dV( -1), nIdTria( SVT_NULL), nFlag( 0), nTemp( 0) {}
StmVert( const Point3d& ptQ) : ptP( ptQ), dU( -1), dV( -1), nIdTria( SVT_NULL), nFlag( 0), nTemp( 0) {}
StmVert( const Point3d& ptQ, int nIdT, int nF) : ptP( ptQ), dU( -1), dV( -1), nIdTria( nIdT), nFlag( nF), nTemp( 0) {}
public :
Point3d ptP ;
double dU ; // parametro riferito alle coordinate del punto nello spazio parametrico ( nSpanU x 1000) ( nSpanV x 1000)
// della sup di Bezier // -1 se non definito
double dV ; // parametro riferito alle coordinate del punto nello spazio parametrico ( nSpanU x 1000) ( nSpanV x 1000)
// della sup di Bezier // -1 se non definito
int nIdTria ;
int nFlag ;
mutable int nTemp ;
} ;
//----------------------------------------------------------------------------
@@ -215,7 +219,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
{ m_dSmoothAng = std::max( dSmoothAngDeg, EPS_ANG_SMALL) ;
m_dCosSmAng = cos( m_dSmoothAng * DEGTORAD) ;
m_OGrMgr.Reset() ; }
int AddVertex( const Point3d& ptVert) override ;
int AddVertex( const Point3d& ptVert, const double dU = -1 , const double dV = -1) override ;
bool MoveVertex( int nInd, const Point3d& ptNewVert) override ;
int AddTriangle( const int nIdVert[3], int nTFlag = 0) override ;
bool RemoveTriangle( int nId) override ;
@@ -244,8 +248,11 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
double GetSmoothAngle( void) const override
{ return m_dSmoothAng ; }
bool GetVertex( int nId, Point3d& ptP) const override ;
bool GetVertexParam( int nId, double& dU, double& dV) const override ;
int GetFirstVertex( Point3d& ptP) const override ;
int GetFirstVertexParam( int nId, double& dU, double& dV) const override ;
int GetNextVertex( int nId, Point3d& ptP) const override ;
int GetNextVertexParam( int nId, double& dU, double& dV) const override ;
bool GetTriangle( int nId, int nIdVert[3]) const override ;
int GetFirstTriangle( int nIdVert[3]) const override ;
int GetNextTriangle( int nId, int nIdVert[3]) const override ;