From: Gerardo H. <ma...@us...> - 2007-02-26 15:25:22
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser/keywords In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv16144/src/org/jrman/parser/keywords Modified Files: AbstractKeywordParser.java KeywordMotionBegin.java KeywordNuPatch.java KeywordPointsPolygons.java KeywordProcedural.java KeywordSubdivisionMesh.java Log Message: Started working on SubdivisionMeshes. Started migration to Java 5. Index: KeywordProcedural.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordProcedural.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** KeywordProcedural.java 12 Sep 2004 00:10:47 -0000 1.3 --- KeywordProcedural.java 26 Feb 2007 15:25:15 -0000 1.4 *************** *** 1,5 **** /* KeywordProcedural.java ! Copyright (C) 2003 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or --- 1,5 ---- /* KeywordProcedural.java ! Copyright (C) 2003, 2007 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or *************** *** 30,48 **** // Expect args ! parseArray(st); String[] args = new String[arraySize]; System.arraycopy(strings, 0, args, 0, arraySize); // Expect bounds ! parseArray(st); if (arraySize != 6) throw new Exception("Invalid number of arguments for bounding box: " + arraySize); ! float xmin = numbers[0]; ! float xmax = numbers[1]; ! float ymin = numbers[2]; ! float ymax = numbers[3]; ! float zmin = numbers[4]; ! float zmax = numbers[5]; if (s.equals("DelayedReadArchive")) { if (args.length != 1) --- 30,48 ---- // Expect args ! parseStringArray(st); String[] args = new String[arraySize]; System.arraycopy(strings, 0, args, 0, arraySize); // Expect bounds ! parseFloatArray(st); if (arraySize != 6) throw new Exception("Invalid number of arguments for bounding box: " + arraySize); ! float xmin = floats[0]; ! float xmax = floats[1]; ! float ymin = floats[2]; ! float ymax = floats[3]; ! float zmin = floats[4]; ! float zmax = floats[5]; if (s.equals("DelayedReadArchive")) { if (args.length != 1) Index: KeywordMotionBegin.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordMotionBegin.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KeywordMotionBegin.java 7 Apr 2003 08:24:25 -0000 1.2 --- KeywordMotionBegin.java 26 Feb 2007 15:25:15 -0000 1.3 *************** *** 25,29 **** public void parse(Tokenizer st) throws Exception { ! float[] times = readFloatArray(st); parser.motionBegin(times); --- 25,31 ---- public void parse(Tokenizer st) throws Exception { ! parseFloatArray(st); ! float[] times = new float[arraySize]; ! System.arraycopy(floats, 0, times, 0, arraySize); parser.motionBegin(times); Index: KeywordPointsPolygons.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordPointsPolygons.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** KeywordPointsPolygons.java 20 Dec 2004 03:22:52 -0000 1.7 --- KeywordPointsPolygons.java 26 Feb 2007 15:25:15 -0000 1.8 *************** *** 38,42 **** // Expect parameter list ! ParameterList parameterList = parseParameterList(st); parser.addPointsPolygons(nVertices, vertices, parameterList); } --- 38,43 ---- // Expect parameter list ! ParameterList parameterList = parseParameterList(st); ! parser.addPointsPolygons(nVertices, vertices, parameterList); } Index: KeywordSubdivisionMesh.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordSubdivisionMesh.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KeywordSubdivisionMesh.java 7 Apr 2003 08:24:24 -0000 1.2 --- KeywordSubdivisionMesh.java 26 Feb 2007 15:25:15 -0000 1.3 *************** *** 1,5 **** /* KeywordSubdivisionMesh.java ! Copyright (C) 2003 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or --- 1,5 ---- /* KeywordSubdivisionMesh.java ! Copyright (C) 2003, 2007 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or *************** *** 20,23 **** --- 20,24 ---- package org.jrman.parser.keywords; + import org.jrman.parameters.ParameterList; import org.jrman.parser.Tokenizer; *************** *** 27,51 **** // Expect scheme match(st, TK_STRING); // Expect nvertices ! parseArray(st); // Expect vertices ! parseArray(st); // Expect tags ! parseArray(st); // Expect nargs ! parseArray(st); // Expect intargs ! parseArray(st); // Expect floatargs ! parseArray(st); // Expect parameter list ! parseParameterList(st); } --- 28,69 ---- // Expect scheme match(st, TK_STRING); + String scheme = st.sval; // Expect nvertices ! parseIntegerArray(st); ! int[] nvertices = new int[arraySize]; ! System.arraycopy(integers, 0, nvertices, 0, arraySize); // Expect vertices ! parseIntegerArray(st); ! int[] vertices = new int[arraySize]; ! System.arraycopy(integers, 0, vertices, 0, arraySize); // Expect tags ! parseStringArray(st); ! String[] tags = new String[arraySize]; ! System.arraycopy(strings, 0, tags, 0, arraySize); // Expect nargs ! parseIntegerArray(st); ! int[] nargs = new int[arraySize]; ! System.arraycopy(integers, 0, nargs, 0, arraySize); // Expect intargs ! parseIntegerArray(st); ! int[] intargs = new int[arraySize]; ! System.arraycopy(intargs, 0, intargs, 0, arraySize); // Expect floatargs ! parseFloatArray(st); ! float[] floatargs = new float[arraySize]; ! System.arraycopy(floatargs, 0, floatargs, 0, arraySize); // Expect parameter list ! ParameterList parameterList = parseParameterList(st); ! ! parser.addSubdivisionMesh(scheme, nvertices, vertices, ! tags, nargs, intargs, floatargs, ! parameterList); } Index: AbstractKeywordParser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/AbstractKeywordParser.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** AbstractKeywordParser.java 4 Jul 2005 06:32:04 -0000 1.14 --- AbstractKeywordParser.java 26 Feb 2007 15:25:15 -0000 1.15 *************** *** 20,24 **** package org.jrman.parser.keywords; - import java.io.IOException; import java.io.StreamTokenizer; import java.util.ArrayList; --- 20,23 ---- *************** *** 55,59 **** final static int TK_RBRACE = ']'; ! protected static float[] numbers = new float[5000]; protected static int[] integers = new int[5000]; --- 54,58 ---- final static int TK_RBRACE = ']'; ! protected static float[] floats = new float[5000]; protected static int[] integers = new int[5000]; *************** *** 70,74 **** public static void reset() { ! numbers = new float[5000]; integers = new int[5000]; strings = new String[10]; --- 69,73 ---- public static void reset() { ! floats = new float[5000]; integers = new int[5000]; strings = new String[10]; *************** *** 116,120 **** } ! protected Bounds3f readBounds(Tokenizer st) throws IOException, Exception { boolean array = false; int token = st.nextToken(); --- 115,119 ---- } ! protected Bounds3f readBounds(Tokenizer st) throws Exception { boolean array = false; int token = st.nextToken(); *************** *** 206,210 **** } ! protected Color3f parseColor(Tokenizer st) throws IOException, Exception { boolean array = false; int token = st.nextToken(); --- 205,209 ---- } ! protected Color3f parseColor(Tokenizer st) throws Exception { boolean array = false; int token = st.nextToken(); *************** *** 233,276 **** } ! protected float[] readFloatArray(Tokenizer st) throws Exception, IOException { ! List floats = new ArrayList(); // Expect array start match(st, TK_LBRACE); ! // Expect a variable length sequence of numbers ! while (st.nextToken() == TK_NUMBER) ! floats.add(new Float(st.nval)); st.pushBack(); - float[] result = new float[floats.size()]; - for (int i = 0; i < floats.size(); i++) - result[i] = ((Float) floats.get(i)).floatValue(); // Expect array end match(st, TK_RBRACE); - return result; } ! /* ! protected Map parseParameterList(Tokenizer st) throws Exception { ! List list = new ArrayList(); ! // Expect list of key & value pairs while (st.nextToken() == TK_STRING) { ! list.add(st.sval); ! int token = st.nextToken(); ! if (token == TK_LBRACE) { ! st.pushBack(); ! list.add(parseArray(st)); ! } else if (token == TK_NUMBER) { ! List array = new ArrayList(); ! array.add(new Float((float) st.nval)); ! list.add(array); ! } else if (token == TK_STRING) { ! List array = new ArrayList(); ! array.add(st.sval); ! list.add(array); } } st.pushBack(); ! return parser.translateParameterList(list); } - */ protected void parseArray(Tokenizer st) throws Exception { --- 232,288 ---- } ! protected void parseIntegerArray(Tokenizer st) throws Exception { ! arraySize = 0; // Expect array start match(st, TK_LBRACE); ! // Expect a variable length sequence of integers ! while (st.nextToken() == TK_NUMBER) { ! if (arraySize == integers.length) { ! int[] tmp = new int[integers.length * 2]; ! System.arraycopy(integers, 0, tmp, 0, integers.length); ! integers = tmp; ! } ! integers[arraySize++] = (int) st.nval; ! } st.pushBack(); // Expect array end match(st, TK_RBRACE); } ! protected void parseFloatArray(Tokenizer st) throws Exception { ! arraySize = 0; ! // Expect array start ! match(st, TK_LBRACE); ! // Expect a variable length sequence of floats ! while (st.nextToken() == TK_NUMBER) { ! if (arraySize == floats.length) { ! float[] tmp = new float[floats.length * 2]; ! System.arraycopy(floats, 0, tmp, 0, floats.length); ! floats = tmp; ! } ! floats[arraySize++] = st.nval; ! } ! st.pushBack(); ! // Expect array end ! match(st, TK_RBRACE); ! } ! ! protected void parseStringArray(Tokenizer st) throws Exception { ! arraySize = 0; ! // Expect array start ! match(st, TK_LBRACE); ! // Expect a variable length sequence of strings while (st.nextToken() == TK_STRING) { ! if (arraySize == strings.length) { ! String[] tmp = new String[strings.length * 2]; ! System.arraycopy(strings, 0, tmp, 0, strings.length); ! strings = tmp; } + strings[arraySize++] = st.sval; } st.pushBack(); ! // Expect array end ! match(st, TK_RBRACE); } protected void parseArray(Tokenizer st) throws Exception { *************** *** 283,292 **** switch (token) { case TK_NUMBER : ! if (arraySize == numbers.length) { ! float[] tmp = new float[numbers.length * 2]; ! System.arraycopy(numbers, 0, tmp, 0, numbers.length); ! numbers = tmp; } ! numbers[arraySize++] = st.nval; break; case TK_STRING : --- 295,304 ---- switch (token) { case TK_NUMBER : ! if (arraySize == floats.length) { ! float[] tmp = new float[floats.length * 2]; ! System.arraycopy(floats, 0, tmp, 0, floats.length); ! floats = tmp; } ! floats[arraySize++] = st.nval; break; case TK_STRING : *************** *** 304,325 **** } - protected void parseIntegerArray(Tokenizer st) throws Exception { - arraySize = 0; - // Expect array start - match(st, TK_LBRACE); - // Expect a variable length sequence of integers - while (st.nextToken() == TK_NUMBER) { - if (arraySize == integers.length) { - int[] tmp = new int[integers.length * 2]; - System.arraycopy(integers, 0, tmp, 0, integers.length); - integers = tmp; - } - integers[arraySize++] = (int) st.nval; - } - st.pushBack(); - // Expect array end - match(st, TK_RBRACE); - } - private Declaration getDeclaration(String name) { Declaration declaration = Global.getDeclaration(name); --- 316,319 ---- *************** *** 356,360 **** parseArray(st); } else if (token == TK_NUMBER) { ! numbers[0] = st.nval; arraySize = 1; } else if (token == TK_STRING) { --- 350,354 ---- parseArray(st); } else if (token == TK_NUMBER) { ! floats[0] = st.nval; arraySize = 1; } else if (token == TK_STRING) { *************** *** 362,366 **** arraySize = 1; } ! parameters.addParameter(declaration.buildParameter(numbers, strings, arraySize)); } st.pushBack(); --- 356,362 ---- arraySize = 1; } ! parameters.addParameter(declaration.buildParameter(floats, ! strings, ! arraySize)); } st.pushBack(); Index: KeywordNuPatch.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/KeywordNuPatch.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** KeywordNuPatch.java 29 Mar 2004 16:47:30 -0000 1.3 --- KeywordNuPatch.java 26 Feb 2007 15:25:15 -0000 1.4 *************** *** 1,5 **** /* KeywordNuPatch.java ! Copyright (C) 2003 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or --- 1,5 ---- /* KeywordNuPatch.java ! Copyright (C) 2003, 2006, 2007 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or *************** *** 35,41 **** // Expect u knot ! parseArray(st); float[] uknot = new float[arraySize]; ! System.arraycopy(numbers, 0, uknot, 0, arraySize); // Expect u min --- 35,41 ---- // Expect u knot ! parseFloatArray(st); float[] uknot = new float[arraySize]; ! System.arraycopy(floats, 0, uknot, 0, arraySize); // Expect u min *************** *** 56,62 **** // Expect v knot ! parseArray(st); float[] vknot = new float[arraySize]; ! System.arraycopy(numbers, 0, vknot, 0, arraySize); // Expect v min --- 56,62 ---- // Expect v knot ! parseFloatArray(st); float[] vknot = new float[arraySize]; ! System.arraycopy(floats, 0, vknot, 0, arraySize); // Expect v min |