mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 07:20:10 +01:00
Remove libGLU
It's been moved to its own repository, found at http://cgit.freedesktop.org/mesa/glu/ Acked-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
6a7dea93fa
commit
b95d598323
217 changed files with 18 additions and 58354 deletions
|
|
@ -94,7 +94,7 @@ MOTIF_CFLAGS = -I/usr/include/Motif1.2
|
|||
# Directories to build
|
||||
LIB_DIR = lib
|
||||
SRC_DIRS = glsl mapi/glapi mapi/vgapi mesa \
|
||||
gallium egl gallium/winsys gallium/targets glu
|
||||
gallium egl gallium/winsys gallium/targets
|
||||
DRIVER_DIRS = x11 osmesa
|
||||
|
||||
# Gallium directories and
|
||||
|
|
|
|||
67
configure.ac
67
configure.ac
|
|
@ -340,18 +340,12 @@ AC_ARG_WITH([gl-lib-name],
|
|||
[specify GL library name @<:@default=GL@:>@])],
|
||||
[GL_LIB=$withval],
|
||||
[GL_LIB=GL])
|
||||
AC_ARG_WITH([glu-lib-name],
|
||||
[AS_HELP_STRING([--with-glu-lib-name@<:@=NAME@:>@],
|
||||
[specify GLU library name @<:@default=GLU@:>@])],
|
||||
[GLU_LIB=$withval],
|
||||
[GLU_LIB=GLU])
|
||||
AC_ARG_WITH([osmesa-lib-name],
|
||||
[AS_HELP_STRING([--with-osmesa-lib-name@<:@=NAME@:>@],
|
||||
[specify OSMesa library name @<:@default=OSMesa@:>@])],
|
||||
[OSMESA_LIB=$withval],
|
||||
[OSMESA_LIB=OSMesa])
|
||||
AS_IF([test "x$GL_LIB" = xyes], [GL_LIB=GL])
|
||||
AS_IF([test "x$GLU_LIB" = xyes], [GLU_LIB=GLU])
|
||||
AS_IF([test "x$OSMESA_LIB" = xyes], [OSMESA_LIB=OSMesa])
|
||||
|
||||
dnl
|
||||
|
|
@ -366,11 +360,9 @@ AC_ARG_ENABLE([mangling],
|
|||
if test "x${enable_mangling}" = "xyes" ; then
|
||||
DEFINES="${DEFINES} -DUSE_MGL_NAMESPACE"
|
||||
GL_LIB="Mangled${GL_LIB}"
|
||||
GLU_LIB="Mangled${GLU_LIB}"
|
||||
OSMESA_LIB="Mangled${OSMESA_LIB}"
|
||||
fi
|
||||
AC_SUBST([GL_LIB])
|
||||
AC_SUBST([GLU_LIB])
|
||||
AC_SUBST([OSMESA_LIB])
|
||||
|
||||
dnl
|
||||
|
|
@ -389,7 +381,6 @@ if test "x$enable_texture_float" = xyes; then
|
|||
fi
|
||||
|
||||
GL_LIB_NAME='lib$(GL_LIB).'${LIB_EXTENSION}
|
||||
GLU_LIB_NAME='lib$(GLU_LIB).'${LIB_EXTENSION}
|
||||
OSMESA_LIB_NAME='lib$(OSMESA_LIB).'${LIB_EXTENSION}
|
||||
EGL_LIB_NAME='lib$(EGL_LIB).'${LIB_EXTENSION}
|
||||
GLESv1_CM_LIB_NAME='lib$(GLESv1_CM_LIB).'${LIB_EXTENSION}
|
||||
|
|
@ -398,7 +389,6 @@ VG_LIB_NAME='lib$(VG_LIB).'${LIB_EXTENSION}
|
|||
GLAPI_LIB_NAME='lib$(GLAPI_LIB).'${LIB_EXTENSION}
|
||||
|
||||
GL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
|
||||
GLU_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLU_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
|
||||
EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
|
||||
EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
|
||||
GLESv1_CM_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLESv1_CM_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
|
||||
|
|
@ -407,7 +397,6 @@ VG_LIB_GLOB=${LIB_PREFIX_GLOB}'$(VG_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENS
|
|||
GLAPI_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLAPI_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
|
||||
|
||||
AC_SUBST([GL_LIB_NAME])
|
||||
AC_SUBST([GLU_LIB_NAME])
|
||||
AC_SUBST([OSMESA_LIB_NAME])
|
||||
AC_SUBST([EGL_LIB_NAME])
|
||||
AC_SUBST([GLESv1_CM_LIB_NAME])
|
||||
|
|
@ -416,7 +405,6 @@ AC_SUBST([VG_LIB_NAME])
|
|||
AC_SUBST([GLAPI_LIB_NAME])
|
||||
|
||||
AC_SUBST([GL_LIB_GLOB])
|
||||
AC_SUBST([GLU_LIB_GLOB])
|
||||
AC_SUBST([EGL_LIB_GLOB])
|
||||
AC_SUBST([GLESv1_CM_LIB_GLOB])
|
||||
AC_SUBST([GLESv2_LIB_GLOB])
|
||||
|
|
@ -1465,60 +1453,6 @@ if test "x$enable_opencl" = xyes; then
|
|||
enable_gallium_loader=yes
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl GLU configuration
|
||||
dnl
|
||||
AC_ARG_ENABLE([glu],
|
||||
[AS_HELP_STRING([--disable-glu],
|
||||
[enable OpenGL Utility library @<:@default=enabled@:>@])],
|
||||
[enable_glu="$enableval"],
|
||||
[enable_glu=yes])
|
||||
|
||||
if test "x$enable_glu" = xyes; then
|
||||
if test "x$enable_glx" = xno -a "x$enable_osmesa" = xno; then
|
||||
AC_MSG_NOTICE([Disabling GLU since there is no OpenGL driver])
|
||||
enable_glu=no
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_glu" = xyes; then
|
||||
SRC_DIRS="$SRC_DIRS glu"
|
||||
|
||||
if test "x$enable_glx" = xno; then
|
||||
# Link libGLU to libOSMesa instead of libGL
|
||||
GLU_LIB_DEPS=""
|
||||
GLU_PC_REQ="osmesa"
|
||||
if test "$enable_static" = no; then
|
||||
GLU_MESA_DEPS='-l$(OSMESA_LIB)'
|
||||
else
|
||||
GLU_MESA_DEPS=""
|
||||
fi
|
||||
else
|
||||
# If static, empty GLU_LIB_DEPS and add libs for programs to link
|
||||
GLU_PC_REQ="gl"
|
||||
GLU_PC_LIB_PRIV="-lm"
|
||||
if test "$enable_static" = no; then
|
||||
GLU_LIB_DEPS="-lm"
|
||||
GLU_MESA_DEPS='-l$(GL_LIB)'
|
||||
else
|
||||
GLU_LIB_DEPS=""
|
||||
GLU_MESA_DEPS=""
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if test "$enable_static" = no; then
|
||||
GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
|
||||
fi
|
||||
GLU_PC_LIB_PRIV="$GLU_PC_LIB_PRIV $OS_CPLUSPLUS_LIBS"
|
||||
AC_SUBST([GLU_LIB_DEPS])
|
||||
AC_SUBST([GLU_MESA_DEPS])
|
||||
AC_SUBST([GLU_PC_REQ])
|
||||
AC_SUBST([GLU_PC_REQ_PRIV])
|
||||
AC_SUBST([GLU_PC_LIB_PRIV])
|
||||
AC_SUBST([GLU_PC_CFLAGS])
|
||||
|
||||
AC_SUBST([PROGRAM_DIRS])
|
||||
|
||||
dnl
|
||||
dnl Gallium configuration
|
||||
dnl
|
||||
|
|
@ -2116,7 +2050,6 @@ xyesno)
|
|||
esac
|
||||
|
||||
echo ""
|
||||
echo " GLU: $enable_glu"
|
||||
|
||||
dnl EGL
|
||||
echo ""
|
||||
|
|
|
|||
|
|
@ -17,10 +17,6 @@
|
|||
<li><a href="#dri">DRI Driver Options</a></li>
|
||||
<li><a href="#osmesa">OSMesa Driver Options</a></li>
|
||||
</ul>
|
||||
<li><p><a href="#library">Library Options</a>
|
||||
<ul>
|
||||
<li><a href="#glu">GLU</a></li>
|
||||
</ul>
|
||||
<li><p><a href="#demos">Demo Program Options</a>
|
||||
</ol>
|
||||
|
||||
|
|
@ -219,12 +215,6 @@ libraries that will be built. More details on the specific GL libraries
|
|||
can be found in the <a href="install.html">basic installation
|
||||
instructions</a>.
|
||||
|
||||
<dl>
|
||||
<dt id="glu">GLU <dd><p> The libGLU library will be built by default
|
||||
on all drivers. This can be disable with the option
|
||||
<code>--disable-glu</code>.
|
||||
</dl>
|
||||
|
||||
|
||||
<h2 id="demos">4. Demo Program Options</h2>
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@
|
|||
<li><a href="http://sourceforge.net/projects/mesa3d" target="_parent">SourceForge homepage</a>
|
||||
<li><a href="repository.html" target="MainFrame">Source Code Repository</a>
|
||||
<li><a href="sourcetree.html" target="MainFrame">Source Code Tree</a>
|
||||
<li><a href="glu.html" target="MainFrame">SGI's GLU</a>
|
||||
<li><a href="utilities.html" target="MainFrame">Utilities</a>
|
||||
<li><a href="helpwanted.html" target="MainFrame">Help Wanted</a>
|
||||
<li><a href="devinfo.html" target="MainFrame">Development Notes</a>
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ docs/ - documentation
|
|||
src/ - source code for libraries
|
||||
src/mesa - sources for the main Mesa library and device drivers
|
||||
src/gallium - sources for Gallium and Gallium drivers
|
||||
src/glu - libGLU source code
|
||||
src/glx - sources for building libGL with full GLX and DRI support
|
||||
</pre>
|
||||
|
||||
|
|
@ -80,7 +79,12 @@ instructions</a>.
|
|||
</p>
|
||||
|
||||
|
||||
<h1>Demos and GLUT</h1>
|
||||
<h1>Demos, GLUT, and GLU</h1>
|
||||
|
||||
<p>
|
||||
A package of SGI's GLU library is available
|
||||
<a href="ftp://ftp.freedesktop.org/pub/mesa/glu/" target="_parent">here</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
A package of Mark Kilgard's GLUT library is available
|
||||
|
|
@ -93,9 +97,13 @@ The Mesa demos collection is available
|
|||
</p>
|
||||
|
||||
<p>
|
||||
In the past, GLUT and the Mesa demos were released in conjunction with
|
||||
Mesa releases. But since GLUT and the demos change infrequently, they
|
||||
were split off some time ago.
|
||||
In the past, GLUT, GLU and the Mesa demos were released in conjunction with
|
||||
Mesa releases. But since GLUT, GLU and the demos change infrequently, they
|
||||
were split off into their own git repositories:
|
||||
|
||||
<a href="http://cgit.freedesktop.org/mesa/glut/">GLUT</a>,
|
||||
<a href="http://cgit.freedesktop.org/mesa/glu/">GLU</a> and
|
||||
<a href="http://cgit.freedesktop.org/mesa/demos/">Demos</a>,
|
||||
</p>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -226,10 +226,6 @@ Basically you'll want the following:
|
|||
</li><li>/usr/lib/libGL.so.1 - a symlink to libGL.so.1.xyz
|
||||
</li><li>/usr/lib/libGL.so.xyz - the actual OpenGL/Mesa library. xyz denotes the
|
||||
Mesa version number.
|
||||
</li><li>/usr/lib/libGLU.so - a symlink to libGLU.so.1
|
||||
</li><li>/usr/lib/libGLU.so.1 - a symlink to libGLU.so.1.3.xyz
|
||||
</li><li>/usr/lib/libGLU.so.xyz - the OpenGL Utility library. xyz denotes the Mesa
|
||||
version number.
|
||||
</li></ul>
|
||||
<p>
|
||||
After installing XFree86/X.org and the DRI drivers, some of these files
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>SGI GLU</title>
|
||||
<link rel="stylesheet" type="text/css" href="mesa.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>SGI SI GLU</h1>
|
||||
|
||||
(Silicon Graphics, Inc. Sample Implementation of the OpenGL Utility library)
|
||||
|
||||
<p>
|
||||
SGI open-sourced their OpenGL Sample Implementation (SI) in January, 2000.
|
||||
This includes the GLU library.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The SI GLU library implements GLU version 1.3 whereas the original
|
||||
Mesa GLU library only implemented version 1.2.
|
||||
We recommend using the SI GLU library instead of Mesa's GLU library
|
||||
since it's more up-to-date, complete and reliable.
|
||||
We're no longer developing the original Mesa GLU library.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The SI GLU library code is included in the Mesa distribution.
|
||||
You don't have to download it separately.
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<b>Olivier Michel</b> has made Linux RPMs of GLU for i386 and PowerPC.
|
||||
You can download them from the
|
||||
<a href="http://www.sourceforge.net/project/showfiles.php?group_id=3"
|
||||
target="_parent">download area</a> under <b>Miscellaneous</b>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Visit the <a href="http://oss.sgi.com/projects/ogl-sample/" target="_parent">
|
||||
OpenGL Sample Implementation home page</a> for more information about the SI.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -151,9 +151,6 @@ You'll see a set of library files similar to this:
|
|||
lrwxrwxrwx 1 brian users 10 Mar 26 07:53 libGL.so -> libGL.so.1*
|
||||
lrwxrwxrwx 1 brian users 19 Mar 26 07:53 libGL.so.1 -> libGL.so.1.5.060100*
|
||||
-rwxr-xr-x 1 brian users 3375861 Mar 26 07:53 libGL.so.1.5.060100*
|
||||
lrwxrwxrwx 1 brian users 11 Mar 26 07:53 libGLU.so -> libGLU.so.1*
|
||||
lrwxrwxrwx 1 brian users 20 Mar 26 07:53 libGLU.so.1 -> libGLU.so.1.3.060100*
|
||||
-rwxr-xr-x 1 brian users 549269 Mar 26 07:53 libGLU.so.1.3.060100*
|
||||
lrwxrwxrwx 1 brian users 14 Mar 26 07:53 libOSMesa.so -> libOSMesa.so.6*
|
||||
lrwxrwxrwx 1 brian users 23 Mar 26 07:53 libOSMesa.so.6 -> libOSMesa.so.6.1.060100*
|
||||
-rwxr-xr-x 1 brian users 23871 Mar 26 07:53 libOSMesa.so.6.1.060100*
|
||||
|
|
@ -162,8 +159,6 @@ lrwxrwxrwx 1 brian users 23 Mar 26 07:53 libOSMesa.so.6 -> libOSM
|
|||
<p>
|
||||
<b>libGL</b> is the main OpenGL library (i.e. Mesa).
|
||||
<br>
|
||||
<b>libGLU</b> is the OpenGL Utility library.
|
||||
<br>
|
||||
<b>libOSMesa</b> is the OSMesa (Off-Screen) interface library.
|
||||
</p>
|
||||
|
||||
|
|
|
|||
|
|
@ -95,8 +95,6 @@ Device drivers src/mesa/drivers/* MIT, generally
|
|||
|
||||
Ext headers include/GL/glext.h Khronos
|
||||
include/GL/glxext.h
|
||||
|
||||
SGI GLU library src/glu/sgi/ SGI Free B
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -82,6 +82,10 @@ The two supported build methods are now autoconf/automake and SCons.
|
|||
<li>Removed Gallium3D - nvfx driver (use nv30 instead)</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
libGLU has been moved into its own repository, found at <a href="http://cgit.freedesktop.org/mesa/glu/">http://cgit.freedesktop.org/mesa/glu/</a>
|
||||
</p>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -146,11 +146,6 @@ each directory.
|
|||
</ul>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><b>glu</b> - The OpenGL Utility library
|
||||
<ul>
|
||||
<li><b>sgi</b> - GLU from SGI
|
||||
<li><b>mesa</b> - Mesa version of GLU (deprecated)
|
||||
</ul>
|
||||
<li><b>glx</b> - The GLX library code for building libGL. This is used for
|
||||
direct rendering drivers. It will dynamically load one of the
|
||||
xxx_dri.so drivers.
|
||||
|
|
|
|||
353
include/GL/glu.h
353
include/GL/glu.h
|
|
@ -1,353 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __glu_h__
|
||||
#define __glu_h__
|
||||
|
||||
#if defined(USE_MGL_NAMESPACE)
|
||||
#include "glu_mangle.h"
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
#ifndef GLAPIENTRY
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#define GLAPIENTRY __stdcall
|
||||
#else
|
||||
#define GLAPIENTRY
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GLAPIENTRYP
|
||||
#define GLAPIENTRYP GLAPIENTRY *
|
||||
#endif
|
||||
|
||||
#if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GLU32)
|
||||
# undef GLAPI
|
||||
# define GLAPI __declspec(dllexport)
|
||||
#elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL)
|
||||
/* tag specifying we're building for DLL runtime support */
|
||||
# undef GLAPI
|
||||
# define GLAPI __declspec(dllimport)
|
||||
#elif !defined(GLAPI)
|
||||
/* for use with static link lib build of Win32 edition only */
|
||||
# define GLAPI extern
|
||||
#endif /* _STATIC_MESA support */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
/* Extensions */
|
||||
#define GLU_EXT_object_space_tess 1
|
||||
#define GLU_EXT_nurbs_tessellator 1
|
||||
|
||||
/* Boolean */
|
||||
#define GLU_FALSE 0
|
||||
#define GLU_TRUE 1
|
||||
|
||||
/* Version */
|
||||
#define GLU_VERSION_1_1 1
|
||||
#define GLU_VERSION_1_2 1
|
||||
#define GLU_VERSION_1_3 1
|
||||
|
||||
/* StringName */
|
||||
#define GLU_VERSION 100800
|
||||
#define GLU_EXTENSIONS 100801
|
||||
|
||||
/* ErrorCode */
|
||||
#define GLU_INVALID_ENUM 100900
|
||||
#define GLU_INVALID_VALUE 100901
|
||||
#define GLU_OUT_OF_MEMORY 100902
|
||||
#define GLU_INCOMPATIBLE_GL_VERSION 100903
|
||||
#define GLU_INVALID_OPERATION 100904
|
||||
|
||||
/* NurbsDisplay */
|
||||
/* GLU_FILL */
|
||||
#define GLU_OUTLINE_POLYGON 100240
|
||||
#define GLU_OUTLINE_PATCH 100241
|
||||
|
||||
/* NurbsCallback */
|
||||
#define GLU_NURBS_ERROR 100103
|
||||
#define GLU_ERROR 100103
|
||||
#define GLU_NURBS_BEGIN 100164
|
||||
#define GLU_NURBS_BEGIN_EXT 100164
|
||||
#define GLU_NURBS_VERTEX 100165
|
||||
#define GLU_NURBS_VERTEX_EXT 100165
|
||||
#define GLU_NURBS_NORMAL 100166
|
||||
#define GLU_NURBS_NORMAL_EXT 100166
|
||||
#define GLU_NURBS_COLOR 100167
|
||||
#define GLU_NURBS_COLOR_EXT 100167
|
||||
#define GLU_NURBS_TEXTURE_COORD 100168
|
||||
#define GLU_NURBS_TEX_COORD_EXT 100168
|
||||
#define GLU_NURBS_END 100169
|
||||
#define GLU_NURBS_END_EXT 100169
|
||||
#define GLU_NURBS_BEGIN_DATA 100170
|
||||
#define GLU_NURBS_BEGIN_DATA_EXT 100170
|
||||
#define GLU_NURBS_VERTEX_DATA 100171
|
||||
#define GLU_NURBS_VERTEX_DATA_EXT 100171
|
||||
#define GLU_NURBS_NORMAL_DATA 100172
|
||||
#define GLU_NURBS_NORMAL_DATA_EXT 100172
|
||||
#define GLU_NURBS_COLOR_DATA 100173
|
||||
#define GLU_NURBS_COLOR_DATA_EXT 100173
|
||||
#define GLU_NURBS_TEXTURE_COORD_DATA 100174
|
||||
#define GLU_NURBS_TEX_COORD_DATA_EXT 100174
|
||||
#define GLU_NURBS_END_DATA 100175
|
||||
#define GLU_NURBS_END_DATA_EXT 100175
|
||||
|
||||
/* NurbsError */
|
||||
#define GLU_NURBS_ERROR1 100251
|
||||
#define GLU_NURBS_ERROR2 100252
|
||||
#define GLU_NURBS_ERROR3 100253
|
||||
#define GLU_NURBS_ERROR4 100254
|
||||
#define GLU_NURBS_ERROR5 100255
|
||||
#define GLU_NURBS_ERROR6 100256
|
||||
#define GLU_NURBS_ERROR7 100257
|
||||
#define GLU_NURBS_ERROR8 100258
|
||||
#define GLU_NURBS_ERROR9 100259
|
||||
#define GLU_NURBS_ERROR10 100260
|
||||
#define GLU_NURBS_ERROR11 100261
|
||||
#define GLU_NURBS_ERROR12 100262
|
||||
#define GLU_NURBS_ERROR13 100263
|
||||
#define GLU_NURBS_ERROR14 100264
|
||||
#define GLU_NURBS_ERROR15 100265
|
||||
#define GLU_NURBS_ERROR16 100266
|
||||
#define GLU_NURBS_ERROR17 100267
|
||||
#define GLU_NURBS_ERROR18 100268
|
||||
#define GLU_NURBS_ERROR19 100269
|
||||
#define GLU_NURBS_ERROR20 100270
|
||||
#define GLU_NURBS_ERROR21 100271
|
||||
#define GLU_NURBS_ERROR22 100272
|
||||
#define GLU_NURBS_ERROR23 100273
|
||||
#define GLU_NURBS_ERROR24 100274
|
||||
#define GLU_NURBS_ERROR25 100275
|
||||
#define GLU_NURBS_ERROR26 100276
|
||||
#define GLU_NURBS_ERROR27 100277
|
||||
#define GLU_NURBS_ERROR28 100278
|
||||
#define GLU_NURBS_ERROR29 100279
|
||||
#define GLU_NURBS_ERROR30 100280
|
||||
#define GLU_NURBS_ERROR31 100281
|
||||
#define GLU_NURBS_ERROR32 100282
|
||||
#define GLU_NURBS_ERROR33 100283
|
||||
#define GLU_NURBS_ERROR34 100284
|
||||
#define GLU_NURBS_ERROR35 100285
|
||||
#define GLU_NURBS_ERROR36 100286
|
||||
#define GLU_NURBS_ERROR37 100287
|
||||
|
||||
/* NurbsProperty */
|
||||
#define GLU_AUTO_LOAD_MATRIX 100200
|
||||
#define GLU_CULLING 100201
|
||||
#define GLU_SAMPLING_TOLERANCE 100203
|
||||
#define GLU_DISPLAY_MODE 100204
|
||||
#define GLU_PARAMETRIC_TOLERANCE 100202
|
||||
#define GLU_SAMPLING_METHOD 100205
|
||||
#define GLU_U_STEP 100206
|
||||
#define GLU_V_STEP 100207
|
||||
#define GLU_NURBS_MODE 100160
|
||||
#define GLU_NURBS_MODE_EXT 100160
|
||||
#define GLU_NURBS_TESSELLATOR 100161
|
||||
#define GLU_NURBS_TESSELLATOR_EXT 100161
|
||||
#define GLU_NURBS_RENDERER 100162
|
||||
#define GLU_NURBS_RENDERER_EXT 100162
|
||||
|
||||
/* NurbsSampling */
|
||||
#define GLU_OBJECT_PARAMETRIC_ERROR 100208
|
||||
#define GLU_OBJECT_PARAMETRIC_ERROR_EXT 100208
|
||||
#define GLU_OBJECT_PATH_LENGTH 100209
|
||||
#define GLU_OBJECT_PATH_LENGTH_EXT 100209
|
||||
#define GLU_PATH_LENGTH 100215
|
||||
#define GLU_PARAMETRIC_ERROR 100216
|
||||
#define GLU_DOMAIN_DISTANCE 100217
|
||||
|
||||
/* NurbsTrim */
|
||||
#define GLU_MAP1_TRIM_2 100210
|
||||
#define GLU_MAP1_TRIM_3 100211
|
||||
|
||||
/* QuadricDrawStyle */
|
||||
#define GLU_POINT 100010
|
||||
#define GLU_LINE 100011
|
||||
#define GLU_FILL 100012
|
||||
#define GLU_SILHOUETTE 100013
|
||||
|
||||
/* QuadricCallback */
|
||||
/* GLU_ERROR */
|
||||
|
||||
/* QuadricNormal */
|
||||
#define GLU_SMOOTH 100000
|
||||
#define GLU_FLAT 100001
|
||||
#define GLU_NONE 100002
|
||||
|
||||
/* QuadricOrientation */
|
||||
#define GLU_OUTSIDE 100020
|
||||
#define GLU_INSIDE 100021
|
||||
|
||||
/* TessCallback */
|
||||
#define GLU_TESS_BEGIN 100100
|
||||
#define GLU_BEGIN 100100
|
||||
#define GLU_TESS_VERTEX 100101
|
||||
#define GLU_VERTEX 100101
|
||||
#define GLU_TESS_END 100102
|
||||
#define GLU_END 100102
|
||||
#define GLU_TESS_ERROR 100103
|
||||
#define GLU_TESS_EDGE_FLAG 100104
|
||||
#define GLU_EDGE_FLAG 100104
|
||||
#define GLU_TESS_COMBINE 100105
|
||||
#define GLU_TESS_BEGIN_DATA 100106
|
||||
#define GLU_TESS_VERTEX_DATA 100107
|
||||
#define GLU_TESS_END_DATA 100108
|
||||
#define GLU_TESS_ERROR_DATA 100109
|
||||
#define GLU_TESS_EDGE_FLAG_DATA 100110
|
||||
#define GLU_TESS_COMBINE_DATA 100111
|
||||
|
||||
/* TessContour */
|
||||
#define GLU_CW 100120
|
||||
#define GLU_CCW 100121
|
||||
#define GLU_INTERIOR 100122
|
||||
#define GLU_EXTERIOR 100123
|
||||
#define GLU_UNKNOWN 100124
|
||||
|
||||
/* TessProperty */
|
||||
#define GLU_TESS_WINDING_RULE 100140
|
||||
#define GLU_TESS_BOUNDARY_ONLY 100141
|
||||
#define GLU_TESS_TOLERANCE 100142
|
||||
|
||||
/* TessError */
|
||||
#define GLU_TESS_ERROR1 100151
|
||||
#define GLU_TESS_ERROR2 100152
|
||||
#define GLU_TESS_ERROR3 100153
|
||||
#define GLU_TESS_ERROR4 100154
|
||||
#define GLU_TESS_ERROR5 100155
|
||||
#define GLU_TESS_ERROR6 100156
|
||||
#define GLU_TESS_ERROR7 100157
|
||||
#define GLU_TESS_ERROR8 100158
|
||||
#define GLU_TESS_MISSING_BEGIN_POLYGON 100151
|
||||
#define GLU_TESS_MISSING_BEGIN_CONTOUR 100152
|
||||
#define GLU_TESS_MISSING_END_POLYGON 100153
|
||||
#define GLU_TESS_MISSING_END_CONTOUR 100154
|
||||
#define GLU_TESS_COORD_TOO_LARGE 100155
|
||||
#define GLU_TESS_NEED_COMBINE_CALLBACK 100156
|
||||
|
||||
/* TessWinding */
|
||||
#define GLU_TESS_WINDING_ODD 100130
|
||||
#define GLU_TESS_WINDING_NONZERO 100131
|
||||
#define GLU_TESS_WINDING_POSITIVE 100132
|
||||
#define GLU_TESS_WINDING_NEGATIVE 100133
|
||||
#define GLU_TESS_WINDING_ABS_GEQ_TWO 100134
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
class GLUnurbs;
|
||||
class GLUquadric;
|
||||
class GLUtesselator;
|
||||
#else
|
||||
typedef struct GLUnurbs GLUnurbs;
|
||||
typedef struct GLUquadric GLUquadric;
|
||||
typedef struct GLUtesselator GLUtesselator;
|
||||
#endif
|
||||
|
||||
typedef GLUnurbs GLUnurbsObj;
|
||||
typedef GLUquadric GLUquadricObj;
|
||||
typedef GLUtesselator GLUtesselatorObj;
|
||||
typedef GLUtesselator GLUtriangulatorObj;
|
||||
|
||||
#define GLU_TESS_MAX_COORD 1.0e150
|
||||
|
||||
/* Internal convenience typedefs */
|
||||
typedef void (GLAPIENTRYP _GLUfuncptr)(void);
|
||||
|
||||
GLAPI void GLAPIENTRY gluBeginCurve (GLUnurbs* nurb);
|
||||
GLAPI void GLAPIENTRY gluBeginPolygon (GLUtesselator* tess);
|
||||
GLAPI void GLAPIENTRY gluBeginSurface (GLUnurbs* nurb);
|
||||
GLAPI void GLAPIENTRY gluBeginTrim (GLUnurbs* nurb);
|
||||
GLAPI GLint GLAPIENTRY gluBuild1DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
|
||||
GLAPI GLint GLAPIENTRY gluBuild1DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void *data);
|
||||
GLAPI GLint GLAPIENTRY gluBuild2DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
|
||||
GLAPI GLint GLAPIENTRY gluBuild2DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data);
|
||||
GLAPI GLint GLAPIENTRY gluBuild3DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
|
||||
GLAPI GLint GLAPIENTRY gluBuild3DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data);
|
||||
GLAPI GLboolean GLAPIENTRY gluCheckExtension (const GLubyte *extName, const GLubyte *extString);
|
||||
GLAPI void GLAPIENTRY gluCylinder (GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks);
|
||||
GLAPI void GLAPIENTRY gluDeleteNurbsRenderer (GLUnurbs* nurb);
|
||||
GLAPI void GLAPIENTRY gluDeleteQuadric (GLUquadric* quad);
|
||||
GLAPI void GLAPIENTRY gluDeleteTess (GLUtesselator* tess);
|
||||
GLAPI void GLAPIENTRY gluDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops);
|
||||
GLAPI void GLAPIENTRY gluEndCurve (GLUnurbs* nurb);
|
||||
GLAPI void GLAPIENTRY gluEndPolygon (GLUtesselator* tess);
|
||||
GLAPI void GLAPIENTRY gluEndSurface (GLUnurbs* nurb);
|
||||
GLAPI void GLAPIENTRY gluEndTrim (GLUnurbs* nurb);
|
||||
GLAPI const GLubyte * GLAPIENTRY gluErrorString (GLenum error);
|
||||
GLAPI void GLAPIENTRY gluGetNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat* data);
|
||||
GLAPI const GLubyte * GLAPIENTRY gluGetString (GLenum name);
|
||||
GLAPI void GLAPIENTRY gluGetTessProperty (GLUtesselator* tess, GLenum which, GLdouble* data);
|
||||
GLAPI void GLAPIENTRY gluLoadSamplingMatrices (GLUnurbs* nurb, const GLfloat *model, const GLfloat *perspective, const GLint *view);
|
||||
GLAPI void GLAPIENTRY gluLookAt (GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ);
|
||||
GLAPI GLUnurbs* GLAPIENTRY gluNewNurbsRenderer (void);
|
||||
GLAPI GLUquadric* GLAPIENTRY gluNewQuadric (void);
|
||||
GLAPI GLUtesselator* GLAPIENTRY gluNewTess (void);
|
||||
GLAPI void GLAPIENTRY gluNextContour (GLUtesselator* tess, GLenum type);
|
||||
GLAPI void GLAPIENTRY gluNurbsCallback (GLUnurbs* nurb, GLenum which, _GLUfuncptr CallBackFunc);
|
||||
GLAPI void GLAPIENTRY gluNurbsCallbackData (GLUnurbs* nurb, GLvoid* userData);
|
||||
GLAPI void GLAPIENTRY gluNurbsCallbackDataEXT (GLUnurbs* nurb, GLvoid* userData);
|
||||
GLAPI void GLAPIENTRY gluNurbsCurve (GLUnurbs* nurb, GLint knotCount, GLfloat *knots, GLint stride, GLfloat *control, GLint order, GLenum type);
|
||||
GLAPI void GLAPIENTRY gluNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat value);
|
||||
GLAPI void GLAPIENTRY gluNurbsSurface (GLUnurbs* nurb, GLint sKnotCount, GLfloat* sKnots, GLint tKnotCount, GLfloat* tKnots, GLint sStride, GLint tStride, GLfloat* control, GLint sOrder, GLint tOrder, GLenum type);
|
||||
GLAPI void GLAPIENTRY gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top);
|
||||
GLAPI void GLAPIENTRY gluPartialDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start, GLdouble sweep);
|
||||
GLAPI void GLAPIENTRY gluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
|
||||
GLAPI void GLAPIENTRY gluPickMatrix (GLdouble x, GLdouble y, GLdouble delX, GLdouble delY, GLint *viewport);
|
||||
GLAPI GLint GLAPIENTRY gluProject (GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ);
|
||||
GLAPI void GLAPIENTRY gluPwlCurve (GLUnurbs* nurb, GLint count, GLfloat* data, GLint stride, GLenum type);
|
||||
GLAPI void GLAPIENTRY gluQuadricCallback (GLUquadric* quad, GLenum which, _GLUfuncptr CallBackFunc);
|
||||
GLAPI void GLAPIENTRY gluQuadricDrawStyle (GLUquadric* quad, GLenum draw);
|
||||
GLAPI void GLAPIENTRY gluQuadricNormals (GLUquadric* quad, GLenum normal);
|
||||
GLAPI void GLAPIENTRY gluQuadricOrientation (GLUquadric* quad, GLenum orientation);
|
||||
GLAPI void GLAPIENTRY gluQuadricTexture (GLUquadric* quad, GLboolean texture);
|
||||
GLAPI GLint GLAPIENTRY gluScaleImage (GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void *dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid* dataOut);
|
||||
GLAPI void GLAPIENTRY gluSphere (GLUquadric* quad, GLdouble radius, GLint slices, GLint stacks);
|
||||
GLAPI void GLAPIENTRY gluTessBeginContour (GLUtesselator* tess);
|
||||
GLAPI void GLAPIENTRY gluTessBeginPolygon (GLUtesselator* tess, GLvoid* data);
|
||||
GLAPI void GLAPIENTRY gluTessCallback (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc);
|
||||
GLAPI void GLAPIENTRY gluTessEndContour (GLUtesselator* tess);
|
||||
GLAPI void GLAPIENTRY gluTessEndPolygon (GLUtesselator* tess);
|
||||
GLAPI void GLAPIENTRY gluTessNormal (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ);
|
||||
GLAPI void GLAPIENTRY gluTessProperty (GLUtesselator* tess, GLenum which, GLdouble data);
|
||||
GLAPI void GLAPIENTRY gluTessVertex (GLUtesselator* tess, GLdouble *location, GLvoid* data);
|
||||
GLAPI GLint GLAPIENTRY gluUnProject (GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* objX, GLdouble* objY, GLdouble* objZ);
|
||||
GLAPI GLint GLAPIENTRY gluUnProject4 (GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble nearVal, GLdouble farVal, GLdouble* objX, GLdouble* objY, GLdouble* objZ, GLdouble* objW);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __glu_h__ */
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.0
|
||||
* Copyright (C) 1995-1998 Brian Paul
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GLU_MANGLE_H
|
||||
#define GLU_MANGLE_H
|
||||
|
||||
|
||||
#define gluLookAt mgluLookAt
|
||||
#define gluOrtho2D mgluOrtho2D
|
||||
#define gluPerspective mgluPerspective
|
||||
#define gluPickMatrix mgluPickMatrix
|
||||
#define gluProject mgluProject
|
||||
#define gluUnProject mgluUnProject
|
||||
#define gluErrorString mgluErrorString
|
||||
#define gluScaleImage mgluScaleImage
|
||||
#define gluBuild1DMipmaps mgluBuild1DMipmaps
|
||||
#define gluBuild2DMipmaps mgluBuild2DMipmaps
|
||||
#define gluNewQuadric mgluNewQuadric
|
||||
#define gluDeleteQuadric mgluDeleteQuadric
|
||||
#define gluQuadricDrawStyle mgluQuadricDrawStyle
|
||||
#define gluQuadricOrientation mgluQuadricOrientation
|
||||
#define gluQuadricNormals mgluQuadricNormals
|
||||
#define gluQuadricTexture mgluQuadricTexture
|
||||
#define gluQuadricCallback mgluQuadricCallback
|
||||
#define gluCylinder mgluCylinder
|
||||
#define gluSphere mgluSphere
|
||||
#define gluDisk mgluDisk
|
||||
#define gluPartialDisk mgluPartialDisk
|
||||
#define gluNewNurbsRenderer mgluNewNurbsRenderer
|
||||
#define gluDeleteNurbsRenderer mgluDeleteNurbsRenderer
|
||||
#define gluLoadSamplingMatrices mgluLoadSamplingMatrices
|
||||
#define gluNurbsProperty mgluNurbsProperty
|
||||
#define gluGetNurbsProperty mgluGetNurbsProperty
|
||||
#define gluBeginCurve mgluBeginCurve
|
||||
#define gluEndCurve mgluEndCurve
|
||||
#define gluNurbsCurve mgluNurbsCurve
|
||||
#define gluBeginSurface mgluBeginSurface
|
||||
#define gluEndSurface mgluEndSurface
|
||||
#define gluNurbsSurface mgluNurbsSurface
|
||||
#define gluBeginTrim mgluBeginTrim
|
||||
#define gluEndTrim mgluEndTrim
|
||||
#define gluPwlCurve mgluPwlCurve
|
||||
#define gluNurbsCallback mgluNurbsCallback
|
||||
#define gluNewTess mgluNewTess
|
||||
#define gluDeleteTess mgluDeleteTess
|
||||
#define gluTessBeginPolygon mgluTessBeginPolygon
|
||||
#define gluTessBeginContour mgluTessBeginContour
|
||||
#define gluTessVertex mgluTessVertex
|
||||
#define gluTessEndPolygon mgluTessEndPolygon
|
||||
#define gluTessEndContour mgluTessEndContour
|
||||
#define gluTessProperty mgluTessProperty
|
||||
#define gluTessNormal mgluTessNormal
|
||||
#define gluTessCallback mgluTessCallback
|
||||
#define gluGetTessProperty mgluGetTessProperty
|
||||
#define gluBeginPolygon mgluBeginPolygon
|
||||
#define gluNextContour mgluNextContour
|
||||
#define gluEndPolygon mgluEndPolygon
|
||||
#define gluGetString mgluGetString
|
||||
#define gluBuild1DMipmapLevels mgluBuild1DMipmapLevels
|
||||
#define gluBuild2DMipmapLevels mgluBuild2DMipmapLevels
|
||||
#define gluBuild3DMipmapLevels mgluBuild3DMipmapLevels
|
||||
#define gluBuild3DMipmaps mgluBuild3DMipmaps
|
||||
#define gluCheckExtension mgluCheckExtension
|
||||
#define gluUnProject4 mgluUnProject4
|
||||
#define gluNurbsCallbackData mgluNurbsCallbackData
|
||||
#define gluNurbsCallbackDataEXT mgluNurbsCallbackDataEXT
|
||||
|
||||
#endif
|
||||
|
|
@ -27,8 +27,6 @@ if not env['embedded']:
|
|||
SConscript('glx/SConscript')
|
||||
if env['platform'] not in ['darwin', 'haiku', 'sunos']:
|
||||
SConscript('egl/main/SConscript')
|
||||
if env['platform'] not in ['darwin']:
|
||||
SConscript('glu/sgi/SConscript')
|
||||
|
||||
if env['gles']:
|
||||
SConscript('mapi/shared-glapi/SConscript')
|
||||
|
|
|
|||
1
src/glu/.gitignore
vendored
1
src/glu/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
|||
exptmp
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
# src/glu/Makefile
|
||||
|
||||
TOP = ../..
|
||||
|
||||
include $(TOP)/configs/current
|
||||
|
||||
|
||||
SUBDIRS = sgi
|
||||
|
||||
|
||||
default: $(TOP)/configs/current
|
||||
@for dir in $(SUBDIRS) ; do \
|
||||
(cd $$dir && $(MAKE)) || exit 1 ; \
|
||||
done
|
||||
|
||||
# GLU pkg-config file
|
||||
pcedit = sed \
|
||||
-e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
|
||||
-e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \
|
||||
-e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \
|
||||
-e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),' \
|
||||
-e 's,@GLU_PC_REQ@,$(GLU_PC_REQ),' \
|
||||
-e 's,@GLU_PC_REQ_PRIV@,$(GLU_PC_REQ_PRIV),' \
|
||||
-e 's,@GLU_PC_LIB_PRIV@,$(GLU_PC_LIB_PRIV),' \
|
||||
-e 's,@GLU_PC_CFLAGS@,$(GLU_PC_CFLAGS),' \
|
||||
-e 's,@GLU_LIB@,$(GLU_LIB),'
|
||||
glu.pc: glu.pc.in
|
||||
$(pcedit) $< > $@
|
||||
|
||||
install: glu.pc
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
|
||||
$(MINSTALL) $(TOP)/$(LIB_DIR)/$(GLU_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR)
|
||||
$(INSTALL) -m 644 glu.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
|
||||
|
||||
clean:
|
||||
-@for dir in $(SUBDIRS) ; do \
|
||||
(cd $$dir && $(MAKE) clean) ; \
|
||||
done
|
||||
-rm -f *.pc
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
prefix=@INSTALL_DIR@
|
||||
exec_prefix=${prefix}
|
||||
libdir=@INSTALL_LIB_DIR@
|
||||
includedir=@INSTALL_INC_DIR@
|
||||
|
||||
Name: glu
|
||||
Description: Mesa OpenGL Utility library
|
||||
Requires: @GLU_PC_REQ@
|
||||
Requires.private: @GLU_PC_REQ_PRIV@
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -l@GLU_LIB@
|
||||
Libs.private: @GLU_PC_LIB_PRIV@
|
||||
Cflags: -I${includedir} @GLU_PC_CFLAGS@
|
||||
1
src/glu/sgi/.gitignore
vendored
1
src/glu/sgi/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
|||
exptmp
|
||||
|
|
@ -1,144 +0,0 @@
|
|||
# src/glu/sgi/Makefile
|
||||
|
||||
.SUFFIXES : .cc
|
||||
|
||||
TOP = ../../..
|
||||
|
||||
include $(TOP)/configs/current
|
||||
|
||||
GLU_MAJOR = 1
|
||||
GLU_MINOR = 3
|
||||
GLU_TINY = 0$(MESA_MAJOR)$(MESA_MINOR)0$(MESA_TINY)
|
||||
|
||||
INCDIRS = -I$(TOP)/include -Iinclude -Iinternals -Ilibnurbs/internals -Ilibnurbs/interface -Ilibnurbs/nurbtess
|
||||
|
||||
C_SOURCES = \
|
||||
libutil/error.c \
|
||||
libutil/glue.c \
|
||||
libutil/mipmap.c \
|
||||
libutil/project.c \
|
||||
libutil/quad.c \
|
||||
libutil/registry.c \
|
||||
libtess/dict.c \
|
||||
libtess/geom.c \
|
||||
libtess/memalloc.c \
|
||||
libtess/mesh.c \
|
||||
libtess/normal.c \
|
||||
libtess/priorityq.c \
|
||||
libtess/render.c \
|
||||
libtess/sweep.c \
|
||||
libtess/tess.c \
|
||||
libtess/tessmono.c
|
||||
|
||||
CC_SOURCES = \
|
||||
libnurbs/interface/bezierEval.cc \
|
||||
libnurbs/interface/bezierPatch.cc \
|
||||
libnurbs/interface/bezierPatchMesh.cc \
|
||||
libnurbs/interface/glcurveval.cc \
|
||||
libnurbs/interface/glinterface.cc \
|
||||
libnurbs/interface/glrenderer.cc \
|
||||
libnurbs/interface/glsurfeval.cc \
|
||||
libnurbs/interface/incurveeval.cc \
|
||||
libnurbs/interface/insurfeval.cc \
|
||||
libnurbs/internals/arc.cc \
|
||||
libnurbs/internals/arcsorter.cc \
|
||||
libnurbs/internals/arctess.cc \
|
||||
libnurbs/internals/backend.cc \
|
||||
libnurbs/internals/basiccrveval.cc \
|
||||
libnurbs/internals/basicsurfeval.cc \
|
||||
libnurbs/internals/bin.cc \
|
||||
libnurbs/internals/bufpool.cc \
|
||||
libnurbs/internals/cachingeval.cc \
|
||||
libnurbs/internals/ccw.cc \
|
||||
libnurbs/internals/coveandtiler.cc \
|
||||
libnurbs/internals/curve.cc \
|
||||
libnurbs/internals/curvelist.cc \
|
||||
libnurbs/internals/curvesub.cc \
|
||||
libnurbs/internals/dataTransform.cc \
|
||||
libnurbs/internals/displaylist.cc \
|
||||
libnurbs/internals/flist.cc \
|
||||
libnurbs/internals/flistsorter.cc \
|
||||
libnurbs/internals/hull.cc \
|
||||
libnurbs/internals/intersect.cc \
|
||||
libnurbs/internals/knotvector.cc \
|
||||
libnurbs/internals/mapdesc.cc \
|
||||
libnurbs/internals/mapdescv.cc \
|
||||
libnurbs/internals/maplist.cc \
|
||||
libnurbs/internals/mesher.cc \
|
||||
libnurbs/internals/monoTriangulationBackend.cc \
|
||||
libnurbs/internals/monotonizer.cc \
|
||||
libnurbs/internals/mycode.cc \
|
||||
libnurbs/internals/nurbsinterfac.cc \
|
||||
libnurbs/internals/nurbstess.cc \
|
||||
libnurbs/internals/patch.cc \
|
||||
libnurbs/internals/patchlist.cc \
|
||||
libnurbs/internals/quilt.cc \
|
||||
libnurbs/internals/reader.cc \
|
||||
libnurbs/internals/renderhints.cc \
|
||||
libnurbs/internals/slicer.cc \
|
||||
libnurbs/internals/sorter.cc \
|
||||
libnurbs/internals/splitarcs.cc \
|
||||
libnurbs/internals/subdivider.cc \
|
||||
libnurbs/internals/tobezier.cc \
|
||||
libnurbs/internals/trimline.cc \
|
||||
libnurbs/internals/trimregion.cc \
|
||||
libnurbs/internals/trimvertpool.cc \
|
||||
libnurbs/internals/uarray.cc \
|
||||
libnurbs/internals/varray.cc \
|
||||
libnurbs/nurbtess/directedLine.cc \
|
||||
libnurbs/nurbtess/gridWrap.cc \
|
||||
libnurbs/nurbtess/monoChain.cc \
|
||||
libnurbs/nurbtess/monoPolyPart.cc \
|
||||
libnurbs/nurbtess/monoTriangulation.cc \
|
||||
libnurbs/nurbtess/partitionX.cc \
|
||||
libnurbs/nurbtess/partitionY.cc \
|
||||
libnurbs/nurbtess/polyDBG.cc \
|
||||
libnurbs/nurbtess/polyUtil.cc \
|
||||
libnurbs/nurbtess/primitiveStream.cc \
|
||||
libnurbs/nurbtess/quicksort.cc \
|
||||
libnurbs/nurbtess/rectBlock.cc \
|
||||
libnurbs/nurbtess/sampleComp.cc \
|
||||
libnurbs/nurbtess/sampleCompBot.cc \
|
||||
libnurbs/nurbtess/sampleCompRight.cc \
|
||||
libnurbs/nurbtess/sampleCompTop.cc \
|
||||
libnurbs/nurbtess/sampleMonoPoly.cc \
|
||||
libnurbs/nurbtess/sampledLine.cc \
|
||||
libnurbs/nurbtess/searchTree.cc
|
||||
|
||||
SOURCES = $(C_SOURCES) $(CC_SOURCES)
|
||||
|
||||
C_OBJECTS = $(C_SOURCES:.c=.o)
|
||||
CC_OBJECTS = $(CC_SOURCES:.cc=.o)
|
||||
OBJECTS = $(C_OBJECTS) $(CC_OBJECTS)
|
||||
|
||||
|
||||
##### RULES #####
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCDIRS) $(CFLAGS) -DNDEBUG -DLIBRARYBUILD $< -o $@
|
||||
|
||||
.cc.o:
|
||||
$(CXX) -c $(INCDIRS) $(CXXFLAGS) -DNDEBUG -DLIBRARYBUILD $< -o $@
|
||||
|
||||
|
||||
##### TARGETS #####
|
||||
|
||||
default:
|
||||
$(MAKE) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME)
|
||||
|
||||
$(TOP)/$(LIB_DIR):
|
||||
-mkdir $(TOP)/$(LIB_DIR)
|
||||
|
||||
# Make the library:
|
||||
$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME): $(OBJECTS)
|
||||
$(MKLIB) -o $(GLU_LIB) -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
|
||||
-major $(GLU_MAJOR) -minor $(GLU_MINOR) -patch $(GLU_TINY) \
|
||||
-cplusplus $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \
|
||||
-exports glu.exports -id $(INSTALL_LIB_DIR)/lib$(GLU_LIB).$(GLU_MAJOR).dylib \
|
||||
$(GLU_LIB_DEPS) $(OBJECTS)
|
||||
|
||||
|
||||
clean:
|
||||
-rm -f *.o */*.o */*/*.o
|
||||
-rm -f *.lo */*.lo */*/*.lo
|
||||
-rm -f *.la */*.la */*/*.la
|
||||
|
|
@ -1,143 +0,0 @@
|
|||
Import('*')
|
||||
|
||||
env = env.Clone()
|
||||
|
||||
env.Prepend(CPPPATH = [
|
||||
'include',
|
||||
'internals',
|
||||
'libnurbs/internals',
|
||||
'libnurbs/interface',
|
||||
'libnurbs/nurbtess',
|
||||
])
|
||||
|
||||
env.Prepend(CPPDEFINES = [
|
||||
'LIBRARYBUILD',
|
||||
'RESOLVE_3D_TEXTURE_SUPPORT',
|
||||
])
|
||||
|
||||
sources = [
|
||||
'libutil/error.c',
|
||||
'libutil/glue.c',
|
||||
'libutil/mipmap.c',
|
||||
'libutil/project.c',
|
||||
'libutil/quad.c',
|
||||
'libutil/registry.c',
|
||||
'libtess/dict.c',
|
||||
'libtess/geom.c',
|
||||
'libtess/memalloc.c',
|
||||
'libtess/mesh.c',
|
||||
'libtess/normal.c',
|
||||
'libtess/priorityq.c',
|
||||
'libtess/render.c',
|
||||
'libtess/sweep.c',
|
||||
'libtess/tess.c',
|
||||
'libtess/tessmono.c',
|
||||
'libnurbs/interface/bezierEval.cc',
|
||||
'libnurbs/interface/bezierPatch.cc',
|
||||
'libnurbs/interface/bezierPatchMesh.cc',
|
||||
'libnurbs/interface/glcurveval.cc',
|
||||
'libnurbs/interface/glinterface.cc',
|
||||
'libnurbs/interface/glrenderer.cc',
|
||||
'libnurbs/interface/glsurfeval.cc',
|
||||
'libnurbs/interface/incurveeval.cc',
|
||||
'libnurbs/interface/insurfeval.cc',
|
||||
'libnurbs/internals/arc.cc',
|
||||
'libnurbs/internals/arcsorter.cc',
|
||||
'libnurbs/internals/arctess.cc',
|
||||
'libnurbs/internals/backend.cc',
|
||||
'libnurbs/internals/basiccrveval.cc',
|
||||
'libnurbs/internals/basicsurfeval.cc',
|
||||
'libnurbs/internals/bin.cc',
|
||||
'libnurbs/internals/bufpool.cc',
|
||||
'libnurbs/internals/cachingeval.cc',
|
||||
'libnurbs/internals/ccw.cc',
|
||||
'libnurbs/internals/coveandtiler.cc',
|
||||
'libnurbs/internals/curve.cc',
|
||||
'libnurbs/internals/curvelist.cc',
|
||||
'libnurbs/internals/curvesub.cc',
|
||||
'libnurbs/internals/dataTransform.cc',
|
||||
'libnurbs/internals/displaylist.cc',
|
||||
'libnurbs/internals/flist.cc',
|
||||
'libnurbs/internals/flistsorter.cc',
|
||||
'libnurbs/internals/hull.cc',
|
||||
'libnurbs/internals/intersect.cc',
|
||||
'libnurbs/internals/knotvector.cc',
|
||||
'libnurbs/internals/mapdesc.cc',
|
||||
'libnurbs/internals/mapdescv.cc',
|
||||
'libnurbs/internals/maplist.cc',
|
||||
'libnurbs/internals/mesher.cc',
|
||||
'libnurbs/internals/monoTriangulationBackend.cc',
|
||||
'libnurbs/internals/monotonizer.cc',
|
||||
'libnurbs/internals/mycode.cc',
|
||||
'libnurbs/internals/nurbsinterfac.cc',
|
||||
'libnurbs/internals/nurbstess.cc',
|
||||
'libnurbs/internals/patch.cc',
|
||||
'libnurbs/internals/patchlist.cc',
|
||||
'libnurbs/internals/quilt.cc',
|
||||
'libnurbs/internals/reader.cc',
|
||||
'libnurbs/internals/renderhints.cc',
|
||||
'libnurbs/internals/slicer.cc',
|
||||
'libnurbs/internals/sorter.cc',
|
||||
'libnurbs/internals/splitarcs.cc',
|
||||
'libnurbs/internals/subdivider.cc',
|
||||
'libnurbs/internals/tobezier.cc',
|
||||
'libnurbs/internals/trimline.cc',
|
||||
'libnurbs/internals/trimregion.cc',
|
||||
'libnurbs/internals/trimvertpool.cc',
|
||||
'libnurbs/internals/uarray.cc',
|
||||
'libnurbs/internals/varray.cc',
|
||||
'libnurbs/nurbtess/directedLine.cc',
|
||||
'libnurbs/nurbtess/gridWrap.cc',
|
||||
'libnurbs/nurbtess/monoChain.cc',
|
||||
'libnurbs/nurbtess/monoPolyPart.cc',
|
||||
'libnurbs/nurbtess/monoTriangulation.cc',
|
||||
'libnurbs/nurbtess/partitionX.cc',
|
||||
'libnurbs/nurbtess/partitionY.cc',
|
||||
'libnurbs/nurbtess/polyDBG.cc',
|
||||
'libnurbs/nurbtess/polyUtil.cc',
|
||||
'libnurbs/nurbtess/primitiveStream.cc',
|
||||
'libnurbs/nurbtess/quicksort.cc',
|
||||
'libnurbs/nurbtess/rectBlock.cc',
|
||||
'libnurbs/nurbtess/sampleComp.cc',
|
||||
'libnurbs/nurbtess/sampleCompBot.cc',
|
||||
'libnurbs/nurbtess/sampleCompRight.cc',
|
||||
'libnurbs/nurbtess/sampleCompTop.cc',
|
||||
'libnurbs/nurbtess/sampleMonoPoly.cc',
|
||||
'libnurbs/nurbtess/sampledLine.cc',
|
||||
'libnurbs/nurbtess/searchTree.cc',
|
||||
]
|
||||
|
||||
if env['platform'] == 'windows':
|
||||
# -D_OPENGL32_ -Iinclude -DBUILD_GL32
|
||||
env.PrependUnique(LIBS = [
|
||||
'gdi32',
|
||||
'user32',
|
||||
'opengl32',
|
||||
])
|
||||
target = 'glu32'
|
||||
sources += ['glu.def']
|
||||
else:
|
||||
env.PrependUnique(LIBS = [
|
||||
'GL',
|
||||
])
|
||||
target = 'glu'
|
||||
|
||||
if env['platform'] == 'haiku':
|
||||
glu = env.StaticLibrary(
|
||||
target = target,
|
||||
source = sources
|
||||
)
|
||||
else:
|
||||
glu = env.SharedLibrary(
|
||||
target = target,
|
||||
source = sources
|
||||
)
|
||||
env.Alias('glu', env.InstallSharedLibrary(glu, version=(1, 3, 0)))
|
||||
|
||||
|
||||
if env['platform'] == 'windows':
|
||||
glu = env.FindIxes(glu, 'LIBPREFIX', 'LIBSUFFIX')
|
||||
else:
|
||||
glu = env.FindIxes(glu, 'SHLIBPREFIX', 'SHLIBSUFFIX')
|
||||
|
||||
Export('glu')
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
/*
|
||||
* This file contains nothing. It's just there so there's at least a single
|
||||
* source file for libGLU.la in this directory.
|
||||
*/
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
;DESCRIPTION 'Mesa GLU (OpenGL work-alike) for Win32'
|
||||
VERSION 5.1
|
||||
;
|
||||
; Module definition file for GLU (GLU32.DLL)
|
||||
;
|
||||
; Note: The GLU functions use the STDCALL
|
||||
; function calling convention. Microsoft's
|
||||
; GLU32 uses this convention and so must the
|
||||
; Mesa GLU32 so that the Mesa DLL can be used
|
||||
; as a drop-in replacement.
|
||||
;
|
||||
; The linker exports STDCALL entry points with
|
||||
; 'decorated' names; e.g., _glBegin@0, where the
|
||||
; trailing number is the number of bytes of
|
||||
; parameter data pushed onto the stack. The
|
||||
; callee is responsible for popping this data
|
||||
; off the stack, usually via a RETF n instruction.
|
||||
;
|
||||
; However, the Microsoft GLU32.DLL does not export
|
||||
; the decorated names, even though the calling convention
|
||||
; is STDCALL. So, this module definition file is
|
||||
; needed to force the Mesa GLU32.DLL to export the
|
||||
; symbols in the same manner as the Microsoft DLL.
|
||||
; Were it not for this problem, this file would not
|
||||
; be needed (for the glu* functions) since the entry
|
||||
; points are compiled with dllexport declspec.
|
||||
;
|
||||
|
||||
EXPORTS
|
||||
gluBeginCurve
|
||||
gluBeginPolygon
|
||||
gluBeginSurface
|
||||
gluBeginTrim
|
||||
gluBuild1DMipmapLevels
|
||||
gluBuild1DMipmaps
|
||||
gluBuild2DMipmapLevels
|
||||
gluBuild2DMipmaps
|
||||
gluBuild3DMipmapLevels
|
||||
gluBuild3DMipmaps
|
||||
gluCheckExtension
|
||||
gluCylinder
|
||||
gluDeleteNurbsRenderer
|
||||
gluDeleteQuadric
|
||||
gluDeleteTess
|
||||
gluDisk
|
||||
gluEndCurve
|
||||
gluEndPolygon
|
||||
gluEndSurface
|
||||
gluEndTrim
|
||||
gluErrorString
|
||||
gluGetNurbsProperty
|
||||
gluGetString
|
||||
gluGetTessProperty
|
||||
gluLoadSamplingMatrices
|
||||
gluLookAt
|
||||
gluNewNurbsRenderer
|
||||
gluNewQuadric
|
||||
gluNewTess
|
||||
gluNextContour
|
||||
gluNurbsCallback
|
||||
gluNurbsCallbackData
|
||||
gluNurbsCallbackDataEXT
|
||||
gluNurbsCurve
|
||||
gluNurbsProperty
|
||||
gluNurbsSurface
|
||||
gluOrtho2D
|
||||
gluPartialDisk
|
||||
gluPerspective
|
||||
gluPickMatrix
|
||||
gluProject
|
||||
gluPwlCurve
|
||||
gluQuadricCallback
|
||||
gluQuadricDrawStyle
|
||||
gluQuadricNormals
|
||||
gluQuadricOrientation
|
||||
gluQuadricTexture
|
||||
gluScaleImage
|
||||
gluSphere
|
||||
gluTessBeginContour
|
||||
gluTessBeginPolygon
|
||||
gluTessCallback
|
||||
gluTessEndContour
|
||||
gluTessEndPolygon
|
||||
gluTessNormal
|
||||
gluTessProperty
|
||||
gluTessVertex
|
||||
gluUnProject
|
||||
gluUnProject4
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
gluBeginCurve
|
||||
gluBeginPolygon
|
||||
gluBeginSurface
|
||||
gluBeginTrim
|
||||
gluBuild1DMipmapLevels
|
||||
gluBuild1DMipmaps
|
||||
gluBuild2DMipmapLevels
|
||||
gluBuild2DMipmaps
|
||||
gluBuild3DMipmapLevels
|
||||
gluBuild3DMipmaps
|
||||
gluCheckExtension
|
||||
gluCylinder
|
||||
gluDeleteNurbsRenderer
|
||||
gluDeleteQuadric
|
||||
gluDeleteTess
|
||||
gluDisk
|
||||
gluEndCurve
|
||||
gluEndPolygon
|
||||
gluEndSurface
|
||||
gluEndTrim
|
||||
gluErrorString
|
||||
gluGetNurbsProperty
|
||||
gluGetString
|
||||
gluGetTessProperty
|
||||
gluLoadSamplingMatrices
|
||||
gluLookAt
|
||||
gluNewNurbsRenderer
|
||||
gluNewQuadric
|
||||
gluNewTess
|
||||
gluNextContour
|
||||
gluNurbsCallback
|
||||
gluNurbsCallbackData
|
||||
gluNurbsCallbackDataEXT
|
||||
gluNurbsCurve
|
||||
gluNurbsProperty
|
||||
gluNurbsSurface
|
||||
gluOrtho2D
|
||||
gluPartialDisk
|
||||
gluPerspective
|
||||
gluPickMatrix
|
||||
gluProject
|
||||
gluPwlCurve
|
||||
gluQuadricCallback
|
||||
gluQuadricDrawStyle
|
||||
gluQuadricNormals
|
||||
gluQuadricOrientation
|
||||
gluQuadricTexture
|
||||
gluScaleImage
|
||||
gluSphere
|
||||
gluTessBeginContour
|
||||
gluTessBeginPolygon
|
||||
gluTessCallback
|
||||
gluTessEndContour
|
||||
gluTessEndPolygon
|
||||
gluTessNormal
|
||||
gluTessProperty
|
||||
gluTessVertex
|
||||
gluUnProject
|
||||
gluUnProject4
|
||||
mgluBeginCurve
|
||||
mgluBeginPolygon
|
||||
mgluBeginSurface
|
||||
mgluBeginTrim
|
||||
mgluBuild1DMipmapLevels
|
||||
mgluBuild1DMipmaps
|
||||
mgluBuild2DMipmapLevels
|
||||
mgluBuild2DMipmaps
|
||||
mgluBuild3DMipmapLevels
|
||||
mgluBuild3DMipmaps
|
||||
mgluCheckExtension
|
||||
mgluCylinder
|
||||
mgluDeleteNurbsRenderer
|
||||
mgluDeleteQuadric
|
||||
mgluDeleteTess
|
||||
mgluDisk
|
||||
mgluEndCurve
|
||||
mgluEndPolygon
|
||||
mgluEndSurface
|
||||
mgluEndTrim
|
||||
mgluErrorString
|
||||
mgluGetNurbsProperty
|
||||
mgluGetString
|
||||
mgluGetTessProperty
|
||||
mgluLoadSamplingMatrices
|
||||
mgluLookAt
|
||||
mgluNewNurbsRenderer
|
||||
mgluNewQuadric
|
||||
mgluNewTess
|
||||
mgluNextContour
|
||||
mgluNurbsCallback
|
||||
mgluNurbsCallbackData
|
||||
mgluNurbsCallbackDataEXT
|
||||
mgluNurbsCurve
|
||||
mgluNurbsProperty
|
||||
mgluNurbsSurface
|
||||
mgluOrtho2D
|
||||
mgluPartialDisk
|
||||
mgluPerspective
|
||||
mgluPickMatrix
|
||||
mgluProject
|
||||
mgluPwlCurve
|
||||
mgluQuadricCallback
|
||||
mgluQuadricDrawStyle
|
||||
mgluQuadricNormals
|
||||
mgluQuadricOrientation
|
||||
mgluQuadricTexture
|
||||
mgluScaleImage
|
||||
mgluSphere
|
||||
mgluTessBeginContour
|
||||
mgluTessBeginPolygon
|
||||
mgluTessCallback
|
||||
mgluTessEndContour
|
||||
mgluTessEndPolygon
|
||||
mgluTessNormal
|
||||
mgluTessProperty
|
||||
mgluTessVertex
|
||||
mgluUnProject
|
||||
mgluUnProject4
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
_*gluBeginCurve
|
||||
_*gluBeginPolygon
|
||||
_*gluBeginSurface
|
||||
_*gluBeginTrim
|
||||
_*gluBuild1DMipmapLevels
|
||||
_*gluBuild1DMipmaps
|
||||
_*gluBuild2DMipmapLevels
|
||||
_*gluBuild2DMipmaps
|
||||
_*gluBuild3DMipmapLevels
|
||||
_*gluBuild3DMipmaps
|
||||
_*gluCheckExtension
|
||||
_*gluCylinder
|
||||
_*gluDeleteNurbsRenderer
|
||||
_*gluDeleteQuadric
|
||||
_*gluDeleteTess
|
||||
_*gluDisk
|
||||
_*gluEndCurve
|
||||
_*gluEndPolygon
|
||||
_*gluEndSurface
|
||||
_*gluEndTrim
|
||||
_*gluErrorString
|
||||
_*gluGetNurbsProperty
|
||||
_*gluGetString
|
||||
_*gluGetTessProperty
|
||||
_*gluLoadSamplingMatrices
|
||||
_*gluLookAt
|
||||
_*gluNewNurbsRenderer
|
||||
_*gluNewQuadric
|
||||
_*gluNewTess
|
||||
_*gluNextContour
|
||||
_*gluNurbsCallback
|
||||
_*gluNurbsCallbackData
|
||||
_*gluNurbsCallbackDataEXT
|
||||
_*gluNurbsCurve
|
||||
_*gluNurbsProperty
|
||||
_*gluNurbsSurface
|
||||
_*gluOrtho2D
|
||||
_*gluPartialDisk
|
||||
_*gluPerspective
|
||||
_*gluPickMatrix
|
||||
_*gluProject
|
||||
_*gluPwlCurve
|
||||
_*gluQuadricCallback
|
||||
_*gluQuadricDrawStyle
|
||||
_*gluQuadricNormals
|
||||
_*gluQuadricOrientation
|
||||
_*gluQuadricTexture
|
||||
_*gluScaleImage
|
||||
_*gluSphere
|
||||
_*gluTessBeginContour
|
||||
_*gluTessBeginPolygon
|
||||
_*gluTessCallback
|
||||
_*gluTessEndContour
|
||||
_*gluTessEndPolygon
|
||||
_*gluTessNormal
|
||||
_*gluTessProperty
|
||||
_*gluTessVertex
|
||||
_*gluUnProject
|
||||
_*gluUnProject4
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
** gluos.h - operating system dependencies for GLU
|
||||
**
|
||||
*/
|
||||
#ifdef __VMS
|
||||
#ifdef __cplusplus
|
||||
#pragma message disable nocordel
|
||||
#pragma message disable codeunreachable
|
||||
#pragma message disable codcauunr
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
/* Disable *lots* of warnings to get a clean build. I can't be bothered fixing the
|
||||
* code at the moment, as it is pretty ugly.
|
||||
*/
|
||||
#pragma warning 7 10
|
||||
#pragma warning 13 10
|
||||
#pragma warning 14 10
|
||||
#pragma warning 367 10
|
||||
#pragma warning 379 10
|
||||
#pragma warning 726 10
|
||||
#pragma warning 836 10
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_FOR_SNAP
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
#include <stdlib.h> /* For _MAX_PATH definition */
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOGDI
|
||||
#define NOIME
|
||||
#define NOMINMAX
|
||||
|
||||
#ifdef __MINGW64_VERSION_MAJOR
|
||||
#undef _WIN32_WINNT
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WINNT
|
||||
/* XXX: Workaround a bug in mingw-w64's headers when NOGDI is set and
|
||||
* _WIN32_WINNT >= 0x0600 */
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#endif
|
||||
#ifndef STRICT
|
||||
#define STRICT 1
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
/* Disable warnings */
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable : 4101)
|
||||
#pragma warning(disable : 4244)
|
||||
#pragma warning(disable : 4761)
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1200 && _MSC_VER < 1300
|
||||
#pragma comment(linker, "/OPT:NOWIN98")
|
||||
#endif
|
||||
|
||||
#ifndef WINGDIAPI
|
||||
#define WINGDIAPI
|
||||
#endif
|
||||
|
||||
#elif defined(__OS2__)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#define WINGDIAPI
|
||||
|
||||
#else
|
||||
|
||||
/* Disable Microsoft-specific keywords */
|
||||
#define GLAPIENTRY
|
||||
#define WINGDIAPI
|
||||
|
||||
#endif
|
||||
|
|
@ -1,260 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
**
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include "bezierEval.h"
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
#pragma warning 14 10
|
||||
#endif
|
||||
|
||||
#define TOLERANCE 0.0001
|
||||
|
||||
#ifndef MAX_ORDER
|
||||
#define MAX_ORDER 16
|
||||
#endif
|
||||
|
||||
#ifndef MAX_DIMENSION
|
||||
#define MAX_DIMENSION 4
|
||||
#endif
|
||||
|
||||
static void normalize(float vec[3]);
|
||||
static void crossProduct(float x[3], float y[3], float ret[3]);
|
||||
#if 0 // UNUSED
|
||||
static void bezierCurveEvalfast(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retpoint[]);
|
||||
#endif
|
||||
|
||||
static float binomialCoefficients[8][8] = {
|
||||
{1,0,0,0,0,0,0,0},
|
||||
{1,1,0,0,0,0,0,0},
|
||||
{1,2,1,0,0,0,0,0},
|
||||
{1,3,3,1,0,0,0,0},
|
||||
{1,4,6,4,1,0,0,0},
|
||||
{1,5,10,10,5,1,0,0},
|
||||
{1,6,15,20,15,6,1,0},
|
||||
{1,7,21,35,35,21,7,1}
|
||||
};
|
||||
|
||||
void bezierCurveEval(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retpoint[])
|
||||
{
|
||||
float uprime = (u-u0)/(u1-u0);
|
||||
float *ctlptr = ctlpoints;
|
||||
float oneMinusX = 1.0f-uprime;
|
||||
float XPower = 1.0f;
|
||||
|
||||
int i,k;
|
||||
for(k=0; k<dimension; k++)
|
||||
retpoint[k] = (*(ctlptr + k));
|
||||
|
||||
for(i=1; i<order; i++){
|
||||
ctlptr += stride;
|
||||
XPower *= uprime;
|
||||
for(k=0; k<dimension; k++) {
|
||||
retpoint[k] = retpoint[k]*oneMinusX + ctlptr[k]* binomialCoefficients[order-1][i] * XPower;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0 // UNUSED
|
||||
/*order = degree +1 >=1.
|
||||
*/
|
||||
void bezierCurveEvalfast(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retpoint[])
|
||||
{
|
||||
float uprime = (u-u0)/(u1-u0);
|
||||
float buf[MAX_ORDER][MAX_ORDER][MAX_DIMENSION];
|
||||
float* ctlptr = ctlpoints;
|
||||
int r, i,j;
|
||||
for(i=0; i<order; i++) {
|
||||
for(j=0; j<dimension; j++)
|
||||
buf[0][i][j] = ctlptr[j];
|
||||
ctlptr += stride;
|
||||
}
|
||||
for(r=1; r<order; r++){
|
||||
for(i=0; i<order-r; i++) {
|
||||
for(j=0; j<dimension; j++)
|
||||
buf[r][i][j] = (1-uprime)*buf[r-1][i][j] + uprime*buf[r-1][i+1][j];
|
||||
}
|
||||
}
|
||||
|
||||
for(j=0; j<dimension; j++)
|
||||
retpoint[j] = buf[order-1][0][j];
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*order = degree +1 >=1.
|
||||
*/
|
||||
void bezierCurveEvalDer(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retDer[])
|
||||
{
|
||||
int i,k;
|
||||
float width = u1-u0;
|
||||
float *ctlptr = ctlpoints;
|
||||
|
||||
float buf[MAX_ORDER][MAX_DIMENSION];
|
||||
if(order == 1){
|
||||
for(k=0; k<dimension; k++)
|
||||
retDer[k]=0;
|
||||
}
|
||||
for(i=0; i<order-1; i++){
|
||||
for(k=0; k<dimension; k++) {
|
||||
buf[i][k] = (ctlptr[stride+k] - ctlptr[k])*(order-1)/width;
|
||||
}
|
||||
ctlptr += stride;
|
||||
}
|
||||
|
||||
bezierCurveEval(u0, u1, order-1, (float*) buf, MAX_DIMENSION, dimension, u, retDer);
|
||||
}
|
||||
|
||||
void bezierCurveEvalDerGen(int der, float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retDer[])
|
||||
{
|
||||
int i,k,r;
|
||||
float *ctlptr = ctlpoints;
|
||||
float width=u1-u0;
|
||||
float buf[MAX_ORDER][MAX_ORDER][MAX_DIMENSION];
|
||||
if(der<0) der=0;
|
||||
for(i=0; i<order; i++){
|
||||
for(k=0; k<dimension; k++){
|
||||
buf[0][i][k] = ctlptr[k];
|
||||
}
|
||||
ctlptr += stride;
|
||||
}
|
||||
|
||||
|
||||
for(r=1; r<=der; r++){
|
||||
for(i=0; i<order-r; i++){
|
||||
for(k=0; k<dimension; k++){
|
||||
buf[r][i][k] = (buf[r-1][i+1][k] - buf[r-1][i][k])*(order-r)/width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bezierCurveEval(u0, u1, order-der, (float *) (buf[der]), MAX_DIMENSION, dimension, u, retDer);
|
||||
}
|
||||
|
||||
/*the Bezier bivarite polynomial is:
|
||||
* sum[i:0,uorder-1][j:0,vorder-1] { ctlpoints[i*ustride+j*vstride] * B(i)*B(j)
|
||||
* where B(i) and B(j) are basis functions
|
||||
*/
|
||||
void bezierSurfEvalDerGen(int uder, int vder, float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float ret[])
|
||||
{
|
||||
int i;
|
||||
float newPoints[MAX_ORDER][MAX_DIMENSION];
|
||||
|
||||
for(i=0; i<uorder; i++){
|
||||
|
||||
bezierCurveEvalDerGen(vder, v0, v1, vorder, ctlpoints+ustride*i, vstride, dimension, v, newPoints[i]);
|
||||
|
||||
}
|
||||
|
||||
bezierCurveEvalDerGen(uder, u0, u1, uorder, (float *) newPoints, MAX_DIMENSION, dimension, u, ret);
|
||||
}
|
||||
|
||||
|
||||
/*division by w is performed*/
|
||||
void bezierSurfEval(float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float ret[])
|
||||
{
|
||||
bezierSurfEvalDerGen(0, 0, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, ret);
|
||||
if(dimension == 4) /*homogeneous*/{
|
||||
ret[0] /= ret[3];
|
||||
ret[1] /= ret[3];
|
||||
ret[2] /= ret[3];
|
||||
}
|
||||
}
|
||||
|
||||
void bezierSurfEvalNormal(float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float retNormal[])
|
||||
{
|
||||
float partialU[4];
|
||||
float partialV[4];
|
||||
assert(dimension>=3 && dimension <=4);
|
||||
bezierSurfEvalDerGen(1,0, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, partialU);
|
||||
bezierSurfEvalDerGen(0,1, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, partialV);
|
||||
|
||||
if(dimension == 3){/*inhomogeneous*/
|
||||
crossProduct(partialU, partialV, retNormal);
|
||||
|
||||
normalize(retNormal);
|
||||
|
||||
return;
|
||||
}
|
||||
else { /*homogeneous*/
|
||||
float val[4]; /*the point coordinates (without derivative)*/
|
||||
float newPartialU[MAX_DIMENSION];
|
||||
float newPartialV[MAX_DIMENSION];
|
||||
int i;
|
||||
bezierSurfEvalDerGen(0,0, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, val);
|
||||
|
||||
for(i=0; i<=2; i++){
|
||||
newPartialU[i] = partialU[i] * val[3] - val[i] * partialU[3];
|
||||
newPartialV[i] = partialV[i] * val[3] - val[i] * partialV[3];
|
||||
}
|
||||
crossProduct(newPartialU, newPartialV, retNormal);
|
||||
normalize(retNormal);
|
||||
}
|
||||
}
|
||||
|
||||
/*if size is 0, then nothing is done*/
|
||||
static void normalize(float vec[3])
|
||||
{
|
||||
float size = (float)sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]);
|
||||
|
||||
if(size < TOLERANCE)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Warning: in oglBSpline.c normal is 0\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
else {
|
||||
vec[0] = vec[0]/size;
|
||||
vec[1] = vec[1]/size;
|
||||
vec[2] = vec[2]/size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void crossProduct(float x[3], float y[3], float ret[3])
|
||||
{
|
||||
ret[0] = x[1]*y[2] - y[1]*x[2];
|
||||
ret[1] = x[2]*y[0] - y[2]*x[0];
|
||||
ret[2] = x[0]*y[1] - y[0]*x[1];
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#ifndef _BEZIEREVAL_H
|
||||
#define _BEZIEREVAL_H
|
||||
|
||||
void bezierCurveEval(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retpoint[]);
|
||||
void bezierCurveEvalDer(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retDer[]);
|
||||
void bezierCurveEvalDerGen(int der, float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retDer[]);
|
||||
|
||||
|
||||
void bezierSurfEvalDerGen(int uder, int vder, float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float ret[]);
|
||||
|
||||
void bezierSurfEval(float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float ret[]);
|
||||
|
||||
void bezierSurfEvalNormal(float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float retNormal[]);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,206 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
**
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "gluos.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <GL/glu.h> /*for drawing bzier patch*/
|
||||
#include "bezierPatch.h"
|
||||
#include "bezierEval.h"
|
||||
|
||||
/*
|
||||
*allocate an instance of bezierPatch. The control points are unknown. But
|
||||
*the space of this array is allocated with size of
|
||||
* uorder*vorder*dimension
|
||||
*
|
||||
*/
|
||||
bezierPatch* bezierPatchMake(float umin, float vmin, float umax, float vmax, int uorder, int vorder, int dimension)
|
||||
{
|
||||
bezierPatch* ret = (bezierPatch*) malloc(sizeof(bezierPatch));
|
||||
assert(ret);
|
||||
ret->umin = umin;
|
||||
ret->vmin = vmin;
|
||||
ret->umax = umax;
|
||||
ret->vmax = vmax;
|
||||
ret->uorder = uorder;
|
||||
ret->vorder = vorder;
|
||||
ret->dimension = dimension;
|
||||
ret->ctlpoints = (float*) malloc(sizeof(float) * dimension * uorder * vorder);
|
||||
assert(ret->ctlpoints);
|
||||
|
||||
ret->next = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bezierPatch* bezierPatchMake2(float umin, float vmin, float umax, float vmax, int uorder, int vorder, int dimension, int ustride, int vstride, float* ctlpoints)
|
||||
{
|
||||
bezierPatch* ret = (bezierPatch*) malloc(sizeof(bezierPatch));
|
||||
assert(ret);
|
||||
ret->umin = umin;
|
||||
ret->vmin = vmin;
|
||||
ret->umax = umax;
|
||||
ret->vmax = vmax;
|
||||
ret->uorder = uorder;
|
||||
ret->vorder = vorder;
|
||||
ret->dimension = dimension;
|
||||
ret->ctlpoints = (float*) malloc(sizeof(float) * dimension * uorder * vorder);
|
||||
assert(ret->ctlpoints);
|
||||
|
||||
/*copy the control points there*/
|
||||
int the_ustride = vorder * dimension;
|
||||
int the_vstride = dimension;
|
||||
for(int i=0; i<uorder; i++)
|
||||
for(int j=0; j<vorder; j++)
|
||||
for(int k=0; k<dimension; k++)
|
||||
ret->ctlpoints[i * the_ustride + j*the_vstride+k] = ctlpoints[i*ustride+j*vstride+k];
|
||||
|
||||
ret->next = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
*deallocate the space as allocated by Make
|
||||
*/
|
||||
void bezierPatchDelete(bezierPatch *b)
|
||||
{
|
||||
free(b->ctlpoints);
|
||||
free(b);
|
||||
}
|
||||
|
||||
/*delete the whole linked list
|
||||
*/
|
||||
void bezierPatchDeleteList(bezierPatch *b)
|
||||
{
|
||||
bezierPatch *temp;
|
||||
while (b != NULL) {
|
||||
temp = b;
|
||||
b = b->next;
|
||||
bezierPatchDelete(temp);
|
||||
}
|
||||
}
|
||||
|
||||
bezierPatch* bezierPatchInsert(bezierPatch *list, bezierPatch *b)
|
||||
{
|
||||
b->next = list;
|
||||
return b;
|
||||
}
|
||||
|
||||
/*print the data stored in this patch*/
|
||||
void bezierPatchPrint(bezierPatch *b)
|
||||
{
|
||||
printf("bezierPatch:\n");
|
||||
printf("umin,umax=(%f,%f), (vmin, vmax)=(%f,%f)\n", b->umin, b->umax, b->vmin, b->vmax);
|
||||
printf("uorder=%i, vorder=%i\n", b->uorder, b->vorder);
|
||||
printf("idmension = %i\n", b->dimension);
|
||||
}
|
||||
|
||||
/*print the whole list*/
|
||||
void bezierPatchPrintList(bezierPatch *list)
|
||||
{
|
||||
bezierPatch* temp;
|
||||
for(temp=list; temp != NULL; temp = temp->next)
|
||||
bezierPatchPrint(temp);
|
||||
}
|
||||
|
||||
void bezierPatchEval(bezierPatch *b, float u, float v, float ret[])
|
||||
{
|
||||
if( u >= b->umin && u<= b->umax
|
||||
&& v >= b->vmin && v<= b->vmax)
|
||||
{
|
||||
|
||||
bezierSurfEval(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
|
||||
|
||||
}
|
||||
else if(b->next != NULL)
|
||||
bezierPatchEval(b->next, u,v, ret);
|
||||
else
|
||||
bezierSurfEval(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
|
||||
}
|
||||
|
||||
/*the returned normal is normlized
|
||||
*/
|
||||
void bezierPatchEvalNormal(bezierPatch *b, float u, float v, float ret[])
|
||||
{
|
||||
bezierSurfEvalNormal(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
|
||||
|
||||
if( u >= b->umin && u<= b->umax
|
||||
&& v >= b->vmin && v<= b->vmax)
|
||||
{
|
||||
bezierSurfEvalNormal(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
|
||||
}
|
||||
else if(b->next != NULL)
|
||||
bezierPatchEvalNormal(b->next, u,v, ret);
|
||||
else
|
||||
bezierSurfEvalNormal(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
|
||||
|
||||
}
|
||||
|
||||
void bezierPatchDraw(bezierPatch *bpatch, int u_reso, int v_reso)
|
||||
{
|
||||
if(bpatch->dimension == 3)
|
||||
glMap2f(GL_MAP2_VERTEX_3, bpatch->umin, bpatch->umax, 3*bpatch->vorder, bpatch->uorder, bpatch->vmin, bpatch->vmax,3, bpatch->vorder, (GLfloat*) bpatch->ctlpoints);
|
||||
else
|
||||
glMap2f(GL_MAP2_VERTEX_4, bpatch->umin, bpatch->umax, 4*bpatch->vorder, bpatch->uorder, bpatch->vmin, bpatch->vmax,3, bpatch->vorder, (GLfloat*) bpatch->ctlpoints);
|
||||
|
||||
glMapGrid2f(u_reso, bpatch->umin, bpatch->umax,
|
||||
v_reso, bpatch->vmin, bpatch->vmax);
|
||||
glEvalMesh2(GL_LINE, 0, u_reso, 0, v_reso);
|
||||
}
|
||||
|
||||
void bezierPatchListDraw(bezierPatch *list, int u_reso, int v_reso)
|
||||
{
|
||||
bezierPatch *temp;
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_MAP2_VERTEX_3);
|
||||
glEnable(GL_AUTO_NORMAL);
|
||||
glEnable(GL_NORMALIZE);
|
||||
glColor3f(1,0,0);
|
||||
#ifdef DEBUG
|
||||
printf("mapmap\n");
|
||||
#endif
|
||||
|
||||
|
||||
for(temp = list; temp != NULL; temp = temp->next)
|
||||
bezierPatchDraw(temp, u_reso, v_reso);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#ifndef _BEZIERPATCH_H
|
||||
#define _BEZIERPATCH_H
|
||||
|
||||
typedef struct bezierPatch{
|
||||
float umin, vmin, umax, vmax;
|
||||
int uorder; /*order= degree + 1*/
|
||||
int vorder;
|
||||
|
||||
/*
|
||||
*the control points are stored in a one dimensional array.
|
||||
*the surface is defined as:
|
||||
* s(u,v) = sum_{i,j} P(i,j) * B_i(u) * B_j(v).
|
||||
*where P(i,j) are the control points, B_i(.) are Bezier
|
||||
*basis functions.
|
||||
*Each control point can have dimension 3 or 4: (x,y,z,w).
|
||||
*The components of P(i,j) are stored in a one dimensional
|
||||
*array:
|
||||
* ctlpoints[]
|
||||
*in the order of:
|
||||
* P[0,0], P[0,1], ..., P[0,vorder-1],
|
||||
* P[1,0], P[1,1], ..., P[1,vorder-1],
|
||||
* ...
|
||||
* P[uorder-1,0], P[uorder-1,1], ..., P[uorder-1,vorder-1].
|
||||
*/
|
||||
int dimension;
|
||||
float* ctlpoints;
|
||||
|
||||
/*
|
||||
*in case we have to manage multiple bezierPatches.
|
||||
*/
|
||||
struct bezierPatch *next;
|
||||
|
||||
} bezierPatch;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
bezierPatch* bezierPatchMake(float umin, float vmin, float umax, float vmax, int urder, int vorder, int dimension);
|
||||
|
||||
bezierPatch* bezierPatchMake2(float umin, float vmin, float umax, float vmax, int urder, int vorder, int dimension, int ustride, int vstride, float *ctlpoints);
|
||||
|
||||
|
||||
bezierPatch* bezierPatchInsert(bezierPatch *list, bezierPatch *b);
|
||||
|
||||
void bezierPatchDelete(bezierPatch *b);
|
||||
|
||||
void bezierPatchDeleteList(bezierPatch *b);
|
||||
|
||||
void bezierPatchPrint(bezierPatch *b);
|
||||
|
||||
void bezierPatchPrintList(bezierPatch *list);
|
||||
|
||||
void bezierPatchEval(bezierPatch *b, float u, float v, float ret[]);
|
||||
|
||||
void bezierPatchEvalNormal(bezierPatch *b, float u, float v, float retNormal[]);
|
||||
|
||||
void bezierPatchEval(bezierPatch *b, float u, float v, float ret[]);
|
||||
|
||||
void bezierPatchEvalNormal(bezierPatch *b, float u, float v, float ret[]);
|
||||
|
||||
|
||||
void bezierPatchDraw(bezierPatch *bpatch, int u_reso, int v_reso);
|
||||
|
||||
void bezierPatchListDraw(bezierPatch *list, int u_reso, int v_reso);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,610 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
**
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "gluos.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <GL/gl.h>
|
||||
#include "bezierEval.h"
|
||||
#include "bezierPatchMesh.h"
|
||||
|
||||
static int isDegenerate(float A[2], float B[2], float C[2]);
|
||||
|
||||
void drawStrips(float *vertex_array, float *normal_array, int *length_array, GLenum *type_array, int num_strips)
|
||||
{
|
||||
int i,j,k;
|
||||
k=0;
|
||||
/*k is the index of the first component of the current vertex*/
|
||||
for(i=0; i<num_strips; i++)
|
||||
{
|
||||
glBegin(type_array[i]);
|
||||
for(j=0; j<length_array[i]; j++)
|
||||
{
|
||||
glNormal3fv(normal_array+k);
|
||||
glVertex3fv(vertex_array+k);
|
||||
k += 3;
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshListDelDeg(bezierPatchMesh* list)
|
||||
{
|
||||
bezierPatchMesh* temp;
|
||||
for(temp=list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
bezierPatchMeshDelDeg(temp);
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshListDelete(bezierPatchMesh *list)
|
||||
{
|
||||
if(list == NULL) return;
|
||||
bezierPatchMeshListDelete(list->next);
|
||||
bezierPatchMeshDelete(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bezierPatchMesh* bezierPatchMeshListReverse(bezierPatchMesh* list)
|
||||
{
|
||||
bezierPatchMesh* ret=NULL;
|
||||
bezierPatchMesh* temp;
|
||||
bezierPatchMesh* nextone;
|
||||
for(temp = list; temp != NULL; temp = nextone)
|
||||
{
|
||||
nextone = temp->next;
|
||||
ret=bezierPatchMeshListInsert(ret, temp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*maptype is either GL_MAP2_VERTEX_3 or GL_MAP2_VERTEX_4
|
||||
*/
|
||||
bezierPatchMesh *bezierPatchMeshMake(int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints, int size_UVarray, int size_length_array)
|
||||
{
|
||||
int i,j,k;
|
||||
int dimension;
|
||||
int the_ustride;
|
||||
int the_vstride;
|
||||
|
||||
if(maptype == GL_MAP2_VERTEX_3) dimension = 3;
|
||||
else if (maptype==GL_MAP2_VERTEX_4) dimension = 4;
|
||||
else {
|
||||
fprintf(stderr, "error in inMap2f, maptype=%i is wrong, maptype,map is invalid\n", maptype);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bezierPatchMesh *ret = (bezierPatchMesh*) malloc(sizeof(bezierPatchMesh));
|
||||
assert(ret);
|
||||
|
||||
ret->bpatch_normal = NULL;
|
||||
ret->bpatch_color = NULL;
|
||||
ret->bpatch_texcoord = NULL;
|
||||
ret->bpatch = bezierPatchMake(umin, vmin, umax, vmax, uorder, vorder, dimension);
|
||||
|
||||
/*copy the control points there*/
|
||||
the_ustride = vorder * dimension;
|
||||
the_vstride = dimension;
|
||||
for(i=0; i<uorder; i++)
|
||||
for(j=0; j<vorder; j++)
|
||||
for(k=0; k<dimension; k++)
|
||||
ret->bpatch->ctlpoints[i * the_ustride + j*the_vstride+k] = ctlpoints[i*ustride+j*vstride+k];
|
||||
|
||||
|
||||
ret->size_UVarray = size_UVarray;
|
||||
ret->size_length_array = size_length_array;
|
||||
ret->UVarray = (float*) malloc(sizeof(float) * size_UVarray);
|
||||
assert(ret->UVarray);
|
||||
ret->length_array = (int *)malloc(sizeof(int) * size_length_array);
|
||||
assert(ret->length_array);
|
||||
ret->type_array = (GLenum *)malloc(sizeof(GLenum) * size_length_array);
|
||||
assert(ret->type_array);
|
||||
|
||||
ret->index_UVarray = 0;
|
||||
ret->index_length_array = 0;
|
||||
|
||||
ret->vertex_array = NULL;
|
||||
ret->normal_array = NULL;
|
||||
ret->color_array = NULL;
|
||||
ret->texcoord_array = NULL;
|
||||
|
||||
ret->next = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bezierPatchMesh *bezierPatchMeshMake2(int size_UVarray, int size_length_array)
|
||||
{
|
||||
bezierPatchMesh *ret = (bezierPatchMesh*) malloc(sizeof(bezierPatchMesh));
|
||||
assert(ret);
|
||||
|
||||
ret->bpatch = NULL;
|
||||
ret->bpatch_normal = NULL;
|
||||
ret->bpatch_color = NULL;
|
||||
ret->bpatch_texcoord = NULL;
|
||||
|
||||
ret->size_UVarray = size_UVarray;
|
||||
ret->size_length_array = size_length_array;
|
||||
ret->UVarray = (float*) malloc(sizeof(float) * size_UVarray);
|
||||
assert(ret->UVarray);
|
||||
ret->length_array = (int *)malloc(sizeof(int) * size_length_array);
|
||||
assert(ret->length_array);
|
||||
ret->type_array = (GLenum *)malloc(sizeof(GLenum) * size_length_array);
|
||||
assert(ret->type_array);
|
||||
|
||||
ret->index_UVarray = 0;
|
||||
ret->index_length_array = 0;
|
||||
|
||||
ret->vertex_array = NULL;
|
||||
ret->normal_array = NULL;
|
||||
ret->color_array = NULL;
|
||||
ret->texcoord_array = NULL;
|
||||
|
||||
ret->next = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void bezierPatchMeshPutPatch(bezierPatchMesh *bpm, int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints)
|
||||
{
|
||||
switch(maptype){
|
||||
case GL_MAP2_VERTEX_3:
|
||||
bpm->bpatch = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_VERTEX_4:
|
||||
bpm->bpatch = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4,ustride, vstride, ctlpoints );
|
||||
break;
|
||||
case GL_MAP2_NORMAL:
|
||||
bpm->bpatch_normal = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_INDEX:
|
||||
bpm->bpatch_color = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 1, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_COLOR_4:
|
||||
bpm->bpatch_color = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_TEXTURE_COORD_1:
|
||||
bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 1, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_TEXTURE_COORD_2:
|
||||
bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 2, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_TEXTURE_COORD_3:
|
||||
bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_TEXTURE_COORD_4:
|
||||
bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "error in bezierPatchMeshPutPatch, maptype=%i is wrong, maptype,map is invalid\n", maptype);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*delete everything including the arrays. So if you want to output the
|
||||
*pointers of the arrays, you should not use this function to deallocate space.
|
||||
*you should dealocate manually
|
||||
*/
|
||||
void bezierPatchMeshDelete(bezierPatchMesh *bpm)
|
||||
{
|
||||
if(bpm->bpatch != NULL)
|
||||
bezierPatchDelete(bpm->bpatch);
|
||||
if(bpm->bpatch_normal != NULL)
|
||||
bezierPatchDelete(bpm->bpatch_normal);
|
||||
if(bpm->bpatch_color != NULL)
|
||||
bezierPatchDelete(bpm->bpatch_color);
|
||||
if(bpm->bpatch_texcoord != NULL)
|
||||
bezierPatchDelete(bpm->bpatch_texcoord);
|
||||
|
||||
free(bpm->UVarray);
|
||||
free(bpm->length_array);
|
||||
free(bpm->vertex_array);
|
||||
free(bpm->normal_array);
|
||||
free(bpm->type_array);
|
||||
free(bpm);
|
||||
}
|
||||
|
||||
/*begin a strip
|
||||
*type is the primitive type:
|
||||
*/
|
||||
void bezierPatchMeshBeginStrip(bezierPatchMesh *bpm, GLenum type)
|
||||
{
|
||||
bpm->counter = 0;
|
||||
bpm->type = type;
|
||||
}
|
||||
|
||||
/*signal the end of the current strip*/
|
||||
void bezierPatchMeshEndStrip(bezierPatchMesh *bpm)
|
||||
{
|
||||
int i;
|
||||
|
||||
/*if there are no vertices in this strip, then nothing needs to be done*/
|
||||
if(bpm->counter == 0) return;
|
||||
|
||||
/*if the length_array is full, it should be expanded*/
|
||||
if(bpm->index_length_array >= bpm->size_length_array)
|
||||
{
|
||||
int *temp = (int*) malloc(sizeof(int) * (bpm->size_length_array*2 + 1));
|
||||
assert(temp);
|
||||
GLenum *temp_type = (GLenum*) malloc(sizeof(GLenum) * (bpm->size_length_array*2 + 1));
|
||||
assert(temp_type);
|
||||
/*update the size*/
|
||||
bpm->size_length_array = bpm->size_length_array*2 + 1;
|
||||
|
||||
/*copy*/
|
||||
for(i=0; i<bpm->index_length_array; i++)
|
||||
{
|
||||
temp[i] = bpm->length_array[i];
|
||||
temp_type[i] = bpm->type_array[i];
|
||||
}
|
||||
|
||||
/*deallocate old array*/
|
||||
free(bpm->length_array);
|
||||
free(bpm->type_array);
|
||||
|
||||
/*point to the new array which is twice as bigger*/
|
||||
bpm->length_array = temp;
|
||||
bpm->type_array = temp_type;
|
||||
}
|
||||
bpm->type_array[bpm->index_length_array] = bpm->type;
|
||||
bpm->length_array[bpm->index_length_array++] = bpm->counter;
|
||||
|
||||
}
|
||||
|
||||
/*insert (u,v) */
|
||||
void bezierPatchMeshInsertUV(bezierPatchMesh *bpm, float u, float v)
|
||||
{
|
||||
int i;
|
||||
/*if the UVarray is full, it should be expanded*/
|
||||
if(bpm->index_UVarray+1 >= bpm->size_UVarray)
|
||||
{
|
||||
float *temp = (float*) malloc(sizeof(float) * (bpm->size_UVarray * 2 + 2));
|
||||
assert(temp);
|
||||
|
||||
/*update the size*/
|
||||
bpm->size_UVarray = bpm->size_UVarray*2 + 2;
|
||||
|
||||
/*copy*/
|
||||
for(i=0; i<bpm->index_UVarray; i++)
|
||||
{
|
||||
temp[i] = bpm->UVarray[i];
|
||||
}
|
||||
|
||||
/*deallocate old array*/
|
||||
free(bpm->UVarray);
|
||||
|
||||
/*pointing to the new arrays*/
|
||||
bpm->UVarray = temp;
|
||||
}
|
||||
/*insert the new UV*/
|
||||
bpm->UVarray[bpm->index_UVarray] = u;
|
||||
bpm->index_UVarray++;
|
||||
bpm->UVarray[bpm->index_UVarray] = v;
|
||||
bpm->index_UVarray++;
|
||||
|
||||
/*update counter: one more vertex*/
|
||||
bpm->counter++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void bezierPatchMeshPrint(bezierPatchMesh *bpm)
|
||||
{
|
||||
int i;
|
||||
printf("the bezier patch is\n");
|
||||
bezierPatchPrint(bpm->bpatch);
|
||||
printf("index_length_array= %i\n", bpm->index_length_array);
|
||||
printf("size_length_array =%i\n", bpm->size_length_array);
|
||||
printf("index_UVarray =%i\n", bpm->index_UVarray);
|
||||
printf("size_UVarray =%i\n", bpm->size_UVarray);
|
||||
printf("UVarray is\n");
|
||||
for(i=0; i<bpm->index_UVarray; i++)
|
||||
printf("%f ", bpm->UVarray[i]);
|
||||
|
||||
printf("length_array is\n");
|
||||
for(i=0; i<bpm->index_length_array; i++)
|
||||
printf("%i ", bpm->length_array[i]);
|
||||
printf("\n");
|
||||
|
||||
}
|
||||
|
||||
/*insert a new patch in front of the current linked list and return the new list*/
|
||||
bezierPatchMesh* bezierPatchMeshListInsert(bezierPatchMesh* list, bezierPatchMesh* bpm)
|
||||
{
|
||||
bpm->next=list;
|
||||
return bpm;
|
||||
}
|
||||
|
||||
/*print all the patches*/
|
||||
void bezierPatchMeshListPrint(bezierPatchMesh* list)
|
||||
{
|
||||
bezierPatchMesh *temp;
|
||||
for(temp = list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
bezierPatchMeshPrint(temp);
|
||||
}
|
||||
}
|
||||
|
||||
int bezierPatchMeshListTotalStrips(bezierPatchMesh* list)
|
||||
{
|
||||
int sum=0;
|
||||
bezierPatchMesh *temp;
|
||||
for(temp=list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
sum += temp->index_length_array;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
int bezierPatchMeshListTotalVert(bezierPatchMesh* list)
|
||||
{
|
||||
int sum=0;
|
||||
bezierPatchMesh *temp;
|
||||
for(temp=list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
sum += temp->index_UVarray;
|
||||
}
|
||||
return sum/2;
|
||||
}
|
||||
|
||||
int bezierPatchMeshListNumTriangles(bezierPatchMesh* list)
|
||||
{
|
||||
int sum=0;
|
||||
bezierPatchMesh* temp;
|
||||
for(temp=list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
sum += bezierPatchMeshNumTriangles(temp);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
int bezierPatchMeshNumTriangles(bezierPatchMesh* bpm)
|
||||
{
|
||||
int i;
|
||||
int sum=0;
|
||||
for(i=0; i<bpm->index_length_array; i++)
|
||||
{
|
||||
switch(bpm->type_array[i])
|
||||
{
|
||||
case GL_TRIANGLES:
|
||||
sum += bpm->length_array[i]/3;
|
||||
break;
|
||||
case GL_TRIANGLE_FAN:
|
||||
if(bpm->length_array[i] > 2)
|
||||
sum += bpm->length_array[i]-2;
|
||||
break;
|
||||
case GL_TRIANGLE_STRIP:
|
||||
if(bpm->length_array[i] > 2)
|
||||
sum += bpm->length_array[i]-2;
|
||||
break;
|
||||
case GL_QUAD_STRIP:
|
||||
if(bpm->length_array[i]>2)
|
||||
sum += (bpm->length_array[i]-2);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"error in bezierPatchMeshListNumTriangles, type invalid\n");
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/*delete degenerate triangles*/
|
||||
void bezierPatchMeshDelDeg(bezierPatchMesh* bpm)
|
||||
{
|
||||
if(bpm == NULL) return;
|
||||
int i,j,k;
|
||||
int *new_length_array;
|
||||
GLenum *new_type_array;
|
||||
int index_new_length_array;
|
||||
float *new_UVarray;
|
||||
int index_new_UVarray;
|
||||
|
||||
new_length_array = (int*)malloc(sizeof(int) * bpm->index_length_array);
|
||||
assert(new_length_array);
|
||||
new_type_array = (GLenum*)malloc(sizeof(GLenum) * bpm->index_length_array);
|
||||
assert(new_length_array);
|
||||
new_UVarray = (float*) malloc(sizeof(float) * bpm->index_UVarray);
|
||||
assert(new_UVarray);
|
||||
|
||||
index_new_length_array = 0;
|
||||
index_new_UVarray=0;
|
||||
k=0;
|
||||
for(i=0; i<bpm->index_length_array; i++){
|
||||
|
||||
/*(if not degenerate, we have to copy*/
|
||||
if( (bpm->length_array[i] != 3) || (!isDegenerate(bpm->UVarray+k, bpm->UVarray+k+2, bpm->UVarray+k+4)))
|
||||
{
|
||||
for(j=0; j<2* bpm->length_array[i]; j++)
|
||||
new_UVarray[index_new_UVarray++] = bpm->UVarray[k++];
|
||||
|
||||
new_length_array[index_new_length_array] = bpm->length_array[i];
|
||||
new_type_array[index_new_length_array] = bpm->type_array[i];
|
||||
index_new_length_array++;
|
||||
}
|
||||
else
|
||||
{
|
||||
k += 6;
|
||||
}
|
||||
}
|
||||
free(bpm->UVarray);
|
||||
free(bpm->length_array);
|
||||
free(bpm->type_array);
|
||||
bpm->UVarray=new_UVarray;
|
||||
bpm->length_array=new_length_array;
|
||||
bpm->type_array=new_type_array;
|
||||
bpm->index_UVarray = index_new_UVarray;
|
||||
bpm->index_length_array = index_new_length_array;
|
||||
|
||||
}
|
||||
|
||||
/*(u,v) to XYZ
|
||||
*the xyz and normals are stored in vertex_array,
|
||||
*and normal_array. the spaces of both are allocated here
|
||||
*/
|
||||
void bezierPatchMeshEval(bezierPatchMesh* bpm)
|
||||
{
|
||||
int i,j,k,l;
|
||||
float u,v;
|
||||
float u0 = bpm->bpatch->umin;
|
||||
float u1 = bpm->bpatch->umax;
|
||||
int uorder = bpm->bpatch->uorder;
|
||||
float v0 = bpm->bpatch->vmin;
|
||||
float v1 = bpm->bpatch->vmax;
|
||||
int vorder = bpm->bpatch->vorder;
|
||||
int dimension = bpm->bpatch->dimension;
|
||||
int ustride = dimension * vorder;
|
||||
int vstride = dimension;
|
||||
float *ctlpoints = bpm->bpatch->ctlpoints;
|
||||
|
||||
bpm->vertex_array = (float*) malloc(sizeof(float)* (bpm->index_UVarray/2) * 3);
|
||||
assert(bpm->vertex_array);
|
||||
bpm->normal_array = (float*) malloc(sizeof(float)* (bpm->index_UVarray/2) * 3);
|
||||
assert(bpm->normal_array);
|
||||
|
||||
k=0;
|
||||
l=0;
|
||||
for(i=0; i<bpm->index_length_array; i++)
|
||||
{
|
||||
for(j=0; j<bpm->length_array[i]; j++)
|
||||
{
|
||||
u = bpm->UVarray[k];
|
||||
v = bpm->UVarray[k+1];
|
||||
bezierSurfEval(u0,u1,uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u,v, bpm->vertex_array+l);
|
||||
bezierSurfEvalNormal(u0,u1,uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u,v, bpm->normal_array+l);
|
||||
k += 2;
|
||||
l += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshListEval(bezierPatchMesh* list)
|
||||
{
|
||||
bezierPatchMesh* temp;
|
||||
for(temp = list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
bezierPatchMeshEval(temp);
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshDraw(bezierPatchMesh* bpm)
|
||||
{
|
||||
int i,j,k;
|
||||
k=0;
|
||||
/*k is the index of the first component of the current vertex*/
|
||||
for(i=0; i<bpm->index_length_array; i++)
|
||||
{
|
||||
glBegin(bpm->type_array[i]);
|
||||
for(j=0; j<bpm->length_array[i]; j++)
|
||||
{
|
||||
glNormal3fv(bpm->normal_array+k);
|
||||
glVertex3fv(bpm->vertex_array+k);
|
||||
k+= 3;
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshListDraw(bezierPatchMesh* list)
|
||||
{
|
||||
bezierPatchMesh* temp;
|
||||
for(temp = list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
bezierPatchMeshDraw(temp);
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshListCollect(bezierPatchMesh* list, float **vertex_array, float **normal_array, int **length_array, GLenum **type_array, int *num_strips)
|
||||
{
|
||||
int i,j,k,l;
|
||||
bezierPatchMesh *temp;
|
||||
int total_num_vertices = bezierPatchMeshListTotalVert(list);
|
||||
(*vertex_array) = (float *) malloc(sizeof(float) * total_num_vertices*3);
|
||||
assert(*vertex_array);
|
||||
(*normal_array) = (float *) malloc(sizeof(float) * total_num_vertices*3);
|
||||
assert(*normal_array);
|
||||
|
||||
*num_strips = bezierPatchMeshListTotalStrips(list);
|
||||
|
||||
*length_array = (int*) malloc(sizeof(int) * (*num_strips));
|
||||
assert(*length_array);
|
||||
|
||||
*type_array = (GLenum*) malloc(sizeof(GLenum) * (*num_strips));
|
||||
assert(*type_array);
|
||||
|
||||
k=0;
|
||||
l=0;
|
||||
for(temp = list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
int x=0;
|
||||
for(i=0; i<temp->index_length_array; i++)
|
||||
{
|
||||
for(j=0; j<temp->length_array[i]; j++)
|
||||
{
|
||||
(*vertex_array)[k] = temp->vertex_array[x];
|
||||
(*vertex_array)[k+1] = temp->vertex_array[x+1];
|
||||
(*vertex_array)[k+2] = temp->vertex_array[x+2];
|
||||
|
||||
(*normal_array)[k] = temp->normal_array[x];
|
||||
(*normal_array)[k+1] = temp->normal_array[x+1];
|
||||
(*normal_array)[k+2] = temp->normal_array[x+2];
|
||||
|
||||
x += 3;
|
||||
k += 3;
|
||||
}
|
||||
(*type_array)[l] = temp->type_array[i];
|
||||
(*length_array)[l++] = temp->length_array[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int isDegenerate(float A[2], float B[2], float C[2])
|
||||
{
|
||||
if( (A[0] == B[0] && A[1]==B[1]) ||
|
||||
(A[0] == C[0] && A[1]==C[1]) ||
|
||||
(B[0] == C[0] && B[1]==C[1])
|
||||
)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#ifndef _BEZIERPATCHMESH_H
|
||||
#define _BEZIERPATCHMESH_H
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include "bezierPatch.h"
|
||||
|
||||
typedef struct bezierPatchMesh{
|
||||
bezierPatch *bpatch; /*vertex*/
|
||||
bezierPatch *bpatch_normal;
|
||||
bezierPatch *bpatch_texcoord; /*s,t,r,q*/
|
||||
bezierPatch *bpatch_color; /*RGBA*/
|
||||
|
||||
float *UVarray; /*all UV components of all vertices of all strips*/
|
||||
int *length_array; /*[i] is the number of vertices in the ith strip*/
|
||||
GLenum *type_array; /*[i] is the type of the ith primitive*/
|
||||
|
||||
/*to support dynamic insertion*/
|
||||
int size_UVarray;
|
||||
int index_UVarray;
|
||||
int size_length_array;
|
||||
int index_length_array;
|
||||
|
||||
int counter; /*track the current strip size*/
|
||||
GLenum type; /*track the current type: 0: GL_TRIANGLES, 1: GL_TRIANGLE_STRIP*/
|
||||
|
||||
/*we eventually want to evaluate from (u,v) to (x,y,z) and draw them*/
|
||||
float *vertex_array; /*each vertex contains three components*/
|
||||
float *normal_array; /*each normal contains three components*/
|
||||
float *color_array;
|
||||
float *texcoord_array;
|
||||
|
||||
/*in case we need a linked list*/
|
||||
struct bezierPatchMesh *next;
|
||||
} bezierPatchMesh;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
bezierPatchMesh *bezierPatchMeshMake(int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints, int size_UVarray, int size_length_array);
|
||||
|
||||
/*initilize patches to be null*/
|
||||
bezierPatchMesh *bezierPatchMeshMake2(int size_UVarray, int size_length_array);
|
||||
|
||||
void bezierPatchMeshPutPatch(bezierPatchMesh *bpm, int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints);
|
||||
|
||||
void bezierPatchMeshDelete(bezierPatchMesh *bpm);
|
||||
|
||||
void bezierPatchMeshBeginStrip(bezierPatchMesh *bpm, GLenum type);
|
||||
|
||||
void bezierPatchMeshEndStrip(bezierPatchMesh *bpm);
|
||||
|
||||
void bezierPatchMeshInsertUV(bezierPatchMesh *bpm, float u, float v);
|
||||
|
||||
void bezierPatchMeshPrint(bezierPatchMesh *bpm);
|
||||
|
||||
bezierPatchMesh* bezierPatchMeshListInsert(bezierPatchMesh* list, bezierPatchMesh* bpm);
|
||||
|
||||
void bezierPatchMeshListPrint(bezierPatchMesh* list);
|
||||
|
||||
int bezierPatchMeshListTotalStrips(bezierPatchMesh* list);
|
||||
|
||||
int bezierPatchMeshListTotalVert(bezierPatchMesh* list);
|
||||
int bezierPatchMeshNumTriangles(bezierPatchMesh* bpm);
|
||||
int bezierPatchMeshListNumTriangles(bezierPatchMesh* list);
|
||||
|
||||
void bezierPatchMeshDelDeg(bezierPatchMesh* bpm);
|
||||
|
||||
|
||||
void bezierPatchMeshEval(bezierPatchMesh* bpm);
|
||||
|
||||
void bezierPatchMeshDraw(bezierPatchMesh* bpm);
|
||||
|
||||
void bezierPatchMeshListDraw(bezierPatchMesh* list);
|
||||
void bezierPatchMeshListEval(bezierPatchMesh* list);
|
||||
void bezierPatchMeshListCollect(bezierPatchMesh* list, float **vertex_array, float **normal_array, int **length_array, GLenum **type_array, int *num_strips);
|
||||
|
||||
void bezierPatchMeshListDelDeg(bezierPatchMesh* list);
|
||||
void bezierPatchMeshListDelete(bezierPatchMesh *list);
|
||||
bezierPatchMesh* bezierPatchMeshListReverse(bezierPatchMesh* list);
|
||||
void drawStrips(float *vertex_array, float *normal_array, int *length_array, GLenum *type_array, int num_strips);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,402 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* glcurveval.c++
|
||||
*
|
||||
*/
|
||||
|
||||
/* Polynomial Evaluator Interface */
|
||||
|
||||
#include "gluos.h"
|
||||
#include "glimports.h"
|
||||
#include "glrenderer.h"
|
||||
#include "glcurveval.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
OpenGLCurveEvaluator::OpenGLCurveEvaluator(void)
|
||||
{
|
||||
//no default callback functions
|
||||
beginCallBackN = NULL;
|
||||
endCallBackN = NULL;
|
||||
vertexCallBackN = NULL;
|
||||
normalCallBackN = NULL;
|
||||
colorCallBackN = NULL;
|
||||
texcoordCallBackN = NULL;
|
||||
beginCallBackData = NULL;
|
||||
endCallBackData = NULL;
|
||||
vertexCallBackData = NULL;
|
||||
normalCallBackData = NULL;
|
||||
colorCallBackData = NULL;
|
||||
texcoordCallBackData = NULL;
|
||||
|
||||
userData = NULL;
|
||||
|
||||
vertex_flag = 0;
|
||||
normal_flag = 0;
|
||||
color_flag = 0;
|
||||
texcoord_flag = 0;
|
||||
|
||||
em_vertex.uprime = -1.0;
|
||||
em_normal.uprime = -1.0;
|
||||
em_color.uprime = -1.0;
|
||||
em_texcoord.uprime = -1.0;
|
||||
output_triangles = 0; // don't output triangles by default
|
||||
}
|
||||
|
||||
OpenGLCurveEvaluator::~OpenGLCurveEvaluator(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* added nonsense to avoid the warning messages at compile time */
|
||||
void
|
||||
OpenGLCurveEvaluator::addMap(CurveMap *m)
|
||||
{
|
||||
m = m;
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::range1f(long type, REAL *from, REAL *to)
|
||||
{
|
||||
type = type;
|
||||
from = from;
|
||||
to = to;
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::domain1f(REAL ulo, REAL uhi)
|
||||
{
|
||||
ulo = ulo;
|
||||
uhi = uhi;
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::bgnline(void)
|
||||
{
|
||||
if(output_triangles)
|
||||
beginCallBack(GL_LINE_STRIP, userData);
|
||||
else
|
||||
glBegin((GLenum) GL_LINE_STRIP);
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::endline(void)
|
||||
{
|
||||
if(output_triangles)
|
||||
endCallBack(userData);
|
||||
else
|
||||
glEnd();
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* disable - turn off a curve map
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::disable(long type)
|
||||
{
|
||||
glDisable((GLenum) type);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* enable - turn on a curve map
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::enable(long type)
|
||||
{
|
||||
glEnable((GLenum) type);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* mapgrid1f - define a lattice of points with origin and offset
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::mapgrid1f(long nu, REAL u0, REAL u1)
|
||||
{
|
||||
if(output_triangles)
|
||||
{
|
||||
global_grid_u0 = u0;
|
||||
global_grid_u1 = u1;
|
||||
global_grid_nu = (int) nu;
|
||||
}
|
||||
else
|
||||
glMapGrid1f((GLint) nu, (GLfloat) u0, (GLfloat) u1);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* bgnmap1 - preamble to curve definition and evaluations
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::bgnmap1f(long)
|
||||
{
|
||||
if(output_triangles)
|
||||
{
|
||||
//initialized so that no maps are set initially
|
||||
vertex_flag = 0;
|
||||
normal_flag = 0;
|
||||
color_flag = 0;
|
||||
texcoord_flag = 0;
|
||||
//no need to worry about gl states when doing callback
|
||||
}
|
||||
else
|
||||
glPushAttrib((GLbitfield) GL_EVAL_BIT);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* endmap1 - postamble to a curve map
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::endmap1f(void)
|
||||
{
|
||||
if(output_triangles)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* map1f - pass a desription of a curve map
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::map1f(
|
||||
long type, /* map type */
|
||||
REAL ulo, /* lower parametric bound */
|
||||
REAL uhi, /* upper parametric bound */
|
||||
long stride, /* distance to next point in REALS */
|
||||
long order, /* parametric order */
|
||||
REAL *pts /* control points */
|
||||
)
|
||||
{
|
||||
if(output_triangles)
|
||||
{
|
||||
int dimension = 0;
|
||||
int which = 0;
|
||||
switch(type){
|
||||
case GL_MAP1_VERTEX_3:
|
||||
which = 0;
|
||||
dimension = 3;
|
||||
break;
|
||||
case GL_MAP1_VERTEX_4:
|
||||
which=0;
|
||||
dimension = 4;
|
||||
break;
|
||||
case GL_MAP1_INDEX:
|
||||
which=2;
|
||||
dimension = 1;
|
||||
break;
|
||||
case GL_MAP1_COLOR_4:
|
||||
which=2;
|
||||
dimension = 4;
|
||||
break;
|
||||
case GL_MAP1_NORMAL:
|
||||
which=1;
|
||||
dimension = 3;
|
||||
break;
|
||||
case GL_MAP1_TEXTURE_COORD_1:
|
||||
which=3;
|
||||
dimension = 1;
|
||||
break;
|
||||
case GL_MAP1_TEXTURE_COORD_2:
|
||||
which=3;
|
||||
dimension = 2;
|
||||
break;
|
||||
|
||||
case GL_MAP1_TEXTURE_COORD_3:
|
||||
which=3;
|
||||
dimension = 3;
|
||||
break;
|
||||
case GL_MAP1_TEXTURE_COORD_4:
|
||||
which=3;
|
||||
dimension = 4;
|
||||
break;
|
||||
}
|
||||
inMap1f(which, dimension, ulo, uhi, stride, order, pts);
|
||||
}
|
||||
else
|
||||
glMap1f((GLenum) type, (GLfloat) ulo, (GLfloat) uhi, (GLint) stride,
|
||||
(GLint) order, (const GLfloat *) pts);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* mapmesh1f - evaluate a mesh of points on lattice
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void OpenGLCurveEvaluator::mapmesh1f(long style, long from, long to)
|
||||
{
|
||||
if(output_triangles)
|
||||
{
|
||||
inMapMesh1f((int) from, (int) to);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(style) {
|
||||
default:
|
||||
case N_MESHFILL:
|
||||
case N_MESHLINE:
|
||||
glEvalMesh1((GLenum) GL_LINE, (GLint) from, (GLint) to);
|
||||
break;
|
||||
case N_MESHPOINT:
|
||||
glEvalMesh1((GLenum) GL_POINT, (GLint) from, (GLint) to);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* evalpoint1i - evaluate a point on a curve
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void OpenGLCurveEvaluator::evalpoint1i(long i)
|
||||
{
|
||||
glEvalPoint1((GLint) i);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* evalcoord1f - evaluate a point on a curve
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void OpenGLCurveEvaluator::evalcoord1f(long, REAL u)
|
||||
{
|
||||
glEvalCoord1f((GLfloat) u);
|
||||
}
|
||||
|
||||
void
|
||||
#ifdef _WIN32
|
||||
OpenGLCurveEvaluator::putCallBack(GLenum which, void (GLAPIENTRY *fn)())
|
||||
#else
|
||||
OpenGLCurveEvaluator::putCallBack(GLenum which, _GLUfuncptr fn)
|
||||
#endif
|
||||
{
|
||||
switch(which)
|
||||
{
|
||||
case GLU_NURBS_BEGIN:
|
||||
beginCallBackN = (void (GLAPIENTRY *) (GLenum)) fn;
|
||||
break;
|
||||
case GLU_NURBS_END:
|
||||
endCallBackN = (void (GLAPIENTRY *) (void)) fn;
|
||||
break;
|
||||
case GLU_NURBS_VERTEX:
|
||||
vertexCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_NORMAL:
|
||||
normalCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_COLOR:
|
||||
colorCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_TEXTURE_COORD:
|
||||
texcoordCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_BEGIN_DATA:
|
||||
beginCallBackData = (void (GLAPIENTRY *) (GLenum, void*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_END_DATA:
|
||||
endCallBackData = (void (GLAPIENTRY *) (void*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_VERTEX_DATA:
|
||||
vertexCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_NORMAL_DATA:
|
||||
normalCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_COLOR_DATA:
|
||||
colorCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_TEXTURE_COORD_DATA:
|
||||
texcoordCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::beginCallBack(GLenum which, void *data)
|
||||
{
|
||||
if(beginCallBackData)
|
||||
beginCallBackData(which, data);
|
||||
else if(beginCallBackN)
|
||||
beginCallBackN(which);
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::endCallBack(void *data)
|
||||
{
|
||||
if(endCallBackData)
|
||||
endCallBackData(data);
|
||||
else if(endCallBackN)
|
||||
endCallBackN();
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::vertexCallBack(const GLfloat *vert, void* data)
|
||||
{
|
||||
if(vertexCallBackData)
|
||||
vertexCallBackData(vert, data);
|
||||
else if(vertexCallBackN)
|
||||
vertexCallBackN(vert);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::normalCallBack(const GLfloat *normal, void* data)
|
||||
{
|
||||
if(normalCallBackData)
|
||||
normalCallBackData(normal, data);
|
||||
else if(normalCallBackN)
|
||||
normalCallBackN(normal);
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::colorCallBack(const GLfloat *color, void* data)
|
||||
{
|
||||
if(colorCallBackData)
|
||||
colorCallBackData(color, data);
|
||||
else if(colorCallBackN)
|
||||
colorCallBackN(color);
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::texcoordCallBack(const GLfloat *texcoord, void* data)
|
||||
{
|
||||
if(texcoordCallBackData)
|
||||
texcoordCallBackData(texcoord, data);
|
||||
else if(texcoordCallBackN)
|
||||
texcoordCallBackN(texcoord);
|
||||
}
|
||||
|
|
@ -1,157 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* glcurveval.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluglcurveval_h_
|
||||
#define __gluglcurveval_h_
|
||||
|
||||
#include "gluos.h"
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include "basiccrveval.h"
|
||||
|
||||
class CurveMap;
|
||||
|
||||
/*for internal evaluator callback stuff*/
|
||||
#ifndef IN_MAX_BEZIER_ORDER
|
||||
#define IN_MAX_BEZIER_ORDER 40 /*XXX should be bigger than machine order*/
|
||||
#endif
|
||||
|
||||
#ifndef IN_MAX_DIMENSION
|
||||
#define IN_MAX_DIMENSION 4
|
||||
#endif
|
||||
|
||||
typedef struct curveEvalMachine{
|
||||
REAL uprime; //cached previously evaluated uprime
|
||||
int k; //the dimension
|
||||
REAL u1;
|
||||
REAL u2;
|
||||
int ustride;
|
||||
int uorder;
|
||||
REAL ctlpoints[IN_MAX_BEZIER_ORDER*IN_MAX_DIMENSION];
|
||||
REAL ucoeff[IN_MAX_BEZIER_ORDER];//cache the polynomial values
|
||||
} curveEvalMachine;
|
||||
|
||||
class OpenGLCurveEvaluator : public BasicCurveEvaluator {
|
||||
public:
|
||||
OpenGLCurveEvaluator(void);
|
||||
virtual ~OpenGLCurveEvaluator(void);
|
||||
void range1f(long, REAL *, REAL *);
|
||||
void domain1f(REAL, REAL);
|
||||
void addMap(CurveMap *);
|
||||
|
||||
void enable(long);
|
||||
void disable(long);
|
||||
void bgnmap1f(long);
|
||||
void map1f(long, REAL, REAL, long, long, REAL *);
|
||||
void mapgrid1f(long, REAL, REAL);
|
||||
void mapmesh1f(long, long, long);
|
||||
void evalpoint1i(long);
|
||||
void evalcoord1f(long, REAL);
|
||||
void endmap1f(void);
|
||||
|
||||
void bgnline(void);
|
||||
void endline(void);
|
||||
|
||||
void put_vertices_call_back(int flag)
|
||||
{
|
||||
output_triangles = flag;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
void putCallBack(GLenum which, void (GLAPIENTRY *fn)() );
|
||||
#else
|
||||
void putCallBack(GLenum which, _GLUfuncptr fn );
|
||||
#endif
|
||||
void set_callback_userData(void *data)
|
||||
{
|
||||
userData = data;
|
||||
}
|
||||
|
||||
/*------------------begin for curveEvalMachine------------*/
|
||||
curveEvalMachine em_vertex;
|
||||
curveEvalMachine em_normal;
|
||||
curveEvalMachine em_color;
|
||||
curveEvalMachine em_texcoord;
|
||||
int vertex_flag; //whether there is a vertex map or not
|
||||
int normal_flag; //whether there is a normal map or not
|
||||
int color_flag; //whether there is a color map or not
|
||||
int texcoord_flag; //whether there is a texture map or not
|
||||
|
||||
REAL global_grid_u0;
|
||||
REAL global_grid_u1;
|
||||
int global_grid_nu;
|
||||
|
||||
void inMap1f(int which, //0: vert, 1: norm, 2: color, 3: tex
|
||||
int dimension,
|
||||
REAL ulower,
|
||||
REAL uupper,
|
||||
int ustride,
|
||||
int uorder,
|
||||
REAL *ctlpoints);
|
||||
|
||||
void inPreEvaluate(int order, REAL vprime, REAL *coeff);
|
||||
void inDoDomain1(curveEvalMachine *em, REAL u, REAL *retPoint);
|
||||
void inDoEvalCoord1(REAL u);
|
||||
void inMapMesh1f(int umin, int umax);
|
||||
|
||||
void (GLAPIENTRY *beginCallBackN) (GLenum type);
|
||||
void (GLAPIENTRY *endCallBackN) (void);
|
||||
void (GLAPIENTRY *vertexCallBackN) (const GLfloat *vert);
|
||||
void (GLAPIENTRY *normalCallBackN) (const GLfloat *normal);
|
||||
void (GLAPIENTRY *colorCallBackN) (const GLfloat *color);
|
||||
void (GLAPIENTRY *texcoordCallBackN) (const GLfloat *texcoord);
|
||||
|
||||
void (GLAPIENTRY *beginCallBackData) (GLenum type, void* data);
|
||||
void (GLAPIENTRY *endCallBackData) (void* data);
|
||||
void (GLAPIENTRY *vertexCallBackData) (const GLfloat *vert, void* data);
|
||||
void (GLAPIENTRY *normalCallBackData) (const GLfloat *normal, void* data);
|
||||
void (GLAPIENTRY *colorCallBackData) (const GLfloat *color, void* data);
|
||||
void (GLAPIENTRY *texcoordCallBackData) (const GLfloat *texcoord, void* data);
|
||||
|
||||
void* userData; //the opaque pointer for Data callback functions
|
||||
void beginCallBack(GLenum type, void* data);
|
||||
void endCallBack(void* data);
|
||||
void vertexCallBack(const GLfloat *vert, void *data);
|
||||
void normalCallBack(const GLfloat *normal, void* data);
|
||||
void colorCallBack(const GLfloat *color, void* data);
|
||||
void texcoordCallBack(const GLfloat *texcoord, void* data);
|
||||
|
||||
|
||||
/*------------------end for curveEvalMachine------------*/
|
||||
|
||||
private:
|
||||
int output_triangles; //true 1; false 0
|
||||
};
|
||||
|
||||
#endif /* __gluglcurveval_h_ */
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* glimports.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluimports_h_
|
||||
#define __gluimports_h_
|
||||
|
||||
#include "mystdlib.h"
|
||||
#include "mystdio.h"
|
||||
|
||||
#endif /* __gluimports_h_ */
|
||||
|
|
@ -1,469 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
**
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "gluos.h"
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include <stdio.h>
|
||||
#include "glimports.h"
|
||||
#include "glrenderer.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
//#define DOWN_LOAD_NURBS
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
|
||||
#include "oglTrimNurbs.h"
|
||||
static int surfcount = 0;
|
||||
static oglTrimNurbs* otn = NULL;
|
||||
nurbSurf* tempNurb = NULL;
|
||||
oglTrimLoops* tempTrim = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
//for LOD
|
||||
extern "C" {void glu_LOD_eval_list(GLUnurbs *nurb, int level);}
|
||||
|
||||
void glu_LOD_eval_list(GLUnurbs *nurb, int level)
|
||||
{
|
||||
nurb->LOD_eval_list(level);
|
||||
}
|
||||
|
||||
GLUnurbs * GLAPIENTRY
|
||||
gluNewNurbsRenderer(void)
|
||||
{
|
||||
GLUnurbs *t;
|
||||
|
||||
t = new GLUnurbs();
|
||||
return t;
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluDeleteNurbsRenderer(GLUnurbs *r)
|
||||
{
|
||||
delete r;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void GLAPIENTRY
|
||||
|
||||
gluDeleteNurbsTessellatorEXT(GLUnurbsObj *r)
|
||||
{
|
||||
delete r;
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluBeginSurface(GLUnurbs *r)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
surfcount++;
|
||||
tempTrim = OTL_make(10,10);
|
||||
#endif
|
||||
r->bgnsurface(0);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluBeginCurve(GLUnurbs *r)
|
||||
{
|
||||
r->bgncurve(0);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluEndCurve(GLUnurbs *r)
|
||||
{
|
||||
r->endcurve();
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluEndSurface(GLUnurbs *r)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
if(surfcount == 1)
|
||||
otn = OTN_make(1);
|
||||
OTN_insert(otn, tempNurb, tempTrim);
|
||||
if(surfcount >= 1)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("write file\n");
|
||||
#endif
|
||||
OTN_write(otn, "out.otn");
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
r->endsurface();
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluBeginTrim(GLUnurbs *r)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
OTL_bgnTrim(tempTrim);
|
||||
#endif
|
||||
|
||||
r->bgntrim();
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluEndTrim(GLUnurbs *r)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
OTL_endTrim(tempTrim);
|
||||
#endif
|
||||
r->endtrim();
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluPwlCurve(GLUnurbs *r, GLint count, INREAL array[],
|
||||
GLint stride, GLenum type)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
OTL_pwlCurve(tempTrim, count, array, stride, type);
|
||||
#endif
|
||||
|
||||
int realType;
|
||||
switch(type) {
|
||||
case GLU_MAP1_TRIM_2:
|
||||
realType = N_P2D;
|
||||
break;
|
||||
case GLU_MAP1_TRIM_3:
|
||||
realType = N_P2DR;
|
||||
break;
|
||||
default:
|
||||
realType = type;
|
||||
break;
|
||||
}
|
||||
r->pwlcurve(count, array, sizeof(INREAL) * stride, realType);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluNurbsCurve(GLUnurbs *r, GLint nknots, INREAL knot[], GLint stride,
|
||||
INREAL ctlarray[], GLint order, GLenum type)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
OTL_nurbsCurve(tempTrim, nknots, knot, stride, ctlarray, order, type);
|
||||
#endif
|
||||
|
||||
int realType;
|
||||
|
||||
switch(type) {
|
||||
case GLU_MAP1_TRIM_2:
|
||||
realType = N_P2D;
|
||||
break;
|
||||
case GLU_MAP1_TRIM_3:
|
||||
realType = N_P2DR;
|
||||
break;
|
||||
default:
|
||||
realType = type;
|
||||
break;
|
||||
}
|
||||
|
||||
r->nurbscurve(nknots, knot, sizeof(INREAL) * stride, ctlarray, order,
|
||||
realType);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluNurbsSurface(GLUnurbs *r, GLint sknot_count, GLfloat *sknot,
|
||||
GLint tknot_count, GLfloat *tknot,
|
||||
GLint s_stride, GLint t_stride,
|
||||
GLfloat *ctlarray, GLint sorder, GLint torder,
|
||||
GLenum type)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
{
|
||||
int dimension;
|
||||
switch(type){
|
||||
case GL_MAP2_VERTEX_3:
|
||||
dimension = 3;
|
||||
break;
|
||||
case GL_MAP2_VERTEX_4:
|
||||
dimension = 4;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "error in glinterface.c++, type no implemented\n");
|
||||
exit(1);
|
||||
}
|
||||
tempNurb = nurbSurfMake(sknot_count, sknot,
|
||||
tknot_count, tknot,
|
||||
sorder, torder,
|
||||
dimension,
|
||||
ctlarray,
|
||||
s_stride, t_stride);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
r->nurbssurface(sknot_count, sknot, tknot_count, tknot,
|
||||
sizeof(INREAL) * s_stride, sizeof(INREAL) * t_stride,
|
||||
ctlarray, sorder, torder, type);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluLoadSamplingMatrices(GLUnurbs *r, const GLfloat modelMatrix[16],
|
||||
const GLfloat projMatrix[16],
|
||||
const GLint viewport[4])
|
||||
{
|
||||
r->useGLMatrices(modelMatrix, projMatrix, viewport);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluNurbsProperty(GLUnurbs *r, GLenum property, GLfloat value)
|
||||
{
|
||||
GLfloat nurbsValue;
|
||||
|
||||
switch (property) {
|
||||
case GLU_AUTO_LOAD_MATRIX:
|
||||
r->setautoloadmode(value);
|
||||
return;
|
||||
|
||||
case GLU_CULLING:
|
||||
if (value != 0.0) {
|
||||
nurbsValue = N_CULLINGON;
|
||||
} else {
|
||||
nurbsValue = N_NOCULLING;
|
||||
}
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_CULLING, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_CULLING, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_CULLING, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_CULLING, nurbsValue);
|
||||
return;
|
||||
|
||||
case GLU_SAMPLING_METHOD:
|
||||
if (value == GLU_PATH_LENGTH) {
|
||||
nurbsValue = N_PATHLENGTH;
|
||||
} else if (value == GLU_PARAMETRIC_ERROR) {
|
||||
nurbsValue = N_PARAMETRICDISTANCE;
|
||||
} else if (value == GLU_DOMAIN_DISTANCE) {
|
||||
nurbsValue = N_DOMAINDISTANCE;
|
||||
r->set_is_domain_distance_sampling(1); //optimzing untrimmed case
|
||||
|
||||
} else if (value == GLU_OBJECT_PARAMETRIC_ERROR) {
|
||||
nurbsValue = N_OBJECTSPACE_PARA;
|
||||
r->setautoloadmode( 0.0 );
|
||||
r->setSamplingMatrixIdentity();
|
||||
} else if (value == GLU_OBJECT_PATH_LENGTH) {
|
||||
nurbsValue = N_OBJECTSPACE_PATH;
|
||||
r->setautoloadmode( 0.0 );
|
||||
r->setSamplingMatrixIdentity();
|
||||
} else {
|
||||
r->postError(GLU_INVALID_VALUE);
|
||||
return;
|
||||
}
|
||||
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMETHOD, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMETHOD, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMETHOD, nurbsValue);
|
||||
return;
|
||||
|
||||
case GLU_SAMPLING_TOLERANCE:
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_PIXEL_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_PIXEL_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_PIXEL_TOLERANCE, value);
|
||||
return;
|
||||
|
||||
case GLU_PARAMETRIC_TOLERANCE:
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_ERROR_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_ERROR_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_ERROR_TOLERANCE, value);
|
||||
return;
|
||||
|
||||
|
||||
case GLU_DISPLAY_MODE:
|
||||
|
||||
if (value == GLU_FILL) {
|
||||
nurbsValue = N_FILL;
|
||||
} else if (value == GLU_OUTLINE_POLYGON) {
|
||||
nurbsValue = N_OUTLINE_POLY;
|
||||
} else if (value == GLU_OUTLINE_PATCH) {
|
||||
nurbsValue = N_OUTLINE_PATCH;
|
||||
} else {
|
||||
r->postError(GLU_INVALID_VALUE);
|
||||
return;
|
||||
}
|
||||
r->setnurbsproperty(N_DISPLAY, nurbsValue);
|
||||
|
||||
break;
|
||||
|
||||
case GLU_U_STEP:
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_S_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_S_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_S_STEPS, value);
|
||||
|
||||
//added for optimizing untrimmed case
|
||||
r->set_domain_distance_u_rate(value);
|
||||
break;
|
||||
|
||||
case GLU_V_STEP:
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_T_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_T_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_T_STEPS, value);
|
||||
|
||||
//added for optimizing untrimmed case
|
||||
r->set_domain_distance_v_rate(value);
|
||||
break;
|
||||
|
||||
case GLU_NURBS_MODE:
|
||||
if(value == GLU_NURBS_RENDERER)
|
||||
r->put_callbackFlag(0);
|
||||
else if(value == GLU_NURBS_TESSELLATOR)
|
||||
r->put_callbackFlag(1);
|
||||
else
|
||||
r->postError(GLU_INVALID_ENUM);
|
||||
break;
|
||||
|
||||
default:
|
||||
r->postError(GLU_INVALID_ENUM);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluGetNurbsProperty(GLUnurbs *r, GLenum property, GLfloat *value)
|
||||
{
|
||||
GLfloat nurbsValue;
|
||||
|
||||
switch(property) {
|
||||
case GLU_AUTO_LOAD_MATRIX:
|
||||
if (r->getautoloadmode()) {
|
||||
*value = GL_TRUE;
|
||||
} else {
|
||||
*value = GL_FALSE;
|
||||
}
|
||||
break;
|
||||
case GLU_CULLING:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_CULLING, &nurbsValue);
|
||||
if (nurbsValue == N_CULLINGON) {
|
||||
*value = GL_TRUE;
|
||||
} else {
|
||||
*value = GL_FALSE;
|
||||
}
|
||||
break;
|
||||
case GLU_SAMPLING_METHOD:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, value);
|
||||
if(*value == N_PATHLENGTH)
|
||||
*value = GLU_PATH_LENGTH;
|
||||
else if(*value == N_PARAMETRICDISTANCE)
|
||||
*value = GLU_PARAMETRIC_ERROR;
|
||||
else if(*value == N_DOMAINDISTANCE)
|
||||
*value = GLU_DOMAIN_DISTANCE;
|
||||
else if(*value == N_OBJECTSPACE_PATH)
|
||||
*value = GLU_OBJECT_PATH_LENGTH;
|
||||
else if(*value == N_OBJECTSPACE_PARA)
|
||||
*value = GLU_OBJECT_PARAMETRIC_ERROR;
|
||||
break;
|
||||
case GLU_SAMPLING_TOLERANCE:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, value);
|
||||
break;
|
||||
case GLU_PARAMETRIC_TOLERANCE:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, value);
|
||||
break;
|
||||
|
||||
case GLU_U_STEP:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, value);
|
||||
break;
|
||||
case GLU_V_STEP:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, value);
|
||||
break;
|
||||
case GLU_DISPLAY_MODE:
|
||||
r->getnurbsproperty(N_DISPLAY, &nurbsValue);
|
||||
if (nurbsValue == N_FILL) {
|
||||
*value = GLU_FILL;
|
||||
} else if (nurbsValue == N_OUTLINE_POLY) {
|
||||
*value = GLU_OUTLINE_POLYGON;
|
||||
} else {
|
||||
*value = GLU_OUTLINE_PATCH;
|
||||
}
|
||||
break;
|
||||
|
||||
case GLU_NURBS_MODE:
|
||||
if(r->is_callback())
|
||||
*value = GLU_NURBS_TESSELLATOR;
|
||||
else
|
||||
*value = GLU_NURBS_RENDERER;
|
||||
break;
|
||||
|
||||
default:
|
||||
r->postError(GLU_INVALID_ENUM);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void GLAPIENTRY
|
||||
gluNurbsCallback(GLUnurbs *r, GLenum which, _GLUfuncptr fn )
|
||||
{
|
||||
switch (which) {
|
||||
case GLU_NURBS_BEGIN:
|
||||
case GLU_NURBS_END:
|
||||
case GLU_NURBS_VERTEX:
|
||||
case GLU_NURBS_NORMAL:
|
||||
case GLU_NURBS_TEXTURE_COORD:
|
||||
case GLU_NURBS_COLOR:
|
||||
case GLU_NURBS_BEGIN_DATA:
|
||||
case GLU_NURBS_END_DATA:
|
||||
case GLU_NURBS_VERTEX_DATA:
|
||||
case GLU_NURBS_NORMAL_DATA:
|
||||
case GLU_NURBS_TEXTURE_COORD_DATA:
|
||||
case GLU_NURBS_COLOR_DATA:
|
||||
r->putSurfCallBack(which, fn);
|
||||
break;
|
||||
|
||||
case GLU_NURBS_ERROR:
|
||||
r->errorCallback = (void (APIENTRY *)( GLenum e )) fn;
|
||||
break;
|
||||
default:
|
||||
r->postError(GLU_INVALID_ENUM);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void GLAPIENTRY
|
||||
gluNurbsCallbackDataEXT(GLUnurbs* r, void* userData)
|
||||
{
|
||||
r->setNurbsCallbackData(userData);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void GLAPIENTRY
|
||||
gluNurbsCallbackData(GLUnurbs* r, void* userData)
|
||||
{
|
||||
gluNurbsCallbackDataEXT(r,userData);
|
||||
}
|
||||
|
|
@ -1,301 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
**
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "gluos.h"
|
||||
#include "glimports.h"
|
||||
#include "glrenderer.h"
|
||||
|
||||
GLUnurbs::GLUnurbs()
|
||||
: NurbsTessellator(curveEvaluator, surfaceEvaluator)
|
||||
{
|
||||
redefineMaps();
|
||||
defineMap(GL_MAP2_NORMAL, 0, 3);
|
||||
defineMap(GL_MAP1_NORMAL, 0, 3);
|
||||
defineMap(GL_MAP2_TEXTURE_COORD_1, 0, 1);
|
||||
defineMap(GL_MAP1_TEXTURE_COORD_1, 0, 1);
|
||||
defineMap(GL_MAP2_TEXTURE_COORD_2, 0, 2);
|
||||
defineMap(GL_MAP1_TEXTURE_COORD_2, 0, 2);
|
||||
defineMap(GL_MAP2_TEXTURE_COORD_3, 0, 3);
|
||||
defineMap(GL_MAP1_TEXTURE_COORD_3, 0, 3);
|
||||
defineMap(GL_MAP2_TEXTURE_COORD_4, 1, 4);
|
||||
defineMap(GL_MAP1_TEXTURE_COORD_4, 1, 4);
|
||||
defineMap(GL_MAP2_VERTEX_4, 1, 4);
|
||||
defineMap(GL_MAP1_VERTEX_4, 1, 4);
|
||||
defineMap(GL_MAP2_VERTEX_3, 0, 3);
|
||||
defineMap(GL_MAP1_VERTEX_3, 0, 3);
|
||||
defineMap(GL_MAP2_COLOR_4, 0, 4);
|
||||
defineMap(GL_MAP1_COLOR_4, 0, 4);
|
||||
defineMap(GL_MAP2_INDEX, 0, 1);
|
||||
defineMap(GL_MAP1_INDEX, 0, 1);
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMETHOD, (float) N_PATHLENGTH);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMETHOD, (float) N_PATHLENGTH);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, (float) N_PATHLENGTH);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMETHOD, (float) N_PATHLENGTH);
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_PIXEL_TOLERANCE, (float) 50.0);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_PIXEL_TOLERANCE, (float) 50.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, (float) 50.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_PIXEL_TOLERANCE, (float) 50.0);
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_ERROR_TOLERANCE, (float) 0.50);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_ERROR_TOLERANCE, (float) 0.50);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, (float) 0.50);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_ERROR_TOLERANCE, (float) 0.50);
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_S_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_S_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_S_STEPS, (float) 100.0);
|
||||
|
||||
//added for optimizing untrimmed case
|
||||
set_domain_distance_u_rate(100.0);
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_T_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_T_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_T_STEPS, (float) 100.0);
|
||||
|
||||
//added for optimizing untrimmed case
|
||||
set_domain_distance_v_rate(100.0);
|
||||
set_is_domain_distance_sampling(0); //since the default is path_length
|
||||
|
||||
//default autoloadmode is true
|
||||
autoloadmode = 1;
|
||||
|
||||
//default callbackFlag is 0
|
||||
callbackFlag = 0;
|
||||
|
||||
errorCallback = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::bgnrender(void)
|
||||
{
|
||||
if (autoloadmode) {
|
||||
loadGLMatrices();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::endrender(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::errorHandler(int i)
|
||||
{
|
||||
int gluError;
|
||||
|
||||
gluError = i + (GLU_NURBS_ERROR1 - 1);
|
||||
postError( gluError );
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::loadGLMatrices(void)
|
||||
{
|
||||
GLfloat vmat[4][4];
|
||||
GLint viewport[4];
|
||||
|
||||
grabGLMatrix((GLfloat (*)[4]) vmat);
|
||||
loadCullingMatrix((GLfloat (*)[4]) vmat);
|
||||
::glGetIntegerv((GLenum) GL_VIEWPORT, (GLint *) viewport);
|
||||
loadSamplingMatrix((const GLfloat (*)[4]) vmat, (const GLint *) viewport);
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::useGLMatrices(const GLfloat modelMatrix[16],
|
||||
const GLfloat projMatrix[16],
|
||||
const GLint viewport[4])
|
||||
{
|
||||
GLfloat vmat[4][4];
|
||||
|
||||
multmatrix4d(vmat, (const GLfloat (*)[4]) modelMatrix,
|
||||
(const GLfloat (*)[4]) projMatrix);
|
||||
loadCullingMatrix((GLfloat (*)[4]) vmat);
|
||||
loadSamplingMatrix((const GLfloat (*)[4]) vmat, (const GLint *) viewport);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* grabGLMatrix
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
GLUnurbs::grabGLMatrix(GLfloat vmat[4][4])
|
||||
{
|
||||
GLfloat m1[4][4], m2[4][4];
|
||||
|
||||
::glGetFloatv((GLenum) GL_MODELVIEW_MATRIX, (GLfloat *) &(m1[0][0]));
|
||||
::glGetFloatv((GLenum) GL_PROJECTION_MATRIX, (GLfloat *) &(m2[0][0]));
|
||||
multmatrix4d((GLfloat (*)[4]) vmat,
|
||||
(const GLfloat (*)[4]) m1, (const GLfloat (*)[4]) m2);
|
||||
}
|
||||
|
||||
//for object space tesselation: view independent
|
||||
void
|
||||
GLUnurbs::setSamplingMatrixIdentity( void )
|
||||
{
|
||||
INREAL smat[4][4] = {
|
||||
{1,0,0,0},
|
||||
{0,1,0,0},
|
||||
{0,0,1,0},
|
||||
{0,0,0,1}
|
||||
};
|
||||
const long rstride = sizeof(smat[0]) / sizeof(smat[0][0]);
|
||||
const long cstride = 1;
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GLUnurbs::loadSamplingMatrix(const GLfloat vmat[4][4],
|
||||
const GLint viewport[4])
|
||||
{
|
||||
|
||||
/* rescale the mapping to correspond to pixels in x/y */
|
||||
REAL xsize = 0.5 * (REAL) (viewport[2]);
|
||||
REAL ysize = 0.5 * (REAL) (viewport[3]);
|
||||
|
||||
INREAL smat[4][4];
|
||||
smat[0][0] = vmat[0][0] * xsize;
|
||||
smat[1][0] = vmat[1][0] * xsize;
|
||||
smat[2][0] = vmat[2][0] * xsize;
|
||||
smat[3][0] = vmat[3][0] * xsize;
|
||||
|
||||
smat[0][1] = vmat[0][1] * ysize;
|
||||
smat[1][1] = vmat[1][1] * ysize;
|
||||
smat[2][1] = vmat[2][1] * ysize;
|
||||
smat[3][1] = vmat[3][1] * ysize;
|
||||
|
||||
smat[0][2] = 0.0;
|
||||
smat[1][2] = 0.0;
|
||||
smat[2][2] = 0.0;
|
||||
smat[3][2] = 0.0;
|
||||
|
||||
smat[0][3] = vmat[0][3];
|
||||
smat[1][3] = vmat[1][3];
|
||||
smat[2][3] = vmat[2][3];
|
||||
smat[3][3] = vmat[3][3];
|
||||
|
||||
const long rstride = sizeof(smat[0]) / sizeof(smat[0][0]);
|
||||
const long cstride = 1;
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::loadCullingMatrix(GLfloat vmat[4][4])
|
||||
{
|
||||
INREAL cmat[4][4];
|
||||
|
||||
cmat[0][0] = vmat[0][0];
|
||||
cmat[0][1] = vmat[0][1];
|
||||
cmat[0][2] = vmat[0][2];
|
||||
cmat[0][3] = vmat[0][3];
|
||||
|
||||
cmat[1][0] = vmat[1][0];
|
||||
cmat[1][1] = vmat[1][1];
|
||||
cmat[1][2] = vmat[1][2];
|
||||
cmat[1][3] = vmat[1][3];
|
||||
|
||||
cmat[2][0] = vmat[2][0];
|
||||
cmat[2][1] = vmat[2][1];
|
||||
cmat[2][2] = vmat[2][2];
|
||||
cmat[2][3] = vmat[2][3];
|
||||
|
||||
cmat[3][0] = vmat[3][0];
|
||||
cmat[3][1] = vmat[3][1];
|
||||
cmat[3][2] = vmat[3][2];
|
||||
cmat[3][3] = vmat[3][3];
|
||||
|
||||
const long rstride = sizeof(cmat[0]) / sizeof(cmat[0][0]);
|
||||
const long cstride = 1;
|
||||
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_CULLINGMATRIX, &cmat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_CULLINGMATRIX, &cmat[0][0], rstride,
|
||||
cstride);
|
||||
//added for curves by zl
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_CULLINGMATRIX, &cmat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_CULLINGMATRIX, &cmat[0][0], rstride,
|
||||
cstride);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* A = B * MAT ; transform a 4d vector through a 4x4 matrix
|
||||
*---------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
GLUnurbs::transform4d(GLfloat A[4], GLfloat B[4], GLfloat mat[4][4])
|
||||
{
|
||||
|
||||
A[0] = B[0]*mat[0][0] + B[1]*mat[1][0] + B[2]*mat[2][0] + B[3]*mat[3][0];
|
||||
A[1] = B[0]*mat[0][1] + B[1]*mat[1][1] + B[2]*mat[2][1] + B[3]*mat[3][1];
|
||||
A[2] = B[0]*mat[0][2] + B[1]*mat[1][2] + B[2]*mat[2][2] + B[3]*mat[3][2];
|
||||
A[3] = B[0]*mat[0][3] + B[1]*mat[1][3] + B[2]*mat[2][3] + B[3]*mat[3][3];
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* new = [left][right] ; multiply two matrices together
|
||||
*---------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
GLUnurbs::multmatrix4d (GLfloat n[4][4], const GLfloat left[4][4],
|
||||
const GLfloat right[4][4])
|
||||
{
|
||||
transform4d ((GLfloat *) n[0],(GLfloat *) left[0],(GLfloat (*)[4]) right);
|
||||
transform4d ((GLfloat *) n[1],(GLfloat *) left[1],(GLfloat (*)[4]) right);
|
||||
transform4d ((GLfloat *) n[2],(GLfloat *) left[2],(GLfloat (*)[4]) right);
|
||||
transform4d ((GLfloat *) n[3],(GLfloat *) left[3],(GLfloat (*)[4]) right);
|
||||
}
|
||||
|
|
@ -1,146 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* glrenderer.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluglrenderer_h_
|
||||
#define __gluglrenderer_h_
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include "nurbstess.h"
|
||||
#include "glsurfeval.h"
|
||||
#include "glcurveval.h"
|
||||
|
||||
extern "C" {
|
||||
typedef void (APIENTRY *errorCallbackType)( GLenum );
|
||||
}
|
||||
|
||||
class GLUnurbs : public NurbsTessellator {
|
||||
|
||||
public:
|
||||
GLUnurbs( void );
|
||||
void loadGLMatrices( void );
|
||||
void useGLMatrices( const GLfloat modelMatrix[16],
|
||||
const GLfloat projMatrix[16],
|
||||
const GLint viewport[4] );
|
||||
void setSamplingMatrixIdentity( void );
|
||||
|
||||
void errorHandler( int );
|
||||
void bgnrender( void );
|
||||
void endrender( void );
|
||||
void setautoloadmode( INREAL value )
|
||||
{
|
||||
|
||||
if (value) autoloadmode = GL_TRUE;
|
||||
else autoloadmode = GL_FALSE;
|
||||
|
||||
}
|
||||
GLboolean getautoloadmode( void ) { return autoloadmode; }
|
||||
|
||||
errorCallbackType errorCallback;
|
||||
void postError( int which )
|
||||
{ if (errorCallback) (errorCallback)( (GLenum)which ); }
|
||||
#ifdef _WIN32
|
||||
void putSurfCallBack(GLenum which, void (GLAPIENTRY *fn)() )
|
||||
#else
|
||||
void putSurfCallBack(GLenum which, _GLUfuncptr fn )
|
||||
#endif
|
||||
{
|
||||
curveEvaluator.putCallBack(which, fn);
|
||||
surfaceEvaluator.putCallBack(which, fn);
|
||||
}
|
||||
|
||||
int get_vertices_call_back()
|
||||
{
|
||||
return surfaceEvaluator.get_vertices_call_back();
|
||||
}
|
||||
|
||||
void put_vertices_call_back(int flag)
|
||||
{
|
||||
surfaceEvaluator.put_vertices_call_back(flag);
|
||||
}
|
||||
|
||||
int get_callback_auto_normal()
|
||||
{
|
||||
return surfaceEvaluator.get_callback_auto_normal();
|
||||
}
|
||||
|
||||
void put_callback_auto_normal(int flag)
|
||||
{
|
||||
surfaceEvaluator.put_callback_auto_normal(flag);
|
||||
}
|
||||
|
||||
void setNurbsCallbackData(void* userData)
|
||||
{
|
||||
curveEvaluator.set_callback_userData(userData);
|
||||
surfaceEvaluator.set_callback_userData(userData);
|
||||
}
|
||||
|
||||
|
||||
//for LOD
|
||||
void LOD_eval_list(int level)
|
||||
{
|
||||
surfaceEvaluator.LOD_eval_list(level);
|
||||
}
|
||||
|
||||
//NEWCALLBACK
|
||||
int is_callback()
|
||||
{
|
||||
return callbackFlag;
|
||||
}
|
||||
void put_callbackFlag(int flag)
|
||||
{
|
||||
callbackFlag = flag;
|
||||
surfaceEvaluator.put_vertices_call_back(flag);
|
||||
curveEvaluator.put_vertices_call_back(flag);
|
||||
}
|
||||
|
||||
private:
|
||||
GLboolean autoloadmode;
|
||||
OpenGLSurfaceEvaluator surfaceEvaluator;
|
||||
OpenGLCurveEvaluator curveEvaluator;
|
||||
|
||||
void loadSamplingMatrix( const GLfloat vmat[4][4],
|
||||
const GLint viewport[4] );
|
||||
void loadCullingMatrix( GLfloat vmat[4][4] );
|
||||
static void grabGLMatrix( GLfloat vmat[4][4] );
|
||||
static void transform4d( GLfloat A[4], GLfloat B[4],
|
||||
GLfloat mat[4][4] );
|
||||
static void multmatrix4d( GLfloat n[4][4], const GLfloat left[4][4],
|
||||
const GLfloat right[4][4] );
|
||||
|
||||
int callbackFlag;
|
||||
};
|
||||
|
||||
#endif /* __gluglrenderer_h_ */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,404 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* glsurfeval.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluglsurfeval_h_
|
||||
#define __gluglsurfeval_h_
|
||||
|
||||
#include "basicsurfeval.h"
|
||||
#include "bezierPatchMesh.h" //in case output triangles
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
class SurfaceMap;
|
||||
class OpenGLSurfaceEvaluator;
|
||||
class StoredVertex;
|
||||
|
||||
#define TYPECOORD 1
|
||||
#define TYPEPOINT 2
|
||||
|
||||
/* Cache up to 3 vertices from tmeshes */
|
||||
#define VERTEX_CACHE_SIZE 3
|
||||
|
||||
/*for internal evaluator callback stuff*/
|
||||
#ifndef IN_MAX_BEZIER_ORDER
|
||||
#define IN_MAX_BEZIER_ORDER 40 /*XXX should be bigger than machine order*/
|
||||
#endif
|
||||
|
||||
#ifndef IN_MAX_DIMENSION
|
||||
#define IN_MAX_DIMENSION 4
|
||||
#endif
|
||||
|
||||
typedef struct surfEvalMachine{
|
||||
REAL uprime;//cached previusly evaluated uprime.
|
||||
REAL vprime;
|
||||
int k; /*the dimension*/
|
||||
REAL u1;
|
||||
REAL u2;
|
||||
int ustride;
|
||||
int uorder;
|
||||
REAL v1;
|
||||
REAL v2;
|
||||
int vstride;
|
||||
int vorder;
|
||||
REAL ctlPoints[IN_MAX_BEZIER_ORDER*IN_MAX_BEZIER_ORDER*IN_MAX_DIMENSION];
|
||||
REAL ucoeff[IN_MAX_BEZIER_ORDER]; /*cache the polynomial values*/
|
||||
REAL vcoeff[IN_MAX_BEZIER_ORDER];
|
||||
REAL ucoeffDeriv[IN_MAX_BEZIER_ORDER]; /*cache the polynomial derivatives*/
|
||||
REAL vcoeffDeriv[IN_MAX_BEZIER_ORDER];
|
||||
} surfEvalMachine;
|
||||
|
||||
|
||||
|
||||
class StoredVertex {
|
||||
public:
|
||||
StoredVertex() { type = 0; coord[0] = 0; coord[1] = 0; point[0] = 0; point[1] = 0; }
|
||||
~StoredVertex(void) {}
|
||||
void saveEvalCoord(REAL x, REAL y)
|
||||
{coord[0] = x; coord[1] = y; type = TYPECOORD; }
|
||||
void saveEvalPoint(long x, long y)
|
||||
{point[0] = x; point[1] = y; type = TYPEPOINT; }
|
||||
void invoke(OpenGLSurfaceEvaluator *eval);
|
||||
|
||||
private:
|
||||
int type;
|
||||
REAL coord[2];
|
||||
long point[2];
|
||||
};
|
||||
|
||||
class OpenGLSurfaceEvaluator : public BasicSurfaceEvaluator {
|
||||
public:
|
||||
OpenGLSurfaceEvaluator();
|
||||
virtual ~OpenGLSurfaceEvaluator( void );
|
||||
void polymode( long style );
|
||||
void range2f( long, REAL *, REAL * );
|
||||
void domain2f( REAL, REAL, REAL, REAL );
|
||||
void addMap( SurfaceMap * ) { }
|
||||
|
||||
void enable( long );
|
||||
void disable( long );
|
||||
void bgnmap2f( long );
|
||||
void map2f( long, REAL, REAL, long, long,
|
||||
REAL, REAL, long, long, REAL * );
|
||||
void mapgrid2f( long, REAL, REAL, long, REAL, REAL );
|
||||
void mapmesh2f( long, long, long, long, long );
|
||||
void evalcoord2f( long, REAL, REAL );
|
||||
void evalpoint2i( long, long );
|
||||
void endmap2f( void );
|
||||
|
||||
void bgnline( void );
|
||||
void endline( void );
|
||||
void bgnclosedline( void );
|
||||
void endclosedline( void );
|
||||
void bgntmesh( void );
|
||||
void swaptmesh( void );
|
||||
void endtmesh( void );
|
||||
void bgnqstrip( void );
|
||||
void endqstrip( void );
|
||||
|
||||
void bgntfan( void );
|
||||
void endtfan( void );
|
||||
void evalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
|
||||
int n_lower, REAL v_lower, REAL* lower_val);
|
||||
void evalVStrip(int n_left, REAL u_left, REAL* left_val,
|
||||
int n_right, REAL u_right, REAL* right_val);
|
||||
|
||||
void coord2f( REAL, REAL );
|
||||
void point2i( long, long );
|
||||
|
||||
void newtmeshvert( REAL, REAL );
|
||||
void newtmeshvert( long, long );
|
||||
|
||||
#ifdef _WIN32
|
||||
void putCallBack(GLenum which, void (GLAPIENTRY *fn)() );
|
||||
#else
|
||||
void putCallBack(GLenum which, _GLUfuncptr fn );
|
||||
#endif
|
||||
|
||||
int get_vertices_call_back()
|
||||
{
|
||||
return output_triangles;
|
||||
}
|
||||
void put_vertices_call_back(int flag)
|
||||
{
|
||||
output_triangles = flag;
|
||||
}
|
||||
|
||||
void put_callback_auto_normal(int flag)
|
||||
{
|
||||
callback_auto_normal = flag;
|
||||
}
|
||||
|
||||
int get_callback_auto_normal()
|
||||
{
|
||||
return callback_auto_normal;
|
||||
}
|
||||
|
||||
void set_callback_userData(void* data)
|
||||
{
|
||||
userData = data;
|
||||
}
|
||||
|
||||
/**************begin for LOD_eval_list***********/
|
||||
void LOD_eval_list(int level);
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
StoredVertex *vertexCache[VERTEX_CACHE_SIZE];
|
||||
int tmeshing;
|
||||
int which;
|
||||
int vcount;
|
||||
|
||||
GLint gl_polygon_mode[2];/*to save and restore so that
|
||||
*no side effect
|
||||
*/
|
||||
bezierPatchMesh *global_bpm; //for output triangles
|
||||
int output_triangles; //true 1 or false 0
|
||||
|
||||
|
||||
|
||||
void (GLAPIENTRY *beginCallBackN) (GLenum type);
|
||||
void (GLAPIENTRY *endCallBackN) (void);
|
||||
void (GLAPIENTRY *vertexCallBackN) (const GLfloat *vert);
|
||||
void (GLAPIENTRY *normalCallBackN) (const GLfloat *normal);
|
||||
void (GLAPIENTRY *colorCallBackN) (const GLfloat *color);
|
||||
void (GLAPIENTRY *texcoordCallBackN) (const GLfloat *texcoord);
|
||||
|
||||
void (GLAPIENTRY *beginCallBackData) (GLenum type, void* data);
|
||||
void (GLAPIENTRY *endCallBackData) (void* data);
|
||||
void (GLAPIENTRY *vertexCallBackData) (const GLfloat *vert, void* data);
|
||||
void (GLAPIENTRY *normalCallBackData) (const GLfloat *normal, void* data);
|
||||
void (GLAPIENTRY *colorCallBackData) (const GLfloat *color, void* data);
|
||||
void (GLAPIENTRY *texcoordCallBackData) (const GLfloat *texcoord, void* data);
|
||||
|
||||
void beginCallBack (GLenum type, void* data);
|
||||
void endCallBack (void* data);
|
||||
void vertexCallBack (const GLfloat *vert, void* data);
|
||||
void normalCallBack (const GLfloat *normal, void* data);
|
||||
void colorCallBack (const GLfloat *color, void* data);
|
||||
void texcoordCallBack (const GLfloat *texcoord, void* data);
|
||||
|
||||
|
||||
void* userData; //the opaque pointer for Data callback functions.
|
||||
|
||||
/*LOD evaluation*/
|
||||
void LOD_triangle(REAL A[2], REAL B[2], REAL C[2],
|
||||
int level);
|
||||
void LOD_eval(int num_vert, REAL* verts, int type, int level);
|
||||
|
||||
int LOD_eval_level; //set by LOD_eval_list()
|
||||
|
||||
/*************begin for internal evaluators*****************/
|
||||
|
||||
/*the following global variables are only defined in this file.
|
||||
*They are used to cache the precomputed Bezier polynomial values.
|
||||
*These calues may be used consecutively in which case we don't have
|
||||
*recompute these values again.
|
||||
*/
|
||||
int global_uorder; /*store the uorder in the previous evaluation*/
|
||||
int global_vorder; /*store the vorder in the previous evaluation*/
|
||||
REAL global_uprime;
|
||||
REAL global_vprime;
|
||||
REAL global_vprime_BV;
|
||||
REAL global_uprime_BU;
|
||||
int global_uorder_BV; /*store the uorder in the previous evaluation*/
|
||||
int global_vorder_BV; /*store the vorder in the previous evaluation*/
|
||||
int global_uorder_BU; /*store the uorder in the previous evaluation*/
|
||||
int global_vorder_BU; /*store the vorder in the previous evaluation*/
|
||||
|
||||
REAL global_ucoeff[IN_MAX_BEZIER_ORDER]; /*cache the polynomial values*/
|
||||
REAL global_vcoeff[IN_MAX_BEZIER_ORDER];
|
||||
REAL global_ucoeffDeriv[IN_MAX_BEZIER_ORDER]; /*cache the polynomial derivatives*/
|
||||
REAL global_vcoeffDeriv[IN_MAX_BEZIER_ORDER];
|
||||
|
||||
REAL global_BV[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
|
||||
REAL global_PBV[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
|
||||
REAL global_BU[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
|
||||
REAL global_PBU[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
|
||||
REAL* global_baseData;
|
||||
|
||||
int global_ev_k; /*the dimension*/
|
||||
REAL global_ev_u1;
|
||||
REAL global_ev_u2;
|
||||
int global_ev_ustride;
|
||||
int global_ev_uorder;
|
||||
REAL global_ev_v1;
|
||||
REAL global_ev_v2;
|
||||
int global_ev_vstride;
|
||||
int global_ev_vorder;
|
||||
REAL global_ev_ctlPoints[IN_MAX_BEZIER_ORDER*IN_MAX_BEZIER_ORDER*IN_MAX_DIMENSION];
|
||||
|
||||
REAL global_grid_u0;
|
||||
REAL global_grid_u1;
|
||||
int global_grid_nu;
|
||||
REAL global_grid_v0;
|
||||
REAL global_grid_v1;
|
||||
int global_grid_nv;
|
||||
|
||||
/*functions*/
|
||||
void inDoDomain2WithDerivs(int k, REAL u, REAL v,
|
||||
REAL u1, REAL u2, int uorder,
|
||||
REAL v1, REAL v2, int vorder,
|
||||
REAL *baseData,
|
||||
REAL *retPoint, REAL *retdu, REAL *retdv);
|
||||
void inPreEvaluate(int order, REAL vprime, REAL *coeff);
|
||||
void inPreEvaluateWithDeriv(int order, REAL vprime, REAL *coeff, REAL *coeffDeriv);
|
||||
void inComputeFirstPartials(REAL *p, REAL *pu, REAL *pv);
|
||||
void inComputeNormal2(REAL *pu, REAL *pv, REAL *n);
|
||||
void inDoEvalCoord2(REAL u, REAL v,
|
||||
REAL *retPoint, REAL *retNormal);
|
||||
void inDoEvalCoord2NOGE(REAL u, REAL v,
|
||||
REAL *retPoint, REAL *retNormal);
|
||||
void inMap2f(int k,
|
||||
REAL ulower,
|
||||
REAL uupper,
|
||||
int ustride,
|
||||
int uorder,
|
||||
REAL vlower,
|
||||
REAL vupper,
|
||||
int vstride,
|
||||
int vorder,
|
||||
REAL *ctlPoints);
|
||||
|
||||
void inMapGrid2f(int nu, REAL u0, REAL u1,
|
||||
int nv, REAL v0, REAL v1);
|
||||
|
||||
void inEvalMesh2(int lowU, int lowV, int highU, int highV);
|
||||
void inEvalPoint2(int i, int j);
|
||||
void inEvalCoord2f(REAL u, REAL v);
|
||||
|
||||
void inEvalULine(int n_points, REAL v, REAL* u_vals,
|
||||
int stride, REAL ret_points[][3], REAL ret_normals[][3]);
|
||||
|
||||
void inEvalVLine(int n_points, REAL u, REAL* v_vals,
|
||||
int stride, REAL ret_points[][3], REAL ret_normals[][3]);
|
||||
|
||||
void inEvalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
|
||||
int n_lower, REAL v_lower, REAL* lower_val
|
||||
);
|
||||
void inEvalVStrip(int n_left, REAL u_left, REAL* left_val, int n_right, REAL u_right, REAL* right_val);
|
||||
|
||||
void inPreEvaluateBV(int k, int uorder, int vorder, REAL vprime, REAL *baseData);
|
||||
void inPreEvaluateBU(int k, int uorder, int vorder, REAL uprime, REAL *baseData);
|
||||
void inPreEvaluateBV_intfac(REAL v )
|
||||
{
|
||||
inPreEvaluateBV(global_ev_k, global_ev_uorder, global_ev_vorder, (v-global_ev_v1)/(global_ev_v2-global_ev_v1), global_ev_ctlPoints);
|
||||
}
|
||||
|
||||
void inPreEvaluateBU_intfac(REAL u)
|
||||
{
|
||||
inPreEvaluateBU(global_ev_k, global_ev_uorder, global_ev_vorder, (u-global_ev_u1)/(global_ev_u2-global_ev_u1), global_ev_ctlPoints);
|
||||
}
|
||||
|
||||
void inDoDomain2WithDerivsBV(int k, REAL u, REAL v,
|
||||
REAL u1, REAL u2, int uorder,
|
||||
REAL v1, REAL v2, int vorder,
|
||||
REAL *baseData,
|
||||
REAL *retPoint, REAL* retdu, REAL *retdv);
|
||||
|
||||
void inDoDomain2WithDerivsBU(int k, REAL u, REAL v,
|
||||
REAL u1, REAL u2, int uorder,
|
||||
REAL v1, REAL v2, int vorder,
|
||||
REAL *baseData,
|
||||
REAL *retPoint, REAL* retdu, REAL *retdv);
|
||||
|
||||
|
||||
void inDoEvalCoord2NOGE_BV(REAL u, REAL v,
|
||||
REAL *retPoint, REAL *retNormal);
|
||||
|
||||
void inDoEvalCoord2NOGE_BU(REAL u, REAL v,
|
||||
REAL *retPoint, REAL *retNormal);
|
||||
|
||||
void inBPMEval(bezierPatchMesh* bpm);
|
||||
void inBPMListEval(bezierPatchMesh* list);
|
||||
|
||||
/*-------------begin for surfEvalMachine -------------*/
|
||||
surfEvalMachine em_vertex;
|
||||
surfEvalMachine em_normal;
|
||||
surfEvalMachine em_color;
|
||||
surfEvalMachine em_texcoord;
|
||||
|
||||
int auto_normal_flag; //whether to output normla or not in callback
|
||||
//determined by GL_AUTO_NORMAL and callback_auto_normal
|
||||
int callback_auto_normal; //GLU_CALLBACK_AUTO_NORMAL_EXT
|
||||
int vertex_flag;
|
||||
int normal_flag;
|
||||
int color_flag;
|
||||
int texcoord_flag;
|
||||
|
||||
void inMap2fEM(int which, //0:vert,1:norm,2:color,3:tex
|
||||
int dimension,
|
||||
REAL ulower,
|
||||
REAL uupper,
|
||||
int ustride,
|
||||
int uorder,
|
||||
REAL vlower,
|
||||
REAL vupper,
|
||||
int vstride,
|
||||
int vorder,
|
||||
REAL *ctlPoints);
|
||||
|
||||
void inDoDomain2WithDerivsEM(surfEvalMachine *em, REAL u, REAL v,
|
||||
REAL *retPoint, REAL *retdu, REAL *retdv);
|
||||
void inDoDomain2EM(surfEvalMachine *em, REAL u, REAL v,
|
||||
REAL *retPoint);
|
||||
void inDoEvalCoord2EM(REAL u, REAL v);
|
||||
|
||||
void inBPMEvalEM(bezierPatchMesh* bpm);
|
||||
void inBPMListEvalEM(bezierPatchMesh* list);
|
||||
|
||||
/*-------------end for surfEvalMachine -------------*/
|
||||
|
||||
|
||||
/*************end for internal evaluators*****************/
|
||||
|
||||
};
|
||||
|
||||
inline void StoredVertex::invoke(OpenGLSurfaceEvaluator *eval)
|
||||
{
|
||||
switch(type) {
|
||||
case TYPECOORD:
|
||||
eval->coord2f(coord[0], coord[1]);
|
||||
break;
|
||||
case TYPEPOINT:
|
||||
eval->point2i(point[0], point[1]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __gluglsurfeval_h_ */
|
||||
|
|
@ -1,206 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
**
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "glcurveval.h"
|
||||
|
||||
|
||||
/*
|
||||
*compute the Bezier polynomials C[n,j](v) for all j at v with
|
||||
*return values stored in coeff[], where
|
||||
* C[n,j](v) = (n,j) * v^j * (1-v)^(n-j),
|
||||
* j=0,1,2,...,n.
|
||||
*order : n+1
|
||||
*vprime: v
|
||||
*coeff : coeff[j]=C[n,j](v), this array store the returned values.
|
||||
*The algorithm is a recursive scheme:
|
||||
* C[0,0]=1;
|
||||
* C[n,j](v) = (1-v)*C[n-1,j](v) + v*C[n-1,j-1](v), n>=1
|
||||
*This code is copied from opengl/soft/so_eval.c:PreEvaluate
|
||||
*/
|
||||
void OpenGLCurveEvaluator::inPreEvaluate(int order, REAL vprime, REAL *coeff)
|
||||
{
|
||||
int i, j;
|
||||
REAL oldval, temp;
|
||||
REAL oneMinusvprime;
|
||||
|
||||
/*
|
||||
* Minor optimization
|
||||
* Compute orders 1 and 2 outright, and set coeff[0], coeff[1] to
|
||||
* their i==1 loop values to avoid the initialization and the i==1 loop.
|
||||
*/
|
||||
if (order == 1) {
|
||||
coeff[0] = 1.0;
|
||||
return;
|
||||
}
|
||||
|
||||
oneMinusvprime = 1-vprime;
|
||||
coeff[0] = oneMinusvprime;
|
||||
coeff[1] = vprime;
|
||||
if (order == 2) return;
|
||||
|
||||
for (i = 2; i < order; i++) {
|
||||
oldval = coeff[0] * vprime;
|
||||
coeff[0] = oneMinusvprime * coeff[0];
|
||||
for (j = 1; j < i; j++) {
|
||||
temp = oldval;
|
||||
oldval = coeff[j] * vprime;
|
||||
coeff[j] = temp + oneMinusvprime * coeff[j];
|
||||
}
|
||||
coeff[j] = oldval;
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLCurveEvaluator::inMap1f(int which, //0: vert, 1: norm, 2: color, 3: tex
|
||||
int k, //dimension
|
||||
REAL ulower,
|
||||
REAL uupper,
|
||||
int ustride,
|
||||
int uorder,
|
||||
REAL *ctlpoints)
|
||||
{
|
||||
int i,x;
|
||||
curveEvalMachine *temp_em;
|
||||
switch(which){
|
||||
case 0: //vertex
|
||||
vertex_flag = 1;
|
||||
temp_em = &em_vertex;
|
||||
break;
|
||||
case 1: //normal
|
||||
normal_flag = 1;
|
||||
temp_em = &em_normal;
|
||||
break;
|
||||
case 2: //color
|
||||
color_flag = 1;
|
||||
temp_em = &em_color;
|
||||
break;
|
||||
default:
|
||||
texcoord_flag = 1;
|
||||
temp_em = &em_texcoord;
|
||||
break;
|
||||
}
|
||||
|
||||
REAL *data = temp_em->ctlpoints;
|
||||
temp_em->uprime = -1; //initialized
|
||||
temp_em->k = k;
|
||||
temp_em->u1 = ulower;
|
||||
temp_em->u2 = uupper;
|
||||
temp_em->ustride = ustride;
|
||||
temp_em->uorder = uorder;
|
||||
/*copy the control points*/
|
||||
for(i=0; i<uorder; i++){
|
||||
for(x=0; x<k; x++){
|
||||
data[x] = ctlpoints[x];
|
||||
}
|
||||
ctlpoints += ustride;
|
||||
data += k;
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLCurveEvaluator::inDoDomain1(curveEvalMachine *em, REAL u, REAL *retPoint)
|
||||
{
|
||||
int j, row;
|
||||
REAL the_uprime;
|
||||
REAL *data;
|
||||
|
||||
if(em->u2 == em->u1)
|
||||
return;
|
||||
the_uprime = (u-em->u1) / (em->u2-em->u1);
|
||||
/*use already cached values if possible*/
|
||||
if(em->uprime != the_uprime){
|
||||
inPreEvaluate(em->uorder, the_uprime, em->ucoeff);
|
||||
em->uprime = the_uprime;
|
||||
}
|
||||
|
||||
for(j=0; j<em->k; j++){
|
||||
data = em->ctlpoints+j;
|
||||
retPoint[j] = 0.0;
|
||||
for(row=0; row<em->uorder; row++)
|
||||
{
|
||||
retPoint[j] += em->ucoeff[row] * (*data);
|
||||
data += em->k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLCurveEvaluator::inDoEvalCoord1(REAL u)
|
||||
{
|
||||
REAL temp_vertex[4];
|
||||
REAL temp_normal[3];
|
||||
REAL temp_color[4];
|
||||
REAL temp_texcoord[4];
|
||||
if(texcoord_flag) //there is a texture map
|
||||
{
|
||||
inDoDomain1(&em_texcoord, u, temp_texcoord);
|
||||
texcoordCallBack(temp_texcoord, userData);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf("color_flag = %i\n", color_flag);
|
||||
#endif
|
||||
if(color_flag) //there is a color map
|
||||
{
|
||||
inDoDomain1(&em_color, u, temp_color);
|
||||
colorCallBack(temp_color, userData);
|
||||
}
|
||||
if(normal_flag) //there is a normal map
|
||||
{
|
||||
inDoDomain1(&em_normal, u, temp_normal);
|
||||
normalCallBack(temp_normal, userData);
|
||||
}
|
||||
if(vertex_flag)
|
||||
{
|
||||
inDoDomain1(&em_vertex, u, temp_vertex);
|
||||
vertexCallBack(temp_vertex, userData);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLCurveEvaluator::inMapMesh1f(int umin, int umax)
|
||||
{
|
||||
REAL du, u;
|
||||
int i;
|
||||
if(global_grid_nu == 0)
|
||||
return; //no points to output
|
||||
du = (global_grid_u1 - global_grid_u0) / (REAL) global_grid_nu;
|
||||
bgnline();
|
||||
for(i=umin; i<= umax; i++){
|
||||
u = (i==global_grid_nu)? global_grid_u1: global_grid_u0 + i*du;
|
||||
inDoEvalCoord1(u);
|
||||
}
|
||||
endline();
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mystdio.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glumystdio_h_
|
||||
#define __glumystdio_h_
|
||||
|
||||
#ifdef STANDALONE
|
||||
inline void _glu_dprintf( const char *, ... ) { }
|
||||
#endif
|
||||
|
||||
#ifdef LIBRARYBUILD
|
||||
#ifndef NDEBUG
|
||||
#include <stdio.h>
|
||||
#define _glu_dprintf printf
|
||||
#else
|
||||
inline void _glu_dprintf( const char *, ... ) { }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GLBUILD
|
||||
inline void _glu_dprintf( const char *, ... ) { }
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#endif /* __glumystdio_h_ */
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mystdlib.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glumystdlib_h_
|
||||
#define __glumystdlib_h_
|
||||
|
||||
#ifdef STANDALONE
|
||||
typedef unsigned int size_t;
|
||||
extern "C" void abort( void );
|
||||
extern "C" void * malloc( size_t );
|
||||
extern "C" void free( void * );
|
||||
#endif
|
||||
|
||||
#ifdef LIBRARYBUILD
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef GLBUILD
|
||||
typedef unsigned int size_t;
|
||||
extern "C" void abort( void );
|
||||
extern "C" void * malloc( size_t );
|
||||
extern "C" void free( void * );
|
||||
#endif
|
||||
|
||||
#endif /* __glumystdlib_h_ */
|
||||
|
|
@ -1,346 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arc.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "arc.h"
|
||||
#include "bin.h"
|
||||
#include "pwlarc.h"
|
||||
#include "simplemath.h"
|
||||
|
||||
/* local preprocessor definitions */
|
||||
#define ZERO 0.00001/*0.000001*/
|
||||
|
||||
const int Arc::bezier_tag = (1<<13);
|
||||
const int Arc::arc_tag = (1<<3);
|
||||
const int Arc::tail_tag = (1<<6);
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* makeSide - attach a pwl arc to an arc and mark it as a border arc
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Arc::makeSide( PwlArc *pwl, arc_side side )
|
||||
{
|
||||
assert( pwl != 0);
|
||||
assert( pwlArc == 0 );
|
||||
assert( pwl->npts > 0 );
|
||||
assert( pwl->pts != 0);
|
||||
pwlArc = pwl;
|
||||
clearbezier();
|
||||
setside( side );
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* numpts - count number of points on arc loop
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
Arc::numpts( void )
|
||||
{
|
||||
Arc_ptr jarc = this;
|
||||
int npts = 0;
|
||||
do {
|
||||
npts += jarc->pwlArc->npts;
|
||||
jarc = jarc->next;
|
||||
} while( jarc != this );
|
||||
return npts;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* markverts - mark each point with id of arc
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Arc::markverts( void )
|
||||
{
|
||||
Arc_ptr jarc = this;
|
||||
|
||||
do {
|
||||
TrimVertex *p = jarc->pwlArc->pts;
|
||||
for( int i=0; i<jarc->pwlArc->npts; i++ )
|
||||
p[i].nuid = jarc->nuid;
|
||||
jarc = jarc->next;
|
||||
} while( jarc != this );
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* getextrema - find axis extrema on arc loop
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Arc::getextrema( Arc_ptr extrema[4] )
|
||||
{
|
||||
REAL leftpt, botpt, rightpt, toppt;
|
||||
|
||||
extrema[0] = extrema[1] = extrema[2] = extrema[3] = this;
|
||||
|
||||
leftpt = rightpt = this->tail()[0];
|
||||
botpt = toppt = this->tail()[1];
|
||||
|
||||
for( Arc_ptr jarc = this->next; jarc != this; jarc = jarc->next ) {
|
||||
if ( jarc->tail()[0] < leftpt ||
|
||||
(jarc->tail()[0] <= leftpt && jarc->rhead()[0]<=leftpt)) {
|
||||
leftpt = jarc->pwlArc->pts->param[0];
|
||||
extrema[1] = jarc;
|
||||
}
|
||||
if ( jarc->tail()[0] > rightpt ||
|
||||
(jarc->tail()[0] >= rightpt && jarc->rhead()[0] >= rightpt)) {
|
||||
rightpt = jarc->pwlArc->pts->param[0];
|
||||
extrema[3] = jarc;
|
||||
}
|
||||
if ( jarc->tail()[1] < botpt ||
|
||||
(jarc->tail()[1] <= botpt && jarc->rhead()[1] <= botpt )) {
|
||||
botpt = jarc->pwlArc->pts->param[1];
|
||||
extrema[2] = jarc;
|
||||
}
|
||||
if ( jarc->tail()[1] > toppt ||
|
||||
(jarc->tail()[1] >= toppt && jarc->rhead()[1] >= toppt)) {
|
||||
toppt = jarc->pwlArc->pts->param[1];
|
||||
extrema[0] = jarc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* show - print to the stdout the vertices of a pwl arc
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Arc::show()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "\tPWLARC NP: %d FL: 1\n", pwlArc->npts );
|
||||
for( int i = 0; i < pwlArc->npts; i++ ) {
|
||||
_glu_dprintf( "\t\tVERTEX %f %f\n", pwlArc->pts[i].param[0],
|
||||
pwlArc->pts[i].param[1] );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* print - print out the vertices of all pwl arcs on a loop
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Arc::print( void )
|
||||
{
|
||||
Arc_ptr jarc = this;
|
||||
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "BGNTRIM\n" );
|
||||
#endif
|
||||
do {
|
||||
jarc->show( );
|
||||
jarc = jarc->next;
|
||||
} while (jarc != this);
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf("ENDTRIM\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* isDisconnected - check if tail of arc and head of prev meet
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
Arc::isDisconnected( void )
|
||||
{
|
||||
if( pwlArc == 0 ) return 0;
|
||||
if( prev->pwlArc == 0 ) return 0;
|
||||
|
||||
REAL *p0 = tail();
|
||||
REAL *p1 = prev->rhead();
|
||||
|
||||
if( ((p0[0] - p1[0]) > ZERO) || ((p1[0] - p0[0]) > ZERO) ||
|
||||
((p0[1] - p1[1]) > ZERO) || ((p1[1] - p0[1]) > ZERO) ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "x coord = %f %f %f\n", p0[0], p1[0], p0[0] - p1[0] );
|
||||
_glu_dprintf( "y coord = %f %f %f\n", p0[1], p1[1], p0[1] - p1[1] );
|
||||
#endif
|
||||
return 1;
|
||||
} else {
|
||||
/* average two points together */
|
||||
p0[0] = p1[0] = (p1[0] + p0[0]) * 0.5;
|
||||
p0[1] = p1[1] = (p1[1] + p0[1]) * 0.5;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* neq_vert - assert that two 2D vertices are not equal
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static int
|
||||
neq_vert( REAL *v1, REAL *v2 )
|
||||
{
|
||||
return ((v1[0] != v2[0]) || (v1[1] != v2[1] )) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* check - verify consistency of a loop, including
|
||||
* 1) if pwl, no two consecutive vertices are identical
|
||||
* 2) the circular link pointers are valid
|
||||
* 3) the geometric info at the head and tail are consistent
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
Arc::check( void )
|
||||
{
|
||||
if( this == 0 ) return 1;
|
||||
Arc_ptr jarc = this;
|
||||
do {
|
||||
assert( (jarc->pwlArc != 0) || (jarc->bezierArc != 0) );
|
||||
|
||||
if (jarc->prev == 0 || jarc->next == 0) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "checkjarc:null next/prev pointer\n");
|
||||
jarc->print( );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (jarc->next->prev != jarc) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "checkjarc: pointer linkage screwed up\n");
|
||||
jarc->print( );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( jarc->pwlArc ) {
|
||||
#ifndef NDEBUG
|
||||
assert( jarc->pwlArc->npts >= 1 );
|
||||
assert( jarc->pwlArc->npts < 100000 );
|
||||
/*
|
||||
for( int i=0; i < jarc->pwlArc->npts-1; i++ )
|
||||
assert( neq_vert( jarc->pwlArc->pts[i].param,
|
||||
jarc->pwlArc->pts[i+1].param) );
|
||||
*/
|
||||
#endif
|
||||
if( jarc->prev->pwlArc ) {
|
||||
if( jarc->tail()[1] != jarc->prev->rhead()[1] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "checkjarc: geometric linkage screwed up 1\n");
|
||||
jarc->prev->show();
|
||||
jarc->show();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
if( jarc->tail()[0] != jarc->prev->rhead()[0] ) {
|
||||
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "checkjarc: geometric linkage screwed up 2\n");
|
||||
jarc->prev->show();
|
||||
jarc->show();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if( jarc->next->pwlArc ) {
|
||||
if( jarc->next->tail()[0] != jarc->rhead()[0] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "checkjarc: geometric linkage screwed up 3\n");
|
||||
jarc->show();
|
||||
jarc->next->show();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
if( jarc->next->tail()[1] != jarc->rhead()[1] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "checkjarc: geometric linkage screwed up 4\n");
|
||||
jarc->show();
|
||||
jarc->next->show();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if( jarc->isbezier() ) {
|
||||
assert( jarc->pwlArc->npts == 2 );
|
||||
assert( (jarc->pwlArc->pts[0].param[0] == \
|
||||
jarc->pwlArc->pts[1].param[0]) ||\
|
||||
(jarc->pwlArc->pts[0].param[1] == \
|
||||
jarc->pwlArc->pts[1].param[1]) );
|
||||
}
|
||||
}
|
||||
jarc = jarc->next;
|
||||
} while (jarc != this);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#define TOL 0.00001
|
||||
|
||||
inline long tooclose( REAL x, REAL y )
|
||||
{
|
||||
return (glu_abs(x-y) < TOL) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* append - append a jordan arc to a circularly linked list
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Arc_ptr
|
||||
Arc::append( Arc_ptr jarc )
|
||||
{
|
||||
if( jarc != 0 ) {
|
||||
next = jarc->next;
|
||||
prev = jarc;
|
||||
next->prev = prev->next = this;
|
||||
} else {
|
||||
next = prev = this;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -1,139 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arc.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluarc_h_
|
||||
#define __gluarc_h_
|
||||
|
||||
#include "myassert.h"
|
||||
#include "bufpool.h"
|
||||
#include "mystdio.h"
|
||||
#include "types.h"
|
||||
#include "pwlarc.h"
|
||||
#include "trimvertex.h"
|
||||
|
||||
class Bin;
|
||||
class Arc;
|
||||
struct BezierArc;
|
||||
|
||||
typedef class Arc *Arc_ptr;
|
||||
|
||||
enum arc_side { arc_none = 0, arc_right, arc_top, arc_left, arc_bottom };
|
||||
|
||||
|
||||
class Arc: public PooledObj { /* an arc, in two list, the trim list and bin */
|
||||
|
||||
public:
|
||||
static const int bezier_tag;
|
||||
static const int arc_tag;
|
||||
static const int tail_tag;
|
||||
Arc_ptr prev; /* trim list pointer */
|
||||
Arc_ptr next; /* trim list pointer */
|
||||
Arc_ptr link; /* bin pointers */
|
||||
BezierArc * bezierArc; /* associated bezier arc */
|
||||
PwlArc * pwlArc; /* associated pwl arc */
|
||||
long type; /* curve type */
|
||||
long nuid;
|
||||
|
||||
inline Arc( Arc *, PwlArc * );
|
||||
inline Arc( arc_side, long );
|
||||
|
||||
Arc_ptr append( Arc_ptr );
|
||||
int check( void );
|
||||
int isMonotone( void );
|
||||
int isDisconnected( void );
|
||||
int numpts( void );
|
||||
void markverts( void );
|
||||
void getextrema( Arc_ptr[4] );
|
||||
void print( void );
|
||||
void show( void );
|
||||
void makeSide( PwlArc *, arc_side );
|
||||
inline int isTessellated() { return pwlArc ? 1 : 0; }
|
||||
inline long isbezier() { return type & bezier_tag; }
|
||||
inline void setbezier() { type |= bezier_tag; }
|
||||
inline void clearbezier() { type &= ~bezier_tag; }
|
||||
inline long npts() { return pwlArc->npts; }
|
||||
inline TrimVertex * pts() { return pwlArc->pts; }
|
||||
inline REAL * tail() { return pwlArc->pts[0].param; }
|
||||
inline REAL * head() { return next->pwlArc->pts[0].param; }
|
||||
inline REAL * rhead() { return pwlArc->pts[pwlArc->npts-1].param; }
|
||||
inline long ismarked() { return type & arc_tag; }
|
||||
inline void setmark() { type |= arc_tag; }
|
||||
inline void clearmark() { type &= (~arc_tag); }
|
||||
inline void clearside() { type &= ~(0x7 << 8); }
|
||||
inline void setside( arc_side s ) { clearside(); type |= (((long)s)<<8); }
|
||||
inline arc_side getside() { return (arc_side) ((type>>8) & 0x7); }
|
||||
inline int getitail() { return type & tail_tag; }
|
||||
inline void setitail() { type |= tail_tag; }
|
||||
inline void clearitail() { type &= (~tail_tag); }
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Arc - initialize a new Arc with the same type and uid of
|
||||
* a given Arc and a given pwl arc
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline
|
||||
Arc::Arc( Arc *j, PwlArc *p )
|
||||
{
|
||||
prev = NULL;
|
||||
next = NULL;
|
||||
link = NULL;
|
||||
bezierArc = NULL;
|
||||
pwlArc = p;
|
||||
type = j->type;
|
||||
nuid = j->nuid;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Arc - initialize a new Arc with the same type and uid of
|
||||
* a given Arc and a given pwl arc
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline
|
||||
Arc::Arc( arc_side side, long _nuid )
|
||||
{
|
||||
prev = NULL;
|
||||
next = NULL;
|
||||
link = NULL;
|
||||
bezierArc = NULL;
|
||||
pwlArc = NULL;
|
||||
type = 0;
|
||||
setside( side );
|
||||
nuid = _nuid;
|
||||
}
|
||||
|
||||
#endif /* __gluarc_h_ */
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arcsorter.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluarcsorter_c_
|
||||
#define __gluarcsorter_c_
|
||||
|
||||
#include "glimports.h"
|
||||
#include "arc.h"
|
||||
#include "arcsorter.h"
|
||||
#include "subdivider.h"
|
||||
|
||||
ArcSorter::ArcSorter(Subdivider &s) : Sorter( sizeof( Arc ** ) ), subdivider(s)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
ArcSorter::qscmp( char *, char * )
|
||||
{
|
||||
_glu_dprintf( "ArcSorter::qscmp: pure virtual called\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ArcSorter::qsort( Arc **a, int n )
|
||||
{
|
||||
Sorter::qsort( (void *) a, n );
|
||||
}
|
||||
|
||||
void
|
||||
ArcSorter::qsexc( char *i, char *j )// i<-j, j<-i
|
||||
{
|
||||
Arc **jarc1 = (Arc **) i;
|
||||
Arc **jarc2 = (Arc **) j;
|
||||
Arc *tmp = *jarc1;
|
||||
*jarc1 = *jarc2;
|
||||
*jarc2 = tmp;
|
||||
}
|
||||
|
||||
void
|
||||
ArcSorter::qstexc( char *i, char *j, char *k )// i<-k, k<-j, j<-i
|
||||
{
|
||||
Arc **jarc1 = (Arc **) i;
|
||||
Arc **jarc2 = (Arc **) j;
|
||||
Arc **jarc3 = (Arc **) k;
|
||||
Arc *tmp = *jarc1;
|
||||
*jarc1 = *jarc3;
|
||||
*jarc3 = *jarc2;
|
||||
*jarc2 = tmp;
|
||||
}
|
||||
|
||||
|
||||
ArcSdirSorter::ArcSdirSorter( Subdivider &s ) : ArcSorter(s)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
ArcSdirSorter::qscmp( char *i, char *j )
|
||||
{
|
||||
Arc *jarc1 = *(Arc **) i;
|
||||
Arc *jarc2 = *(Arc **) j;
|
||||
|
||||
int v1 = (jarc1->getitail() ? 0 : (jarc1->pwlArc->npts - 1));
|
||||
int v2 = (jarc2->getitail() ? 0 : (jarc2->pwlArc->npts - 1));
|
||||
|
||||
REAL diff = jarc1->pwlArc->pts[v1].param[1] -
|
||||
jarc2->pwlArc->pts[v2].param[1];
|
||||
|
||||
if( diff < 0.0)
|
||||
return -1;
|
||||
else if( diff > 0.0)
|
||||
return 1;
|
||||
else {
|
||||
if( v1 == 0 ) {
|
||||
if( jarc2->tail()[0] < jarc1->tail()[0] ) {
|
||||
return subdivider.ccwTurn_sl( jarc2, jarc1 ) ? 1 : -1;
|
||||
} else {
|
||||
return subdivider.ccwTurn_sr( jarc2, jarc1 ) ? -1 : 1;
|
||||
}
|
||||
} else {
|
||||
if( jarc2->head()[0] < jarc1->head()[0] ) {
|
||||
return subdivider.ccwTurn_sl( jarc1, jarc2 ) ? -1 : 1;
|
||||
} else {
|
||||
return subdivider.ccwTurn_sr( jarc1, jarc2 ) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArcTdirSorter::ArcTdirSorter( Subdivider &s ) : ArcSorter(s)
|
||||
{
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* ArcTdirSorter::qscmp -
|
||||
* compare two axis monotone arcs that are incident
|
||||
* to the line T == compare_value. Determine which of the
|
||||
* two intersects that line with a LESSER S value. If
|
||||
* jarc1 does, return 1. If jarc2 does, return -1.
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
ArcTdirSorter::qscmp( char *i, char *j )
|
||||
{
|
||||
Arc *jarc1 = *(Arc **) i;
|
||||
Arc *jarc2 = *(Arc **) j;
|
||||
|
||||
int v1 = (jarc1->getitail() ? 0 : (jarc1->pwlArc->npts - 1));
|
||||
int v2 = (jarc2->getitail() ? 0 : (jarc2->pwlArc->npts - 1));
|
||||
|
||||
REAL diff = jarc1->pwlArc->pts[v1].param[0] -
|
||||
jarc2->pwlArc->pts[v2].param[0];
|
||||
|
||||
if( diff < 0.0)
|
||||
return 1;
|
||||
else if( diff > 0.0)
|
||||
return -1;
|
||||
else {
|
||||
if( v1 == 0 ) {
|
||||
if (jarc2->tail()[1] < jarc1->tail()[1]) {
|
||||
return subdivider.ccwTurn_tl( jarc2, jarc1 ) ? 1 : -1;
|
||||
} else {
|
||||
return subdivider.ccwTurn_tr( jarc2, jarc1 ) ? -1 : 1;
|
||||
}
|
||||
} else {
|
||||
if( jarc2->head()[1] < jarc1->head()[1] ) {
|
||||
return subdivider.ccwTurn_tl( jarc1, jarc2 ) ? -1 : 1;
|
||||
} else {
|
||||
return subdivider.ccwTurn_tr( jarc1, jarc2 ) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* __gluarcsorter_c_ */
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arcsorter.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluarcsorter_h_
|
||||
#define __gluarcsorter_h_
|
||||
|
||||
#include "sorter.h"
|
||||
|
||||
class Arc;
|
||||
class Subdivider;
|
||||
|
||||
class ArcSorter : private Sorter {
|
||||
public:
|
||||
ArcSorter(Subdivider &);
|
||||
void qsort( Arc **a, int n );
|
||||
protected:
|
||||
virtual int qscmp( char *, char * );
|
||||
Subdivider& subdivider;
|
||||
private:
|
||||
void qsexc( char *i, char *j ); // i<-j, j<-i
|
||||
void qstexc( char *i, char *j, char *k ); // i<-k, k<-j, j<-i
|
||||
};
|
||||
|
||||
|
||||
class ArcSdirSorter : public ArcSorter {
|
||||
public:
|
||||
ArcSdirSorter( Subdivider & );
|
||||
private:
|
||||
int qscmp( char *, char * );
|
||||
};
|
||||
|
||||
|
||||
class ArcTdirSorter : public ArcSorter {
|
||||
public:
|
||||
ArcTdirSorter( Subdivider & );
|
||||
private:
|
||||
int qscmp( char *, char * );
|
||||
};
|
||||
|
||||
#endif /* __gluarcsorter_h_ */
|
||||
|
|
@ -1,611 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arctessellator.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "arctess.h"
|
||||
#include "bufpool.h"
|
||||
#include "simplemath.h"
|
||||
#include "bezierarc.h"
|
||||
#include "trimvertex.h"
|
||||
#include "trimvertpool.h"
|
||||
|
||||
#define NOELIMINATION
|
||||
|
||||
#define steps_function(large, small, rate) (max(1, 1+ (int) ((large-small)/rate)));
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* ArcTessellator - construct an ArcTessellator
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
ArcTessellator::ArcTessellator( TrimVertexPool& t, Pool& p )
|
||||
: pwlarcpool(p), trimvertexpool(t)
|
||||
{
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* ~ArcTessellator - destroy an ArcTessellator
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
ArcTessellator::~ArcTessellator( void )
|
||||
{
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* bezier - construct a bezier arc and attach it to an Arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::bezier( Arc *arc, REAL s1, REAL s2, REAL t1, REAL t2 )
|
||||
{
|
||||
assert( arc != 0 );
|
||||
assert( ! arc->isTessellated() );
|
||||
|
||||
#ifndef NDEBUG
|
||||
switch( arc->getside() ) {
|
||||
case arc_left:
|
||||
assert( s1 == s2 );
|
||||
assert( t2 < t1 );
|
||||
break;
|
||||
case arc_right:
|
||||
assert( s1 == s2 );
|
||||
assert( t1 < t2 );
|
||||
break;
|
||||
case arc_top:
|
||||
assert( t1 == t2 );
|
||||
assert( s2 < s1 );
|
||||
break;
|
||||
case arc_bottom:
|
||||
assert( t1 == t2 );
|
||||
assert( s1 < s2 );
|
||||
break;
|
||||
case arc_none:
|
||||
(void) abort();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
TrimVertex *p = trimvertexpool.get(2);
|
||||
arc->pwlArc = new(pwlarcpool) PwlArc( 2, p );
|
||||
p[0].param[0] = s1;
|
||||
p[0].param[1] = t1;
|
||||
p[1].param[0] = s2;
|
||||
p[1].param[1] = t2;
|
||||
assert( (s1 == s2) || (t1 == t2) );
|
||||
arc->setbezier();
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* pwl_left - construct a left boundary pwl arc and attach it to an arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::pwl_left( Arc *arc, REAL s, REAL t1, REAL t2, REAL rate )
|
||||
{
|
||||
assert( t2 < t1 );
|
||||
|
||||
/* if(rate <= 0.06) rate = 0.06;*/
|
||||
/* int nsteps = 1 + (int) ((t1 - t2) / rate ); */
|
||||
int nsteps = steps_function(t1, t2, rate);
|
||||
|
||||
|
||||
REAL stepsize = (t1 - t2) / (REAL) nsteps;
|
||||
|
||||
TrimVertex *newvert = trimvertexpool.get( nsteps+1 );
|
||||
int i;
|
||||
for( i = nsteps; i > 0; i-- ) {
|
||||
newvert[i].param[0] = s;
|
||||
newvert[i].param[1] = t2;
|
||||
t2 += stepsize;
|
||||
}
|
||||
newvert[i].param[0] = s;
|
||||
newvert[i].param[1] = t1;
|
||||
|
||||
arc->makeSide( new(pwlarcpool) PwlArc( nsteps+1, newvert ), arc_left );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* pwl_right - construct a right boundary pwl arc and attach it to an arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::pwl_right( Arc *arc, REAL s, REAL t1, REAL t2, REAL rate )
|
||||
{
|
||||
assert( t1 < t2 );
|
||||
|
||||
/* if(rate <= 0.06) rate = 0.06;*/
|
||||
|
||||
/* int nsteps = 1 + (int) ((t2 - t1) / rate ); */
|
||||
int nsteps = steps_function(t2,t1,rate);
|
||||
REAL stepsize = (t2 - t1) / (REAL) nsteps;
|
||||
|
||||
TrimVertex *newvert = trimvertexpool.get( nsteps+1 );
|
||||
int i;
|
||||
for( i = 0; i < nsteps; i++ ) {
|
||||
newvert[i].param[0] = s;
|
||||
newvert[i].param[1] = t1;
|
||||
t1 += stepsize;
|
||||
}
|
||||
newvert[i].param[0] = s;
|
||||
newvert[i].param[1] = t2;
|
||||
|
||||
arc->makeSide( new(pwlarcpool) PwlArc( nsteps+1, newvert ), arc_right );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* pwl_top - construct a top boundary pwl arc and attach it to an arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::pwl_top( Arc *arc, REAL t, REAL s1, REAL s2, REAL rate )
|
||||
{
|
||||
assert( s2 < s1 );
|
||||
|
||||
/* if(rate <= 0.06) rate = 0.06;*/
|
||||
|
||||
/* int nsteps = 1 + (int) ((s1 - s2) / rate ); */
|
||||
int nsteps = steps_function(s1,s2,rate);
|
||||
REAL stepsize = (s1 - s2) / (REAL) nsteps;
|
||||
|
||||
TrimVertex *newvert = trimvertexpool.get( nsteps+1 );
|
||||
int i;
|
||||
for( i = nsteps; i > 0; i-- ) {
|
||||
newvert[i].param[0] = s2;
|
||||
newvert[i].param[1] = t;
|
||||
s2 += stepsize;
|
||||
}
|
||||
newvert[i].param[0] = s1;
|
||||
newvert[i].param[1] = t;
|
||||
|
||||
arc->makeSide( new(pwlarcpool) PwlArc( nsteps+1, newvert ), arc_top );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* pwl_bottom - construct a bottom boundary pwl arc and attach it to an arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::pwl_bottom( Arc *arc, REAL t, REAL s1, REAL s2, REAL rate )
|
||||
{
|
||||
assert( s1 < s2 );
|
||||
|
||||
/* if(rate <= 0.06) rate = 0.06;*/
|
||||
|
||||
/* int nsteps = 1 + (int) ((s2 - s1) / rate ); */
|
||||
int nsteps = steps_function(s2,s1,rate);
|
||||
REAL stepsize = (s2 - s1) / (REAL) nsteps;
|
||||
|
||||
TrimVertex *newvert = trimvertexpool.get( nsteps+1 );
|
||||
int i;
|
||||
for( i = 0; i < nsteps; i++ ) {
|
||||
newvert[i].param[0] = s1;
|
||||
newvert[i].param[1] = t;
|
||||
s1 += stepsize;
|
||||
}
|
||||
newvert[i].param[0] = s2;
|
||||
newvert[i].param[1] = t;
|
||||
|
||||
arc->makeSide( new(pwlarcpool) PwlArc( nsteps+1, newvert ), arc_bottom );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* pwl - construct a pwl arc and attach it to an arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::pwl( Arc *arc, REAL s1, REAL s2, REAL t1, REAL t2, REAL rate )
|
||||
{
|
||||
|
||||
/* if(rate <= 0.06) rate = 0.06;*/
|
||||
|
||||
int snsteps = 1 + (int) (glu_abs(s2 - s1) / rate );
|
||||
int tnsteps = 1 + (int) (glu_abs(t2 - t1) / rate );
|
||||
int nsteps = max(1,max( snsteps, tnsteps ));
|
||||
|
||||
REAL sstepsize = (s2 - s1) / (REAL) nsteps;
|
||||
REAL tstepsize = (t2 - t1) / (REAL) nsteps;
|
||||
TrimVertex *newvert = trimvertexpool.get( nsteps+1 );
|
||||
long i;
|
||||
for( i = 0; i < nsteps; i++ ) {
|
||||
newvert[i].param[0] = s1;
|
||||
newvert[i].param[1] = t1;
|
||||
s1 += sstepsize;
|
||||
t1 += tstepsize;
|
||||
}
|
||||
newvert[i].param[0] = s2;
|
||||
newvert[i].param[1] = t2;
|
||||
|
||||
/* arc->makeSide( new(pwlarcpool) PwlArc( nsteps+1, newvert ), arc_bottom ); */
|
||||
arc->pwlArc = new(pwlarcpool) PwlArc( nsteps+1, newvert );
|
||||
|
||||
arc->clearbezier();
|
||||
arc->clearside( );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* tessellateLinear - constuct a linear pwl arc and attach it to an Arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::tessellateLinear( Arc *arc, REAL geo_stepsize, REAL arc_stepsize, int isrational )
|
||||
{
|
||||
assert( arc->pwlArc == NULL );
|
||||
REAL s1, s2, t1, t2;
|
||||
|
||||
//we don't need to scale by arc_stepsize if the trim curve
|
||||
//is piecewise linear. Reason: In pwl_right, pwl_left, pwl_top, pwl_left,
|
||||
//and pwl, the nsteps is computed by deltaU (or V) /stepsize.
|
||||
//The quantity deltaU/arc_stepsize doesn't have any meaning. And
|
||||
//it causes problems: see bug 517641
|
||||
REAL stepsize = geo_stepsize; /* * arc_stepsize*/;
|
||||
|
||||
BezierArc *b = arc->bezierArc;
|
||||
|
||||
if( isrational ) {
|
||||
s1 = b->cpts[0] / b->cpts[2];
|
||||
t1 = b->cpts[1] / b->cpts[2];
|
||||
s2 = b->cpts[b->stride+0] / b->cpts[b->stride+2];
|
||||
t2 = b->cpts[b->stride+1] / b->cpts[b->stride+2];
|
||||
} else {
|
||||
s1 = b->cpts[0];
|
||||
t1 = b->cpts[1];
|
||||
s2 = b->cpts[b->stride+0];
|
||||
t2 = b->cpts[b->stride+1];
|
||||
}
|
||||
if( s1 == s2 )
|
||||
if( t1 < t2 )
|
||||
pwl_right( arc, s1, t1, t2, stepsize );
|
||||
else
|
||||
pwl_left( arc, s1, t1, t2, stepsize );
|
||||
else if( t1 == t2 )
|
||||
if( s1 < s2 )
|
||||
pwl_bottom( arc, t1, s1, s2, stepsize );
|
||||
else
|
||||
pwl_top( arc, t1, s1, s2, stepsize );
|
||||
else
|
||||
pwl( arc, s1, s2, t1, t2, stepsize );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* tessellateNonlinear - constuct a nonlinear pwl arc and attach it to an Arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::tessellateNonlinear( Arc *arc, REAL geo_stepsize, REAL arc_stepsize, int isrational )
|
||||
{
|
||||
assert( arc->pwlArc == NULL );
|
||||
|
||||
REAL stepsize = geo_stepsize * arc_stepsize;
|
||||
|
||||
BezierArc *bezierArc = arc->bezierArc;
|
||||
|
||||
REAL size; //bounding box size of the curve in UV
|
||||
{
|
||||
int i,j;
|
||||
REAL min_u, min_v, max_u,max_v;
|
||||
min_u = max_u = bezierArc->cpts[0];
|
||||
min_v = max_v = bezierArc->cpts[1];
|
||||
for(i=1, j=bezierArc->stride; i<bezierArc->order; i++, j+= bezierArc->stride)
|
||||
{
|
||||
if(bezierArc->cpts[j] < min_u)
|
||||
min_u = bezierArc->cpts[j];
|
||||
if(bezierArc->cpts[j] > max_u)
|
||||
max_u = bezierArc->cpts[j];
|
||||
if(bezierArc->cpts[j+1] < min_v)
|
||||
min_v = bezierArc->cpts[j+1];
|
||||
if(bezierArc->cpts[j+1] > max_v)
|
||||
max_v = bezierArc->cpts[j+1];
|
||||
}
|
||||
|
||||
size = max_u - min_u;
|
||||
if(size < max_v - min_v)
|
||||
size = max_v - min_v;
|
||||
}
|
||||
|
||||
/*int nsteps = 1 + (int) (1.0/stepsize);*/
|
||||
|
||||
int nsteps = (int) (size/stepsize);
|
||||
if(nsteps <=0)
|
||||
nsteps=1;
|
||||
|
||||
TrimVertex *vert = trimvertexpool.get( nsteps+1 );
|
||||
REAL dp = 1.0/nsteps;
|
||||
|
||||
|
||||
arc->pwlArc = new(pwlarcpool) PwlArc();
|
||||
arc->pwlArc->pts = vert;
|
||||
|
||||
if( isrational ) {
|
||||
REAL pow_u[MAXORDER], pow_v[MAXORDER], pow_w[MAXORDER];
|
||||
trim_power_coeffs( bezierArc, pow_u, 0 );
|
||||
trim_power_coeffs( bezierArc, pow_v, 1 );
|
||||
trim_power_coeffs( bezierArc, pow_w, 2 );
|
||||
|
||||
/* compute first point exactly */
|
||||
REAL *b = bezierArc->cpts;
|
||||
vert->param[0] = b[0]/b[2];
|
||||
vert->param[1] = b[1]/b[2];
|
||||
|
||||
/* strength reduction on p = dp * step would introduce error */
|
||||
int step;
|
||||
#ifndef NOELIMINATION
|
||||
int ocanremove = 0;
|
||||
#endif
|
||||
register long order = bezierArc->order;
|
||||
for( step=1, ++vert; step<nsteps; step++, vert++ ) {
|
||||
register REAL p = dp * step;
|
||||
register REAL u = pow_u[0];
|
||||
register REAL v = pow_v[0];
|
||||
register REAL w = pow_w[0];
|
||||
for( register int i = 1; i < order; i++ ) {
|
||||
u = u * p + pow_u[i];
|
||||
v = v * p + pow_v[i];
|
||||
w = w * p + pow_w[i];
|
||||
}
|
||||
vert->param[0] = u/w;
|
||||
vert->param[1] = v/w;
|
||||
#ifndef NOELIMINATION
|
||||
REAL ds = glu_abs(vert[0].param[0] - vert[-1].param[0]);
|
||||
REAL dt = glu_abs(vert[0].param[1] - vert[-1].param[1]);
|
||||
int canremove = (ds<geo_stepsize && dt<geo_stepsize) ? 1 : 0;
|
||||
REAL ods=0.0, odt=0.0;
|
||||
|
||||
if( ocanremove && canremove ) {
|
||||
REAL nds = ds + ods;
|
||||
REAL ndt = dt + odt;
|
||||
if( nds<geo_stepsize && ndt<geo_stepsize ) {
|
||||
// remove previous point
|
||||
--vert;
|
||||
vert[0].param[0] = vert[1].param[0];
|
||||
vert[0].param[1] = vert[1].param[1];
|
||||
ods = nds;
|
||||
odt = ndt;
|
||||
ocanremove = 1;
|
||||
} else {
|
||||
ocanremove = canremove;
|
||||
ods = ds;
|
||||
odt = dt;
|
||||
}
|
||||
} else {
|
||||
ocanremove = canremove;
|
||||
ods = ds;
|
||||
odt = dt;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* compute last point exactly */
|
||||
b += (order - 1) * bezierArc->stride;
|
||||
vert->param[0] = b[0]/b[2];
|
||||
vert->param[1] = b[1]/b[2];
|
||||
|
||||
} else {
|
||||
REAL pow_u[MAXORDER], pow_v[MAXORDER];
|
||||
trim_power_coeffs( bezierArc, pow_u, 0 );
|
||||
trim_power_coeffs( bezierArc, pow_v, 1 );
|
||||
|
||||
/* compute first point exactly */
|
||||
REAL *b = bezierArc->cpts;
|
||||
vert->param[0] = b[0];
|
||||
vert->param[1] = b[1];
|
||||
|
||||
/* strength reduction on p = dp * step would introduce error */
|
||||
int step;
|
||||
#ifndef NOELIMINATION
|
||||
int ocanremove = 0;
|
||||
#endif
|
||||
register long order = bezierArc->order;
|
||||
for( step=1, ++vert; step<nsteps; step++, vert++ ) {
|
||||
register REAL p = dp * step;
|
||||
register REAL u = pow_u[0];
|
||||
register REAL v = pow_v[0];
|
||||
for( register int i = 1; i < bezierArc->order; i++ ) {
|
||||
u = u * p + pow_u[i];
|
||||
v = v * p + pow_v[i];
|
||||
}
|
||||
vert->param[0] = u;
|
||||
vert->param[1] = v;
|
||||
#ifndef NOELIMINATION
|
||||
REAL ds = glu_abs(vert[0].param[0] - vert[-1].param[0]);
|
||||
REAL dt = glu_abs(vert[0].param[1] - vert[-1].param[1]);
|
||||
int canremove = (ds<geo_stepsize && dt<geo_stepsize) ? 1 : 0;
|
||||
REAL ods=0.0, odt=0.0;
|
||||
|
||||
if( ocanremove && canremove ) {
|
||||
REAL nds = ds + ods;
|
||||
REAL ndt = dt + odt;
|
||||
if( nds<geo_stepsize && ndt<geo_stepsize ) {
|
||||
// remove previous point
|
||||
--vert;
|
||||
vert[0].param[0] = vert[1].param[0];
|
||||
vert[0].param[1] = vert[1].param[1];
|
||||
ods = nds;
|
||||
odt = ndt;
|
||||
ocanremove = 1;
|
||||
} else {
|
||||
ocanremove = canremove;
|
||||
ods = ds;
|
||||
odt = dt;
|
||||
}
|
||||
} else {
|
||||
ocanremove = canremove;
|
||||
ods = ds;
|
||||
odt = dt;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* compute last point exactly */
|
||||
b += (order - 1) * bezierArc->stride;
|
||||
vert->param[0] = b[0];
|
||||
vert->param[1] = b[1];
|
||||
}
|
||||
arc->pwlArc->npts = vert - arc->pwlArc->pts + 1;
|
||||
/*
|
||||
for( TrimVertex *vt=pwlArc->pts; vt != vert-1; vt++ ) {
|
||||
if( tooclose( vt[0].param[0], vt[1].param[0] ) )
|
||||
vt[1].param[0] = vt[0].param[0];
|
||||
if( tooclose( vt[0].param[1], vt[1].param[1] ) )
|
||||
vt[1].param[1] = vt[0].param[1];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
const REAL ArcTessellator::gl_Bernstein[][MAXORDER][MAXORDER] = {
|
||||
{
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{-1, 1, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{1, -2, 1, 0, 0, 0, 0, 0 },
|
||||
{-2, 2, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{-1, 3, -3, 1, 0, 0, 0, 0 },
|
||||
{3, -6, 3, 0, 0, 0, 0, 0 },
|
||||
{-3, 3, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{1, -4, 6, -4, 1, 0, 0, 0 },
|
||||
{-4, 12, -12, 4, 0, 0, 0, 0 },
|
||||
{6, -12, 6, 0, 0, 0, 0, 0 },
|
||||
{-4, 4, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{-1, 5, -10, 10, -5, 1, 0, 0 },
|
||||
{5, -20, 30, -20, 5, 0, 0, 0 },
|
||||
{-10, 30, -30, 10, 0, 0, 0, 0 },
|
||||
{10, -20, 10, 0, 0, 0, 0, 0 },
|
||||
{-5, 5, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{1, -6, 15, -20, 15, -6, 1, 0 },
|
||||
{-6, 30, -60, 60, -30, 6, 0, 0 },
|
||||
{15, -60, 90, -60, 15, 0, 0, 0 },
|
||||
{-20, 60, -60, 20, 0, 0, 0, 0 },
|
||||
{15, -30, 15, 0, 0, 0, 0, 0 },
|
||||
{-6, 6, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{-1, 7, -21, 35, -35, 21, -7, 1 },
|
||||
{7, -42, 105, -140, 105, -42, 7, 0 },
|
||||
{-21, 105, -210, 210, -105, 21, 0, 0 },
|
||||
{35, -140, 210, -140, 35, 0, 0, 0 },
|
||||
{-35, 105, -105, 35, 0, 0, 0, 0 },
|
||||
{21, -42, 21, 0, 0, 0, 0, 0 },
|
||||
{-7, 7, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 }
|
||||
}};
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* trim_power_coeffs - compute power basis coefficients from bezier coeffients
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
ArcTessellator::trim_power_coeffs( BezierArc *bez_arc, REAL *p, int coord )
|
||||
{
|
||||
register int stride = bez_arc->stride;
|
||||
register int order = bez_arc->order;
|
||||
register REAL *base = bez_arc->cpts + coord;
|
||||
|
||||
REAL const (*mat)[MAXORDER][MAXORDER] = &gl_Bernstein[order-1];
|
||||
REAL const (*lrow)[MAXORDER] = &(*mat)[order];
|
||||
|
||||
/* WIN32 didn't like the following line within the for-loop */
|
||||
REAL const (*row)[MAXORDER] = &(*mat)[0];
|
||||
for( ; row != lrow; row++ ) {
|
||||
register REAL s = 0.0;
|
||||
register REAL *point = base;
|
||||
register REAL const *mlast = *row + order;
|
||||
for( REAL const *m = *row; m != mlast; m++, point += stride )
|
||||
s += *(m) * (*point);
|
||||
*(p++) = s;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arctess.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluarctess_h_
|
||||
#define __gluarctess_h_
|
||||
|
||||
#include "defines.h"
|
||||
#include "types.h"
|
||||
#include "arc.h"
|
||||
|
||||
struct BezierArc;
|
||||
class Pool;
|
||||
class TrimVertexPool;
|
||||
|
||||
class ArcTessellator {
|
||||
public:
|
||||
ArcTessellator( TrimVertexPool&, Pool& );
|
||||
~ArcTessellator( void );
|
||||
void bezier( Arc_ptr, REAL, REAL, REAL, REAL );
|
||||
void pwl( Arc_ptr, REAL, REAL, REAL, REAL, REAL );
|
||||
void pwl_left( Arc_ptr, REAL, REAL, REAL, REAL );
|
||||
void pwl_right( Arc_ptr, REAL, REAL, REAL, REAL );
|
||||
void pwl_top( Arc_ptr, REAL, REAL, REAL, REAL );
|
||||
void pwl_bottom( Arc_ptr, REAL, REAL, REAL, REAL );
|
||||
void tessellateLinear( Arc_ptr, REAL, REAL, int );
|
||||
void tessellateNonlinear( Arc_ptr, REAL, REAL, int );
|
||||
private:
|
||||
static const REAL gl_Bernstein[][MAXORDER][MAXORDER];
|
||||
Pool& pwlarcpool;
|
||||
TrimVertexPool& trimvertexpool;
|
||||
static void trim_power_coeffs( BezierArc *, REAL[MAXORDER], int );
|
||||
};
|
||||
|
||||
#endif /* __gluarctess_h_ */
|
||||
|
|
@ -1,588 +0,0 @@
|
|||
/*
|
||||
** 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++
|
||||
*
|
||||
*/
|
||||
|
||||
/* 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"
|
||||
|
||||
#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( const 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);
|
||||
#endif
|
||||
}
|
||||
|
||||
//opt for a line with the same v.
|
||||
void
|
||||
Backend::tmeshvertNOGE_BV(TrimVertex *t)
|
||||
{
|
||||
#ifdef USE_OPTTT
|
||||
surfaceEvaluator.inDoEvalCoord2NOGE_BV( t->param[0], t->param[1], t->cache_point, t->cache_normal);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
Backend::preEvaluateBU(REAL u)
|
||||
{
|
||||
surfaceEvaluator.inPreEvaluateBU_intfac(u);
|
||||
}
|
||||
|
||||
void
|
||||
Backend::preEvaluateBV(REAL v)
|
||||
{
|
||||
surfaceEvaluator.inPreEvaluateBV_intfac(v);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* tmeshvert - evaluate a point on a triangle mesh
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::tmeshvert( TrimVertex *t )
|
||||
{
|
||||
|
||||
#ifndef NOWIREFRAME
|
||||
const long nuid = t->nuid;
|
||||
#endif
|
||||
const REAL u = t->param[0];
|
||||
const REAL v = t->param[1];
|
||||
|
||||
#ifndef NOWIREFRAME
|
||||
npts++;
|
||||
if( wireframetris ) {
|
||||
if( npts >= 3 ) {
|
||||
surfaceEvaluator.bgnclosedline();
|
||||
if( mesh[0][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( mesh[0][3], mesh[0][0], mesh[0][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
|
||||
if( mesh[1][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( mesh[1][3], mesh[1][0], mesh[1][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
|
||||
surfaceEvaluator.evalcoord2f( nuid, u, v );
|
||||
surfaceEvaluator.endclosedline();
|
||||
}
|
||||
mesh[meshindex][0] = u;
|
||||
mesh[meshindex][1] = v;
|
||||
mesh[meshindex][2] = 0;
|
||||
mesh[meshindex][3] = nuid;
|
||||
meshindex = (meshindex+1) % 2;
|
||||
} else {
|
||||
surfaceEvaluator.evalcoord2f( nuid, u, v );
|
||||
}
|
||||
#else
|
||||
|
||||
surfaceEvaluator.evalcoord2f( 0, u, v );
|
||||
//for uninitial memory read surfaceEvaluator.evalcoord2f( nuid, u, v );
|
||||
#endif
|
||||
}
|
||||
|
||||
//the same as tmeshvert(trimvertex), for efficiency purpose
|
||||
void
|
||||
Backend::tmeshvert( REAL u, REAL v )
|
||||
{
|
||||
#ifndef NOWIREFRAME
|
||||
const long nuid = 0;
|
||||
|
||||
npts++;
|
||||
if( wireframetris ) {
|
||||
if( npts >= 3 ) {
|
||||
surfaceEvaluator.bgnclosedline();
|
||||
if( mesh[0][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( mesh[0][3], mesh[0][0], mesh[0][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
|
||||
if( mesh[1][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( mesh[1][3], mesh[1][0], mesh[1][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
|
||||
surfaceEvaluator.evalcoord2f( nuid, u, v );
|
||||
surfaceEvaluator.endclosedline();
|
||||
}
|
||||
mesh[meshindex][0] = u;
|
||||
mesh[meshindex][1] = v;
|
||||
mesh[meshindex][2] = 0;
|
||||
mesh[meshindex][3] = nuid;
|
||||
meshindex = (meshindex+1) % 2;
|
||||
} else {
|
||||
surfaceEvaluator.evalcoord2f( nuid, u, v );
|
||||
}
|
||||
#else
|
||||
|
||||
surfaceEvaluator.evalcoord2f( 0, u, v );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* tmeshvert - evaluate a grid point of a triangle mesh
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::tmeshvert( GridVertex *g )
|
||||
{
|
||||
const long u = g->gparam[0];
|
||||
const long v = g->gparam[1];
|
||||
|
||||
#ifndef NOWIREFRAME
|
||||
npts++;
|
||||
if( wireframetris ) {
|
||||
if( npts >= 3 ) {
|
||||
surfaceEvaluator.bgnclosedline();
|
||||
if( mesh[0][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( (long) mesh[0][3], mesh[0][0], mesh[0][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
|
||||
if( mesh[1][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( (long) mesh[1][3], mesh[1][0], mesh[1][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
|
||||
surfaceEvaluator.evalpoint2i( u, v );
|
||||
surfaceEvaluator.endclosedline();
|
||||
}
|
||||
mesh[meshindex][0] = u;
|
||||
mesh[meshindex][1] = v;
|
||||
mesh[meshindex][2] = 1;
|
||||
meshindex = (meshindex+1) % 2;
|
||||
} else {
|
||||
surfaceEvaluator.evalpoint2i( u, v );
|
||||
}
|
||||
#else
|
||||
surfaceEvaluator.evalpoint2i( u, v );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* swaptmesh - perform a swap of the triangle mesh pointers
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::swaptmesh( void )
|
||||
{
|
||||
#ifndef NOWIREFRAME
|
||||
if( wireframetris ) {
|
||||
meshindex = 1 - meshindex;
|
||||
} else {
|
||||
surfaceEvaluator.swaptmesh();
|
||||
}
|
||||
#else
|
||||
surfaceEvaluator.swaptmesh();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* endtmesh - postamble to triangle mesh
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::endtmesh( void )
|
||||
{
|
||||
#ifndef NOWIREFRAME
|
||||
if( ! wireframetris )
|
||||
surfaceEvaluator.endtmesh();
|
||||
#else
|
||||
surfaceEvaluator.endtmesh();
|
||||
/* surfaceEvaluator.polymode( N_MESHFILL );*/
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* bgnoutline - preamble to outlined rendering
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::bgnoutline( void )
|
||||
{
|
||||
surfaceEvaluator.bgnline();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* linevert - evaluate a point on an outlined contour
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::linevert( TrimVertex *t )
|
||||
{
|
||||
surfaceEvaluator.evalcoord2f( t->nuid, t->param[0], t->param[1] );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* linevert - evaluate a grid point of an outlined contour
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::linevert( GridVertex *g )
|
||||
{
|
||||
surfaceEvaluator.evalpoint2i( g->gparam[0], g->gparam[1] );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* endoutline - postamble to outlined rendering
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::endoutline( void )
|
||||
{
|
||||
surfaceEvaluator.endline();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* triangle - output a triangle
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::triangle( TrimVertex *a, TrimVertex *b, TrimVertex *c )
|
||||
{
|
||||
/* bgntmesh( "spittriangle" );*/
|
||||
bgntfan();
|
||||
tmeshvert( a );
|
||||
tmeshvert( b );
|
||||
tmeshvert( c );
|
||||
endtfan();
|
||||
/* endtmesh();*/
|
||||
}
|
||||
|
||||
void
|
||||
Backend::bgncurv( void )
|
||||
{
|
||||
curveEvaluator.bgnmap1f( 0 );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::segment( REAL ulo, REAL uhi )
|
||||
{
|
||||
curveEvaluator.domain1f( ulo, uhi );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::curvpts(
|
||||
long type, /* geometry, color, texture, normal */
|
||||
REAL *pts, /* control points */
|
||||
long stride, /* distance to next point */
|
||||
int order, /* parametric order */
|
||||
REAL ulo, /* lower parametric bound */
|
||||
REAL uhi ) /* upper parametric bound */
|
||||
|
||||
{
|
||||
curveEvaluator.map1f( type, ulo, uhi, stride, order, pts );
|
||||
curveEvaluator.enable( type );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::curvgrid( REAL u0, REAL u1, long nu )
|
||||
{
|
||||
curveEvaluator.mapgrid1f( nu, u0, u1 );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::curvmesh( long from, long n )
|
||||
{
|
||||
curveEvaluator.mapmesh1f( N_MESHFILL, from, from+n );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::curvpt(REAL u)
|
||||
{
|
||||
curveEvaluator.evalcoord1f( 0, u );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::bgnline( void )
|
||||
{
|
||||
curveEvaluator.bgnline();
|
||||
}
|
||||
|
||||
void
|
||||
Backend::endline( void )
|
||||
{
|
||||
curveEvaluator.endline();
|
||||
}
|
||||
|
||||
void
|
||||
Backend::endcurv( void )
|
||||
{
|
||||
curveEvaluator.endmap1f();
|
||||
}
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* backend.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glubackend_h_
|
||||
#define __glubackend_h_
|
||||
|
||||
#include "trimvertex.h"
|
||||
#include "gridvertex.h"
|
||||
#include "gridtrimvertex.h"
|
||||
|
||||
class BasicCurveEvaluator;
|
||||
class BasicSurfaceEvaluator;
|
||||
|
||||
class Backend {
|
||||
private:
|
||||
BasicCurveEvaluator& curveEvaluator;
|
||||
BasicSurfaceEvaluator& surfaceEvaluator;
|
||||
public:
|
||||
Backend( BasicCurveEvaluator &c, BasicSurfaceEvaluator& e )
|
||||
: curveEvaluator(c), surfaceEvaluator(e) {}
|
||||
|
||||
/* surface backend routines */
|
||||
void bgnsurf( int, int, long );
|
||||
void patch( REAL, REAL, REAL, REAL );
|
||||
void surfpts( long, REAL *, long, long, int, int,
|
||||
REAL, REAL, REAL, REAL );
|
||||
void surfbbox( long, REAL *, REAL * );
|
||||
void surfgrid( REAL, REAL, long, REAL, REAL, long );
|
||||
void surfmesh( long, long, long, long );
|
||||
void bgntmesh( const char * );
|
||||
void endtmesh( void );
|
||||
void swaptmesh( void );
|
||||
void tmeshvert( GridTrimVertex * );
|
||||
void tmeshvert( TrimVertex * );
|
||||
void tmeshvert( GridVertex * );
|
||||
void tmeshvert( REAL u, REAL v );
|
||||
void linevert( TrimVertex * );
|
||||
void linevert( GridVertex * );
|
||||
void bgnoutline( void );
|
||||
void endoutline( void );
|
||||
void endsurf( void );
|
||||
void triangle( TrimVertex*, TrimVertex*, TrimVertex* );
|
||||
|
||||
void bgntfan();
|
||||
void endtfan();
|
||||
void bgnqstrip();
|
||||
void endqstrip();
|
||||
void evalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
|
||||
int n_lower, REAL v_lower, REAL* lower_val
|
||||
);
|
||||
void evalVStrip(int n_left, REAL u_left, REAL* left_val,
|
||||
int n_right, REAL v_right, REAL* right_val
|
||||
);
|
||||
void tmeshvertNOGE(TrimVertex *t);
|
||||
void tmeshvertNOGE_BU(TrimVertex *t);
|
||||
void tmeshvertNOGE_BV(TrimVertex *t);
|
||||
void preEvaluateBU(REAL u);
|
||||
void preEvaluateBV(REAL v);
|
||||
|
||||
|
||||
/* curve backend routines */
|
||||
void bgncurv( void );
|
||||
void segment( REAL, REAL );
|
||||
void curvpts( long, REAL *, long, int, REAL, REAL );
|
||||
void curvgrid( REAL, REAL, long );
|
||||
void curvmesh( long, long );
|
||||
void curvpt( REAL );
|
||||
void bgnline( void );
|
||||
void endline( void );
|
||||
void endcurv( void );
|
||||
private:
|
||||
#ifndef NOWIREFRAME
|
||||
int wireframetris;
|
||||
int wireframequads;
|
||||
int npts;
|
||||
REAL mesh[3][4];
|
||||
int meshindex;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* __glubackend_h_ */
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* basiccrveval.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mystdio.h"
|
||||
#include "types.h"
|
||||
#include "basiccrveval.h"
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::domain1f( REAL, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "domain1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::range1f( long , REAL *, REAL * )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "range1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::enable( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "enable\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::disable( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "disable\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::bgnmap1f( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "bgnmap1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::map1f( long, REAL, REAL, long, long, REAL * )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "map1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::mapgrid1f( long, REAL, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "mapgrid1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::mapmesh1f( long, long, long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "mapmesh1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::evalcoord1f( long, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "evalcoord1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::endmap1f( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "endmap1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::bgnline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "bgnline\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::endline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "endline\n" );
|
||||
#endif
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* basiccurveeval.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glubasiccrveval_h_
|
||||
#define __glubasiccrveval_h_
|
||||
|
||||
#include "types.h"
|
||||
#include "displaymode.h"
|
||||
#include "cachingeval.h"
|
||||
|
||||
class BasicCurveEvaluator : public CachingEvaluator {
|
||||
public:
|
||||
virtual ~BasicCurveEvaluator() { /* silence warning*/ }
|
||||
virtual void domain1f( REAL, REAL );
|
||||
virtual void range1f( long, REAL *, REAL * );
|
||||
|
||||
virtual void enable( long );
|
||||
virtual void disable( long );
|
||||
virtual void bgnmap1f( long );
|
||||
virtual void map1f( long, REAL, REAL, long, long, REAL * );
|
||||
virtual void mapgrid1f( long, REAL, REAL );
|
||||
virtual void mapmesh1f( long, long, long );
|
||||
virtual void evalcoord1f( long, REAL );
|
||||
virtual void endmap1f( void );
|
||||
|
||||
virtual void bgnline( void );
|
||||
virtual void endline( void );
|
||||
};
|
||||
|
||||
#endif /* __glubasiccrveval_h_ */
|
||||
|
|
@ -1,232 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* basicsurfaceevaluator.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mystdio.h"
|
||||
#include "types.h"
|
||||
#include "basicsurfeval.h"
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
#pragma warning 726 10
|
||||
#endif
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::domain2f( REAL, REAL, REAL, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "domain2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::polymode( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "polymode\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::range2f( long type, REAL *from, REAL *to )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "range2f type %ld, from (%g,%g), to (%g,%g)\n",
|
||||
type, from[0], from[1], to[0], to[1] );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::enable( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "enable\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::disable( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "disable\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgnmap2f( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "bgnmap2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endmap2f( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "endmap2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::map2f( long, REAL, REAL, long, long,
|
||||
REAL, REAL, long, long,
|
||||
REAL * )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "map2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::mapgrid2f( long, REAL, REAL, long, REAL, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "mapgrid2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::mapmesh2f( long, long, long, long, long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "mapmesh2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::evalcoord2f( long, REAL, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "evalcoord2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::evalpoint2i( long, long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "evalpoint2i\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgnline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "bgnline\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "endline\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgnclosedline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "bgnclosedline\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endclosedline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "endclosedline\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgntfan( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "bgntfan\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endtfan( void )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgntmesh( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "bgntmesh\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::swaptmesh( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "swaptmesh\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endtmesh( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "endtmesh\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgnqstrip( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "bgnqstrip\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endqstrip( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "endqstrip\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* basicsurfeval.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glubasicsurfeval_h_
|
||||
#define __glubasicsurfeval_h_
|
||||
|
||||
#include "types.h"
|
||||
#include "displaymode.h"
|
||||
#include "cachingeval.h"
|
||||
|
||||
class BasicSurfaceEvaluator : public CachingEvaluator {
|
||||
public:
|
||||
virtual ~BasicSurfaceEvaluator() { /* silence warning*/ }
|
||||
virtual void range2f( long, REAL *, REAL * );
|
||||
virtual void domain2f( REAL, REAL, REAL, REAL );
|
||||
|
||||
virtual void enable( long );
|
||||
virtual void disable( long );
|
||||
virtual void bgnmap2f( long );
|
||||
virtual void map2f( long, REAL, REAL, long, long,
|
||||
REAL, REAL, long, long,
|
||||
REAL * );
|
||||
virtual void mapgrid2f( long, REAL, REAL, long, REAL, REAL );
|
||||
virtual void mapmesh2f( long, long, long, long, long );
|
||||
virtual void evalcoord2f( long, REAL, REAL );
|
||||
virtual void evalpoint2i( long, long );
|
||||
virtual void endmap2f( void );
|
||||
|
||||
virtual void polymode( long );
|
||||
virtual void bgnline( void );
|
||||
virtual void endline( void );
|
||||
virtual void bgnclosedline( void );
|
||||
virtual void endclosedline( void );
|
||||
virtual void bgntmesh( void );
|
||||
virtual void swaptmesh( void );
|
||||
virtual void endtmesh( void );
|
||||
virtual void bgnqstrip( void );
|
||||
virtual void endqstrip( void );
|
||||
|
||||
virtual void bgntfan( void );
|
||||
virtual void endtfan( void );
|
||||
|
||||
virtual void evalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
|
||||
int n_lower, REAL v_lower, REAL* lower_val
|
||||
) = 0;
|
||||
|
||||
virtual void evalVStrip(int n_left, REAL u_left, REAL* left_val,
|
||||
int n_right, REAL u_right, REAL* right_val
|
||||
) = 0;
|
||||
virtual void inDoEvalCoord2NOGE(REAL u, REAL v, REAL* ret_point, REAL* ret_normal) = 0;
|
||||
virtual void inDoEvalCoord2NOGE_BU(REAL u, REAL v, REAL* ret_point, REAL* ret_normal) = 0;
|
||||
virtual void inDoEvalCoord2NOGE_BV(REAL u, REAL v, REAL* ret_point, REAL* ret_normal) = 0;
|
||||
virtual void inPreEvaluateBV_intfac(REAL v ) = 0;
|
||||
virtual void inPreEvaluateBU_intfac(REAL u ) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* __glubasicsurfeval_h_ */
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* bezierarc.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glubezierarc_h
|
||||
#define __glubezierarc_h
|
||||
|
||||
#include "myassert.h"
|
||||
|
||||
class Mapdesc;
|
||||
|
||||
struct BezierArc : public PooledObj { /* a bezier arc */
|
||||
REAL * cpts; /* control points of arc */
|
||||
int order; /* order of arc */
|
||||
int stride; /* REAL distance between points */
|
||||
long type; /* curve type */
|
||||
Mapdesc * mapdesc;
|
||||
};
|
||||
|
||||
#endif /* __glubezierarc_h */
|
||||
|
|
@ -1,167 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* bin.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "bin.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Constructor and destructor
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
Bin::Bin()
|
||||
{
|
||||
head = NULL;
|
||||
current = NULL;
|
||||
}
|
||||
|
||||
Bin::~Bin()
|
||||
{
|
||||
assert( head == NULL);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* remove_this_arc - remove given Arc_ptr from bin
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Bin::remove_this_arc( Arc_ptr arc )
|
||||
{
|
||||
Arc_ptr *j;
|
||||
for( j = &(head); (*j != 0) && (*j != arc); j = &((*j)->link) );
|
||||
|
||||
if( *j != 0 ) {
|
||||
if( *j == current )
|
||||
current = (*j)->link;
|
||||
*j = (*j)->link;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* numarcs - count number of arcs in bin
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
Bin::numarcs()
|
||||
{
|
||||
long count = 0;
|
||||
for( Arc_ptr jarc = firstarc(); jarc; jarc = nextarc() )
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* adopt - place an orphaned arcs into their new parents bin
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Bin::adopt()
|
||||
{
|
||||
markall();
|
||||
|
||||
Arc_ptr orphan;
|
||||
while( (orphan = removearc()) != NULL ) {
|
||||
for( Arc_ptr parent = orphan->next; parent != orphan; parent = parent->next ) {
|
||||
if (! parent->ismarked() ) {
|
||||
orphan->link = parent->link;
|
||||
parent->link = orphan;
|
||||
orphan->clearmark();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* show - print out descriptions of the arcs in the bin
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Bin::show( const char *name )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "%s\n", name );
|
||||
for( Arc_ptr jarc = firstarc(); jarc; jarc = nextarc() )
|
||||
jarc->show( );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* markall - mark all arcs with an identifying tag
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Bin::markall()
|
||||
{
|
||||
for( Arc_ptr jarc=firstarc(); jarc; jarc=nextarc() )
|
||||
jarc->setmark();
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* listBezier - print out all arcs that are untessellated border arcs
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Bin::listBezier( void )
|
||||
{
|
||||
for( Arc_ptr jarc=firstarc(); jarc; jarc=nextarc() ) {
|
||||
if( jarc->isbezier( ) ) {
|
||||
assert( jarc->pwlArc->npts == 2 );
|
||||
#ifndef NDEBUG
|
||||
TrimVertex *pts = jarc->pwlArc->pts;
|
||||
REAL s1 = pts[0].param[0];
|
||||
REAL t1 = pts[0].param[1];
|
||||
REAL s2 = pts[1].param[0];
|
||||
REAL t2 = pts[1].param[1];
|
||||
_glu_dprintf( "arc (%g,%g) (%g,%g)\n", s1, t1, s2, t2 );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* bin.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glubin_h_
|
||||
#define __glubin_h_
|
||||
|
||||
#include "myassert.h"
|
||||
#include "arc.h"
|
||||
#include "defines.h"
|
||||
|
||||
class Bin
|
||||
{ /* a linked list of jordan arcs */
|
||||
private:
|
||||
Arc_ptr head;/*first arc on list */
|
||||
Arc_ptr current; /* current arc on list */
|
||||
public:
|
||||
Bin();
|
||||
~Bin();
|
||||
inline Arc_ptr firstarc( void );
|
||||
inline Arc_ptr nextarc( void );
|
||||
inline Arc_ptr removearc( void );
|
||||
inline int isnonempty( void ) { return (head ? 1 : 0); }
|
||||
inline void addarc( Arc_ptr );
|
||||
void remove_this_arc( Arc_ptr );
|
||||
int numarcs( void );
|
||||
void adopt( void );
|
||||
void markall( void );
|
||||
void show( const char * );
|
||||
void listBezier( void );
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Bin::addarc - add an Arc_ptr to head of linked list of Arc_ptr
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline void
|
||||
Bin::addarc( Arc_ptr jarc )
|
||||
{
|
||||
jarc->link = head;
|
||||
head = jarc;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Bin::removearc - remove first Arc_ptr from bin
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline Arc_ptr
|
||||
Bin::removearc( void )
|
||||
{
|
||||
Arc_ptr jarc = head;
|
||||
|
||||
if( jarc ) head = jarc->link;
|
||||
return jarc;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* BinIter::nextarc - return current arc in bin and advance pointer to next arc
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline Arc_ptr
|
||||
Bin::nextarc( void )
|
||||
{
|
||||
Arc_ptr jarc = current;
|
||||
|
||||
#ifdef DEBUG
|
||||
assert( jarc->check() != 0 );
|
||||
#endif
|
||||
|
||||
if( jarc ) current = jarc->link;
|
||||
return jarc;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* BinIter::firstarc - set current arc to first arc of bin advance to next arc
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline Arc_ptr
|
||||
Bin::firstarc( void )
|
||||
{
|
||||
current = head;
|
||||
return nextarc( );
|
||||
}
|
||||
|
||||
#endif /* __glubin_h_ */
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* bufpool.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "bufpool.h"
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Pool - allocate a new pool of buffers
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
Pool::Pool( int _buffersize, int initpoolsize, const char *n )
|
||||
{
|
||||
if((unsigned)_buffersize < sizeof(Buffer))
|
||||
buffersize = sizeof(Buffer);
|
||||
else
|
||||
buffersize = _buffersize;
|
||||
initsize = initpoolsize * buffersize;
|
||||
nextsize = initsize;
|
||||
name = n;
|
||||
magic = is_allocated;
|
||||
nextblock = 0;
|
||||
curblock = 0;
|
||||
freelist = 0;
|
||||
nextfree = 0;
|
||||
for (int i = 0; i < NBLOCKS; i++) {
|
||||
blocklist[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* ~Pool - free a pool of buffers and the pool itself
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Pool::~Pool( void )
|
||||
{
|
||||
assert( (this != 0) && (magic == is_allocated) );
|
||||
|
||||
while( nextblock ) {
|
||||
delete [] blocklist[--nextblock];
|
||||
blocklist[nextblock] = 0;
|
||||
}
|
||||
magic = is_free;
|
||||
}
|
||||
|
||||
|
||||
void Pool::grow( void )
|
||||
{
|
||||
assert( (this != 0) && (magic == is_allocated) );
|
||||
curblock = new char[nextsize];
|
||||
blocklist[nextblock++] = curblock;
|
||||
nextfree = nextsize;
|
||||
nextsize *= 2;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Pool::clear - free buffers associated with pool but keep pool
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Pool::clear( void )
|
||||
{
|
||||
assert( (this != 0) && (magic == is_allocated) );
|
||||
|
||||
while( nextblock ) {
|
||||
delete [] blocklist[--nextblock];
|
||||
blocklist[nextblock] = 0;
|
||||
}
|
||||
curblock = 0;
|
||||
freelist = 0;
|
||||
nextfree = 0;
|
||||
if( nextsize > initsize )
|
||||
nextsize /= 2;
|
||||
}
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* bufpool.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glubufpool_h_
|
||||
#define __glubufpool_h_
|
||||
|
||||
#include "gluos.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdlib.h"
|
||||
|
||||
#define NBLOCKS 32
|
||||
|
||||
class Buffer {
|
||||
friend class Pool;
|
||||
Buffer * next; /* next buffer on free list */
|
||||
};
|
||||
|
||||
class Pool {
|
||||
public:
|
||||
Pool( int, int, const char * );
|
||||
~Pool( void );
|
||||
inline void* new_buffer( void );
|
||||
inline void free_buffer( void * );
|
||||
void clear( void );
|
||||
|
||||
private:
|
||||
void grow( void );
|
||||
|
||||
protected:
|
||||
Buffer *freelist; /* linked list of free buffers */
|
||||
char *blocklist[NBLOCKS]; /* blocks of malloced memory */
|
||||
int nextblock; /* next free block index */
|
||||
char *curblock; /* last malloced block */
|
||||
int buffersize; /* bytes per buffer */
|
||||
int nextsize; /* size of next block of memory */
|
||||
int nextfree; /* byte offset past next free buffer */
|
||||
int initsize;
|
||||
enum Magic { is_allocated = 0xf3a1, is_free = 0xf1a2 };
|
||||
const char *name; /* name of the pool */
|
||||
Magic magic; /* marker for valid pool */
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Pool::free_buffer - return a buffer to a pool
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline void
|
||||
Pool::free_buffer( void *b )
|
||||
{
|
||||
assert( (this != 0) && (magic == is_allocated) );
|
||||
|
||||
/* add buffer to singly connected free list */
|
||||
|
||||
((Buffer *) b)->next = freelist;
|
||||
freelist = (Buffer *) b;
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Pool::new_buffer - allocate a buffer from a pool
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline void *
|
||||
Pool::new_buffer( void )
|
||||
{
|
||||
void *buffer;
|
||||
|
||||
assert( (this != 0) && (magic == is_allocated) );
|
||||
|
||||
/* find free buffer */
|
||||
|
||||
if( freelist ) {
|
||||
buffer = (void *) freelist;
|
||||
freelist = freelist->next;
|
||||
} else {
|
||||
if( ! nextfree )
|
||||
grow( );
|
||||
nextfree -= buffersize;;
|
||||
buffer = (void *) (curblock + nextfree);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
class PooledObj {
|
||||
public:
|
||||
inline void * operator new( size_t, Pool & );
|
||||
inline void * operator new( size_t, void *);
|
||||
inline void * operator new( size_t s)
|
||||
{ return ::new char[s]; }
|
||||
inline void operator delete( void * ) { assert( 0 ); }
|
||||
inline void operator delete( void *, Pool & ) { assert( 0 ); }
|
||||
inline void deleteMe( Pool & );
|
||||
};
|
||||
|
||||
inline void *
|
||||
PooledObj::operator new( size_t, Pool& pool )
|
||||
{
|
||||
return pool.new_buffer();
|
||||
}
|
||||
|
||||
inline void
|
||||
PooledObj::deleteMe( Pool& pool )
|
||||
{
|
||||
pool.free_buffer( (void *) this );
|
||||
}
|
||||
|
||||
#endif /* __glubufpool_h_ */
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* cachingeval.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cachingeval.h"
|
||||
|
||||
int
|
||||
CachingEvaluator::canRecord( void )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
CachingEvaluator::canPlayAndRecord( void )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
CachingEvaluator::createHandle( int )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
CachingEvaluator::beginOutput( ServiceMode, int )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CachingEvaluator::endOutput( void )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CachingEvaluator::discardRecording( int )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CachingEvaluator::playRecording( int )
|
||||
{
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* cachingeval.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glucachingval_h_
|
||||
#define __glucachingval_h_
|
||||
|
||||
class CachingEvaluator {
|
||||
public:
|
||||
virtual ~CachingEvaluator() { /* silence warning*/ }
|
||||
enum ServiceMode { play, record, playAndRecord };
|
||||
virtual int canRecord( void );
|
||||
virtual int canPlayAndRecord( void );
|
||||
virtual int createHandle( int handle );
|
||||
virtual void beginOutput( ServiceMode, int handle );
|
||||
virtual void endOutput( void );
|
||||
virtual void discardRecording( int handle );
|
||||
virtual void playRecording( int handle );
|
||||
};
|
||||
#endif /* __glucachingval_h_ */
|
||||
|
|
@ -1,565 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ccw.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "subdivider.h"
|
||||
#include "types.h"
|
||||
#include "arc.h"
|
||||
#include "trimvertex.h"
|
||||
#include "simplemath.h"
|
||||
|
||||
inline int
|
||||
Subdivider::bbox( TrimVertex *a, TrimVertex *b, TrimVertex *c, int p )
|
||||
{
|
||||
return bbox( a->param[p], b->param[p], c->param[p],
|
||||
a->param[1-p], b->param[1-p], c->param[1-p] );
|
||||
}
|
||||
|
||||
int
|
||||
Subdivider::ccwTurn_sr( Arc_ptr j1, Arc_ptr j2 ) // dir = 1
|
||||
{
|
||||
register TrimVertex *v1 = &j1->pwlArc->pts[j1->pwlArc->npts-1];
|
||||
register TrimVertex *v1last = &j1->pwlArc->pts[0];
|
||||
register TrimVertex *v2 = &j2->pwlArc->pts[0];
|
||||
register TrimVertex *v2last = &j2->pwlArc->pts[j2->pwlArc->npts-1];
|
||||
register TrimVertex *v1next = v1-1;
|
||||
register TrimVertex *v2next = v2+1;
|
||||
int sgn;
|
||||
|
||||
assert( v1 != v1last );
|
||||
assert( v2 != v2last );
|
||||
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "arc_ccw_turn, p = %d\n", 0 );
|
||||
#endif
|
||||
|
||||
// the arcs lie on the line (0 == v1->param[0])
|
||||
if( v1->param[0] == v1next->param[0] && v2->param[0] == v2next->param[0] )
|
||||
return 0;
|
||||
|
||||
if( v2next->param[0] < v2->param[0] || v1next->param[0] < v1->param[0] )
|
||||
::mylongjmp( jumpbuffer, 28 );
|
||||
|
||||
if( v1->param[1] < v2->param[1] )
|
||||
return 0;
|
||||
else if( v1->param[1] > v2->param[1] )
|
||||
return 1;
|
||||
|
||||
while( 1 ) {
|
||||
if( v1next->param[0] < v2next->param[0] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case a\n" );
|
||||
#endif
|
||||
assert( v1->param[0] <= v1next->param[0] );
|
||||
assert( v2->param[0] <= v1next->param[0] );
|
||||
switch( bbox( v2, v2next, v1next, 1 ) ) {
|
||||
case -1:
|
||||
return 0;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v2, v2next );
|
||||
if( sgn != -1 ) {
|
||||
return sgn;
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "decr\n" );
|
||||
#endif
|
||||
v1 = v1next--;
|
||||
if( v1 == v1last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 1;
|
||||
}
|
||||
} else if( v1next->param[0] > v2next->param[0] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case b\n" );
|
||||
#endif
|
||||
assert( v1->param[0] <= v2next->param[0] );
|
||||
assert( v2->param[0] <= v2next->param[0] );
|
||||
switch( bbox( v1, v1next, v2next, 1 ) ) {
|
||||
case -1:
|
||||
return 1;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v1, v2next );
|
||||
if( sgn != -1 ) {
|
||||
return sgn;
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "incr\n" );
|
||||
#endif
|
||||
v2 = v2next++;
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case ab\n" );
|
||||
#endif
|
||||
if( v1next->param[1] < v2next->param[1] )
|
||||
return 0;
|
||||
else if( v1next->param[1] > v2next->param[1] )
|
||||
return 1;
|
||||
else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "incr\n" );
|
||||
#endif
|
||||
v2 = v2next++;
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Subdivider::ccwTurn_sl( Arc_ptr j1, Arc_ptr j2 ) // dir = 0
|
||||
{
|
||||
register TrimVertex *v1 = &j1->pwlArc->pts[j1->pwlArc->npts-1];
|
||||
register TrimVertex *v1last = &j1->pwlArc->pts[0];
|
||||
register TrimVertex *v2 = &j2->pwlArc->pts[0];
|
||||
register TrimVertex *v2last = &j2->pwlArc->pts[j2->pwlArc->npts-1];
|
||||
register TrimVertex *v1next = v1-1;
|
||||
register TrimVertex *v2next = v2+1;
|
||||
int sgn;
|
||||
|
||||
assert( v1 != v1last );
|
||||
assert( v2 != v2last );
|
||||
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "arc_ccw_turn, p = %d\n", 0 );
|
||||
#endif
|
||||
|
||||
// the arcs lie on the line (0 == v1->param[0])
|
||||
if( v1->param[0] == v1next->param[0] && v2->param[0] == v2next->param[0] )
|
||||
return 0;
|
||||
|
||||
if( v2next->param[0] > v2->param[0] || v1next->param[0] > v1->param[0] )
|
||||
::mylongjmp( jumpbuffer, 28 );
|
||||
|
||||
if( v1->param[1] < v2->param[1] )
|
||||
return 1;
|
||||
else if( v1->param[1] > v2->param[1] )
|
||||
return 0;
|
||||
|
||||
while( 1 ) {
|
||||
if( v1next->param[0] > v2next->param[0] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case c\n" );
|
||||
#endif
|
||||
assert( v1->param[0] >= v1next->param[0] );
|
||||
assert( v2->param[0] >= v1next->param[0] );
|
||||
switch( bbox( v2next, v2, v1next, 1 ) ) {
|
||||
case -1:
|
||||
return 1;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v2, v2next );
|
||||
if( sgn != -1 )
|
||||
return sgn;
|
||||
else {
|
||||
v1 = v1next--;
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "decr\n" );
|
||||
#endif
|
||||
if( v1 == v1last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 0;
|
||||
}
|
||||
} else if( v1next->param[0] < v2next->param[0] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case d\n" );
|
||||
#endif
|
||||
assert( v1->param[0] >= v2next->param[0] );
|
||||
assert( v2->param[0] >= v2next->param[0] );
|
||||
switch( bbox( v1next, v1, v2next, 1 ) ) {
|
||||
case -1:
|
||||
return 0;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v1, v2next );
|
||||
if( sgn != -1 )
|
||||
return sgn;
|
||||
else {
|
||||
v2 = v2next++;
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "incr\n" );
|
||||
#endif
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "case cd\n" );
|
||||
#endif
|
||||
if( v1next->param[1] < v2next->param[1] )
|
||||
return 1;
|
||||
else if( v1next->param[1] > v2next->param[1] )
|
||||
return 0;
|
||||
else {
|
||||
v2 = v2next++;
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "incr\n" );
|
||||
#endif
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Subdivider::ccwTurn_tr( Arc_ptr j1, Arc_ptr j2 ) // dir = 1
|
||||
{
|
||||
register TrimVertex *v1 = &j1->pwlArc->pts[j1->pwlArc->npts-1];
|
||||
register TrimVertex *v1last = &j1->pwlArc->pts[0];
|
||||
register TrimVertex *v2 = &j2->pwlArc->pts[0];
|
||||
register TrimVertex *v2last = &j2->pwlArc->pts[j2->pwlArc->npts-1];
|
||||
register TrimVertex *v1next = v1-1;
|
||||
register TrimVertex *v2next = v2+1;
|
||||
int sgn;
|
||||
|
||||
assert( v1 != v1last );
|
||||
assert( v2 != v2last );
|
||||
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "arc_ccw_turn, p = %d\n", 1 );
|
||||
#endif
|
||||
|
||||
// the arcs lie on the line (1 == v1->param[1])
|
||||
if( v1->param[1] == v1next->param[1] && v2->param[1] == v2next->param[1] )
|
||||
return 0;
|
||||
|
||||
if( v2next->param[1] < v2->param[1] || v1next->param[1] < v1->param[1] )
|
||||
::mylongjmp( jumpbuffer, 28 );
|
||||
|
||||
if( v1->param[0] < v2->param[0] )
|
||||
return 1;
|
||||
else if( v1->param[0] > v2->param[0] )
|
||||
return 0;
|
||||
|
||||
while( 1 ) {
|
||||
if( v1next->param[1] < v2next->param[1] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case a\n" );
|
||||
#endif
|
||||
assert( v1->param[1] <= v1next->param[1] );
|
||||
assert( v2->param[1] <= v1next->param[1] );
|
||||
switch( bbox( v2, v2next, v1next, 0 ) ) {
|
||||
case -1:
|
||||
return 1;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v2, v2next );
|
||||
if( sgn != -1 ) {
|
||||
return sgn;
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "decr\n" );
|
||||
#endif
|
||||
v1 = v1next--;
|
||||
if( v1 == v1last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 0;
|
||||
}
|
||||
} else if( v1next->param[1] > v2next->param[1] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case b\n" );
|
||||
#endif
|
||||
assert( v1->param[1] <= v2next->param[1] );
|
||||
assert( v2->param[1] <= v2next->param[1] );
|
||||
switch( bbox( v1, v1next, v2next, 0 ) ) {
|
||||
case -1:
|
||||
return 0;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v1, v2next );
|
||||
if( sgn != -1 ) {
|
||||
return sgn;
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "incr\n" );
|
||||
#endif
|
||||
v2 = v2next++;
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "case ab\n" );
|
||||
#endif
|
||||
if( v1next->param[0] < v2next->param[0] )
|
||||
return 1;
|
||||
else if( v1next->param[0] > v2next->param[0] )
|
||||
return 0;
|
||||
else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "incr\n" );
|
||||
#endif
|
||||
v2 = v2next++;
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Subdivider::ccwTurn_tl( Arc_ptr j1, Arc_ptr j2 )
|
||||
{
|
||||
register TrimVertex *v1 = &j1->pwlArc->pts[j1->pwlArc->npts-1];
|
||||
register TrimVertex *v1last = &j1->pwlArc->pts[0];
|
||||
register TrimVertex *v2 = &j2->pwlArc->pts[0];
|
||||
register TrimVertex *v2last = &j2->pwlArc->pts[j2->pwlArc->npts-1];
|
||||
register TrimVertex *v1next = v1-1;
|
||||
register TrimVertex *v2next = v2+1;
|
||||
int sgn;
|
||||
|
||||
assert( v1 != v1last );
|
||||
assert( v2 != v2last );
|
||||
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "arc_ccw_turn, p = %d\n", 1 );
|
||||
#endif
|
||||
|
||||
// the arcs lie on the line (1 == v1->param[1])
|
||||
if( v1->param[1] == v1next->param[1] && v2->param[1] == v2next->param[1] )
|
||||
return 0;
|
||||
|
||||
if( v2next->param[1] > v2->param[1] || v1next->param[1] > v1->param[1] )
|
||||
::mylongjmp( jumpbuffer, 28 );
|
||||
|
||||
if( v1->param[0] < v2->param[0] )
|
||||
return 0;
|
||||
else if( v1->param[0] > v2->param[0] )
|
||||
return 1;
|
||||
|
||||
while( 1 ) {
|
||||
if( v1next->param[1] > v2next->param[1] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case c\n" );
|
||||
#endif
|
||||
assert( v1->param[1] >= v1next->param[1] );
|
||||
assert( v2->param[1] >= v1next->param[1] );
|
||||
switch( bbox( v2next, v2, v1next, 0 ) ) {
|
||||
case -1:
|
||||
return 0;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v2, v2next );
|
||||
if( sgn != -1 )
|
||||
return sgn;
|
||||
else {
|
||||
v1 = v1next--;
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "decr\n" );
|
||||
#endif
|
||||
if( v1 == v1last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 1;
|
||||
}
|
||||
} else if( v1next->param[1] < v2next->param[1] ) {
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "case d\n" );
|
||||
assert( v1->param[1] >= v2next->param[1] );
|
||||
assert( v2->param[1] >= v2next->param[1] );
|
||||
#endif
|
||||
switch( bbox( v1next, v1, v2next, 0 ) ) {
|
||||
case -1:
|
||||
return 1;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v1, v2next );
|
||||
if( sgn != -1 )
|
||||
return sgn;
|
||||
else {
|
||||
v2 = v2next++;
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "incr\n" );
|
||||
#endif
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "case cd\n" );
|
||||
#endif
|
||||
if( v1next->param[0] < v2next->param[0] )
|
||||
return 0;
|
||||
else if( v1next->param[0] > v2next->param[0] )
|
||||
return 1;
|
||||
else {
|
||||
v2 = v2next++;
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "incr\n" );
|
||||
#endif
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
_glu_dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
int
|
||||
Subdivider::bbox( register REAL sa, register REAL sb, register REAL sc,
|
||||
register REAL ta, register REAL tb, register REAL tc )
|
||||
#else
|
||||
int
|
||||
Subdivider::bbox( register REAL sa, register REAL sb, register REAL sc,
|
||||
register REAL , register REAL , register REAL )
|
||||
#endif
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
assert( tc >= ta );
|
||||
assert( tc <= tb );
|
||||
#endif
|
||||
|
||||
if( sa < sb ) {
|
||||
if( sc <= sa ) {
|
||||
return -1;
|
||||
} else if( sb <= sc ) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else if( sa > sb ) {
|
||||
if( sc >= sa ) {
|
||||
return 1;
|
||||
} else if( sb >= sc ) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if( sc > sa ) {
|
||||
return 1;
|
||||
} else if( sb > sc ) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* ccw - determine how three points are oriented by computing their
|
||||
* determinant.
|
||||
* Return 1 if the vertices are ccw oriented,
|
||||
* 0 if they are cw oriented, or
|
||||
* -1 if the computation is ill-conditioned.
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Subdivider::ccw( TrimVertex *a, TrimVertex *b, TrimVertex *c )
|
||||
{
|
||||
REAL d = det3( a, b, c );
|
||||
if( glu_abs(d) < 0.0001 ) return -1;
|
||||
return (d < 0.0) ? 0 : 1;
|
||||
}
|
||||
|
|
@ -1,440 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* coveandtiler.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "coveandtiler.h"
|
||||
#include "gridvertex.h"
|
||||
#include "gridtrimvertex.h"
|
||||
#include "uarray.h"
|
||||
#include "backend.h"
|
||||
|
||||
|
||||
const int CoveAndTiler::MAXSTRIPSIZE = 1000;
|
||||
|
||||
CoveAndTiler::CoveAndTiler( Backend& b )
|
||||
: backend( b )
|
||||
{ }
|
||||
|
||||
CoveAndTiler::~CoveAndTiler( void )
|
||||
{ }
|
||||
|
||||
inline void
|
||||
CoveAndTiler::output( GridVertex &gv )
|
||||
{
|
||||
backend.tmeshvert( &gv );
|
||||
}
|
||||
|
||||
inline void
|
||||
CoveAndTiler::output( TrimVertex *tv )
|
||||
{
|
||||
backend.tmeshvert( tv );
|
||||
}
|
||||
|
||||
inline void
|
||||
CoveAndTiler::output( GridTrimVertex& g )
|
||||
{
|
||||
backend.tmeshvert( &g );
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveAndTile( void )
|
||||
{
|
||||
long ustart = (top.ustart >= bot.ustart) ? top.ustart : bot.ustart;
|
||||
long uend = (top.uend <= bot.uend) ? top.uend : bot.uend;
|
||||
if( ustart <= uend ) {
|
||||
tile( bot.vindex, ustart, uend );
|
||||
if( top.ustart >= bot.ustart )
|
||||
coveUpperLeft();
|
||||
else
|
||||
coveLowerLeft();
|
||||
|
||||
if( top.uend <= bot.uend )
|
||||
coveUpperRight();
|
||||
else
|
||||
coveLowerRight();
|
||||
} else {
|
||||
TrimVertex blv, tlv, *bl, *tl;
|
||||
GridTrimVertex bllv, tllv;
|
||||
TrimVertex *lf = left.first();
|
||||
TrimVertex *ll = left.last();
|
||||
if( lf->param[0] >= ll->param[0] ) {
|
||||
blv.param[0] = lf->param[0];
|
||||
blv.param[1] = ll->param[1];
|
||||
blv.nuid = 0; // XXX
|
||||
assert( blv.param[1] == bot.vval );
|
||||
bl = &blv;
|
||||
tl = lf;
|
||||
tllv.set( lf );
|
||||
if( ll->param[0] > uarray.uarray[top.ustart-1] ) {
|
||||
bllv.set( ll );
|
||||
assert( ll->param[0] <= uarray.uarray[bot.ustart] );
|
||||
} else {
|
||||
bllv.set( top.ustart-1, bot.vindex );
|
||||
}
|
||||
coveUpperLeftNoGrid( bl );
|
||||
} else {
|
||||
tlv.param[0] = ll->param[0];
|
||||
tlv.param[1] = lf->param[1];
|
||||
tlv.nuid = 0; // XXX
|
||||
assert( tlv.param[1] == top.vval );
|
||||
tl = &tlv;
|
||||
bl = ll;
|
||||
bllv.set( ll );
|
||||
if( lf->param[0] > uarray.uarray[bot.ustart-1] ) {
|
||||
assert( lf->param[0] <= uarray.uarray[bot.ustart] );
|
||||
tllv.set( lf );
|
||||
} else {
|
||||
tllv.set( bot.ustart-1, top.vindex );
|
||||
}
|
||||
coveLowerLeftNoGrid( tl );
|
||||
}
|
||||
|
||||
TrimVertex brv, trv, *br, *tr;
|
||||
GridTrimVertex brrv, trrv;
|
||||
TrimVertex *rf = right.first();
|
||||
TrimVertex *rl = right.last();
|
||||
|
||||
if( rf->param[0] <= rl->param[0] ) {
|
||||
brv.param[0] = rf->param[0];
|
||||
brv.param[1] = rl->param[1];
|
||||
brv.nuid = 0; // XXX
|
||||
assert( brv.param[1] == bot.vval );
|
||||
br = &brv;
|
||||
tr = rf;
|
||||
trrv.set( rf );
|
||||
if( rl->param[0] < uarray.uarray[top.uend+1] ) {
|
||||
assert( rl->param[0] >= uarray.uarray[top.uend] );
|
||||
brrv.set( rl );
|
||||
} else {
|
||||
brrv.set( top.uend+1, bot.vindex );
|
||||
}
|
||||
coveUpperRightNoGrid( br );
|
||||
} else {
|
||||
trv.param[0] = rl->param[0];
|
||||
trv.param[1] = rf->param[1];
|
||||
trv.nuid = 0; // XXX
|
||||
assert( trv.param[1] == top.vval );
|
||||
tr = &trv;
|
||||
br = rl;
|
||||
brrv.set( rl );
|
||||
if( rf->param[0] < uarray.uarray[bot.uend+1] ) {
|
||||
assert( rf->param[0] >= uarray.uarray[bot.uend] );
|
||||
trrv.set( rf );
|
||||
} else {
|
||||
trrv.set( bot.uend+1, top.vindex );
|
||||
}
|
||||
coveLowerRightNoGrid( tr );
|
||||
}
|
||||
|
||||
backend.bgntmesh( "doit" );
|
||||
output(trrv);
|
||||
output(tllv);
|
||||
output( tr );
|
||||
output( tl );
|
||||
output( br );
|
||||
output( bl );
|
||||
output(brrv);
|
||||
output(bllv);
|
||||
backend.endtmesh();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::tile( long vindex, long ustart, long uend )
|
||||
{
|
||||
long numsteps = uend - ustart;
|
||||
|
||||
if( numsteps == 0 ) return;
|
||||
|
||||
if( numsteps > MAXSTRIPSIZE ) {
|
||||
long umid = ustart + (uend - ustart) / 2;
|
||||
tile( vindex, ustart, umid );
|
||||
tile( vindex, umid, uend );
|
||||
} else {
|
||||
backend.surfmesh( ustart, vindex-1, numsteps, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUpperRight( void )
|
||||
{
|
||||
GridVertex tgv( top.uend, top.vindex );
|
||||
GridVertex gv( top.uend, bot.vindex );
|
||||
|
||||
right.first();
|
||||
backend.bgntmesh( "coveUpperRight" );
|
||||
output( right.next() );
|
||||
output( tgv );
|
||||
backend.swaptmesh();
|
||||
output( gv );
|
||||
coveUR();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUpperRightNoGrid( TrimVertex* br )
|
||||
{
|
||||
backend.bgntmesh( "coveUpperRight" );
|
||||
output( right.first() );
|
||||
output( right.next() );
|
||||
backend.swaptmesh();
|
||||
output( br );
|
||||
coveUR();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUR( )
|
||||
{
|
||||
GridVertex gv( top.uend, bot.vindex );
|
||||
TrimVertex *vert = right.next();
|
||||
if( vert == NULL ) return;
|
||||
|
||||
assert( vert->param[0] >= uarray.uarray[gv.gparam[0]] );
|
||||
|
||||
if( gv.nextu() >= bot.uend ) {
|
||||
for( ; vert; vert = right.next() ) {
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
}
|
||||
} else while( 1 ) {
|
||||
if( vert->param[0] < uarray.uarray[gv.gparam[0]] ) {
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
vert = right.next();
|
||||
if( vert == NULL ) break;
|
||||
} else {
|
||||
backend.swaptmesh();
|
||||
output( gv );
|
||||
if( gv.nextu() == bot.uend ) {
|
||||
for( ; vert; vert = right.next() ) {
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUpperLeft( void )
|
||||
{
|
||||
GridVertex tgv( top.ustart, top.vindex );
|
||||
GridVertex gv( top.ustart, bot.vindex );
|
||||
|
||||
left.first();
|
||||
backend.bgntmesh( "coveUpperLeft" );
|
||||
output( tgv );
|
||||
output( left.next() );
|
||||
output( gv );
|
||||
backend.swaptmesh();
|
||||
coveUL();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUpperLeftNoGrid( TrimVertex* bl )
|
||||
{
|
||||
backend.bgntmesh( "coveUpperLeftNoGrid" );
|
||||
output( left.first() );
|
||||
output( left.next() );
|
||||
output( bl );
|
||||
backend.swaptmesh();
|
||||
coveUL();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUL()
|
||||
{
|
||||
GridVertex gv( top.ustart, bot.vindex );
|
||||
TrimVertex *vert = left.next();
|
||||
if( vert == NULL ) return;
|
||||
assert( vert->param[0] <= uarray.uarray[gv.gparam[0]] );
|
||||
|
||||
if( gv.prevu() <= bot.ustart ) {
|
||||
for( ; vert; vert = left.next() ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
}
|
||||
} else while( 1 ) {
|
||||
if( vert->param[0] > uarray.uarray[gv.gparam[0]] ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
vert = left.next();
|
||||
if( vert == NULL ) break;
|
||||
} else {
|
||||
output( gv );
|
||||
backend.swaptmesh();
|
||||
if( gv.prevu() == bot.ustart ) {
|
||||
for( ; vert; vert = left.next() ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLowerLeft( void )
|
||||
{
|
||||
GridVertex bgv( bot.ustart, bot.vindex );
|
||||
GridVertex gv( bot.ustart, top.vindex );
|
||||
|
||||
left.last();
|
||||
backend.bgntmesh( "coveLowerLeft" );
|
||||
output( left.prev() );
|
||||
output( bgv );
|
||||
backend.swaptmesh();
|
||||
output( gv );
|
||||
coveLL();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLowerLeftNoGrid( TrimVertex* tl )
|
||||
{
|
||||
backend.bgntmesh( "coveLowerLeft" );
|
||||
output( left.last() );
|
||||
output( left.prev() );
|
||||
backend.swaptmesh();
|
||||
output( tl );
|
||||
coveLL( );
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLL()
|
||||
{
|
||||
GridVertex gv( bot.ustart, top.vindex );
|
||||
TrimVertex *vert = left.prev();
|
||||
if( vert == NULL ) return;
|
||||
assert( vert->param[0] <= uarray.uarray[gv.gparam[0]] );
|
||||
|
||||
if( gv.prevu() <= top.ustart ) {
|
||||
for( ; vert; vert = left.prev() ) {
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
}
|
||||
} else while( 1 ) {
|
||||
if( vert->param[0] > uarray.uarray[gv.gparam[0]] ){
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
vert = left.prev();
|
||||
if( vert == NULL ) break;
|
||||
} else {
|
||||
backend.swaptmesh();
|
||||
output( gv );
|
||||
if( gv.prevu() == top.ustart ) {
|
||||
for( ; vert; vert = left.prev() ) {
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLowerRight( void )
|
||||
{
|
||||
GridVertex bgv( bot.uend, bot.vindex );
|
||||
GridVertex gv( bot.uend, top.vindex );
|
||||
|
||||
right.last();
|
||||
backend.bgntmesh( "coveLowerRight" );
|
||||
output( bgv );
|
||||
output( right.prev() );
|
||||
output( gv );
|
||||
backend.swaptmesh();
|
||||
coveLR();
|
||||
backend.endtmesh( );
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLowerRightNoGrid( TrimVertex* tr )
|
||||
{
|
||||
backend.bgntmesh( "coveLowerRIght" );
|
||||
output( right.last() );
|
||||
output( right.prev() );
|
||||
output( tr );
|
||||
backend.swaptmesh();
|
||||
coveLR();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLR( )
|
||||
{
|
||||
GridVertex gv( bot.uend, top.vindex );
|
||||
TrimVertex *vert = right.prev();
|
||||
if( vert == NULL ) return;
|
||||
assert( vert->param[0] >= uarray.uarray[gv.gparam[0]] );
|
||||
|
||||
if( gv.nextu() >= top.uend ) {
|
||||
for( ; vert; vert = right.prev() ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
}
|
||||
} else while( 1 ) {
|
||||
if( vert->param[0] < uarray.uarray[gv.gparam[0]] ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
vert = right.prev();
|
||||
if( vert == NULL ) break;
|
||||
} else {
|
||||
output( gv );
|
||||
backend.swaptmesh();
|
||||
if( gv.nextu() == top.uend ) {
|
||||
for( ; vert; vert = right.prev() ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* coveandtiler.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glucoveandtiler_h
|
||||
#define __glucoveandtiler_h
|
||||
|
||||
#include "trimregion.h"
|
||||
#include "trimvertex.h"
|
||||
#include "gridvertex.h"
|
||||
|
||||
class Backend;
|
||||
class GridTrimVertex;
|
||||
|
||||
class CoveAndTiler : virtual public TrimRegion {
|
||||
public:
|
||||
CoveAndTiler( Backend& );
|
||||
~CoveAndTiler( void );
|
||||
void coveAndTile( void );
|
||||
private:
|
||||
Backend& backend;
|
||||
static const int MAXSTRIPSIZE;
|
||||
void tile( long, long, long );
|
||||
void coveLowerLeft( void );
|
||||
void coveLowerRight( void );
|
||||
void coveUpperLeft( void );
|
||||
void coveUpperRight( void );
|
||||
void coveUpperLeftNoGrid( TrimVertex * );
|
||||
void coveUpperRightNoGrid( TrimVertex * );
|
||||
void coveLowerLeftNoGrid( TrimVertex * );
|
||||
void coveLowerRightNoGrid( TrimVertex * );
|
||||
void coveLL( void );
|
||||
void coveLR( void );
|
||||
void coveUL( void );
|
||||
void coveUR( void );
|
||||
inline void output( GridTrimVertex& );
|
||||
inline void output( GridVertex& );
|
||||
inline void output( TrimVertex* );
|
||||
};
|
||||
|
||||
#endif /* __glucoveandtiler_h */
|
||||
|
|
@ -1,204 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* curve.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "mymath.h"
|
||||
#include "curve.h"
|
||||
#include "mapdesc.h"
|
||||
#include "types.h"
|
||||
#include "quilt.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Curve::Curve - copy curve from quilt and transform control points
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Curve::Curve( Quilt_ptr geo, REAL pta, REAL ptb, Curve *c )
|
||||
{
|
||||
mapdesc = geo->mapdesc;
|
||||
next = c;
|
||||
needsSampling = mapdesc->isRangeSampling() ? 1 : 0;
|
||||
cullval = mapdesc->isCulling() ? CULL_ACCEPT : CULL_TRIVIAL_ACCEPT;
|
||||
order = geo->qspec[0].order;
|
||||
stride = MAXCOORDS;
|
||||
for( int i = 0; i < MAXORDER * MAXCOORDS; i++ ) {
|
||||
cpts[i] = 0;
|
||||
spts[i] = 0;
|
||||
}
|
||||
stepsize = 0;
|
||||
minstepsize = 0;
|
||||
|
||||
REAL *ps = geo->cpts;
|
||||
Quiltspec_ptr qs = geo->qspec;
|
||||
ps += qs->offset;
|
||||
ps += qs->index * qs->order * qs->stride;
|
||||
|
||||
if( needsSampling )
|
||||
mapdesc->xformSampling( ps, qs->order, qs->stride, spts, stride );
|
||||
|
||||
if( cullval == CULL_ACCEPT )
|
||||
mapdesc->xformCulling( ps, qs->order, qs->stride, cpts, stride );
|
||||
|
||||
/* set untrimmed curve range */
|
||||
range[0] = qs->breakpoints[qs->index];
|
||||
range[1] = qs->breakpoints[qs->index+1];
|
||||
range[2] = range[1] - range[0];
|
||||
|
||||
if( range[0] != pta ) {
|
||||
Curve lower( *this, pta, 0 );
|
||||
lower.next = next;
|
||||
*this = lower;
|
||||
}
|
||||
if( range[1] != ptb ) {
|
||||
Curve lower( *this, ptb, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Curve::Curve - subdivide a curve along an isoparametric line
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Curve::Curve( Curve& upper, REAL value, Curve *c )
|
||||
{
|
||||
Curve &lower = *this;
|
||||
|
||||
lower.next = c;
|
||||
lower.mapdesc = upper.mapdesc;
|
||||
lower.needsSampling = upper.needsSampling;
|
||||
lower.order = upper.order;
|
||||
lower.stride = upper.stride;
|
||||
lower.cullval = upper.cullval;
|
||||
|
||||
REAL d = (value - upper.range[0]) / upper.range[2];
|
||||
|
||||
if( needsSampling )
|
||||
mapdesc->subdivide( upper.spts, lower.spts, d, upper.stride, upper.order );
|
||||
|
||||
if( cullval == CULL_ACCEPT )
|
||||
mapdesc->subdivide( upper.cpts, lower.cpts, d, upper.stride, upper.order );
|
||||
|
||||
lower.range[0] = upper.range[0];
|
||||
lower.range[1] = value;
|
||||
lower.range[2] = value - upper.range[0];
|
||||
upper.range[0] = value;
|
||||
upper.range[2] = upper.range[1] - value;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Curve::clamp - clamp the sampling rate to a given maximum
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Curve::clamp( void )
|
||||
{
|
||||
if( stepsize < minstepsize )
|
||||
stepsize = mapdesc->clampfactor * minstepsize;
|
||||
}
|
||||
|
||||
void
|
||||
Curve::setstepsize( REAL max )
|
||||
{
|
||||
stepsize = ( max >= 1.0 ) ? (range[2] / max) : range[2];
|
||||
minstepsize = stepsize;
|
||||
}
|
||||
|
||||
void
|
||||
Curve::getstepsize( void )
|
||||
{
|
||||
minstepsize= 0;
|
||||
|
||||
if( mapdesc->isConstantSampling() ) {
|
||||
// fixed number of samples per patch in each direction
|
||||
// maxrate is number of s samples per patch
|
||||
setstepsize( mapdesc->maxrate );
|
||||
} else if( mapdesc->isDomainSampling() ) {
|
||||
// maxrate is number of s samples per unit s length of domain
|
||||
setstepsize( mapdesc->maxrate * range[2] );
|
||||
} else {
|
||||
// upper bound on path length between sample points
|
||||
|
||||
assert( order <= MAXORDER );
|
||||
|
||||
/* points have been transformed, therefore they are homogeneous */
|
||||
REAL tmp[MAXORDER][MAXCOORDS];
|
||||
const int tstride = sizeof(tmp[0]) / sizeof(REAL);
|
||||
int val = mapdesc->project( spts, stride, &tmp[0][0], tstride, order );
|
||||
|
||||
if( val == 0 ) {
|
||||
// control points cross infinity, therefore derivatives are undefined
|
||||
setstepsize( mapdesc->maxrate );
|
||||
} else {
|
||||
REAL t = mapdesc->getProperty( N_PIXEL_TOLERANCE );
|
||||
if( mapdesc->isParametricDistanceSampling() ) {
|
||||
REAL d = mapdesc->calcPartialVelocity( &tmp[0][0], tstride, order, 2, range[2] );
|
||||
stepsize = (d > 0.0) ? sqrtf( 8.0 * t / d ) : range[2];
|
||||
minstepsize = ( mapdesc->maxrate > 0.0 ) ? (range[2] / mapdesc->maxrate) : 0.0;
|
||||
} else if( mapdesc->isPathLengthSampling() ) {
|
||||
// t is upper bound on path (arc) length
|
||||
REAL d = mapdesc->calcPartialVelocity( &tmp[0][0], tstride, order, 1, range[2] );
|
||||
stepsize = ( d > 0.0 ) ? (t / d) : range[2];
|
||||
minstepsize = ( mapdesc->maxrate > 0.0 ) ? (range[2] / mapdesc->maxrate) : 0.0;
|
||||
} else {
|
||||
// control points cross infinity, therefore partials are undefined
|
||||
setstepsize( mapdesc->maxrate );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Curve::needsSamplingSubdivision( void )
|
||||
{
|
||||
return ( stepsize < minstepsize ) ? 1 : 0;
|
||||
}
|
||||
|
||||
int
|
||||
Curve::cullCheck( void )
|
||||
{
|
||||
if( cullval == CULL_ACCEPT )
|
||||
cullval = mapdesc->cullCheck( cpts, order, stride );
|
||||
return cullval;
|
||||
}
|
||||
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* curve.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glucurve_h_
|
||||
#define __glucurve_h_
|
||||
|
||||
#include "types.h"
|
||||
#include "defines.h"
|
||||
|
||||
class Mapdesc;
|
||||
class Quilt;
|
||||
|
||||
|
||||
class Curve {
|
||||
public:
|
||||
friend class Curvelist;
|
||||
Curve( Quilt *, REAL, REAL, Curve * );
|
||||
Curve( Curve&, REAL, Curve * );
|
||||
Curve * next;
|
||||
private:
|
||||
Mapdesc * mapdesc;
|
||||
int stride;
|
||||
int order;
|
||||
int cullval;
|
||||
int needsSampling;
|
||||
REAL cpts[MAXORDER*MAXCOORDS];
|
||||
REAL spts[MAXORDER*MAXCOORDS];
|
||||
REAL stepsize;
|
||||
REAL minstepsize;
|
||||
REAL range[3];
|
||||
|
||||
void clamp( void );
|
||||
void setstepsize( REAL );
|
||||
void getstepsize( void );
|
||||
int cullCheck( void );
|
||||
int needsSamplingSubdivision( void );
|
||||
};
|
||||
#endif /* __glucurve_h_ */
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* curvelist.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "quilt.h"
|
||||
#include "curvelist.h"
|
||||
#include "curve.h"
|
||||
#include "types.h"
|
||||
|
||||
Curvelist::Curvelist( Quilt *quilts, REAL pta, REAL ptb )
|
||||
{
|
||||
curve = 0;
|
||||
for( Quilt *q = quilts; q; q = q->next )
|
||||
curve = new Curve( q, pta, ptb, curve );
|
||||
range[0] = pta;
|
||||
range[1] = ptb;
|
||||
range[2] = ptb - pta;
|
||||
needsSubdivision = 0;
|
||||
stepsize = 0;
|
||||
}
|
||||
|
||||
Curvelist::Curvelist( Curvelist &upper, REAL value )
|
||||
{
|
||||
curve = 0;
|
||||
for( Curve *c = upper.curve; c; c = c->next )
|
||||
curve = new Curve( *c, value, curve );
|
||||
|
||||
range[0] = upper.range[0];
|
||||
range[1] = value;
|
||||
range[2] = value - upper.range[0];
|
||||
upper.range[0] = value;
|
||||
upper.range[2] = upper.range[1] - value;
|
||||
needsSubdivision = 0;
|
||||
stepsize = 0;
|
||||
}
|
||||
|
||||
Curvelist::~Curvelist()
|
||||
{
|
||||
while( curve ) {
|
||||
Curve *c = curve;
|
||||
curve = curve->next;
|
||||
delete c;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Curvelist::cullCheck( void )
|
||||
{
|
||||
for( Curve *c = curve; c; c = c->next )
|
||||
if( c->cullCheck() == CULL_TRIVIAL_REJECT )
|
||||
return CULL_TRIVIAL_REJECT;
|
||||
return CULL_ACCEPT;
|
||||
}
|
||||
|
||||
void
|
||||
Curvelist::getstepsize( void )
|
||||
{
|
||||
stepsize = range[2];
|
||||
Curve *c;
|
||||
for( c = curve; c; c = c->next ) {
|
||||
c->getstepsize();
|
||||
c->clamp();
|
||||
stepsize = ((c->stepsize < stepsize) ? c->stepsize : stepsize);
|
||||
if( c->needsSamplingSubdivision() ) break;
|
||||
}
|
||||
needsSubdivision = ( c ) ? 1 : 0;
|
||||
}
|
||||
|
||||
int
|
||||
Curvelist::needsSamplingSubdivision( void )
|
||||
{
|
||||
return needsSubdivision;
|
||||
}
|
||||
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* curvelist.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glucurvelist_h_
|
||||
#define __glucurvelist_h_
|
||||
|
||||
#include "types.h"
|
||||
#include "defines.h"
|
||||
|
||||
class Mapdesc;
|
||||
class Quilt;
|
||||
class Curve;
|
||||
|
||||
class Curvelist
|
||||
{
|
||||
friend class Subdivider;
|
||||
public:
|
||||
Curvelist( Quilt *, REAL, REAL );
|
||||
Curvelist( Curvelist &, REAL );
|
||||
~Curvelist( void );
|
||||
int cullCheck( void );
|
||||
void getstepsize( void );
|
||||
int needsSamplingSubdivision();
|
||||
private:
|
||||
Curve *curve;
|
||||
float range[3];
|
||||
int needsSubdivision;
|
||||
float stepsize;
|
||||
};
|
||||
#endif /* __glucurvelist_h_ */
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* curvesub.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "subdivider.h"
|
||||
#include "renderhints.h"
|
||||
#include "backend.h"
|
||||
#include "quilt.h"
|
||||
#include "curvelist.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* drawCurves - main curve rendering entry point
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Subdivider::drawCurves( void )
|
||||
{
|
||||
REAL from[1], to[1];
|
||||
Flist bpts;
|
||||
qlist->getRange( from, to, bpts );
|
||||
|
||||
renderhints.init( );
|
||||
|
||||
backend.bgncurv();
|
||||
for( int i=bpts.start; i<bpts.end-1; i++ ) {
|
||||
REAL pta, ptb;
|
||||
pta = bpts.pts[i];
|
||||
ptb = bpts.pts[i+1];
|
||||
|
||||
qlist->downloadAll( &pta, &ptb, backend );
|
||||
|
||||
Curvelist curvelist( qlist, pta, ptb );
|
||||
samplingSplit( curvelist, renderhints.maxsubdivisions );
|
||||
}
|
||||
backend.endcurv();
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* samplingSplit - recursively subdivide patch, cull check each subpatch
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Subdivider::samplingSplit( Curvelist& curvelist, int subdivisions )
|
||||
{
|
||||
if( curvelist.cullCheck() == CULL_TRIVIAL_REJECT ) return;
|
||||
|
||||
curvelist.getstepsize();
|
||||
|
||||
if( curvelist.needsSamplingSubdivision() && (subdivisions > 0) ) {
|
||||
REAL mid = ( curvelist.range[0] + curvelist.range[1] ) * 0.5;
|
||||
Curvelist lowerlist( curvelist, mid );
|
||||
samplingSplit( lowerlist, subdivisions-1 ); // lower
|
||||
samplingSplit( curvelist, subdivisions-1 ); // upper
|
||||
} else {
|
||||
long nu = 1 + ((long) (curvelist.range[2] / curvelist.stepsize));
|
||||
backend.curvgrid( curvelist.range[0], curvelist.range[1], nu );
|
||||
backend.curvmesh( 0, nu );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,209 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
**
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "nurbsconsts.h"
|
||||
#include "trimvertex.h"
|
||||
#include "dataTransform.h"
|
||||
|
||||
extern directedLine* arcLoopToDLineLoop(Arc_ptr loop);
|
||||
|
||||
#if 0 // UNUSED
|
||||
static directedLine* copy_loop(Arc_ptr loop, Real2* vertArray, int& index, directedLine dline_buf[], sampledLine sline_buf[], int& index_dline)
|
||||
{
|
||||
directedLine *ret;
|
||||
int old_index = index;
|
||||
int i = index;
|
||||
int j;
|
||||
for(j=0; j<loop->pwlArc->npts-1; j++, i++)
|
||||
{
|
||||
vertArray[i][0] = loop->pwlArc->pts[j].param[0];
|
||||
vertArray[i][1] = loop->pwlArc->pts[j].param[1];
|
||||
}
|
||||
loop->clearmark();
|
||||
|
||||
for(Arc_ptr jarc = loop->next; jarc != loop; jarc=jarc->next)
|
||||
{
|
||||
for(j=0; j<jarc->pwlArc->npts-1; j++, i++)
|
||||
{
|
||||
vertArray[i][0] = jarc->pwlArc->pts[j].param[0];
|
||||
vertArray[i][1] = jarc->pwlArc->pts[j].param[1];
|
||||
}
|
||||
jarc->clearmark();
|
||||
}
|
||||
//copy the first vertex again
|
||||
vertArray[i][0] = loop->pwlArc->pts[0].param[0];
|
||||
vertArray[i][1] = loop->pwlArc->pts[0].param[1];
|
||||
i++;
|
||||
index=i;
|
||||
|
||||
directedLine* dline;
|
||||
sampledLine* sline;
|
||||
sline = &sline_buf[index_dline];
|
||||
dline = &dline_buf[index_dline];
|
||||
sline->init(2, &vertArray[old_index]);
|
||||
dline->init(INCREASING, sline);
|
||||
ret = dline;
|
||||
index_dline++;
|
||||
|
||||
for(i=old_index+1; i<= index-2; i++)
|
||||
{
|
||||
sline = &sline_buf[index_dline];
|
||||
dline = &dline_buf[index_dline];
|
||||
sline->init(2, &vertArray[i]);
|
||||
dline->init(INCREASING, sline);
|
||||
ret->insert(dline);
|
||||
index_dline++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0 // UNUSED
|
||||
static int num_edges(Bin& bin)
|
||||
{
|
||||
int sum=0;
|
||||
for(Arc_ptr jarc = bin.firstarc(); jarc; jarc=bin.nextarc())
|
||||
sum += jarc->pwlArc->npts-1;
|
||||
return sum;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
directedLine* bin_to_DLineLoops(Bin& bin)
|
||||
{
|
||||
directedLine *ret=NULL;
|
||||
directedLine *temp;
|
||||
|
||||
int numedges = num_edges(bin);
|
||||
directedLine* dline_buf = new directedLine[numedges]; //not work for N32?
|
||||
sampledLine* sline_buf=new sampledLine[numedges];
|
||||
|
||||
Real2* vertArray = new Real2[numedges*2];
|
||||
int index = 0;
|
||||
int index_dline = 0;
|
||||
bin.markall();
|
||||
|
||||
for(Arc_ptr jarc = bin.firstarc(); jarc; jarc=bin.nextarc())
|
||||
{
|
||||
if(jarc->ismarked())
|
||||
{
|
||||
assert(jarc->check() != 0);
|
||||
Arc_ptr jarchead = jarc;
|
||||
do {
|
||||
jarc->clearmark();
|
||||
jarc = jarc->next;
|
||||
} while(jarc != jarchead);
|
||||
temp=copy_loop(jarchead, vertArray, index, dline_buf, sline_buf, index_dline);
|
||||
ret = temp->insertPolygon(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
directedLine* bin_to_DLineLoops(Bin& bin)
|
||||
{
|
||||
directedLine *ret=NULL;
|
||||
directedLine *temp;
|
||||
bin.markall();
|
||||
for(Arc_ptr jarc=bin.firstarc(); jarc; jarc=bin.nextarc()){
|
||||
if(jarc->ismarked()) {
|
||||
assert(jarc->check() != 0);
|
||||
Arc_ptr jarchead = jarc;
|
||||
do {
|
||||
jarc->clearmark();
|
||||
jarc = jarc->next;
|
||||
} while(jarc != jarchead);
|
||||
temp = arcLoopToDLineLoop(jarc);
|
||||
ret = temp->insertPolygon(ret);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
directedLine* o_pwlcurve_to_DLines(directedLine* original, O_pwlcurve* pwl)
|
||||
{
|
||||
directedLine* ret = original;
|
||||
for(Int i=0; i<pwl->npts-1; i++)
|
||||
{
|
||||
sampledLine* sline = new sampledLine(2);
|
||||
sline->setPoint(0, pwl->pts[i].param);
|
||||
sline->setPoint(1, pwl->pts[i+1].param);
|
||||
directedLine* dline = new directedLine(INCREASING, sline);
|
||||
if(ret == NULL)
|
||||
ret = dline;
|
||||
else
|
||||
ret->insert(dline);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
directedLine* o_curve_to_DLineLoop(O_curve* cur)
|
||||
{
|
||||
directedLine *ret;
|
||||
if(cur == NULL)
|
||||
return NULL;
|
||||
assert(cur->curvetype == ct_pwlcurve);
|
||||
ret = o_pwlcurve_to_DLines(NULL, cur->curve.o_pwlcurve);
|
||||
for(O_curve* temp = cur->next; temp != NULL; temp = temp->next)
|
||||
{
|
||||
assert(temp->curvetype == ct_pwlcurve);
|
||||
ret = o_pwlcurve_to_DLines(ret, temp->curve.o_pwlcurve);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
directedLine* o_trim_to_DLineLoops(O_trim* trim)
|
||||
{
|
||||
O_trim* temp;
|
||||
directedLine *ret;
|
||||
if(trim == NULL)
|
||||
return NULL;
|
||||
ret = o_curve_to_DLineLoop(trim->o_curve);
|
||||
|
||||
for(temp=trim->next; temp != NULL; temp = temp->next)
|
||||
{
|
||||
ret = ret->insertPolygon(o_curve_to_DLineLoop(temp->o_curve));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#ifndef _DATA_TRANSFORM_H
|
||||
#define _DATA_TRANSFORM_H
|
||||
|
||||
#include "reader.h"
|
||||
#include "directedLine.h"
|
||||
#include "bin.h"
|
||||
directedLine* bin_to_DLineLoops(Bin& bin);
|
||||
|
||||
/*transform the pwlcurve into a number of directedline lines
|
||||
*insert these directedlines into orignal which is supposed to be
|
||||
*the part of the trimming loop obtained so far.
|
||||
*return the updated trimkming loop.
|
||||
*/
|
||||
directedLine* o_pwlcurve_to_DLines(directedLine* original, O_pwlcurve* pwl);
|
||||
|
||||
/*transform a trim loop (curve) into a directedLine loop
|
||||
*/
|
||||
directedLine* o_curve_to_DLineLoop(O_curve* curve);
|
||||
|
||||
/*transform a list of trim loops (trim) into
|
||||
*a list of polygons represented as directedLine*.
|
||||
*/
|
||||
directedLine* o_trim_to_DLineLoops(O_trim* trim);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* defines.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gludefines_h_
|
||||
#define __gludefines_h_
|
||||
|
||||
/* culling constants */
|
||||
#define CULL_TRIVIAL_REJECT 0
|
||||
#define CULL_TRIVIAL_ACCEPT 1
|
||||
#define CULL_ACCEPT 2
|
||||
|
||||
/* maximum order of a B-Spline */
|
||||
#define MAXORDER 24
|
||||
|
||||
/* maximum dimension of any B-spline range space */
|
||||
#define MAXCOORDS 5
|
||||
|
||||
#endif /* __gludefines_h_ */
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* displaylist.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "nurbstess.h"
|
||||
#include "displaylist.h"
|
||||
|
||||
|
||||
DisplayList::DisplayList( NurbsTessellator *_nt ) :
|
||||
dlnodePool( sizeof( Dlnode ), 1, "dlnodepool" )
|
||||
{
|
||||
lastNode = &nodes;
|
||||
nt = _nt;
|
||||
}
|
||||
|
||||
DisplayList::~DisplayList( void )
|
||||
{
|
||||
for( Dlnode *nextNode; nodes; nodes = nextNode ) {
|
||||
nextNode = nodes->next;
|
||||
if( nodes->cleanup != 0 ) (nt->*nodes->cleanup)( nodes->arg );
|
||||
//nodes->deleteMe(dlnodePool);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DisplayList::play( void )
|
||||
{
|
||||
for( Dlnode *node = nodes; node; node = node->next )
|
||||
if( node->work != 0 ) (nt->*node->work)( node->arg );
|
||||
}
|
||||
|
||||
void
|
||||
DisplayList::endList( void )
|
||||
{
|
||||
*lastNode = 0;
|
||||
}
|
||||
|
||||
void
|
||||
DisplayList::append( PFVS work, void *arg, PFVS cleanup )
|
||||
{
|
||||
Dlnode *node = new(dlnodePool) Dlnode( work, arg, cleanup );
|
||||
*lastNode = node;
|
||||
lastNode = &(node->next);
|
||||
}
|
||||
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* displaylist.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gludisplaylist_h_
|
||||
#define __gludisplaylist_h_
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mysetjmp.h"
|
||||
#include "mystdio.h"
|
||||
#include "bufpool.h"
|
||||
|
||||
class NurbsTessellator;
|
||||
|
||||
typedef void (NurbsTessellator::*PFVS)( void * );
|
||||
|
||||
struct Dlnode : public PooledObj {
|
||||
Dlnode( PFVS, void *, PFVS );
|
||||
PFVS work;
|
||||
void * arg;
|
||||
PFVS cleanup;
|
||||
Dlnode * next;
|
||||
};
|
||||
|
||||
inline
|
||||
Dlnode::Dlnode( PFVS _work, void *_arg, PFVS _cleanup )
|
||||
{
|
||||
work = _work;
|
||||
arg = _arg;
|
||||
cleanup = _cleanup;
|
||||
next = 0;
|
||||
}
|
||||
|
||||
class DisplayList {
|
||||
public:
|
||||
DisplayList( NurbsTessellator * );
|
||||
~DisplayList( void );
|
||||
void play( void );
|
||||
void append( PFVS work, void *arg, PFVS cleanup );
|
||||
void endList( void );
|
||||
private:
|
||||
Dlnode *nodes;
|
||||
Pool dlnodePool;
|
||||
Dlnode **lastNode;
|
||||
NurbsTessellator *nt;
|
||||
};
|
||||
|
||||
#endif /* __gludisplaylist_h_ */
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#ifndef __gludisplaymode_h_
|
||||
#define __gludisplaymode_h_
|
||||
|
||||
#define N_MESHFILL 0
|
||||
#define N_MESHLINE 1
|
||||
#define N_MESHPOINT 2
|
||||
|
||||
#endif /* __gludisplaymode_h_ */
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* flist.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "flist.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Flist::Flist - initialize a REAL number array
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
Flist::Flist( void )
|
||||
{
|
||||
npts = 0;
|
||||
pts = 0;
|
||||
start = end = 0;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Flist::~Flist - free a REAL number array
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
Flist::~Flist( void )
|
||||
{
|
||||
if( npts ) delete[] pts;
|
||||
}
|
||||
|
||||
void
|
||||
Flist::add( REAL x )
|
||||
{
|
||||
pts[end++] = x;
|
||||
assert( end <= npts );
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Flist::filter - remove duplicate numbers from array
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
void Flist::filter( void )
|
||||
{
|
||||
sorter.qsort( pts, end );
|
||||
start = 0;
|
||||
|
||||
int j = 0;
|
||||
for( int i = 1; i < end; i++ ) {
|
||||
if( pts[i] == pts[i-j-1] )
|
||||
j++;
|
||||
pts[i-j] = pts[i];
|
||||
}
|
||||
end -= j;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Flist::grow - ensure that array is large enough
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
void Flist::grow( int maxpts )
|
||||
{
|
||||
if( npts < maxpts ) {
|
||||
if( npts ) delete[] pts;
|
||||
npts = 2 * maxpts;
|
||||
pts = new REAL[npts];
|
||||
assert( pts != 0 );
|
||||
}
|
||||
start = end = 0;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Flist::taper - ignore head and tail of array
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
void Flist::taper( REAL from, REAL to )
|
||||
{
|
||||
while( pts[start] != from )
|
||||
start++;
|
||||
|
||||
while( pts[end-1] != to )
|
||||
end--;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* flist.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluflist_h_
|
||||
#define __gluflist_h_
|
||||
|
||||
#include "types.h"
|
||||
#include "flistsorter.h"
|
||||
|
||||
class Flist {
|
||||
public:
|
||||
REAL * pts; /* head of array */
|
||||
int npts; /* number of points in array */
|
||||
int start; /* first important point index */
|
||||
int end; /* last important point index */
|
||||
|
||||
Flist( void );
|
||||
~Flist( void );
|
||||
void add( REAL x );
|
||||
void filter( void );
|
||||
void grow( int);
|
||||
void taper( REAL , REAL );
|
||||
protected:
|
||||
FlistSorter sorter;
|
||||
};
|
||||
|
||||
#endif /* __gluflist_h_ */
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* flistsorter.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "flistsorter.h"
|
||||
|
||||
FlistSorter::FlistSorter( void ) : Sorter( sizeof( REAL ) )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
FlistSorter::qsort( REAL *p, int n )
|
||||
{
|
||||
Sorter::qsort( (char *)p, n );
|
||||
}
|
||||
|
||||
int
|
||||
FlistSorter::qscmp( char *i, char *j )
|
||||
{
|
||||
REAL f0 = *(REAL *)i;
|
||||
REAL f1 = *(REAL *)j;
|
||||
return (f0 < f1) ? -1 : 1;
|
||||
}
|
||||
|
||||
void
|
||||
FlistSorter::qsexc( char *i, char *j )
|
||||
{
|
||||
REAL *f0 = (REAL *)i;
|
||||
REAL *f1 = (REAL *)j;
|
||||
REAL tmp = *f0;
|
||||
*f0 = *f1;
|
||||
*f1 = tmp;
|
||||
}
|
||||
|
||||
void
|
||||
FlistSorter::qstexc( char *i, char *j, char *k )
|
||||
{
|
||||
REAL *f0 = (REAL *)i;
|
||||
REAL *f1 = (REAL *)j;
|
||||
REAL *f2 = (REAL *)k;
|
||||
REAL tmp = *f0;
|
||||
*f0 = *f2;
|
||||
*f2 = *f1;
|
||||
*f1 = tmp;
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* flistsorter.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluflistsorter_h_
|
||||
#define __gluflistsorter_h_
|
||||
|
||||
#include "sorter.h"
|
||||
#include "types.h"
|
||||
|
||||
class FlistSorter : public Sorter {
|
||||
public:
|
||||
FlistSorter(void);
|
||||
virtual ~FlistSorter() { /* silence warning*/ }
|
||||
void qsort( REAL *a, int n );
|
||||
|
||||
protected:
|
||||
virtual int qscmp( char *, char * );
|
||||
virtual void qsexc( char *i, char *j ); // i<-j, j<-i
|
||||
virtual void qstexc( char *i, char *j, char *k ); // i<-k, k<-j, j<-i
|
||||
};
|
||||
#endif /* __gluflistsorter_h_ */
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* gridline.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glugridline_h_
|
||||
#define __glugridline_h_
|
||||
|
||||
struct Gridline {
|
||||
long v;
|
||||
REAL vval;
|
||||
long vindex;
|
||||
long ustart;
|
||||
long uend;
|
||||
};
|
||||
#endif /* __glugridline_h_ */
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* gridtrimvertex.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glugridtrimvertex_h_
|
||||
#define __glugridtrimvertex_h_
|
||||
|
||||
#include "mystdlib.h"
|
||||
#include "bufpool.h"
|
||||
#include "trimvertex.h"
|
||||
#include "gridvertex.h"
|
||||
|
||||
class GridTrimVertex : public PooledObj
|
||||
{
|
||||
private:
|
||||
TrimVertex dummyt;
|
||||
GridVertex dummyg;
|
||||
public:
|
||||
GridTrimVertex() { g = 0; t = 0; }
|
||||
TrimVertex *t;
|
||||
GridVertex *g;
|
||||
|
||||
inline void set( long, long );
|
||||
inline void set( REAL, REAL );
|
||||
inline void set( TrimVertex * );
|
||||
inline void clear( void ) { t = 0; g = 0; };
|
||||
inline int isGridVert() { return g ? 1 : 0 ; }
|
||||
inline int isTrimVert() { return t ? 1 : 0 ; }
|
||||
inline void output();
|
||||
};
|
||||
|
||||
inline void
|
||||
GridTrimVertex::set( long x, long y )
|
||||
{
|
||||
g = &dummyg;
|
||||
dummyg.gparam[0] = x;
|
||||
dummyg.gparam[1] = y;
|
||||
}
|
||||
|
||||
inline void
|
||||
GridTrimVertex::set( REAL x, REAL y )
|
||||
{
|
||||
g = 0;
|
||||
t = &dummyt;
|
||||
dummyt.param[0] = x;
|
||||
dummyt.param[1] = y;
|
||||
dummyt.nuid = 0;
|
||||
}
|
||||
|
||||
inline void
|
||||
GridTrimVertex::set( TrimVertex *v )
|
||||
{
|
||||
g = 0;
|
||||
t = v;
|
||||
}
|
||||
|
||||
typedef GridTrimVertex *GridTrimVertex_p;
|
||||
#endif /* __glugridtrimvertex_h_ */
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* gridvertex.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glugridvertex_h_
|
||||
#define __glugridvertex_h_
|
||||
|
||||
struct GridVertex {
|
||||
long gparam[2];
|
||||
GridVertex( void ) { gparam[0] = 0, gparam[1] = 0; }
|
||||
GridVertex( long u, long v ) { gparam[0] = u, gparam[1] = v; }
|
||||
void set( long u, long v ) { gparam[0] = u, gparam[1] = v; }
|
||||
long nextu() { return gparam[0]++; }
|
||||
long prevu() { return gparam[0]--; }
|
||||
};
|
||||
|
||||
#endif /* __glugridvertex_h_ */
|
||||
|
|
@ -1,165 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* hull.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "hull.h"
|
||||
#include "gridvertex.h"
|
||||
#include "gridtrimvertex.h"
|
||||
#include "gridline.h"
|
||||
#include "trimline.h"
|
||||
#include "uarray.h"
|
||||
#include "trimregion.h"
|
||||
|
||||
Hull::Hull( void )
|
||||
{}
|
||||
|
||||
Hull::~Hull( void )
|
||||
{}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Hull:init - this routine does the initialization needed before any
|
||||
* calls to nextupper or nextlower can be made.
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Hull::init( void )
|
||||
{
|
||||
TrimVertex *lfirst = left.first();
|
||||
TrimVertex *llast = left.last();
|
||||
if( lfirst->param[0] <= llast->param[0] ) {
|
||||
fakeleft.init( left.first() );
|
||||
upper.left = &fakeleft;
|
||||
lower.left = &left;
|
||||
} else {
|
||||
fakeleft.init( left.last() );
|
||||
lower.left = &fakeleft;
|
||||
upper.left = &left;
|
||||
}
|
||||
upper.left->last();
|
||||
lower.left->first();
|
||||
|
||||
if( top.ustart <= top.uend ) {
|
||||
upper.line = ⊤
|
||||
upper.index = top.ustart;
|
||||
} else
|
||||
upper.line = 0;
|
||||
|
||||
if( bot.ustart <= bot.uend ) {
|
||||
lower.line = ⊥
|
||||
lower.index = bot.ustart;
|
||||
} else
|
||||
lower.line = 0;
|
||||
|
||||
TrimVertex *rfirst = right.first();
|
||||
TrimVertex *rlast = right.last();
|
||||
if( rfirst->param[0] <= rlast->param[0] ) {
|
||||
fakeright.init( right.last() );
|
||||
lower.right = &fakeright;
|
||||
upper.right = &right;
|
||||
} else {
|
||||
fakeright.init( right.first() );
|
||||
upper.right = &fakeright;
|
||||
lower.right = &right;
|
||||
}
|
||||
upper.right->first();
|
||||
lower.right->last();
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* nextupper - find next vertex on upper hull of trim region.
|
||||
* - if vertex is on trim curve, set vtop point to
|
||||
* that vertex. if vertex is on grid, set vtop to
|
||||
* point to temporary area and stuff coordinants into
|
||||
* temporary vertex. Also, place grid coords in temporary
|
||||
* grid vertex.
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
GridTrimVertex *
|
||||
Hull::nextupper( GridTrimVertex *gv )
|
||||
{
|
||||
if( upper.left ) {
|
||||
gv->set( upper.left->prev() );
|
||||
if( gv->isTrimVert() ) return gv;
|
||||
upper.left = 0;
|
||||
}
|
||||
|
||||
if( upper.line ) {
|
||||
assert( upper.index <= upper.line->uend );
|
||||
gv->set( uarray.uarray[upper.index], upper.line->vval );
|
||||
gv->set( upper.index, upper.line->vindex );
|
||||
if( upper.index++ == upper.line->uend ) upper.line = 0;
|
||||
return gv;
|
||||
}
|
||||
|
||||
if( upper.right ) {
|
||||
gv->set( upper.right->next() );
|
||||
if( gv->isTrimVert() ) return gv;
|
||||
upper.right = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GridTrimVertex *
|
||||
Hull::nextlower( register GridTrimVertex *gv )
|
||||
{
|
||||
if( lower.left ) {
|
||||
gv->set( lower.left->next() );
|
||||
if( gv->isTrimVert() ) return gv;
|
||||
lower.left = 0;
|
||||
}
|
||||
|
||||
if( lower.line ) {
|
||||
gv->set( uarray.uarray[lower.index], lower.line->vval );
|
||||
gv->set( lower.index, lower.line->vindex );
|
||||
if( lower.index++ == lower.line->uend ) lower.line = 0;
|
||||
return gv;
|
||||
}
|
||||
|
||||
if( lower.right ) {
|
||||
gv->set( lower.right->prev() );
|
||||
if( gv->isTrimVert() ) return gv;
|
||||
lower.right = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* hull.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluhull_h_
|
||||
#define __gluhull_h_
|
||||
|
||||
#include "trimline.h"
|
||||
#include "trimregion.h"
|
||||
#include "trimvertex.h"
|
||||
#include "gridtrimvertex.h"
|
||||
|
||||
struct Gridline;
|
||||
class Uarray;
|
||||
|
||||
class Hull : virtual public TrimRegion {
|
||||
public:
|
||||
Hull( void );
|
||||
~Hull( void );
|
||||
void init( void );
|
||||
GridTrimVertex * nextlower( GridTrimVertex * );
|
||||
GridTrimVertex * nextupper( GridTrimVertex * );
|
||||
private:
|
||||
struct Side {
|
||||
Trimline *left;
|
||||
Gridline *line;
|
||||
Trimline *right;
|
||||
long index;
|
||||
};
|
||||
|
||||
Side lower;
|
||||
Side upper;
|
||||
Trimline fakeleft;
|
||||
Trimline fakeright;
|
||||
};
|
||||
|
||||
|
||||
#endif /* __gluhull_h_ */
|
||||
|
|
@ -1,665 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* intersect.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "subdivider.h"
|
||||
#include "arc.h"
|
||||
#include "bin.h"
|
||||
#include "backend.h"
|
||||
#include "trimvertpool.h"
|
||||
|
||||
/*#define NOTDEF*/
|
||||
|
||||
enum i_result { INTERSECT_VERTEX, INTERSECT_EDGE };
|
||||
|
||||
/* local functions */
|
||||
#ifndef NDEBUG // for asserts only
|
||||
static int arc_classify( Arc_ptr, int, REAL );
|
||||
#endif
|
||||
static enum i_result pwlarc_intersect( PwlArc *, int, REAL, int, int[3] );
|
||||
|
||||
|
||||
void
|
||||
Subdivider::partition( Bin & bin, Bin & left, Bin & intersections,
|
||||
Bin & right, Bin & unknown, int param, REAL value )
|
||||
{
|
||||
Bin headonleft, headonright, tailonleft, tailonright;
|
||||
|
||||
for( Arc_ptr jarc = bin.removearc(); jarc; jarc = bin.removearc() ) {
|
||||
|
||||
REAL tdiff = jarc->tail()[param] - value;
|
||||
REAL hdiff = jarc->head()[param] - value;
|
||||
|
||||
if( tdiff > 0.0 ) {
|
||||
if( hdiff > 0.0 ) {
|
||||
right.addarc( jarc );
|
||||
} else if( hdiff == 0.0 ) {
|
||||
tailonright.addarc( jarc );
|
||||
} else {
|
||||
Arc_ptr jtemp;
|
||||
switch( arc_split(jarc, param, value, 0) ) {
|
||||
case 2:
|
||||
tailonright.addarc( jarc );
|
||||
headonleft.addarc( jarc->next );
|
||||
break;
|
||||
case 31:
|
||||
assert( jarc->head()[param] > value );
|
||||
right.addarc( jarc );
|
||||
tailonright.addarc( jtemp = jarc->next );
|
||||
headonleft.addarc( jtemp->next );
|
||||
break;
|
||||
case 32:
|
||||
assert( jarc->head()[param] <= value );
|
||||
tailonright .addarc( jarc );
|
||||
headonleft.addarc( jtemp = jarc->next );
|
||||
left.addarc( jtemp->next );
|
||||
break;
|
||||
case 4:
|
||||
right.addarc( jarc );
|
||||
tailonright.addarc( jtemp = jarc->next );
|
||||
headonleft.addarc( jtemp = jtemp->next );
|
||||
left.addarc( jtemp->next );
|
||||
}
|
||||
}
|
||||
} else if( tdiff == 0.0 ) {
|
||||
if( hdiff > 0.0 ) {
|
||||
headonright.addarc( jarc );
|
||||
} else if( hdiff == 0.0 ) {
|
||||
unknown.addarc( jarc );
|
||||
} else {
|
||||
headonleft.addarc( jarc );
|
||||
}
|
||||
} else {
|
||||
if( hdiff > 0.0 ) {
|
||||
Arc_ptr jtemp;
|
||||
switch( arc_split(jarc, param, value, 1) ) {
|
||||
case 2:
|
||||
tailonleft.addarc( jarc );
|
||||
headonright.addarc( jarc->next );
|
||||
break;
|
||||
case 31:
|
||||
assert( jarc->head()[param] < value );
|
||||
left.addarc( jarc );
|
||||
tailonleft.addarc( jtemp = jarc->next );
|
||||
headonright.addarc( jtemp->next );
|
||||
break;
|
||||
case 32:
|
||||
assert( jarc->head()[param] >= value );
|
||||
tailonleft.addarc( jarc );
|
||||
headonright.addarc( jtemp = jarc->next );
|
||||
right.addarc( jtemp->next );
|
||||
break;
|
||||
case 4:
|
||||
left.addarc( jarc );
|
||||
tailonleft.addarc( jtemp = jarc->next );
|
||||
headonright.addarc( jtemp = jtemp->next );
|
||||
right.addarc( jtemp->next );
|
||||
}
|
||||
} else if( hdiff == 0.0 ) {
|
||||
tailonleft.addarc( jarc );
|
||||
} else {
|
||||
left.addarc( jarc );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( param == 0 ) {
|
||||
classify_headonleft_s( headonleft, intersections, left, value );
|
||||
classify_tailonleft_s( tailonleft, intersections, left, value );
|
||||
classify_headonright_s( headonright, intersections, right, value );
|
||||
classify_tailonright_s( tailonright, intersections, right, value );
|
||||
} else {
|
||||
classify_headonleft_t( headonleft, intersections, left, value );
|
||||
classify_tailonleft_t( tailonleft, intersections, left, value );
|
||||
classify_headonright_t( headonright, intersections, right, value );
|
||||
classify_tailonright_t( tailonright, intersections, right, value );
|
||||
}
|
||||
}
|
||||
|
||||
inline static void
|
||||
vert_interp( TrimVertex *n, TrimVertex *l, TrimVertex *r, int p, REAL val )
|
||||
{
|
||||
assert( val > l->param[p]);
|
||||
assert( val < r->param[p]);
|
||||
|
||||
n->nuid = l->nuid;
|
||||
|
||||
n->param[p] = val;
|
||||
if( l->param[1-p] != r->param[1-p] ) {
|
||||
REAL ratio = (val - l->param[p]) / (r->param[p] - l->param[p]);
|
||||
n->param[1-p] = l->param[1-p] +
|
||||
ratio * (r->param[1-p] - l->param[1-p]);
|
||||
} else {
|
||||
n->param[1-p] = l->param[1-p];
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Subdivider::arc_split( Arc_ptr jarc, int param, REAL value, int dir )
|
||||
{
|
||||
int maxvertex = jarc->pwlArc->npts;
|
||||
Arc_ptr jarc1;
|
||||
TrimVertex* v = jarc->pwlArc->pts;
|
||||
|
||||
int loc[3];
|
||||
switch( pwlarc_intersect( jarc->pwlArc, param, value, dir, loc ) ) {
|
||||
|
||||
// When the parameter value lands on a vertex, life is sweet
|
||||
case INTERSECT_VERTEX: {
|
||||
jarc1 = new(arcpool) Arc( jarc, new( pwlarcpool) PwlArc( maxvertex-loc[1], &v[loc[1]] ) );
|
||||
jarc->pwlArc->npts = loc[1] + 1;
|
||||
jarc1->next = jarc->next;
|
||||
jarc1->next->prev = jarc1;
|
||||
jarc->next = jarc1;
|
||||
jarc1->prev = jarc;
|
||||
assert(jarc->check() != 0);
|
||||
return 2;
|
||||
}
|
||||
|
||||
// When the parameter value intersects an edge, we have to
|
||||
// interpolate a new vertex. There are special cases
|
||||
// if the new vertex is adjacent to one or both of the
|
||||
// endpoints of the arc.
|
||||
case INTERSECT_EDGE: {
|
||||
int i, j;
|
||||
if( dir == 0 ) {
|
||||
i = loc[0];
|
||||
j = loc[2];
|
||||
} else {
|
||||
i = loc[2];
|
||||
j = loc[0];
|
||||
}
|
||||
|
||||
#ifndef NOTDEF
|
||||
// The split is between vertices at index j and i, in that
|
||||
// order (j < i)
|
||||
|
||||
// JEB: This code is my idea of how to do the split without
|
||||
// increasing the number of links. I'm doing this so that
|
||||
// the is_rect routine can recognize rectangles created by
|
||||
// subdivision. In exchange for simplifying the curve list,
|
||||
// however, it costs in allocated space and vertex copies.
|
||||
|
||||
TrimVertex *newjunk = trimvertexpool.get(maxvertex -i+1 /*-j*/);
|
||||
int k;
|
||||
for(k=0; k<maxvertex-i; k++)
|
||||
{
|
||||
newjunk[k+1] = v[i+k];
|
||||
newjunk[k+1].nuid = jarc->nuid;
|
||||
}
|
||||
|
||||
TrimVertex *vcopy = trimvertexpool.get(maxvertex);
|
||||
for(k=0; k<maxvertex; k++)
|
||||
{
|
||||
vcopy[k].param[0] = v[k].param[0];
|
||||
vcopy[k].param[1] = v[k].param[1];
|
||||
}
|
||||
jarc->pwlArc->pts=vcopy;
|
||||
|
||||
v[i].nuid = jarc->nuid;
|
||||
v[j].nuid = jarc->nuid;
|
||||
vert_interp( &newjunk[0], &v[loc[0]], &v[loc[2]], param, value );
|
||||
|
||||
if( showingDegenerate() )
|
||||
backend.triangle( &v[i], &newjunk[0], &v[j] );
|
||||
|
||||
vcopy[j+1].param[0]=newjunk[0].param[0];
|
||||
vcopy[j+1].param[1]=newjunk[0].param[1];
|
||||
|
||||
|
||||
jarc1 = new(arcpool) Arc( jarc,
|
||||
new(pwlarcpool) PwlArc(maxvertex-i+1 , newjunk ) );
|
||||
|
||||
jarc->pwlArc->npts = j+2;
|
||||
jarc1->next = jarc->next;
|
||||
jarc1->next->prev = jarc1;
|
||||
jarc->next = jarc1;
|
||||
jarc1->prev = jarc;
|
||||
assert(jarc->check() != 0);
|
||||
|
||||
return 2;
|
||||
#endif //not NOTDEF
|
||||
// JEB: This is the original version:
|
||||
#ifdef NOTDEF
|
||||
Arc_ptr jarc2, jarc3;
|
||||
|
||||
TrimVertex *newjunk = trimvertexpool.get(3);
|
||||
v[i].nuid = jarc->nuid;
|
||||
v[j].nuid = jarc->nuid;
|
||||
newjunk[0] = v[j];
|
||||
newjunk[2] = v[i];
|
||||
vert_interp( &newjunk[1], &v[loc[0]], &v[loc[2]], param, value );
|
||||
|
||||
if( showingDegenerate() )
|
||||
backend.triangle( &newjunk[2], &newjunk[1], &newjunk[0] );
|
||||
|
||||
// New vertex adjacent to both endpoints
|
||||
if (maxvertex == 2) {
|
||||
jarc1 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk+1 ) );
|
||||
jarc->pwlArc->npts = 2;
|
||||
jarc->pwlArc->pts = newjunk;
|
||||
jarc1->next = jarc->next;
|
||||
jarc1->next->prev = jarc1;
|
||||
jarc->next = jarc1;
|
||||
jarc1->prev = jarc;
|
||||
assert(jarc->check() != 0);
|
||||
|
||||
return 2;
|
||||
|
||||
// New vertex adjacent to ending point of arc
|
||||
} else if (maxvertex - j == 2) {
|
||||
jarc1 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk ) );
|
||||
jarc2 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk+1 ) );
|
||||
jarc->pwlArc->npts = maxvertex-1;
|
||||
jarc2->next = jarc->next;
|
||||
jarc2->next->prev = jarc2;
|
||||
jarc->next = jarc1;
|
||||
jarc1->prev = jarc;
|
||||
jarc1->next = jarc2;
|
||||
jarc2->prev = jarc1;
|
||||
assert(jarc->check() != 0);
|
||||
return 31;
|
||||
|
||||
// New vertex adjacent to starting point of arc
|
||||
} else if (i == 1) {
|
||||
jarc1 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk+1 ) );
|
||||
jarc2 = new(arcpool) Arc( jarc,
|
||||
new(pwlarcpool) PwlArc( maxvertex-1, &jarc->pwlArc->pts[1] ) );
|
||||
jarc->pwlArc->npts = 2;
|
||||
jarc->pwlArc->pts = newjunk;
|
||||
jarc2->next = jarc->next;
|
||||
jarc2->next->prev = jarc2;
|
||||
jarc->next = jarc1;
|
||||
jarc1->prev = jarc;
|
||||
jarc1->next = jarc2;
|
||||
jarc2->prev = jarc1;
|
||||
assert(jarc->check() != 0);
|
||||
return 32;
|
||||
|
||||
// It's somewhere in the middle
|
||||
} else {
|
||||
jarc1 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk ) );
|
||||
jarc2 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk+1 ) );
|
||||
jarc3 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( maxvertex-i, v+i ) );
|
||||
jarc->pwlArc->npts = j + 1;
|
||||
jarc3->next = jarc->next;
|
||||
jarc3->next->prev = jarc3;
|
||||
jarc->next = jarc1;
|
||||
jarc1->prev = jarc;
|
||||
jarc1->next = jarc2;
|
||||
jarc2->prev = jarc1;
|
||||
jarc2->next = jarc3;
|
||||
jarc3->prev = jarc2;
|
||||
assert(jarc->check() != 0);
|
||||
return 4;
|
||||
}
|
||||
#endif // NOTDEF
|
||||
}
|
||||
default:
|
||||
return -1; //picked -1 since it's not used
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* pwlarc_intersect - find intersection of pwlArc and isoparametric line
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static enum i_result
|
||||
pwlarc_intersect(
|
||||
PwlArc *pwlArc,
|
||||
int param,
|
||||
REAL value,
|
||||
int dir,
|
||||
int loc[3] )
|
||||
{
|
||||
assert( pwlArc->npts > 0 );
|
||||
|
||||
if( dir ) {
|
||||
TrimVertex *v = pwlArc->pts;
|
||||
int imin = 0;
|
||||
int imax = pwlArc->npts - 1;
|
||||
assert( value > v[imin].param[param] );
|
||||
assert( value < v[imax].param[param] );
|
||||
while( (imax - imin) > 1 ) {
|
||||
int imid = (imax + imin)/2;
|
||||
if( v[imid].param[param] > value )
|
||||
imax = imid;
|
||||
else if( v[imid].param[param] < value )
|
||||
imin = imid;
|
||||
else {
|
||||
loc[1] = imid;
|
||||
return INTERSECT_VERTEX;
|
||||
}
|
||||
}
|
||||
loc[0] = imin;
|
||||
loc[2] = imax;
|
||||
return INTERSECT_EDGE;
|
||||
} else {
|
||||
TrimVertex *v = pwlArc->pts;
|
||||
int imax = 0;
|
||||
int imin = pwlArc->npts - 1;
|
||||
assert( value > v[imin].param[param] );
|
||||
assert( value < v[imax].param[param] );
|
||||
while( (imin - imax) > 1 ) {
|
||||
int imid = (imax + imin)/2;
|
||||
if( v[imid].param[param] > value )
|
||||
imax = imid;
|
||||
else if( v[imid].param[param] < value )
|
||||
imin = imid;
|
||||
else {
|
||||
loc[1] = imid;
|
||||
return INTERSECT_VERTEX;
|
||||
}
|
||||
}
|
||||
loc[0] = imin;
|
||||
loc[2] = imax;
|
||||
return INTERSECT_EDGE;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* arc_classify - determine which side of a line a jarc lies
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef NDEBUG // for asserts only
|
||||
static int
|
||||
arc_classify( Arc_ptr jarc, int param, REAL value )
|
||||
{
|
||||
REAL tdiff, hdiff;
|
||||
if( param == 0 ) {
|
||||
tdiff = jarc->tail()[0] - value;
|
||||
hdiff = jarc->head()[0] - value;
|
||||
} else {
|
||||
tdiff = jarc->tail()[1] - value;
|
||||
hdiff = jarc->head()[1] - value;
|
||||
}
|
||||
|
||||
if( tdiff > 0.0 ) {
|
||||
if( hdiff > 0.0 ) {
|
||||
return 0x11;
|
||||
} else if( hdiff == 0.0 ) {
|
||||
return 0x12;
|
||||
} else {
|
||||
return 0x10;
|
||||
}
|
||||
} else if( tdiff == 0.0 ) {
|
||||
if( hdiff > 0.0 ) {
|
||||
return 0x21;
|
||||
} else if( hdiff == 0.0 ) {
|
||||
return 0x22;
|
||||
} else {
|
||||
return 0x20;
|
||||
}
|
||||
} else {
|
||||
if( hdiff > 0.0 ) {
|
||||
return 0x01;
|
||||
} else if( hdiff == 0.0 ) {
|
||||
return 0x02;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
Subdivider::classify_tailonleft_s( Bin& bin, Bin& in, Bin& out, REAL val )
|
||||
{
|
||||
/* tail at left, head on line */
|
||||
Arc_ptr j;
|
||||
|
||||
while( (j = bin.removearc()) != NULL ) {
|
||||
assert( arc_classify( j, 0, val ) == 0x02 );
|
||||
j->clearitail();
|
||||
|
||||
REAL diff = j->next->head()[0] - val;
|
||||
if( diff > 0.0 ) {
|
||||
in.addarc( j );
|
||||
} else if( diff < 0.0 ) {
|
||||
if( ccwTurn_sl( j, j->next ) )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
} else {
|
||||
if( j->next->tail()[1] > j->next->head()[1] )
|
||||
in.addarc(j);
|
||||
else
|
||||
out.addarc(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Subdivider::classify_tailonleft_t( Bin& bin, Bin& in, Bin& out, REAL val )
|
||||
{
|
||||
/* tail at left, head on line */
|
||||
Arc_ptr j;
|
||||
|
||||
while( (j = bin.removearc()) != NULL ) {
|
||||
assert( arc_classify( j, 1, val ) == 0x02 );
|
||||
j->clearitail();
|
||||
|
||||
REAL diff = j->next->head()[1] - val;
|
||||
if( diff > 0.0 ) {
|
||||
in.addarc( j );
|
||||
} else if( diff < 0.0 ) {
|
||||
if( ccwTurn_tl( j, j->next ) )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
} else {
|
||||
if (j->next->tail()[0] > j->next->head()[0] )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Subdivider::classify_headonleft_s( Bin& bin, Bin& in, Bin& out, REAL val )
|
||||
{
|
||||
/* tail on line, head at left */
|
||||
Arc_ptr j;
|
||||
|
||||
while( (j = bin.removearc()) != NULL ) {
|
||||
assert( arc_classify( j, 0, val ) == 0x20 );
|
||||
|
||||
j->setitail();
|
||||
|
||||
REAL diff = j->prev->tail()[0] - val;
|
||||
if( diff > 0.0 ) {
|
||||
out.addarc( j );
|
||||
} else if( diff < 0.0 ) {
|
||||
if( ccwTurn_sl( j->prev, j ) )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
} else {
|
||||
if( j->prev->tail()[1] > j->prev->head()[1] )
|
||||
in.addarc( j );
|
||||
else
|
||||
out.addarc( j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Subdivider::classify_headonleft_t( Bin& bin, Bin& in, Bin& out, REAL val )
|
||||
{
|
||||
/* tail on line, head at left */
|
||||
Arc_ptr j;
|
||||
|
||||
while( (j = bin.removearc()) != NULL ) {
|
||||
assert( arc_classify( j, 1, val ) == 0x20 );
|
||||
j->setitail();
|
||||
|
||||
REAL diff = j->prev->tail()[1] - val;
|
||||
if( diff > 0.0 ) {
|
||||
out.addarc( j );
|
||||
} else if( diff < 0.0 ) {
|
||||
if( ccwTurn_tl( j->prev, j ) )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
} else {
|
||||
if( j->prev->tail()[0] > j->prev->head()[0] )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Subdivider::classify_tailonright_s( Bin& bin, Bin& in, Bin& out, REAL val )
|
||||
{
|
||||
/* tail at right, head on line */
|
||||
Arc_ptr j;
|
||||
|
||||
while( (j = bin.removearc()) != NULL ) {
|
||||
assert( arc_classify( j, 0, val ) == 0x12);
|
||||
|
||||
j->clearitail();
|
||||
|
||||
REAL diff = j->next->head()[0] - val;
|
||||
if( diff > 0.0 ) {
|
||||
if( ccwTurn_sr( j, j->next ) )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
} else if( diff < 0.0 ) {
|
||||
in.addarc( j );
|
||||
} else {
|
||||
if( j->next->tail()[1] > j->next->head()[1] )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Subdivider::classify_tailonright_t( Bin& bin, Bin& in, Bin& out, REAL val )
|
||||
{
|
||||
/* tail at right, head on line */
|
||||
Arc_ptr j;
|
||||
|
||||
while( (j = bin.removearc()) != NULL ) {
|
||||
assert( arc_classify( j, 1, val ) == 0x12);
|
||||
|
||||
j->clearitail();
|
||||
|
||||
REAL diff = j->next->head()[1] - val;
|
||||
if( diff > 0.0 ) {
|
||||
if( ccwTurn_tr( j, j->next ) )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
} else if( diff < 0.0 ) {
|
||||
in.addarc( j );
|
||||
} else {
|
||||
if( j->next->tail()[0] > j->next->head()[0] )
|
||||
in.addarc( j );
|
||||
else
|
||||
out.addarc( j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Subdivider::classify_headonright_s( Bin& bin, Bin& in, Bin& out, REAL val )
|
||||
{
|
||||
/* tail on line, head at right */
|
||||
Arc_ptr j;
|
||||
|
||||
while( (j = bin.removearc()) != NULL ) {
|
||||
assert( arc_classify( j, 0, val ) == 0x21 );
|
||||
|
||||
j->setitail();
|
||||
|
||||
REAL diff = j->prev->tail()[0] - val;
|
||||
if( diff > 0.0 ) {
|
||||
if( ccwTurn_sr( j->prev, j ) )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
} else if( diff < 0.0 ) {
|
||||
out.addarc( j );
|
||||
} else {
|
||||
if( j->prev->tail()[1] > j->prev->head()[1] )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Subdivider::classify_headonright_t( Bin& bin, Bin& in, Bin& out, REAL val )
|
||||
{
|
||||
/* tail on line, head at right */
|
||||
Arc_ptr j;
|
||||
|
||||
while( (j = bin.removearc()) != NULL ) {
|
||||
assert( arc_classify( j, 1, val ) == 0x21 );
|
||||
|
||||
j->setitail();
|
||||
|
||||
REAL diff = j->prev->tail()[1] - val;
|
||||
if( diff > 0.0 ) {
|
||||
if( ccwTurn_tr( j->prev, j ) )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
} else if( diff < 0.0 ) {
|
||||
out.addarc( j );
|
||||
} else {
|
||||
if( j->prev->tail()[0] > j->prev->head()[0] )
|
||||
in.addarc( j );
|
||||
else
|
||||
out.addarc( j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* jarcloc.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glujarcloc_h_
|
||||
#define __glujarcloc_h_
|
||||
|
||||
#include "arc.h"
|
||||
|
||||
class Jarcloc {
|
||||
private:
|
||||
Arc_ptr arc;
|
||||
TrimVertex *p;
|
||||
TrimVertex *plast;
|
||||
public:
|
||||
inline void init( Arc_ptr a, long first, long last ) { arc = a; p=&a->pwlArc->pts[first]; plast = &a->pwlArc->pts[last]; }
|
||||
inline TrimVertex * getnextpt( void );
|
||||
inline TrimVertex * getprevpt( void );
|
||||
inline void reverse();
|
||||
};
|
||||
|
||||
inline void
|
||||
Jarcloc::reverse()
|
||||
{
|
||||
if( plast == &arc->pwlArc->pts[0] )
|
||||
plast = &arc->pwlArc->pts[arc->pwlArc->npts - 1];
|
||||
else
|
||||
plast = &arc->pwlArc->pts[0];
|
||||
}
|
||||
|
||||
inline TrimVertex *
|
||||
Jarcloc::getnextpt()
|
||||
{
|
||||
assert( p <= plast );
|
||||
if( p == plast ) {
|
||||
arc = arc->next;
|
||||
p = &arc->pwlArc->pts[0];
|
||||
plast = &arc->pwlArc->pts[arc->pwlArc->npts - 1];
|
||||
assert( p < plast );
|
||||
}
|
||||
return p++;
|
||||
}
|
||||
|
||||
inline TrimVertex *
|
||||
Jarcloc::getprevpt()
|
||||
{
|
||||
assert( p >= plast );
|
||||
if( p == plast ) {
|
||||
arc = arc->prev;
|
||||
p = &arc->pwlArc->pts[arc->pwlArc->npts - 1];
|
||||
plast = &arc->pwlArc->pts[0];
|
||||
assert( p > plast );
|
||||
}
|
||||
return p--;
|
||||
}
|
||||
#endif /* __glujarcloc_h_ */
|
||||
|
|
@ -1,142 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* knotvector.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "knotvector.h"
|
||||
#include "defines.h"
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
#pragma warning 726 10
|
||||
#endif
|
||||
|
||||
void Knotvector::init( long _knotcount, long _stride, long _order, INREAL *_knotlist )
|
||||
{
|
||||
knotcount = _knotcount;
|
||||
stride = _stride;
|
||||
order = _order;
|
||||
knotlist = new Knot[_knotcount];
|
||||
assert( knotlist != 0 );
|
||||
|
||||
for( int i = 0; i != _knotcount; i++ )
|
||||
knotlist[i] = (Knot) _knotlist[i];
|
||||
}
|
||||
|
||||
Knotvector::Knotvector( void )
|
||||
{
|
||||
knotcount = 0;
|
||||
stride = 0;
|
||||
order = 0;
|
||||
knotlist = 0;
|
||||
}
|
||||
|
||||
Knotvector::~Knotvector( void )
|
||||
{
|
||||
if( knotlist ) delete[] knotlist;
|
||||
}
|
||||
|
||||
int Knotvector::validate( void )
|
||||
{
|
||||
/* kindex is used as an array index so subtract one first,
|
||||
* this propagates throughout the code so study carefully */
|
||||
long kindex = knotcount-1;
|
||||
|
||||
if( order < 1 || order > MAXORDER ) {
|
||||
// spline order un-supported
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
if( knotcount < (2 * order) ) {
|
||||
// too few knots
|
||||
return( 2 );
|
||||
}
|
||||
|
||||
if( identical( knotlist[kindex-(order-1)], knotlist[order-1]) ) {
|
||||
// valid knot range is empty
|
||||
return( 3 );
|
||||
}
|
||||
|
||||
for( long i = 0; i < kindex; i++)
|
||||
if( knotlist[i] > knotlist[i+1] ) {
|
||||
// decreasing knot sequence
|
||||
return( 4 );
|
||||
}
|
||||
|
||||
/* check for valid multiplicity */
|
||||
|
||||
/* kindex is currently the index of the last knot.
|
||||
* In the next loop it is decremented to ignore the last knot
|
||||
* and the loop stops when kindex is 2 so as to ignore the first
|
||||
* knot as well. These knots are not used in computing
|
||||
* knot multiplicities.
|
||||
*/
|
||||
|
||||
long multi = 1;
|
||||
for( ; kindex >= 1; kindex-- ) {
|
||||
if( knotlist[kindex] - knotlist[kindex-1] < TOLERANCE ) {
|
||||
multi++;
|
||||
continue;
|
||||
}
|
||||
if ( multi > order ) {
|
||||
// knot multiplicity greater than order of spline
|
||||
return( 5 );
|
||||
}
|
||||
multi = 1;
|
||||
}
|
||||
|
||||
if ( multi > order ) {
|
||||
// knot multiplicity greater than order of spline
|
||||
return( 5 );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Knotvector::show( const char *msg )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
_glu_dprintf( "%s\n", msg );
|
||||
_glu_dprintf( "order = %ld, count = %ld\n", order, knotcount );
|
||||
|
||||
for( int i=0; i<knotcount; i++ )
|
||||
_glu_dprintf( "knot[%d] = %g\n", i, knotlist[i] );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* knotvector.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __gluknotvector_h_
|
||||
#define __gluknotvector_h_
|
||||
|
||||
#include "types.h"
|
||||
|
||||
struct Knotvector { /* a knot vector */
|
||||
Knotvector( void );
|
||||
~Knotvector( void );
|
||||
void init( long, long, long, INREAL * );
|
||||
int validate( void );
|
||||
void show( const char * );
|
||||
|
||||
long order; /* order of spline */
|
||||
long knotcount; /* number of knots */
|
||||
long stride; /* bytes between points */
|
||||
Knot * knotlist; /* global knot vector */
|
||||
};
|
||||
|
||||
/* tolerance to test knot coincidence */
|
||||
#define TOLERANCE 1.0e-5
|
||||
|
||||
inline int
|
||||
identical( Knot x, Knot y )
|
||||
{
|
||||
return ((x-y) < TOLERANCE) ? 1 : 0;
|
||||
}
|
||||
#endif /* __gluknotvector_h_ */
|
||||
|
|
@ -1,841 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mapdesc.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "mystring.h"
|
||||
#include "mymath.h"
|
||||
#include "backend.h"
|
||||
#include "nurbsconsts.h"
|
||||
#include "mapdesc.h"
|
||||
|
||||
Mapdesc::Mapdesc( long _type, int _israt, int _ncoords, Backend& b )
|
||||
: backend( b )
|
||||
{
|
||||
type = _type;
|
||||
isrational = _israt;
|
||||
ncoords = _ncoords;
|
||||
hcoords = _ncoords + (_israt ? 0 : 1 );
|
||||
inhcoords = _ncoords - (_israt ? 1 : 0 );
|
||||
mask = ((1<<(inhcoords*2))-1);
|
||||
next = 0;
|
||||
|
||||
assert( hcoords <= MAXCOORDS );
|
||||
assert( inhcoords >= 1 );
|
||||
|
||||
pixel_tolerance = 1.0;
|
||||
error_tolerance = 1.0;
|
||||
bbox_subdividing = N_NOBBOXSUBDIVISION;
|
||||
culling_method = N_NOCULLING;
|
||||
sampling_method = N_NOSAMPLING;
|
||||
clampfactor = N_NOCLAMPING;
|
||||
minsavings = N_NOSAVINGSSUBDIVISION;
|
||||
s_steps = 0.0;
|
||||
t_steps = 0.0;
|
||||
maxrate = ( s_steps < 0.0 ) ? 0.0 : s_steps;
|
||||
maxsrate = ( s_steps < 0.0 ) ? 0.0 : s_steps;
|
||||
maxtrate = ( t_steps < 0.0 ) ? 0.0 : t_steps;
|
||||
identify( bmat );
|
||||
identify( cmat );
|
||||
identify( smat );
|
||||
for( int i = 0; i != inhcoords; i++ )
|
||||
bboxsize[i] = 1.0;
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::setBboxsize( INREAL *mat )
|
||||
{
|
||||
for( int i = 0; i != inhcoords; i++ )
|
||||
bboxsize[i] = (REAL) mat[i];
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::identify( REAL dest[MAXCOORDS][MAXCOORDS] )
|
||||
{
|
||||
memset( dest, 0, sizeof( REAL ) * MAXCOORDS * MAXCOORDS );
|
||||
for( int i=0; i != hcoords; i++ )
|
||||
dest[i][i] = 1.0;
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::surfbbox( REAL bb[2][MAXCOORDS] )
|
||||
{
|
||||
backend.surfbbox( type, bb[0], bb[1] );
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::copy( REAL dest[MAXCOORDS][MAXCOORDS], long n, INREAL *src,
|
||||
long rstride, long cstride )
|
||||
{
|
||||
assert( n >= 0 );
|
||||
for( int i=0; i != n; i++ )
|
||||
for( int j=0; j != n; j++ )
|
||||
dest[i][j] = src[i*rstride + j*cstride];
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* copyPt - copy a homogeneous point
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Mapdesc::copyPt( REAL *d, REAL *s )
|
||||
{
|
||||
assert( hcoords > 0 );
|
||||
switch( hcoords ) {
|
||||
case 4:
|
||||
d[3] = s[3];
|
||||
d[2] = s[2];
|
||||
d[1] = s[1];
|
||||
d[0] = s[0];
|
||||
break;
|
||||
case 3:
|
||||
d[2] = s[2];
|
||||
d[1] = s[1];
|
||||
d[0] = s[0];
|
||||
break;
|
||||
case 2:
|
||||
d[1] = s[1];
|
||||
d[0] = s[0];
|
||||
break;
|
||||
case 1:
|
||||
d[0] = s[0];
|
||||
break;
|
||||
case 5:
|
||||
d[4] = s[4];
|
||||
d[3] = s[3];
|
||||
d[2] = s[2];
|
||||
d[1] = s[1];
|
||||
d[0] = s[0];
|
||||
break;
|
||||
default:
|
||||
memcpy( d, s, hcoords * sizeof( REAL ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* sumPt - compute affine combination of two homogeneous points
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Mapdesc::sumPt( REAL *dst, REAL *src1, REAL *src2, register REAL alpha, register REAL beta )
|
||||
{
|
||||
assert( hcoords > 0 );
|
||||
switch( hcoords ) {
|
||||
case 4:
|
||||
dst[3] = src1[3] * alpha + src2[3] * beta;
|
||||
dst[2] = src1[2] * alpha + src2[2] * beta;
|
||||
dst[1] = src1[1] * alpha + src2[1] * beta;
|
||||
dst[0] = src1[0] * alpha + src2[0] * beta;
|
||||
break;
|
||||
case 3:
|
||||
dst[2] = src1[2] * alpha + src2[2] * beta;
|
||||
dst[1] = src1[1] * alpha + src2[1] * beta;
|
||||
dst[0] = src1[0] * alpha + src2[0] * beta;
|
||||
break;
|
||||
case 2:
|
||||
dst[1] = src1[1] * alpha + src2[1] * beta;
|
||||
dst[0] = src1[0] * alpha + src2[0] * beta;
|
||||
break;
|
||||
case 1:
|
||||
dst[0] = src1[0] * alpha + src2[0] * beta;
|
||||
break;
|
||||
case 5:
|
||||
dst[4] = src1[4] * alpha + src2[4] * beta;
|
||||
dst[3] = src1[3] * alpha + src2[3] * beta;
|
||||
dst[2] = src1[2] * alpha + src2[2] * beta;
|
||||
dst[1] = src1[1] * alpha + src2[1] * beta;
|
||||
dst[0] = src1[0] * alpha + src2[0] * beta;
|
||||
break;
|
||||
default: {
|
||||
for( int i = 0; i != hcoords; i++ )
|
||||
dst[i] = src1[i] * alpha + src2[i] * beta;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* clipbits - compute bit-vector indicating point/window position
|
||||
* of a (transformed) homogeneous point
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
unsigned int
|
||||
Mapdesc::clipbits( REAL *p )
|
||||
{
|
||||
assert( inhcoords >= 0 );
|
||||
assert( inhcoords <= 3 );
|
||||
|
||||
register int nc = inhcoords;
|
||||
register REAL pw = p[nc];
|
||||
register REAL nw = -pw;
|
||||
register unsigned int bits = 0;
|
||||
|
||||
if( pw == 0.0 ) return mask;
|
||||
|
||||
if( pw > 0.0 ) {
|
||||
switch( nc ) {
|
||||
case 3:
|
||||
if( p[2] <= pw ) bits |= (1<<5);
|
||||
if( p[2] >= nw ) bits |= (1<<4);
|
||||
if( p[1] <= pw ) bits |= (1<<3);
|
||||
if( p[1] >= nw ) bits |= (1<<2);
|
||||
if( p[0] <= pw ) bits |= (1<<1);
|
||||
if( p[0] >= nw ) bits |= (1<<0);
|
||||
return bits;
|
||||
case 2:
|
||||
if( p[1] <= pw ) bits |= (1<<3);
|
||||
if( p[1] >= nw ) bits |= (1<<2);
|
||||
if( p[0] <= pw ) bits |= (1<<1);
|
||||
if( p[0] >= nw ) bits |= (1<<0);
|
||||
return bits;
|
||||
case 1:
|
||||
if( p[0] <= pw ) bits |= (1<<1);
|
||||
if( p[0] >= nw ) bits |= (1<<0);
|
||||
return bits;
|
||||
default: {
|
||||
int bit = 1;
|
||||
for( int i=0; i<nc; i++ ) {
|
||||
if( p[i] >= nw ) bits |= bit;
|
||||
bit <<= 1;
|
||||
if( p[i] <= pw ) bits |= bit;
|
||||
bit <<= 1;
|
||||
}
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch( nc ) {
|
||||
case 3:
|
||||
if( p[2] <= nw ) bits |= (1<<5);
|
||||
if( p[2] >= pw ) bits |= (1<<4);
|
||||
if( p[1] <= nw ) bits |= (1<<3);
|
||||
if( p[1] >= pw ) bits |= (1<<2);
|
||||
if( p[0] <= nw ) bits |= (1<<1);
|
||||
if( p[0] >= pw ) bits |= (1<<0);
|
||||
return bits;
|
||||
case 2:
|
||||
if( p[1] <= nw ) bits |= (1<<3);
|
||||
if( p[1] >= pw ) bits |= (1<<2);
|
||||
if( p[0] <= nw ) bits |= (1<<1);
|
||||
if( p[0] >= pw ) bits |= (1<<0);
|
||||
return bits;
|
||||
case 1:
|
||||
if( p[0] <= nw ) bits |= (1<<1);
|
||||
if( p[0] >= pw ) bits |= (1<<0);
|
||||
return bits;
|
||||
default: {
|
||||
int bit = 1;
|
||||
for( int i=0; i<nc; i++ ) {
|
||||
if( p[i] >= pw ) bits |= bit;
|
||||
bit <<= 1;
|
||||
if( p[i] <= nw ) bits |= bit;
|
||||
bit <<= 1;
|
||||
}
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bits;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* xformRational - transform a homogeneous point
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Mapdesc::xformRational( Maxmatrix mat, REAL *d, REAL *s )
|
||||
{
|
||||
assert( hcoords >= 0 );
|
||||
|
||||
if( hcoords == 3 ) {
|
||||
REAL x = s[0];
|
||||
REAL y = s[1];
|
||||
REAL z = s[2];
|
||||
d[0] = x*mat[0][0]+y*mat[1][0]+z*mat[2][0];
|
||||
d[1] = x*mat[0][1]+y*mat[1][1]+z*mat[2][1];
|
||||
d[2] = x*mat[0][2]+y*mat[1][2]+z*mat[2][2];
|
||||
} else if( hcoords == 4 ) {
|
||||
REAL x = s[0];
|
||||
REAL y = s[1];
|
||||
REAL z = s[2];
|
||||
REAL w = s[3];
|
||||
d[0] = x*mat[0][0]+y*mat[1][0]+z*mat[2][0]+w*mat[3][0];
|
||||
d[1] = x*mat[0][1]+y*mat[1][1]+z*mat[2][1]+w*mat[3][1];
|
||||
d[2] = x*mat[0][2]+y*mat[1][2]+z*mat[2][2]+w*mat[3][2];
|
||||
d[3] = x*mat[0][3]+y*mat[1][3]+z*mat[2][3]+w*mat[3][3];
|
||||
} else {
|
||||
for( int i=0; i != hcoords; i++ ) {
|
||||
d[i] = 0;
|
||||
for( int j = 0; j != hcoords; j++ )
|
||||
d[i] += s[j] * mat[j][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* xformNonrational - transform a inhomogeneous point to a homogeneous point
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Mapdesc::xformNonrational( Maxmatrix mat, REAL *d, REAL *s )
|
||||
{
|
||||
if( inhcoords == 2 ) {
|
||||
REAL x = s[0];
|
||||
REAL y = s[1];
|
||||
d[0] = x*mat[0][0]+y*mat[1][0]+mat[2][0];
|
||||
d[1] = x*mat[0][1]+y*mat[1][1]+mat[2][1];
|
||||
d[2] = x*mat[0][2]+y*mat[1][2]+mat[2][2];
|
||||
} else if( inhcoords == 3 ) {
|
||||
REAL x = s[0];
|
||||
REAL y = s[1];
|
||||
REAL z = s[2];
|
||||
d[0] = x*mat[0][0]+y*mat[1][0]+z*mat[2][0]+mat[3][0];
|
||||
d[1] = x*mat[0][1]+y*mat[1][1]+z*mat[2][1]+mat[3][1];
|
||||
d[2] = x*mat[0][2]+y*mat[1][2]+z*mat[2][2]+mat[3][2];
|
||||
d[3] = x*mat[0][3]+y*mat[1][3]+z*mat[2][3]+mat[3][3];
|
||||
} else {
|
||||
assert( inhcoords >= 0 );
|
||||
for( int i=0; i != hcoords; i++ ) {
|
||||
d[i] = mat[inhcoords][i];
|
||||
for( int j = 0; j < inhcoords; j++ )
|
||||
d[i] += s[j] * mat[j][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* xformAndCullCheck - transform a set of points that may be EITHER
|
||||
* homogeneous or inhomogeneous depending on the map description and
|
||||
* check if they are either completely inside, completely outside,
|
||||
* or intersecting the viewing frustrum.
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Mapdesc::xformAndCullCheck(
|
||||
REAL *pts, int uorder, int ustride, int vorder, int vstride )
|
||||
{
|
||||
assert( uorder > 0 );
|
||||
assert( vorder > 0 );
|
||||
|
||||
unsigned int inbits = mask;
|
||||
unsigned int outbits = 0;
|
||||
|
||||
REAL *p = pts;
|
||||
for( REAL *pend = p + uorder * ustride; p != pend; p += ustride ) {
|
||||
REAL *q = p;
|
||||
for( REAL *qend = q + vorder * vstride; q != qend; q += vstride ) {
|
||||
REAL cpts[MAXCOORDS];
|
||||
xformCulling( cpts, q );
|
||||
unsigned int bits = clipbits( cpts );
|
||||
outbits |= bits;
|
||||
inbits &= bits;
|
||||
if( ( outbits == (unsigned int)mask ) && ( inbits != (unsigned int)mask ) ) return CULL_ACCEPT;
|
||||
}
|
||||
}
|
||||
|
||||
if( outbits != (unsigned int)mask ) {
|
||||
return CULL_TRIVIAL_REJECT;
|
||||
} else if( inbits == (unsigned int)mask ) {
|
||||
return CULL_TRIVIAL_ACCEPT;
|
||||
} else {
|
||||
return CULL_ACCEPT;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* cullCheck - check if a set of homogeneous transformed points are
|
||||
* either completely inside, completely outside,
|
||||
* or intersecting the viewing frustrum.
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Mapdesc::cullCheck( REAL *pts, int uorder, int ustride, int vorder, int vstride )
|
||||
{
|
||||
unsigned int inbits = mask;
|
||||
unsigned int outbits = 0;
|
||||
|
||||
REAL *p = pts;
|
||||
for( REAL *pend = p + uorder * ustride; p != pend; p += ustride ) {
|
||||
REAL *q = p;
|
||||
for( REAL *qend = q + vorder * vstride; q != qend; q += vstride ) {
|
||||
unsigned int bits = clipbits( q );
|
||||
outbits |= bits;
|
||||
inbits &= bits;
|
||||
if( ( outbits == (unsigned int)mask ) && ( inbits != (unsigned int)mask ) ) return CULL_ACCEPT;
|
||||
}
|
||||
}
|
||||
|
||||
if( outbits != (unsigned int)mask ) {
|
||||
return CULL_TRIVIAL_REJECT;
|
||||
} else if( inbits == (unsigned int)mask ) {
|
||||
return CULL_TRIVIAL_ACCEPT;
|
||||
} else {
|
||||
return CULL_ACCEPT;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* cullCheck - check if a set of homogeneous transformed points are
|
||||
* either completely inside, completely outside,
|
||||
* or intersecting the viewing frustrum.
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Mapdesc::cullCheck( REAL *pts, int order, int stride )
|
||||
{
|
||||
unsigned int inbits = mask;
|
||||
unsigned int outbits = 0;
|
||||
|
||||
REAL *p = pts;
|
||||
for( REAL *pend = p + order * stride; p != pend; p += stride ) {
|
||||
unsigned int bits = clipbits( p );
|
||||
outbits |= bits;
|
||||
inbits &= bits;
|
||||
if( ( outbits == (unsigned int)mask ) && ( inbits != (unsigned int)mask ) ) return CULL_ACCEPT;
|
||||
}
|
||||
|
||||
if( outbits != (unsigned int)mask ) {
|
||||
return CULL_TRIVIAL_REJECT;
|
||||
} else if( inbits == (unsigned int)mask ) {
|
||||
return CULL_TRIVIAL_ACCEPT;
|
||||
} else {
|
||||
return CULL_ACCEPT;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* xformSampling - transform a set of points that may be EITHER
|
||||
* homogeneous or inhomogeneous depending on the map description
|
||||
* into sampling space
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Mapdesc::xformSampling( REAL *pts, int order, int stride, REAL *sp, int outstride )
|
||||
{
|
||||
xformMat( smat, pts, order, stride, sp, outstride );
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::xformBounding( REAL *pts, int order, int stride, REAL *sp, int outstride )
|
||||
{
|
||||
xformMat( bmat, pts, order, stride, sp, outstride );
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* xformCulling - transform a set of points that may be EITHER
|
||||
* homogeneous or inhomogeneous depending on the map description
|
||||
* into culling space
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Mapdesc::xformCulling( REAL *pts, int order, int stride, REAL *cp, int outstride )
|
||||
{
|
||||
xformMat( cmat, pts, order, stride, cp, outstride );
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* xformCulling - transform a set of points that may be EITHER
|
||||
* homogeneous or inhomogeneous depending on the map description
|
||||
* into culling space
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Mapdesc::xformCulling( REAL *pts,
|
||||
int uorder, int ustride,
|
||||
int vorder, int vstride,
|
||||
REAL *cp, int outustride, int outvstride )
|
||||
{
|
||||
xformMat( cmat, pts, uorder, ustride, vorder, vstride, cp, outustride, outvstride );
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* xformSampling - transform a set of points that may be EITHER
|
||||
* homogeneous or inhomogeneous depending on the map description
|
||||
* into sampling space
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Mapdesc::xformSampling( REAL *pts,
|
||||
int uorder, int ustride,
|
||||
int vorder, int vstride,
|
||||
REAL *sp, int outustride, int outvstride )
|
||||
{
|
||||
xformMat( smat, pts, uorder, ustride, vorder, vstride, sp, outustride, outvstride );
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::xformBounding( REAL *pts,
|
||||
int uorder, int ustride,
|
||||
int vorder, int vstride,
|
||||
REAL *sp, int outustride, int outvstride )
|
||||
{
|
||||
xformMat( bmat, pts, uorder, ustride, vorder, vstride, sp, outustride, outvstride );
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::xformMat(
|
||||
Maxmatrix mat,
|
||||
REAL * pts,
|
||||
int order,
|
||||
int stride,
|
||||
REAL * cp,
|
||||
int outstride )
|
||||
{
|
||||
if( isrational ) {
|
||||
REAL *pend = pts + order * stride;
|
||||
for( REAL *p = pts ; p != pend; p += stride ) {
|
||||
xformRational( mat, cp, p );
|
||||
cp += outstride;
|
||||
}
|
||||
} else {
|
||||
REAL *pend = pts + order * stride;
|
||||
for( REAL *p = pts ; p != pend; p += stride ) {
|
||||
xformNonrational( mat, cp, p );
|
||||
cp += outstride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::xformMat( Maxmatrix mat, REAL *pts,
|
||||
int uorder, int ustride,
|
||||
int vorder, int vstride,
|
||||
REAL *cp, int outustride, int outvstride )
|
||||
{
|
||||
if( isrational ) {
|
||||
REAL *pend = pts + uorder * ustride;
|
||||
for( REAL *p = pts ; p != pend; p += ustride ) {
|
||||
REAL *cpts2 = cp;
|
||||
REAL *qend = p + vorder * vstride;
|
||||
for( REAL *q = p; q != qend; q += vstride ) {
|
||||
xformRational( mat, cpts2, q );
|
||||
cpts2 += outvstride;
|
||||
}
|
||||
cp += outustride;
|
||||
}
|
||||
} else {
|
||||
REAL *pend = pts + uorder * ustride;
|
||||
for( REAL *p = pts ; p != pend; p += ustride ) {
|
||||
REAL *cpts2 = cp;
|
||||
REAL *qend = p + vorder * vstride;
|
||||
for( REAL *q = p; q != qend; q += vstride ) {
|
||||
xformNonrational( mat, cpts2, q );
|
||||
cpts2 += outvstride;
|
||||
}
|
||||
cp += outustride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* subdivide - subdivide a curve along an isoparametric line
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Mapdesc::subdivide( REAL *src, REAL *dst, REAL v, int stride, int order )
|
||||
{
|
||||
REAL mv = 1.0 - v;
|
||||
|
||||
for( REAL *send=src+stride*order; src!=send; send-=stride, dst+=stride ) {
|
||||
copyPt( dst, src );
|
||||
REAL *qpnt = src + stride;
|
||||
for( REAL *qp=src; qpnt!=send; qp=qpnt, qpnt+=stride )
|
||||
sumPt( qp, qp, qpnt, mv, v );
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* subdivide - subdivide a patch along an isoparametric line
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Mapdesc::subdivide( REAL *src, REAL *dst, REAL v,
|
||||
int so, int ss, int to, int ts )
|
||||
{
|
||||
REAL mv = 1.0 - v;
|
||||
|
||||
for( REAL *slast = src+ss*so; src != slast; src += ss, dst += ss ) {
|
||||
REAL *sp = src;
|
||||
REAL *dp = dst;
|
||||
for( REAL *send = src+ts*to; sp != send; send -= ts, dp += ts ) {
|
||||
copyPt( dp, sp );
|
||||
REAL *qp = sp;
|
||||
for( REAL *qpnt = sp+ts; qpnt != send; qp = qpnt, qpnt += ts )
|
||||
sumPt( qp, qp, qpnt, mv, v );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define sign(x) ((x > 0) ? 1 : ((x < 0.0) ? -1 : 0))
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* project - project a set of homogeneous coordinates into inhomogeneous ones
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Mapdesc::project( REAL *src, int rstride, int cstride,
|
||||
REAL *dest, int trstride, int tcstride,
|
||||
int nrows, int ncols )
|
||||
{
|
||||
int s = sign( src[inhcoords] );
|
||||
REAL *rlast = src + nrows * rstride;
|
||||
REAL *trptr = dest;
|
||||
for( REAL *rptr=src; rptr != rlast; rptr+=rstride, trptr+=trstride ) {
|
||||
REAL *clast = rptr + ncols * cstride;
|
||||
REAL *tcptr = trptr;
|
||||
for( REAL *cptr = rptr; cptr != clast; cptr+=cstride, tcptr+=tcstride ) {
|
||||
REAL *coordlast = cptr + inhcoords;
|
||||
if( sign( *coordlast ) != s ) return 0;
|
||||
REAL *tcoord = tcptr;
|
||||
for( REAL *coord = cptr; coord != coordlast; coord++, tcoord++ ) {
|
||||
*tcoord = *coord / *coordlast;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* project - project a set of homogeneous coordinates into inhomogeneous ones
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Mapdesc::project( REAL *src, int stride, REAL *dest, int tstride, int ncols )
|
||||
{
|
||||
int s = sign( src[inhcoords] );
|
||||
|
||||
REAL *clast = src + ncols * stride;
|
||||
for( REAL *cptr = src, *tcptr = dest; cptr != clast; cptr+=stride, tcptr+=tstride ) {
|
||||
REAL *coordlast = cptr + inhcoords;
|
||||
if( sign( *coordlast ) != s ) return 0;
|
||||
for( REAL *coord = cptr, *tcoord = tcptr; coord != coordlast; coord++, tcoord++ )
|
||||
*tcoord = *coord / *coordlast;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
Mapdesc::bboxTooBig(
|
||||
REAL *p,
|
||||
int rstride,
|
||||
int cstride,
|
||||
int nrows,
|
||||
int ncols,
|
||||
REAL bb[2][MAXCOORDS] )
|
||||
{
|
||||
REAL bbpts[MAXORDER][MAXORDER][MAXCOORDS];
|
||||
const int trstride = sizeof(bbpts[0]) / sizeof(REAL);
|
||||
const int tcstride = sizeof(bbpts[0][0]) / sizeof(REAL);
|
||||
|
||||
// points have been transformed, therefore they are homogeneous
|
||||
// project points
|
||||
int val = project( p, rstride, cstride,
|
||||
&bbpts[0][0][0], trstride, tcstride, nrows, ncols );
|
||||
if( val == 0 ) return -1;
|
||||
|
||||
// compute bounding box
|
||||
bbox( bb, &bbpts[0][0][0], trstride, tcstride, nrows, ncols );
|
||||
|
||||
// find out if bounding box can't fit in unit cube
|
||||
if( bbox_subdividing == N_BBOXROUND ) {
|
||||
for( int k=0; k != inhcoords; k++ )
|
||||
if( ceilf(bb[1][k]) - floorf(bb[0][k]) > bboxsize[k] ) return 1;
|
||||
} else {
|
||||
for( int k=0; k != inhcoords; k++ )
|
||||
if( bb[1][k] - bb[0][k] > bboxsize[k] ) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::bbox(
|
||||
REAL bb[2][MAXCOORDS],
|
||||
REAL *p,
|
||||
int rstride,
|
||||
int cstride,
|
||||
int nrows,
|
||||
int ncols )
|
||||
{
|
||||
int k;
|
||||
for( k=0; k != inhcoords; k++ )
|
||||
bb[0][k] = bb[1][k] = p[k];
|
||||
|
||||
for( int i=0; i != nrows; i++ )
|
||||
for( int j=0; j != ncols; j++ )
|
||||
for( k=0; k != inhcoords; k++ ) {
|
||||
REAL x = p[i*rstride + j*cstride + k];
|
||||
if( x < bb[0][k] ) bb[0][k] = x;
|
||||
else if( x > bb[1][k] ) bb[1][k] = x;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* calcVelocityRational - calculate upper bound on first partial derivative
|
||||
* of a homogeneous set of points and bounds on each row of points.
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
REAL
|
||||
Mapdesc::calcVelocityRational( REAL *p, int stride, int ncols )
|
||||
{
|
||||
REAL tmp[MAXORDER][MAXCOORDS];
|
||||
|
||||
assert( ncols <= MAXORDER );
|
||||
|
||||
const int tstride = sizeof(tmp[0]) / sizeof(REAL);
|
||||
|
||||
if( project( p, stride, &tmp[0][0], tstride, ncols ) ) {
|
||||
return calcPartialVelocity( &tmp[0][0], tstride, ncols, 1, 1.0 );
|
||||
} else { /* XXX */
|
||||
return calcPartialVelocity( &tmp[0][0], tstride, ncols, 1, 1.0 );
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* calcVelocityNonrational - calculate upper bound on first partial
|
||||
* derivative of a inhomogeneous set of points.
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
REAL
|
||||
Mapdesc::calcVelocityNonrational( REAL *pts, int stride, int ncols )
|
||||
{
|
||||
return calcPartialVelocity( pts, stride, ncols, 1, 1.0 );
|
||||
}
|
||||
|
||||
int
|
||||
Mapdesc::isProperty( long property )
|
||||
{
|
||||
switch ( property ) {
|
||||
case N_PIXEL_TOLERANCE:
|
||||
case N_ERROR_TOLERANCE:
|
||||
case N_CULLING:
|
||||
case N_BBOX_SUBDIVIDING:
|
||||
case N_S_STEPS:
|
||||
case N_T_STEPS:
|
||||
case N_SAMPLINGMETHOD:
|
||||
case N_CLAMPFACTOR:
|
||||
case N_MINSAVINGS:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
REAL
|
||||
Mapdesc::getProperty( long property )
|
||||
{
|
||||
switch ( property ) {
|
||||
case N_PIXEL_TOLERANCE:
|
||||
return pixel_tolerance;
|
||||
case N_ERROR_TOLERANCE:
|
||||
return error_tolerance;
|
||||
case N_CULLING:
|
||||
return culling_method;
|
||||
case N_BBOX_SUBDIVIDING:
|
||||
return bbox_subdividing;
|
||||
case N_S_STEPS:
|
||||
return s_steps;
|
||||
case N_T_STEPS:
|
||||
return t_steps;
|
||||
case N_SAMPLINGMETHOD:
|
||||
return sampling_method;
|
||||
case N_CLAMPFACTOR:
|
||||
return clampfactor;
|
||||
case N_MINSAVINGS:
|
||||
return minsavings;
|
||||
default:
|
||||
abort();
|
||||
return -1; //not necessary, needed to shut up compiler
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::setProperty( long property, REAL value )
|
||||
{
|
||||
|
||||
switch ( property ) {
|
||||
case N_PIXEL_TOLERANCE:
|
||||
pixel_tolerance = value;
|
||||
break;
|
||||
case N_ERROR_TOLERANCE:
|
||||
error_tolerance = value;
|
||||
break;
|
||||
case N_CULLING:
|
||||
culling_method = value;
|
||||
break;
|
||||
case N_BBOX_SUBDIVIDING:
|
||||
if( value <= 0.0 ) value = N_NOBBOXSUBDIVISION;
|
||||
bbox_subdividing = value;
|
||||
break;
|
||||
case N_S_STEPS:
|
||||
if( value < 0.0 ) value = 0.0;
|
||||
s_steps = value;
|
||||
maxrate = ( value < 0.0 ) ? 0.0 : value;
|
||||
maxsrate = ( value < 0.0 ) ? 0.0 : value;
|
||||
break;
|
||||
case N_T_STEPS:
|
||||
if( value < 0.0 ) value = 0.0;
|
||||
t_steps = value;
|
||||
maxtrate = ( value < 0.0 ) ? 0.0 : value;
|
||||
break;
|
||||
case N_SAMPLINGMETHOD:
|
||||
sampling_method = value;
|
||||
break;
|
||||
case N_CLAMPFACTOR:
|
||||
if( value <= 0.0 ) value = N_NOCLAMPING;
|
||||
clampfactor = value;
|
||||
break;
|
||||
case N_MINSAVINGS:
|
||||
if( value <= 0.0 ) value = N_NOSAVINGSSUBDIVISION;
|
||||
minsavings = value;
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,271 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mapdesc.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glumapdesc_h_
|
||||
#define __glumapdesc_h_
|
||||
|
||||
#include "mystdio.h"
|
||||
#include "types.h"
|
||||
#include "defines.h"
|
||||
#include "bufpool.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
typedef REAL Maxmatrix[MAXCOORDS][MAXCOORDS];
|
||||
|
||||
class Backend;
|
||||
|
||||
class Mapdesc : public PooledObj {
|
||||
friend class Maplist;
|
||||
|
||||
public:
|
||||
Mapdesc( long, int, int, Backend & );
|
||||
int isProperty( long );
|
||||
REAL getProperty( long );
|
||||
void setProperty( long, REAL );
|
||||
int isConstantSampling( void );
|
||||
int isDomainSampling( void );
|
||||
int isRangeSampling( void );
|
||||
int isSampling( void );
|
||||
int isParametricDistanceSampling( void );
|
||||
int isObjectSpaceParaSampling( void );
|
||||
int isObjectSpacePathSampling( void );
|
||||
int isSurfaceAreaSampling( void );
|
||||
int isPathLengthSampling( void );
|
||||
int isCulling( void );
|
||||
int isBboxSubdividing( void );
|
||||
long getType( void );
|
||||
|
||||
/* curve routines */
|
||||
void subdivide( REAL *, REAL *, REAL, int, int );
|
||||
int cullCheck( REAL *, int, int );
|
||||
void xformBounding( REAL *, int, int, REAL *, int );
|
||||
void xformCulling( REAL *, int, int, REAL *, int );
|
||||
void xformSampling( REAL *, int, int, REAL *, int );
|
||||
void xformMat( Maxmatrix, REAL *, int, int, REAL *, int );
|
||||
REAL calcPartialVelocity ( REAL *, int, int, int, REAL );
|
||||
int project( REAL *, int, REAL *, int, int );
|
||||
REAL calcVelocityRational( REAL *, int, int );
|
||||
REAL calcVelocityNonrational( REAL *, int, int );
|
||||
|
||||
/* surface routines */
|
||||
void subdivide( REAL *, REAL *, REAL, int, int, int, int );
|
||||
int cullCheck( REAL *, int, int, int, int );
|
||||
void xformBounding( REAL *, int, int, int, int, REAL *, int, int );
|
||||
void xformCulling( REAL *, int, int, int, int, REAL *, int, int );
|
||||
void xformSampling( REAL *, int, int, int, int, REAL *, int, int );
|
||||
void xformMat( Maxmatrix, REAL *, int, int, int, int, REAL *, int, int );
|
||||
REAL calcPartialVelocity ( REAL *, REAL *, int, int, int, int, int, int, REAL, REAL, int );
|
||||
int project( REAL *, int, int, REAL *, int, int, int, int);
|
||||
void surfbbox( REAL bb[2][MAXCOORDS] );
|
||||
|
||||
int bboxTooBig( REAL *, int, int, int, int, REAL [2][MAXCOORDS] );
|
||||
int xformAndCullCheck( REAL *, int, int, int, int );
|
||||
|
||||
void identify( REAL[MAXCOORDS][MAXCOORDS] );
|
||||
void setBboxsize( INREAL *);
|
||||
inline void setBmat( INREAL*, long, long );
|
||||
inline void setCmat( INREAL*, long, long );
|
||||
inline void setSmat( INREAL*, long, long );
|
||||
inline int isRational( void );
|
||||
inline int getNcoords( void );
|
||||
|
||||
REAL pixel_tolerance; /* pathlength sampling tolerance */
|
||||
REAL error_tolerance; /* parametric error sampling tolerance*/
|
||||
REAL object_space_error_tolerance; /* object space tess*/
|
||||
REAL clampfactor;
|
||||
REAL minsavings;
|
||||
REAL maxrate;
|
||||
REAL maxsrate;
|
||||
REAL maxtrate;
|
||||
REAL bboxsize[MAXCOORDS];
|
||||
|
||||
private:
|
||||
long type;
|
||||
int isrational;
|
||||
int ncoords;
|
||||
int hcoords;
|
||||
int inhcoords;
|
||||
int mask;
|
||||
Maxmatrix bmat;
|
||||
Maxmatrix cmat;
|
||||
Maxmatrix smat;
|
||||
REAL s_steps; /* max samples in s direction */
|
||||
REAL t_steps; /* max samples in t direction */
|
||||
REAL sampling_method;
|
||||
REAL culling_method; /* check for culling */
|
||||
REAL bbox_subdividing;
|
||||
Mapdesc * next;
|
||||
Backend & backend;
|
||||
|
||||
void bbox( REAL [2][MAXCOORDS], REAL *, int, int, int, int );
|
||||
REAL maxDifference( int, REAL *, int );
|
||||
static void copy( Maxmatrix, long, INREAL *, long, long );
|
||||
|
||||
/* individual control point routines */
|
||||
static void transform4d( float[4], float[4], float[4][4] );
|
||||
static void multmatrix4d ( float[4][4], const float[4][4],
|
||||
const float[4][4] );
|
||||
void copyPt( REAL *, REAL * );
|
||||
void sumPt( REAL *, REAL *, REAL *, REAL, REAL );
|
||||
void xformSampling( REAL *, REAL * );
|
||||
void xformCulling( REAL *, REAL * );
|
||||
void xformRational( Maxmatrix, REAL *, REAL * );
|
||||
void xformNonrational( Maxmatrix, REAL *, REAL * );
|
||||
unsigned int clipbits( REAL * );
|
||||
};
|
||||
|
||||
inline void
|
||||
Mapdesc::setBmat( INREAL *mat, long rstride, long cstride )
|
||||
{
|
||||
copy( bmat, hcoords, mat, rstride, cstride );
|
||||
}
|
||||
|
||||
inline void
|
||||
Mapdesc::setCmat( INREAL *mat, long rstride, long cstride )
|
||||
{
|
||||
copy( cmat, hcoords, mat, rstride, cstride );
|
||||
}
|
||||
|
||||
inline void
|
||||
Mapdesc::setSmat( INREAL *mat, long rstride, long cstride )
|
||||
{
|
||||
copy( smat, hcoords, mat, rstride, cstride );
|
||||
}
|
||||
|
||||
inline long
|
||||
Mapdesc::getType( void )
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
inline void
|
||||
Mapdesc::xformCulling( REAL *d, REAL *s )
|
||||
{
|
||||
if( isrational )
|
||||
xformRational( cmat, d, s );
|
||||
else
|
||||
xformNonrational( cmat, d, s );
|
||||
}
|
||||
|
||||
inline void
|
||||
Mapdesc::xformSampling( REAL *d, REAL *s )
|
||||
{
|
||||
if( isrational )
|
||||
xformRational( smat, d, s );
|
||||
else
|
||||
xformNonrational( smat, d, s );
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isRational( void )
|
||||
{
|
||||
return isrational ? 1 : 0;
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::getNcoords( void )
|
||||
{
|
||||
return ncoords;
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isConstantSampling( void )
|
||||
{
|
||||
return ((sampling_method == N_FIXEDRATE) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isDomainSampling( void )
|
||||
{
|
||||
return ((sampling_method == N_DOMAINDISTANCE) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isParametricDistanceSampling( void )
|
||||
{
|
||||
return ((sampling_method == N_PARAMETRICDISTANCE) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isObjectSpaceParaSampling( void )
|
||||
{
|
||||
return ((sampling_method == N_OBJECTSPACE_PARA) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isObjectSpacePathSampling( void )
|
||||
{
|
||||
return ((sampling_method == N_OBJECTSPACE_PATH) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isSurfaceAreaSampling( void )
|
||||
{
|
||||
return ((sampling_method == N_SURFACEAREA) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isPathLengthSampling( void )
|
||||
{
|
||||
return ((sampling_method == N_PATHLENGTH) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isRangeSampling( void )
|
||||
{
|
||||
return ( isParametricDistanceSampling() || isPathLengthSampling() ||
|
||||
isSurfaceAreaSampling() ||
|
||||
isObjectSpaceParaSampling() ||
|
||||
isObjectSpacePathSampling());
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isSampling( void )
|
||||
{
|
||||
return isRangeSampling() || isConstantSampling() || isDomainSampling();
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isCulling( void )
|
||||
{
|
||||
return ((culling_method != N_NOCULLING) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isBboxSubdividing( void )
|
||||
{
|
||||
return ((bbox_subdividing != N_NOBBOXSUBDIVISION) ? 1 : 0);
|
||||
}
|
||||
#endif /* __glumapdesc_h_ */
|
||||
|
|
@ -1,243 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mapdescv.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "mystring.h"
|
||||
#include "mymath.h"
|
||||
#include "nurbsconsts.h"
|
||||
#include "mapdesc.h"
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* calcPartialVelocity - calculate maximum magnitude of a given partial
|
||||
* derivative
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
REAL
|
||||
Mapdesc::calcPartialVelocity (
|
||||
REAL *p,
|
||||
int stride,
|
||||
int ncols,
|
||||
int partial,
|
||||
REAL range )
|
||||
{
|
||||
REAL tmp[MAXORDER][MAXCOORDS];
|
||||
REAL mag[MAXORDER];
|
||||
|
||||
assert( ncols <= MAXORDER );
|
||||
|
||||
int j, k, t;
|
||||
// copy inhomogeneous control points into temporary array
|
||||
for( j=0; j != ncols; j++ )
|
||||
for( k=0; k != inhcoords; k++ )
|
||||
tmp[j][k] = p[j*stride + k];
|
||||
|
||||
for( t=0; t != partial; t++ )
|
||||
for( j=0; j != ncols-t-1; j++ )
|
||||
for( k=0; k != inhcoords; k++ )
|
||||
tmp[j][k] = tmp[j+1][k] - tmp[j][k];
|
||||
|
||||
// compute magnitude and store in mag array
|
||||
for( j=0; j != ncols-partial; j++ ) {
|
||||
mag[j] = 0.0;
|
||||
for( k=0; k != inhcoords; k++ )
|
||||
mag[j] += tmp[j][k] * tmp[j][k];
|
||||
}
|
||||
|
||||
// compute scale factor
|
||||
REAL fac = 1;
|
||||
REAL invt = 1.0 / range;
|
||||
for( t = ncols-1; t != ncols-1-partial; t-- )
|
||||
fac *= t * invt;
|
||||
|
||||
// compute max magnitude of all entries in array
|
||||
REAL max = 0.0;
|
||||
for( j=0; j != ncols-partial; j++ )
|
||||
if( mag[j] > max ) max = mag[j];
|
||||
max = fac * sqrtf( (float) max );
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* calcPartialVelocity - calculate maximum magnitude of a given partial
|
||||
* derivative
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
REAL
|
||||
Mapdesc::calcPartialVelocity (
|
||||
REAL *dist,
|
||||
REAL *p,
|
||||
int rstride,
|
||||
int cstride,
|
||||
int nrows,
|
||||
int ncols,
|
||||
int spartial,
|
||||
int tpartial,
|
||||
REAL srange,
|
||||
REAL trange,
|
||||
int side )
|
||||
{
|
||||
REAL tmp[MAXORDER][MAXORDER][MAXCOORDS];
|
||||
REAL mag[MAXORDER][MAXORDER];
|
||||
|
||||
assert( nrows <= MAXORDER );
|
||||
assert( ncols <= MAXORDER );
|
||||
|
||||
REAL *tp = &tmp[0][0][0];
|
||||
REAL *mp = &mag[0][0];
|
||||
const int istride = sizeof( tmp[0]) / sizeof( tmp[0][0][0] );
|
||||
const int jstride = sizeof( tmp[0][0]) / sizeof( tmp[0][0][0] );
|
||||
/*
|
||||
const int kstride = sizeof( tmp[0][0][0]) / sizeof( tmp[0][0][0] );
|
||||
*/
|
||||
const int mistride = sizeof( mag[0]) / sizeof( mag[0][0] );
|
||||
const int mjstride = sizeof( mag[0][0]) / sizeof( mag[0][0] );
|
||||
const int idist = nrows * istride;
|
||||
const int jdist = ncols * jstride;
|
||||
/*
|
||||
const int kdist = inhcoords * kstride;
|
||||
*/
|
||||
const int id = idist - spartial * istride;
|
||||
const int jd = jdist - tpartial * jstride;
|
||||
|
||||
{
|
||||
// copy control points
|
||||
REAL *ti = tp;
|
||||
REAL *qi = p;
|
||||
REAL *til = tp + idist;
|
||||
for( ; ti != til; ) {
|
||||
REAL *tj = ti;
|
||||
REAL *qj = qi;
|
||||
REAL *tjl = ti + jdist;
|
||||
for( ; tj != tjl; ) {
|
||||
for( int k=0; k != inhcoords; k++ ) {
|
||||
tj[k] = qj[k];
|
||||
}
|
||||
tj += jstride;
|
||||
qj += cstride;
|
||||
}
|
||||
ti += istride;
|
||||
qi += rstride;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// compute (s)-partial derivative control points
|
||||
REAL *til = tp + idist - istride;
|
||||
const REAL *till = til - ( spartial * istride );
|
||||
for( ; til != till; til -= istride )
|
||||
for( REAL *ti = tp; ti != til; ti += istride )
|
||||
for( REAL *tj = ti, *tjl = tj + jdist; tj != tjl; tj += jstride )
|
||||
for( int k=0; k != inhcoords; k++ )
|
||||
tj[k] = tj[k+istride] - tj[k];
|
||||
}
|
||||
|
||||
{
|
||||
// compute (s,t)-partial derivative control points
|
||||
REAL *tjl = tp + jdist - jstride;
|
||||
const REAL *tjll = tjl - ( tpartial * jstride );
|
||||
for( ; tjl != tjll; tjl -= jstride )
|
||||
for( REAL *tj = tp; tj != tjl; tj += jstride )
|
||||
for( REAL *ti = tj, *til = ti + id; ti != til; ti += istride )
|
||||
for( int k=0; k != inhcoords; k++ )
|
||||
ti[k] = ti[k+jstride] - ti[k];
|
||||
|
||||
}
|
||||
|
||||
REAL max = 0.0;
|
||||
{
|
||||
// compute magnitude and store in mag array
|
||||
memset( (void *) mp, 0, sizeof( mag ) );
|
||||
for( REAL *ti = tp, *mi = mp, *til = tp + id; ti != til; ti += istride, mi += mistride )
|
||||
for( REAL *tj = ti, *mj = mi, *tjl = ti + jd; tj != tjl; tj += jstride, mj += mjstride ) {
|
||||
for( int k=0; k != inhcoords; k++ )
|
||||
*mj += tj[k] * tj[k];
|
||||
if( *mj > max ) max = *mj;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int i, j;
|
||||
|
||||
// compute scale factor
|
||||
REAL fac = 1.0;
|
||||
{
|
||||
REAL invs = 1.0 / srange;
|
||||
REAL invt = 1.0 / trange;
|
||||
for( int s = nrows-1, slast = s-spartial; s != slast; s-- )
|
||||
fac *= s * invs;
|
||||
for( int t = ncols-1, tlast = t-tpartial; t != tlast; t-- )
|
||||
fac *= t * invt;
|
||||
}
|
||||
|
||||
if( side == 0 ) {
|
||||
// compute max magnitude of first and last column
|
||||
dist[0] = 0.0;
|
||||
dist[1] = 0.0;
|
||||
for( i=0; i != nrows-spartial; i++ ) {
|
||||
j = 0;
|
||||
if( mag[i][j] > dist[0] ) dist[0] = mag[i][j];
|
||||
|
||||
j = ncols-tpartial-1;
|
||||
if( mag[i][j] > dist[1] ) dist[1] = mag[i][j];
|
||||
}
|
||||
dist[0] = fac * sqrtf( dist[0] );
|
||||
dist[1] = fac * sqrtf( dist[1] );
|
||||
} else if( side == 1 ) {
|
||||
// compute max magnitude of first and last row
|
||||
dist[0] = 0.0;
|
||||
dist[1] = 0.0;
|
||||
for( j=0; j != ncols-tpartial; j++ ) {
|
||||
i = 0;
|
||||
if( mag[i][j] > dist[0] ) dist[0] = mag[i][j];
|
||||
|
||||
i = nrows-spartial-1;
|
||||
if( mag[i][j] > dist[1] ) dist[1] = mag[i][j];
|
||||
}
|
||||
dist[0] = fac * sqrtf( dist[0] );
|
||||
dist[1] = fac * sqrtf( dist[1] );
|
||||
}
|
||||
|
||||
max = fac * sqrtf( (float) max );
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* maplist.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "mymath.h"
|
||||
#include "nurbsconsts.h"
|
||||
#include "maplist.h"
|
||||
#include "mapdesc.h"
|
||||
|
||||
Maplist::Maplist( Backend& b )
|
||||
: mapdescPool( sizeof( Mapdesc ), 10, "mapdesc pool" ),
|
||||
backend( b )
|
||||
{
|
||||
maps = 0; lastmap = &maps;
|
||||
}
|
||||
|
||||
void
|
||||
Maplist::initialize( void )
|
||||
{
|
||||
freeMaps();
|
||||
define( N_P2D, 0, 2 );
|
||||
define( N_P2DR, 1, 3 );
|
||||
}
|
||||
|
||||
void
|
||||
Maplist::add( long type, int israt, int ncoords )
|
||||
{
|
||||
*lastmap = new(mapdescPool) Mapdesc( type, israt, ncoords, backend );
|
||||
lastmap = &((*lastmap)->next);
|
||||
}
|
||||
|
||||
void
|
||||
Maplist::define( long type, int israt, int ncoords )
|
||||
{
|
||||
#ifndef NDEBUG // to avoid warning
|
||||
Mapdesc *m = locate( type );
|
||||
assert( m == NULL || ( m->isrational == israt && m->ncoords == ncoords ) );
|
||||
#endif
|
||||
add( type, israt, ncoords );
|
||||
}
|
||||
|
||||
void
|
||||
Maplist::remove( Mapdesc *m )
|
||||
{
|
||||
for( Mapdesc **curmap = &maps; *curmap; curmap = &((*curmap)->next) ) {
|
||||
if( *curmap == m ) {
|
||||
*curmap = m->next;
|
||||
m->deleteMe( mapdescPool );
|
||||
return;
|
||||
}
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
||||
void
|
||||
Maplist::freeMaps( void )
|
||||
{
|
||||
mapdescPool.clear();
|
||||
maps = 0;
|
||||
lastmap = &maps;
|
||||
}
|
||||
|
||||
Mapdesc *
|
||||
Maplist::find( long type )
|
||||
{
|
||||
Mapdesc *val = locate( type );
|
||||
assert( val != 0 );
|
||||
return val;
|
||||
}
|
||||
|
||||
Mapdesc *
|
||||
Maplist::locate( long type )
|
||||
{
|
||||
Mapdesc *m;
|
||||
for( m = maps; m; m = m->next )
|
||||
if( m->getType() == type ) break;
|
||||
return m;
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* maplist.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glumaplist_h_
|
||||
#define __glumaplist_h_
|
||||
|
||||
#include "types.h"
|
||||
#include "defines.h"
|
||||
#include "bufpool.h"
|
||||
|
||||
class Backend;
|
||||
class Mapdesc;
|
||||
|
||||
class Maplist {
|
||||
public:
|
||||
Maplist( Backend & );
|
||||
void define( long, int, int );
|
||||
inline void undefine( long );
|
||||
inline int isMap( long );
|
||||
|
||||
void initialize( void );
|
||||
Mapdesc * find( long );
|
||||
Mapdesc * locate( long );
|
||||
|
||||
private:
|
||||
Pool mapdescPool;
|
||||
Mapdesc * maps;
|
||||
Mapdesc ** lastmap;
|
||||
Backend & backend;
|
||||
|
||||
void add( long, int, int );
|
||||
void remove( Mapdesc * );
|
||||
void freeMaps( void );
|
||||
};
|
||||
|
||||
inline int
|
||||
Maplist::isMap( long type )
|
||||
{
|
||||
return (locate( type ) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline void
|
||||
Maplist::undefine( long type )
|
||||
{
|
||||
Mapdesc *m = locate( type );
|
||||
assert( m != 0 );
|
||||
remove( m );
|
||||
}
|
||||
#endif /* __glumaplist_h_ */
|
||||
|
|
@ -1,489 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mesher.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "gridvertex.h"
|
||||
#include "gridtrimvertex.h"
|
||||
#include "jarcloc.h"
|
||||
#include "gridline.h"
|
||||
#include "trimline.h"
|
||||
#include "uarray.h"
|
||||
#include "backend.h"
|
||||
#include "mesher.h"
|
||||
|
||||
|
||||
const float Mesher::ZERO = 0.0;
|
||||
|
||||
Mesher::Mesher( Backend& b )
|
||||
: backend( b ),
|
||||
p( sizeof( GridTrimVertex ), 100, "GridTrimVertexPool" )
|
||||
{
|
||||
stacksize = 0;
|
||||
vdata = 0;
|
||||
last[0] = 0;
|
||||
last[1] = 0;
|
||||
itop = 0;
|
||||
lastedge = 0; //needed to prevent purify UMR
|
||||
}
|
||||
|
||||
Mesher::~Mesher( void )
|
||||
{
|
||||
if( vdata ) delete[] vdata;
|
||||
}
|
||||
|
||||
void
|
||||
Mesher::init( unsigned int npts )
|
||||
{
|
||||
p.clear();
|
||||
if( stacksize < npts ) {
|
||||
stacksize = 2 * npts;
|
||||
if( vdata ) delete[] vdata;
|
||||
vdata = new GridTrimVertex_p[stacksize];
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::push( GridTrimVertex *gt )
|
||||
{
|
||||
assert( itop+1 != (int)stacksize );
|
||||
vdata[++itop] = gt;
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::pop( long )
|
||||
{
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::openMesh()
|
||||
{
|
||||
backend.bgntmesh( "addedge" );
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::closeMesh()
|
||||
{
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::swapMesh()
|
||||
{
|
||||
backend.swaptmesh();
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::clearStack()
|
||||
{
|
||||
itop = -1;
|
||||
last[0] = 0;
|
||||
}
|
||||
|
||||
void
|
||||
Mesher::finishLower( GridTrimVertex *gtlower )
|
||||
{
|
||||
for( push(gtlower);
|
||||
nextlower( gtlower=new(p) GridTrimVertex );
|
||||
push(gtlower) )
|
||||
addLower();
|
||||
addLast();
|
||||
}
|
||||
|
||||
void
|
||||
Mesher::finishUpper( GridTrimVertex *gtupper )
|
||||
{
|
||||
for( push(gtupper);
|
||||
nextupper( gtupper=new(p) GridTrimVertex );
|
||||
push(gtupper) )
|
||||
addUpper();
|
||||
addLast();
|
||||
}
|
||||
|
||||
void
|
||||
Mesher::mesh( void )
|
||||
{
|
||||
GridTrimVertex *gtlower, *gtupper;
|
||||
|
||||
Hull::init( );
|
||||
nextupper( gtupper = new(p) GridTrimVertex );
|
||||
nextlower( gtlower = new(p) GridTrimVertex );
|
||||
|
||||
clearStack();
|
||||
openMesh();
|
||||
push(gtupper);
|
||||
|
||||
nextupper( gtupper = new(p) GridTrimVertex );
|
||||
nextlower( gtlower );
|
||||
|
||||
assert( gtupper->t && gtlower->t );
|
||||
|
||||
if( gtupper->t->param[0] < gtlower->t->param[0] ) {
|
||||
push(gtupper);
|
||||
lastedge = 1;
|
||||
if( nextupper( gtupper=new(p) GridTrimVertex ) == 0 ) {
|
||||
finishLower(gtlower);
|
||||
return;
|
||||
}
|
||||
} else if( gtupper->t->param[0] > gtlower->t->param[0] ) {
|
||||
push(gtlower);
|
||||
lastedge = 0;
|
||||
if( nextlower( gtlower=new(p) GridTrimVertex ) == 0 ) {
|
||||
finishUpper(gtupper);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if( lastedge == 0 ) {
|
||||
push(gtupper);
|
||||
lastedge = 1;
|
||||
if( nextupper(gtupper=new(p) GridTrimVertex) == 0 ) {
|
||||
finishLower(gtlower);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
push(gtlower);
|
||||
lastedge = 0;
|
||||
if( nextlower( gtlower=new(p) GridTrimVertex ) == 0 ) {
|
||||
finishUpper(gtupper);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while ( 1 ) {
|
||||
if( gtupper->t->param[0] < gtlower->t->param[0] ) {
|
||||
push(gtupper);
|
||||
addUpper();
|
||||
if( nextupper( gtupper=new(p) GridTrimVertex ) == 0 ) {
|
||||
finishLower(gtlower);
|
||||
return;
|
||||
}
|
||||
} else if( gtupper->t->param[0] > gtlower->t->param[0] ) {
|
||||
push(gtlower);
|
||||
addLower();
|
||||
if( nextlower( gtlower=new(p) GridTrimVertex ) == 0 ) {
|
||||
finishUpper(gtupper);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if( lastedge == 0 ) {
|
||||
push(gtupper);
|
||||
addUpper();
|
||||
if( nextupper( gtupper=new(p) GridTrimVertex ) == 0 ) {
|
||||
finishLower(gtlower);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
push(gtlower);
|
||||
addLower();
|
||||
if( nextlower( gtlower=new(p) GridTrimVertex ) == 0 ) {
|
||||
finishUpper(gtupper);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline int
|
||||
Mesher::isCcw( int ilast )
|
||||
{
|
||||
REAL area = det3( vdata[ilast]->t, vdata[itop-1]->t, vdata[itop-2]->t );
|
||||
return (area < ZERO) ? 0 : 1;
|
||||
}
|
||||
|
||||
inline int
|
||||
Mesher::isCw( int ilast )
|
||||
{
|
||||
REAL area = det3( vdata[ilast]->t, vdata[itop-1]->t, vdata[itop-2]->t );
|
||||
return (area > -ZERO) ? 0 : 1;
|
||||
}
|
||||
|
||||
inline int
|
||||
Mesher::equal( int x, int y )
|
||||
{
|
||||
return( last[0] == vdata[x] && last[1] == vdata[y] );
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::copy( int x, int y )
|
||||
{
|
||||
last[0] = vdata[x]; last[1] = vdata[y];
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::move( int x, int y )
|
||||
{
|
||||
vdata[x] = vdata[y];
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::output( int x )
|
||||
{
|
||||
backend.tmeshvert( vdata[x] );
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* addedge - addedge an edge to the triangulation
|
||||
*
|
||||
* This code has been re-written to generate large triangle meshes
|
||||
* from a monotone polygon. Although smaller triangle meshes
|
||||
* could be generated faster and with less code, larger meshes
|
||||
* actually give better SYSTEM performance. This is because
|
||||
* vertices are processed in the backend slower than they are
|
||||
* generated by this code and any decrease in the number of vertices
|
||||
* results in a decrease in the time spent in the backend.
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Mesher::addLast( )
|
||||
{
|
||||
register int ilast = itop;
|
||||
|
||||
if( lastedge == 0 ) {
|
||||
if( equal( 0, 1 ) ) {
|
||||
output( ilast );
|
||||
swapMesh();
|
||||
for( register int i = 2; i < ilast; i++ ) {
|
||||
swapMesh();
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, ilast-1 );
|
||||
} else if( equal( ilast-2, ilast-1) ) {
|
||||
swapMesh();
|
||||
output( ilast );
|
||||
for( register int i = ilast-3; i >= 0; i-- ) {
|
||||
output( i );
|
||||
swapMesh();
|
||||
}
|
||||
copy( 0, ilast );
|
||||
} else {
|
||||
closeMesh(); openMesh();
|
||||
output( ilast );
|
||||
output( 0 );
|
||||
for( register int i = 1; i < ilast; i++ ) {
|
||||
swapMesh();
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, ilast-1 );
|
||||
}
|
||||
} else {
|
||||
if( equal( 1, 0) ) {
|
||||
swapMesh();
|
||||
output( ilast );
|
||||
for( register int i = 2; i < ilast; i++ ) {
|
||||
output( i );
|
||||
swapMesh();
|
||||
}
|
||||
copy( ilast-1, ilast );
|
||||
} else if( equal( ilast-1, ilast-2) ) {
|
||||
output( ilast );
|
||||
swapMesh();
|
||||
for( register int i = ilast-3; i >= 0; i-- ) {
|
||||
swapMesh();
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, 0 );
|
||||
} else {
|
||||
closeMesh(); openMesh();
|
||||
output( 0 );
|
||||
output( ilast );
|
||||
for( register int i = 1; i < ilast; i++ ) {
|
||||
output( i );
|
||||
swapMesh();
|
||||
}
|
||||
copy( ilast-1, ilast );
|
||||
}
|
||||
}
|
||||
closeMesh();
|
||||
//for( register long k=0; k<=ilast; k++ ) pop( k );
|
||||
}
|
||||
|
||||
void
|
||||
Mesher::addUpper( )
|
||||
{
|
||||
register int ilast = itop;
|
||||
|
||||
if( lastedge == 0 ) {
|
||||
if( equal( 0, 1 ) ) {
|
||||
output( ilast );
|
||||
swapMesh();
|
||||
for( register int i = 2; i < ilast; i++ ) {
|
||||
swapMesh();
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, ilast-1 );
|
||||
} else if( equal( ilast-2, ilast-1) ) {
|
||||
swapMesh();
|
||||
output( ilast );
|
||||
for( register int i = ilast-3; i >= 0; i-- ) {
|
||||
output( i );
|
||||
swapMesh();
|
||||
}
|
||||
copy( 0, ilast );
|
||||
} else {
|
||||
closeMesh(); openMesh();
|
||||
output( ilast );
|
||||
output( 0 );
|
||||
for( register int i = 1; i < ilast; i++ ) {
|
||||
swapMesh();
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, ilast-1 );
|
||||
}
|
||||
lastedge = 1;
|
||||
//for( register long k=0; k<ilast-1; k++ ) pop( k );
|
||||
move( 0, ilast-1 );
|
||||
move( 1, ilast );
|
||||
itop = 1;
|
||||
} else {
|
||||
if( ! isCcw( ilast ) ) return;
|
||||
do {
|
||||
itop--;
|
||||
} while( (itop > 1) && isCcw( ilast ) );
|
||||
|
||||
if( equal( ilast-1, ilast-2 ) ) {
|
||||
output( ilast );
|
||||
swapMesh();
|
||||
for( register int i=ilast-3; i>=itop-1; i-- ) {
|
||||
swapMesh();
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, itop-1 );
|
||||
} else if( equal( itop, itop-1 ) ) {
|
||||
swapMesh();
|
||||
output( ilast );
|
||||
for( register int i = itop+1; i < ilast; i++ ) {
|
||||
output( i );
|
||||
swapMesh();
|
||||
}
|
||||
copy( ilast-1, ilast );
|
||||
} else {
|
||||
closeMesh(); openMesh();
|
||||
output( ilast );
|
||||
output( ilast-1 );
|
||||
for( register int i=ilast-2; i>=itop-1; i-- ) {
|
||||
swapMesh();
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, itop-1 );
|
||||
}
|
||||
//for( register int k=itop; k<ilast; k++ ) pop( k );
|
||||
move( itop, ilast );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Mesher::addLower()
|
||||
{
|
||||
register int ilast = itop;
|
||||
|
||||
if( lastedge == 1 ) {
|
||||
if( equal( 1, 0) ) {
|
||||
swapMesh();
|
||||
output( ilast );
|
||||
for( register int i = 2; i < ilast; i++ ) {
|
||||
output( i );
|
||||
swapMesh();
|
||||
}
|
||||
copy( ilast-1, ilast );
|
||||
} else if( equal( ilast-1, ilast-2) ) {
|
||||
output( ilast );
|
||||
swapMesh();
|
||||
for( register int i = ilast-3; i >= 0; i-- ) {
|
||||
swapMesh();
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, 0 );
|
||||
} else {
|
||||
closeMesh(); openMesh();
|
||||
output( 0 );
|
||||
output( ilast );
|
||||
for( register int i = 1; i < ilast; i++ ) {
|
||||
output( i );
|
||||
swapMesh();
|
||||
}
|
||||
copy( ilast-1, ilast );
|
||||
}
|
||||
|
||||
lastedge = 0;
|
||||
//for( register long k=0; k<ilast-1; k++ ) pop( k );
|
||||
move( 0, ilast-1 );
|
||||
move( 1, ilast );
|
||||
itop = 1;
|
||||
} else {
|
||||
if( ! isCw( ilast ) ) return;
|
||||
do {
|
||||
itop--;
|
||||
} while( (itop > 1) && isCw( ilast ) );
|
||||
|
||||
if( equal( ilast-2, ilast-1) ) {
|
||||
swapMesh();
|
||||
output( ilast );
|
||||
for( register int i=ilast-3; i>=itop-1; i--) {
|
||||
output( i );
|
||||
swapMesh( );
|
||||
}
|
||||
copy( itop-1, ilast );
|
||||
} else if( equal( itop-1, itop) ) {
|
||||
output( ilast );
|
||||
swapMesh();
|
||||
for( register int i=itop+1; i<ilast; i++ ) {
|
||||
swapMesh( );
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, ilast-1 );
|
||||
} else {
|
||||
closeMesh(); openMesh();
|
||||
output( ilast-1 );
|
||||
output( ilast );
|
||||
for( register int i=ilast-2; i>=itop-1; i-- ) {
|
||||
output( i );
|
||||
swapMesh( );
|
||||
}
|
||||
copy( itop-1, ilast );
|
||||
}
|
||||
//for( register int k=itop; k<ilast; k++ ) pop( k );
|
||||
move( itop, ilast );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mesher.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glumesher_h_
|
||||
#define __glumesher_h_
|
||||
|
||||
#include "hull.h"
|
||||
|
||||
class TrimRegion;
|
||||
class Backend;
|
||||
class Pool;
|
||||
// struct GridTrimVertex;
|
||||
|
||||
|
||||
class Mesher : virtual public TrimRegion, public Hull {
|
||||
public:
|
||||
Mesher( Backend & );
|
||||
~Mesher( void );
|
||||
void init( unsigned int );
|
||||
void mesh( void );
|
||||
|
||||
private:
|
||||
static const float ZERO;
|
||||
Backend& backend;
|
||||
|
||||
Pool p;
|
||||
unsigned int stacksize;
|
||||
GridTrimVertex ** vdata;
|
||||
GridTrimVertex * last[2];
|
||||
int itop;
|
||||
int lastedge;
|
||||
|
||||
inline void openMesh( void );
|
||||
inline void swapMesh( void );
|
||||
inline void closeMesh( void );
|
||||
inline int isCcw( int );
|
||||
inline int isCw( int );
|
||||
inline void clearStack( void );
|
||||
inline void push( GridTrimVertex * );
|
||||
inline void pop( long );
|
||||
inline void move( int, int );
|
||||
inline int equal( int, int );
|
||||
inline void copy( int, int );
|
||||
inline void output( int );
|
||||
void addUpper( void );
|
||||
void addLower( void );
|
||||
void addLast( void );
|
||||
void finishUpper( GridTrimVertex * );
|
||||
void finishLower( GridTrimVertex * );
|
||||
};
|
||||
#endif /* __glumesher_h_ */
|
||||
|
|
@ -1,397 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
**
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "monoTriangulation.h"
|
||||
#include "polyUtil.h"
|
||||
#include "backend.h"
|
||||
#include "arc.h"
|
||||
|
||||
void reflexChain::outputFan(Real v[2], Backend* backend)
|
||||
{
|
||||
Int i;
|
||||
/*
|
||||
TrimVertex trimVert;
|
||||
*/
|
||||
backend->bgntfan();
|
||||
|
||||
/*
|
||||
trimVert.param[0]=v[0];
|
||||
trimVert.param[1]=v[1];
|
||||
backend->tmeshvert(&trimVert);
|
||||
*/
|
||||
backend->tmeshvert(v[0], v[1]);
|
||||
|
||||
if(isIncreasing) {
|
||||
for(i=0; i<index_queue; i++)
|
||||
{
|
||||
/*
|
||||
trimVert.param[0]=queue[i][0];
|
||||
trimVert.param[1]=queue[i][1];
|
||||
backend->tmeshvert(&trimVert);
|
||||
*/
|
||||
backend->tmeshvert(queue[i][0], queue[i][1]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(i=index_queue-1; i>=0; i--)
|
||||
{
|
||||
/*
|
||||
trimVert.param[0]=queue[i][0];
|
||||
trimVert.param[1]=queue[i][1];
|
||||
backend->tmeshvert(&trimVert);
|
||||
*/
|
||||
backend->tmeshvert(queue[i][0], queue[i][1]);
|
||||
}
|
||||
}
|
||||
backend->endtfan();
|
||||
}
|
||||
|
||||
void reflexChain::processNewVertex(Real v[2], Backend* backend)
|
||||
{
|
||||
Int i,j,k;
|
||||
Int isReflex;
|
||||
/*TrimVertex trimVert;*/
|
||||
/*if there are at most one vertex in the queue, then simply insert
|
||||
*/
|
||||
if(index_queue <=1){
|
||||
insert(v);
|
||||
return;
|
||||
}
|
||||
|
||||
/*there are at least two vertices in the queue*/
|
||||
j=index_queue-1;
|
||||
|
||||
for(i=j; i>=1; i--) {
|
||||
if(isIncreasing) {
|
||||
isReflex = (area(queue[i-1], queue[i], v) <= 0.0);
|
||||
}
|
||||
else /*decreasing*/{
|
||||
isReflex = (area(v, queue[i], queue[i-1]) <= 0.0);
|
||||
}
|
||||
if(isReflex) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*if i<j then vertices: i+1--j are convex
|
||||
* output triangle fan:
|
||||
* v, and queue[i], i+1, ..., j
|
||||
*/
|
||||
if(i<j)
|
||||
{
|
||||
backend->bgntfan();
|
||||
/*
|
||||
trimVert.param[0]=v[0];
|
||||
trimVert.param[1]=v[1];
|
||||
backend->tmeshvert(& trimVert);
|
||||
*/
|
||||
backend->tmeshvert(v[0], v[1]);
|
||||
|
||||
if(isIncreasing) {
|
||||
for(k=i; k<=j; k++)
|
||||
{
|
||||
/*
|
||||
trimVert.param[0]=queue[k][0];
|
||||
trimVert.param[1]=queue[k][1];
|
||||
backend->tmeshvert(& trimVert);
|
||||
*/
|
||||
backend->tmeshvert(queue[k][0], queue[k][1]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(k=j; k>=i; k--)
|
||||
{
|
||||
/*
|
||||
trimVert.param[0]=queue[k][0];
|
||||
trimVert.param[1]=queue[k][1];
|
||||
backend->tmeshvert(& trimVert);
|
||||
*/
|
||||
backend->tmeshvert(queue[k][0], queue[k][1]);
|
||||
}
|
||||
}
|
||||
|
||||
backend->endtfan();
|
||||
}
|
||||
|
||||
/*delete vertices i+1--j from the queue*/
|
||||
index_queue = i+1;
|
||||
/*finally insert v at the end of the queue*/
|
||||
insert(v);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void monoTriangulationRec(Real* topVertex, Real* botVertex,
|
||||
vertexArray* inc_chain, Int inc_current,
|
||||
vertexArray* dec_chain, Int dec_current,
|
||||
Backend* backend)
|
||||
{
|
||||
assert( inc_chain != NULL && dec_chain != NULL);
|
||||
assert( ! (inc_current>=inc_chain->getNumElements() &&
|
||||
dec_current>=dec_chain->getNumElements()));
|
||||
Int inc_nVertices;
|
||||
Int dec_nVertices;
|
||||
Real** inc_array ;
|
||||
Real** dec_array ;
|
||||
Int i;
|
||||
assert( ! ( (inc_chain==NULL) && (dec_chain==NULL)));
|
||||
|
||||
if(inc_current>=inc_chain->getNumElements()) /*no more vertices on inc_chain*/
|
||||
{
|
||||
|
||||
dec_array = dec_chain->getArray();
|
||||
dec_nVertices = dec_chain->getNumElements();
|
||||
reflexChain rChain(20,0);
|
||||
/*put the top vertex into the reflex chain*/
|
||||
rChain.processNewVertex(topVertex, backend);
|
||||
/*process all the vertices on the dec_chain*/
|
||||
for(i=dec_current; i<dec_nVertices; i++){
|
||||
rChain.processNewVertex(dec_array[i], backend);
|
||||
}
|
||||
/*process the bottom vertex*/
|
||||
rChain.processNewVertex(botVertex, backend);
|
||||
|
||||
}
|
||||
else if(dec_current>= dec_chain->getNumElements()) /*no more vertices on dec_chain*/
|
||||
{
|
||||
inc_array = inc_chain->getArray();
|
||||
inc_nVertices= inc_chain->getNumElements();
|
||||
reflexChain rChain(20,1);
|
||||
/*put the top vertex into the reflex chain*/
|
||||
rChain.processNewVertex(topVertex, backend);
|
||||
/*process all the vertices on the inc_chain*/
|
||||
for(i=inc_current; i<inc_nVertices; i++){
|
||||
rChain.processNewVertex(inc_array[i], backend);
|
||||
}
|
||||
/*process the bottom vertex*/
|
||||
rChain.processNewVertex(botVertex, backend);
|
||||
}
|
||||
else /*neither chain is empty*/
|
||||
{
|
||||
inc_array = inc_chain -> getArray();
|
||||
dec_array = dec_chain -> getArray();
|
||||
inc_nVertices= inc_chain->getNumElements();
|
||||
dec_nVertices= dec_chain->getNumElements();
|
||||
/*if top of inc_chain is 'lower' than top of dec_chain, process all the
|
||||
*vertices on the dec_chain which are higher than top of inc_chain
|
||||
*/
|
||||
if(compV2InY(inc_array[inc_current], dec_array[dec_current]) <= 0)
|
||||
{
|
||||
|
||||
reflexChain rChain(20, 0);
|
||||
rChain.processNewVertex(topVertex, backend);
|
||||
for(i=dec_current; i<dec_nVertices; i++)
|
||||
{
|
||||
if(compV2InY(inc_array[inc_current], dec_array[i]) <= 0)
|
||||
rChain.processNewVertex(dec_array[i], backend);
|
||||
else
|
||||
break;
|
||||
}
|
||||
rChain.outputFan(inc_array[inc_current], backend);
|
||||
monoTriangulationRec(dec_array[i-1], botVertex,
|
||||
inc_chain, inc_current,
|
||||
dec_chain, i,
|
||||
backend);
|
||||
}
|
||||
else /*compV2InY(inc_array[inc_current], dec_array[dec_current]) > 0*/
|
||||
{
|
||||
|
||||
reflexChain rChain(20, 1);
|
||||
rChain.processNewVertex(topVertex, backend);
|
||||
for(i=inc_current; i<inc_nVertices; i++)
|
||||
{
|
||||
if(compV2InY(inc_array[i], dec_array[dec_current]) >0)
|
||||
rChain.processNewVertex(inc_array[i], backend);
|
||||
else
|
||||
break;
|
||||
}
|
||||
rChain.outputFan(dec_array[dec_current], backend);
|
||||
monoTriangulationRec(inc_array[i-1], botVertex,
|
||||
inc_chain, i,
|
||||
dec_chain, dec_current,
|
||||
backend);
|
||||
}
|
||||
}/*end case neither is empty*/
|
||||
}
|
||||
|
||||
|
||||
void monoTriangulationFunBackend(Arc_ptr loop, Int (*compFun)(Real*, Real*), Backend* backend)
|
||||
{
|
||||
Int i;
|
||||
/*find the top vertex, bottom vertex, inccreasing chain, and decreasing chain,
|
||||
*then call monoTriangulationRec
|
||||
*/
|
||||
Arc_ptr tempV;
|
||||
Arc_ptr topV;
|
||||
Arc_ptr botV;
|
||||
topV = botV = loop;
|
||||
for(tempV = loop->next; tempV != loop; tempV = tempV->next)
|
||||
{
|
||||
if(compFun(topV->tail(), tempV->tail())<0) {
|
||||
topV = tempV;
|
||||
}
|
||||
if(compFun(botV->tail(), tempV->tail())>0) {
|
||||
botV = tempV;
|
||||
}
|
||||
}
|
||||
|
||||
/*creat increase and decrease chains*/
|
||||
vertexArray inc_chain(20); /*this is a dynamic array*/
|
||||
for(i=1; i<=topV->pwlArc->npts-2; i++) { /*the first vertex is the top vertex which doesn't belong to inc_chain*/
|
||||
inc_chain.appendVertex(topV->pwlArc->pts[i].param);
|
||||
}
|
||||
for(tempV = topV->next; tempV != botV; tempV = tempV->next)
|
||||
{
|
||||
for(i=0; i<=tempV->pwlArc->npts-2; i++){
|
||||
inc_chain.appendVertex(tempV->pwlArc->pts[i].param);
|
||||
}
|
||||
}
|
||||
|
||||
vertexArray dec_chain(20);
|
||||
for(tempV = topV->prev; tempV != botV; tempV = tempV->prev)
|
||||
{
|
||||
for(i=tempV->pwlArc->npts-2; i>=0; i--){
|
||||
dec_chain.appendVertex(tempV->pwlArc->pts[i].param);
|
||||
}
|
||||
}
|
||||
for(i=botV->pwlArc->npts-2; i>=1; i--){
|
||||
dec_chain.appendVertex(tempV->pwlArc->pts[i].param);
|
||||
}
|
||||
|
||||
monoTriangulationRecFunBackend(topV->tail(), botV->tail(), &inc_chain, 0, &dec_chain, 0, compFun, backend);
|
||||
|
||||
}
|
||||
|
||||
/*if compFun == compV2InY, top to bottom: V-monotone
|
||||
*if compFun == compV2InX, right to left: U-monotone
|
||||
*/
|
||||
void monoTriangulationRecFunBackend(Real* topVertex, Real* botVertex,
|
||||
vertexArray* inc_chain, Int inc_current,
|
||||
vertexArray* dec_chain, Int dec_current,
|
||||
Int (*compFun)(Real*, Real*),
|
||||
Backend* backend)
|
||||
{
|
||||
assert( inc_chain != NULL && dec_chain != NULL);
|
||||
assert( ! (inc_current>=inc_chain->getNumElements() &&
|
||||
dec_current>=dec_chain->getNumElements()));
|
||||
Int inc_nVertices;
|
||||
Int dec_nVertices;
|
||||
Real** inc_array ;
|
||||
Real** dec_array ;
|
||||
Int i;
|
||||
assert( ! ( (inc_chain==NULL) && (dec_chain==NULL)));
|
||||
|
||||
if(inc_current>=inc_chain->getNumElements()) /*no more vertices on inc_chain*/
|
||||
{
|
||||
|
||||
dec_array = dec_chain->getArray();
|
||||
dec_nVertices = dec_chain->getNumElements();
|
||||
reflexChain rChain(20,0);
|
||||
/*put the top vertex into the reflex chain*/
|
||||
rChain.processNewVertex(topVertex, backend);
|
||||
/*process all the vertices on the dec_chain*/
|
||||
for(i=dec_current; i<dec_nVertices; i++){
|
||||
rChain.processNewVertex(dec_array[i], backend);
|
||||
}
|
||||
/*process the bottom vertex*/
|
||||
rChain.processNewVertex(botVertex, backend);
|
||||
|
||||
}
|
||||
else if(dec_current>= dec_chain->getNumElements()) /*no more vertices on dec_chain*/
|
||||
{
|
||||
inc_array = inc_chain->getArray();
|
||||
inc_nVertices= inc_chain->getNumElements();
|
||||
reflexChain rChain(20,1);
|
||||
/*put the top vertex into the reflex chain*/
|
||||
rChain.processNewVertex(topVertex, backend);
|
||||
/*process all the vertices on the inc_chain*/
|
||||
for(i=inc_current; i<inc_nVertices; i++){
|
||||
rChain.processNewVertex(inc_array[i], backend);
|
||||
}
|
||||
/*process the bottom vertex*/
|
||||
rChain.processNewVertex(botVertex, backend);
|
||||
}
|
||||
else /*neither chain is empty*/
|
||||
{
|
||||
inc_array = inc_chain -> getArray();
|
||||
dec_array = dec_chain -> getArray();
|
||||
inc_nVertices= inc_chain->getNumElements();
|
||||
dec_nVertices= dec_chain->getNumElements();
|
||||
/*if top of inc_chain is 'lower' than top of dec_chain, process all the
|
||||
*vertices on the dec_chain which are higher than top of inc_chain
|
||||
*/
|
||||
if(compFun(inc_array[inc_current], dec_array[dec_current]) <= 0)
|
||||
{
|
||||
|
||||
reflexChain rChain(20, 0);
|
||||
rChain.processNewVertex(topVertex, backend);
|
||||
for(i=dec_current; i<dec_nVertices; i++)
|
||||
{
|
||||
if(compFun(inc_array[inc_current], dec_array[i]) <= 0)
|
||||
rChain.processNewVertex(dec_array[i], backend);
|
||||
else
|
||||
break;
|
||||
}
|
||||
rChain.outputFan(inc_array[inc_current], backend);
|
||||
monoTriangulationRecFunBackend(dec_array[i-1], botVertex,
|
||||
inc_chain, inc_current,
|
||||
dec_chain, i,
|
||||
compFun,
|
||||
backend);
|
||||
}
|
||||
else /*compFun(inc_array[inc_current], dec_array[dec_current]) > 0*/
|
||||
{
|
||||
|
||||
reflexChain rChain(20, 1);
|
||||
rChain.processNewVertex(topVertex, backend);
|
||||
for(i=inc_current; i<inc_nVertices; i++)
|
||||
{
|
||||
if(compFun(inc_array[i], dec_array[dec_current]) >0)
|
||||
rChain.processNewVertex(inc_array[i], backend);
|
||||
else
|
||||
break;
|
||||
}
|
||||
rChain.outputFan(dec_array[dec_current], backend);
|
||||
monoTriangulationRecFunBackend(inc_array[i-1], botVertex,
|
||||
inc_chain, i,
|
||||
dec_chain, dec_current,
|
||||
compFun,
|
||||
backend);
|
||||
}
|
||||
}/*end case neither is empty*/
|
||||
}
|
||||
|
|
@ -1,260 +0,0 @@
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* monotonizer.c++
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "arc.h"
|
||||
#include "arctess.h"
|
||||
#include "bezierarc.h"
|
||||
#include "bin.h"
|
||||
#include "mapdesc.h"
|
||||
#include "nurbsconsts.h"
|
||||
#include "subdivider.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Subdivider::decompose - break all curves into monotone arcs
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Subdivider::decompose( Bin& bin, REAL geo_stepsize )
|
||||
{
|
||||
Arc_ptr jarc;
|
||||
for( jarc=bin.firstarc(); jarc; jarc=bin.nextarc() ) {
|
||||
if( ! jarc->isTessellated() ) {
|
||||
/* points have not been transformed, therefore they may be either
|
||||
homogeneous or inhomogeneous */
|
||||
tessellate( jarc, geo_stepsize );
|
||||
if( jarc->isDisconnected() || jarc->next->isDisconnected() )
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
for( jarc=bin.firstarc(); jarc; jarc=bin.nextarc() ) {
|
||||
monotonize( jarc, bin );
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
for( jarc=bin.firstarc(); jarc; jarc=bin.nextarc() ) {
|
||||
assert( isMonotone( jarc ) != 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Subdivider::tessellate( Arc_ptr jarc, REAL geo_stepsize )
|
||||
{
|
||||
BezierArc *b = jarc->bezierArc;
|
||||
Mapdesc *mapdesc = b->mapdesc;
|
||||
|
||||
if( mapdesc->isRational() ) {
|
||||
REAL max = mapdesc->calcVelocityRational( b->cpts, b->stride, b->order );
|
||||
REAL arc_stepsize = (max > 1.0) ? (1.0/max) : 1.0;
|
||||
if( jarc->bezierArc->order != 2 )
|
||||
arctessellator.tessellateNonlinear( jarc, geo_stepsize, arc_stepsize, 1 );
|
||||
else {
|
||||
arctessellator.tessellateLinear( jarc, geo_stepsize, arc_stepsize, 1 );
|
||||
}
|
||||
} else {
|
||||
REAL max = mapdesc->calcVelocityNonrational( b->cpts, b->stride, b->order );
|
||||
REAL arc_stepsize = (max > 1.0) ? (1.0/max) : 1.0;
|
||||
if( jarc->bezierArc->order != 2 )
|
||||
arctessellator.tessellateNonlinear( jarc, geo_stepsize, arc_stepsize, 0 );
|
||||
else {
|
||||
arctessellator.tessellateLinear( jarc, geo_stepsize, arc_stepsize, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Subdivider::monotonize - break up a jordan arc into s,t-monotone
|
||||
* components. This code will remove degenerate segments, including
|
||||
* arcs of only a single point.
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Subdivider::monotonize( Arc_ptr jarc, Bin& bin )
|
||||
{
|
||||
TrimVertex *firstvert = jarc->pwlArc->pts;
|
||||
TrimVertex *lastvert = firstvert + (jarc->pwlArc->npts - 1);
|
||||
long uid = jarc->nuid;
|
||||
arc_side side = jarc->getside();
|
||||
dir sdir = none;
|
||||
dir tdir = none;
|
||||
int degenerate = 1;
|
||||
|
||||
int nudegenerate;
|
||||
int change;
|
||||
|
||||
TrimVertex *vert;
|
||||
for( vert = firstvert; vert != lastvert; vert++ ) {
|
||||
|
||||
nudegenerate = 1;
|
||||
change = 0;
|
||||
|
||||
/* check change relative to s axis, clear degenerate bit if needed */
|
||||
REAL sdiff = vert[1].param[0] - vert[0].param[0];
|
||||
if( sdiff == 0 ) {
|
||||
if( sdir != same ) {
|
||||
sdir = same;
|
||||
change = 1;
|
||||
}
|
||||
} else if( sdiff < 0.0 ) {
|
||||
if( sdir != down ) {
|
||||
sdir = down;
|
||||
change = 1;
|
||||
}
|
||||
nudegenerate = 0;
|
||||
} else {
|
||||
if( sdir != up ) {
|
||||
sdir = up;
|
||||
change = 1;
|
||||
}
|
||||
nudegenerate = 0;
|
||||
}
|
||||
|
||||
/* check change relative to t axis, clear degenerate bit if needed */
|
||||
REAL tdiff = vert[1].param[1] - vert[0].param[1];
|
||||
if( tdiff == 0 ) {
|
||||
if( tdir != same ) {
|
||||
tdir = same;
|
||||
change = 1;
|
||||
}
|
||||
} else if( tdiff < 0.0 ) {
|
||||
if( tdir != down ) {
|
||||
tdir = down;
|
||||
change = 1;
|
||||
}
|
||||
nudegenerate = 0;
|
||||
} else {
|
||||
if( tdir != up ) {
|
||||
tdir = up;
|
||||
change = 1;
|
||||
}
|
||||
nudegenerate = 0;
|
||||
}
|
||||
|
||||
if( change ) {
|
||||
if( ! degenerate ) {
|
||||
/* make last segment into separate pwl curve */
|
||||
jarc->pwlArc->npts = vert - firstvert + 1;
|
||||
jarc = (new(arcpool) Arc( side, uid ))->append( jarc );
|
||||
jarc->pwlArc = new(pwlarcpool) PwlArc();
|
||||
bin.addarc( jarc );
|
||||
}
|
||||
firstvert = jarc->pwlArc->pts = vert;
|
||||
degenerate = nudegenerate;
|
||||
}
|
||||
}
|
||||
jarc->pwlArc->npts = vert - firstvert + 1;
|
||||
|
||||
if( degenerate ) {
|
||||
/* remove jarc from circularly linked list */
|
||||
jarc->prev->next = jarc->next;
|
||||
jarc->next->prev = jarc->prev;
|
||||
|
||||
assert( jarc->prev->check( ) != 0 );
|
||||
assert( jarc->next->check( ) != 0 );
|
||||
|
||||
/* remove jarc from bin */
|
||||
bin.remove_this_arc( jarc );
|
||||
|
||||
jarc->pwlArc->deleteMe( pwlarcpool ); jarc->pwlArc = 0;
|
||||
jarc->deleteMe( arcpool );
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Subdivider::isMonotone - return true if arc is monotone AND non-degenerate
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Subdivider::isMonotone( Arc_ptr jarc )
|
||||
{
|
||||
TrimVertex *firstvert = jarc->pwlArc->pts;
|
||||
TrimVertex *lastvert = firstvert + (jarc->pwlArc->npts - 1);
|
||||
|
||||
if( firstvert == lastvert ) return 1;
|
||||
|
||||
TrimVertex *vert = firstvert;
|
||||
enum dir sdir;
|
||||
enum dir tdir;
|
||||
|
||||
REAL diff = vert[1].param[0] - vert[0].param[0];
|
||||
if( diff == 0.0 )
|
||||
sdir = same;
|
||||
else if( diff < 0.0 )
|
||||
sdir = down;
|
||||
else
|
||||
sdir = up;
|
||||
|
||||
diff = vert[1].param[1] - vert[0].param[1];
|
||||
if( diff == 0.0 )
|
||||
tdir = same;
|
||||
else if( diff < 0.0 )
|
||||
tdir = down;
|
||||
else
|
||||
tdir = up;
|
||||
|
||||
if( (sdir == same) && (tdir == same) ) return 0;
|
||||
|
||||
for( ++vert ; vert != lastvert; vert++ ) {
|
||||
diff = vert[1].param[0] - vert[0].param[0];
|
||||
if( diff == 0.0 ) {
|
||||
if( sdir != same ) return 0;
|
||||
} else if( diff < 0.0 ) {
|
||||
if( sdir != down ) return 0;
|
||||
} else {
|
||||
if( sdir != up ) return 0;
|
||||
}
|
||||
|
||||
diff = vert[1].param[1] - vert[0].param[1];
|
||||
if( diff == 0.0 ) {
|
||||
if( tdir != same ) return 0;
|
||||
} else if( diff < 0.0 ) {
|
||||
if( tdir != down ) return 0;
|
||||
} else {
|
||||
if( tdir != up ) return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* monotonizer.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glumonotonizer_h_
|
||||
#define __glumonotonizer_h_
|
||||
|
||||
#include "mysetjmp.h"
|
||||
#include "types.h"
|
||||
|
||||
class Arc;
|
||||
class ArcTessellator;
|
||||
class Pool;
|
||||
class Bin;
|
||||
class PwlArcPool;
|
||||
class Mapdesc;
|
||||
|
||||
class Monotonizer {
|
||||
ArcTessellator& arctessellator;
|
||||
Pool& arcpool;
|
||||
Pool& pwlarcpool;
|
||||
jmp_buf& nurbsJmpBuf;
|
||||
|
||||
enum dir { down, same, up, none };
|
||||
void tessellate( Arc *, REAL );
|
||||
void monotonize( Arc *, Bin & );
|
||||
int isMonotone( Arc * );
|
||||
public:
|
||||
Monotonizer( ArcTessellator& at, Pool& ap, Pool& p, jmp_buf& j )
|
||||
: arctessellator(at), arcpool(ap), pwlarcpool(p), nurbsJmpBuf(j) {}
|
||||
int decompose( Bin &, REAL );
|
||||
};
|
||||
#endif /* __glumonotonizer_h_ */
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* myassert.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __glumyassert_h_
|
||||
#define __glumyassert_h_
|
||||
|
||||
#ifdef STANDALONE
|
||||
#define assert(EX) ((void)0)
|
||||
#endif
|
||||
|
||||
#ifdef LIBRARYBUILD
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
#ifdef GLBUILD
|
||||
#define assert(EX) ((void)0)
|
||||
#endif
|
||||
|
||||
#endif /* __glumyassert_h_ */
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue