Source code: org/pqt/autorib/rib/RIBSubdivisionSurf.java
1 //AutoRIB
2 // Copyright © 1998 - 2002, P W Quint
3 //
4 // Contact: autorib00@aol.com
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public
8 // License as published by the Free Software Foundation; either
9 // version 2 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 package org.pqt.autorib.rib;
21
22 import java.util.*;
23 import java.io.*;
24 import java.lang.Math;
25
26 import org.pqt.autorib.tokenizer.*;
27 import org.pqt.autorib.globals.*;
28 import org.pqt.autorib.util.*;
29
30
31 /** Class for storing RIB PointsPolygons requests, and subdivision surfaces
32 *@version $Header: /home/CVSRepository/autoribnew/org/pqt/autorib/rib/RIBSubdivisionSurf.java,v 1.1 2003/12/02 17:11:44 remote Exp $
33 */
34 public class RIBSubdivisionSurf extends RIBPrimitive {
35 /** stores */
36 public Token nverts;
37 private Token vertids;
38
39 /** the scheme for the subdivision mesh*/
40 public String scheme = "catmull-clark";
41 /** the tags parameter for the subdivision mesh, if the pointspolygon is
42 * converted - null for empty*/
43 public Token tags = null;
44 /** the nargs parameter for the subdivision mesh, if the pointspolygon is
45 * converted - null for empty*/
46 public Token nargs = null;
47 /** the intargs parameter for the subdivision mesh, if the pointspolygon is
48 * converted - null for empty*/
49 public Token intargs = null;
50 /** the floatargs parameter for the subdivision mesh, if the pointspolygon is
51 * converted - null for empty*/
52 public Token floatargs = null;
53
54 public RIBSubdivisionSurf() {
55 requestID = RIBGlobals.SUBDIVISIONMESH;
56 requestName = RIBGlobals.requests[requestID];
57 deleted = false;
58 }
59
60 public RIBSubdivisionSurf(Tokenizer in) throws FormatException, IOException {
61 read(in);
62 }
63
64 public static RIBSubdivisionSurf create(RIBPointsPolygons poly, String scheme, Token tags,
65 Token nargs, Token intargs, Token floatargs) {
66 RIBSubdivisionSurf s = new RIBSubdivisionSurf();
67 if (scheme != null ) s.scheme = scheme;
68 s.tags = tags;
69 s.nargs = nargs;
70 s.intargs = intargs;
71 s.floatargs = floatargs;
72 s.nverts = poly.nverts;
73 s.vertids = poly.vertids;
74 s.params = poly.params;
75 return s;
76 }
77
78 public void read(Tokenizer in) throws FormatException, IOException {
79 readRequestName(in);
80 scheme = in.getString();
81 nverts = in.getArrayToken();
82 vertids = in.getArrayToken();
83 if (in.getToken() == Token.ARRAY) {
84 tags = in.token;
85 nargs = in.getArrayToken();
86 if (in.getToken() == Token.ARRAY) {
87 intargs = in.token;
88 if (in.getToken() == Token.ARRAY) {
89 floatargs = in.token;
90 } else
91 in.pushBack();
92 } else
93 in.pushBack();
94 }
95 else
96 in.pushBack();
97 params.read(in);
98 }
99
100
101
102 public void writeOther(Writer out) throws IOException {
103 Token.write(out, "\"" + scheme + "\" ");
104 nverts.write(out);
105 vertids.write(out);
106 if (tags != null)
107 tags.write(out);
108 if (nargs != null)
109 nargs.write(out);
110 if (intargs != null)
111 intargs.write(out);
112 if (floatargs != null)
113 floatargs.write(out);
114 params.write(out);
115 }
116
117 public Bounds3D getLocalBounds() {
118 if (bounds == null)
119 bounds = calculateLocalPPwBounds(params);
120 return bounds;
121 }
122
123 }
124