📄 backend.cc
字号:
/*
** License Applicability. Except to the extent portions of this file are
** made subject to an alternative license as permitted in the SGI Free
** Software License B, Version 1.1 (the "License"), the contents of this
** file are subject only to the provisions of the License. You may not use
** this file except in compliance with the License. You may obtain a copy
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
**
** http://oss.sgi.com/projects/FreeB
**
** Note that, as provided in the License, the Software is distributed on an
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
**
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
**
** Additional Notice Provisions: The application programming interfaces
** established by SGI in conjunction with the Original Code are The
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
** Window System(R) (Version 1.3), released October 19, 1998. This software
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
*/
/*
* backend.c++
*
* $Date: 2006-03-11 18:07:02 -0600 (Sat, 11 Mar 2006) $ $Revision: 1.1 $
* $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/lib/glu32/libnurbs/internals/backend.cc,v 1.1 2004/02/02 16:39:10 navaraf Exp $
*/
/* Bezier surface backend
- interprets display mode (wireframe,shaded,...)
*/
#include <stdio.h>
#include "glimports.h"
#include "mystdio.h"
#include "backend.h"
#include "basiccrveval.h"
#include "basicsurfeval.h"
#include "nurbsconsts.h"
#define NOWIREFRAME
/*-------------------------------------------------------------------------
* bgnsurf - preamble to surface definition and evaluations
*-------------------------------------------------------------------------
*/
void
Backend::bgnsurf( int wiretris, int wirequads, long nuid )
{
/*#ifndef NOWIREFRAME*/ //need this for old version
wireframetris = wiretris;
wireframequads = wirequads;
/*#endif*/
/*in the spec, GLU_DISPLAY_MODE is either
* GLU_FILL
* GLU_OUTLINE_POLY
* GLU_OUTLINE_PATCH.
*In fact, GLU_FLL is has the same effect as
* set GL_FRONT_AND_BACK to be GL_FILL
* and GLU_OUTLINE_POLY is the same as set
* GL_FRONT_AND_BACK to be GL_LINE
*It is more efficient to do this once at the beginning of
*each surface than to do it for each primitive.
* The internal has more options: outline_triangle and outline_quad
*can be seperated. But since this is not in spec, and more importantly,
*this is not so useful, so we don't need to keep this option.
*/
surfaceEvaluator.bgnmap2f( nuid );
if(wiretris)
surfaceEvaluator.polymode(N_MESHLINE);
else
surfaceEvaluator.polymode(N_MESHFILL);
}
void
Backend::patch( REAL ulo, REAL uhi, REAL vlo, REAL vhi )
{
surfaceEvaluator.domain2f( ulo, uhi, vlo, vhi );
}
void
Backend::surfbbox( long type, REAL *from, REAL *to )
{
surfaceEvaluator.range2f( type, from, to );
}
/*-------------------------------------------------------------------------
* surfpts - pass a desription of a surface map
*-------------------------------------------------------------------------
*/
void
Backend::surfpts(
long type, /* geometry, color, texture, normal */
REAL *pts, /* control points */
long ustride, /* distance to next point in u direction */
long vstride, /* distance to next point in v direction */
int uorder, /* u parametric order */
int vorder, /* v parametric order */
REAL ulo, /* u lower bound */
REAL uhi, /* u upper bound */
REAL vlo, /* v lower bound */
REAL vhi ) /* v upper bound */
{
surfaceEvaluator.map2f( type,ulo,uhi,ustride,uorder,vlo,vhi,vstride,vorder,pts );
surfaceEvaluator.enable( type );
}
/*-------------------------------------------------------------------------
* surfgrid - define a lattice of points with origin and offset
*-------------------------------------------------------------------------
*/
void
Backend::surfgrid( REAL u0, REAL u1, long nu, REAL v0, REAL v1, long nv )
{
surfaceEvaluator.mapgrid2f( nu, u0, u1, nv, v0, v1 );
}
/*-------------------------------------------------------------------------
* surfmesh - evaluate a mesh of points on lattice
*-------------------------------------------------------------------------
*/
void
Backend::surfmesh( long u, long v, long n, long m )
{
#ifndef NOWIREFRAME
if( wireframequads ) {
long v0, v1;
long u0f = u, u1f = u+n;
long v0f = v, v1f = v+m;
long parity = (u & 1);
for( v0 = v0f, v1 = v0f++ ; v0<v1f; v0 = v1, v1++ ) {
surfaceEvaluator.bgnline();
for( long u = u0f; u<=u1f; u++ ) {
if( parity ) {
surfaceEvaluator.evalpoint2i( u, v0 );
surfaceEvaluator.evalpoint2i( u, v1 );
} else {
surfaceEvaluator.evalpoint2i( u, v1 );
surfaceEvaluator.evalpoint2i( u, v0 );
}
parity = 1 - parity;
}
surfaceEvaluator.endline();
}
} else {
surfaceEvaluator.mapmesh2f( N_MESHFILL, u, u+n, v, v+m );
}
#else
if( wireframequads ) {
surfaceEvaluator.mapmesh2f( N_MESHLINE, u, u+n, v, v+m );
} else {
surfaceEvaluator.mapmesh2f( N_MESHFILL, u, u+n, v, v+m );
}
#endif
}
/*-------------------------------------------------------------------------
* endsurf - postamble to surface
*-------------------------------------------------------------------------
*/
void
Backend::endsurf( void )
{
surfaceEvaluator.endmap2f();
}
/***************************************/
void
Backend::bgntfan( void )
{
surfaceEvaluator.bgntfan();
/*
if(wireframetris)
surfaceEvaluator.polymode( N_MESHLINE );
else
surfaceEvaluator.polymode( N_MESHFILL );
*/
}
void
Backend::endtfan( void )
{
surfaceEvaluator.endtfan();
}
void
Backend::bgnqstrip( void )
{
surfaceEvaluator.bgnqstrip();
/*
if(wireframequads)
surfaceEvaluator.polymode( N_MESHLINE );
else
surfaceEvaluator.polymode( N_MESHFILL );
*/
}
void
Backend::endqstrip( void )
{
surfaceEvaluator.endqstrip();
}
void
Backend::evalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
int n_lower, REAL v_lower, REAL* lower_val
)
{
surfaceEvaluator.evalUStrip(n_upper, v_upper, upper_val,
n_lower, v_lower, lower_val);
}
void
Backend::evalVStrip(int n_left, REAL u_left, REAL* left_val,
int n_right, REAL u_right, REAL* right_val
)
{
surfaceEvaluator.evalVStrip(n_left, u_left, left_val,
n_right, u_right, right_val);
}
/***************************************/
/*-------------------------------------------------------------------------
* bgntmesh - preamble to a triangle mesh
*-------------------------------------------------------------------------
*/
void
Backend::bgntmesh( char * )
{
#ifndef NOWIREFRAME
meshindex = 0; /* I think these need to be initialized to zero */
npts = 0;
if( !wireframetris ) {
surfaceEvaluator.bgntmesh();
}
#else
if( wireframetris ) {
surfaceEvaluator.bgntmesh();
surfaceEvaluator.polymode( N_MESHLINE );
} else {
surfaceEvaluator.bgntmesh();
surfaceEvaluator.polymode( N_MESHFILL );
}
#endif
}
void
Backend::tmeshvert( GridTrimVertex *v )
{
if( v->isGridVert() ) {
tmeshvert( v->g );
} else {
tmeshvert( v->t );
}
}
void
Backend::tmeshvertNOGE(TrimVertex *t)
{
// surfaceEvaluator.inDoEvalCoord2NOGE( t->param[0], t->param[1], temp, ttt);
#ifdef USE_OPTTT
surfaceEvaluator.inDoEvalCoord2NOGE( t->param[0], t->param[1], t->cache_point, t->cache_normal);
#endif
}
//opt for a line with the same u.
void
Backend::tmeshvertNOGE_BU(TrimVertex *t)
{
#ifdef USE_OPTTT
surfaceEvaluator.inDoEvalCoord2NOGE_BU( t->param[0], t->param[1], t->cache_point, t->cache_normal);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -