#include <TAPsOpenGLHalfEdgeTrigonalModel.hpp>


Public Member Functions | |
| void | DrawHalfEdgeByNextPtrs () |
| void | DrawHalfEdgeByPrevPtrs () |
| void | DrawHalfEdgePairs (const HEHalfEdge< T > *pHalfEdge, Vector3< T > &color1, Vector3< T > &color2) |
| void | DrawVertexNormals () |
| OpenGLHalfEdgeTrigonalModel () | |
| virtual void | ToggleDisplayVertexNormals () |
| virtual | ~OpenGLHalfEdgeTrigonalModel () |
Protected Member Functions | |
| virtual void | DrawGL (GLenum) |
Protected Attributes | |
| bool | bIsDisplayVertexNormals |
Friends | |
| std::ostream & | operator<< (std::ostream &output, OpenGLHalfEdgeTrigonalModel< T > const &o) |
Definition at line 22 of file TAPsOpenGLHalfEdgeTrigonalModel.hpp.
| BEGIN_NAMESPACE_TAPs__OpenGL OpenGLHalfEdgeTrigonalModel< T >::OpenGLHalfEdgeTrigonalModel | ( | ) | [inline] |
Definition at line 24 of file TAPsOpenGLHalfEdgeTrigonalModel.cpp.
00025 : HalfEdgeTrigonalModel<T>(), bIsDisplayVertexNormals( false ) 00026 { 00027 #ifdef TAPs_DEBUG_MODE 00028 std::cout << "OpenGLHalfEdgeTrigonalModel<" << typeid(T).name() << "> constructor\n"; 00029 #endif//TAPs_DEBUG_MODE 00030 }
| OpenGLHalfEdgeTrigonalModel< T >::~OpenGLHalfEdgeTrigonalModel | ( | ) | [inline, virtual] |
Definition at line 34 of file TAPsOpenGLHalfEdgeTrigonalModel.cpp.
00035 { 00036 #ifdef TAPs_DEBUG_MODE 00037 std::cout << "OpenGLHalfEdgeTrigonalModel<" << typeid(T).name() << "> destructor\n"; 00038 #endif//TAPs_DEBUG_MODE 00039 }
| void OpenGLHalfEdgeTrigonalModel< T >::DrawGL | ( | GLenum | drawMode | ) | [inline, protected, virtual] |
Implements OpenGLSupport.
Definition at line 77 of file TAPsOpenGLHalfEdgeTrigonalModel.cpp.
00078 { 00079 //---------------------------------------------------------------- 00080 if ( drawMode == OpenGL::Enum::POINT ) { 00081 HEVertex<T> *ptr = m_listVertex->Head(); 00082 glBegin( drawMode ); 00083 while ( ptr != NULL ) { 00084 // Draw the vertex 00085 glVertex3f ( 00086 static_cast<float>( (*ptr)[0] ), 00087 static_cast<float>( (*ptr)[1] ), 00088 static_cast<float>( (*ptr)[2] ) ); 00089 ptr = ptr->Next(); 00090 } 00091 glEnd(); 00092 } 00093 else if ( isFacetShading ) { 00094 // Draw the object 00095 //glEnable( GL_TEXTURE_2D ); 00096 HEFace<T> *facePtr = m_listFace->Head(); 00097 HEHalfEdge<T> *halfEdgePtr; 00098 //for ( int f = 0; f < GetNoFaces(); ++f ) { 00099 while ( facePtr != NULL ) { 00100 halfEdgePtr = facePtr->IncidentHalfEdge(); 00101 glBegin( drawMode ); 00102 //for ( int i = 0; i < 3; ++i ) { 00103 do { 00105 //if ( m_prFace[i].GetNoTexCoords() != 0 ) { 00106 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 00107 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 00108 //} 00109 // Normal of the face 00110 glNormal3f ( 00111 static_cast<float>( facePtr->GetNormal()[0] ), 00112 static_cast<float>( facePtr->GetNormal()[1] ), 00113 static_cast<float>( facePtr->GetNormal()[2] ) 00114 ); 00115 // Normal of the vertex 00116 // Draw the vertex 00117 glVertex3f ( 00118 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 00119 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 00120 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 00121 ); 00122 // DEBUG: 00123 //std::cout << halfEdgePtr->Vertex()->GetPosition()[0]; 00124 //std::cout << halfEdgePtr->Vertex()->GetPosition()[1]; 00125 //std::cout << halfEdgePtr->Vertex()->GetPosition()[2]; 00126 //std::cout << "\n"; 00127 halfEdgePtr = halfEdgePtr->Next(); 00128 } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 00129 //std::cout << "\n"; 00130 //} 00131 glEnd(); 00132 facePtr = facePtr->Next(); 00133 } 00134 00135 // Draw the object 00136 //for ( int i = 0; i < m_iNoFaces; i++ ) 00137 //{ 00138 // glBegin( drawMode ); 00139 // for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j ) 00140 // { 00141 // // Draw texture 00142 // if ( m_prFace[i].GetNoTexCoords() != 0 ) { 00143 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 00144 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 00145 // } 00146 // // Normal of the face 00147 // //glNormal3f ( static_cast<float>( m_prFace[i].GetNormal()[0] ), 00148 // // static_cast<float>( m_prFace[i].GetNormal()[1] ), 00149 // // static_cast<float>( m_prFace[i].GetNormal()[2] ) ); 00150 // // Draw the vertex 00151 // glVertex3f ( 00152 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 00153 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 00154 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) ); 00155 // } 00156 // glEnd(); 00157 //} 00159 } 00160 else { 00161 // Draw the object 00162 //glEnable( GL_TEXTURE_2D ); 00163 HEFace<T> *facePtr = m_listFace->Head(); 00164 HEHalfEdge<T> *halfEdgePtr; 00165 //for ( int f = 0; f < GetNoFaces(); ++f ) { 00166 while ( facePtr != NULL ) { 00167 halfEdgePtr = facePtr->IncidentHalfEdge(); 00168 glBegin( drawMode ); 00169 //for ( int i = 0; i < 3; ++i ) { 00170 do { 00172 //if ( m_prFace[i].GetNoTexCoords() != 0 ) { 00173 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 00174 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 00175 //} 00177 glNormal3f ( 00178 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[0] ), 00179 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[1] ), 00180 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[2] ) 00181 ); 00182 // Normal of the vertex 00183 // Draw the vertex 00184 glVertex3f ( 00185 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 00186 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 00187 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 00188 ); 00189 // DEBUG: 00190 //std::cout << halfEdgePtr->Vertex()->GetPosition()[0]; 00191 //std::cout << halfEdgePtr->Vertex()->GetPosition()[1]; 00192 //std::cout << halfEdgePtr->Vertex()->GetPosition()[2]; 00193 //std::cout << "\n"; 00194 halfEdgePtr = halfEdgePtr->Next(); 00195 } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 00196 //std::cout << "\n"; 00197 //} 00198 glEnd(); 00199 facePtr = facePtr->Next(); 00200 } 00201 00204 //for ( int i = 0; i < m_iNoFaces; i++ ) 00205 //{ 00206 // glBegin( drawMode ); 00207 // for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j ) 00208 // { 00209 // // Draw texture 00210 // if ( m_prFace[i].GetNoTexCoords() != 0 ) { 00211 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 00212 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 00213 // } 00214 // // Normal of the vertex 00215 // glNormal3f ( static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[0] ), 00216 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[1] ), 00217 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[2] ) ); 00218 // // Draw the vertex 00219 // glVertex3f ( 00220 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 00221 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 00222 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) ); 00223 // } 00224 // glEnd(); 00225 //} 00227 } 00228 00229 // Draw Boundary 00230 //if ( drawMode == OpenGL::Enum::POLYGON_WITH_WIRE_FRAME ) { 00231 //if ( true ) { 00232 // glColor3f( 1.0f, 0.0f, 0.0f ); 00233 // glDisable( GL_LIGHTING ); 00234 // glBegin( GL_LINES ); 00235 // HEFace<T> *facePtr = m_listFace->Head(); 00236 // HEHalfEdge<T> *halfEdgePtr; 00237 // while ( facePtr != NULL ) { 00238 // halfEdgePtr = facePtr->IncidentHalfEdge(); 00239 // do { 00240 // if ( !halfEdgePtr->Pair() ) { 00241 // // Draw the vertex 00242 // glVertex3f ( 00243 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 00244 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 00245 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 00246 // ); 00247 // glVertex3f ( 00248 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[0] ), 00249 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[1] ), 00250 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[2] ) 00251 // ); 00252 // } 00253 // halfEdgePtr = halfEdgePtr->Next(); 00254 // } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 00255 // facePtr = facePtr->Next(); 00256 // } 00257 // glEnd(); 00258 // glEnable( GL_LIGHTING ); 00259 //} 00260 00261 // Draw Boundary 00262 if ( true ) { 00263 glColor3f( 1.0f, 0.0f, 0.0f ); 00264 glPushAttrib( GL_LIGHTING_BIT ); 00265 glDisable( GL_LIGHTING ); 00266 glBegin( GL_LINES ); 00267 if ( m_listHoleFace != NULL ) { 00268 HEFace<T> *facePtr = m_listHoleFace->Head(); 00269 HEHalfEdge<T> *halfEdgePtr; 00270 while ( facePtr != NULL ) { 00271 halfEdgePtr = facePtr->IncidentHalfEdge(); 00272 do { 00273 //if ( halfEdgePtr && halfEdgePtr->Next() ) { 00274 // Draw the vertex 00275 glVertex3f ( 00276 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 00277 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 00278 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 00279 ); 00280 glVertex3f ( 00281 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[0] ), 00282 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[1] ), 00283 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[2] ) 00284 ); 00285 //} 00286 halfEdgePtr = halfEdgePtr->Next(); 00287 } while ( halfEdgePtr && halfEdgePtr != facePtr->IncidentHalfEdge() ); 00288 facePtr = facePtr->Next(); 00289 } 00290 } 00291 glEnd(); 00292 //glEnable( GL_LIGHTING ); 00293 glPopAttrib(); 00294 } 00295 00296 static HEFace<T> * g_pFace = m_listFace->Head(); 00297 static int gCount = 0; 00298 //static int gCount2 = 0; 00299 00300 if ( bIsDisplayVertexNormals ) { 00301 ++gCount; 00302 glPushAttrib( GL_LIGHTING_BIT | GL_ENABLE_BIT ); 00303 glDisable( GL_LIGHTING ); 00304 glEnable( GL_COLOR_MATERIAL ); 00305 00306 //glColor3ub( 175, 50, 70 ); 00307 //DrawVertexNormals(); 00308 00309 /* 00310 glColor3ub( 75, 50, 175 ); 00311 DrawHalfEdgeByPrevPtrs(); 00312 00313 glColor3ub( 175, 150, 70 ); 00314 DrawHalfEdgeByNextPtrs(); 00315 //*/ 00316 00317 // while ( g_pFace ) { 00318 if ( g_pFace ) { 00319 HEHalfEdge<T> * pHalfEdge = g_pFace->IncidentHalfEdge(); 00320 HEHalfEdge<T> * pStartHalfEdge = pHalfEdge; 00321 Vector3<T> color[6]; 00322 00323 color[0] = Vector3<T>( 0.5, 0.0, 0.0 ); 00324 color[1] = Vector3<T>( 1.0, 0.5, 0.5 ); 00325 00326 color[2] = Vector3<T>( 0.0, 0.5, 0.0 ); 00327 color[3] = Vector3<T>( 0.5, 1.0, 0.5 ); 00328 00329 color[4] = Vector3<T>( 0.0, 0.0, 0.5 ); 00330 color[5] = Vector3<T>( 0.5, 0.5, 1.0 ); 00331 00332 int count = 0; 00333 do { 00334 //std::cout << ++count << "\n"; 00335 DrawHalfEdgePairs( pHalfEdge, color[count], color[count+1] ); 00336 count += 2; 00337 pHalfEdge = pHalfEdge->Next(); 00338 } while ( pHalfEdge != pStartHalfEdge ); 00339 if ( gCount % 25 == 0 ) { 00340 g_pFace = g_pFace->Next(); 00341 gCount = 0; 00342 } 00343 } 00344 else { 00345 g_pFace = m_listFace->Head(); 00346 } 00347 00348 glPopAttrib(); 00349 } 00350 00351 // Draw AABB Bounding Box 00352 //DrawBoundingAABB(); 00353 //DrawBoundingEllipsoid(); 00354 //DrawBoundingSphere(); 00355 //---------------------------------------------------------------- 00356 }
| void OpenGLHalfEdgeTrigonalModel< T >::DrawHalfEdgeByNextPtrs | ( | ) | [inline] |
Definition at line 371 of file TAPsOpenGLHalfEdgeTrigonalModel.cpp.
00372 { 00373 HEFace<T> * pFace = m_listFace->Head(); 00374 while ( pFace ) { 00375 HEHalfEdge<T> * pHalfEdge = pFace->IncidentHalfEdge(); 00376 HEHalfEdge<T> * pNextHalfEdge = pHalfEdge->Next(); 00377 HEHalfEdge<T> * pStartHalfEdge = pHalfEdge; 00378 do { 00379 OpenGLUsefulObj<T>::DrawOneHeadArrow( 00380 pHalfEdge->Vertex()->GetPosition() + pFace->GetNormal()/5, 00381 pNextHalfEdge->Vertex()->GetPosition() + pFace->GetNormal()/5 ); 00382 pHalfEdge = pHalfEdge->Next(); 00383 pNextHalfEdge = pNextHalfEdge->Next(); 00384 } while ( pHalfEdge != pStartHalfEdge ); 00385 pFace = pFace->Next(); 00386 } 00387 }
| void OpenGLHalfEdgeTrigonalModel< T >::DrawHalfEdgeByPrevPtrs | ( | ) | [inline] |
Definition at line 390 of file TAPsOpenGLHalfEdgeTrigonalModel.cpp.
00391 { 00392 HEFace<T> * pFace = m_listFace->Head(); 00393 while ( pFace ) { 00394 HEHalfEdge<T> * pHalfEdge = pFace->IncidentHalfEdge(); 00395 HEHalfEdge<T> * pPrevHalfEdge = pHalfEdge->Prev(); 00396 HEHalfEdge<T> * pStartHalfEdge = pHalfEdge; 00397 do { 00398 OpenGLUsefulObj<T>::DrawOneHeadArrow( 00399 pHalfEdge->Vertex()->GetPosition() + pFace->GetNormal()/10, 00400 pPrevHalfEdge->Vertex()->GetPosition() + pFace->GetNormal()/10 ); 00401 pHalfEdge = pHalfEdge->Next(); 00402 pPrevHalfEdge = pPrevHalfEdge->Next(); 00403 } while ( pHalfEdge != pStartHalfEdge ); 00404 pFace = pFace->Next(); 00405 } 00406 }
| void OpenGLHalfEdgeTrigonalModel< T >::DrawHalfEdgePairs | ( | const HEHalfEdge< T > * | pHalfEdge, | |
| Vector3< T > & | color1, | |||
| Vector3< T > & | color2 | |||
| ) | [inline] |
Definition at line 409 of file TAPsOpenGLHalfEdgeTrigonalModel.cpp.
00410 { 00411 glPushAttrib( GL_LIGHTING_BIT | GL_ENABLE_BIT ); 00412 glDisable( GL_LIGHTING ); 00413 glEnable( GL_COLOR_MATERIAL ); 00414 00415 glColor3f( color1[0], color1[1], color1[2] ); 00416 OpenGLUsefulObj<T>::DrawOneHeadArrow( 00417 pHalfEdge->Vertex()->GetPosition() + pHalfEdge->Face()->GetNormal()/2, 00418 pHalfEdge->Next()->Vertex()->GetPosition() + pHalfEdge->Face()->GetNormal()/2 ); 00419 00420 HEHalfEdge<T> * pPair = pHalfEdge->Pair(); 00421 glColor3f( color2[0], color2[1], color2[2] ); 00422 OpenGLUsefulObj<T>::DrawOneHeadArrow( 00423 pPair->Vertex()->GetPosition() + pHalfEdge->Face()->GetNormal()/4, 00424 pPair->Next()->Vertex()->GetPosition() + pHalfEdge->Face()->GetNormal()/4 ); 00425 00426 glPopAttrib(); 00427 }
| void OpenGLHalfEdgeTrigonalModel< T >::DrawVertexNormals | ( | ) | [inline, virtual] |
Reimplemented from OpenGLModel< T >.
Definition at line 361 of file TAPsOpenGLHalfEdgeTrigonalModel.cpp.
00362 { 00363 HEVertex<T> * pVertex = m_listVertex->Head(); 00364 while ( pVertex ) { 00365 OpenGLUsefulObj<T>::DrawOneHeadArrow( pVertex->GetPosition(), pVertex->GetPosition() + pVertex->GetNormal() ); 00366 pVertex = pVertex->Next(); 00367 } 00368 }
| virtual void OpenGLHalfEdgeTrigonalModel< T >::ToggleDisplayVertexNormals | ( | ) | [inline, virtual] |
Reimplemented from OpenGLModel< T >.
Definition at line 80 of file TAPsOpenGLHalfEdgeTrigonalModel.hpp.
00081 { bIsDisplayVertexNormals = !bIsDisplayVertexNormals; }
| std::ostream& operator<< | ( | std::ostream & | output, | |
| OpenGLHalfEdgeTrigonalModel< T > const & | o | |||
| ) | [friend] |
Definition at line 25 of file TAPsOpenGLHalfEdgeTrigonalModel.hpp.
00026 { 00027 output << "\n==========================================\n" 00028 << "TAPs::OpenGL::OpenGLHalfEdgeTrigonalModel<" 00029 << typeid(T).name() << "> Class\n" 00030 << "==========================================\n"; 00031 //---------------------------------------------------------------- 00032 /* 00033 // Material Node from OpenGLSupport 00034 output << "\nMaterial Node" << "\n{\n" << o.material << "\n}"; 00035 //---------------------------------------------------------------- 00036 // Nodes from XPolygonalModel<T> 00037 output << "\n\nVertices " << o.m_iNoVertices << "\n{"; 00038 for ( int i = 0; i < o.m_iNoVertices; ++i ) { 00039 output << "\n #" << i << "\t" << o.m_prXVertex[i]; 00040 } 00041 output << "\n}"; 00042 //---------------------------------------------------------------- 00043 // Neighbor vertex ring#1 00044 if ( o.m_pviVertexRing1List ) { 00045 std::vector<int>::const_iterator iterator; 00046 output << "\n\nVertexRing1 " << o.m_iNoVertices << "\n{"; 00047 for ( int i = 0; i < o.m_iNoVertices; ++i ) { 00048 output << "\n #" << i; 00049 for ( iterator = o.m_pviVertexRing1List[i].begin(); 00050 iterator != o.m_pviVertexRing1List[i].end(); 00051 ++iterator ) 00052 { 00053 output << "\t" << *iterator; 00054 } 00055 } 00056 output << "\n}"; 00057 } 00058 //---------------------------------------------------------------- 00059 // Faces Node 00060 output << "\n\nFaces " << o.m_iNoFaces << "\n{"; 00061 for ( int i = 0; i < o.m_iNoFaces; ++i ) { 00062 output << "\n #" << i << "\t" << o.m_prFace[i]; 00063 } 00064 output << "\n}"; 00065 */ 00066 return output; 00067 }
bool OpenGLHalfEdgeTrigonalModel< T >::bIsDisplayVertexNormals [protected] |
Definition at line 96 of file TAPsOpenGLHalfEdgeTrigonalModel.hpp.
1.5.6