1 // File: OpenGl_QuadrangleStrip.cxx
2 // Created: 13 July 2011
3 // Author: Sergey ZERCHANINOV
4 // Copyright: OPEN CASCADE 2011
6 #include <OpenGl_tgl_all.hxx>
9 #include <OpenGl_QuadrangleStrip.hxx>
11 #include <OpenGl_telem_util.hxx>
12 #include <OpenGl_TextureBox.hxx>
14 #include <OpenGl_AspectFace.hxx>
15 #include <OpenGl_Structure.hxx>
17 /*----------------------------------------------------------------------*/
19 #define OPENGL_RAND() ( ( unsigned )( s_Rand = s_Rand * 214013L + 2531011L ) )
21 /*----------------------------------------------------------------------*/
23 extern void draw_degenerates_as_points ( PDS_INTERNAL, tel_point, Tint, const Handle(OpenGl_Workspace) & );
24 extern void draw_degenerates_as_bboxs ( PDS_INTERNAL, tel_point, Tint, const Handle(OpenGl_Workspace) & );
25 extern void set_drawable_items ( GLboolean*, int, const float );
27 /*----------------------------------------------------------------------*/
29 void OpenGl_QuadrangleStrip::draw_qstrip (const Tint front_lighting_model,
30 const Aspect_InteriorStyle interior_style,
31 const TEL_COLOUR *edge_colour,
32 const Handle(OpenGl_Workspace) &AWorkspace) const
34 Tint i, m, newList = 0;
38 tel_colour pfc = myData.fcolours;
39 tel_point pv = myData.vertices;
40 tel_colour pvc = myData.vcolours;
41 tel_point pvn = myData.vnormals;
42 tel_texture_coord pvt = myData.vtexturecoord;
44 if ( AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT )
50 if ( AWorkspace->DegenerateModel < 2 && interior_style != Aspect_IS_EMPTY )
52 if ( front_lighting_model )
53 glEnable(GL_LIGHTING);
55 glDisable(GL_LIGHTING);
57 lighting_model = front_lighting_model;
59 nc = myData.num_columns;
61 nv = ( nr + 1 ) * ( nc + 1 );
62 if ( (AWorkspace->NamedStatus & OPENGL_NS_ANIMATION) == 0 )
63 goto doDraw; /* Disable object display list out of animation */
64 /* window's context and bitmap's one */
65 if ( myDS->model != front_lighting_model || !myDS->list || myDS->model == -1 ||
66 ( AWorkspace->DegenerateModel && myDS->skipRatio != AWorkspace->SkipRatio ) )
68 myDS->skipRatio = AWorkspace->SkipRatio;
69 myDS->model = front_lighting_model;
70 myDS->degMode = AWorkspace->DegenerateModel;
72 if ( AWorkspace->SkipRatio == 0.f ) {
74 if ( !myDS->list ) myDS->list = glGenLists ( 1 );
76 glNewList ( myDS->list, GL_COMPILE_AND_EXECUTE );
81 if ( pvt && (AWorkspace->NamedStatus & OPENGL_NS_FORBIDSETTEX) == 0 )
83 for ( m = 0; m < nr; ++m )
85 glBegin ( GL_QUAD_STRIP );
86 glNormal3fv ( pvn[ m * ( nc + 1 ) ].xyz );
87 glTexCoord2fv ( pvt[ m * ( nc + 1 ) ].xy );
88 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
89 glNormal3fv ( pvn[ ( m + 1 ) * ( nc + 1 ) ].xyz );
90 glTexCoord2fv ( pvt[ ( m + 1 ) * ( nc + 1 ) ].xy );
91 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
92 for ( i = 1; i < nc + 1; ++i )
94 glNormal3fv ( pvn[ i + m * ( nc + 1 ) ].xyz );
95 glTexCoord2fv ( pvt[ i + m * ( nc + 1 ) ].xy );
96 glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
97 glNormal3fv ( pvn[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
98 glTexCoord2fv ( pvt[ i + ( m + 1 ) * ( nc + 1 ) ].xy );
99 glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
106 for ( m = 0; m < nr; ++m )
108 glBegin ( GL_QUAD_STRIP );
109 glNormal3fv ( pvn[ m * ( nc + 1 ) ].xyz );
110 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
111 glNormal3fv ( pvn[ ( m + 1 ) * ( nc + 1 ) ].xyz );
112 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
113 for ( i = 1; i < nc + 1; ++i )
115 glNormal3fv ( pvn[ i + m * ( nc + 1 ) ].xyz );
116 glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
117 glNormal3fv ( pvn[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
118 glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
128 for ( m = 0; m < nr; ++m )
130 glBegin ( GL_QUAD_STRIP );
131 glColor3fv ( pvc[ m * ( nc + 1 ) ].rgb );
132 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
133 glColor3fv ( pvc[ ( m + 1 ) * ( nc + 1 ) ].rgb );
134 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
135 for ( i = 1; i < nc + 1; ++i )
137 glColor3fv ( pvc[ i + m * ( nc + 1 ) ].rgb );
138 glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
139 glColor3fv ( pvc[ i + ( m + 1 ) * ( nc + 1 ) ].rgb );
140 glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
147 glColor3fv ( pfc[ 0 ].rgb );
148 for ( m = 0; m < nr; ++m )
150 glBegin ( GL_QUAD_STRIP );
151 glColor3fv ( pfc[ m * nc ].rgb );
152 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
153 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
154 for ( i = 1; i < nc + 1; ++i )
156 glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
157 glColor3fv ( pfc[ i - 1 + m * nc ].rgb );
158 glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
165 for ( m = 0; m < nr; ++m )
167 glBegin ( GL_QUAD_STRIP );
168 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
169 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
170 for ( i = 1; i < nc + 1; ++i )
172 glVertex3fv( pv[ i + m * ( nc + 1 ) ].xyz );
173 glVertex3fv( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
180 else if ( AWorkspace->SkipRatio < 1.f )
182 set_drawable_items ( myDS->bDraw, nr, AWorkspace->SkipRatio );
184 if ( !myDS->dlist ) myDS->dlist = glGenLists ( 1 );
186 glNewList ( myDS->dlist, GL_COMPILE_AND_EXECUTE );
189 if ( lighting_model )
191 if ( pvt && (AWorkspace->NamedStatus & OPENGL_NS_FORBIDSETTEX) == 0 )
193 for ( m = 0; m < nr; ++m )
195 if ( myDS->bDraw[ m ] )
197 glBegin ( GL_QUADS );
198 glNormal3fv ( pvn[ m * ( nc + 1 ) ].xyz );
199 glTexCoord2fv ( pvt[ m * ( nc + 1 ) ].xy );
200 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
201 glNormal3fv ( pvn[ ( m + 1 ) * ( nc + 1 ) ].xyz );
202 glTexCoord2fv ( pvt[ ( m + 1 ) * ( nc + 1 ) ].xy );
203 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
204 for ( i = 1; i < nc + 1; ++i )
206 glNormal3fv ( pvn[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
207 glTexCoord2fv ( pvt[ i + ( m + 1 ) * ( nc + 1 ) ].xy );
208 glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
209 glNormal3fv ( pvn[ i + m * ( nc + 1 ) ].xyz );
210 glTexCoord2fv ( pvt[ i + m * ( nc + 1 ) ].xy );
211 glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
219 for ( m = 0; m < nr; ++m )
221 if ( myDS->bDraw[ m ] )
223 glBegin ( GL_QUADS );
224 glNormal3fv ( pvn[ m * ( nc + 1 ) ].xyz );
225 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
226 glNormal3fv ( pvn[ ( m + 1 ) * ( nc + 1 ) ].xyz );
227 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
228 for ( i = 1; i < nc + 1; ++i )
230 glNormal3fv ( pvn[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
231 glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
232 glNormal3fv ( pvn[ i + m * ( nc + 1 ) ].xyz );
233 glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
244 for ( m = 0; m < nr; ++m )
246 if ( myDS->bDraw[ m ] )
248 glBegin ( GL_QUAD_STRIP );
249 glColor3fv ( pvc[ m * ( nc + 1 ) ].rgb );
250 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
251 glColor3fv ( pvc[ ( m + 1 ) * ( nc + 1 ) ].rgb );
252 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
253 for ( i = 1; i < nc + 1; ++i )
255 glColor3fv ( pvc[ i + ( m + 1 ) * ( nc + 1 ) ].rgb );
256 glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
257 glColor3fv ( pvc[ i + m * ( nc + 1 ) ].rgb );
258 glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
266 glColor3fv ( pfc[ 0 ].rgb );
267 for ( m = 0; m < nr; ++m )
269 if ( myDS->bDraw[ m ] )
271 glBegin ( GL_QUADS );
272 glColor3fv ( pfc[ m * nc ].rgb );
273 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
274 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
275 for ( i = 1; i < nc + 1; ++i )
277 glColor3fv ( pfc[ i - 1 + m * nc ].rgb );
278 glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
279 glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
287 for ( m = 0; m < nr; ++m )
289 if ( myDS->bDraw[ m ] )
291 glBegin ( GL_QUADS );
292 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
293 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
294 for ( i = 1; i < nc + 1; ++i )
296 glVertex3fv( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
297 glVertex3fv( pv[ i + m * ( nc + 1 ) ].xyz );
307 if ( !myDS->dlist ) myDS->dlist = glGenLists ( 1 );
309 glNewList ( myDS->dlist, GL_COMPILE_AND_EXECUTE );
313 if ( newList ) glEndList ();
315 if ( AWorkspace->DegenerateModel ) return;
319 glCallList ( AWorkspace->SkipRatio <= 0.f ? myDS->list : myDS->dlist );
321 if ( AWorkspace->DegenerateModel ) return;
328 /* OCC11904 -- Temporarily disable environment mapping */
329 glPushAttrib(GL_ENABLE_BIT);
330 glDisable(GL_TEXTURE_1D);
331 glDisable(GL_TEXTURE_2D);
333 switch ( AWorkspace->DegenerateModel )
338 case 2: /* XXX_TDM_WIREFRAME */
342 case 3: /* XXX_TDM_MARKER */
343 draw_degenerates_as_points ( myDS, myData.vertices, ( myData.num_rows + 1 ) * ( myData.num_columns + 1 ), AWorkspace );
347 case 4: /* XXX_TDM_BBOX */
348 draw_degenerates_as_bboxs ( myDS, myData.vertices, ( myData.num_rows + 1 ) * ( myData.num_columns + 1 ), AWorkspace );
353 draw_edges ( edge_colour, interior_style, i, AWorkspace );
358 /*----------------------------------------------------------------------*/
360 void OpenGl_QuadrangleStrip::draw_edges (const TEL_COLOUR *edge_colour, const Aspect_InteriorStyle interior_style,
361 Tint forceDraw, const Handle(OpenGl_Workspace) &AWorkspace) const
363 const OpenGl_AspectFace *aspect_face = AWorkspace->AspectFace( Standard_True );
365 if ( interior_style != Aspect_IS_HIDDENLINE && !forceDraw && aspect_face->Context().Edge == TOff )
368 glDisable(GL_LIGHTING);
369 const GLboolean texture_on = IsTextureEnabled();
370 if ( texture_on ) DisableTexture();
373 const OpenGl_AspectLine *aspect_line_old = AWorkspace->SetAspectLine( aspect_face->AspectEdge() );
374 AWorkspace->AspectLine( Standard_True );
376 Tint nc = myData.num_columns;
377 Tint nf = myData.num_rows * myData.num_columns;
382 draw_line_strip ( edge_colour, nf, nc );
385 if ( (AWorkspace->NamedStatus & OPENGL_NS_ANIMATION) == 0 )
386 goto doDraw; /* Disable object display list out of animation */
387 if ( myDS->degMode != 2 || myDS->skipRatio != AWorkspace->SkipRatio || !myDS->dlist ) {
389 if ( !myDS->dlist ) myDS->dlist = glGenLists ( 1 );
392 myDS->skipRatio = AWorkspace->SkipRatio;
393 glNewList ( myDS->dlist, GL_COMPILE_AND_EXECUTE );
396 glPushAttrib ( GL_DEPTH_BUFFER_BIT );
397 glDisable ( GL_DEPTH_TEST );
399 if ( AWorkspace->SkipRatio <= 0.f )
401 draw_line_strip ( edge_colour, nf, nc );
403 else if ( AWorkspace->SkipRatio < 1.f ) {
405 int i, m1, m2, n1, n2, n3, n4;
407 set_drawable_items ( myDS->bDraw, nf, AWorkspace->SkipRatio );
409 glColor3fv ( edge_colour -> rgb );
411 for ( i = 0; i < nf; ++i )
413 if ( myDS->bDraw[ i ] ) {
415 glBegin ( GL_LINE_STRIP );
418 n1 = m1 * ( nc + 1 ) + m2;
423 glVertex3fv ( myData.vertices[ n1 ].xyz );
424 glVertex3fv ( myData.vertices[ n2 ].xyz );
425 glVertex3fv ( myData.vertices[ n3 ].xyz );
426 glVertex3fv ( myData.vertices[ n4 ].xyz );
427 glVertex3fv ( myData.vertices[ n1 ].xyz );
435 if ( newList ) glEndList ();
437 } else glCallList ( myDS->dlist );
441 // Restore line context
442 AWorkspace->SetAspectLine( aspect_line_old );
444 if ( texture_on ) EnableTexture ();
447 void OpenGl_QuadrangleStrip::draw_line_strip (const TEL_COLOUR *c, Tint nf, Tint nc) const
449 int i, m1, m2, n1, n2, n3, n4;
451 glColor3fv ( c->rgb );
453 for ( i = 0; i < nf; ++i )
455 glBegin ( GL_LINE_STRIP );
458 n1 = m1 * ( nc + 1 ) + m2;
463 glVertex3fv ( myData.vertices[ n1 ].xyz );
464 glVertex3fv ( myData.vertices[ n2 ].xyz );
465 glVertex3fv ( myData.vertices[ n3 ].xyz );
466 glVertex3fv ( myData.vertices[ n4 ].xyz );
467 glVertex3fv ( myData.vertices[ n1 ].xyz );
472 /*----------------------------------------------------------------------*/
474 OpenGl_QuadrangleStrip::OpenGl_QuadrangleStrip (const Graphic3d_Array2OfVertex& AListVertex)
476 const Standard_Integer nbr = AListVertex.RowLength ();
477 const Standard_Integer nbc = AListVertex.ColLength ();
478 const Standard_Integer nbf = nbr*nbc;
480 // Dynamic allocation
481 TEL_POINT *points = new TEL_POINT[nbf];
483 const Standard_Integer LowerRow = AListVertex.LowerRow ();
484 const Standard_Integer UpperRow = AListVertex.UpperRow ();
485 const Standard_Integer LowerCol = AListVertex.LowerCol ();
486 const Standard_Integer UpperCol = AListVertex.UpperCol ();
488 Standard_Integer i, j, k = 0;
489 Standard_Real X, Y, Z;
490 for (i=LowerRow; i<=UpperRow; i++)
491 for (j=LowerCol; j<=UpperCol; j++)
493 AListVertex (i, j).Coord (X, Y, Z);
494 points[k].xyz[0] = float (X);
495 points[k].xyz[1] = float (Y);
496 points[k].xyz[2] = float (Z);
500 Init(nbr,nbc,points,NULL,NULL,NULL,NULL,NULL,TEL_SHAPE_UNKNOWN);
503 /*----------------------------------------------------------------------*/
505 OpenGl_QuadrangleStrip::OpenGl_QuadrangleStrip (const Graphic3d_Array2OfVertexN& AListVertex)
507 const Standard_Integer nbr = AListVertex.RowLength ();
508 const Standard_Integer nbc = AListVertex.ColLength ();
509 const Standard_Integer nbf = nbr*nbc;
511 // Dynamic allocation
512 TEL_POINT *points = new TEL_POINT[nbf];
513 TEL_POINT *normals = new TEL_POINT[nbf];
515 const Standard_Integer LowerRow = AListVertex.LowerRow ();
516 const Standard_Integer UpperRow = AListVertex.UpperRow ();
517 const Standard_Integer LowerCol = AListVertex.LowerCol ();
518 const Standard_Integer UpperCol = AListVertex.UpperCol ();
520 Standard_Integer i, j, k = 0;
521 Standard_Real X, Y, Z;
522 for (i=LowerRow; i<=UpperRow; i++)
523 for (j=LowerCol; j<=UpperCol; j++)
525 AListVertex (i, j).Coord (X, Y, Z);
526 points[k].xyz[0] = float (X);
527 points[k].xyz[1] = float (Y);
528 points[k].xyz[2] = float (Z);
529 AListVertex (i, j).Normal (X, Y, Z);
530 normals[k].xyz[0] = float (X);
531 normals[k].xyz[1] = float (Y);
532 normals[k].xyz[2] = float (Z);
536 Init(nbr,nbc,points,normals,NULL,NULL,NULL,NULL,TEL_SHAPE_UNKNOWN);
539 /*----------------------------------------------------------------------*/
541 OpenGl_QuadrangleStrip::OpenGl_QuadrangleStrip (const Graphic3d_Array2OfVertexNT& AListVertex)
543 const Standard_Integer nbr = AListVertex.RowLength ();
544 const Standard_Integer nbc = AListVertex.ColLength ();
545 const Standard_Integer nbf = nbr*nbc;
547 // Dynamic allocation
548 TEL_POINT *points = new TEL_POINT[nbf];
549 TEL_POINT *normals = new TEL_POINT[nbf];
550 TEL_TEXTURE_COORD *tcoords = new TEL_TEXTURE_COORD[nbf];
552 const Standard_Integer LowerRow = AListVertex.LowerRow ();
553 const Standard_Integer UpperRow = AListVertex.UpperRow ();
554 const Standard_Integer LowerCol = AListVertex.LowerCol ();
555 const Standard_Integer UpperCol = AListVertex.UpperCol ();
557 Standard_Integer i, j, k = 0;
558 Standard_Real X, Y, Z;
559 for (i=LowerRow; i<=UpperRow; i++)
560 for (j=LowerCol; j<=UpperCol; j++)
562 AListVertex (i, j).Coord (X, Y, Z);
563 points[k].xyz[0] = float (X);
564 points[k].xyz[1] = float (Y);
565 points[k].xyz[2] = float (Z);
566 AListVertex (i, j).Normal (X, Y, Z);
567 normals[k].xyz[0] = float (X);
568 normals[k].xyz[1] = float (Y);
569 normals[k].xyz[2] = float (Z);
570 AListVertex (i, j).TextureCoordinate(X, Y);
571 tcoords[k].xy[0] = float(X);
572 tcoords[k].xy[1] = float(Y);
576 Init(nbr,nbc,points,normals,NULL,tcoords,NULL,NULL,TEL_SHAPE_UNKNOWN);
579 /*----------------------------------------------------------------------*/
581 void OpenGl_QuadrangleStrip::Init (const Tint ANbRows, const Tint ANbCols, tel_point AVertices,
582 tel_point AVNormals, tel_colour AVColors, tel_texture_coord ATCoords,
583 tel_point AFNormals, tel_colour AFColors, const Tint AShapeFlag)
585 myData.num_rows = ANbRows;
586 myData.num_columns = ANbCols;
588 const Tint nf = ANbRows * ANbCols;
589 const Tint nv = ( ANbRows+1 ) * ( ANbCols+1 );
594 myData.vertices = AVertices;
596 // Store or compute (based on vertices) facet normals
599 myData.facet_flag = TEL_FA_NORMAL;
600 myData.fnormals = new TEL_POINT[nf];
601 memcpy( myData.fnormals, AFNormals, nf*sizeof(TEL_POINT) );
602 for( i = 0; i < nf; i++ )
603 vecnrm( myData.fnormals[i].xyz );
607 myData.facet_flag = TEL_FA_NONE;
608 myData.fnormals = new TEL_POINT[nf];
609 for( i = 0; i < nf; i++ )
611 const Tint r = i/ANbCols;
612 const Tint c = i%ANbCols;
613 const Tint id = r*(ANbCols+1) + c;
615 TEL_POINT p1, p2, p3, p4;
617 p1 = myData.vertices[id];
618 p2 = myData.vertices[id+ANbCols+1];
619 p3 = myData.vertices[id+ANbCols+2];
620 p4 = myData.vertices[id+1];
622 p4.xyz[0] -= p2.xyz[0];
623 p4.xyz[1] -= p2.xyz[1];
624 p4.xyz[2] -= p2.xyz[2];
626 p4.xyz[0] += p1.xyz[0];
627 p4.xyz[1] += p1.xyz[1];
628 p4.xyz[2] += p1.xyz[2];
630 TelGetNormal( p4.xyz, p1.xyz, p3.xyz, myData.fnormals[i].xyz );
634 // Store or compute (based on facet normals) vertex normals
637 myData.vertex_flag = TEL_VT_NORMAL;
638 myData.vnormals = AVNormals;
639 for( i = 0; i < nv; i++ )
640 vecnrm( myData.vnormals[i].xyz );
644 myData.vertex_flag = TEL_VT_NONE;
645 myData.vnormals = new TEL_POINT[nv];
647 for( i = 0; i < nv; i++ )
650 myData.vnormals[i] = myData.fnormals[i];
651 else if( i == (nv-1) )
652 myData.vnormals[i] = myData.fnormals[nf-1];
653 else if( i == (nv-ANbCols-1) )
654 myData.vnormals[i] = myData.fnormals[nf-ANbCols];
655 else if( i == ANbCols )
656 myData.vnormals[i] = myData.fnormals[i-1];
657 else if( i%(ANbCols+1) == 0 )
659 r = i/(myData.num_columns+1);
660 myData.vnormals[i].xyz[0] = ( myData.fnormals[(r-1)*ANbCols].xyz[0] + myData.fnormals[r*ANbCols].xyz[0] ) / 2.0F;
661 myData.vnormals[i].xyz[1] = ( myData.fnormals[(r-1)*ANbCols].xyz[1] + myData.fnormals[r*ANbCols].xyz[1] ) / 2.0F;
662 myData.vnormals[i].xyz[2] = ( myData.fnormals[(r-1)*ANbCols].xyz[2] + myData.fnormals[r*ANbCols].xyz[2] ) / 2.0F;
664 else if( i <= ANbCols )
666 myData.vnormals[i].xyz[0] = ( myData.fnormals[i-1].xyz[0] + myData.fnormals[i].xyz[0] ) / 2.0F;
667 myData.vnormals[i].xyz[1] = ( myData.fnormals[i-1].xyz[1] + myData.fnormals[i].xyz[1] ) / 2.0F;
668 myData.vnormals[i].xyz[2] = ( myData.fnormals[i-1].xyz[2] + myData.fnormals[i].xyz[2] ) / 2.0F;
670 else if( i >= (nv-ANbCols-1 ) )
675 myData.vnormals[i].xyz[0] = ( myData.fnormals[id-1].xyz[0] + myData.fnormals[id].xyz[0] ) / 2.0F;
676 myData.vnormals[i].xyz[1] = ( myData.fnormals[id-1].xyz[1] + myData.fnormals[id].xyz[1] ) / 2.0F;
677 myData.vnormals[i].xyz[2] = ( myData.fnormals[id-1].xyz[2] + myData.fnormals[id].xyz[2] ) / 2.0F;
679 else if( (i+1)%(ANbCols+1) == 0 )
681 r = (i+1)/(ANbCols+1);
682 myData.vnormals[i].xyz[0] = ( myData.fnormals[(r-1)*ANbCols-1].xyz[0] + myData.fnormals[r*ANbCols-1].xyz[0] ) / 2.0F;
683 myData.vnormals[i].xyz[1] = ( myData.fnormals[(r-1)*ANbCols-1].xyz[1] + myData.fnormals[r*ANbCols-1].xyz[1] ) / 2.0F;
684 myData.vnormals[i].xyz[2] = ( myData.fnormals[(r-1)*ANbCols-1].xyz[2] + myData.fnormals[r*ANbCols-1].xyz[2] ) / 2.0F;
693 myData.vnormals[i].xyz[0] = ( myData.fnormals[id].xyz[0] + myData.fnormals[id-ANbCols].xyz[0] + myData.fnormals[id-1].xyz[0] + myData.fnormals[id-ANbCols-1].xyz[0] ) / 4.0F;
694 myData.vnormals[i].xyz[1] = ( myData.fnormals[id].xyz[1] + myData.fnormals[id-ANbCols].xyz[1] + myData.fnormals[id-1].xyz[1] + myData.fnormals[id-ANbCols-1].xyz[1] ) / 4.0F;
695 myData.vnormals[i].xyz[2] = ( myData.fnormals[id].xyz[2] + myData.fnormals[id-ANbCols].xyz[2] + myData.fnormals[id-1].xyz[2] + myData.fnormals[id-ANbCols-1].xyz[2] ) / 4.0F;
700 myData.vcolours = AVColors;
701 myData.vtexturecoord = ATCoords;
702 myData.fcolours = AFColors;
704 myData.shape_flag = AShapeFlag;
706 myDS = new DS_INTERNAL;
711 myDS->skipRatio = 0.0F;
712 myDS->bDraw = new unsigned char[nv];
715 /*----------------------------------------------------------------------*/
717 OpenGl_QuadrangleStrip::~OpenGl_QuadrangleStrip ()
719 if( myData.fnormals )
720 delete[] myData.fnormals;
721 if( myData.fcolours )
722 delete[] myData.fcolours;
723 if( myData.vertices )
724 delete[] myData.vertices;
725 if( myData.vcolours )
726 delete[] myData.vcolours;
727 if( myData.vnormals )
728 delete[] myData.vnormals;
729 if ( myData.vtexturecoord )
730 delete[] myData.vtexturecoord;
734 if ( GET_GL_CONTEXT() != NULL )
736 if ( myDS->list ) glDeleteLists ( myDS->list, 1 );
737 if ( myDS->dlist ) glDeleteLists ( myDS->dlist, 1 );
740 delete[] myDS->bDraw;
746 /*----------------------------------------------------------------------*/
748 void OpenGl_QuadrangleStrip::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
750 const OpenGl_AspectFace *aspect_face = AWorkspace->AspectFace( Standard_True );
752 Tint front_lighting_model = aspect_face->Context().IntFront.color_mask;
753 const TEL_COLOUR *interior_colour = &aspect_face->Context().IntFront.matcol;
754 const TEL_COLOUR *edge_colour = &aspect_face->AspectEdge()->Color();
756 // Use highlight colors
757 if ( AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT )
759 edge_colour = interior_colour = AWorkspace->HighlightColor;
760 front_lighting_model = 0;
763 glColor3fv( interior_colour->rgb );
765 draw_qstrip( front_lighting_model,
766 aspect_face->Context().InteriorStyle,
771 /*----------------------------------------------------------------------*/