aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2007-10-09 07:38:10 +0000
committerKenneth Russel <[email protected]>2007-10-09 07:38:10 +0000
commitc92573e5f90bfefdfa6697a3f628a263c2f211f9 (patch)
tree53258db2dae2d3a54f9c2f30cd1a55fe163ba958 /src
parentf7b664564d2dcdf674660b5d1fc38c7f2ac25b76 (diff)
Integration of Tomas Hrasky's port of basic GLU NURBS functionality
from C++ to Java, plus example applications, done as part of his Bachelor of Science degree at the University of Hradec Králové, Faculty of Informatics and Management. Current state of code is documented in src/classes/com/sun/opengl/impl/nurbs/README.txt. Example applications require Java 1.5 and are not currently built by default. Specify -Djogl.nurbs=1 during jogl-demos build with a 1.5 javac on the PATH to build them. Dependent jars are copied to build output directory. Deleted old partially-complete GLU NURBS port. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1389 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Arc.java258
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/ArcSdirSorter.java63
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/ArcTdirSorter.java60
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/ArcTesselator.java90
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Backend.java217
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/BezierArc.java44
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Bin.java155
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Breakpt.java59
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/CArrayOfArcs.java194
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/CArrayOfBreakpts.java130
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/CArrayOfFloats.java195
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/CArrayOfQuiltspecs.java160
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Curve.java238
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Curvelist.java121
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/DisplayList.java56
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Flist.java130
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/GLUnurbsImpl.java860
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Knotspec.java557
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Knotvector.java179
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Mapdesc.java442
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Maplist.java122
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/NurbsConsts.java184
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/O_curve.java63
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/O_nurbscurve.java80
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/O_nurbssurface.java79
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/O_pwlcurve.java44
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/O_surface.java52
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/O_trim.java44
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/OpenGLCurveEvaluator.java202
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/OpenGLSurfaceEvaluator.java214
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Patch.java54
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Patchlist.java145
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Property.java75
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Pspec.java47
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/PwlArc.java71
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Quilt.java282
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Quiltspec.java85
-rw-r--r--src/classes/com/sun/opengl/impl/nurbs/README-PORTING.txt40
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/README.txt59
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Renderhints.java128
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Splinespec.java204
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/Subdivider.java1167
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/nurbs/TrimVertex.java56
-rw-r--r--src/classes/com/sun/opengl/impl/nurbs/internals/Arc.java284
-rw-r--r--src/classes/com/sun/opengl/impl/nurbs/internals/ArcTesselator.java459
-rw-r--r--src/classes/com/sun/opengl/impl/nurbs/internals/Backend.java387
-rw-r--r--src/classes/com/sun/opengl/impl/nurbs/internals/BasicCurveEvaluator.java60
-rw-r--r--src/classes/com/sun/opengl/impl/nurbs/internals/BasicSurfaceEvaluator.java86
-rw-r--r--src/classes/com/sun/opengl/impl/nurbs/internals/BezierArc.java52
-rw-r--r--src/classes/com/sun/opengl/impl/nurbs/internals/Bin.java157
-rw-r--r--src/classes/com/sun/opengl/impl/nurbs/internals/CachingEvaluator.java66
-rw-r--r--src/classes/com/sun/opengl/impl/nurbs/internals/Defines.java56
-rw-r--r--src/classes/com/sun/opengl/impl/nurbs/internals/NurbsConsts.java127
-rw-r--r--src/classes/com/sun/opengl/impl/nurbs/internals/NurbsException.java30
-rw-r--r--src/classes/com/sun/opengl/impl/nurbs/internals/Subdivider.java1791
-rwxr-xr-xsrc/classes/javax/media/opengl/glu/GLUnurbs.java8
56 files changed, 7673 insertions, 3595 deletions
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Arc.java b/src/classes/com/sun/opengl/impl/nurbs/Arc.java
new file mode 100755
index 000000000..717edbb33
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Arc.java
@@ -0,0 +1,258 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+** 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.
+*/
+
+/**
+ * Trimming arc
+ * @author Tomas Hrasky
+ *
+ */
+class Arc {
+ /**
+ * Corresponding picewise-linear arc
+ */
+ public PwlArc pwlArc;
+
+ /**
+ * Arc type
+ */
+ private long type;
+
+ /**
+ * Arc link in linked list
+ */
+ public Arc link;
+
+ /**
+ * Previous arc
+ */
+ Arc prev;
+
+ /**
+ * Next arc
+ */
+ Arc next;
+
+ /**
+ * Corresponding berizer type arc
+ */
+ private BezierArc bezierArc;
+
+ /**
+ * Makes new arc at specified side
+ *
+ * @param side
+ * which side doeas this arc form
+ */
+ public Arc(int side) {
+ bezierArc = null;
+ pwlArc = null;
+ type = 0;
+ setside(side);
+ // nuid=_nuid
+ }
+
+ /**
+ * Sets side the arc is at
+ *
+ * @param side
+ * arc side
+ */
+ private void setside(int side) {
+ // DONE
+ clearside();
+ type |= side << 8;
+ }
+
+ /**
+ * Unsets side
+ */
+ private void clearside() {
+ // DONE
+ type &= ~(0x7 << 8);
+ }
+
+ // this one replaces enum arc_side
+ /**
+ * Side not specified
+ */
+ public static final int ARC_NONE = 0;
+
+ /**
+ * Arc on right
+ */
+ public static final int ARC_RIGHT = 1;
+
+ /**
+ * Arc on top
+ */
+ public static final int ARC_TOP = 2;
+
+ /**
+ * Arc on left
+ */
+ public static final int ARC_LEFT = 3;
+
+ /**
+ * Arc on bottom
+ */
+ public static final int ARC_BOTTOM = 4;
+
+ /**
+ * Bezier type flag
+ */
+ private static final long BEZIER_TAG = 1 << 13;
+
+ /**
+ * Arc type flag
+ */
+ private static final long ARC_TAG = 1 << 3;
+
+ /**
+ * Tail type tag
+ */
+ private static final long TAIL_TAG = 1 << 6;
+
+ /**
+ * Appends arc to the list
+ *
+ * @param jarc
+ * arc to be append
+ * @return this
+ */
+ public Arc append(Arc jarc) {
+ // DONE
+ if (jarc != null) {
+ next = jarc.next;
+ prev = jarc;
+ next.prev = this;
+ prev.next = this;
+ } else {
+ next = this;
+ prev = this;
+ }
+
+ return this;
+ }
+
+ /**
+ * Unused
+ *
+ * @return true
+ */
+ public boolean check() {
+ return true;
+ }
+
+ /**
+ * Sets bezier type flag
+ */
+ public void setbezier() {
+ // DONE
+ type |= BEZIER_TAG;
+
+ }
+
+ /**
+ * Returns tail of linked list coords
+ *
+ * @return tail coords
+ */
+ public float[] tail() {
+ // DONE
+ return pwlArc.pts[0].param;
+ }
+
+ /**
+ * Returns head of linked list coords
+ *
+ * @return head coords
+ */
+ public float[] head() {
+ // DONE
+ return next.pwlArc.pts[0].param;
+ }
+
+ /**
+ * Returns whether arc is marked with arc_tag
+ *
+ * @return is arc marked with arc_tag
+ */
+ public boolean ismarked() {
+ // DONE
+ return ((type & ARC_TAG) > 0) ? true : false;
+ }
+
+ /**
+ * Cleans arc_tag flag
+ */
+ public void clearmark() {
+ // DONE
+ type &= (~ARC_TAG);
+ }
+
+ /**
+ * Sets arc_tag flag
+ */
+ public void setmark() {
+ // DONE
+ type |= ARC_TAG;
+ }
+
+ /**
+ * sets tail tag
+ */
+ public void setitail() {
+ // DONE
+ type |= TAIL_TAG;
+ }
+
+ /**
+ * Returns whether arc is marked tail
+ *
+ * @return is tail
+ */
+ public boolean getitail() {
+ return false;
+ }
+
+ /**
+ * Unsets tail tag
+ */
+ public void clearitail() {
+ // DONE
+ type &= (~TAIL_TAG);
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/ArcSdirSorter.java b/src/classes/com/sun/opengl/impl/nurbs/ArcSdirSorter.java
new file mode 100755
index 000000000..cc420b48c
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/ArcSdirSorter.java
@@ -0,0 +1,63 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Class for sorting list of Arcs
+ * @author Tomas Hrasky
+ *
+ */
+class ArcSdirSorter {
+
+ /**
+ * Makes new ArcSdirSorter with Subdivider
+ * @param subdivider subdivider
+ */
+ public ArcSdirSorter(Subdivider subdivider) {
+ //TODO
+ // System.out.println("TODO arcsdirsorter.constructor");
+ }
+
+ /**
+ * Sorts list of arcs
+ * @param list arc list to be sorted
+ * @param count size of list
+ */
+ public void qsort(CArrayOfArcs list, int count) {
+ // TODO
+ // System.out.println("TODO arcsdirsorter.qsort");
+ }
+
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/ArcTdirSorter.java b/src/classes/com/sun/opengl/impl/nurbs/ArcTdirSorter.java
new file mode 100755
index 000000000..88b6e3285
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/ArcTdirSorter.java
@@ -0,0 +1,60 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Class for sorting list of Arcs
+ * @author Tomas Hrasky
+ *
+ */
+class ArcTdirSorter {
+ /**
+ * Makes new ArcSdirSorter with Subdivider
+ * @param subdivider subdivider
+ */
+ public ArcTdirSorter(Subdivider subdivider) {
+ // TODO Auto-generated constructor stub
+ // System.out.println("TODO arcTsorter.konstruktor");
+ }
+ /**
+ * Sorts list of arcs
+ * @param list arc list to be sorted
+ * @param count size of list
+ */
+ public void qsort(CArrayOfArcs list, int count) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO arcTsorter.qsort");
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/ArcTesselator.java b/src/classes/com/sun/opengl/impl/nurbs/ArcTesselator.java
new file mode 100755
index 000000000..61cd969ea
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/ArcTesselator.java
@@ -0,0 +1,90 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Class for arc tesselation
+ * @author Tomas Hrasky
+ *
+ */
+class ArcTesselator {
+
+ /**
+ * Makes given arc an bezier arc
+ * @param arc arc to work with
+ * @param s1 minimum s param
+ * @param s2 maximum s param
+ * @param t1 minimum t param
+ * @param t2 maximum s param
+ */
+ public void bezier(Arc arc, float s1, float s2, float t1, float t2) {
+ // DONE
+ TrimVertex[] p = new TrimVertex[2];
+ p[0] = new TrimVertex();
+ p[1] = new TrimVertex();
+ arc.pwlArc = new PwlArc(2, p);
+ p[0].param[0] = s1;
+ p[0].param[1] = s2;
+ p[1].param[0] = t1;
+ p[1].param[1] = t2;
+ arc.setbezier();
+ }
+
+ /**
+ * Empty method
+ * @param newright arc to work with
+ * @param s first tail
+ * @param t2 second tail
+ * @param t1 third tail
+ * @param f stepsize
+ */
+ public void pwl_right(Arc newright, float s, float t1, float t2, float f) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO arctesselator.pwl_right");
+ }
+
+ /**
+ * Empty method
+ * @param newright arc to work with
+ * @param s first tail
+ * @param t2 second tail
+ * @param t1 third tail
+ * @param f stepsize
+ */
+ public void pwl_left(Arc newright, float s, float t2, float t1, float f) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO arctesselator.pwl_left");
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Backend.java b/src/classes/com/sun/opengl/impl/nurbs/Backend.java
new file mode 100755
index 000000000..aff484b04
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Backend.java
@@ -0,0 +1,217 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Class responsible for rendering
+ * @author Tomas Hrasky
+ *
+ */
+class Backend {
+
+ /**
+ * Fill surface
+ */
+ public static final int N_MESHFILL = 0;
+
+ /**
+ * Draw surface as wire model
+ */
+ public static final int N_MESHLINE = 1;
+
+ /**
+ * Draw surface with points
+ */
+ public static final int N_MESHPOINT = 2;
+
+ /**
+ * Object rendering curves
+ */
+ private OpenGLCurveEvaluator curveEvaluator;
+
+ /**
+ * Object rendering surfaces
+ */
+ private OpenGLSurfaceEvaluator surfaceEvaluator;
+
+ /**
+ * Makes new backend
+ */
+ public Backend() {
+ curveEvaluator = new OpenGLCurveEvaluator();
+ surfaceEvaluator = new OpenGLSurfaceEvaluator();
+ }
+
+ /**
+ * Begin a curve
+ */
+ public void bgncurv() {
+ // DONE
+ curveEvaluator.bgnmap1f();
+
+ }
+
+ /**
+ * End a curve
+ */
+ public void endcurv() {
+ // DONE
+ curveEvaluator.endmap1f();
+
+ }
+
+ /**
+ * Make cuve with given parameters
+ * @param type curve type
+ * @param ps control points
+ * @param stride control points coordinates number
+ * @param order order of curve
+ * @param ulo smallest u
+ * @param uhi highest u
+ */
+ public void curvpts(int type, CArrayOfFloats ps, int stride, int order,
+ float ulo, float uhi) {
+ // DONE
+ curveEvaluator.map1f(type, ulo, uhi, stride, order, ps);
+ curveEvaluator.enable(type);
+ }
+
+ /**
+ * Draw curve
+ * @param u1 smallest u
+ * @param u2 highest u
+ * @param nu number of pieces
+ */
+ public void curvgrid(float u1, float u2, int nu) {
+ // DONE
+ curveEvaluator.mapgrid1f(nu, u1, u2);
+
+ }
+
+ /**
+ * Evaluates curve mesh
+ * @param from low param
+ * @param n step
+ */
+ public void curvmesh(int from, int n) {
+ // DONE
+ curveEvaluator.mapmesh1f(N_MESHFILL, from, from + n);
+ }
+
+ /**
+ * Begin surface
+ * @param wiretris use triangles
+ * @param wirequads use quads
+ */
+ public void bgnsurf(int wiretris, int wirequads) {
+ // DONE
+ surfaceEvaluator.bgnmap2f();
+
+ if (wiretris > 0)
+ surfaceEvaluator.polymode(NurbsConsts.N_MESHLINE);
+ else
+ surfaceEvaluator.polymode(NurbsConsts.N_MESHFILL);
+ }
+
+ /**
+ * End surface
+ */
+ public void endsurf() {
+ // DONE
+ surfaceEvaluator.endmap2f();
+ }
+
+ /**
+ * Empty method
+ * @param ulo low u param
+ * @param uhi hig u param
+ * @param vlo low v param
+ * @param vhi high v param
+ */
+ public void patch(float ulo, float uhi, float vlo, float vhi) {
+ // DONE
+ surfaceEvaluator.domain2f(ulo, uhi, vlo, vhi);
+ }
+
+ /**
+ * Draw surface
+ * @param u0 lowest u
+ * @param u1 highest u
+ * @param nu number of pieces in u direction
+ * @param v0 lowest v
+ * @param v1 highest v
+ * @param nv number of pieces in v direction
+ */
+ public void surfgrid(float u0, float u1, int nu, float v0, float v1, int nv) {
+ // DONE
+ surfaceEvaluator.mapgrid2f(nu, u0, u1, nv, v0, v1);
+
+ }
+
+ /**
+ * Evaluates surface mesh
+ * @param u u param
+ * @param v v param
+ * @param n step in u direction
+ * @param m step in v direction
+ */
+ public void surfmesh(int u, int v, int n, int m) {
+ // System.out.println("TODO backend.surfmesh wireframequads");
+ // TODO wireframequads
+ surfaceEvaluator.mapmesh2f(NurbsConsts.N_MESHFILL, u, u + n, v, v + m);
+ }
+
+ /**
+ * Make surface
+ * @param type surface type
+ * @param pts control points
+ * @param ustride control points coordinates in u direction
+ * @param vstride control points coordinates in v direction
+ * @param uorder surface order in u direction
+ * @param vorder surface order in v direction
+ * @param ulo lowest u
+ * @param uhi hightest u
+ * @param vlo lowest v
+ * @param vhi hightest v
+ */
+ public void surfpts(int type, CArrayOfFloats pts, int ustride, int vstride,
+ int uorder, int vorder, float ulo, float uhi, float vlo, float vhi) {
+ // DONE
+ surfaceEvaluator.map2f(type, ulo, uhi, ustride, uorder, vlo, vhi,
+ vstride, vorder, pts);
+ surfaceEvaluator.enable(type);
+
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/BezierArc.java b/src/classes/com/sun/opengl/impl/nurbs/BezierArc.java
new file mode 100755
index 000000000..ed05f33c6
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/BezierArc.java
@@ -0,0 +1,44 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Empty class
+ * @author Tomas Hrasky
+ *
+ */
+class BezierArc {
+
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Bin.java b/src/classes/com/sun/opengl/impl/nurbs/Bin.java
new file mode 100755
index 000000000..2b23c34ab
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Bin.java
@@ -0,0 +1,155 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Class holding trimming arcs
+ * @author Tomas Hrasky
+ *
+ */
+class Bin {
+
+ /**
+ * Head of linked list of arcs
+ */
+ private Arc head;
+
+ /**
+ * Current arc
+ */
+ private Arc current;
+
+ /**
+ * Indicates whether there are any Arcs in linked list
+ * @return true if there are any Arcs in linked list
+ */
+ public boolean isnonempty() {
+ // DONE
+ return this.head != null ? true : false;
+ }
+
+ /**
+ * Adds and arc to linked list
+ * @param jarc added arc
+ */
+ public void addarc(Arc jarc) {
+ // DONE
+ // if (head == null)
+ // head = jarc;
+ // else {
+ jarc.link = head;
+ head = jarc;
+ // }
+
+ }
+
+ /**
+ * Returns number of arcs in linked list
+ * @return number of arcs
+ */
+ public int numarcs() {
+ // DONE
+ int count = 0;
+ for (Arc jarc = firstarc(); jarc != null; jarc = nextarc())
+ count++;
+ return count;
+ }
+
+ /**
+ * Removes first arc in list
+ * @return new linked list head
+ */
+ public Arc removearc() {
+ // DONE
+ Arc jarc = head;
+ if (jarc != null)
+ head = jarc.link;
+ return jarc;
+
+ }
+
+ /**
+ * Consolidates linked list
+ */
+ public void adopt() {
+ // DONE
+ markall();
+
+ Arc orphan;
+ while ((orphan = removearc()) != null) {
+ for (Arc parent = orphan.next; !parent.equals(orphan); parent = parent.next) {
+ if (!parent.ismarked()) {
+ orphan.link = parent.link;
+ parent.link = orphan;
+ orphan.clearmark();
+ break;
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Marks all arc in linked list
+ */
+ private void markall() {
+ // DONE
+ for (Arc jarc = firstarc(); jarc != null; jarc = nextarc())
+ jarc.setmark();
+ }
+
+ /**
+ * Returns first arc in linked list
+ * @return first arc in linked list
+ */
+ private Arc firstarc() {
+ // DONE
+ current = head;
+ return nextarc();
+ }
+
+ /**
+ * Returns next arc in linked list
+ * @return next arc
+ *
+ */
+ private Arc nextarc() {
+ // DONE
+ Arc jarc = current;
+ if (jarc != null)
+ current = jarc.link;
+ return jarc;
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Breakpt.java b/src/classes/com/sun/opengl/impl/nurbs/Breakpt.java
new file mode 100755
index 000000000..a62a8bb80
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Breakpt.java
@@ -0,0 +1,59 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Class holding break point parameters
+ *
+ * @author Tomas Hrasky
+ *
+ */
+class Breakpt {
+
+ /**
+ * Breakpoint multiplicity
+ */
+ public int multi;
+
+ /**
+ * Breakpint value
+ */
+ public float value;
+
+ /**
+ * Breakpoint deficit (how many times it has to be added)
+ */
+ public int def;
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/CArrayOfArcs.java b/src/classes/com/sun/opengl/impl/nurbs/CArrayOfArcs.java
new file mode 100755
index 000000000..3d803f09c
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/CArrayOfArcs.java
@@ -0,0 +1,194 @@
+package com.sun.opengl.impl.nurbs;
+
+/**
+ * Class replacing C language pointer
+ *
+ * @author Tomas Hrasky
+ *
+ */
+class CArrayOfArcs {
+ /**
+ * Underlaying array
+ */
+ private Arc[] array;
+
+ /**
+ * Pointer to array member
+ */
+ private int pointer;
+
+ /**
+ * Don't check for array borders?
+ */
+ private boolean noCheck = true;
+
+ /**
+ * Makes new CArray
+ *
+ * @param array
+ * underlaying array
+ * @param pointer
+ * pointer (index) to array
+ */
+ public CArrayOfArcs(Arc[] array, int pointer) {
+ this.array = array;
+ // this.pointer=pointer;
+ setPointer(pointer);
+ }
+
+ /**
+ * Makes new CArray from other CArray
+ *
+ * @param carray
+ * reference array
+ */
+ public CArrayOfArcs(CArrayOfArcs carray) {
+ this.array = carray.array;
+ // this.pointer=carray.pointer;
+ setPointer(carray.pointer);
+ }
+
+ /**
+ * Makes new CArray with pointer set to 0
+ *
+ * @param ctlarray
+ * underlaying array
+ */
+ public CArrayOfArcs(Arc[] ctlarray) {
+ this.array = ctlarray;
+ this.pointer = 0;
+ }
+
+ /**
+ * Returns element at pointer
+ *
+ * @return element at pointer
+ */
+ public Arc get() {
+ return array[pointer];
+ }
+
+ /**
+ * Increases pointer by one (++)
+ */
+ public void pp() {
+ // pointer++;
+ setPointer(pointer + 1);
+ }
+
+ /**
+ * Sets element at pointer
+ *
+ * @param f
+ * desired value
+ */
+ public void set(Arc f) {
+ array[pointer] = f;
+
+ }
+
+ /**
+ * Returns array element at specified index
+ *
+ * @param i
+ * array index
+ * @return element at index
+ */
+ public Arc get(int i) {
+ return array[i];
+ }
+
+ /**
+ * Returns array element at specified index relatively to pointer
+ *
+ * @param i
+ * relative index
+ * @return element at relative index
+ */
+ public Arc getRelative(int i) {
+ return array[pointer + i];
+ }
+
+ /**
+ * Sets value of element at specified index relatively to pointer
+ *
+ * @param i
+ * relative index
+ * @param value
+ * value to be set
+ */
+ public void setRelative(int i, Arc value) {
+ array[pointer + i] = value;
+ }
+
+ /**
+ * Lessens pointer by value
+ *
+ * @param i
+ * lessen by
+ */
+ public void lessenPointerBy(int i) {
+ // pointer-=i;
+ setPointer(pointer - i);
+ }
+
+ /**
+ * Returns pointer value
+ *
+ * @return pointer value
+ */
+ public int getPointer() {
+ return pointer;
+ }
+
+ /**
+ * Sets ponter value
+ *
+ * @param pointer
+ * pointer value to be set
+ */
+ public void setPointer(int pointer) {
+ if (!noCheck && pointer > array.length)
+ throw new IllegalArgumentException("Pointer " + pointer
+ + " out of bounds " + array.length);
+ this.pointer = pointer;
+ }
+
+ /**
+ * Raises pointer by value
+ *
+ * @param i
+ * raise by
+ */
+ public void raisePointerBy(int i) {
+ // pointer+=i;
+ setPointer(pointer + i);
+ }
+
+ /**
+ * Lessens ponter by one (--)
+ */
+ public void mm() {
+ // pointer--;
+ setPointer(pointer - 1);
+ }
+
+ /**
+ * Returns underlaying array
+ *
+ * @return underlaying array
+ */
+ public Arc[] getArray() {
+ return array;
+ }
+
+ /**
+ * Sets underlaying array
+ *
+ * @param array
+ * underlaying array
+ */
+ public void setArray(Arc[] array) {
+ this.array = array;
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/CArrayOfBreakpts.java b/src/classes/com/sun/opengl/impl/nurbs/CArrayOfBreakpts.java
new file mode 100755
index 000000000..c4c14b66c
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/CArrayOfBreakpts.java
@@ -0,0 +1,130 @@
+package com.sun.opengl.impl.nurbs;
+
+/**
+ * Class replacing C language pointer
+ *
+ * @author Tomas Hrasky
+ *
+ */
+class CArrayOfBreakpts {
+ /**
+ * Underlaying array
+ */
+ private Breakpt[] pole;
+
+ /**
+ * Pointer to array member
+ */
+ private int pointer;
+
+ /**
+ * Makes new CArray
+ *
+ * @param array
+ * underlaying array
+ * @param pointer
+ * pointer (index) to array
+ */
+ public CArrayOfBreakpts(Breakpt[] array, int pointer) {
+ this.pole = array;
+ this.pointer = pointer;
+ }
+
+ /**
+ * Makes new CArray from other CArray
+ *
+ * @param carray
+ * reference array
+ */
+ public CArrayOfBreakpts(CArrayOfBreakpts carray) {
+ this.pole = carray.pole;
+ this.pointer = carray.pointer;
+ }
+
+ /**
+ * Returns element at pointer
+ *
+ * @return element at pointer
+ */
+ public Breakpt get() {
+ return pole[pointer];
+ }
+
+ /**
+ * Increases pointer by one (++)
+ */
+ public void pp() {
+ pointer++;
+ }
+
+ /**
+ * Sets element at pointer
+ *
+ * @param f
+ * desired value
+ */
+ public void set(Breakpt f) {
+ pole[pointer] = f;
+
+ }
+
+ /**
+ * Returns array element at specified index
+ *
+ * @param i
+ * array index
+ * @return element at index
+ */
+ public Breakpt get(int i) {
+ return pole[i];
+ }
+
+ /**
+ * Lessens pointer by value
+ *
+ * @param i
+ * lessen by
+ */
+ public void lessenPointerBy(int i) {
+ pointer -= i;
+
+ }
+
+ /**
+ * Returns pointer value
+ *
+ * @return pointer value
+ */
+ public int getPointer() {
+ return pointer;
+ }
+
+ /**
+ * Sets ponter value
+ *
+ * @param pointer
+ * pointer value to be set
+ */
+ public void setPointer(int pointer) {
+ this.pointer = pointer;
+ }
+
+ /**
+ * Raises pointer by value
+ *
+ * @param i
+ * raise by
+ */
+ public void raisePointerBy(int i) {
+ pointer += i;
+
+ }
+
+ /**
+ * Lessens ponter by one (--)
+ */
+ public void mm() {
+ pointer--;
+
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/CArrayOfFloats.java b/src/classes/com/sun/opengl/impl/nurbs/CArrayOfFloats.java
new file mode 100755
index 000000000..237715a01
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/CArrayOfFloats.java
@@ -0,0 +1,195 @@
+package com.sun.opengl.impl.nurbs;
+
+/**
+ * Class replacing C language pointer
+ *
+ * @author Tomas Hrasky
+ *
+ */
+class CArrayOfFloats {
+
+ /**
+ * Underlaying array
+ */
+ private float[] array;
+
+ /**
+ * Pointer to array member
+ */
+ private int pointer;
+
+ /**
+ * Don't check for array borders?
+ */
+ private boolean noCheck = true;
+
+ /**
+ * Makes new CArray
+ *
+ * @param array
+ * underlaying array
+ * @param pointer
+ * pointer (index) to array
+ */
+ public CArrayOfFloats(float[] array, int pointer) {
+ this.array = array;
+ // this.pointer=pointer;
+ setPointer(pointer);
+ }
+
+ /**
+ * Makes new CArray from other CArray
+ *
+ * @param carray
+ * reference array
+ */
+ public CArrayOfFloats(CArrayOfFloats carray) {
+ this.array = carray.array;
+ // this.pointer=carray.pointer;
+ setPointer(carray.pointer);
+ }
+
+ /**
+ * Makes new CArray with pointer set to 0
+ *
+ * @param ctlarray
+ * underlaying array
+ */
+ public CArrayOfFloats(float[] ctlarray) {
+ this.array = ctlarray;
+ this.pointer = 0;
+ }
+
+ /**
+ * Returns element at pointer
+ *
+ * @return element at pointer
+ */
+ public float get() {
+ return array[pointer];
+ }
+
+ /**
+ * Increases pointer by one (++)
+ */
+ public void pp() {
+ // pointer++;
+ setPointer(pointer + 1);
+ }
+
+ /**
+ * Sets element at pointer
+ *
+ * @param f
+ * desired value
+ */
+ public void set(float f) {
+ array[pointer] = f;
+
+ }
+
+ /**
+ * Returns array element at specified index
+ *
+ * @param i
+ * array index
+ * @return element at index
+ */
+ public float get(int i) {
+ return array[i];
+ }
+
+ /**
+ * Returns array element at specified index relatively to pointer
+ *
+ * @param i
+ * relative index
+ * @return element at relative index
+ */
+ public float getRelative(int i) {
+ return array[pointer + i];
+ }
+
+ /**
+ * Sets value of element at specified index relatively to pointer
+ *
+ * @param i
+ * relative index
+ * @param value
+ * value to be set
+ */
+ public void setRelative(int i, float value) {
+ array[pointer + i] = value;
+ }
+
+ /**
+ * Lessens pointer by value
+ *
+ * @param i
+ * lessen by
+ */
+ public void lessenPointerBy(int i) {
+ // pointer-=i;
+ setPointer(pointer - i);
+ }
+
+ /**
+ * Returns pointer value
+ *
+ * @return pointer value
+ */
+ public int getPointer() {
+ return pointer;
+ }
+
+ /**
+ * Sets ponter value
+ *
+ * @param pointer
+ * pointer value to be set
+ */
+ public void setPointer(int pointer) {
+ if (!noCheck && pointer > array.length)
+ throw new IllegalArgumentException("Pointer " + pointer
+ + " out of bounds " + array.length);
+ this.pointer = pointer;
+ }
+
+ /**
+ * Raises pointer by value
+ *
+ * @param i
+ * raise by
+ */
+ public void raisePointerBy(int i) {
+ // pointer+=i;
+ setPointer(pointer + i);
+ }
+
+ /**
+ * Lessens ponter by one (--)
+ */
+ public void mm() {
+ // pointer--;
+ setPointer(pointer - 1);
+ }
+
+ /**
+ * Returns underlaying array
+ *
+ * @return underlaying array
+ */
+ public float[] getArray() {
+ return array;
+ }
+
+ /**
+ * Sets underlaying array
+ *
+ * @param array
+ * underlaying array
+ */
+ public void setArray(float[] array) {
+ this.array = array;
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/CArrayOfQuiltspecs.java b/src/classes/com/sun/opengl/impl/nurbs/CArrayOfQuiltspecs.java
new file mode 100755
index 000000000..40559fe6b
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/CArrayOfQuiltspecs.java
@@ -0,0 +1,160 @@
+package com.sun.opengl.impl.nurbs;
+
+/**
+ * Class replacing C language pointer
+ *
+ * @author Tomas Hrasky
+ *
+ */
+class CArrayOfQuiltspecs {
+ /**
+ * Underlaying array
+ */
+ private Quiltspec[] array;
+
+ /**
+ * Pointer to array member
+ */
+ private int pointer;
+
+ /**
+ * Makes new CArray
+ *
+ * @param array
+ * underlaying array
+ * @param pointer
+ * pointer (index) to array
+ */
+ public CArrayOfQuiltspecs(Quiltspec[] array, int pointer) {
+ this.array = array;
+ this.pointer = pointer;
+ }
+
+ /**
+ * Makes new CArray from other CArray
+ *
+ * @param carray
+ * reference array
+ */
+ public CArrayOfQuiltspecs(CArrayOfQuiltspecs carray) {
+ this.array = carray.array;
+ this.pointer = carray.pointer;
+ }
+
+ /**
+ * Makes new CArray with pointer set to 0
+ *
+ * @param array
+ * underlaying array
+ */
+ public CArrayOfQuiltspecs(Quiltspec[] array) {
+ this.array = array;
+ this.pointer = 0;
+ }
+
+ /**
+ * Returns element at pointer
+ *
+ * @return element at pointer
+ */
+ public Quiltspec get() {
+ return array[pointer];
+ }
+
+ /**
+ * Increases pointer by one (++)
+ */
+ public void pp() {
+ pointer++;
+ }
+
+ /**
+ * Sets element at pointer
+ *
+ * @param f
+ * desired value
+ */
+ public void set(Quiltspec f) {
+ array[pointer] = f;
+
+ }
+
+ /**
+ * Returns array element at specified index
+ *
+ * @param i
+ * array index
+ * @return element at index
+ */
+ public Quiltspec get(int i) {
+ return array[i];
+ }
+
+ /**
+ * Lessens pointer by value
+ *
+ * @param i
+ * lessen by
+ */
+ public void lessenPointerBy(int i) {
+ pointer -= i;
+
+ }
+
+ /**
+ * Returns pointer value
+ *
+ * @return pointer value
+ */
+ public int getPointer() {
+ return pointer;
+ }
+
+ /**
+ * Sets ponter value
+ *
+ * @param pointer
+ * pointer value to be set
+ */
+ public void setPointer(int pointer) {
+ this.pointer = pointer;
+ }
+
+ /**
+ * Raises pointer by value
+ *
+ * @param i
+ * raise by
+ */
+ public void raisePointerBy(int i) {
+ pointer += i;
+
+ }
+
+ /**
+ * Lessens ponter by one (--)
+ */
+ public void mm() {
+ pointer--;
+
+ }
+
+ /**
+ * Returns underlaying array
+ *
+ * @return underlaying array
+ */
+ public Quiltspec[] getArray() {
+ return array;
+ }
+
+ /**
+ * Sets underlaying array
+ *
+ * @param array
+ * underlaying array
+ */
+ public void setArray(Quiltspec[] array) {
+ this.array = array;
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Curve.java b/src/classes/com/sun/opengl/impl/nurbs/Curve.java
new file mode 100755
index 000000000..0fe7418f2
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Curve.java
@@ -0,0 +1,238 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Class holding curve definition
+ * @author Tomáš Hráský
+ *
+ */
+class Curve {
+
+ /**
+ * Maximum coordinates per control point
+ */
+ private static final int MAXCOORDS = 5;
+
+ /**
+ * Max curve order
+ */
+ private static final int MAXORDER = 24;
+
+ /**
+ * Next curve in linked list
+ */
+ public Curve next;
+
+ /**
+ * OpenGL maps
+ */
+ private Mapdesc mapdesc;
+
+ /**
+ * Does the curve need sampling
+ */
+ private boolean needsSampling;
+
+ /**
+ * Culling
+ */
+ private int cullval;
+
+ /**
+ * Number of coords
+ */
+ private int stride;
+
+ /**
+ * Curve order
+ */
+ private int order;
+
+ /**
+ * Holds conversion range borders
+ */
+ private float[] range;
+
+ /**
+ * Subdivision stepsize
+ */
+ public float stepsize;
+
+ /**
+ * Minimal subdivision stepsize
+ */
+ private float minstepsize;
+
+ /**
+ * Sampling points
+ */
+ float[] spts;
+
+ /**
+ * Makes new Curve
+ *
+ * @param geo
+ * @param pta
+ * @param ptb
+ * @param c
+ * next curve in linked list
+ */
+ public Curve(Quilt geo, float[] pta, float[] ptb, Curve c) {
+
+ spts = new float[MAXORDER * MAXCOORDS];
+
+ mapdesc = geo.mapdesc;
+
+ next = c;
+ needsSampling = mapdesc.isRangeSampling() ? true : false;
+
+ cullval = mapdesc.isCulling() ? Subdivider.CULL_ACCEPT
+ : Subdivider.CULL_TRIVIAL_REJECT;
+ order = geo.qspec.get(0).order;
+ stride = MAXCOORDS;
+
+ // CArrayOfFloats ps = geo.cpts;
+ CArrayOfFloats ps = new CArrayOfFloats(geo.cpts.getArray(), 0);
+ CArrayOfQuiltspecs qs = geo.qspec;
+ ps.raisePointerBy(qs.get().offset);
+ ps.raisePointerBy(qs.get().index * qs.get().order * qs.get().stride);
+
+ if (needsSampling) {
+ mapdesc.xformSampling(ps, qs.get().order, qs.get().stride, spts,
+ stride);
+ }
+ if (cullval == Subdivider.CULL_ACCEPT) {
+ // System.out.println("TODO curve.Curve-cullval");
+ // mapdesc.xformCulling(ps,qs.get().order,qs.get().stride,cpts,stride);
+ }
+
+ range = new float[3];
+ range[0] = qs.get().breakpoints[qs.get().index];
+ range[1] = qs.get().breakpoints[qs.get().index + 1];
+ range[2] = range[1] - range[0];
+ // TODO it is necessary to solve problem with "this" pointer here
+ if (range[0] != pta[0]) {
+ // System.out.println("TODO curve.Curve-range0");
+ // Curve lower=new Curve(this,pta,0);
+ // lower.next=next;
+ // this=lower;
+ }
+ if (range[1] != ptb[0]) {
+ // System.out.println("TODO curve.Curve-range1");
+ // Curve lower=new Curve(this,ptb,0);
+ }
+ }
+
+ /**
+ * Checks culling type
+ * @return Subdivider.CULL_ACCEPT
+ */
+ public int cullCheck() {
+ if (cullval == Subdivider.CULL_ACCEPT) {
+ // System.out.println("TODO curve.cullval");
+ // cullval=mapdesc.cullCheck(cpts,order,stride);
+ }
+ // TODO compute cullval and return the computed value
+ // return cullval;
+ return Subdivider.CULL_ACCEPT;
+ }
+
+ /**
+ * Computes subdivision step size
+ */
+ public void getStepSize() {
+ minstepsize = 0;
+ if (mapdesc.isConstantSampling()) {
+ setstepsize(mapdesc.maxrate);
+ } else if (mapdesc.isDomainSampling()) {
+ setstepsize(mapdesc.maxrate * range[2]);
+ } else {
+ assert (order <= MAXORDER);
+
+ float tmp[][] = new float[MAXORDER][MAXCOORDS];
+
+ int tstride = (MAXORDER);
+
+ int val = 0;
+ // mapdesc.project(spts,stride,tmp,tstride,order);
+
+ // System.out.println("TODO curve.getsptepsize mapdesc.project");
+
+ if (val == 0) {
+ setstepsize(mapdesc.maxrate);
+ } else {
+ float t = mapdesc.getProperty(NurbsConsts.N_PIXEL_TOLERANCE);
+ if (mapdesc.isParametricDistanceSampling()) {
+ // System.out.println("TODO curve.getstepsize - parametric");
+ } else if (mapdesc.isPathLengthSampling()) {
+ // System.out.println("TODO curve.getstepsize - pathlength");
+ } else {
+ setstepsize(mapdesc.maxrate);
+ }
+ }
+
+ }
+
+ }
+
+ /**
+ * Sets maximum subdivision step size
+ * @param max maximum subdivision step size
+ */
+ private void setstepsize(float max) {
+ // DONE
+ stepsize = (max >= 1) ? (range[2] / max) : range[2];
+ minstepsize = stepsize;
+ }
+
+ /**
+ * Clamps the curve
+ */
+ public void clamp() {
+ // DONE
+ if (stepsize < minstepsize)
+ stepsize = mapdesc.clampfactor * minstepsize;
+ }
+
+ /**
+ * Tells whether curve needs subdivision
+ *
+ * @return curve needs subdivison
+ */
+ public boolean needsSamplingSubdivision() {
+ return (stepsize < minstepsize);
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Curvelist.java b/src/classes/com/sun/opengl/impl/nurbs/Curvelist.java
new file mode 100755
index 000000000..b37aac927
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Curvelist.java
@@ -0,0 +1,121 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Class for woking with linked list of curves
+ * @author Tomas Hrasky
+ *
+ */
+class Curvelist {
+
+ /**
+ * Head of linked list
+ */
+ private Curve curve;
+
+ /**
+ * Holds conversion range borders
+ */
+ float[] range;
+
+ /**
+ * Subdivision step size
+ */
+ public float stepsize;
+
+ /**
+ * Do curves need subdivision?
+ */
+ private boolean needsSubdivision;
+
+ /**
+ * Makes new instance on top of specified lis of Quilts
+ * @param qlist underlaying list of quilts
+ * @param pta range start
+ * @param ptb range end
+ */
+ public Curvelist(Quilt qlist, float[] pta, float[] ptb) {
+ // DONE
+ curve = null;
+ range = new float[3];
+
+ for (Quilt q = qlist; q != null; q = q.next) {
+ curve = new Curve(q, pta, ptb, curve);
+ }
+ range[0] = pta[0];
+ range[1] = ptb[0];
+ range[2] = range[1] - range[0];
+ }
+
+ /**
+ * Compute step size
+ */
+ public void getstepsize() {
+ // DONE
+ stepsize = range[2];
+ Curve c;
+ for (c = curve; c != null; c = c.next) {
+ c.getStepSize();
+ c.clamp();
+ stepsize = (c.stepsize < stepsize) ? c.stepsize : stepsize;
+ if (c.needsSamplingSubdivision())
+ break;
+ }
+ needsSubdivision = (c != null) ? true : false;
+
+ }
+
+ /**
+ * Indicates whether curves need subdivision
+ * @return curves need subdivision
+ */
+ public boolean needsSamplingSubdivision() {
+ // DONE
+ return needsSubdivision;
+ }
+
+ /**
+ * Checks for culling
+ * @return Subdivider.CULL_TRIVIAL_REJECT or Subdivider.CULL_ACCEPT
+ */
+ public int cullCheck() {
+ // DONE
+ for (Curve c = curve; c != null; c = c.next)
+ if (c.cullCheck() == Subdivider.CULL_TRIVIAL_REJECT)
+ return Subdivider.CULL_TRIVIAL_REJECT;
+ return Subdivider.CULL_ACCEPT;
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/DisplayList.java b/src/classes/com/sun/opengl/impl/nurbs/DisplayList.java
new file mode 100755
index 000000000..8ea8392b3
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/DisplayList.java
@@ -0,0 +1,56 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+import java.lang.reflect.Method;
+
+/**
+ * Display list
+ * @author Tomas Hrasky
+ *
+ */
+class DisplayList {
+
+ /**
+ * Append action to the display list
+ * @param src source object to invoke method on
+ * @param m invoked method
+ * @param arg method argument
+ */
+ public void append(Object src, Method m, Object arg) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO displaylist append");
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Flist.java b/src/classes/com/sun/opengl/impl/nurbs/Flist.java
new file mode 100755
index 000000000..bf1b45986
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Flist.java
@@ -0,0 +1,130 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+import java.util.Arrays;
+
+/**
+ * List of breakpoints
+ * @author Tomas Hrasky
+ *
+ */
+class Flist {
+
+ /**
+ * Data elements end index
+ *
+ */
+ public int end;
+
+ /**
+ *Data elements start index
+ */
+ public int start;
+
+ /**
+ * Breakpoint values
+ */
+ public float[] pts;
+
+ /**
+ * Number of array fields
+ */
+ private int npts;
+
+ /**
+ * Grows list
+ * @param maxpts maximum desired size
+ */
+ public void grow(int maxpts) {
+ // DONE
+ if (npts < maxpts) {
+ // npts=2*maxpts;
+ npts = maxpts;
+ pts = new float[npts];
+ }
+ start = 0;
+ end = 0;
+ }
+
+ /**
+ * Removes duplicate array elemnts
+ */
+ public void filter() {
+ // INFO the aim of this method is to remove duplicates from array
+
+ Arrays.sort(pts);
+
+ 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;
+
+ }
+
+ /**
+ * Sets start and and to real start and end of array elements
+ * @param from start from
+ * @param to end at
+ */
+ public void taper(float from, float to) {
+ // DONE
+
+ while (pts[start] != from) {
+ start++;
+ }
+
+ while (pts[end - 1] != to) {
+ end--;
+ }
+
+ }
+
+ /**
+ * Adds breakpoint value
+ * @param f value
+ */
+ public void add(float f) {
+ //DONE
+ pts[end++] = f;
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/GLUnurbsImpl.java b/src/classes/com/sun/opengl/impl/nurbs/GLUnurbsImpl.java
new file mode 100755
index 000000000..fd277744e
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/GLUnurbsImpl.java
@@ -0,0 +1,860 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+import java.lang.reflect.Method;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.glu.GLUnurbs;
+
+/**
+ * Base object for working with NURBS curves and surfaces
+ *
+ * @author Tomas Hrasky
+ *
+ */
+public class GLUnurbsImpl implements GLUnurbs {
+
+ /**
+ * Curve type - no type
+ */
+ public static final int CT_NONE = 0;
+
+ /**
+ * Curve type - NURBS curve
+ */
+ public static final int CT_NURBSCURVE = 1;
+
+ /**
+ * Curve type - picewise linear curve
+ */
+ public static final int CT_NPWLCURVE = 2;
+
+ /**
+ * Matrixes autoloading
+ */
+ private boolean autoloadmode;
+
+ /**
+ * Using callback
+ */
+ private int callBackFlag;
+
+ /**
+ * Object for error call backs
+ */
+ private Object errorCallback;
+
+ /**
+ * List of map definitions
+ */
+ Maplist maplist;
+
+ /**
+ * Indicates validity of data
+ */
+ private int isDataValid;
+
+ /**
+ * Are we in the middle of curve processing
+ */
+ private int inCurve;
+
+ /**
+ * Current curve
+ */
+ private O_curve currentCurve;
+
+ /**
+ * Are we in trim
+ */
+ private boolean inTrim;
+
+ /**
+ * Are we playbacking curve/surface rendering
+ */
+ private boolean playBack;
+
+ /**
+ * Next curve in linked list
+ */
+ private O_curve nextCurve;
+
+ /**
+ * Is curve modified
+ */
+ private int isCurveModified;
+
+ /**
+ * Object holding rendering settings
+ */
+ private Renderhints renderhints;
+
+ /**
+ * Display list
+ */
+ private DisplayList dl;
+
+ /**
+ * Object for subdividing curves and surfaces
+ */
+ private Subdivider subdivider;
+
+ /**
+ * Object responsible for rendering
+ */
+ private Backend backend;
+
+ /**
+ * Next picewise linear curve in linked list
+ */
+ private O_pwlcurve nextPwlcurve;
+
+ /**
+ * Next trimming NURBS curve in linked list
+ */
+ private O_nurbscurve nextNurbscurve;
+
+ /**
+ * Are we in the middle of surface processing
+ */
+ private int inSurface;
+
+ /**
+ * Are there any changes in trimming
+ */
+ private boolean isTrimModified;
+
+ /**
+ * Are there any changes in surface data
+ */
+ private boolean isDataSurfaceModified;
+
+ /**
+ * Nurber of trmims of processed surface
+ */
+ private int numTrims;
+
+ /**
+ * Current processed surface
+ */
+ private O_surface currentSurface;
+
+ /**
+ * Next trimming curve
+ */
+ private O_trim nextTrim;
+
+ /**
+ * Nextr surface in linked list
+ */
+ private O_nurbssurface nextNurbssurface;
+
+ /**
+ * Are there any changes in surface
+ */
+ private boolean isSurfaceModified;
+
+ /**
+ * Initializes default GLUnurbs object
+ */
+ public GLUnurbsImpl() {
+ // DONE
+ maplist = new Maplist(backend);
+ renderhints = new Renderhints();
+ subdivider = new Subdivider();
+ // original code
+
+ redefineMaps();
+
+ defineMap(GL.GL_MAP2_NORMAL, 0, 3);
+ defineMap(GL.GL_MAP1_NORMAL, 0, 3);
+ defineMap(GL.GL_MAP2_TEXTURE_COORD_1, 0, 1);
+ defineMap(GL.GL_MAP1_TEXTURE_COORD_1, 0, 1);
+ defineMap(GL.GL_MAP2_TEXTURE_COORD_2, 0, 2);
+ defineMap(GL.GL_MAP1_TEXTURE_COORD_2, 0, 2);
+ defineMap(GL.GL_MAP2_TEXTURE_COORD_3, 0, 3);
+ defineMap(GL.GL_MAP1_TEXTURE_COORD_3, 0, 3);
+ defineMap(GL.GL_MAP2_TEXTURE_COORD_4, 1, 4);
+ defineMap(GL.GL_MAP1_TEXTURE_COORD_4, 1, 4);
+ defineMap(GL.GL_MAP2_VERTEX_4, 1, 4);
+ defineMap(GL.GL_MAP1_VERTEX_4, 1, 4);
+ defineMap(GL.GL_MAP2_VERTEX_3, 0, 3);
+ defineMap(GL.GL_MAP1_VERTEX_3, 0, 3);
+ defineMap(GL.GL_MAP2_COLOR_4, 0, 4);
+ defineMap(GL.GL_MAP1_COLOR_4, 0, 4);
+ defineMap(GL.GL_MAP2_INDEX, 0, 1);
+ defineMap(GL.GL_MAP1_INDEX, 0, 1);
+
+ setnurbsproperty(GL.GL_MAP1_VERTEX_3, NurbsConsts.N_SAMPLINGMETHOD,
+ (float) NurbsConsts.N_PATHLENGTH);
+ setnurbsproperty(GL.GL_MAP1_VERTEX_4, NurbsConsts.N_SAMPLINGMETHOD,
+ (float) NurbsConsts.N_PATHLENGTH);
+ setnurbsproperty(GL.GL_MAP2_VERTEX_3, NurbsConsts.N_SAMPLINGMETHOD,
+ (float) NurbsConsts.N_PATHLENGTH);
+ setnurbsproperty(GL.GL_MAP2_VERTEX_4, NurbsConsts.N_SAMPLINGMETHOD,
+ (float) NurbsConsts.N_PATHLENGTH);
+
+ setnurbsproperty(GL.GL_MAP1_VERTEX_3, NurbsConsts.N_PIXEL_TOLERANCE,
+ (float) 50.0);
+ setnurbsproperty(GL.GL_MAP1_VERTEX_4, NurbsConsts.N_PIXEL_TOLERANCE,
+ (float) 50.0);
+ setnurbsproperty(GL.GL_MAP2_VERTEX_3, NurbsConsts.N_PIXEL_TOLERANCE,
+ (float) 50.0);
+ setnurbsproperty(GL.GL_MAP2_VERTEX_4, NurbsConsts.N_PIXEL_TOLERANCE,
+ (float) 50.0);
+
+ setnurbsproperty(GL.GL_MAP1_VERTEX_3, NurbsConsts.N_ERROR_TOLERANCE,
+ (float) 0.50);
+ setnurbsproperty(GL.GL_MAP1_VERTEX_4, NurbsConsts.N_ERROR_TOLERANCE,
+ (float) 0.50);
+ setnurbsproperty(GL.GL_MAP2_VERTEX_3, NurbsConsts.N_ERROR_TOLERANCE,
+ (float) 0.50);
+ setnurbsproperty(GL.GL_MAP2_VERTEX_4, NurbsConsts.N_ERROR_TOLERANCE,
+ (float) 0.50);
+
+ setnurbsproperty(GL.GL_MAP1_VERTEX_3, NurbsConsts.N_S_STEPS,
+ (float) 100.0);
+ setnurbsproperty(GL.GL_MAP1_VERTEX_4, NurbsConsts.N_S_STEPS,
+ (float) 100.0);
+ setnurbsproperty(GL.GL_MAP2_VERTEX_3, NurbsConsts.N_S_STEPS,
+ (float) 100.0);
+ setnurbsproperty(GL.GL_MAP2_VERTEX_4, NurbsConsts.N_S_STEPS,
+ (float) 100.0);
+
+ setnurbsproperty(GL.GL_MAP1_VERTEX_3, NurbsConsts.N_SAMPLINGMETHOD,
+ NurbsConsts.N_PATHLENGTH);
+
+ set_domain_distance_u_rate(100.0);
+ set_domain_distance_v_rate(100.0);
+ set_is_domain_distance_sampling(0);
+
+ this.autoloadmode = true;
+
+ this.callBackFlag = 0;
+
+ this.errorCallback = null;
+ }
+
+ /**
+ * Sets domain distance for dom.dist. sampling in u direction
+ *
+ * @param d
+ * distance
+ */
+ private void set_domain_distance_u_rate(double d) {
+ // DONE
+ subdivider.set_domain_distance_u_rate(d);
+ }
+
+ /**
+ * Sets domain distance for dom.dist. sampling in v direction
+ *
+ * @param d
+ * distance
+ */
+ private void set_domain_distance_v_rate(double d) {
+ // DONE
+ subdivider.set_domain_distance_v_rate(d);
+ }
+
+ /**
+ * Begins new NURBS curve
+ */
+ public void bgncurve() {
+ // DONE
+ O_curve o_curve = new O_curve();
+ thread("do_bgncurve", o_curve);
+ }
+
+ /**
+ * Calls a method with given name and passes argumet
+ *
+ * @param name
+ * name of a method to be called
+ * @param arg
+ * parameter to be passed to called method
+ */
+ private void thread(String name, Object arg) {
+ // DONE
+ Class partype[] = new Class[1];
+ partype[0] = arg.getClass();
+ Method m;
+ try {
+ m = this.getClass().getMethod(name, partype);
+ if (dl != null) {
+ dl.append(this, m, arg);
+ } else {
+ m.invoke(this, new Object[] { arg });
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Calls a method with given name
+ *
+ * @param name
+ * name of a method to be called
+ */
+ private void thread2(String name) {
+ // DONE
+ try {
+ Method m = this.getClass().getMethod(name, (Class[]) null);
+ if (dl != null) {
+ dl.append(this, m, null);
+ } else {
+ m.invoke(this, (Object[]) null);
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Begins a NURBS curve
+ *
+ * @param o_curve
+ * curve object
+ */
+ public void do_bgncurve(O_curve o_curve) {
+ if (inCurve > 0) {
+ do_nurbserror(6);
+ endcurve();
+ }
+ inCurve = 1;
+ currentCurve = o_curve;
+
+ currentCurve.curvetype = CT_NONE;
+
+ if (inTrim) {
+ if (!nextCurve.equals(o_curve)) {
+ isCurveModified = 1;
+ nextCurve = o_curve;
+ }
+ } else {
+ if (!playBack)
+ bgnrender();
+ isDataValid = 1;
+ }
+ nextCurve = o_curve.next;
+ // kind of solution of union
+ nextPwlcurve = o_curve.o_pwlcurve;
+ nextNurbscurve = o_curve.o_nurbscurve;
+ }
+
+ /**
+ * Begins new surface
+ *
+ * @param o_surface
+ * surface object
+ */
+ public void do_bgnsurface(O_surface o_surface) {
+ // DONE
+ if (inSurface > 0) {
+ do_nurbserror(27);
+ endsurface();
+ }
+ inSurface = 1;
+ if (!playBack)
+ bgnrender();
+
+ isTrimModified = false;
+ isDataSurfaceModified = false;
+ isDataValid = 1;
+ numTrims = 0;
+ currentSurface = o_surface;
+ nextTrim = o_surface.o_trim;
+ nextNurbssurface = o_surface.o_nurbssurface;
+ }
+
+ /**
+ * End a curve
+ */
+ public void endcurve() {
+ // DONE
+ thread2("do_endcurve");
+ }
+
+ /**
+ * Ends surface
+ */
+ public void do_endsurface() {
+ // DONE
+ if (inTrim) {
+ do_nurbserror(12);
+ endtrim();
+ }
+
+ if (inSurface <= 0) {
+ do_nurbserror(13);
+ return;
+ }
+
+ inSurface = 0;
+
+ nextNurbssurface = null;
+
+ if (isDataValid <= 0) {
+ return;
+ }
+
+ if (nextTrim != null) {
+ isTrimModified = true;
+ nextTrim = null;
+ }
+
+ // TODO errval ??
+ if (numTrims > 0) {
+ // System.out.println("TODO glunurbs.do_endsurface - numtrims > 0");
+ }
+
+ subdivider.beginQuilts();
+ for (O_nurbssurface n = currentSurface.o_nurbssurface; n != null; n = n.next) {
+ subdivider.addQuilt(n.bezier_patches);
+ }
+ subdivider.endQuilts();
+ subdivider.drawSurfaces();
+ if (!playBack)
+ endrender();
+
+ }
+
+ /**
+ * Ends a curve
+ */
+ public void do_endcurve() {
+ // DONE
+ // // System.out.println("do_endcurve");
+ if (inCurve <= 0) {
+ do_nurbserror(7);
+ return;
+ }
+ inCurve = 0;
+
+ nextCurve = null;
+
+ if (currentCurve.curvetype == CT_NURBSCURVE) {
+ // nextNurbscurve = null;
+ // currentCurve.o_nurbscurve=null;
+ } else {
+ // nextPwlcurve = null;
+ // currentCurve.o_pwlcurve=null;
+ }
+ if (!inTrim) {
+ if (isDataValid <= 0) {
+ return;
+ }
+ // TODO errval?
+ if (currentCurve.curvetype == CT_NURBSCURVE) {
+ subdivider.beginQuilts();
+
+ for (O_nurbscurve n = currentCurve.o_nurbscurve; n != null; n = n.next)
+ subdivider.addQuilt(n.bezier_curves);
+
+ subdivider.endQuilts();
+ subdivider.drawCurves();
+ if (!playBack)
+ endrender();
+ } else {
+ if (!playBack)
+ endrender();
+ do_nurbserror(9);
+ }
+ }
+
+ }
+
+ /**
+ * Method for handling error codes
+ *
+ * @param i
+ * error code
+ */
+ private void do_nurbserror(int i) {
+ // TODO nurberror
+ // System.out.println("TODO nurbserror " + i);
+ }
+
+ /**
+ * Begin rendering
+ */
+ private void bgnrender() {
+ // DONE
+ if (autoloadmode) {
+ loadGLMatrices();
+ }
+ }
+
+ /**
+ * Load matrices from OpenGL state machine
+ */
+ private void loadGLMatrices() {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO glunurbs.loadGLMatrices");
+ }
+
+ /**
+ * End rendering
+ */
+ private void endrender() {
+ // DONE
+ }
+
+ /**
+ * Make a NURBS curve
+ *
+ * @param nknots
+ * number of knots in knot vector
+ * @param knot
+ * knot vector
+ * @param stride
+ * number of control points coordinates
+ * @param ctlarray
+ * control points
+ * @param order
+ * order of the curve
+ * @param realType
+ * type of the curve
+ */
+ public void nurbscurve(int nknots, float[] knot, int stride,
+ float[] ctlarray, int order, int realType) {
+ // DONE
+ Mapdesc mapdesc = maplist.locate(realType);
+ if (mapdesc == null) {
+ do_nurbserror(35);
+ isDataValid = 0;
+ return;
+ }
+ if (ctlarray == null) {
+ do_nurbserror(36);
+ isDataValid = 0;
+ return;
+ }
+ if (stride < 0) {
+ do_nurbserror(34);
+ isDataValid = 0;
+ return;
+ }
+ Knotvector knots = new Knotvector(nknots, stride, order, knot);
+
+ if (!do_check_knots(knots, "curve"))
+ return;
+
+ O_nurbscurve o_nurbscurve = new O_nurbscurve(realType);
+ o_nurbscurve.bezier_curves = new Quilt(mapdesc);
+ CArrayOfFloats ctrlcarr = new CArrayOfFloats(ctlarray);
+ o_nurbscurve.bezier_curves.toBezier(knots, ctrlcarr, mapdesc
+ .getNCoords());
+ thread("do_nurbscurve", o_nurbscurve);
+ }
+
+ /**
+ * Check knot vector specification
+ *
+ * @param knots
+ * knot vector
+ * @param msg
+ * error message
+ * @return knot vector is / is not valid
+ */
+ public boolean do_check_knots(Knotvector knots, String msg) {
+ // DONE
+ int status = knots.validate();
+ if (status > 0) {
+ do_nurbserror(status);
+ if (renderhints.errorchecking != NurbsConsts.N_NOMSG)
+ knots.show(msg);
+ }
+ return (status > 0) ? false : true;
+ }
+
+ /**
+ * Draw a curve
+ *
+ * @param o_nurbscurve
+ * NURBS curve object
+ */
+ public void do_nurbscurve(O_nurbscurve o_nurbscurve) {
+ // DONE
+
+ if (inCurve <= 0) {
+ bgncurve();
+ inCurve = 2;
+ }
+
+ if (o_nurbscurve.used) {
+ do_nurbserror(23);
+ isDataValid = 0;
+ return;
+ } else
+ o_nurbscurve.used = true;
+
+ if (currentCurve.curvetype == CT_NONE) {
+ currentCurve.curvetype = CT_NURBSCURVE;
+ } else if (currentCurve.curvetype != CT_NURBSCURVE) {
+ do_nurbserror(24);
+ isDataValid = 0;
+ return;
+ }
+
+ // it was necessary to overcome problem with pointer to pointer here
+
+ // if(!o_nurbscurve.equals(nextNurbscurve)){
+ if (!o_nurbscurve.equals(currentCurve.o_nurbscurve)) {
+ isCurveModified = 1;
+ currentCurve.o_nurbscurve = o_nurbscurve;
+ // nextNurbscurve=o_nurbscurve;
+
+ }
+
+ nextNurbscurve = o_nurbscurve.next;
+
+ if (!currentCurve.equals(o_nurbscurve.owner)) {
+ isCurveModified = 1;
+ o_nurbscurve.owner = currentCurve;
+ }
+
+ if (o_nurbscurve.owner == null)
+ isCurveModified = 1;
+
+ if (inCurve == 2)
+ endcurve();
+ }
+
+ /**
+ * Draw NURBS surface
+ *
+ * @param o_nurbssurface
+ * NURBS surface object
+ */
+ public void do_nurbssurface(O_nurbssurface o_nurbssurface) {
+ // DONE
+ if (inSurface <= 0) {
+ bgnsurface();
+ inSurface = 2;
+ }
+ if (o_nurbssurface.used) {
+ do_nurbserror(25);
+ isDataValid = 0;
+ return;
+ } else
+ o_nurbssurface.used = true;
+
+ if (!o_nurbssurface.equals(nextNurbscurve)) {
+ isSurfaceModified = true;
+ // nextNurbssurface=o_nurbssurface;
+ currentSurface.o_nurbssurface = o_nurbssurface;
+ }
+
+ if (!currentSurface.equals(o_nurbssurface.owner)) {
+ isSurfaceModified = true;
+ o_nurbssurface.owner = currentSurface;
+ }
+
+ nextNurbssurface = o_nurbssurface.next;
+
+ if (inSurface == 2)
+ endsurface();
+ }
+
+ /**
+ * (Re)Inicialize maps
+ */
+ public void redefineMaps() {
+ // DONE
+ maplist.initialize();
+ }
+
+ /**
+ * Define a map of given properties
+ *
+ * @param type
+ * map type
+ * @param rational
+ * is rational
+ * @param ncoords
+ * number of control point coordinates
+ */
+ public void defineMap(int type, int rational, int ncoords) {
+ // DONE
+ maplist.define(type, rational, ncoords);
+ }
+
+ /**
+ * Set NURBS property
+ *
+ * @param type
+ * property type
+ * @param tag
+ * property tag
+ * @param value
+ * property value
+ */
+ public void setnurbsproperty(int type, int tag, float value) {
+ // DONE
+ Mapdesc mapdesc = maplist.locate(type);
+ if (mapdesc == null) {
+ do_nurbserror(35);
+ return;
+ }
+ if (!mapdesc.isProperty(tag)) {
+ do_nurbserror(26);
+ return;
+ }
+ Property prop = new Property(type, tag, value);
+ thread("do_setnurbsproperty2", prop);
+ }
+
+ /**
+ * Set parameters of existing property
+ *
+ * @param prop
+ * property
+ */
+ public void do_setnurbsproperty2(Property prop) {
+ Mapdesc mapdesc = maplist.find(prop.type);
+ mapdesc.setProperty(prop.tag, prop.value);
+ }
+
+ /**
+ * Set given property to rendering hints
+ *
+ * @param prop
+ * property to be set
+ */
+ public void do_setnurbsproperty(Property prop) {
+ // DONE
+ renderhints.setProperty(prop);
+ // TODO freeproperty?
+ }
+
+ /**
+ * Sets wheteher we use domain distance sampling
+ *
+ * @param i
+ * domain distance sampling flag
+ */
+ public void set_is_domain_distance_sampling(int i) {
+ // DONE
+ subdivider.set_is_domain_distance_sampling(i);
+ }
+
+ /**
+ * Begin new surface
+ */
+ public void bgnsurface() {
+ // DONE
+ O_surface o_surface = new O_surface();
+ // TODO nuid
+ // System.out.println("TODO glunurbs.bgnsurface nuid");
+ thread("do_bgnsurface", o_surface);
+ }
+
+ /**
+ * End current surface
+ */
+ public void endsurface() {
+ // DONE
+ thread2("do_endsurface");
+ }
+
+ /**
+ * End surface trimming
+ */
+ private void endtrim() {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO glunurbs.endtrim");
+ }
+
+ /**
+ * Make NURBS surface
+ *
+ * @param sknot_count
+ * number of knots in s direction
+ * @param sknot
+ * knot vector in s direction
+ * @param tknot_count
+ * number of knots in t direction
+ * @param tknot
+ * knot vector in t direction
+ * @param s_stride
+ * number of coords of control points in s direction
+ * @param t_stride
+ * number of coords of control points in t direction
+ * @param ctlarray
+ * control points
+ * @param sorder
+ * order of curve in s direction
+ * @param torder
+ * order of curve in t direction
+ * @param type
+ * NURBS surface type (rational,...)
+ */
+ public void nurbssurface(int sknot_count, float[] sknot, int tknot_count,
+ float[] tknot, int s_stride, int t_stride, float[] ctlarray,
+ int sorder, int torder, int type) {
+ // DONE
+ Mapdesc mapdesc = maplist.locate(type);
+ if (mapdesc == null) {
+ do_nurbserror(35);
+ isDataValid = 0;
+ return;
+ }
+ if (s_stride < 0 || t_stride < 0) {
+ do_nurbserror(34);
+ isDataValid = 0;
+ return;
+ }
+ Knotvector sknotvector = new Knotvector(sknot_count, s_stride, sorder,
+ sknot);
+ if (!do_check_knots(sknotvector, "surface"))
+ return;
+ Knotvector tknotvector = new Knotvector(tknot_count, t_stride, torder,
+ tknot);
+ if (!do_check_knots(tknotvector, "surface"))
+ return;
+
+ O_nurbssurface o_nurbssurface = new O_nurbssurface(type);
+ o_nurbssurface.bezier_patches = new Quilt(mapdesc);
+
+ CArrayOfFloats ctrlarr = new CArrayOfFloats(ctlarray);
+ o_nurbssurface.bezier_patches.toBezier(sknotvector, tknotvector,
+ ctrlarr, mapdesc.getNCoords());
+ thread("do_nurbssurface", o_nurbssurface);
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Knotspec.java b/src/classes/com/sun/opengl/impl/nurbs/Knotspec.java
new file mode 100755
index 000000000..9739e353c
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Knotspec.java
@@ -0,0 +1,557 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Knot vector specification
+ *
+ * @author Tomas Hrasky
+ *
+ */
+class Knotspec {
+
+ /**
+ * Begin of input knots
+ */
+ public CArrayOfFloats inkbegin;
+
+ /**
+ * End of input knots
+ */
+ public CArrayOfFloats inkend;
+
+ /**
+ * Stride before knot operations
+ */
+ public int prestride;
+
+ /**
+ * Curve order
+ */
+ public int order;
+
+ /**
+ * Next knot specification in linked list (used in surfaces)
+ */
+ public Knotspec next;
+
+ /**
+ * Last knot
+ */
+ public CArrayOfFloats klast;
+
+ /**
+ * First knot
+ */
+ CArrayOfFloats kfirst;
+
+ /**
+ * Beginning of breakpoints
+ */
+ CArrayOfBreakpts bbegin;
+
+ /**
+ * End of breakpoints
+ */
+ CArrayOfBreakpts bend;
+
+ /**
+ * Considered left end knot
+ */
+ CArrayOfFloats kleft;
+
+ /**
+ * Considered right end knot
+ */
+ CArrayOfFloats kright;
+
+ /**
+ * Offset before knot operations
+ */
+ int preoffset;
+
+ /**
+ * Control points array Length after knot operations
+ */
+ int postwidth;
+
+ /**
+ * Beginning of coeficients array
+ */
+ private CArrayOfFloats sbegin;
+
+ /**
+ * Beginning of output knots
+ */
+ private CArrayOfFloats outkbegin;
+
+ /**
+ * End of output knots
+ */
+ private CArrayOfFloats outkend;
+
+ /**
+ * Control points aray length before knot operations
+ */
+ int prewidth;
+
+ /**
+ * Offset after knot operations
+ */
+ int postoffset;
+
+ /**
+ * Number of control points' coordinates after knot operations
+ */
+ public int poststride;
+
+ /**
+ * Number of control points' coordinates
+ */
+ public int ncoords;
+
+ /**
+ * Tell whether knotspec has already benn transformed
+ */
+ public boolean istransformed;
+
+ /**
+ * Knotspec to be transformed
+ */
+ public Knotspec kspectotrans;
+
+ /**
+ * Finds knot border of knot insertion and required multiplicities
+ */
+ public void preselect() {
+ // DONE
+ float kval;
+
+ klast = new CArrayOfFloats(inkend);
+ klast.lessenPointerBy(order);
+ for (kval = klast.get(); klast.getPointer() != inkend.getPointer(); klast
+ .pp()) {
+ if (!Knotvector.identical(klast.get(), kval))
+ break;
+ }
+
+ kfirst = new CArrayOfFloats(inkbegin);
+ kfirst.raisePointerBy(order - 1);
+ for (kval = kfirst.get(); kfirst.getPointer() != inkend.getPointer(); kfirst
+ .pp()) {
+ if (!Knotvector.identical(kfirst.get(), kval))
+ break;
+ }
+
+ CArrayOfFloats k = new CArrayOfFloats(kfirst);
+ k.mm();
+
+ for (; k.getPointer() >= inkbegin.getPointer(); k.mm())
+ if (!Knotvector.identical(kval, k.get()))
+ break;
+ k.pp();
+
+ Breakpt[] bbeginArray = new Breakpt[(klast.getPointer() - kfirst
+ .getPointer()) + 1];
+ for (int i = 0; i < bbeginArray.length; i++)
+ bbeginArray[i] = new Breakpt();
+ bbegin = new CArrayOfBreakpts(bbeginArray, 0);
+ bbegin.get().multi = kfirst.getPointer() - k.getPointer();
+ bbegin.get().value = kval;
+
+ bend = new CArrayOfBreakpts(bbegin);
+ kleft = new CArrayOfFloats(kfirst);
+ kright = new CArrayOfFloats(kfirst);
+
+ }
+
+ /**
+ * Perpares knotspec for transformation
+ */
+ public void select() {
+ // DONE
+ breakpoints();
+ knots();
+ factors();
+
+ preoffset = kleft.getPointer() - (inkbegin.getPointer() + order);
+ postwidth = ((bend.getPointer() - bbegin.getPointer()) * order);
+ prewidth = (outkend.getPointer() - outkbegin.getPointer()) - order;
+ postoffset = (bbegin.get().def > 1) ? (bbegin.get().def - 1) : 0;
+
+ }
+
+ /**
+ * Computes alpha factors for computing new control points
+ */
+ private void factors() {
+ // DONE
+ CArrayOfFloats mid = new CArrayOfFloats(outkend.getArray(), (outkend
+ .getPointer() - 1)
+ - order + bend.get().multi);
+
+ CArrayOfFloats fptr = null;
+ if (sbegin != null)
+ fptr = new CArrayOfFloats(sbegin);
+
+ for (CArrayOfBreakpts bpt = new CArrayOfBreakpts(bend); bpt
+ .getPointer() >= bbegin.getPointer(); bpt.mm()) {
+ mid.lessenPointerBy(bpt.get().multi);
+ int def = bpt.get().def - 1;
+ if (def < 0)
+ continue;
+ float kv = bpt.get().value;
+
+ CArrayOfFloats kf = new CArrayOfFloats(mid.getArray(), (mid
+ .getPointer() - def)
+ + (order - 1));
+ for (CArrayOfFloats kl = new CArrayOfFloats(kf.getArray(), kf
+ .getPointer()
+ + def); kl.getPointer() != kf.getPointer(); kl.mm()) {
+ CArrayOfFloats kh, kt;
+ for (kt = new CArrayOfFloats(kl), kh = new CArrayOfFloats(mid); kt
+ .getPointer() != kf.getPointer(); kh.mm(), kt.mm()) {
+ fptr.set((kv - kh.get()) / (kt.get() - kh.get()));
+ fptr.pp();
+ }
+ kl.set(kv);
+ }
+ }
+
+ }
+
+ /**
+ * Makes new knot vector
+ */
+ private void knots() {
+ // DONE
+ CArrayOfFloats inkpt = new CArrayOfFloats(kleft.getArray(), kleft
+ .getPointer()
+ - order);
+ CArrayOfFloats inkend = new CArrayOfFloats(kright.getArray(), kright
+ .getPointer()
+ + bend.get().def);
+
+ outkbegin = new CArrayOfFloats(new float[inkend.getPointer()
+ - inkpt.getPointer()], 0);
+ CArrayOfFloats outkpt;
+ for (outkpt = new CArrayOfFloats(outkbegin); inkpt.getPointer() != inkend
+ .getPointer(); inkpt.pp(), outkpt.pp()) {
+ outkpt.set(inkpt.get());
+ }
+ outkend = new CArrayOfFloats(outkpt);
+ }
+
+ /**
+ * Analyzes breakpoints
+ */
+ private void breakpoints() {
+ // DONE
+ CArrayOfBreakpts ubpt = new CArrayOfBreakpts(bbegin);
+ CArrayOfBreakpts ubend = new CArrayOfBreakpts(bend);
+ int nfactors = 0;
+
+ ubpt.get().value = ubend.get().value;
+ ubpt.get().multi = ubend.get().multi;
+
+ kleft = new CArrayOfFloats(kright);
+
+ for (; kright.getPointer() != klast.getPointer(); kright.pp()) {
+ if (Knotvector.identical(kright.get(), ubpt.get().value)) {
+ ubpt.get().multi++;
+ } else {
+ ubpt.get().def = order - ubpt.get().multi;
+ nfactors += (ubpt.get().def * (ubpt.get().def - 1)) / 2;
+ ubpt.pp();
+ ubpt.get().value = kright.get();
+ ubpt.get().multi = 1;
+ }
+ }
+ ubpt.get().def = order - ubpt.get().multi;
+ nfactors += (ubpt.get().def * (ubpt.get().def - 1)) / 2;
+
+ bend = new CArrayOfBreakpts(ubpt);
+
+ if (nfactors > 0) {
+ sbegin = new CArrayOfFloats(new float[nfactors], 0);
+ } else {
+ sbegin = null;
+ }
+
+ }
+
+ /**
+ * Copies control points
+ *
+ * @param _inpt
+ * input control points
+ * @param _outpt
+ * output control points
+ */
+ public void copy(CArrayOfFloats _inpt, CArrayOfFloats _outpt) {
+ CArrayOfFloats inpt = new CArrayOfFloats(_inpt);
+ CArrayOfFloats outpt = new CArrayOfFloats(_outpt);
+
+ inpt.raisePointerBy(preoffset);
+ if (next != null) {
+ for (CArrayOfFloats lpt = new CArrayOfFloats(outpt.getArray(),
+ outpt.getPointer() + prewidth); outpt.getPointer() != lpt
+ .getPointer(); outpt.raisePointerBy(poststride)) {
+ next.copy(inpt, outpt);
+ inpt.raisePointerBy(prestride);
+ }
+
+ } else {
+ for (CArrayOfFloats lpt = new CArrayOfFloats(outpt.getArray(),
+ outpt.getPointer() + prewidth); outpt.getPointer() != lpt
+ .getPointer(); outpt.raisePointerBy(poststride)) {
+ pt_io_copy(outpt, inpt);
+ inpt.raisePointerBy(prestride);
+ }
+ }
+
+ }
+
+ /**
+ * Copies one control point to other
+ *
+ * @param topt
+ * source control point
+ * @param frompt
+ * destination control point
+ */
+ private void pt_io_copy(CArrayOfFloats topt, CArrayOfFloats frompt) {
+ // DONE
+ switch (ncoords) {
+ case 4:
+ topt.setRelative(3, frompt.getRelative(3));
+ case 3:
+ topt.setRelative(2, frompt.getRelative(2));
+ case 2:
+ topt.setRelative(1, frompt.getRelative(1));
+ case 1:
+ topt.set(frompt.get());
+ break;
+ default:
+ // TODO break with copying in general case
+ // System.out.println("TODO knotspec.pt_io_copy");
+ break;
+ }
+
+ }
+
+ /**
+ * Inserts a knot
+ *
+ * @param _p
+ * inserted knot
+ */
+ public void transform(CArrayOfFloats _p) {
+ CArrayOfFloats p = new CArrayOfFloats(_p);
+ // DONE
+ if (next != null) {//surface code
+ if (this.equals(kspectotrans)) {
+ next.transform(p);
+ } else {
+ if (istransformed) {
+ p.raisePointerBy(postoffset);
+ for (CArrayOfFloats pend = new CArrayOfFloats(p.getArray(),
+ p.getPointer() + postwidth); p.getPointer() != pend
+ .getPointer(); p.raisePointerBy(poststride))
+ next.transform(p);
+
+ } else {
+ CArrayOfFloats pend = new CArrayOfFloats(p.getArray(), p
+ .getPointer()
+ + prewidth);
+ for (; p.getPointer() != pend.getPointer(); p
+ .raisePointerBy(poststride))
+ next.transform(p);
+ }
+ }
+
+ } else {//code for curve
+ if (this.equals(kspectotrans)) {
+ insert(p);
+ } else {
+ if (istransformed) {
+ p.raisePointerBy(postoffset);
+ for (CArrayOfFloats pend = new CArrayOfFloats(p.getArray(),
+ p.getPointer() + postwidth); p.getPointer() != pend
+ .getPointer(); p.raisePointerBy(poststride)) {
+ kspectotrans.insert(p);
+ }
+ } else {
+ CArrayOfFloats pend = new CArrayOfFloats(p.getArray(), p
+ .getPointer()
+ + prewidth);
+ for (; p.getPointer() != pend.getPointer(); p
+ .raisePointerBy(poststride))
+ kspectotrans.insert(p);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Inserts a knot and computes new control points
+ *
+ * @param p
+ * inserted knot
+ */
+ private void insert(CArrayOfFloats p) {
+ // DONE
+ CArrayOfFloats fptr = null;
+ if (sbegin != null)
+ fptr = new CArrayOfFloats(sbegin);
+ CArrayOfFloats srcpt = new CArrayOfFloats(p.getArray(), p.getPointer()
+ + prewidth - poststride);
+ // CArrayOfFloats srcpt = new CArrayOfFloats(p.getArray(), prewidth -
+ // poststride);
+ CArrayOfFloats dstpt = new CArrayOfFloats(p.getArray(), p.getPointer()
+ + postwidth + postoffset - poststride);
+ // CArrayOfFloats dstpt = new CArrayOfFloats(p.getArray(), postwidth +
+ // postoffset - poststride);
+ CArrayOfBreakpts bpt = new CArrayOfBreakpts(bend);
+
+ for (CArrayOfFloats pend = new CArrayOfFloats(srcpt.getArray(), srcpt
+ .getPointer()
+ - poststride * bpt.get().def); srcpt.getPointer() != pend
+ .getPointer(); pend.raisePointerBy(poststride)) {
+ CArrayOfFloats p1 = new CArrayOfFloats(srcpt);
+ for (CArrayOfFloats p2 = new CArrayOfFloats(srcpt.getArray(), srcpt
+ .getPointer()
+ - poststride); p2.getPointer() != pend.getPointer(); p1
+ .setPointer(p2.getPointer()), p2
+ .lessenPointerBy(poststride)) {
+ pt_oo_sum(p1, p1, p2, fptr.get(), 1.0 - fptr.get());
+ fptr.pp();
+ }
+ }
+ bpt.mm();
+ for (; bpt.getPointer() >= bbegin.getPointer(); bpt.mm()) {
+
+ for (int multi = bpt.get().multi; multi > 0; multi--) {
+ pt_oo_copy(dstpt, srcpt);
+ dstpt.lessenPointerBy(poststride);
+ srcpt.lessenPointerBy(poststride);
+ }
+ for (CArrayOfFloats pend = new CArrayOfFloats(srcpt.getArray(),
+ srcpt.getPointer() - poststride * bpt.get().def); srcpt
+ .getPointer() != pend.getPointer(); pend
+ .raisePointerBy(poststride), dstpt
+ .lessenPointerBy(poststride)) {
+ pt_oo_copy(dstpt, srcpt);
+ CArrayOfFloats p1 = new CArrayOfFloats(srcpt);
+
+ for (CArrayOfFloats p2 = new CArrayOfFloats(srcpt.getArray(),
+ srcpt.getPointer() - poststride); p2.getPointer() != pend
+ .getPointer(); p1.setPointer(p2.getPointer()), p2
+ .lessenPointerBy(poststride)) {
+ pt_oo_sum(p1, p1, p2, fptr.get(), 1.0 - fptr.get());
+ fptr.pp();
+ }
+ }
+ }
+ }
+
+ /**
+ * Copies one control point to another
+ *
+ * @param topt
+ * source ctrl point
+ * @param frompt
+ * distance ctrl point
+ */
+ private void pt_oo_copy(CArrayOfFloats topt, CArrayOfFloats frompt) {
+ // DONE
+ // this is a "trick" with case - "break" is omitted so it comes through all cases
+ switch (ncoords) {
+ case 4:
+ topt.setRelative(3, frompt.getRelative(3));
+ case 3:
+ topt.setRelative(2, frompt.getRelative(2));
+ case 2:
+ topt.setRelative(1, frompt.getRelative(1));
+ case 1:
+ topt.setRelative(0, frompt.getRelative(0));
+ break;
+ default:
+ // default uses memcpy but it is not needed (we probably won't have more than 4 coords)
+ // TODO not sure about it
+ break;
+ }
+
+ }
+
+ /**
+ * Computes new control point
+ *
+ * @param x
+ * first point
+ * @param y
+ * second point
+ * @param z
+ * third pont
+ * @param a
+ * alpha
+ * @param b
+ * 1 - alpha
+ */
+ private void pt_oo_sum(CArrayOfFloats x, CArrayOfFloats y,
+ CArrayOfFloats z, float a, double b) {
+ // DONE
+ switch (ncoords) {
+ case 4:
+ x.setRelative(3, (float) (a * y.getRelative(3) + b
+ * z.getRelative(3)));
+ case 3:
+ x.setRelative(2, (float) (a * y.getRelative(2) + b
+ * z.getRelative(2)));
+ case 2:
+ x.setRelative(1, (float) (a * y.getRelative(1) + b
+ * z.getRelative(1)));
+ case 1:
+ x.setRelative(0, (float) (a * y.getRelative(0) + b
+ * z.getRelative(0)));
+ break;
+ default:
+ //no need of default - see previous method and its case statement
+ // System.out.println("TODO pt_oo_sum default");
+ break;
+ }
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Knotvector.java b/src/classes/com/sun/opengl/impl/nurbs/Knotvector.java
new file mode 100755
index 000000000..1442fe17d
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Knotvector.java
@@ -0,0 +1,179 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Knot vector used in curve specification
+ *
+ * @author Tomas Hrasky
+ *
+ */
+class Knotvector {
+
+ /**
+ * Tolerance used when comparing knots - when difference is smaller, knots
+ * are considered equal
+ */
+ public static final float TOLERANCE = 1.0e-5f;
+
+ /**
+ * Maximum curve order
+ */
+ private static final int MAXORDER = 24;
+
+ /**
+ * Number of knots
+ */
+ int knotcount;
+
+ /**
+ * Number of control points' coordinates
+ */
+ int stride;
+
+ /**
+ * Curve order
+ */
+ int order;
+
+ /**
+ * Knots
+ */
+ float[] knotlist;
+
+ /**
+ * Makes new knotvector
+ *
+ * @param nknots
+ * number of knots
+ * @param stride
+ * number of ctrl points' corrdinates
+ * @param order
+ * curve order
+ * @param knot
+ * knots
+ */
+ public Knotvector(int nknots, int stride, int order, float[] knot) {
+ // DONE
+ init(nknots, stride, order, knot);
+ }
+
+ /**
+ * Initializes knotvector
+ *
+ * @param nknots
+ * number of knots
+ * @param stride
+ * number of ctrl points' corrdinates
+ * @param order
+ * curve order
+ * @param knot
+ * knots
+ */
+ public void init(int nknots, int stride, int order, float[] knot) {
+ // DONE
+ this.knotcount = nknots;
+ this.stride = stride;
+ this.order = order;
+ this.knotlist = new float[nknots];
+ for (int i = 0; i < nknots; i++) {
+ this.knotlist[i] = knot[i];
+ }
+
+ }
+
+ /**
+ * Validates knot vector parameters
+ *
+ * @return knot vector validity
+ */
+ public int validate() {
+ int kindex = knotcount - 1;
+ if (order < 1 || order > MAXORDER) {
+ return 1;
+ }
+ if (knotcount < 2 * order) {
+ return 2;
+ }
+ if (identical(knotlist[kindex - (order - 1)], knotlist[order - 1])) {
+ return 3;
+ }
+ for (int i = 0; i < kindex; i++) {
+ if (knotlist[i] > knotlist[i + 1])
+ return 4;
+ }
+ int multi = 1;
+ for (; kindex >= 1; kindex--) {
+ if (knotlist[kindex] - knotlist[kindex - 1] < TOLERANCE) {
+ multi++;
+ continue;
+ }
+ if (multi > order) {
+ return 5;
+ }
+ multi = 1;
+ }
+ if (multi > order) {
+ return 5;
+ }
+
+ return 0;
+ }
+
+ /**
+ * Show specified message
+ *
+ * @param msg
+ * message to be shown
+ */
+ public void show(String msg) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO knotvector.show");
+
+ }
+
+ /**
+ * Compares two knots for equality
+ *
+ * @param a
+ * first knot
+ * @param b
+ * second knot
+ * @return knots are/are not equal
+ */
+ public static boolean identical(float a, float b) {
+ return ((a - b) < TOLERANCE) ? true : false;
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Mapdesc.java b/src/classes/com/sun/opengl/impl/nurbs/Mapdesc.java
new file mode 100755
index 000000000..a6536dcb8
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Mapdesc.java
@@ -0,0 +1,442 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Class holding properties of OpenGL map
+ * @author Tomas Hrasky
+ *
+ */
+class Mapdesc {
+
+ /**
+ * Maximum control point coords
+ */
+ private static final int MAXCOORDS = 5;
+
+ /**
+ * Next description in list
+ */
+ public Mapdesc next;
+
+ /**
+ * Is map rational
+ */
+ public int isrational;
+
+ /**
+ * Number of control point coords
+ */
+ public int ncoords;
+
+ /**
+ * Map type
+ */
+ private int type;
+
+ /**
+ * Number of homogenous coords
+ */
+ private int hcoords;
+
+ /**
+ * Number of inhomogenous coords
+ */
+ private int inhcoords;
+
+ /**
+ * Not used
+ */
+ private int mask;
+
+ /**
+ * Value of N_PIXEL_TOLERANCE property
+ */
+ private float pixel_tolerance;
+
+ /**
+ * Value of N_ERROR_TOLERANCE property
+ */
+ private float error_tolerance;
+
+ /**
+ * Value of N_BBOX_SUBDIVIDING property
+ */
+ private float bbox_subdividing;
+
+ /**
+ * Value of N_CULLING property
+ */
+ private float culling_method;
+
+ /**
+ * Value of N_SAMPLINGMETHOD property
+ */
+ private float sampling_method;
+
+ /**
+ * Value of N_CLAMPFACTOR property
+ */
+ float clampfactor;
+
+ /**
+ * Value of N_MINSAVINGS property
+ */
+ private float minsavings;
+
+ /**
+ * Steps in u direction
+ */
+ private float s_steps;
+
+ /**
+ * Steps in v direction
+ */
+ private float t_steps;
+
+ /**
+ * Maximal step
+ */
+ float maxrate;
+
+ /**
+ * Maximal u direction step
+ */
+ private float maxsrate;
+
+ /**
+ * Maximal v direction step
+ */
+ private float maxtrate;
+
+ /**
+ * Not used
+ */
+ private float[][] bmat;
+
+ /**
+ * Sampling matrix
+ */
+ private float[][] smat;
+
+ /**
+ * Not used
+ */
+ private float[][] cmat;
+
+ /**
+ * Not used
+ */
+ private float[] bboxsize;
+
+ /**
+ * Makes new mapdesc
+ * @param type map type
+ * @param rational is rational
+ * @param ncoords number of control points coords
+ * @param backend backend object
+ */
+ public Mapdesc(int type, int rational, int ncoords, Backend backend) {
+ // DONE
+ this.type = type;
+ this.isrational = rational;
+ this.ncoords = ncoords;
+ this.hcoords = ncoords + (isrational > 0 ? 0 : 1);
+ this.inhcoords = ncoords - (isrational > 0 ? 1 : 0);
+ this.mask = ((1 << (inhcoords * 2)) - 1);
+ next = null;
+
+ assert (hcoords <= MAXCOORDS);
+ assert (inhcoords >= 1);
+
+ pixel_tolerance = 1f;
+ error_tolerance = 1f;
+ bbox_subdividing = NurbsConsts.N_NOBBOXSUBDIVISION;
+ culling_method = NurbsConsts.N_NOCULLING;
+ sampling_method = NurbsConsts.N_NOSAMPLING;
+ clampfactor = NurbsConsts.N_NOCLAMPING;
+ minsavings = NurbsConsts.N_NOSAVINGSSUBDIVISION;
+ s_steps = 0f;
+ t_steps = 0f;
+
+ maxrate = (s_steps < 0) ? 0 : s_steps;
+ maxsrate = (s_steps < 0) ? 0 : s_steps;
+ maxtrate = (t_steps < 0) ? 0 : t_steps;
+ bmat = new float[MAXCOORDS][MAXCOORDS];
+ cmat = new float[MAXCOORDS][MAXCOORDS];
+ smat = new float[MAXCOORDS][MAXCOORDS];
+
+ identify(bmat);
+ identify(cmat);
+ identify(smat);
+ bboxsize = new float[MAXCOORDS];
+ for (int i = 0; i < inhcoords; i++)
+ bboxsize[i] = 1;
+ }
+
+ /**
+ * Make matrix identity matrix
+ * @param arr matrix
+ */
+ private void identify(float[][] arr) {
+ // DONE
+ for (int i = 0; i < MAXCOORDS; i++)
+ for (int j = 0; j < MAXCOORDS; j++)
+ arr[i][j] = 0;
+ for (int i = 0; i < MAXCOORDS; i++)
+ arr[i][i] = 1;
+
+ }
+
+ /**
+ * Tells whether tag is property tag
+ * @param tag property tag
+ * @return is/is not property
+ */
+ public boolean isProperty(int tag) {
+ boolean ret;
+ switch (tag) {
+ case NurbsConsts.N_PIXEL_TOLERANCE:
+ case NurbsConsts.N_ERROR_TOLERANCE:
+ case NurbsConsts.N_CULLING:
+ case NurbsConsts.N_BBOX_SUBDIVIDING:
+ case NurbsConsts.N_S_STEPS:
+ case NurbsConsts.N_T_STEPS:
+ case NurbsConsts.N_SAMPLINGMETHOD:
+ case NurbsConsts.N_CLAMPFACTOR:
+ case NurbsConsts.N_MINSAVINGS:
+ ret = true;
+ break;
+ default:
+ ret = false;
+ break;
+ }
+ return ret;
+ }
+
+ /**
+ * Returns number of control points' coords
+ * @return number of control points' coords
+ */
+ public int getNCoords() {
+ return ncoords;
+ }
+
+ /**
+ * Returns map type
+ * @return map type
+ */
+ public int getType() {
+ return type;
+ }
+
+ /**
+ * Tells whether map is range sampling
+ * @return is map range sampling
+ */
+ public boolean isRangeSampling() {
+ // DONE
+ return (isParametricDistanceSampling() || isPathLengthSampling()
+ || isSurfaceAreaSampling() || isObjectSpaceParaSampling() || isObjectSpacePathSampling());
+ }
+
+ /**
+ * Tells whether map is object space sampling
+ * @return is map object space sampling
+ */
+ private boolean isObjectSpacePathSampling() {
+ // DONE
+ return sampling_method == NurbsConsts.N_OBJECTSPACE_PATH;
+ }
+
+ /**
+ * Tells whether map is object space parasampling
+ * @return is map object space parasampling
+ */
+ private boolean isObjectSpaceParaSampling() {
+ // DONE
+ return sampling_method == NurbsConsts.N_OBJECTSPACE_PARA;
+ }
+
+ /**
+ * Tells whether map is area sampling surface
+ * @return is map area sampling surface
+ */
+ private boolean isSurfaceAreaSampling() {
+ // DONE
+ return sampling_method == NurbsConsts.N_SURFACEAREA;
+ }
+
+ /**
+ * Tells whether map is path length sampling
+ * @return is map path length sampling
+ */
+ boolean isPathLengthSampling() {
+ // DONE
+ return sampling_method == NurbsConsts.N_PATHLENGTH;
+ }
+
+ /**
+ * Tells whether map is parametric distance sampling
+ * @return is map parametric distance sampling
+ */
+ boolean isParametricDistanceSampling() {
+ // DONE
+ return sampling_method == NurbsConsts.N_PARAMETRICDISTANCE;
+ }
+
+ /**
+ * Tells whether map is culling
+ * @return is map culling
+ */
+ public boolean isCulling() {
+ // DONE
+ return culling_method != NurbsConsts.N_NOCULLING ? true : false;
+ }
+
+ /**
+ * Tells whether map is constantly sampling
+ * @return is map constant sampling
+ */
+ public boolean isConstantSampling() {
+ return (sampling_method == NurbsConsts.N_FIXEDRATE) ? true : false;
+ }
+
+ /**
+ * Tells whether map is domain sampling
+ * @return is map domain sampling
+ */
+ public boolean isDomainSampling() {
+ return (sampling_method == NurbsConsts.N_DOMAINDISTANCE) ? true : false;
+ }
+
+ /**
+ * Returns property of specified tag value
+ * @param tag property tag
+ * @return property value
+ */
+ public float getProperty(int tag) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO mapdesc.getproperty");
+ return 0;
+ }
+
+ /**
+ * Sets property with given tag
+ * @param tag property tag
+ * @param value desired value
+ */
+ public void setProperty(int tag, float value) {
+ // TODO Auto-generated method stub
+ switch (tag) {
+ case NurbsConsts.N_PIXEL_TOLERANCE:
+ pixel_tolerance = value;
+ break;
+ case NurbsConsts.N_ERROR_TOLERANCE:
+ error_tolerance = value;
+ break;
+ case NurbsConsts.N_CULLING:
+ culling_method = value;
+ break;
+ case NurbsConsts.N_BBOX_SUBDIVIDING:
+ if (value <= 0)
+ value = NurbsConsts.N_NOBBOXSUBDIVISION;
+ bbox_subdividing = value;
+ break;
+ case NurbsConsts.N_S_STEPS:
+ if (value < 0)
+ value = 0;
+ s_steps = value;
+ maxrate = value;
+ maxsrate = value;
+ break;
+ case NurbsConsts.N_T_STEPS:
+ if (value < 0)
+ value = 0;
+ t_steps = value;
+ maxtrate = value;
+ break;
+ case NurbsConsts.N_SAMPLINGMETHOD:
+ sampling_method = value;
+ break;
+ case NurbsConsts.N_CLAMPFACTOR:
+ if (value < 0)
+ value = 0;
+ clampfactor = value;
+ break;
+ case NurbsConsts.N_MINSAVINGS:
+ if (value <= 0)
+ value = NurbsConsts.N_NOSAVINGSSUBDIVISION;
+ minsavings = value;
+ break;
+ }
+ }
+
+ /**
+ * Samples curve
+ * @param pts control points
+ * @param order curve order
+ * @param stride number of control points' coordinates
+ * @param sp breakpoints
+ * @param outstride output number of control points' coordinates
+ */
+ public void xformSampling(CArrayOfFloats pts, int order, int stride,
+ float[] sp, int outstride) {
+ // DONE
+ xFormMat(smat, pts, order, stride, sp, outstride);
+ }
+
+ /**
+ * Empty method
+ * @param mat sampling matrix
+ * @param pts ontrol points
+ * @param order curve order
+ * @param stride number of control points' coordinates
+ * @param cp breakpoints
+ * @param outstride output number of control points' coordinates
+ */
+ private void xFormMat(float[][] mat, CArrayOfFloats pts, int order,
+ int stride, float[] cp, int outstride) {
+ // TODO Auto-generated method stub
+
+ // System.out.println("TODO mapdsc.xformmat ; change cp from float[] to carrayoffloats");
+
+ if (isrational > 0) {
+
+ } else {
+
+ }
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Maplist.java b/src/classes/com/sun/opengl/impl/nurbs/Maplist.java
new file mode 100755
index 000000000..e6450f75d
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Maplist.java
@@ -0,0 +1,122 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Class holding list of Mapdescs
+ * @author Tomáš Hráský
+ *
+ */
+class Maplist {
+ /**
+ * Head of linked list
+ */
+ private Mapdesc maps;
+
+ /**
+ * Backend class
+ */
+ private Backend backend;
+
+ /**
+ * Makes new Maplist
+ * @param backend Backend class
+ */
+ public Maplist(Backend backend) {
+ this.backend = backend;
+ }
+
+ /**
+ * Sets linked list beginning to null
+ */
+ public void initialize() {
+ // TODO mapdespool.clear ?
+ maps = null;
+ }
+
+ /**
+ * Defines new Mapdesc if it is not defined and appends it to linked list
+ * @param type map type
+ * @param rational is map rational
+ * @param ncoords number of coords
+ */
+ public void define(int type, int rational, int ncoords) {
+ // DONE
+ Mapdesc m = locate(type);
+ assert (m == null || (m.isrational == rational && m.ncoords == ncoords));
+ add(type, rational, ncoords);
+
+ }
+
+ /**
+ * Adds new Mapdesc to linked list
+ * @param type map type
+ * @param rational is map rational
+ * @param ncoords number of coords
+ */
+ private void add(int type, int rational, int ncoords) {
+ // DONE
+ Mapdesc map = new Mapdesc(type, rational, ncoords, backend);
+ if (maps == null) {
+ maps = map;
+ } else {
+ map.next = maps;
+ maps = map;
+ }
+ }
+
+ /**
+ * Tries to find Mapdesc in linked list
+ * @param type map type
+ * @return Mapdesc of type or null if there is no such map
+ */
+ public Mapdesc locate(int type) {
+ // DONE
+ Mapdesc m = null;
+ for (m = maps; m != null; m = m.next)
+ if (m.getType() == type)
+ break;
+ return m;
+ }
+
+ /**
+ * Alias for locate
+ * @param type maptype
+ * @return Mapdesc of type or null if there is no such map
+ */
+ public Mapdesc find(int type) {
+ return locate(type);
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/NurbsConsts.java b/src/classes/com/sun/opengl/impl/nurbs/NurbsConsts.java
new file mode 100755
index 000000000..0ff77069b
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/NurbsConsts.java
@@ -0,0 +1,184 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Class hodling NURBS constants as seen in OpenGL GLU documentation
+ * @author JOGL project
+ *
+ */
+class NurbsConsts {
+ /*
+ * NURBS Properties - one set per map, each takes a single INREAL arg
+ */
+ public static final int N_SAMPLING_TOLERANCE = 1;
+
+ public static final int N_S_RATE = 6;
+
+ public static final int N_T_RATE = 7;
+
+ public static final int N_CLAMPFACTOR = 13;
+
+ public static final float N_NOCLAMPING = 0.0f;
+
+ public static final int N_MINSAVINGS = 14;
+
+ public static final float N_NOSAVINGSSUBDIVISION = 0.0f;
+
+ /*
+ * NURBS Properties - one set per map, each takes an enumerated value
+ */
+ public static final int N_CULLING = 2;
+
+ public static final float N_NOCULLING = 0.0f;
+
+ public static final float N_CULLINGON = 1.0f;
+
+ public static final int N_SAMPLINGMETHOD = 10;
+
+ public static final float N_NOSAMPLING = 0.0f;
+
+ public static final float N_FIXEDRATE = 3.0f;
+
+ public static final float N_DOMAINDISTANCE = 2.0f;
+
+ public static final float N_PARAMETRICDISTANCE = 5.0f;
+
+ public static final float N_PATHLENGTH = 6.0f;
+
+ public static final float N_SURFACEAREA = 7.0f;
+
+ public static final float N_OBJECTSPACE_PARA = 8.0f;
+
+ public static final float N_OBJECTSPACE_PATH = 9.0f;
+
+ public static final int N_BBOX_SUBDIVIDING = 17;
+
+ public static final float N_NOBBOXSUBDIVISION = 0.0f;
+
+ public static final float N_BBOXTIGHT = 1.0f;
+
+ public static final float N_BBOXROUND = 2.0f;
+
+ /*
+ * NURBS Rendering Properties - one set per renderer each takes an
+ * enumerated value
+ */
+ public static final int N_DISPLAY = 3;
+
+ public static final int N_FILL = 1;
+
+ public static final int N_OUTLINE_POLY = 2;
+
+ public static final int N_OUTLINE_TRI = 3;
+
+ public static final int N_OUTLINE_QUAD = 4;
+
+ public static final int N_OUTLINE_PATCH = 5;
+
+ public static final int N_OUTLINE_PARAM = 6;
+
+ public static final int N_OUTLINE_PARAM_S = 7;
+
+ public static final int N_OUTLINE_PARAM_ST = 8;
+
+ public static final int N_OUTLINE_SUBDIV = 9;
+
+ public static final int N_OUTLINE_SUBDIV_S = 10;
+
+ public static final int N_OUTLINE_SUBDIV_ST = 11;
+
+ public static final int N_ISOLINE_S = 12;
+
+ public static final int N_ERRORCHECKING = 4;
+
+ public static final int N_NOMSG = 0;
+
+ public static final int N_MSG = 1;
+
+ /* GL 4.0 propeties not defined above */
+
+ public static final int N_PIXEL_TOLERANCE = N_SAMPLING_TOLERANCE;
+
+ public static final int N_ERROR_TOLERANCE = 20;
+
+ public static final int N_SUBDIVISIONS = 5;
+
+ public static final int N_TILES = 8;
+
+ public static final int N_TMP1 = 9;
+
+ public static final int N_TMP2 = N_SAMPLINGMETHOD;
+
+ public static final int N_TMP3 = 11;
+
+ public static final int N_TMP4 = 12;
+
+ public static final int N_TMP5 = N_CLAMPFACTOR;
+
+ public static final int N_TMP6 = N_MINSAVINGS;
+
+ public static final int N_S_STEPS = N_S_RATE;
+
+ public static final int N_T_STEPS = N_T_RATE;
+
+ /*
+ * NURBS Rendering Properties - one set per map, each takes an INREAL matrix
+ * argument
+ */
+ public static final int N_CULLINGMATRIX = 1;
+
+ public static final int N_SAMPLINGMATRIX = 2;
+
+ public static final int N_BBOXMATRIX = 3;
+
+ /*
+ * NURBS Rendering Properties - one set per map, each takes an INREAL vector
+ * argument
+ */
+ public static final int N_BBOXSIZE = 4;
+
+ /* type argument for trimming curves */
+
+ public static final int N_P2D = 0x8;
+
+ public static final int N_P2DR = 0xd;
+
+ public static final int N_MESHLINE = 1;
+
+ public static final int N_MESHFILL = 0;
+
+ public static final int N_MESHPOINT = 2;
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/O_curve.java b/src/classes/com/sun/opengl/impl/nurbs/O_curve.java
new file mode 100755
index 000000000..1a88d427f
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/O_curve.java
@@ -0,0 +1,63 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Struct holding curve links
+ * @author Tomáš Hráský
+ *
+ */
+class O_curve {
+
+ /**
+ * Curve type
+ */
+ public int curvetype;
+
+ /**
+ * Next curve in linked list
+ */
+ public O_curve next;
+
+ /**
+ * Curve of picewiselinear type
+ */
+ public O_pwlcurve o_pwlcurve;
+
+ /**
+ * NURBS curve
+ */
+ public O_nurbscurve o_nurbscurve;
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/O_nurbscurve.java b/src/classes/com/sun/opengl/impl/nurbs/O_nurbscurve.java
new file mode 100755
index 000000000..634558815
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/O_nurbscurve.java
@@ -0,0 +1,80 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * NURBS curve object
+ * @author Tomáš Hráský
+ *
+ */
+class O_nurbscurve {
+
+ /**
+ * List of bezier curves
+ */
+ public Quilt bezier_curves;
+
+ /**
+ * Curve type
+ */
+ public int type;
+
+ /**
+ * Was curve used ?
+ */
+ boolean used;
+
+ /**
+ * Parent curve
+ */
+ O_curve owner;
+
+ /**
+ * Next curve in list
+ */
+ O_nurbscurve next;
+
+ /**
+ * Makes new O_nurbscurve
+ * @param realType type of curve
+ */
+ public O_nurbscurve(int realType) {
+ // DONE
+ this.type = realType;
+ this.owner = null;
+ this.next = null;
+ this.used = false;
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/O_nurbssurface.java b/src/classes/com/sun/opengl/impl/nurbs/O_nurbssurface.java
new file mode 100755
index 000000000..7497b8c0f
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/O_nurbssurface.java
@@ -0,0 +1,79 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * NURBS surface object
+ * @author Tomáš Hráský
+ *
+ */
+class O_nurbssurface {
+
+ /**
+ * List of bezier patches forming NURBS surface
+ */
+ public Quilt bezier_patches;
+
+ /**
+ * Was surface used
+ */
+ public boolean used;
+
+ /**
+ * Parent O_surface
+ */
+ public O_surface owner;
+
+ /**
+ * Next surface in list
+ */
+ public O_nurbssurface next;
+
+ /**
+ * Surface type
+ */
+ private int type;
+
+ /**
+ * Makes new O_nurbssurface of type
+ * @param type surface type
+ */
+ public O_nurbssurface(int type) {
+ this.type = type;
+ this.owner = null;
+ this.next = null;
+ this.used = false;
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/O_pwlcurve.java b/src/classes/com/sun/opengl/impl/nurbs/O_pwlcurve.java
new file mode 100755
index 000000000..460136d49
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/O_pwlcurve.java
@@ -0,0 +1,44 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Empty class
+ * @author Tomáš Hráský
+ *
+ */
+class O_pwlcurve {
+
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/O_surface.java b/src/classes/com/sun/opengl/impl/nurbs/O_surface.java
new file mode 100755
index 000000000..009953147
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/O_surface.java
@@ -0,0 +1,52 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Surface object
+ * @author Tomáš Hráský
+ *
+ */
+class O_surface {
+ /**
+ * NURBS surface
+ */
+ O_nurbssurface o_nurbssurface;
+
+ /**
+ * Trims
+ */
+ O_trim o_trim;
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/O_trim.java b/src/classes/com/sun/opengl/impl/nurbs/O_trim.java
new file mode 100755
index 000000000..ccbcc12f0
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/O_trim.java
@@ -0,0 +1,44 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Empty class
+ * @author Tomáš Hráský
+ *
+ */
+class O_trim {
+
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/OpenGLCurveEvaluator.java b/src/classes/com/sun/opengl/impl/nurbs/OpenGLCurveEvaluator.java
new file mode 100755
index 000000000..65ec983c4
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/OpenGLCurveEvaluator.java
@@ -0,0 +1,202 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+import javax.media.opengl.GL;
+import javax.media.opengl.glu.GLU;
+
+/**
+ * Class rendering curves with OpenGL
+ * @author Tomáš Hráský
+ *
+ */
+class OpenGLCurveEvaluator {
+
+ /**
+ * Output triangles (for callback) or render curve
+ */
+ private boolean output_triangles;
+
+ /**
+ * OpenGL object
+ */
+ private GL gl;
+
+ /**
+ * Not used
+ */
+ private int vertex_flag;
+
+ /**
+ * Not used
+ */
+ private int normal_flag;
+
+ /**
+ * Not used
+ */
+ private int color_flag;
+
+ /**
+ * Not used
+ */
+ private int texcoord_flag;
+
+ /**
+ * Number of bezier arc - used for color distinguishing of arcs forming NURBS curve
+ */
+ private int poradi;
+
+ /**
+ * Makes new Evaluator
+ */
+ public OpenGLCurveEvaluator() {
+ gl = GLU.getCurrentGL();
+ }
+
+ /**
+ * Pushes eval bit
+ */
+ public void bgnmap1f() {
+ // DONE
+ if (output_triangles) {
+ vertex_flag = 0;
+ normal_flag = 0;
+ color_flag = 0;
+ texcoord_flag = 0;
+ } else {
+ gl.glPushAttrib(GL.GL_EVAL_BIT);
+ }
+
+ }
+
+ /**
+ * Pops all OpenGL attributes
+ */
+ public void endmap1f() {
+ // DONE
+ if (output_triangles) {
+
+ } else {
+ gl.glPopAttrib();
+ }
+
+ }
+
+ /**
+ * Initializes opengl evaluator
+ * @param type curve type
+ * @param ulo lowest u
+ * @param uhi highest u
+ * @param stride control point coords
+ * @param order curve order
+ * @param ps control points
+ */
+ public void map1f(int type, float ulo, float uhi, int stride, int order,
+ CArrayOfFloats ps) {
+ if (output_triangles) {
+ // TODO code for callback (output_triangles probably indicates callback)
+ // System.out.println("TODO curveevaluator.map1f-output_triangles");
+ } else {
+ gl.glMap1f(type, ulo, uhi, stride, order, ps.getArray(), ps
+ .getPointer());
+
+ // DEBUG - drawing bézier control points
+ // gl.glColor3d(.5,.5,.5);
+ // gl.glPointSize(5);
+ // gl.glBegin(GL.GL_POINTS);
+ // float[] ctrlpoints=ps.getArray();
+ // for(int i=ps.getPointer();i<ps.getPointer()+order;i++){
+ // gl.glVertex3d(ctrlpoints[i * 4], ctrlpoints[i * 4 + 1],0);
+ // }
+ // gl.glEnd();
+ }
+
+ }
+
+ /**
+ * Calls opengl enable
+ * @param type what to enable
+ */
+ public void enable(int type) {
+ // DONE
+ gl.glEnable(type);
+ }
+
+ /**
+ * Calls glMapGrid1f
+ * @param nu steps
+ * @param u1 low u
+ * @param u2 high u
+ */
+ public void mapgrid1f(int nu, float u1, float u2) {
+ if (output_triangles) {
+ // System.out.println("TODO curveevaluator.mapgrid1f");
+ } else
+ gl.glMapGrid1f(nu, u1, u2);
+ // // System.out.println("upravit NU");
+ // gl.glMapGrid1f(50,u1,u2);
+ }
+
+ /**
+ * Evaluates a curve using glEvalMesh1f
+ * @param style Backend.N_MESHFILL/N_MESHLINE/N_MESHPOINT
+ * @param from lowest param
+ * @param to highest param
+ */
+ public void mapmesh1f(int style, int from, int to) {
+ /* //DEBUG drawing control points
+ this.poradi++;
+ if (poradi % 2 == 0)
+ gl.glColor3f(1, 0, 0);
+ else
+ gl.glColor3f(0, 1, 0);
+ */
+ if (output_triangles) {
+ // TODO code for callback
+ // System.out.println("TODO openglcurveevaluator.mapmesh1f output_triangles");
+ } else {
+ switch (style) {
+ case Backend.N_MESHFILL:
+ case Backend.N_MESHLINE:
+ gl.glEvalMesh1(GL.GL_LINE, from, to);
+ break;
+ case Backend.N_MESHPOINT:
+ gl.glEvalMesh1(GL.GL_POINT, from, to);
+ break;
+ }
+ }
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/OpenGLSurfaceEvaluator.java b/src/classes/com/sun/opengl/impl/nurbs/OpenGLSurfaceEvaluator.java
new file mode 100755
index 000000000..2c31bc2bc
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/OpenGLSurfaceEvaluator.java
@@ -0,0 +1,214 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+import javax.media.opengl.GL;
+import javax.media.opengl.glu.GLU;
+
+/**
+ * Class rendering surfaces with OpenGL
+ * @author Tomas Hrasky
+ *
+ */
+class OpenGLSurfaceEvaluator {
+
+ /**
+ * JOGL OpenGL object
+ */
+ private GL gl;
+
+ /**
+ * Output triangles (callback)
+ */
+ private boolean output_triangles;
+
+ /**
+ * Number of patch - used for distinguishing bezier plates forming NURBS surface with different colors
+ */
+ private int poradi;
+
+ /**
+ * Creates new evaluator
+ */
+ public OpenGLSurfaceEvaluator() {
+ gl = GLU.getCurrentGL();
+ }
+
+ /**
+ * Pushes eval bit
+ */
+ public void bgnmap2f() {
+
+ if (output_triangles) {
+ // TODO outp triangles surfaceevaluator bgnmap2f
+ // System.out.println("TODO surfaceevaluator.bgnmap2f output triangles");
+ } else {
+ gl.glPushAttrib(GL.GL_EVAL_BIT);
+ // System.out.println("TODO surfaceevaluator.bgnmap2f glgetintegerv");
+ }
+
+ }
+
+ /**
+ * Sets glPolygonMode
+ * @param style polygon mode (N_MESHFILL/N_MESHLINE/N_MESHPOINT)
+ */
+ public void polymode(int style) {
+ if (!output_triangles) {
+ switch (style) {
+ default:
+ case NurbsConsts.N_MESHFILL:
+ gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
+ break;
+ case NurbsConsts.N_MESHLINE:
+ gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
+ break;
+ case NurbsConsts.N_MESHPOINT:
+ gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_POINT);
+ break;
+ }
+ }
+
+ }
+
+ /**
+ * Pops all attributes
+ */
+ public void endmap2f() {
+ // TODO Auto-generated method stub
+ if (output_triangles) {
+ // System.out.println("TODO surfaceevaluator.endmap2f output triangles");
+ } else {
+ gl.glPopAttrib();
+ // TODO use LOD
+ }
+ }
+
+ /**
+ * Empty method
+ * @param ulo
+ * @param uhi
+ * @param vlo
+ * @param vhi
+ */
+ public void domain2f(float ulo, float uhi, float vlo, float vhi) {
+ // DONE
+ }
+
+ /**
+ * Defines 2D mesh
+ * @param nu number of steps in u direction
+ * @param u0 lowest u
+ * @param u1 highest u
+ * @param nv number of steps in v direction
+ * @param v0 lowest v
+ * @param v1 highest v
+ */
+ public void mapgrid2f(int nu, float u0, float u1, int nv, float v0, float v1) {
+
+ if (output_triangles) {
+ // System.out.println("TODO openglsurfaceavaluator.mapgrid2f output_triangles");
+ } else {
+ gl.glMapGrid2d(nu, u0, u1, nv, v0, v1);
+ }
+
+ }
+
+ /**
+ * Evaluates surface
+ * @param style surface style
+ * @param umin minimum U
+ * @param umax maximum U
+ * @param vmin minimum V
+ * @param vmax maximum V
+ */
+ public void mapmesh2f(int style, int umin, int umax, int vmin, int vmax) {
+ if (output_triangles) {
+ // System.out.println("TODO openglsurfaceavaluator.mapmesh2f output_triangles");
+ } else {
+ /* //DEBUG - draw control points
+ this.poradi++;
+ if (poradi % 2 == 0)
+ gl.glColor3f(1, 0, 0);
+ else if (poradi % 2 == 1)
+ gl.glColor3f(0, 1, 0);
+ */
+ switch (style) {
+ case NurbsConsts.N_MESHFILL:
+ gl.glEvalMesh2(GL.GL_FILL, umin, umax, vmin, vmax);
+ break;
+ case NurbsConsts.N_MESHLINE:
+ gl.glEvalMesh2(GL.GL_LINE, umin, umax, vmin, vmax);
+ break;
+ case NurbsConsts.N_MESHPOINT:
+ gl.glEvalMesh2(GL.GL_POINT, umin, umax, vmin, vmax);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Initializes evaluator
+ * @param type surface type
+ * @param ulo lowest u
+ * @param uhi highest u
+ * @param ustride number of objects between control points in u direction
+ * @param uorder surface order in u direction
+ * @param vlo lowest v
+ * @param vhi highest v
+ * @param vstride number of control points' coords
+ * @param vorder surface order in v direction
+ * @param pts control points
+ */
+ public void map2f(int type, float ulo, float uhi, int ustride, int uorder,
+ float vlo, float vhi, int vstride, int vorder, CArrayOfFloats pts) {
+ // TODO Auto-generated method stub
+ if (output_triangles) {
+ // System.out.println("TODO openglsurfaceevaluator.map2f output_triangles");
+ } else {
+ gl.glMap2f(type, ulo, uhi, ustride, uorder, vlo, vhi, vstride,
+ vorder, pts.getArray(), pts.getPointer());
+ }
+ }
+
+ /**
+ * Calls opengl enable
+ * @param type what to enable
+ */
+ public void enable(int type) {
+ //DONE
+ gl.glEnable(type);
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Patch.java b/src/classes/com/sun/opengl/impl/nurbs/Patch.java
new file mode 100755
index 000000000..176f58cbf
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Patch.java
@@ -0,0 +1,54 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Empty class
+ * @author Tomas Hrasky
+ *
+ */
+class Patch {
+
+ /**
+ * Empty constructor
+ * @param q
+ * @param pta
+ * @param ptb
+ * @param patch
+ */
+ public Patch(Quilt q, float[] pta, float[] ptb, Patch patch) {
+ // System.out.println("TODO patch.constructor");
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Patchlist.java b/src/classes/com/sun/opengl/impl/nurbs/Patchlist.java
new file mode 100755
index 000000000..0eba45b34
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Patchlist.java
@@ -0,0 +1,145 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * List of patches
+ * @author Tomáš Hráský
+ *
+ */
+class Patchlist {
+
+ /**
+ * Array of ranges
+ */
+ public Pspec[] pspec;
+
+ /**
+ * head of list of patches
+ */
+ private Patch patch;
+
+ /**
+ * Makes new list of patches
+ * @param quilts list of quilts
+ * @param pta low border
+ * @param ptb high border
+ */
+ public Patchlist(Quilt quilts, float[] pta, float[] ptb) {
+ // DONE
+ patch = null;
+
+ for (Quilt q = quilts; q != null; q = q.next)
+ patch = new Patch(q, pta, ptb, patch);
+ pspec[0] = new Pspec();
+ pspec[0].range[0] = pta[0];
+ pspec[0].range[1] = ptb[0];
+ pspec[0].range[2] = ptb[0] - pta[0];
+ pspec[1] = new Pspec();
+ pspec[1].range[0] = pta[1];
+ pspec[1].range[1] = ptb[1];
+ pspec[1].range[2] = ptb[1] - pta[1];
+
+ }
+
+ /**
+ * Empty constructor
+ * @param patchlist
+ * @param param
+ * @param mid
+ */
+ public Patchlist(Patchlist patchlist, int param, float mid) {
+ // TODO Auto-generated constructor stub
+ // System.out.println("TODO patchlist.konstruktor 2");
+ }
+
+ /**
+ * Empty method
+ * @return 0
+ */
+ public int cullCheck() {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO patchlist.cullcheck");
+ return 0;
+ }
+
+ /**
+ * Empty method
+ */
+ public void getstepsize() {
+ // System.out.println("TODO patchlist.getsptepsize");
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * Empty method
+ * @return false
+ */
+ public boolean needsSamplingSubdivision() {
+ // TODO Auto-generated method stub
+ // System.out.println("patchlist.needsSamplingSubdivision");
+ return false;
+ }
+
+ /**
+ * Empty method
+ * @param i
+ * @return false
+ */
+ public boolean needsSubdivision(int i) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO patchlist.needsSubdivision");
+ return false;
+ }
+
+ /**
+ * Empty method
+ * @return false
+ */
+ public boolean needsNonSamplingSubdivision() {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO patchlist.needsNonSamplingSubdivision");
+ return false;
+ }
+
+ /**
+ * Empty method
+ */
+ public void bbox() {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO patchlist.bbox");
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Property.java b/src/classes/com/sun/opengl/impl/nurbs/Property.java
new file mode 100755
index 000000000..2304973ab
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Property.java
@@ -0,0 +1,75 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Class representing property
+ *
+ * @author Tomas Hrasky
+ *
+ */
+class Property {
+
+ /**
+ * Property type
+ */
+ int type;
+
+ /**
+ * Property id
+ */
+ int tag;
+
+ /**
+ * Property value
+ */
+ float value;
+
+ /**
+ * Makes new property with given parameters
+ *
+ * @param type
+ * property type
+ * @param tag
+ * property id
+ * @param value
+ * property value
+ */
+ public Property(int type, int tag, float value) {
+ this.type = type;
+ this.tag = tag;
+ this.value = value;
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Pspec.java b/src/classes/com/sun/opengl/impl/nurbs/Pspec.java
new file mode 100755
index 000000000..b6439a73d
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Pspec.java
@@ -0,0 +1,47 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Class holding range
+ * @author Tomáš Hráský
+ *
+ */
+class Pspec {
+ /**
+ * Range
+ */
+ public float[] range;
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/PwlArc.java b/src/classes/com/sun/opengl/impl/nurbs/PwlArc.java
new file mode 100755
index 000000000..d6c2bbbdb
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/PwlArc.java
@@ -0,0 +1,71 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Picewiselinar trimming arc
+ * @author Tomáš Hráský
+ *
+ */
+class PwlArc {
+
+ /**
+ * Number of points
+ */
+ private int npts;
+
+ /**
+ * Vertexes
+ */
+ public TrimVertex[] pts;
+
+ /**
+ * Arc type
+ */
+ private int type;
+
+ /**
+ * Makes new trimming arc
+ * @param i num ber of vertexes
+ * @param p trimming vertexes array
+ */
+ public PwlArc(int i, TrimVertex[] p) {
+ // DONE
+ this.npts = i;
+ this.pts = p;
+ type = NurbsConsts.N_P2D;
+
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Quilt.java b/src/classes/com/sun/opengl/impl/nurbs/Quilt.java
new file mode 100755
index 000000000..f5b566e76
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Quilt.java
@@ -0,0 +1,282 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Class for converting NURBS curves and surfaces to list of bezier arcs or patches repectively
+ * @author Tomáš Hráský
+ *
+ */
+class Quilt {
+ /**
+ * Maximum quilt dimension
+ */
+ private static final int MAXDIM = 2;
+
+ /**
+ * List of map descriptions
+ */
+ Mapdesc mapdesc;
+
+ /**
+ * Array of quiltspecs pointer
+ */
+ public CArrayOfQuiltspecs qspec;
+
+ /**
+ * End array of quilt specs pointer
+ */
+ public CArrayOfQuiltspecs eqspec;
+
+ /**
+ * Control points
+ */
+ public CArrayOfFloats cpts;
+
+ /**
+ * Next quilt in list
+ */
+ public Quilt next;
+
+ /**
+ * Makes new quilt with mapdesc
+ * @param mapdesc map description
+ */
+ public Quilt(Mapdesc mapdesc) {
+ // DONE
+ this.mapdesc = mapdesc;
+ Quiltspec[] tmpquilts = new Quiltspec[MAXDIM];
+ for (int i = 0; i < tmpquilts.length; i++)
+ tmpquilts[i] = new Quiltspec();
+ this.qspec = new CArrayOfQuiltspecs(tmpquilts);
+
+ }
+
+ /**
+ * Converts NURBS surface to bezier patches
+ * @param sknotvector knots in u direction
+ * @param tknotvector knots in v direction
+ * @param ctrlarr control points
+ * @param coords control points coords
+ */
+ public void toBezier(Knotvector sknotvector, Knotvector tknotvector,
+ CArrayOfFloats ctrlarr, int coords) {
+ Splinespec spline = new Splinespec(2);
+ spline.kspecinit(sknotvector, tknotvector);
+ spline.select();
+ spline.layout(coords);
+ spline.setupquilt(this);
+ spline.copy(ctrlarr);
+ spline.transform();
+ }
+
+ /**
+ * Converts NURBS curve to list of bezier curves
+ * @param knots knot vector
+ * @param ctlarray control points
+ * @param ncoords number of coordinates
+ */
+ public void toBezier(Knotvector knots, CArrayOfFloats ctlarray, int ncoords) {
+ // DONE
+ Splinespec spline = new Splinespec(1);
+ spline.kspecinit(knots);
+ spline.select();
+ spline.layout(ncoords);
+ spline.setupquilt(this);
+ spline.copy(ctlarray);
+ spline.transform();
+ }
+
+ /**
+ * Walks thru all arcs/patches
+ * @param pta low border
+ * @param ptb high border
+ * @param backend Backend
+ */
+ public void downloadAll(float[] pta, float[] ptb, Backend backend) {
+ // DONE
+ for (Quilt m = this; m != null; m = m.next) {
+ m.select(pta, ptb);
+ m.download(backend);
+ }
+
+ }
+
+ /**
+ * Renders arcs/patches
+ * @param backend Backend for rendering
+ */
+ private void download(Backend backend) {
+ // DONE
+ if (getDimension() == 2) {
+
+ CArrayOfFloats ps = new CArrayOfFloats(cpts);
+ ps.raisePointerBy(qspec.get(0).offset);
+ ps.raisePointerBy(qspec.get(1).offset);
+ ps.raisePointerBy(qspec.get(0).index * qspec.get(0).order
+ * qspec.get(0).stride);
+ ps.raisePointerBy(qspec.get(1).index * qspec.get(1).order
+ * qspec.get(1).stride);
+
+ backend.surfpts(mapdesc.getType(), ps, qspec.get(0).stride, qspec
+ .get(1).stride, qspec.get(0).order, qspec.get(1).order,
+ qspec.get(0).breakpoints[qspec.get(0).index],
+ qspec.get(0).breakpoints[qspec.get(0).index + 1], qspec
+ .get(1).breakpoints[qspec.get(1).index], qspec
+ .get(1).breakpoints[qspec.get(1).index + 1]);
+
+ } else {// code for curves
+ // CArrayOfFloats ps=new CArrayOfFloats(cpts);
+ CArrayOfFloats ps = new CArrayOfFloats(cpts.getArray(), 0);
+ ps.raisePointerBy(qspec.get(0).offset);
+ ps.raisePointerBy(qspec.get(0).index * qspec.get(0).order
+ * qspec.get(0).stride);
+ backend.curvpts(mapdesc.getType(), ps, qspec.get(0).stride, qspec
+ .get(0).order,
+ qspec.get(0).breakpoints[qspec.get(0).index],
+ qspec.get(0).breakpoints[qspec.get(0).index + 1]);
+ }
+
+ }
+
+ /**
+ * Returns quilt dimension
+ * @return quilt dimesion
+ */
+ private int getDimension() {
+ // DONE
+ return eqspec.getPointer() - qspec.getPointer();
+ }
+
+ /**
+ * Finds Quiltspec.index
+ * @param pta range
+ * @param ptb range
+ */
+ private void select(float[] pta, float[] ptb) {
+ // DONE
+ int dim = eqspec.getPointer() - qspec.getPointer();
+ int i, j;
+ for (i = 0; i < dim; i++) {
+ for (j = qspec.get(i).width - 1; j >= 0; j--)
+ if (qspec.get(i).breakpoints[j] <= pta[i]
+ && ptb[i] <= qspec.get(i).breakpoints[j + 1])
+ break;
+ assert (j != -1);
+ qspec.get(i).index = j;
+ }
+ }
+
+ /**
+ * Find range according to breakpoints
+ * @param from low param
+ * @param to high param
+ * @param bpts breakpoints
+ */
+ public void getRange(float[] from, float[] to, Flist bpts) {
+ // DONE
+ getRange(from, to, 0, bpts);
+
+ }
+
+ /**
+ * Find range according to breakpoints
+ * @param from low param
+ * @param to high param
+ * @param i from/to array index
+ * @param list breakpoints
+ */
+ private void getRange(float[] from, float[] to, int i, Flist list) {
+ // DONE
+ Quilt maps = this;
+ from[i] = maps.qspec.get(i).breakpoints[0];
+ to[i] = maps.qspec.get(i).breakpoints[maps.qspec.get(i).width];
+ int maxpts = 0;
+ Quilt m;
+ for (m = maps; m != null; m = m.next) {
+ if (m.qspec.get(i).breakpoints[0] > from[i])
+ from[i] = m.qspec.get(i).breakpoints[0];
+ if (m.qspec.get(i).breakpoints[m.qspec.get(i).width] < to[i])
+ to[i] = m.qspec.get(i).breakpoints[m.qspec.get(i).width];
+ maxpts += m.qspec.get(i).width + 1;
+ }
+ list.grow(maxpts);
+ for (m = maps; m != null; m = m.next) {
+ for (int j = 0; j <= m.qspec.get(i).width; j++) {
+ list.add(m.qspec.get(i).breakpoints[j]);
+ }
+ }
+ list.filter();
+ list.taper(from[i], to[i]);
+ }
+
+ /**
+ * Is this quilt culled
+ * @return 0 or Subdivider.CULL_ACCEPT
+ */
+ public int isCulled() {
+ if (mapdesc.isCulling()) {
+ // System.out.println("TODO quilt.isculled mapdesc.isculling");
+ return 0;
+ } else {
+ return Subdivider.CULL_ACCEPT;
+ }
+ }
+
+ /**
+ * Finds range for surface
+ * @param from low param
+ * @param to high param
+ * @param slist u direction breakpoints
+ * @param tlist v direction breakpoints
+ */
+ public void getRange(float[] from, float[] to, Flist slist, Flist tlist) {
+ // DONE
+ getRange(from, to, 0, slist);
+ getRange(from, to, 1, tlist);
+
+ }
+
+ /**
+ * Empty method
+ * @param sbrkpts
+ * @param tbrkpts
+ * @param rate
+ */
+ public void findRates(Flist sbrkpts, Flist tbrkpts, float[] rate) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO quilt.findrates");
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Quiltspec.java b/src/classes/com/sun/opengl/impl/nurbs/Quiltspec.java
new file mode 100755
index 000000000..1b41c5168
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Quiltspec.java
@@ -0,0 +1,85 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Quilt definition
+ * @author Tomas Hrasky
+ *
+ */
+class Quiltspec {
+
+ /**
+ * Stride between control points
+ */
+ public int stride;
+
+ /**
+ * Quilt width in breakpoints
+ */
+ public int width;
+
+ /**
+ * Quilt order
+ */
+ public int order;
+
+ /**
+ * Start offset
+ */
+ public int offset;
+
+ /**
+ * Breakpoint index
+ */
+ public int index;
+
+ /**
+ * Boundary
+ */
+ public int[] bdry;
+
+ /**
+ * Breakpoints
+ */
+ public float[] breakpoints;
+
+ /**
+ * Makes new quiltspec
+ */
+ public Quiltspec() {
+ this.bdry = new int[2];
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/README-PORTING.txt b/src/classes/com/sun/opengl/impl/nurbs/README-PORTING.txt
deleted file mode 100644
index df5f41782..000000000
--- a/src/classes/com/sun/opengl/impl/nurbs/README-PORTING.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-This is a currently incomplete port of SGI's GLU NURBS library from
-C++ to Java. There are a few reasons for doing such a port:
-
- - The C interface is structured around function pointers. It is
- generally difficult to bind such interfaces up to Java.
-
- - Some people have reported crashes on certain Linux distributions
- when trying to use any routines out of the C GLU library. To date
- we have not been able to diagnose the root cause of these failures.
- Porting the code involved from C++ to Java has solved these
- problems.
-
-The port so far has been started in the internals/ directory. The C++
-sources have been gone through roughly alphabetically and
-transliterated into the appropriate files. The large Subdivider class
-was the current focus of attention at the time of this writing, and a
-closer look indicates that at least a few classes were skipped on the
-way down to some of the Subdivider's sources like intersect.cc. It may
-be a good idea to continue the port in this directory first, since it
-looks like the other directories' sources are built on top of these
-and it would be good to firm up the Java interfaces for the internals
-(and perhaps get the sources to compile) before porting lots of code
-built on top of them.
-
-A couple of notes on the translation:
-
- - All object pool classes have been removed. The intention is to have
- a static allocate() method on the appropriate classes which will
- instantiate populated arrays of these types (not just arrays of
- null references). See uses of TrimVertex.allocate().
-
- - There are a significant number of places in the original C++ code
- where pointer arithmetic is used. Some of these are not obvious
- until the code has been ported and examined. Bin.java was a good
- example of this where the algorithms needed some restructuring. At
- the time of this writing intersect.cc was in the process of being
- ported and it wasn't clear whether we would need to change some of
- the APIs or add more utility routines to be able to do pointer
- arithmetic on, for example, the TrimVertex arrays returned from the
- allocate() routine.
diff --git a/src/classes/com/sun/opengl/impl/nurbs/README.txt b/src/classes/com/sun/opengl/impl/nurbs/README.txt
new file mode 100755
index 000000000..89630c71e
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/README.txt
@@ -0,0 +1,59 @@
+Unimplemented functionality
+ - tesselation and callbacks
+ - trimming
+ - setting NURBS properties (-> sampling etc.)
+Differences from C++ source
+ - no pooling
+ - pointers to arrays are replaced by CArrayOf... classes and their methods
+Unimplemented or incomplete "calltree top" methods (according to glu.def in Mesa 6.5)
+ gluBeginTrim
+ gluDeleteNurbsRenderer - won't be needed
+ gluEndTrim
+ gluGetNurbsProperty
+ gluLoadSamplingMatrices
+ gluNurbsCallback
+ gluNurbsCallbackData
+ gluNurbsCallbackDataEXT
+ gluNurbsCurve - TODO type switch
+ gluNurbsProperty
+ gluPwlCurve
+ gluQuadricCallback - not a NURBS method
+As of files
+ - Arc[ST]dirSorter.java - unimplemented (part of tesselation)
+ - Backend.java:194 - wireframe quads - part of tesselation/callback
+ - Curve.java:141-204 - culling
+ - DisplayList.java:57 - append to DL - not sure whether it will be needed
+ - GLUnurbs.java :443,484 - error values
+ :445 - trimming
+ :512 - error handling (callback)
+ :530 - loadGLmatrices
+ :786 - nuid - nurbs object id - won't be needed I think
+ :803 - end trim
+ - GLUwNURBS.java:68,176 - NUBRS properties
+ - Knotspec.java :371 - copying in general case (more than 4 coords)
+ :517 - copying with more than 4 coords
+ :556 - pt_oo_sum default
+ - Knotvector.java:165 - show method (probably debugging)
+ - Mapdesc.java :354 - get property
+ :435 - xFormMat - change param cp to CArrayOfFloats; probably sampling functionality
+ - Maplist.java:68 - clear ?
+ - OpenGLCurveEvaluator.java :132 - tess./callback code
+ :168 - mapgrid1f
+ :190 - tess./callback code (output triangles)
+ - OpenGLSurfaceEvaluator.java :77 . tess./callback code
+ :81 - glGetIntegerValue
+ :114 - tess./callback code
+ :117 - Level of detail
+ :144,161,201 - tess./callback code - output triangles
+ - Patch.java:55 - constructor stuff ?
+ - Patchlist.java:55 - constructor stuff ?
+ :97 - cull check
+ :105 - step size
+ :115 - need of sampling subdivision
+ :126 - need of subdivision
+ :137 - need of non sampling subd.
+ :146 - bbox (??)
+ -Quilt.java :254 - culling
+ :282 - rates
+ -Subdivider.java - all TODOs - it's stuff about trimming probably
+ :545 - jumpbuffer - not sure purpose it exactly served in original source
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Renderhints.java b/src/classes/com/sun/opengl/impl/nurbs/Renderhints.java
new file mode 100755
index 000000000..02bc4c5bd
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Renderhints.java
@@ -0,0 +1,128 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Class holding rendering params
+ * @author Tomas Hrasky
+ *
+ */
+class Renderhints {
+
+ /**
+ * Check for errors
+ */
+ public int errorchecking;
+
+ /**
+ * Maximum subdivisions
+ */
+ public int maxsubdivisions;
+
+ /**
+ * Number of subdivisions
+ */
+ private int subdivisions;
+
+ /**
+ * Display method
+ */
+ int display_method;
+
+ /**
+ * Output triangles
+ */
+ int wiretris;
+
+ /**
+ * Output quads
+ */
+ int wirequads;
+
+ /**
+ * Makes new Renderinghints
+ */
+ public Renderhints() {
+ display_method = NurbsConsts.N_FILL;
+ errorchecking = NurbsConsts.N_MSG;
+ subdivisions = 6;
+ // tmp1=0;
+ }
+
+ /**
+ * Set property value
+ * @param prop property
+ */
+ public void setProperty(Property prop) {
+ switch (prop.type) {
+ case NurbsConsts.N_DISPLAY:
+ display_method = (int) prop.value;
+ break;
+ case NurbsConsts.N_ERRORCHECKING:
+ errorchecking = (int) prop.value;
+ break;
+ case NurbsConsts.N_SUBDIVISIONS:
+ subdivisions = (int) prop.value;
+ break;
+ default:
+ // abort - end program
+ break;
+ }
+ }
+
+ /**
+ * Initialization
+ */
+ public void init() {
+ // DONE
+ maxsubdivisions = subdivisions;
+ if (maxsubdivisions < 0)
+ maxsubdivisions = 0;
+
+ if (display_method == NurbsConsts.N_FILL) {
+ wiretris = 0;
+ wirequads = 0;
+ } else if (display_method == NurbsConsts.N_OUTLINE_TRI) {
+ wiretris = 1;
+ wirequads = 0;
+ } else if (display_method == NurbsConsts.N_OUTLINE_QUAD) {
+ wiretris = 0;
+ wirequads = 1;
+ } else {
+ wiretris = 1;
+ wirequads = 1;
+ }
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Splinespec.java b/src/classes/com/sun/opengl/impl/nurbs/Splinespec.java
new file mode 100755
index 000000000..5e7d31ff3
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Splinespec.java
@@ -0,0 +1,204 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * NURBS definition
+ * @author Tomas Hrasky
+ *
+ */
+class Splinespec {
+
+ /**
+ * Dimension
+ */
+ private int dim;
+
+ /**
+ * Knot vector specs
+ */
+ private Knotspec kspec;
+
+ /**
+ * Control points after conversion
+ */
+ private CArrayOfFloats outcpts;
+
+ /**
+ * Makes new Splinespec with given dimension
+ * @param i dimension
+ */
+ public Splinespec(int i) {
+ // DONE
+ this.dim = i;
+ }
+
+ /**
+ * Initializes knotspec according to knotvector
+ * @param knotvector basic knotvector
+ */
+ public void kspecinit(Knotvector knotvector) {
+ // DONE
+ this.kspec = new Knotspec();
+ kspec.inkbegin = new CArrayOfFloats(knotvector.knotlist, 0);
+ kspec.inkend = new CArrayOfFloats(knotvector.knotlist,
+ knotvector.knotcount);
+ kspec.prestride = knotvector.stride;
+ kspec.order = knotvector.order;
+ kspec.next = null;
+ }
+
+ /**
+ * Initializes knotspec according to knotvector - SURFACE
+ * @param sknotvector knotvector in u dir
+ * @param tknotvector knotvector in v dir
+ */
+ public void kspecinit(Knotvector sknotvector, Knotvector tknotvector) {
+ // DONE
+ this.kspec = new Knotspec();
+ Knotspec tkspec = new Knotspec();
+
+ kspec.inkbegin = new CArrayOfFloats(sknotvector.knotlist, 0);
+ kspec.inkend = new CArrayOfFloats(sknotvector.knotlist,
+ sknotvector.knotcount);
+ kspec.prestride = sknotvector.stride;
+ kspec.order = sknotvector.order;
+ kspec.next = tkspec;
+
+ tkspec.inkbegin = new CArrayOfFloats(tknotvector.knotlist, 0);
+ tkspec.inkend = new CArrayOfFloats(tknotvector.knotlist,
+ tknotvector.knotcount);
+ tkspec.prestride = tknotvector.stride;
+ tkspec.order = tknotvector.order;
+ tkspec.next = null;
+ }
+
+ /**
+ * Preselect and select knotspecs
+ */
+ public void select() {
+ // DONE
+ for (Knotspec knotspec = kspec; knotspec != null; knotspec = knotspec.next) {
+ knotspec.preselect();
+ knotspec.select();
+ }
+
+ }
+
+ /**
+ * Prepares for conversion
+ * @param ncoords number of coords
+ */
+ public void layout(int ncoords) {
+ // DONE
+ int stride = ncoords;
+ for (Knotspec knotspec = kspec; knotspec != null; knotspec = knotspec.next) {
+ knotspec.poststride = stride;
+ stride *= (knotspec.bend.getPointer() - knotspec.bbegin
+ .getPointer())
+ * knotspec.order + knotspec.postoffset;
+ knotspec.preoffset *= knotspec.prestride;
+ knotspec.prewidth *= knotspec.poststride;
+ knotspec.postwidth *= knotspec.poststride;
+ knotspec.postoffset *= knotspec.poststride;
+ knotspec.ncoords = ncoords;
+ }
+ outcpts = new CArrayOfFloats(new float[stride]);
+
+ }
+
+ /**
+ * Prepares quilt for conversion
+ * @param quilt quilt to work with
+ */
+ public void setupquilt(Quilt quilt) {
+ // DONE
+ CArrayOfQuiltspecs qspec = new CArrayOfQuiltspecs(quilt.qspec);
+ quilt.eqspec = new CArrayOfQuiltspecs(qspec.getArray(), dim);
+ for (Knotspec knotspec = kspec; knotspec != null;) {
+ qspec.get().stride = knotspec.poststride;
+ qspec.get().width = knotspec.bend.getPointer()
+ - knotspec.bbegin.getPointer();
+ qspec.get().order = knotspec.order;
+ qspec.get().offset = knotspec.postoffset;
+ qspec.get().index = 0;
+ qspec.get().bdry[0] = (knotspec.kleft.getPointer() == knotspec.kfirst
+ .getPointer()) ? 1 : 0;
+ qspec.get().bdry[1] = (knotspec.kright.getPointer() == knotspec.klast
+ .getPointer()) ? 1 : 0;
+ qspec.get().breakpoints = new float[qspec.get().width + 1];
+ CArrayOfFloats k = new CArrayOfFloats(qspec.get().breakpoints, 0);
+ for (CArrayOfBreakpts bk = new CArrayOfBreakpts(knotspec.bbegin); bk
+ .getPointer() <= knotspec.bend.getPointer(); bk.pp()) {
+ k.set(bk.get().value);
+ k.pp();
+ }
+ knotspec = knotspec.next;
+ if (knotspec != null)
+ qspec.pp();
+ }
+ quilt.cpts = new CArrayOfFloats(outcpts);
+ quilt.next = null;
+ }
+
+ /**
+ * Copies array of control points to output array
+ * @param ctlarray control points array
+ */
+ public void copy(CArrayOfFloats ctlarray) {
+ // DONE
+ kspec.copy(ctlarray, outcpts);
+
+ }
+
+ /**
+ * Transforms knotspecs - conversion
+ */
+ public void transform() {
+ // DONE
+ Knotspec knotspec;
+ outcpts.setPointer(0);
+ for (knotspec = kspec; knotspec != null; knotspec = knotspec.next)
+ knotspec.istransformed = false;
+
+ for (knotspec = kspec; knotspec != null; knotspec = knotspec.next) {
+ for (Knotspec kspec2 = kspec; kspec2 != null; kspec2 = kspec2.next)
+ kspec2.kspectotrans = knotspec;
+ kspec.transform(outcpts);
+ knotspec.istransformed = true;
+ }
+
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/Subdivider.java b/src/classes/com/sun/opengl/impl/nurbs/Subdivider.java
new file mode 100755
index 000000000..4e5116106
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/Subdivider.java
@@ -0,0 +1,1167 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Class working with curves and surfaces
+ * @author Tomas Hrasky
+ *
+ */
+class Subdivider {
+ /**
+ * Cull type
+ */
+ public static final int CULL_TRIVIAL_REJECT = 0;
+
+ /**
+ * Cull type
+ */
+ public static final int CULL_ACCEPT = 1;
+
+ /**
+ * Maximum trimming arcs
+ */
+ private static final int MAXARCS = 10;
+
+ /**
+ * Linked list of Quilts
+ */
+ Quilt qlist;
+
+ /**
+ * Object holding rendering honts information
+ */
+ private Renderhints renderhints;
+
+ /**
+ * Backend object
+ */
+ private Backend backend;
+
+ /**
+ * Number of subdivisions
+ */
+ private int subdivisions;
+
+ /**
+ * U step when using domain distance sampling
+ */
+ private float domain_distance_u_rate;
+
+ /**
+ * Use domain distance sampling
+ */
+ private int is_domain_distance_sampling;
+
+ /**
+ * Initial class holding trimming arcs
+ */
+ private Bin initialbin;
+
+ /**
+ * Not used
+ */
+ private boolean showDegenerate;
+
+ /**
+ * Is triming arc type bezier arc
+ */
+ private boolean isArcTypeBezier;
+
+ /**
+ * Breakpoints in v direction
+ */
+ private Flist tpbrkpts;
+
+ /**
+ * Breakpoints in u direction
+ */
+ private Flist spbrkpts;
+
+ /**
+ * Unused
+ */
+ private int s_index;
+
+ /**
+ * Head of linked list of trimming arcs
+ */
+ private Arc pjarc;
+
+ /**
+ * Class tesselating trimming arcs
+ */
+ private ArcTesselator arctesselator;
+
+ /**
+ * Unused
+ */
+ private int t_index;
+
+ /**
+ * Breakpoints
+ */
+ private Flist smbrkpts;
+
+ /**
+ * Not used
+ */
+ private float[] stepsizes;
+
+ /**
+ * Domain distance in V direction
+ */
+ private float domain_distance_v_rate;
+
+ /**
+ * Initializes quilt list
+ */
+ public void beginQuilts() {
+ // DONE
+ qlist = null;
+ renderhints = new Renderhints();
+ backend = new Backend();
+
+ initialbin = new Bin();
+ arctesselator = new ArcTesselator();
+ }
+
+ /**
+ * Adds quilt to linked list
+ * @param quilt added quilt
+ */
+ public void addQuilt(Quilt quilt) {
+ // DONE
+ if (qlist == null)
+ qlist = quilt;
+ else {
+ quilt.next = qlist;
+ qlist = quilt;
+ }
+
+ }
+
+ /**
+ * Empty method
+ */
+ public void endQuilts() {
+ // DONE
+ }
+
+ /**
+ * Draws a surface
+ */
+ public void drawSurfaces() {
+ renderhints.init();
+
+ if (qlist == null) {
+ // System.out.println("qlist is null");
+ return;
+ }
+
+ for (Quilt q = qlist; q != null; q = q.next) {
+ if (q.isCulled() == CULL_TRIVIAL_REJECT) {
+ freejarcs(initialbin);
+ return;
+ }
+ }
+
+ float[] from = new float[2];
+ float[] to = new float[2];
+
+ spbrkpts = new Flist();
+ tpbrkpts = new Flist();
+ qlist.getRange(from, to, spbrkpts, tpbrkpts);
+
+ boolean optimize = (is_domain_distance_sampling > 0 && (renderhints.display_method != NurbsConsts.N_OUTLINE_PATCH));
+
+ // TODO decide whether to optimize (when there is gluNurbsProperty implemented)
+ optimize = true;
+
+ if (!initialbin.isnonempty()) {
+ if (!optimize) {
+ makeBorderTrim(from, to);
+ }
+ } else {
+ float[] rate = new float[2];
+ qlist.findRates(spbrkpts, tpbrkpts, rate);
+ // System.out.println("subdivider.drawsurfaces decompose");
+ }
+
+ backend.bgnsurf(renderhints.wiretris, renderhints.wirequads);
+
+ // TODO partition test
+
+ if (!initialbin.isnonempty() && optimize) {
+
+ int i, j;
+ int num_u_steps;
+ int num_v_steps;
+ for (i = spbrkpts.start; i < spbrkpts.end - 1; i++) {
+ for (j = tpbrkpts.start; j < tpbrkpts.end - 1; j++) {
+ float[] pta = new float[2];
+ float[] ptb = new float[2];
+
+ pta[0] = spbrkpts.pts[i];
+ ptb[0] = spbrkpts.pts[i + 1];
+ pta[1] = tpbrkpts.pts[j];
+ ptb[1] = tpbrkpts.pts[j + 1];
+ qlist.downloadAll(pta, ptb, backend);
+
+ num_u_steps = (int) (domain_distance_u_rate * (ptb[0] - pta[0]));
+ num_v_steps = (int) (domain_distance_v_rate * (ptb[1] - pta[1]));
+
+ if (num_u_steps <= 0)
+ num_u_steps = 1;
+ if (num_v_steps <= 0)
+ num_v_steps = 1;
+
+ backend.surfgrid(pta[0], ptb[0], num_u_steps, ptb[1],
+ pta[1], num_v_steps);
+ backend.surfmesh(0, 0, num_u_steps, num_v_steps);
+
+ }
+ }
+
+ } else
+
+ subdivideInS(initialbin);
+
+ backend.endsurf();
+ }
+
+ /**
+ * Empty method
+ * @param initialbin2
+ */
+ private void freejarcs(Bin initialbin2) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.freejarcs");
+ }
+
+ /**
+ * Subdivide in U direction
+ * @param source Trimming arcs source
+ */
+ private void subdivideInS(Bin source) {
+ // DONE
+ if (renderhints.display_method == NurbsConsts.N_OUTLINE_PARAM) {
+ outline(source);
+ freejarcs(source);
+ } else {
+ setArcTypeBezier();
+ setNonDegenerate();
+ splitInS(source, spbrkpts.start, spbrkpts.end);
+ }
+
+ }
+
+ /**
+ * Split in U direction
+ * @param source Trimming arcs source
+ * @param start breakpoints start
+ * @param end breakpoints end
+ */
+ private void splitInS(Bin source, int start, int end) {
+ // DONE
+ if (source.isnonempty()) {
+ if (start != end) {
+ int i = start + (end - start) / 2;
+ Bin left = new Bin();
+ Bin right = new Bin();
+
+ split(source, left, right, 0, spbrkpts.pts[i]);
+ splitInS(left, start, i);
+ splitInS(right, i + 1, end);
+ } else {
+ if (start == spbrkpts.start || start == spbrkpts.end) {
+ freejarcs(source);
+ } else if (renderhints.display_method == NurbsConsts.N_OUTLINE_PARAM_S) {
+ outline(source);
+ freejarcs(source);
+ } else {
+ setArcTypeBezier();
+ setNonDegenerate();
+ s_index = start;
+ splitInT(source, tpbrkpts.start, tpbrkpts.end);
+ }
+ }
+ } else{
+ // System.out.println("Source is empty - subdivider.splitins");
+ }
+ }
+
+ /**
+ * Split in V direction
+ * @param source
+ * @param start
+ * @param end
+ */
+ private void splitInT(Bin source, int start, int end) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.splitint");
+
+ if (source.isnonempty()) {
+ if (start != end) {
+ int i = start + (end - start) / 2;
+ Bin left = new Bin();
+ Bin right = new Bin();
+ split(source, left, right, 1, tpbrkpts.pts[i + 1]);
+ splitInT(left, start, i);
+ splitInT(right, i + 1, end);
+ } else {
+ if (start == tpbrkpts.start || start == tpbrkpts.end) {
+ freejarcs(source);
+ } else if (renderhints.display_method == NurbsConsts.N_OUTLINE_PARAM_ST) {
+ outline(source);
+ freejarcs(source);
+ } else {
+ t_index = start;
+ setArcTypeBezier();
+ setDegenerate();
+
+ float[] pta = new float[2];
+ float[] ptb = new float[2];
+
+ pta[0] = spbrkpts.pts[s_index - 1];
+ pta[1] = tpbrkpts.pts[t_index - 1];
+
+ ptb[0] = spbrkpts.pts[s_index];
+ ptb[1] = tpbrkpts.pts[t_index];
+ qlist.downloadAll(pta, ptb, backend);
+
+ Patchlist patchlist = new Patchlist(qlist, pta, ptb);
+
+ samplingSplit(source, patchlist,
+ renderhints.maxsubdivisions, 0);
+ setNonDegenerate();
+ setArcTypeBezier();
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Sample
+ * @param source
+ * @param patchlist
+ * @param subdivisions
+ * @param param
+ */
+ private void samplingSplit(Bin source, Patchlist patchlist,
+ int subdivisions, int param) {
+ // DONE
+ if (!source.isnonempty())
+ return;
+ if (patchlist.cullCheck() == CULL_TRIVIAL_REJECT) {
+ freejarcs(source);
+ return;
+ }
+
+ patchlist.getstepsize();
+ if (renderhints.display_method == NurbsConsts.N_OUTLINE_PATCH) {
+ tesselation(source, patchlist);
+ outline(source);
+ freejarcs(source);
+ return;
+ }
+
+ tesselation(source, patchlist);
+ if (patchlist.needsSamplingSubdivision() && subdivisions > 0) {
+ if (!patchlist.needsSubdivision(0)) {
+ param = 1;
+ } else if (patchlist.needsSubdivision(1))
+ param = 0;
+ else
+ param = 1 - param;
+
+ Bin left = new Bin();
+ Bin right = new Bin();
+
+ float mid = (float) ((patchlist.pspec[param].range[0] + patchlist.pspec[param].range[1]) * .5);
+
+ split(source, left, right, param, mid);
+ Patchlist subpatchlist = new Patchlist(patchlist, param, mid);
+ samplingSplit(left, subpatchlist, subdivisions - 1, param);
+ samplingSplit(right, subpatchlist, subdivisions - 1, param);
+ } else {
+ setArcTypePwl();
+ setDegenerate();
+ nonSamplingSplit(source, patchlist, subdivisions, param);
+ setDegenerate();
+ setArcTypeBezier();
+ }
+ }
+
+ /**
+ * Not used
+ * @param source
+ * @param patchlist
+ * @param subdivisions
+ * @param param
+ */
+ private void nonSamplingSplit(Bin source, Patchlist patchlist,
+ int subdivisions, int param) {
+ // DONE
+ if (patchlist.needsNonSamplingSubdivision() && subdivisions > 0) {
+ param = 1 - param;
+
+ Bin left = new Bin();
+ Bin right = new Bin();
+
+ float mid = (float) ((patchlist.pspec[param].range[0] + patchlist.pspec[param].range[1]) * .5);
+ split(source, left, right, param, mid);
+ Patchlist subpatchlist = new Patchlist(patchlist, param, mid);
+ if (left.isnonempty()) {
+ if (subpatchlist.cullCheck() == CULL_TRIVIAL_REJECT)
+ freejarcs(left);
+ else
+ nonSamplingSplit(left, subpatchlist, subdivisions - 1,
+ param);
+ }
+ if (right.isnonempty()) {
+ if (patchlist.cullCheck() == CULL_TRIVIAL_REJECT)
+ freejarcs(right);
+ else
+ nonSamplingSplit(right, subpatchlist, subdivisions - 1,
+ param);
+ }
+ } else {
+ patchlist.bbox();
+ backend.patch(patchlist.pspec[0].range[0],
+ patchlist.pspec[0].range[1], patchlist.pspec[1].range[0],
+ patchlist.pspec[1].range[1]);
+ if (renderhints.display_method == NurbsConsts.N_OUTLINE_SUBDIV) {
+ outline(source);
+ freejarcs(source);
+ } else {
+ setArcTypePwl();
+ setDegenerate();
+ findIrregularS(source);
+ monosplitInS(source, smbrkpts.start, smbrkpts.end);
+ }
+ }
+
+ }
+
+ /**
+ * Not used
+ * @param source
+ * @param start
+ * @param end
+ */
+ private void monosplitInS(Bin source, int start, int end) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.monosplitins");
+ }
+
+ /**
+ * Not used
+ * @param source
+ */
+ private void findIrregularS(Bin source) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.findIrregularS");
+ }
+
+ /**
+ * Not used
+ */
+ private void setArcTypePwl() {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.setarctypepwl");
+ }
+
+ /**
+ * Not used
+ * @param source
+ * @param patchlist
+ */
+ private void tesselation(Bin source, Patchlist patchlist) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.tesselation");
+ }
+
+ /**
+ * Not used
+ */
+ private void setDegenerate() {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.setdegenerate");
+ }
+
+ /**
+ * Not used
+ * @param bin
+ * @param left
+ * @param right
+ * @param param
+ * @param value
+ */
+ private void split(Bin bin, Bin left, Bin right, int param, float value) {
+ // DONE
+ Bin intersections = new Bin();
+ Bin unknown = new Bin();
+
+ partition(bin, left, intersections, right, unknown, param, value);
+
+ int count = intersections.numarcs();
+ // TODO jumpbuffer ??
+
+ if (count % 2 == 0) {
+
+ Arc[] arclist = new Arc[MAXARCS];
+ CArrayOfArcs list;
+ if (count >= MAXARCS) {
+ list = new CArrayOfArcs(new Arc[count]);
+ } else {
+ list = new CArrayOfArcs(arclist);
+ }
+
+ CArrayOfArcs last, lptr;
+ Arc jarc;
+
+ for (last = new CArrayOfArcs(list); (jarc = intersections
+ .removearc()) != null; last.pp())
+ last.set(jarc);
+
+ if (param == 0) {// sort into incrasing t order
+ ArcSdirSorter sorter = new ArcSdirSorter(this);
+ sorter.qsort(list, count);
+
+ for (lptr = new CArrayOfArcs(list); lptr.getPointer() < last
+ .getPointer(); lptr.raisePointerBy(2))
+ check_s(lptr.get(), lptr.getRelative(1));
+ for (lptr = new CArrayOfArcs(list); lptr.getPointer() < last
+ .getPointer(); lptr.raisePointerBy(2))
+ join_s(left, right, lptr.get(), lptr.getRelative(1));
+ for (lptr = new CArrayOfArcs(list); lptr.getPointer() != last
+ .getPointer(); lptr.pp()) {
+ if (lptr.get().head()[0] <= value
+ && lptr.get().tail()[0] <= value)
+ left.addarc(lptr.get());
+ else
+ right.addarc(lptr.get());
+ }
+
+ } else {// sort into decreasing s order
+ ArcTdirSorter sorter = new ArcTdirSorter(this);
+ sorter.qsort(list, count);
+
+ for (lptr = new CArrayOfArcs(list); lptr.getPointer() < last
+ .getPointer(); lptr.raisePointerBy(2))
+ check_t(lptr.get(), lptr.getRelative(1));
+ for (lptr = new CArrayOfArcs(list); lptr.getPointer() < last
+ .getPointer(); lptr.raisePointerBy(2))
+ join_t(left, right, lptr.get(), lptr.getRelative(1));
+ for (lptr = new CArrayOfArcs(list); lptr.getPointer() != last
+ .getPointer(); lptr.raisePointerBy(2)) {
+ if (lptr.get().head()[0] <= value
+ && lptr.get().tail()[0] <= value)
+ left.addarc(lptr.get());
+ else
+ right.addarc(lptr.get());
+ }
+
+ }
+
+ unknown.adopt();
+ }
+ }
+
+ /**
+ * Not used
+ * @param left
+ * @param right
+ * @param arc
+ * @param relative
+ */
+ private void join_t(Bin left, Bin right, Arc arc, Arc relative) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.join_t");
+ }
+
+ /**
+ * Not used
+ * @param arc
+ * @param relative
+ */
+ private void check_t(Arc arc, Arc relative) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.check_t");
+ }
+
+ /**
+ * Not used
+ * @param left
+ * @param right
+ * @param jarc1
+ * @param jarc2
+ */
+ private void join_s(Bin left, Bin right, Arc jarc1, Arc jarc2) {
+ // DONE
+ if (!jarc1.getitail())
+ jarc1 = jarc1.next;
+ if (!jarc2.getitail())
+ jarc2 = jarc2.next;
+
+ float s = jarc1.tail()[0];
+ float t1 = jarc1.tail()[1];
+ float t2 = jarc2.tail()[1];
+
+ if (t1 == t2) {
+ simplelink(jarc1, jarc2);
+ } else {
+ Arc newright = new Arc(Arc.ARC_RIGHT);
+ Arc newleft = new Arc(Arc.ARC_LEFT);
+ if (isBezierArcType()) {
+ arctesselator.bezier(newright, s, s, t1, t2);
+ arctesselator.bezier(newleft, s, s, t2, t1);
+ } else {
+ arctesselator.pwl_right(newright, s, t1, t2, stepsizes[0]);
+ arctesselator.pwl_left(newright, s, t2, t1, stepsizes[2]);
+ }
+ link(jarc1, jarc2, newright, newleft);
+ left.addarc(newright);
+ right.addarc(newleft);
+ }
+
+ }
+
+ /**
+ * Not used
+ * @param jarc1
+ * @param jarc2
+ * @param newright
+ * @param newleft
+ */
+ private void link(Arc jarc1, Arc jarc2, Arc newright, Arc newleft) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.link");
+ }
+
+ /**
+ * Not used
+ * @return true
+ */
+ private boolean isBezierArcType() {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.isbezierarc");
+ return true;
+ }
+
+ /**
+ * Not used
+ * @param jarc1
+ * @param jarc2
+ */
+ private void simplelink(Arc jarc1, Arc jarc2) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.simplelink");
+ }
+
+ /**
+ * Not used
+ * @param arc
+ * @param relative
+ */
+ private void check_s(Arc arc, Arc relative) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.check_s");
+
+ }
+
+ /**
+ * Not used
+ * @param bin
+ * @param left
+ * @param intersections
+ * @param right
+ * @param unknown
+ * @param param
+ * @param value
+ */
+ private void partition(Bin bin, Bin left, Bin intersections, Bin right,
+ Bin unknown, int param, float value) {
+
+ Bin headonleft = new Bin();
+ Bin headonright = new Bin();
+ Bin tailonleft = new Bin();
+ Bin tailonright = new Bin();
+
+ for (Arc jarc = bin.removearc(); jarc != null; jarc = bin.removearc()) {
+ float tdiff = jarc.tail()[param] - value;
+ float hdiff = jarc.head()[param] - value;
+
+ if (tdiff > 0) {
+ if (hdiff > 0) {
+ right.addarc(jarc);
+ } else if (hdiff == 0) {
+ tailonright.addarc(jarc);
+ } else {
+ Arc jtemp;
+ switch (arc_split(jarc, param, value, 0)) {
+ case 2:
+ tailonright.addarc(jarc);
+ headonleft.addarc(jarc.next);
+ break;
+ // TODO rest cases
+ default:
+ System.out
+ .println("TODO subdivider.partition rest cases");
+ break;
+ }
+ }
+ } else if (tdiff == 0) {
+ if (hdiff > 0) {
+ headonright.addarc(jarc);
+ } else if (hdiff == 0) {
+ unknown.addarc(jarc);
+ } else {
+ headonright.addarc(jarc);
+ }
+ } else {
+ if (hdiff > 0) {
+ // TODO rest
+ // System.out.println("TODO subdivider.partition rest of else");
+ } else if (hdiff == 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);
+ }
+ }
+
+ /**
+ * Not used
+ * @param tailonright
+ * @param intersections
+ * @param right
+ * @param value
+ */
+ private void classify_tailonright_t(Bin tailonright, Bin intersections,
+ Bin right, float value) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.classify_tailonright_t");
+
+ }
+
+ /**
+ * Not used
+ * @param bin
+ * @param in
+ * @param out
+ * @param val
+ */
+ private void classify_tailonleft_s(Bin bin, Bin in, Bin out, float val) {
+
+ // DONE
+ Arc j;
+ while ((j = bin.removearc()) != null) {
+ j.clearitail();
+
+ float diff = j.next.head()[0] - val;
+ if (diff > 0) {
+ in.addarc(j);
+ } else if (diff < 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);
+ }
+ }
+
+ }
+
+ /**
+ * Not used
+ * @param bin
+ * @param in
+ * @param out
+ * @param val
+ */
+ private void classify_headonright_s(Bin bin, Bin in, Bin out, float val) {
+ // DONE
+ Arc j;
+ while ((j = bin.removearc()) != null) {
+ j.setitail();
+
+ float diff = j.prev.tail()[0] - val;
+ if (diff > 0) {
+ if (ccwTurn_sr(j.prev, j))
+ out.addarc(j);
+ else
+ in.addarc(j);
+ } else if (diff < 0) {
+ out.addarc(j);
+ } else {
+ if (j.prev.tail()[1] > j.prev.head()[1])
+ out.addarc(j);
+ else
+ in.addarc(j);
+ }
+ }
+ }
+
+ /**
+ * Not used
+ * @param prev
+ * @param j
+ * @return false
+ */
+ private boolean ccwTurn_sr(Arc prev, Arc j) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO ccwTurn_sr");
+ return false;
+ }
+
+ /**
+ * Not used
+ * @param headonright
+ * @param intersections
+ * @param right
+ * @param value
+ */
+ private void classify_headonright_t(Bin headonright, Bin intersections,
+ Bin right, float value) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.classify_headonright_t");
+ }
+
+ /**
+ * Not used
+ * @param tailonleft
+ * @param intersections
+ * @param left
+ * @param value
+ */
+ private void classify_tailonleft_t(Bin tailonleft, Bin intersections,
+ Bin left, float value) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.classify_tailonleft_t");
+ }
+
+ /**
+ * Not used
+ * @param bin
+ * @param in
+ * @param out
+ * @param val
+ */
+ private void classify_headonleft_t(Bin bin, Bin in, Bin out, float val) {
+ // DONE
+ Arc j;
+ while ((j = bin.removearc()) != null) {
+ j.setitail();
+
+ float diff = j.prev.tail()[1] - val;
+ if (diff > 0) {
+ out.addarc(j);
+ } else if (diff < 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);
+ }
+ }
+ }
+
+ /**
+ * Not used
+ * @param prev
+ * @param j
+ * @return false
+ */
+ private boolean ccwTurn_tl(Arc prev, Arc j) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.ccwTurn_tl");
+ return false;
+ }
+
+ /**
+ * Not used
+ * @param bin
+ * @param in
+ * @param out
+ * @param val
+ */
+ private void classify_tailonright_s(Bin bin, Bin in, Bin out, float val) {
+ // DONE
+ Arc j;
+ while ((j = bin.removearc()) != null) {
+ j.clearitail();
+
+ float diff = j.next.head()[0] - val;
+ if (diff > 0) {
+ if (ccwTurn_sr(j, j.next))
+ out.addarc(j);
+ else
+ in.addarc(j);
+ } else if (diff < 0) {
+ in.addarc(j);
+ } else {
+ if (j.next.tail()[1] > j.next.head()[1])
+ out.addarc(j);
+ else
+ in.addarc(j);
+ }
+ }
+
+ }
+
+ /**
+ * Not used
+ * @param bin
+ * @param in
+ * @param out
+ * @param val
+ */
+ private void classify_headonleft_s(Bin bin, Bin in, Bin out, float val) {
+ // DONE
+ Arc j;
+ while ((j = bin.removearc()) != null) {
+ j.setitail();
+
+ float diff = j.prev.tail()[0] - val;
+ if (diff > 0) {
+ out.addarc(j);
+ } else if (diff < 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);
+ }
+ }
+
+ }
+
+ /**
+ * Not used
+ * @param prev
+ * @param j
+ * @return false
+ */
+ private boolean ccwTurn_sl(Arc prev, Arc j) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.ccwTurn_sl");
+ return false;
+ }
+
+ /**
+ * Not used
+ * @param jarc
+ * @param param
+ * @param value
+ * @param i
+ * @return 0
+ */
+ private int arc_split(Arc jarc, int param, float value, int i) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.arc_split");
+ return 0;
+ }
+
+ /**
+ * Not used
+ */
+ private void setNonDegenerate() {
+ // DONE
+ this.showDegenerate = false;
+
+ }
+
+ /**
+ * sets trimming arc default type to bezier
+ */
+ private void setArcTypeBezier() {
+ // DONE
+ isArcTypeBezier = true;
+ }
+
+ /**
+ * Not used
+ * @param source
+ */
+ private void outline(Bin source) {
+ // TODO Auto-generated method stub
+ // System.out.println("TODO subdivider.outline");
+ }
+
+ /**
+ * Makes default trim along surface borders
+ * @param from range beginnings
+ * @param to range ends
+ */
+ private void makeBorderTrim(float[] from, float[] to) {
+ // DONE
+ float smin = from[0];
+ float smax = to[0];
+
+ float tmin = from[1];
+ float tmax = to[1];
+
+ pjarc = null;
+ Arc jarc = null;
+
+ jarc = new Arc(Arc.ARC_BOTTOM);
+ arctesselator.bezier(jarc, smin, smax, tmin, tmin);
+ initialbin.addarc(jarc);
+ pjarc = jarc.append(pjarc);
+
+ jarc = new Arc(Arc.ARC_RIGHT);
+ arctesselator.bezier(jarc, smax, smax, tmin, tmax);
+ initialbin.addarc(jarc);
+ pjarc = jarc.append(pjarc);
+
+ jarc = new Arc(Arc.ARC_TOP);
+ arctesselator.bezier(jarc, smax, smin, tmax, tmax);
+ initialbin.addarc(jarc);
+ pjarc = jarc.append(pjarc);
+
+ jarc = new Arc(Arc.ARC_LEFT);
+ arctesselator.bezier(jarc, smin, smin, tmax, tmin);
+ initialbin.addarc(jarc);
+ jarc = jarc.append(pjarc);
+
+ // assert (jarc.check() == true);
+ }
+
+ /**
+ * Draws NURBS curve
+ */
+ public void drawCurves() {
+ // DONE
+ float[] from = new float[1];
+ float[] to = new float[1];
+
+ Flist bpts = new Flist();
+ qlist.getRange(from, to, bpts);
+
+ renderhints.init();
+
+ backend.bgncurv();
+
+ for (int i = bpts.start; i < bpts.end - 1; i++) {
+ float[] pta = new float[1];
+ float[] ptb = new float[1];
+ pta[0] = bpts.pts[i];
+ ptb[0] = bpts.pts[i + 1];
+
+ qlist.downloadAll(pta, ptb, backend);
+ Curvelist curvelist = new Curvelist(qlist, pta, ptb);
+ samplingSplit(curvelist, renderhints.maxsubdivisions);
+ }
+ backend.endcurv();
+ }
+
+ /**
+ * Samples a curve in case of need, or sends curve to backend
+ * @param curvelist list of curves
+ * @param maxsubdivisions maximum number of subdivisions
+ */
+ private void samplingSplit(Curvelist curvelist, int maxsubdivisions) {
+ if (curvelist.cullCheck() == CULL_TRIVIAL_REJECT)
+ return;
+
+ curvelist.getstepsize();
+
+ if (curvelist.needsSamplingSubdivision() && (subdivisions > 0)) {
+ // TODO kód
+ // System.out.println("TODO subdivider-needsSamplingSubdivision");
+ } else {
+ int nu = (int) (1 + curvelist.range[2] / curvelist.stepsize);
+ backend.curvgrid(curvelist.range[0], curvelist.range[1], nu);
+ backend.curvmesh(0, nu);
+ }
+
+ }
+
+ /**
+ * Sets new domain_distance_u_rate value
+ * @param d new domain_distance_u_rate value
+
+ */
+ public void set_domain_distance_u_rate(double d) {
+ // DONE
+ domain_distance_u_rate = (float) d;
+ }
+
+ /**
+ * Sets new domain_distance_v_rate value
+ * @param d new domain_distance_v_rate value
+ */
+ public void set_domain_distance_v_rate(double d) {
+ // DONE
+ domain_distance_v_rate = (float) d;
+ }
+
+ /**
+ * Sets new is_domain_distance_sampling value
+ * @param i new is_domain_distance_sampling value
+ */
+ public void set_is_domain_distance_sampling(int i) {
+ // DONE
+ this.is_domain_distance_sampling = i;
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/TrimVertex.java b/src/classes/com/sun/opengl/impl/nurbs/TrimVertex.java
new file mode 100755
index 000000000..e57c5ffbf
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/nurbs/TrimVertex.java
@@ -0,0 +1,56 @@
+package com.sun.opengl.impl.nurbs;
+
+/*
+ ** 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.
+ */
+
+/**
+ * Holds vertex used in trim
+ *
+ * @author Tomas Hrasky
+ *
+ */
+class TrimVertex {
+
+ /**
+ * Trim vertex coords
+ */
+ public float[] param;
+
+ /**
+ * Makes new empty trim vertex
+ */
+ public TrimVertex() {
+ param = new float[2];
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/internals/Arc.java b/src/classes/com/sun/opengl/impl/nurbs/internals/Arc.java
deleted file mode 100644
index e5d77b74a..000000000
--- a/src/classes/com/sun/opengl/impl/nurbs/internals/Arc.java
+++ /dev/null
@@ -1,284 +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.
-**
-** NOTE: The Original Code (as defined below) has been licensed to Sun
-** Microsystems, Inc. ("Sun") under the SGI Free Software License B
-** (Version 1.1), shown above ("SGI License"). Pursuant to Section
-** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
-** you under an alternative license ("Alternative License"). This
-** Alternative License includes all of the provisions of the SGI License
-** except that Section 2.2 and 11 are omitted. Any differences between
-** the Alternative License and the SGI License are offered solely by Sun
-** and not by SGI.
-**
-** 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.
-*/
-
-/* an arc, in two list, the trim list and bin */
-public class Arc {
- public static final int SIDE_NONE = 0;
- public static final int SIDE_RIGHT = 1;
- public static final int SIDE_TOP = 2;
- public static final int SIDE_LEFT = 3;
- public static final int SIDE_BOTTOM = 4;
-
- public static final int bezier_tag = (1 << 13);
- public static final int arc_tag = (1 << 3);
- public static final int tail_tag = (1 << 6);
- public Arc prev; /* trim list pointer */
- public Arc next; /* trim list pointer */
- public Arc link; /* bin pointers */
- public BezierArc bezierArc; /* associated bezier arc */
- public PwlArc pwlArc; /* associated pwl arc */
- public long type; /* curve type */
- public long nuid;
-
- private static final float ZERO = 0.00001f;
-
- public Arc(Arc j, PwlArc p) {
- pwlArc = p;
- type = j.type;
- nuid = j.nuid;
- }
-
- public Arc(int arcSide, long nuid) {
- type = 0;
- setside(arcSide);
- this.nuid = nuid;
- }
-
- public Arc append(Arc jarc) {
- if ( jarc != null ) {
- next = jarc.next;
- prev = jarc;
- next.prev = prev.next = this;
- } else {
- next = prev = this;
- }
- return this;
- }
-
- public boolean check() {
- Arc jarc = this;
- do {
- assert( (jarc.pwlArc != null) || (jarc.bezierArc != null) );
-
- if (jarc.prev == 0 || jarc.next == 0) {
- System.out.println( "checkjarc:null next/prev pointer");
- jarc.print( );
- return false;
- }
-
- if (jarc.next.prev != jarc) {
- System.out.println( "checkjarc: pointer linkage screwed up");
- jarc.print( );
- return false;
- }
-
- if( jarc.pwlArc != null ) {
- assert( jarc.pwlArc.npts >= 1 );
- assert( jarc.pwlArc.npts < 100000 );
- if( jarc.prev.pwlArc != null ) {
- if( jarc.tail()[1] != jarc.prev.rhead()[1] ) {
- System.out.println( "checkjarc: geometric linkage screwed up 1");
- jarc.prev.show();
- jarc.show();
- return false;
- }
- if( jarc.tail()[0] != jarc.prev.rhead()[0] ) {
- System.out.println( "checkjarc: geometric linkage screwed up 2");
- jarc.prev.show();
- jarc.show();
- return false;
- }
- }
- if( jarc.next.pwlArc ) {
- if( jarc.next.tail()[0] != jarc.rhead()[0] ) {
- System.out.println( "checkjarc: geometric linkage screwed up 3");
- jarc.show();
- jarc.next.show();
- return false;
- }
- if( jarc.next.tail()[1] != jarc.rhead()[1] ) {
- System.out.println( "checkjarc: geometric linkage screwed up 4");
- jarc.show();
- jarc.next.show();
- return false;
- }
- }
- 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 true;
- }
-
- /**
- * Checks if tail of arc and head of prev meet.
- */
- public boolean isDisconnected() {
- if( pwlArc == 0 ) return 0;
- if( prev.pwlArc == 0 ) return 0;
-
- float[] p0 = tail();
- float[] p1 = prev.rhead();
-
- if( ((p0[0] - p1[0]) > ZERO) || ((p1[0] - p0[0]) > ZERO) ||
- ((p0[1] - p1[1]) > ZERO) || ((p1[1] - p0[1]) > ZERO) ) {
- return true;
- } else {
- /* average two points together */
- p0[0] = p1[0] = (p1[0] + p0[0]) * 0.5f;
- p0[1] = p1[1] = (p1[1] + p0[1]) * 0.5f;
- return false;
- }
- }
-
- /**
- * Counts number of points on arc loop.
- */
- public int numpts( ) {
- Arc jarc = this;
- int npts = 0;
- do {
- npts += jarc.pwlArc.npts;
- jarc = jarc.next;
- } while( jarc != this );
- return npts;
- }
-
- /**
- * Marks each point with id of arc.
- */
- public void markverts( void ) {
- Arc 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 );
- }
-
- /**
- * Finds axis extrema on arc loop.
- */
- public void getextrema( Arc[4] ) {
- float 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 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;
- }
- }
- }
-
- /**
- * Prints out the vertices of all pwl arcs on a loop.
- */
- public void print( ) {
- Arc jarc = this;
-
- do {
- jarc.show( );
- jarc = jarc.next;
- } while (jarc != this);
- }
-
- public void show( ) {
- System.out.println( "\tPWLARC NP: " + pwlArc.npts + " FL: 1");
- for( int i = 0; i < pwlArc.npts; i++ ) {
- System.out.println( "\t\tVERTEX " + pwlArc.pts[i].param[0] + " " +
- pwlArc.pts[i].param[1] );
- }
- }
-
- /**
- * Attaches a pwl arc to an arc and mark it as a border arc.
- */
- public void makeSide( PwlArc pwl, int arcSide ) {
- assert( pwl != 0);
- assert( pwlArc == 0 );
- assert( pwl.npts > 0 );
- assert( pwl.pts != 0);
- pwlArc = pwl;
- clearbezier();
- setside( arcSide );
- }
-
- public boolean isTessellated() { return (pwlArc != null); }
- public boolean isbezier() { return (type & bezier_tag) != 0; }
- public void setbezier() { type |= bezier_tag; }
- public void clearbezier() { type &= ~bezier_tag; }
- public long npts() { return pwlArc.npts; }
- public TrimVertex[] pts() { return pwlArc.pts; }
- public float[] tail() { return pwlArc.pts[0].param; }
- public float[] head() { return next.pwlArc.pts[0].param; }
- public float[] rhead() { return pwlArc.pts[pwlArc.npts-1].param; }
- public long ismarked() { return type & arc_tag; }
- public void setmark() { type |= arc_tag; }
- public void clearmark() { type &= (~arc_tag); }
- public void clearside() { type &= ~(0x7 << 8); }
- public void setside( int arcSide ) { clearside(); type |= (((long)arcSide)<<8); }
- public int getside() { return ((type>>8) & 0x7); }
- public int getitail() { return type & tail_tag; }
- public void setitail() { type |= tail_tag; }
- public void clearitail() { type &= (~tail_tag); }
-}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/internals/ArcTesselator.java b/src/classes/com/sun/opengl/impl/nurbs/internals/ArcTesselator.java
deleted file mode 100644
index e8757b7cb..000000000
--- a/src/classes/com/sun/opengl/impl/nurbs/internals/ArcTesselator.java
+++ /dev/null
@@ -1,459 +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.
-**
-** NOTE: The Original Code (as defined below) has been licensed to Sun
-** Microsystems, Inc. ("Sun") under the SGI Free Software License B
-** (Version 1.1), shown above ("SGI License"). Pursuant to Section
-** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
-** you under an alternative license ("Alternative License"). This
-** Alternative License includes all of the provisions of the SGI License
-** except that Section 2.2 and 11 are omitted. Any differences between
-** the Alternative License and the SGI License are offered solely by Sun
-** and not by SGI.
-**
-** 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.
-*/
-
-public class ArcTessellator {
- /**
- * Constructs a bezier arc and attaches it to an Arc.
- */
- public void bezier( Arc arc, float s1, float s2, float t1, float t2 ) {
- assert( arc != null );
- assert( ! arc.isTessellated() );
-
- switch( arc.getside() ) {
- case Arc.SIDE_LEFT:
- assert( s1 == s2 );
- assert( t2 < t1 );
- break;
- case Arc.SIDE_RIGHT:
- assert( s1 == s2 );
- assert( t1 < t2 );
- break;
- case Arc.SIDE_TOP:
- assert( t1 == t2 );
- assert( s2 < s1 );
- break;
- case Arc.SIDE_BOTTOM:
- assert( t1 == t2 );
- assert( s1 < s2 );
- break;
- case Arc.SIDE_NONE:
- throw new InternalError();
- break;
- }
-
- TrimVertex[] p = TrimVertex.allocate(2);
- arc.pwlArc = new PwlArc( 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();
- }
-
- /**
- * Constructs a pwl arc and attaches it to an arc.
- */
- public void pwl( Arc arc, float s1, float s2, float t1, float t2, float rate ) {
- int snsteps = 1 + (int) (Math.abs(s2 - s1) / rate );
- int tnsteps = 1 + (int) (Math.abs(t2 - t1) / rate );
- int nsteps = (int) Math.max(1, Math.max( snsteps, tnsteps ));
-
- float sstepsize = (s2 - s1) / (float) nsteps;
- float tstepsize = (t2 - t1) / (float) nsteps;
- TrimVertex[] newvert = TrimVertex.allocate( 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.pwlArc = new PwlArc( newvert );
-
- arc.clearbezier();
- arc.clearside( );
- }
-
- /**
- * Constructs a left boundary pwl arc and attaches it to an arc.
- */
- public void pwl_left( Arc arc, float s, float t1, float t2, float rate ) {
- assert( t2 < t1 );
-
- int nsteps = steps_function(t1, t2, rate);
-
- float stepsize = (t1 - t2) / (float) nsteps;
-
- TrimVertex[] newvert = TrimVertex.allocate( 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 PwlArc( newvert ), Arc.SIDE_LEFT );
- }
-
- /**
- * Constructs a right boundary pwl arc and attaches it to an arc.
- */
- public void pwl_right( Arc arc, float s, float t1, float t2, float rate ) {
- assert( t1 < t2 );
-
- int nsteps = steps_function(t2,t1,rate);
- float stepsize = (t2 - t1) / (float) nsteps;
-
- TrimVertex[] newvert = TrimVertex.allocate( 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 PwlArc( newvert ), Arc.SIDE_RIGHT );
- }
-
- /**
- * Constructs a top boundary pwl arc and attaches it to an arc.
- */
- public void pwl_top( Arc arc, float t, float s1, float s2, float rate ) {
- assert( s2 < s1 );
-
- int nsteps = steps_function(s1,s2,rate);
- float stepsize = (s1 - s2) / (float) nsteps;
-
- TrimVertex[] newvert = TrimVertex.allocate( 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 PwlArc( newvert ), Arc.SIDE_TOP );
- }
-
- /**
- * Constructs a bottom boundary pwl arc and attaches it to an arc.
- */
- public void pwl_bottom( Arc arc, float t, float s1, float s2, float rate ) {
- assert( s1 < s2 );
-
- int nsteps = steps_function(s2,s1,rate);
- float stepsize = (s2 - s1) / (float) nsteps;
-
- TrimVertex[] newvert = TrimVertex.allocate( 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 PwlArc( newvert ), Arc.SIDE_BOTTOM );
- }
-
- /**
- * Constucts a linear pwl arc and attaches it to an Arc.
- */
- public void tessellateLinear( Arc arc, float geo_stepsize, float arc_stepsize, boolean isrational ) {
- assert( arc.pwlArc == null );
- float 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
- float 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 );
- }
-
- /**
- * Constucts a nonlinear pwl arc and attaches it to an Arc.
- */
- public void tessellateNonlinear( Arc arc, float geo_stepsize, float arc_stepsize, int isrational ) {
- assert( arc.pwlArc == null );
-
- float stepsize = geo_stepsize * arc_stepsize;
-
- BezierArc *bezierArc = arc.bezierArc;
-
- float size; //bounding box size of the curve in UV
- {
- int i,j;
- float 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=2; 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 = TrimVertex.allocate( nsteps+1 );
- float dp = 1.0/nsteps;
- int vi = 0; // vertIdx
-
- arc.pwlArc = new PwlArc();
- arc.pwlArc.pts = vert;
-
- if( isrational ) {
- float[] pow_u = new float[Defines.MAXORDER];
- float[] pow_v = new float[Defines.MAXORDER];
- float[] pow_w = new float[Defines.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 */
- float[] b = bezierArc.cpts;
- vert[vi].param[0] = b[0]/b[2];
- vert[vi].param[1] = b[1]/b[2];
-
- /* strength reduction on p = dp * step would introduce error */
- long order = bezierArc.order;
- for( int step=1, ++vi; step<nsteps; step++, vi++ ) {
- float p = dp * step;
- float u = pow_u[0];
- float v = pow_v[0];
- float w = pow_w[0];
- for( 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[vi].param[0] = u/w;
- vert[vi].param[1] = v/w;
- }
-
- /* compute last point exactly */
- b += (order - 1) * bezierArc.stride;
- vert[vi].param[0] = b[0]/b[2];
- vert[vi].param[1] = b[1]/b[2];
-
- } else {
- float[] pow_u = new float[Defines.MAXORDER];
- float[] pow_v = new float[Defines.MAXORDER];
- trim_power_coeffs( bezierArc, pow_u, 0 );
- trim_power_coeffs( bezierArc, pow_v, 1 );
-
- /* compute first point exactly */
- float[] b = bezierArc.cpts;
- vert[vi].param[0] = b[0];
- vert[vi].param[1] = b[1];
-
- /* strength reduction on p = dp * step would introduce error */
- long order = bezierArc.order;
- for( int step=1, ++vi; step<nsteps; step++, vi++ ) {
- float p = dp * step;
- float u = pow_u[0];
- float v = pow_v[0];
- for( int i = 1; i < bezierArc.order; i++ ) {
- u = u * p + pow_u[i];
- v = v * p + pow_v[i];
- }
- vert[vi].param[0] = u;
- vert[vi].param[1] = v;
- }
-
- /* compute last point exactly */
- b += (order - 1) * bezierArc.stride;
- vert[vi].param[0] = b[0];
- vert[vi].param[1] = b[1];
- }
- arc.pwlArc.npts = vi + 1;
- }
-
- private static final float gl_Bernstein[][Defines.MAXORDER][Defines.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 }
- }
- };
-
- /**
- * Computes power basis coefficients from bezier coeffients.
- */
- private static void trim_power_coeffs( BezierArc bez_arc, float[] p, int coord ) {
- int stride = bez_arc.stride;
- int order = bez_arc.order;
- float[] base = bez_arc.cpts;
- int baseIdx = coord;
-
- float[][] mat = gl_Bernstein[order-1];
-
- for (int i = 0; i < order; i++) {
- float[] row = mat[i];
- float s = 0.0f;
- int pointIdx = baseIdx;
- for (int j = 0; j < order; j++, pointIdx += stride) {
- s += row[j] * base[pointIdx];
- }
- p[i] = s;
- }
- }
-}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/internals/Backend.java b/src/classes/com/sun/opengl/impl/nurbs/internals/Backend.java
deleted file mode 100644
index ec0856322..000000000
--- a/src/classes/com/sun/opengl/impl/nurbs/internals/Backend.java
+++ /dev/null
@@ -1,387 +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.
-**
-** NOTE: The Original Code (as defined below) has been licensed to Sun
-** Microsystems, Inc. ("Sun") under the SGI Free Software License B
-** (Version 1.1), shown above ("SGI License"). Pursuant to Section
-** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
-** you under an alternative license ("Alternative License"). This
-** Alternative License includes all of the provisions of the SGI License
-** except that Section 2.2 and 11 are omitted. Any differences between
-** the Alternative License and the SGI License are offered solely by Sun
-** and not by SGI.
-**
-** 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.
-*/
-
-public class Backend {
- private BasicCurveEvaluator curveEvaluator;
- private BasicSurfaceEvaluator surfaceEvaluator;
-
- public Backend( BasicCurveEvaluator c, BasicSurfaceEvaluator e ) {
- this.c = c;
- this.e = e;
- }
-
- /* surface backend routines */
-
- /**
- * bgnsurf - preamble to surface definition and evaluations
- */
- public void bgnsurf( boolean wiretris, boolean wirequads, long nuid ) {
- wireframetris = wiretris;
- wireframequads = wirequads;
-
- /*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);
- }
-
- public void patch( float ulo, float uhi, float vlo, float vhi ) {
- surfaceEvaluator.domain2f( ulo, uhi, vlo, vhi );
- }
-
- /**
- * surfpts - pass a desription of a surface map
- */
- public void surfpts(long type, /* geometry, color, texture, normal */
- float[] 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 */
- float ulo, /* u lower bound */
- float uhi, /* u upper bound */
- float vlo, /* v lower bound */
- float vhi /* v upper bound */ ) {
- surfaceEvaluator.map2f( type,ulo,uhi,ustride,uorder,vlo,vhi,vstride,vorder,pts );
- surfaceEvaluator.enable( type );
- }
- public void surfbbox( long type, float[] from, float[] to ) {
- surfaceEvaluator.range2f( type, from, to );
- }
- /**
- * surfgrid - define a lattice of points with origin and offset
- */
- public void surfgrid( float u0, float u1, long nu, float v0, float v1, long nv ) {
- surfaceEvaluator.mapgrid2f( nu, u0, u1, nv, v0, v1 );
- }
- /**
- * surfmesh - evaluate a mesh of points on lattice
- */
- public void surfmesh( long u, long v, long n, long m ) {
- 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 );
- }
- }
- /**
- * bgntmesh - preamble to a triangle mesh
- */
- public void bgntmesh() {
- meshindex = 0; /* I think these need to be initialized to zero */
- npts = 0;
-
- if( !wireframetris ) {
- surfaceEvaluator.bgntmesh();
- }
- }
- /**
- * endtmesh - postamble to triangle mesh
- */
- public void endtmesh( ) {
- if( ! wireframetris )
- surfaceEvaluator.endtmesh();
- }
- /**
- * swaptmesh - perform a swap of the triangle mesh pointers
- */
- public void swaptmesh( ) {
- if( wireframetris ) {
- meshindex = 1 - meshindex;
- } else {
- surfaceEvaluator.swaptmesh();
- }
- }
- public void tmeshvert( GridTrimVertex v ) {
- if( v.isGridVert() ) {
- tmeshvert( v.g );
- } else {
- tmeshvert( v.t );
- }
- }
- /**
- * tmeshvert - evaluate a point on a triangle mesh
- */
- public void tmeshvert( TrimVertex t ) {
- long nuid = t.nuid;
- float u = t.param[0];
- float v = t.param[1];
-
- 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 );
- }
- }
- /**
- * tmeshvert - evaluate a grid point of a triangle mesh
- */
- public void tmeshvert( GridVertex g ) {
- long u = g->gparam[0];
- long v = g->gparam[1];
-
- 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 );
- }
- }
- /** the same as tmeshvert(trimvertex), for efficiency purpose */
- public void tmeshvert( float u, float v ) {
- 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 );
- }
- }
- /**
- * linevert - evaluate a point on an outlined contour
- */
- public void linevert( TrimVertex t ) {
- surfaceEvaluator.evalcoord2f( t.nuid, t.param[0], t.param[1] );
- }
- /**
- * linevert - evaluate a grid point of an outlined contour
- */
- public void linevert( GridVertex g ) {
- surfaceEvaluator.evalpoint2i( g.gparam[0], g.gparam[1] );
- }
- /**
- * bgnoutline - preamble to outlined rendering
- */
- public void bgnoutline( ) {
- surfaceEvaluator.bgnline();
- }
- /**
- * endoutline - postamble to outlined rendering
- */
- public void endoutline( ) {
- surfaceEvaluator.endline();
- }
- /**
- * endsurf - postamble to surface
- */
- public void endsurf( ) {
- surfaceEvaluator.endmap2f();
- }
- /**
- * triangle - output a triangle
- */
- public void triangle( TrimVertex a, TrimVertex b, TrimVertex c ) {
- bgntfan();
- tmeshvert( a );
- tmeshvert( b );
- tmeshvert( c );
- endtfan();
- }
-
- public void bgntfan() {
- surfaceEvaluator.bgntfan();
- }
- public void endtfan() {
- surfaceEvaluator.endtfan();
- }
- public void bgnqstrip() {
- surfaceEvaluator.bgnqstrip();
- }
- public void endqstrip() {
- surfaceEvaluator.endqstrip();
- }
- public void evalUStrip(int n_upper, float v_upper, float[] upper_val,
- int n_lower, float v_lower, float[] lower_val) {
- surfaceEvaluator.evalUStrip(n_upper, v_upper, upper_val,
- n_lower, v_lower, lower_val);
- }
- public void evalVStrip(int n_left, float u_left, float[] left_val,
- int n_right, float v_right, float[] right_val) {
- surfaceEvaluator.evalVStrip(n_left, u_left, left_val,
- n_right, u_right, right_val);
- }
- public void tmeshvertNOGE(TrimVertex *t) {
- // NOTE: under undefined USE_OPTTT #ifdef
- }
- public void tmeshvertNOGE_BU(TrimVertex *t) {
- // NOTE: under undefined USE_OPTTT #ifdef
- }
- public void tmeshvertNOGE_BV(TrimVertex *t) {
- // NOTE: under undefined USE_OPTTT #ifdef
- }
- public void preEvaluateBU(float u) {
- surfaceEvaluator.inPreEvaluateBU_intfac(u);
- }
- public void preEvaluateBV(float v) {
- surfaceEvaluator.inPreEvaluateBV_intfac(v);
- }
-
- /* curve backend routines */
- public void bgncurv( void ) {
- curveEvaluator.bgnmap1f( 0 );
- }
- public void segment( float ulo, float uhi ) {
- curveEvaluator.domain1f( ulo, uhi );
- }
- public void curvpts(long type, /* geometry, color, texture, normal */
- float[] pts, /* control points */
- long stride, /* distance to next point */
- int order, /* parametric order */
- float ulo, /* lower parametric bound */
- float uhi ) /* upper parametric bound */ {
- curveEvaluator.map1f( type, ulo, uhi, stride, order, pts );
- curveEvaluator.enable( type );
- }
- public void curvgrid( float u0, float u1, long nu ) {
- curveEvaluator.mapgrid1f( nu, u0, u1 );
- }
- public void curvmesh( long from, long n ) {
- curveEvaluator.mapmesh1f( N_MESHFILL, from, from+n );
- }
- public void curvpt( float u ) {
- curveEvaluator.evalcoord1f( 0, u );
- }
- public void bgnline( ) {
- curveEvaluator.bgnline();
- }
- public void endline( ) {
- curveEvaluator.endline();
- }
- public void endcurv( ) {
- curveEvaluator.endmap1f();
- }
-
- private boolean wireframetris;
- private boolean wireframequads;
- private int npts;
- private float[][] mesh = new float[3][4];
- private int meshindex;
-}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/internals/BasicCurveEvaluator.java b/src/classes/com/sun/opengl/impl/nurbs/internals/BasicCurveEvaluator.java
deleted file mode 100644
index 24f2a682a..000000000
--- a/src/classes/com/sun/opengl/impl/nurbs/internals/BasicCurveEvaluator.java
+++ /dev/null
@@ -1,60 +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.
-**
-** NOTE: The Original Code (as defined below) has been licensed to Sun
-** Microsystems, Inc. ("Sun") under the SGI Free Software License B
-** (Version 1.1), shown above ("SGI License"). Pursuant to Section
-** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
-** you under an alternative license ("Alternative License"). This
-** Alternative License includes all of the provisions of the SGI License
-** except that Section 2.2 and 11 are omitted. Any differences between
-** the Alternative License and the SGI License are offered solely by Sun
-** and not by SGI.
-**
-** 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.
-*/
-
-public class BasicCurveEvaluator extends CachingEvaluator {
- public void domain1f(float ulo, float uhi) {}
- public void range1f(long type, float[] from, float[] to) {}
-
- public void enable(long type) {}
- public void disable(long type) {}
- public void bgnmap1f(long type) {}
- public void map1f(long type, float ulo, float uhi, long stride, long order, float[] pts) {}
- public void mapgrid1f(long nu, float u0, float u1) {}
- public void mapmesh1f(long style, long from, long to) {}
- public void evalcoord1f(long type, float u) {}
- public void endmap1f() {}
-
- public void bgnline() {}
- public void endline() {}
-}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/internals/BasicSurfaceEvaluator.java b/src/classes/com/sun/opengl/impl/nurbs/internals/BasicSurfaceEvaluator.java
deleted file mode 100644
index 191874d32..000000000
--- a/src/classes/com/sun/opengl/impl/nurbs/internals/BasicSurfaceEvaluator.java
+++ /dev/null
@@ -1,86 +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.
-**
-** NOTE: The Original Code (as defined below) has been licensed to Sun
-** Microsystems, Inc. ("Sun") under the SGI Free Software License B
-** (Version 1.1), shown above ("SGI License"). Pursuant to Section
-** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
-** you under an alternative license ("Alternative License"). This
-** Alternative License includes all of the provisions of the SGI License
-** except that Section 2.2 and 11 are omitted. Any differences between
-** the Alternative License and the SGI License are offered solely by Sun
-** and not by SGI.
-**
-** 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.
-*/
-
-public abstract class BasicSurfaceEvaluator extends CachingEvaluator {
- public void range2f(long, float[] from, float[] to) {}
- public void domain2f(float ulo, float uhi, float vlo, float vhi) {}
-
- public void enable(long type) {}
- public void disable(long type) {}
- public void bgnmap2f(long type) {}
- public void map2f(long type, float ulower, float uupper, long ustride, long uorder,
- float vlower, float vupper, long vstride, long vorder,
- float[] pts) {}
- public void mapgrid2f(long nu, float u0, float u1,
- long nv, float v0, float v1) {}
- public void mapmesh2f(long style, long umin, long umax,
- long vmin, long vmax) {}
- public void evalcoord2f(long type, float u, float v) {}
- public void evalpoint2i(long u, long v) {}
- public void endmap2f() {}
-
- public void polymode(long style) {}
- public void bgnline() {}
- public void endline() {}
- public void bgnclosedline() {}
- public void endclosedline() {}
- public void bgntmesh() {}
- public void swaptmesh() {}
- public void endtmesh() {}
- public void bgnqstrip() {}
- public void endqstrip() {}
-
- public void bgntfan() {}
- public void endtfan() {}
-
- public abstract void evalUStrip(int n_upper, float v_upper, float[] upper_val,
- int n_lower, float v_lower, float[] lower_val);
- public abstract void evalVStrip(int n_left, float u_left, float[] left_val,
- int n_right, float u_right, float[] right_val);
- public abstract void inDoEvalCoord2NOGE(float u, float v, float[] ret_point, float[] ret_normal);
- public abstract void inDoEvalCoord2NOGE_BU(float u, float v, float[] ret_point, float[] ret_normal);
- public abstract void inDoEvalCoord2NOGE_BV(float u, float v, float[] ret_point, float[] ret_normal);
- public abstract void inPreEvaluateBV_intfac(float v);
- public abstract void inPreEvaluateBU_intfac(float u);
-}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/internals/BezierArc.java b/src/classes/com/sun/opengl/impl/nurbs/internals/BezierArc.java
deleted file mode 100644
index 30607c0f2..000000000
--- a/src/classes/com/sun/opengl/impl/nurbs/internals/BezierArc.java
+++ /dev/null
@@ -1,52 +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.
-**
-** NOTE: The Original Code (as defined below) has been licensed to Sun
-** Microsystems, Inc. ("Sun") under the SGI Free Software License B
-** (Version 1.1), shown above ("SGI License"). Pursuant to Section
-** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
-** you under an alternative license ("Alternative License"). This
-** Alternative License includes all of the provisions of the SGI License
-** except that Section 2.2 and 11 are omitted. Any differences between
-** the Alternative License and the SGI License are offered solely by Sun
-** and not by SGI.
-**
-** 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.
-*/
-
-/** A bezier arc. */
-class BezierArc {
- public float[] cpts; /* control points of arc */
- public int order; /* order of arc */
- public int stride; /* REAL distance between points */
- public long type; /* curve type */
- public Mapdesc mapdesc;
-}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/internals/Bin.java b/src/classes/com/sun/opengl/impl/nurbs/internals/Bin.java
deleted file mode 100644
index 42306c1ff..000000000
--- a/src/classes/com/sun/opengl/impl/nurbs/internals/Bin.java
+++ /dev/null
@@ -1,157 +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.
-**
-** NOTE: The Original Code (as defined below) has been licensed to Sun
-** Microsystems, Inc. ("Sun") under the SGI Free Software License B
-** (Version 1.1), shown above ("SGI License"). Pursuant to Section
-** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
-** you under an alternative license ("Alternative License"). This
-** Alternative License includes all of the provisions of the SGI License
-** except that Section 2.2 and 11 are omitted. Any differences between
-** the Alternative License and the SGI License are offered solely by Sun
-** and not by SGI.
-**
-** 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.
-*/
-
-public class Bin {
- private Arc head; /*first arc on list */
- private Arc current; /* current arc on list */
-
- /**
- * Sets current arc to first arc of bin; advances to next arc.
- */
- public Arc firstarc( ) {
- current = head;
- return nextarc( );
- }
- /**
- * Returns current arc in bin and advances pointer to next arc.
- */
- public Arc nextarc( ) {
- Arc jarc = current;
-
- assert( (jarc == null) || jarc.check() );
-
- if( jarc != null ) current = jarc.link;
- return jarc;
- }
- /**
- * Removes first Arc from bin.
- */
- public Arc removearc( ) {
- Arc jarc = head;
-
- if( jarc != null ) head = jarc.link;
- return jarc;
- }
- public boolean isnonempty( ) { return (head != null); }
- /**
- * Adds an Arc to head of the linked list of Arcs.
- */
- public void addarc( Arc jarc ) {
- jarc.link = head;
- head = jarc;
- }
- /**
- * Removes given Arc from bin.
- */
- public void remove_this_arc( Arc arc ) {
- Arc j, prev;
- for( j = head; (j != null) && (j != arc); prev = j, j = j.link );
-
- if( j != null ) {
- if( j == current )
- current = j.link;
- if ( prev != null )
- prev.link = j.link;
- }
- }
- /**
- * Counts number of arcs in bin.
- */
- public int numarcs( ) {
- long count = 0;
- for( Arc jarc = firstarc(); jarc != null; jarc = nextarc() )
- count++;
- return count;
- }
- /**
- * Places an orphaned arc into its new parent's bin.
- */
- public void adopt( ) {
- markall();
-
- Arc orphan;
- while( (orphan = removearc()) != null ) {
- for( Arc parent = orphan.next; parent != orphan; parent = parent.next ) {
- if (! parent.ismarked() ) {
- orphan.link = parent.link;
- parent.link = orphan;
- orphan.clearmark();
- break;
- }
- }
- }
- }
- /**
- * Marks all arcs with an identifying tag.
- */
- public void markall( ) {
- for( Arc jarc = firstarc(); jarc != null; jarc = nextarc() )
- jarc.setmark();
- }
- /**
- * Prints out descriptions of the arcs in the bin.
- */
- public void show( String name ) {
- System.out.println( name );
- for( Arc jarc = firstarc(); jarc != null; jarc = nextarc() )
- jarc.show( );
- }
- /**
- * Prints out all arcs that are untessellated border arcs.
- */
- public void listBezier( ) {
- for( Arc jarc = firstarc(); jarc != null; jarc = nextarc() ) {
- if( jarc.isbezier( ) ) {
- assert( jarc.pwlArc.npts == 2 );
- TrimVertex[] pts = jarc.pwlArc.pts;
- float s1 = pts[0].param[0];
- float t1 = pts[0].param[1];
- float s2 = pts[1].param[0];
- float t2 = pts[1].param[1];
- System.out.println( "arc ( " + s1 + "," + t1 + ") (" +
- s2 + "," + t2 + ")");
- }
- }
- }
-}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/internals/CachingEvaluator.java b/src/classes/com/sun/opengl/impl/nurbs/internals/CachingEvaluator.java
deleted file mode 100644
index 98baec3bf..000000000
--- a/src/classes/com/sun/opengl/impl/nurbs/internals/CachingEvaluator.java
+++ /dev/null
@@ -1,66 +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.
-**
-** NOTE: The Original Code (as defined below) has been licensed to Sun
-** Microsystems, Inc. ("Sun") under the SGI Free Software License B
-** (Version 1.1), shown above ("SGI License"). Pursuant to Section
-** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
-** you under an alternative license ("Alternative License"). This
-** Alternative License includes all of the provisions of the SGI License
-** except that Section 2.2 and 11 are omitted. Any differences between
-** the Alternative License and the SGI License are offered solely by Sun
-** and not by SGI.
-**
-** 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.
-*/
-
-public class CachingEvaluator {
- public int ServiceModePlay = 0;
- public int ServiceModeRecord = 1;
- public int ServiceModePlayAndRecord = 2;
-
- public int canRecord() {
- return 0;
- }
-
- public int canPlayAndRecord() {
- return 0;
- }
-
- public int createHandle( int handle ) {
- return 0;
- }
-
- public void beginOutput( int serviceMode, int handle ) {}
- public void endOutput() {}
- public void discardRecording(int handle) {}
- public void playRecording(int handle) {}
-}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/internals/Defines.java b/src/classes/com/sun/opengl/impl/nurbs/internals/Defines.java
deleted file mode 100644
index 4b4f0ff7f..000000000
--- a/src/classes/com/sun/opengl/impl/nurbs/internals/Defines.java
+++ /dev/null
@@ -1,56 +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.
-**
-** NOTE: The Original Code (as defined below) has been licensed to Sun
-** Microsystems, Inc. ("Sun") under the SGI Free Software License B
-** (Version 1.1), shown above ("SGI License"). Pursuant to Section
-** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
-** you under an alternative license ("Alternative License"). This
-** Alternative License includes all of the provisions of the SGI License
-** except that Section 2.2 and 11 are omitted. Any differences between
-** the Alternative License and the SGI License are offered solely by Sun
-** and not by SGI.
-**
-** 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.
-*/
-
-public class Defines {
- /* culling constants */
- public static final int CULL_TRIVIAL_REJECT = 0;
- public static final int CULL_TRIVIAL_ACCEPT = 1;
- public static final int CULL_ACCEPT = 2;
-
- /* maximum order of a B-Spline */
- public static final int MAXORDER = 24;
-
- /* maximum dimension of any B-spline range space */
- public static final int MAXCOORDS = 5;
-}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/internals/NurbsConsts.java b/src/classes/com/sun/opengl/impl/nurbs/internals/NurbsConsts.java
deleted file mode 100644
index 20b45efba..000000000
--- a/src/classes/com/sun/opengl/impl/nurbs/internals/NurbsConsts.java
+++ /dev/null
@@ -1,127 +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.
-**
-** NOTE: The Original Code (as defined below) has been licensed to Sun
-** Microsystems, Inc. ("Sun") under the SGI Free Software License B
-** (Version 1.1), shown above ("SGI License"). Pursuant to Section
-** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
-** you under an alternative license ("Alternative License"). This
-** Alternative License includes all of the provisions of the SGI License
-** except that Section 2.2 and 11 are omitted. Any differences between
-** the Alternative License and the SGI License are offered solely by Sun
-** and not by SGI.
-**
-** 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.
-*/
-
-public class NurbsConsts {
- /* NURBS Properties - one set per map,
- each takes a single INREAL arg */
- public static final int N_SAMPLING_TOLERANCE = 1;
- public static final int N_S_RATE = 6;
- public static final int N_T_RATE = 7;
- public static final int N_CLAMPFACTOR = 13;
- public static final float N_NOCLAMPING = 0.0f;
- public static final int N_MINSAVINGS = 14;
- public static final float N_NOSAVINGSSUBDIVISION = 0.0f;
-
- /* NURBS Properties - one set per map,
- each takes an enumerated value */
- public static final int N_CULLING = 2;
- public static final float N_NOCULLING = 0.0f;
- public static final float N_CULLINGON = 1.0f;
- public static final int N_SAMPLINGMETHOD 10;
- public static final float N_NOSAMPLING = 0.0f;
- public static final float N_FIXEDRATE = 3.0f;
- public static final float N_DOMAINDISTANCE = 2.0f;
- public static final float N_PARAMETRICDISTANCE = 5.0f;
- public static final float N_PATHLENGTH = 6.0f;
- public static final float N_SURFACEAREA = 7.0f;
- public static final float N_OBJECTSPACE_PARA = 8.0f;
- public static final float N_OBJECTSPACE_PATH = 9.0f;
- public static final int N_BBOX_SUBDIVIDING = 17;
- public static final float N_NOBBOXSUBDIVISION = 0.0f;
- public static final float N_BBOXTIGHT = 1.0f;
- public static final float N_BBOXROUND = 2.0f;
-
- /* NURBS Rendering Properties - one set per renderer
- each takes an enumerated value */
-public static final int N_DISPLAY 3
-public static final int N_FILL 1.0
-public static final int N_OUTLINE_POLY 2.0
-public static final int N_OUTLINE_TRI 3.0
-public static final int N_OUTLINE_QUAD 4.0
-public static final int N_OUTLINE_PATCH 5.0
-public static final int N_OUTLINE_PARAM 6.0
-public static final int N_OUTLINE_PARAM_S 7.0
-public static final int N_OUTLINE_PARAM_ST 8.0
-public static final int N_OUTLINE_SUBDIV 9.0
-public static final int N_OUTLINE_SUBDIV_S 10.0
-public static final int N_OUTLINE_SUBDIV_ST 11.0
-public static final int N_ISOLINE_S 12.0
-public static final int N_ERRORCHECKING 4
-public static final int N_NOMSG 0.0
-public static final int N_MSG 1.0
-
-/* GL 4.0 propeties not defined above */
-#ifndef N_PIXEL_TOLERANCE
-public static final int N_PIXEL_TOLERANCE N_SAMPLING_TOLERANCE
-public static final int N_ERROR_TOLERANCE 20
-public static final int N_SUBDIVISIONS 5
-public static final int N_TILES 8
-public static final int N_TMP1 9
-public static final int N_TMP2 N_SAMPLINGMETHOD
-public static final int N_TMP3 11
-public static final int N_TMP4 12
-public static final int N_TMP5 N_CLAMPFACTOR
-public static final int N_TMP6 N_MINSAVINGS
-public static final int N_S_STEPS N_S_RATE
-public static final int N_T_STEPS N_T_RATE
-#endif
-
-/* NURBS Rendering Properties - one set per map,
- each takes an INREAL matrix argument */
-public static final int N_CULLINGMATRIX 1
-public static final int N_SAMPLINGMATRIX 2
-public static final int N_BBOXMATRIX 3
-
-
-/* NURBS Rendering Properties - one set per map,
- each takes an INREAL vector argument */
-public static final int N_BBOXSIZE 4
-
-/* type argument for trimming curves */
-#ifndef N_P2D
-public static final int N_P2D 0x8
-public static final int N_P2DR 0xd
-#endif
-
-}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/internals/NurbsException.java b/src/classes/com/sun/opengl/impl/nurbs/internals/NurbsException.java
deleted file mode 100644
index 5453807cd..000000000
--- a/src/classes/com/sun/opengl/impl/nurbs/internals/NurbsException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/** Encapsulates functionality of the C GLU NURBS implementation's
- setjmp/longjmp wrappers. */
-
-public class NurbsException extends RuntimeException {
- private int errorCode;
-
- public NurbsException(int code) {
- super();
- errorCode = code;
- }
-
- public NurbsException(String message, int code) {
- super(message);
- errorCode = code;
- }
-
- public NurbsException(String message, Throwable cause, int code) {
- super(message, cause);
- errorCode = code;
- }
-
- public NurbsException(Throwable cause, int code) {
- super(cause);
- errorCode = code;
- }
-
- public int errorCode() {
- return errorCode;
- }
-}
diff --git a/src/classes/com/sun/opengl/impl/nurbs/internals/Subdivider.java b/src/classes/com/sun/opengl/impl/nurbs/internals/Subdivider.java
deleted file mode 100644
index 85b569e25..000000000
--- a/src/classes/com/sun/opengl/impl/nurbs/internals/Subdivider.java
+++ /dev/null
@@ -1,1791 +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.
-**
-** NOTE: The Original Code (as defined below) has been licensed to Sun
-** Microsystems, Inc. ("Sun") under the SGI Free Software License B
-** (Version 1.1), shown above ("SGI License"). Pursuant to Section
-** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
-** you under an alternative license ("Alternative License"). This
-** Alternative License includes all of the provisions of the SGI License
-** except that Section 2.2 and 11 are omitted. Any differences between
-** the Alternative License and the SGI License are offered solely by Sun
-** and not by SGI.
-**
-** 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.
-*/
-
-public class Subdivider {
-
- /**
- * Constructs a subdivider.
- */
- public Subdivider(RenderHints hints, Backend b) {
- renderhints = hints;
- arctessellator = new ArcTesselator();
- backend = b;
- slicer = new Slicer(b);
- }
-
- /**
- * Resets all state after possible error condition.
- */
- public void clear() {
- // FIXME: looks like nothing to do given that we have no object pools
- }
- public void beginTrims() {}
- public void beginLoop() {
- pjarc = 0;
- }
-
- /**
- * Adds a bezier arc to a trim loop and to a bin.
- */
- public void addArc(float[] cpts, Quilt quilt, long _nuid) {
- BezierArc bezierArc = new BezierArc();
- Arc jarc = new Arc(Arc.SIDE_NONE, _nuid);
- jarc.bezierArc = bezierArc;
- bezierArc.order = quilt.qspec.order;
- bezierArc.stride = quilt.qspec.stride;
- bezierArc.mapdesc = quilt.mapdesc;
- bezierArc.cpts = cpts;
- initialbin.addarc( jarc );
- pjarc = jarc.append( pjarc );
- }
-
- /**
- * Adds a pwl arc to a trim loop and to a bin.
- */
- public void addArc(int npts, TrimVertex[] pts, long _nuid) {
- Arc jarc = new Arc( Arc.SIDE_NONE, _nuid );
- jarc.pwlArc = new PwlArc( npts, pts );
- initialbin.addarc( jarc );
- pjarc = jarc.append( pjarc );
- }
- public void endLoop() {}
- public void endTrims() {}
-
- public void beginQuilts() {
- qlist = null;
- }
- public void addQuilt( Quilt quilt ) {
- quilt.next = qlist;
- qlist = quilt;
- }
- public void endQuilts() {}
-
- /**
- * Main curve rendering entry point
- */
- public void drawCurves() {
- float[] from = new float[1];
- float[] to = new float[1];
- Flist bpts = new Flist();
- qlist.getRange( from, to, bpts );
-
- renderhints.init( );
-
- backend.bgncurv();
- float[] pta = new float[0];
- float[] ptb = new float[1];
- for( int i=bpts.start; i<bpts.end-1; i++ ) {
- pta[0] = bpts.pts[i];
- ptb[0] = bpts.pts[i+1];
-
- qlist.downloadAll( pta, ptb, backend );
-
- Curvelist curvelist = new Curvelist( qlist, pta, ptb );
- samplingSplit( curvelist, renderhints.maxsubdivisions );
- }
- backend.endcurv();
- }
- public void drawSurfaces(long nuid) {
- renderhints.init( );
-
- if (qlist == null) {
- //initialbin could be nonempty due to some errors
- freejarcs(initialbin);
- return;
- }
-
- for( Quilt q = qlist; q != null; q = q.next ) {
- if( q.isCulled( ) == Defines.CULL_TRIVIAL_REJECT ) {
- freejarcs( initialbin );
- return;
- }
- }
-
-
- float[] from = new float[2];
- float[] to = new float[2];
- qlist.getRange( from, to, spbrkpts, tpbrkpts );
- //perform optimization only when the samplng method is
- //DOMAIN_DISTANCE and the display methdo is either
- //fill or outline_polygon.
- bool optimize = (is_domain_distance_sampling && (renderhints.display_method != N_OUTLINE_PATCH));
-
- if( ! initialbin.isnonempty() ) {
- if(! optimize )
- {
- makeBorderTrim( from, to );
- }
- } else {
- float[] rate = new float[2];
- qlist.findRates( spbrkpts, tpbrkpts, rate );
-
- if( decompose( initialbin, Math.min(rate[0], rate[1]) ) )
- throw new NurbsException( 31 );
- }
-
- backend.bgnsurf( renderhints.wiretris, renderhints.wirequads, nuid );
-
- if( (!initialbin.isnonempty()) && optimize )
- {
- int i,j;
- int num_u_steps;
- int num_v_steps;
- for(i=spbrkpts.start; i<spbrkpts.end-1; i++){
- for(j=tpbrkpts.start; j<tpbrkpts.end-1; j++){
- float[] pta = new float[2];
- float[] ptb = new float[2];
- pta[0] = spbrkpts.pts[i];
- ptb[0] = spbrkpts.pts[i+1];
- pta[1] = tpbrkpts.pts[j];
- ptb[1] = tpbrkpts.pts[j+1];
- qlist.downloadAll(pta, ptb, backend);
-
- num_u_steps = (int) (domain_distance_u_rate * (ptb[0]-pta[0]));
- num_v_steps = (int) (domain_distance_v_rate * (ptb[1]-pta[1]));
-
- if(num_u_steps <= 0) num_u_steps = 1;
- if(num_v_steps <= 0) num_v_steps = 1;
-
- backend.surfgrid(pta[0], ptb[0], num_u_steps,
- ptb[1], pta[1], num_v_steps);
- backend.surfmesh(0,0,num_u_steps,num_v_steps);
-
- continue;
- }
- }
- }
- else
- subdivideInS( initialbin );
-
- backend.endsurf();
- }
-
- public int ccwTurn_sl(Arc j1, Arc j2 ) {
- int v1i = j1.pwlArc.npts-1;
- int v1lasti = 0;
- int v2i = 0;
- int v2lasti = j2.pwlArc.npts-1;
- int v1nexti = v1i-1;
- int v2nexti = v2i+1;
- TrimVertex v1 = j1.pwlArc.pts[v1i];
- TrimVertex v1last = j1.pwlArc.pts[v1lasti];
- TrimVertex v2 = j2.pwlArc.pts[v2i];
- TrimVertex v2last = j2.pwlArc.pts[v2lasti];
- TrimVertex v1next = j1.pwlArc.pts[v1nexti];
- TrimVertex v2next = j2.pwlArc.pts[v2nexti];
- int sgn;
-
- assert( v1 != v1last );
- assert( v2 != v2last );
-
- // 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] )
- throw new NurbsException(28);
-
- if( v1.param[1] < v2.param[1] )
- return 1;
- else if( v1.param[1] > v2.param[1] )
- return 0;
-
- while( true ) {
- if( v1next.param[0] > v2next.param[0] ) {
- 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 {
- v1i = v1nexti--;
- v1 = j1.pwlArc.pts[v1i];
- v1next = j1.pwlArc.pts[v1nexti];
- if( v1 == v1last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- break;
- case 1:
- return 0;
- }
- } else if( v1next.param[0] < v2next.param[0] ) {
- 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 {
- v2i = v2nexti++;
- v2 = j2.pwlArc.pts[v2i];
- v2next = j2.pwlArc.pts[v2nexti];
- if( v2 == v2last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- break;
- case 1:
- return 1;
- }
- } else {
- if( v1next.param[1] < v2next.param[1] )
- return 1;
- else if( v1next.param[1] > v2next.param[1] )
- return 0;
- else {
- v2i = v2nexti++;
- v2 = j2.pwlArc.pts[v2i];
- v2next = j2.pwlArc.pts[v2nexti];
- if( v2 == v2last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- }
- }
- }
-
- public int ccwTurn_sr(Arc j1, Arc j2 ) {
- // dir = 1
- int v1i = j1.pwlArc.npts-1;
- int v1lasti = 0;
- int v2i = 0;
- int v2lasti = j2.pwlArc.npts-1;
- int v1nexti = v1i-1;
- int v2nexti = v2i+1;
- TrimVertex v1 = j1.pwlArc.pts[v1i];
- TrimVertex v1last = j1.pwlArc.pts[v1lasti];
- TrimVertex v2 = j2.pwlArc.pts[v2i];
- TrimVertex v2last = j2.pwlArc.pts[v2lasti];
- TrimVertex v1next = j1.pwlArc.pts[v1nexti];
- TrimVertex v2next = j2.pwlArc.pts[v2nexti];
- int sgn;
-
- assert( v1 != v1last );
- assert( v2 != v2last );
-
- // 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] )
- throw new NurbsException(28);
-
- if( v1.param[1] < v2.param[1] )
- return 0;
- else if( v1.param[1] > v2.param[1] )
- return 1;
-
- while( true ) {
- if( v1next.param[0] < v2next.param[0] ) {
- 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 {
- v1i = v1nexti--;
- v1 = j1.pwlArc.pts[v1i];
- v1next = j1.pwlArc.pts[v1nexti];
- if( v1 == v1last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- break;
- case 1:
- return 1;
- }
- } else if( v1next.param[0] > v2next.param[0] ) {
- 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 {
- v2i = v2nexti++;
- v2 = j2.pwlArc.pts[v2i];
- v2next = j2.pwlArc.pts[v2nexti];
- if( v2 == v2last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- break;
- case 1:
- return 0;
- }
- } else {
- if( v1next.param[1] < v2next.param[1] )
- return 0;
- else if( v1next.param[1] > v2next.param[1] )
- return 1;
- else {
- v2i = v2nexti++;
- v2 = j2.pwlArc.pts[v2i];
- v2next = j2.pwlArc.pts[v2nexti];
- if( v2 == v2last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- }
- }
- }
-
- public int ccwTurn_tl(Arc j1, Arc j2 ) {
- int v1i = j1.pwlArc.npts-1;
- int v1lasti = 0;
- int v2i = 0;
- int v2lasti = j2.pwlArc.npts-1;
- int v1nexti = v1i-1;
- int v2nexti = v2i+1;
- TrimVertex v1 = j1.pwlArc.pts[v1i];
- TrimVertex v1last = j1.pwlArc.pts[v1lasti];
- TrimVertex v2 = j2.pwlArc.pts[v2i];
- TrimVertex v2last = j2.pwlArc.pts[v2lasti];
- TrimVertex v1next = j1.pwlArc.pts[v1nexti];
- TrimVertex v2next = j2.pwlArc.pts[v2nexti];
- int sgn;
-
- assert( v1 != v1last );
- assert( v2 != v2last );
-
- // 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] )
- throw new NurbsException(28 );
-
- if( v1.param[0] < v2.param[0] )
- return 0;
- else if( v1.param[0] > v2.param[0] )
- return 1;
-
- while( true ) {
- if( v1next.param[1] > v2next.param[1] ) {
- 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 {
- v1i = v1nexti--;
- v1 = j1.pwlArc.pts[v1i];
- v1next = j1.pwlArc.pts[v1nexti];
- if( v1 == v1last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- break;
- case 1:
- return 1;
- }
- } else if( v1next.param[1] < v2next.param[1] ) {
- switch( bbox( v1next, v1, v2next, 0 ) ) {
- case -1:
- return 1;
- case 0:
- sgn = ccw( v1next, v1, v2next );
- if( sgn != -1 )
- return sgn;
- else {
- v2i = v2nexti++;
- v2 = j2.pwlArc.pts[v2i];
- v2next = j2.pwlArc.pts[v2nexti];
- if( v2 == v2last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- break;
- case 1:
- return 0;
- }
- } else {
- if( v1next.param[0] < v2next.param[0] )
- return 0;
- else if( v1next.param[0] > v2next.param[0] )
- return 1;
- else {
- v2i = v2nexti++;
- v2 = j2.pwlArc.pts[v2i];
- v2next = j2.pwlArc.pts[v2nexti];
- if( v2 == v2last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- }
- }
- }
-
- public int ccwTurn_tr(Arc j1, Arc j2) {
- int v1i = j1.pwlArc.npts-1;
- int v1lasti = 0;
- int v2i = 0;
- int v2lasti = j2.pwlArc.npts-1;
- int v1nexti = v1i-1;
- int v2nexti = v2i+1;
- TrimVertex v1 = j1.pwlArc.pts[v1i];
- TrimVertex v1last = j1.pwlArc.pts[v1lasti];
- TrimVertex v2 = j2.pwlArc.pts[v2i];
- TrimVertex v2last = j2.pwlArc.pts[v2lasti];
- TrimVertex v1next = j1.pwlArc.pts[v1nexti];
- TrimVertex v2next = j2.pwlArc.pts[v2nexti];
- int sgn;
-
- assert( v1 != v1last );
- assert( v2 != v2last );
-
- // 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] )
- throw new NurbsException( 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] ) {
- 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 {
- v1i = v1nexti--;
- v1 = j1.pwlArc.pts[v1i];
- v1next = j1.pwlArc.pts[v1nexti];
- if( v1 == v1last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- break;
- case 1:
- return 0;
- }
- } else if( v1next.param[1] > v2next.param[1] ) {
- 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 {
- v2i = v2nexti++;
- v2 = j2.pwlArc.pts[v2i];
- v2next = j2.pwlArc.pts[v2nexti];
- if( v2 == v2last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- break;
- case 1:
- return 1;
- }
- } else {
- if( v1next.param[0] < v2next.param[0] )
- return 1;
- else if( v1next.param[0] > v2next.param[0] )
- return 0;
- else {
- v2i = v2nexti++;
- v2 = j2.pwlArc.pts[v2i];
- v2next = j2.pwlArc.pts[v2nexti];
- if( v2 == v2last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- }
- }
- }
-
- public void set_domain_distance_u_rate(float u_rate) {
- domain_distance_u_rate = u_rate;
- }
-
- public void set_domain_distance_v_rate(float v_rate) {
- domain_distance_v_rate = v_rate;
- }
-
- public void set_is_domain_distance_sampling(int flag) {
- is_domain_distance_sampling = flag;
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- /**
- * Determine which side of a line a jarc lies (for debugging only)
- */
- private int arc_classify( Arc jarc, int param, float value )
- {
- float 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;
- }
- }
- }
-
- private void classify_headonleft_s( Bin bin, Bin in, Bin out, float val ) {
- /* tail on line, head at left */
- Arc j;
-
- while( (j = bin.removearc()) != null ) {
- assert( arc_classify( j, 0, val ) == 0x20 );
-
- j.setitail();
-
- float diff = j.prev.tail()[0] - val;
- if( diff > 0.0 ) {
- out.addarc( j );
- } else if( diff < 0.0 ) {
- if( ccwTurn_sl( j.prev, j ) != 0 )
- out.addarc( j );
- else
- in.addarc( j );
- } else {
- if( j.prev.tail()[1] > j.prev.head()[1] )
- in.addarc( j );
- else
- out.addarc( j );
- }
- }
- }
-
- private void classify_tailonleft_s( Bin bin, Bin in, Bin out, float val ) {
- /* tail at left, head on line */
- Arc j;
-
- while( (j = bin.removearc()) != null ) {
- assert( arc_classify( j, 1, val ) == 0x02 );
- j.clearitail();
-
- float diff = j.next.head()[1] - val;
- if( diff > 0.0 ) {
- in.addarc( j );
- } else if( diff < 0.0 ) {
- if( ccwTurn_tl( j, j.next ) != 0 )
- out.addarc( j );
- else
- in.addarc( j );
- } else {
- if (j.next.tail()[0] > j.next.head()[0] )
- out.addarc( j );
- else
- in.addarc( j );
- }
- }
- }
-
- private void classify_headonright_s( Bin bin, Bin in, Bin out, float val ) {
- /* tail on line, head at right */
- Arc j;
-
- while( (j = bin.removearc()) != null ) {
- assert( arc_classify( j, 0, val ) == 0x21 );
-
- j.setitail();
-
- float diff = j.prev.tail()[0] - val;
- if( diff > 0.0 ) {
- if( ccwTurn_sr( j.prev, j ) != 0 )
- 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 );
- }
- }
- }
-
- private void classify_tailonright_s( Bin bin, Bin in, Bin out, float val ) {
- /* tail at right, head on line */
- Arc j;
-
- while( (j = bin.removearc()) != null ) {
- assert( arc_classify( j, 0, val ) == 0x12);
-
- j.clearitail();
-
- float diff = j.next.head()[0] - val;
- if( diff > 0.0 ) {
- if( ccwTurn_sr( j, j.next ) != 0 )
- 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 );
- }
- }
- }
-
- private void classify_headonleft_t( Bin bin, Bin in, Bin out, float val ) {
- /* tail on line, head at left */
- Arc j;
-
- while( (j = bin.removearc()) != null ) {
- assert( arc_classify( j, 1, val ) == 0x20 );
- j.setitail();
-
- float diff = j.prev.tail()[1] - val;
- if( diff > 0.0 ) {
- out.addarc( j );
- } else if( diff < 0.0 ) {
- if( ccwTurn_tl( j.prev, j ) != 0 )
- out.addarc( j );
- else
- in.addarc( j );
- } else {
- if( j.prev.tail()[0] > j.prev.head()[0] )
- out.addarc( j );
- else
- in.addarc( j );
- }
- }
- }
-
- private void classify_tailonleft_t( Bin bin, Bin in, Bin out, float val ) {
- /* tail at left, head on line */
- Arc j;
-
- while( (j = bin.removearc()) != null ) {
- assert( arc_classify( j, 1, val ) == 0x02 );
- j.clearitail();
-
- float diff = j.next.head()[1] - val;
- if( diff > 0.0 ) {
- in.addarc( j );
- } else if( diff < 0.0 ) {
- if( ccwTurn_tl( j, j.next ) != 0 )
- out.addarc( j );
- else
- in.addarc( j );
- } else {
- if (j.next.tail()[0] > j.next.head()[0] )
- out.addarc( j );
- else
- in.addarc( j );
- }
- }
- }
-
- private void classify_headonright_t( Bin bin, Bin in, Bin out, float val ) {
- /* tail on line, head at right */
- Arc j;
-
- while( (j = bin.removearc()) != null ) {
- assert( arc_classify( j, 1, val ) == 0x21 );
-
- j.setitail();
-
- float diff = j.prev.tail()[1] - val;
- if( diff > 0.0 ) {
- if( ccwTurn_tr( j.prev, j ) != 0 )
- 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 );
- }
- }
- }
-
- private void classify_tailonright_t( Bin bin, Bin in, Bin out, float val ) {
- /* tail at right, head on line */
- Arc j;
-
- while( (j = bin.removearc()) != null ) {
- assert( arc_classify( j, 1, val ) == 0x12);
-
- j.clearitail();
-
- float diff = j.next.head()[1] - val;
- if( diff > 0.0 ) {
- if( ccwTurn_tr( j, j.next ) != 0 )
- 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 );
- }
- }
- }
-
- private int DIR_DOWN = 0;
- private int DIR_SAME = 1;
- private int DIR_UP = 2;
- private int DIR_NONE = 3;
-
- private void tessellate( Arc_ptr, float );
- private void monotonize( Arc_ptr , Bin & );
- private int isMonotone( Arc_ptr );
- private int decompose( Bin &, float );
-
-
- private Slicer slicer;
- private ArcTessellator arctessellator;
- // private Pool arcpool;
- // private Pool bezierarcpool;
- // private Pool pwlarcpool;
- // private TrimVertexPool trimvertexpool;
-
- private JumpBuffer* jumpbuffer;
- private Renderhints& renderhints;
- private Backend& backend;
-
- private Bin initialbin;
- private Arc pjarc;
- private int s_index;
- private int t_index;
- private Quilt *qlist;
- private Flist spbrkpts;
- private Flist tpbrkpts;
- private Flist smbrkpts;
- private Flist tmbrkpts;
- private float stepsizes[4];
- private int showDegenerate;
- private int isArcTypeBezier;
-
- // FIXME: NOT FINISHED
- private void samplingSplit( Curvelist&, int );
-
- private void subdivideInS( Bin source ) {
- if( renderhints.display_method == N_OUTLINE_PARAM ) {
- outline( source );
- freejarcs( source );
- } else {
- setArcTypeBezier();
- setNonDegenerate();
- splitInS( source, spbrkpts.start, spbrkpts.end );
- }
- }
-
- /**
- * Splits a patch and a bin by an isoparametric line.
- */
- private void splitInS( Bin source, int start, int end ) {
- if( source.isnonempty() ) {
- if( start != end ) {
- int i = start + (end - start) / 2;
- Bin left = new Bin();
- Bin right = new Bin();
- split( source, left, right, 0, spbrkpts.pts[i] );
- splitInS( left, start, i );
- splitInS( right, i+1, end );
- } else {
- if( start == spbrkpts.start || start == spbrkpts.end ) {
- freejarcs( source );
- } else if( renderhints.display_method == NurbsConsts.N_OUTLINE_PARAM_S ) {
- outline( source );
- freejarcs( source );
- } else {
- setArcTypeBezier();
- setNonDegenerate();
- s_index = start;
- splitInT( source, tpbrkpts.start, tpbrkpts.end );
- }
- }
- }
- }
-
- /**
- * Splits a patch and a bin by an isoparametric line.
- */
- private void splitInT( Bin source, int start, int end ) {
- if( source.isnonempty() ) {
- if( start != end ) {
- int i = start + (end - start) / 2;
- Bin left = new Bin();
- Bin right = new Bin();
- split( source, left, right, 1, tpbrkpts.pts[i] );
- splitInT( left, start, i );
- splitInT( right, i+1, end );
- } else {
- if( start == tpbrkpts.start || start == tpbrkpts.end ) {
- freejarcs( source );
- } else if( renderhints.display_method == NurbsConsts.N_OUTLINE_PARAM_ST ) {
- outline( source );
- freejarcs( source );
- } else {
- t_index = start;
- setArcTypeBezier();
- setDegenerate();
-
- float[] pta = new float[2];
- float[] ptb = new float[2];
- pta[0] = spbrkpts.pts[s_index-1];
- pta[1] = tpbrkpts.pts[t_index-1];
-
- ptb[0] = spbrkpts.pts[s_index];
- ptb[1] = tpbrkpts.pts[t_index];
- qlist.downloadAll( pta, ptb, backend );
-
- Patchlist patchlist = new Patchlist( qlist, pta, ptb );
- /*
- printf("-------samplingSplit-----\n");
- source.show("samplingSplit source");
- */
- samplingSplit( source, patchlist, renderhints.maxsubdivisions, 0 );
- setNonDegenerate();
- setArcTypeBezier();
- }
- }
- }
- }
-
- /**
- * Recursively subdivides patch, cull checks each subpatch
- */
- private void samplingSplit( Bin source, Patchlist patchlist, int subdivisions, int param ) {
- if( ! source.isnonempty() ) return;
-
- if( patchlist.cullCheck() == Defines.CULL_TRIVIAL_REJECT ) {
- freejarcs( source );
- return;
- }
-
- patchlist.getstepsize();
-
- if( renderhints.display_method == NurbsConsts.N_OUTLINE_PATCH ) {
- tessellation( source, patchlist );
- outline( source );
- freejarcs( source );
- return;
- }
-
- //patchlist.clamp();
-
- tessellation( source, patchlist );
-
- if( patchlist.needsSamplingSubdivision() && (subdivisions > 0) ) {
- if( ! patchlist.needsSubdivision( 0 ) )
- param = 1;
- else if( ! patchlist.needsSubdivision( 1 ) )
- param = 0;
- else
- param = 1 - param;
-
- Bin left = new Bin();
- Bin right = new Bin();
- float mid = ( patchlist.pspec[param].range[0] +
- patchlist.pspec[param].range[1] ) * 0.5;
- split( source, left, right, param, mid );
- Patchlist subpatchlist = new Patchlist( patchlist, param, mid );
- samplingSplit( left, subpatchlist, subdivisions-1, param );
- samplingSplit( right, patchlist, subdivisions-1, param );
- } else {
- setArcTypePwl();
- setDegenerate();
- nonSamplingSplit( source, patchlist, subdivisions, param );
- setDegenerate();
- setArcTypeBezier();
- }
- }
-
- private void nonSamplingSplit( Bin source, Patchlist patchlist, int subdivisions, int param ) {
- if( patchlist.needsNonSamplingSubdivision() && (subdivisions > 0) ) {
- param = 1 - param;
-
- Bin left = new Bin();
- Bin right = new Bin();
- float mid = ( patchlist.pspec[param].range[0] +
- patchlist.pspec[param].range[1] ) * 0.5;
- split( source, left, right, param, mid );
- Patchlist subpatchlist = new Patchlist( patchlist, param, mid );
- if( left.isnonempty() )
- if( subpatchlist.cullCheck() == Defines.CULL_TRIVIAL_REJECT )
- freejarcs( left );
- else
- nonSamplingSplit( left, subpatchlist, subdivisions-1, param );
- if( right.isnonempty() )
- if( patchlist.cullCheck() == Defines.CULL_TRIVIAL_REJECT )
- freejarcs( right );
- else
- nonSamplingSplit( right, patchlist, subdivisions-1, param );
-
- } else {
- // make bbox calls
- patchlist.bbox();
- backend.patch( patchlist.pspec[0].range[0], patchlist.pspec[0].range[1],
- patchlist.pspec[1].range[0], patchlist.pspec[1].range[1] );
-
- if( renderhints.display_method == NurbsConsts.N_OUTLINE_SUBDIV ) {
- outline( source );
- freejarcs( source );
- } else {
- setArcTypePwl();
- setDegenerate();
- findIrregularS( source );
- monosplitInS( source, smbrkpts.start, smbrkpts.end );
- }
- }
- }
-
- /**
- * Sets tessellation of interior and boundary of patch.
- */
- private void tessellation( Bin bin, Patchlist patchlist ) {
- // tessellate unsampled trim curves
- tessellate( bin, patchlist.pspec[1].sidestep[1], patchlist.pspec[0].sidestep[1],
- patchlist.pspec[1].sidestep[0], patchlist.pspec[0].sidestep[0] );
-
- // set interior sampling rates
- slicer.setstriptessellation( patchlist.pspec[0].stepsize, patchlist.pspec[1].stepsize );
-
- //added by zl: set the order which will be used in slicer.c++
- slicer.set_ulinear( (patchlist.get_uorder() == 2));
- slicer.set_vlinear( (patchlist.get_vorder() == 2));
-
- // set boundary sampling rates
- stepsizes[0] = patchlist.pspec[1].stepsize;
- stepsizes[1] = patchlist.pspec[0].stepsize;
- stepsizes[2] = patchlist.pspec[1].stepsize;
- stepsizes[3] = patchlist.pspec[0].stepsize;
- }
-
- /**
- * Splits a patch and a bin by an isoparametric line.
- */
- private void monosplitInS( Bin source, int start, int end ) {
- if( source.isnonempty() ) {
- if( start != end ) {
- int i = start + (end - start) / 2;
- Bin left = new Bin();
- Bin right = new Bin();
- split( source, left, right, 0, smbrkpts.pts[i] );
- monosplitInS( left, start, i );
- monosplitInS( right, i+1, end );
- } else {
- if( renderhints.display_method == NurbsConsts.N_OUTLINE_SUBDIV_S ) {
- outline( source );
- freejarcs( source );
- } else {
- setArcTypePwl();
- setDegenerate();
- findIrregularT( source );
- monosplitInT( source, tmbrkpts.start, tmbrkpts.end );
- }
- }
- }
- }
-
- /**
- * Splits a patch and a bin by an isoparametric line.
- */
- private void monosplitInT( Bin source, int start, int end ) {
- if( source.isnonempty() ) {
- if( start != end ) {
- int i = start + (end - start) / 2;
- Bin left = new Bin();
- Bin right = new Bin();
- split( source, left, right, 1, tmbrkpts.pts[i] );
- monosplitInT( left, start, i );
- monosplitInT( right, i+1, end );
- } else {
- if( renderhints.display_method == NurbsConsts.N_OUTLINE_SUBDIV_ST ) {
- outline( source );
- freejarcs( source );
- } else {
- /*
- printf("*******render\n");
- source.show("source\n");
- */
- render( source );
- freejarcs( source );
- }
- }
- }
- }
-
- /**
- * Renders the trimmed patch by outlining the boundary .
- */
- private void outline( Bin bin ) {
- bin.markall();
- for( Arc jarc=bin.firstarc(); jarc != null; jarc=bin.nextarc() ) {
- if( jarc.ismarked() ) {
- assert( jarc.check( ) );
- Arc jarchead = jarc;
- do {
- slicer.outline( jarc );
- jarc.clearmark();
- jarc = jarc.prev;
- } while (jarc != jarchead);
- }
- }
- }
-
- /**
- * Frees all arcs in a bin.
- */
- private void freejarcs( Bin & ) {
- bin.adopt(); /* XXX - should not be necessary */
-
- Arc jarc;
- while( (jarc = bin.removearc()) != null ) {
- if( jarc.pwlArc != null ) jarc.pwlArc.deleteMe( ); jarc.pwlArc = null;
- if( jarc.bezierArc != null) jarc.bezierArc.deleteMe( ); jarc.bezierArc = null;
- jarc.deleteMe( );
- }
- }
-
- /**
- * Renders all monotone regions in a bin and frees the bin.
- */
- private void render( Bin bin ) {
- bin.markall();
-
- slicer.setisolines( ( renderhints.display_method == N_ISOLINE_S ) ? 1 : 0 );
-
- for( Arc jarc=bin.firstarc(); jarc != null; jarc=bin.nextarc() ) {
- if( jarc.ismarked() ) {
- assert( jarc.check( ) != 0 );
- Arc jarchead = jarc;
- do {
- jarc.clearmark();
- jarc = jarc.next;
- } while (jarc != jarchead);
- slicer.slice( jarc );
- }
- }
- }
-
- private void split( Bin &, Bin &, Bin &, int, float );
-
- /**
- * Tessellates all Bezier arcs in a bin.
- * <ol>
- * <li> only accepts linear Bezier arcs as input
- * <li> the Bezier arcs are stored in the pwlArc structure
- * <li> only vertical or horizontal lines work
- * </ol>
- * should:
- * <ol>
- * <li> represent Bezier arcs in BezierArc structure
- * (this requires a multitude of changes to the code)
- * <li> accept high degree Bezier arcs (hard)
- * <il> map the curve onto the surface to determine tessellation
- * <li> work for curves of arbitrary geometry
- * </ol>
- *----------------------------------------------------------------------------
- */
- private void tessellate( Bin bin, float rrate, float trate, float lrate, float brate ) {
- for( Arc jarc=bin.firstarc(); jarc != null; jarc=bin.nextarc() ) {
- if( jarc.isbezier( ) ) {
- assert( jarc.pwlArc.npts == 2 );
- TrimVertex[] pts = jarc.pwlArc.pts;
- float s1 = pts[0].param[0];
- float t1 = pts[0].param[1];
- float s2 = pts[1].param[0];
- float t2 = pts[1].param[1];
-
- jarc.pwlArc.deleteMe( );
- jarc.pwlArc = null;
-
- switch( jarc.getside() ) {
- case Arc.SIDE_LEFT:
- assert( s1 == s2 );
- arctessellator.pwl_left( jarc, s1, t1, t2, lrate );
- break;
- case Arc.SIDE_RIGHT:
- assert( s1 == s2 );
- arctessellator.pwl_right( jarc, s1, t1, t2, rrate );
- break;
- case Arc.SIDE_TOP:
- assert( t1 == t2 );
- arctessellator.pwl_top( jarc, t1, s1, s2, trate );
- break;
- case Arc.SIDE_BOTTOM:
- assert( t1 == t2 );
- arctessellator.pwl_bottom( jarc, t1, s1, s2, brate );
- break;
- case Arc.SIDE_NONE:
- throw new InternalError("Incorrect tesselation state");
- break;
- }
- assert( ! jarc.isbezier() );
- assert( jarc.check() != 0 );
- }
- }
- }
-
- private inline void setDegenerate( void ) { showDegenerate = 1; }
- private inline void setNonDegenerate( void ) { showDegenerate = 0; }
- private inline int showingDegenerate( void ) { return showDegenerate; }
- private inline void setArcTypeBezier( void ) { isArcTypeBezier = 1; }
- private inline void setArcTypePwl( void ) { isArcTypeBezier = 0; }
- private inline int isBezierArcType( void ) { return isArcTypeBezier; }
-
- /**
- * If no user input trimming data, then create a trimming curve
- * around the boundaries of the Quilt. The curve consists of four
- * Jordan arcs, one for each side of the Quilt, connected, of
- * course, head to tail.
- */
- private void makeBorderTrim( float[] from, float[] to ) {
- float smin = from[0];
- float smax = to[0];
- float tmin = from[1];
- float tmax = to[1];
-
- pjarc = null;
-
- Arc jarc = new Arc( Arc.SIDE_BOTTOM, 0 );
- arctessellator.bezier( jarc, smin, smax, tmin, tmin );
- initialbin.addarc( jarc );
- pjarc = jarc.append( pjarc );
-
- jarc = new Arc( Arc.SIDE_RIGHT, 0 );
- arctessellator.bezier( jarc, smax, smax, tmin, tmax );
- initialbin.addarc( jarc );
- pjarc = jarc.append( pjarc );
-
- jarc = new Arc( Arc.SIDE_TOP, 0 );
- arctessellator.bezier( jarc, smax, smin, tmax, tmax );
- initialbin.addarc( jarc );
- pjarc = jarc.append( pjarc );
-
- jarc = new Arc( Arc.SIDE_LEFT, 0 );
- arctessellator.bezier( jarc, smin, smin, tmax, tmin );
- initialbin.addarc( jarc );
- jarc.append( pjarc );
-
- assert( jarc.check() );
- }
-
- private void split( Bin &, int, const float *, int, int );
- private void partition( Bin bin, Bin left, Bin intersections, Bin right, Bin unknown, int param, float value ) {
- Bin headonleft = new Bin();
- Bin headonright = new Bin();
- Bin tailonleft = new Bin();
- Bin tailonright = new Bin();
-
- for( Arc jarc = bin.removearc(); jarc != null; jarc = bin.removearc() ) {
-
- float tdiff = jarc.tail()[param] - value;
- float 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 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 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 );
- }
- }
-
- /**
- * Determine points of non-monotonicity in s direction.
- */
- private void findIrregularS( Bin bin ) {
- assert( bin.firstarc() == null || bin.firstarc().check() );
-
- smbrkpts.grow( bin.numarcs() );
-
- for( Arc jarc=bin.firstarc(); jarc != null; jarc=bin.nextarc() ) {
- float[] a = jarc.prev.tail();
- float[] b = jarc.tail();
- float[] c = jarc.head();
-
- if( b[1] == a[1] && b[1] == c[1] ) continue;
-
- //corrected code
- if((b[1]<=a[1] && b[1] <= c[1]) ||
- (b[1]>=a[1] && b[1] >= c[1]))
- {
- //each arc (jarc, jarc.prev, jarc.next) is a
- //monotone arc consisting of multiple line segements.
- //it may happen that jarc.prev and jarc.next are the same,
- //that is, jarc.prev and jarc form a closed loop.
- //In such case, a and c will be the same.
- if(a[0]==c[0] && a[1] == c[1])
- {
- if(jarc.pwlArc.npts >2)
- {
- c = jarc.pwlArc.pts[jarc.pwlArc.npts-2].param;
- }
- else
- {
- assert(jarc.prev.pwlArc.npts>2);
- a = jarc.prev.pwlArc.pts[jarc.prev.pwlArc.npts-2].param;
- }
-
- }
- if(area(a,b,c) < 0)
- {
- smbrkpts.add(b[0]);
- }
-
- }
-
- /* old code,
- if( b[1] <= a[1] && b[1] <= c[1] ) {
- if( ! ccwTurn_tr( jarc.prev, jarc ) )
- smbrkpts.add( b[0] );
- } else if( b[1] >= a[1] && b[1] >= c[1] ) {
- if( ! ccwTurn_tl( jarc.prev, jarc ) )
- smbrkpts.add( b[0] );
- }
- */
-
- }
-
- smbrkpts.filter();
- }
-
- /**
- * Determines points of non-monotonicity in t direction where one
- * arc is parallel to the s axis.
- */
- private void findIrregularT( Bin bin ) {
- assert( bin.firstarc() == null || bin.firstarc().check() );
-
- tmbrkpts.grow( bin.numarcs() );
-
- for( Arc jarc=bin.firstarc(); jarc != null; jarc=bin.nextarc() ) {
- float[] a = jarc.prev.tail();
- float[] b = jarc.tail();
- float[] c = jarc.head();
-
- if( b[0] == a[0] && b[0] == c[0] ) continue;
-
- if( b[0] <= a[0] && b[0] <= c[0] ) {
- if( a[1] != b[1] && b[1] != c[1] ) continue;
- if( ccwTurn_sr( jarc.prev, jarc ) == 0)
- tmbrkpts.add( b[1] );
- } else if ( b[0] >= a[0] && b[0] >= c[0] ) {
- if( a[1] != b[1] && b[1] != c[1] ) continue;
- if( ccwTurn_sl( jarc.prev, jarc ) == 0)
- tmbrkpts.add( b[1] );
- }
- }
- tmbrkpts.filter( );
- }
-
-
- private int 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] );
- }
-
- private static int bbox( float sa, float sb, float sc, float ta, float tb, float tc ) {
- assert( tc >= ta );
- assert( tc <= tb );
-
- 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;
- }
- }
- }
- /**
- * Determines 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.
- */
- private static int ccw( TrimVertex a, TrimVertex b, TrimVertex c ) {
- float d = TrimVertex.det3( a, b, c );
- if( Math.abs(d) < 0.0001 ) return -1;
- return (d < 0.0) ? 0 : 1;
- }
- private void join_s( Bin &, Bin &, Arc_ptr, Arc_ptr );
- private void join_t( Bin &, Bin &, Arc_ptr , Arc_ptr );
-
- private static void vert_interp( TrimVertex n, TrimVertex l, TrimVertex r, int p, float 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] ) {
- float 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];
- }
- }
-
- private static final int INTERSECT_VERTEX = 1;
- private static final int INTERSECT_EDGE = 2;
-
- /**
- * Finds intersection of pwlArc and isoparametric line.
- */
- private static int pwlarc_intersect( PwlArc pwlArc, int param, float value, int dir, int[] loc ) {
- assert( pwlArc.npts > 0 );
-
- if( dir != 0 ) {
- 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;
- }
- }
-
- private int arc_split( Arc jarc , int param, float value, int dir ) {
- int maxvertex = jarc.pwlArc.npts;
- Arc jarc1, jarc2, jarc3;
- TrimVertex v = jarc.pwlArc.pts;
-
- int[] loc = new int[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 Arc( jarc, new PwlArc( maxvertex-loc[1], /* &v[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());
- 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];
- }
-
- // 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 = TrimVertex.allocate(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 = TrimVertex.allocate(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 Arc( jarc,
- new 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());
-
- return 2;
-
- /***
- // JEB: This is the original version:
-
- TrimVertex[] newjunk = TrimVertex.allocate(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;
- }
- ***/
- }
- default:
- return -1; //picked -1 since it's not used
- }
- }
-
- private void check_s( Arc_ptr , Arc_ptr );
- private void check_t( Arc_ptr , Arc_ptr );
- private inline void link( Arc_ptr , Arc_ptr , Arc_ptr , Arc_ptr );
- private inline void simple_link( Arc_ptr , Arc_ptr );
-
- private Bin makePatchBoundary( const float[] from, const float[] to ) {
- Bin ret = new Bin();
- float smin = from[0];
- float smax = to[0];
- float tmin = from[1];
- float tmax = to[1];
-
- pjarc = 0;
-
- Arc jarc = new Arc( arc_bottom, 0 );
- arctessellator.bezier( jarc, smin, smax, tmin, tmin );
- ret.addarc( jarc );
- pjarc = jarc.append( pjarc );
-
- jarc = new(arcpool) Arc( arc_right, 0 );
- arctessellator.bezier( jarc, smax, smax, tmin, tmax );
- ret.addarc( jarc );
- pjarc = jarc.append( pjarc );
-
- jarc = new(arcpool) Arc( arc_top, 0 );
- arctessellator.bezier( jarc, smax, smin, tmax, tmax );
- ret.addarc( jarc );
- pjarc = jarc.append( pjarc );
-
- jarc = new(arcpool) Arc( arc_left, 0 );
- arctessellator.bezier( jarc, smin, smin, tmax, tmin );
- ret.addarc( jarc );
- jarc.append( pjarc );
-
- assert( jarc.check() != 0 );
- return ret;
- }
-
- /*in domain distance method, the tessellation is controled by two numbers:
- *GLU_U_STEP: number of u-segments per unit u length of domain
- *GLU_V_STEP: number of v-segments per unit v length of domain
- *These two numbers are normally stored in mapdesc.maxs(t)rate.
- *I (ZL) put these two numbers here so that I can optimize the untrimmed
- *case in the case of domain distance sampling.
- *These two numbers are set by set_domain_distance_u_rate() and ..._v_..().
- */
- private float domain_distance_u_rate;
- private float domain_distance_v_rate;
- private int is_domain_distance_sampling;
-
-}
diff --git a/src/classes/javax/media/opengl/glu/GLUnurbs.java b/src/classes/javax/media/opengl/glu/GLUnurbs.java
new file mode 100755
index 000000000..2641115d0
--- /dev/null
+++ b/src/classes/javax/media/opengl/glu/GLUnurbs.java
@@ -0,0 +1,8 @@
+package javax.media.opengl.glu;
+
+/**
+ * Wrapper for a GLU NURBS object.
+ */
+
+public interface GLUnurbs {
+}