aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/impl/glu/gl2
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-02-08 06:20:35 +0100
committerSven Gothel <[email protected]>2011-02-08 06:20:35 +0100
commit4cda4b70dbcd21cf57e1e253ddba32b88bcaec18 (patch)
tree6f16d211cb80ebf5dcc8cab6424c70079a38ea7f /src/jogl/classes/com/jogamp/opengl/impl/glu/gl2
parenteb7986963c87bc6f33e7f18bb90ddf898b7dd63a (diff)
Move implementation private files from com.jogamp.<module>.impl. to jogamp.<module> (1/2) - rename task
- com.jogamp.opengl.impl -> jogamp.opengl - com.jogamp.opengl.util.glsl.fixedfunc.impl -> jogamp.opengl.util.glsl.fixedfunc - com.jogamp.nativewindow.impl -> jogamp.nativewindow - com.jogamp.newt.impl -> jogamp.newt This sorts implementation details from the top level, ie skipping the public 'com', allowing a better seperation of public classes and implementation details and also reduces strings. This approach of public/private seperation is also used in the OpenJDK.
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/glu/gl2')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/glu/gl2/nurbs/GL2Backend.java49
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/glu/gl2/nurbs/GL2CurveEvaluator.java205
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/glu/gl2/nurbs/GL2SurfaceEvaluator.java217
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/glu/gl2/nurbs/GLUgl2nurbsImpl.java862
4 files changed, 0 insertions, 1333 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/glu/gl2/nurbs/GL2Backend.java b/src/jogl/classes/com/jogamp/opengl/impl/glu/gl2/nurbs/GL2Backend.java
deleted file mode 100644
index 42ddeea50..000000000
--- a/src/jogl/classes/com/jogamp/opengl/impl/glu/gl2/nurbs/GL2Backend.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.jogamp.opengl.impl.glu.gl2.nurbs;
-import com.jogamp.opengl.impl.glu.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 2.0 (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
- *
- */
-public class GL2Backend extends Backend {
- public GL2Backend() {
- super();
- curveEvaluator = new GL2CurveEvaluator();
- surfaceEvaluator = new GL2SurfaceEvaluator();
- }
-}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/glu/gl2/nurbs/GL2CurveEvaluator.java b/src/jogl/classes/com/jogamp/opengl/impl/glu/gl2/nurbs/GL2CurveEvaluator.java
deleted file mode 100644
index adb8c51d8..000000000
--- a/src/jogl/classes/com/jogamp/opengl/impl/glu/gl2/nurbs/GL2CurveEvaluator.java
+++ /dev/null
@@ -1,205 +0,0 @@
-package com.jogamp.opengl.impl.glu.gl2.nurbs;
-import com.jogamp.opengl.impl.glu.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 2.0 (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.GL2;
-import javax.media.opengl.glu.GLU;
-import javax.media.opengl.glu.gl2.GLUgl2;
-
-/**
- * Class rendering curves with OpenGL
- * @author Tomáš Hráský
- *
- */
-class GL2CurveEvaluator implements CurveEvaluator {
-
- /**
- * Output triangles (for callback) or render curve
- */
- private boolean output_triangles;
-
- /**
- * OpenGL object
- */
- private GL2 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 GL2CurveEvaluator() {
- gl = GLUgl2.getCurrentGL2();
- }
-
- /**
- * 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(GL2.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(GL2.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(GL2.GL_LINE, from, to);
- break;
- case Backend.N_MESHPOINT:
- gl.glEvalMesh1(GL2.GL_POINT, from, to);
- break;
- }
- }
- }
-}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/glu/gl2/nurbs/GL2SurfaceEvaluator.java b/src/jogl/classes/com/jogamp/opengl/impl/glu/gl2/nurbs/GL2SurfaceEvaluator.java
deleted file mode 100644
index 393601ff7..000000000
--- a/src/jogl/classes/com/jogamp/opengl/impl/glu/gl2/nurbs/GL2SurfaceEvaluator.java
+++ /dev/null
@@ -1,217 +0,0 @@
-package com.jogamp.opengl.impl.glu.gl2.nurbs;
-import com.jogamp.opengl.impl.glu.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 2.0 (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.GL2;
-import javax.media.opengl.glu.GLU;
-import javax.media.opengl.glu.gl2.GLUgl2;
-
-/**
- * Class rendering surfaces with OpenGL
- * @author Tomas Hrasky
- *
- */
-class GL2SurfaceEvaluator implements SurfaceEvaluator {
-
- /**
- * JOGL OpenGL object
- */
- private GL2 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 GL2SurfaceEvaluator() {
- gl = GLUgl2.getCurrentGL2();
- }
-
- /**
- * 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(GL2.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(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL);
- break;
- case NurbsConsts.N_MESHLINE:
- gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);
- break;
- case NurbsConsts.N_MESHPOINT:
- gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.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(GL2.GL_FILL, umin, umax, vmin, vmax);
- break;
- case NurbsConsts.N_MESHLINE:
- gl.glEvalMesh2(GL2.GL_LINE, umin, umax, vmin, vmax);
- break;
- case NurbsConsts.N_MESHPOINT:
- gl.glEvalMesh2(GL2.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/jogl/classes/com/jogamp/opengl/impl/glu/gl2/nurbs/GLUgl2nurbsImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/glu/gl2/nurbs/GLUgl2nurbsImpl.java
deleted file mode 100644
index 13b68138c..000000000
--- a/src/jogl/classes/com/jogamp/opengl/impl/glu/gl2/nurbs/GLUgl2nurbsImpl.java
+++ /dev/null
@@ -1,862 +0,0 @@
-package com.jogamp.opengl.impl.glu.gl2.nurbs;
-import com.jogamp.opengl.impl.glu.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 2.0 (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.GL2;
-import javax.media.opengl.glu.GLUnurbs;
-
-/**
- * Base object for working with NURBS curves and surfaces
- *
- * @author Tomas Hrasky
- *
- */
-public class GLUgl2nurbsImpl 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 GLUgl2nurbs object
- */
- public GLUgl2nurbsImpl() {
- // DONE
- maplist = new Maplist(backend);
- renderhints = new Renderhints();
- subdivider = new Subdivider();
- // original code
-
- redefineMaps();
-
- defineMap(GL2.GL_MAP2_NORMAL, 0, 3);
- defineMap(GL2.GL_MAP1_NORMAL, 0, 3);
- defineMap(GL2.GL_MAP2_TEXTURE_COORD_1, 0, 1);
- defineMap(GL2.GL_MAP1_TEXTURE_COORD_1, 0, 1);
- defineMap(GL2.GL_MAP2_TEXTURE_COORD_2, 0, 2);
- defineMap(GL2.GL_MAP1_TEXTURE_COORD_2, 0, 2);
- defineMap(GL2.GL_MAP2_TEXTURE_COORD_3, 0, 3);
- defineMap(GL2.GL_MAP1_TEXTURE_COORD_3, 0, 3);
- defineMap(GL2.GL_MAP2_TEXTURE_COORD_4, 1, 4);
- defineMap(GL2.GL_MAP1_TEXTURE_COORD_4, 1, 4);
- defineMap(GL2.GL_MAP2_VERTEX_4, 1, 4);
- defineMap(GL2.GL_MAP1_VERTEX_4, 1, 4);
- defineMap(GL2.GL_MAP2_VERTEX_3, 0, 3);
- defineMap(GL2.GL_MAP1_VERTEX_3, 0, 3);
- defineMap(GL2.GL_MAP2_COLOR_4, 0, 4);
- defineMap(GL2.GL_MAP1_COLOR_4, 0, 4);
- defineMap(GL2.GL_MAP2_INDEX, 0, 1);
- defineMap(GL2.GL_MAP1_INDEX, 0, 1);
-
- setnurbsproperty(GL2.GL_MAP1_VERTEX_3, NurbsConsts.N_SAMPLINGMETHOD,
- (float) NurbsConsts.N_PATHLENGTH);
- setnurbsproperty(GL2.GL_MAP1_VERTEX_4, NurbsConsts.N_SAMPLINGMETHOD,
- (float) NurbsConsts.N_PATHLENGTH);
- setnurbsproperty(GL2.GL_MAP2_VERTEX_3, NurbsConsts.N_SAMPLINGMETHOD,
- (float) NurbsConsts.N_PATHLENGTH);
- setnurbsproperty(GL2.GL_MAP2_VERTEX_4, NurbsConsts.N_SAMPLINGMETHOD,
- (float) NurbsConsts.N_PATHLENGTH);
-
- setnurbsproperty(GL2.GL_MAP1_VERTEX_3, NurbsConsts.N_PIXEL_TOLERANCE,
- (float) 50.0);
- setnurbsproperty(GL2.GL_MAP1_VERTEX_4, NurbsConsts.N_PIXEL_TOLERANCE,
- (float) 50.0);
- setnurbsproperty(GL2.GL_MAP2_VERTEX_3, NurbsConsts.N_PIXEL_TOLERANCE,
- (float) 50.0);
- setnurbsproperty(GL2.GL_MAP2_VERTEX_4, NurbsConsts.N_PIXEL_TOLERANCE,
- (float) 50.0);
-
- setnurbsproperty(GL2.GL_MAP1_VERTEX_3, NurbsConsts.N_ERROR_TOLERANCE,
- (float) 0.50);
- setnurbsproperty(GL2.GL_MAP1_VERTEX_4, NurbsConsts.N_ERROR_TOLERANCE,
- (float) 0.50);
- setnurbsproperty(GL2.GL_MAP2_VERTEX_3, NurbsConsts.N_ERROR_TOLERANCE,
- (float) 0.50);
- setnurbsproperty(GL2.GL_MAP2_VERTEX_4, NurbsConsts.N_ERROR_TOLERANCE,
- (float) 0.50);
-
- setnurbsproperty(GL2.GL_MAP1_VERTEX_3, NurbsConsts.N_S_STEPS,
- (float) 100.0);
- setnurbsproperty(GL2.GL_MAP1_VERTEX_4, NurbsConsts.N_S_STEPS,
- (float) 100.0);
- setnurbsproperty(GL2.GL_MAP2_VERTEX_3, NurbsConsts.N_S_STEPS,
- (float) 100.0);
- setnurbsproperty(GL2.GL_MAP2_VERTEX_4, NurbsConsts.N_S_STEPS,
- (float) 100.0);
-
- setnurbsproperty(GL2.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(new GL2Backend());
- 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(new GL2Backend());
-
- 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);
- }
-}