diff --git a/StmFromTriangleSoup.cpp b/StmFromTriangleSoup.cpp index 08db0c7..8c55a74 100644 --- a/StmFromTriangleSoup.cpp +++ b/StmFromTriangleSoup.cpp @@ -99,14 +99,14 @@ StmFromTriangleSoup::AddTriangle( const Point3d& ptP0, const Point3d& ptP1, cons //---------------------------------------------------------------------------- int -StmFromTriangleSoup::AddVertex( const Point3d& ptP) +StmFromTriangleSoup::AddVertex( const Point3d& ptP, const double dU, const double dV) { // 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) + if ( ( nId = m_pSTM->AddVertex( ptP, dU, dV)) == SVT_NULL) return SVT_NULL ; m_VertGrid.InsertPoint( ptP, nId) ; return nId ; diff --git a/SurfBezier.cpp b/SurfBezier.cpp index 6c7588a..bb2e591 100644 --- a/SurfBezier.cpp +++ b/SurfBezier.cpp @@ -1524,7 +1524,7 @@ SurfBezier::GetAuxSurf( void) const Triangulate Tri ; if ( ! Tri.Make( vPL, vPnt, vTria)) return nullptr ; - + // porto i punti in 3d PNTVECTOR vPnt3d ; for ( int i = 0 ; i < int( vPnt.size()) ; ++ i) { diff --git a/SurfTriMesh.cpp b/SurfTriMesh.cpp index 76ad9e9..d171748 100644 --- a/SurfTriMesh.cpp +++ b/SurfTriMesh.cpp @@ -107,7 +107,7 @@ SurfTriMesh::Clear( void) //---------------------------------------------------------------------------- int -SurfTriMesh::AddVertex( const Point3d& ptVert) +SurfTriMesh::AddVertex( const Point3d& ptVert, const double dU, const double dV) { // imposto ricalcolo m_nStatus = TO_VERIFY ; @@ -118,7 +118,11 @@ SurfTriMesh::AddVertex( const Point3d& ptVert) try { m_vVert.emplace_back( ptVert) ;} catch(...) { return SVT_NULL ;} // ne determino l'indice - return int( m_vVert.size() - 1) ; + 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,19 @@ 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 +499,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 +523,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 diff --git a/SurfTriMesh.h b/SurfTriMesh.h index 6ae2946..9f8c8d1 100644 --- a/SurfTriMesh.h +++ b/SurfTriMesh.h @@ -28,11 +28,15 @@ class SurfFlatRegion ; 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) {} + StmVert( void) : ptP(), nIdTria( SVT_NULL), nFlag( 0), nTemp( 0), dU( -1), dV( -1) {} + StmVert( const Point3d& ptQ) : ptP( ptQ), nIdTria( SVT_NULL), nFlag( 0), nTemp( 0), dU( -1), dV( -1) {} + StmVert( const Point3d& ptQ, int nIdT, int nF) : ptP( ptQ), nIdTria( nIdT), nFlag( nF), nTemp( 0), dU( -1), dV( -1) {} public : Point3d ptP ; + double dU ; // parametro riferito alle coordinate del punto nello spazio parametrico ( nSpanU x nSpanV) + // della sup di Bezier // -1 se non definito + double dV ; // parametro riferito alle coordinate del punto nello spazio parametrico ( nSpanU x nSpanV) + // 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 ;