Source Code Cross Referenced for StripifierStats.java in  » 6.0-JDK-Modules » java-3d » com » sun » j3d » utils » geometry » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » java 3d » com.sun.j3d.utils.geometry 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: StripifierStats.java,v $
003:         *
004:         * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions
008:         * are met:
009:         *
010:         * - Redistribution of source code must retain the above copyright
011:         *   notice, this list of conditions and the following disclaimer.
012:         *
013:         * - Redistribution in binary form must reproduce the above copyright
014:         *   notice, this list of conditions and the following disclaimer in
015:         *   the documentation and/or other materials provided with the
016:         *   distribution.
017:         *
018:         * Neither the name of Sun Microsystems, Inc. or the names of
019:         * contributors may be used to endorse or promote products derived
020:         * from this software without specific prior written permission.
021:         *
022:         * This software is provided "AS IS," without a warranty of any
023:         * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
024:         * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
025:         * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
026:         * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
027:         * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
028:         * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
029:         * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
030:         * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
031:         * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
032:         * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
033:         * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
034:         * POSSIBILITY OF SUCH DAMAGES.
035:         *
036:         * You acknowledge that this software is not designed, licensed or
037:         * intended for use in the design, construction, operation or
038:         * maintenance of any nuclear facility.
039:         *
040:         * $Revision: 1.4 $
041:         * $Date: 2007/02/09 17:20:20 $
042:         * $State: Exp $
043:         */
044:
045:        // ----------------------------------------------------------------------
046:        //
047:        // The reference to Fast Industrial Strength Triangulation (FIST) code
048:        // in this release by Sun Microsystems is related to Sun's rewrite of
049:        // an early version of FIST. FIST was originally created by Martin
050:        // Held and Joseph Mitchell at Stony Brook University and is
051:        // incorporated by Sun under an agreement with The Research Foundation
052:        // of SUNY (RFSUNY). The current version of FIST is available for
053:        // commercial use under a license agreement with RFSUNY on behalf of
054:        // the authors and Stony Brook University.  Please contact the Office
055:        // of Technology Licensing at Stony Brook, phone 631-632-9009, for
056:        // licensing information.
057:        //
058:        // ----------------------------------------------------------------------
059:        package com.sun.j3d.utils.geometry;
060:
061:        import java.util.ArrayList;
062:
063:        /**
064:         * This class collects statistics on the Stripifier.  The statistics
065:         * are cumulative over all calls to stripify() until clearData() is called.
066:         *
067:         * @since Java 3D 1.2.1
068:         */
069:
070:        public class StripifierStats {
071:
072:            int numStrips = 0;
073:            int numVerts = 0;
074:            int minStripLen = 10000;
075:            int maxStripLen = 0;
076:            int totalTris = 0;
077:            int numFaces = 0;
078:            long time = 0;
079:            int[] counts = new int[14];
080:
081:            boolean noData = true;
082:
083:            /**
084:             * Returns the number of triangles in the original, un-stripified data.
085:             * @since Java 3D 1.2.1
086:             */
087:            public int getNumOrigTris() {
088:                return numFaces;
089:            }
090:
091:            /**
092:             * Returns the number of vertices in the original, un-stripified data
093:             * @since Java 3D 1.2.1
094:             */
095:            public int getNumOrigVerts() {
096:                return (numFaces * 3);
097:            }
098:
099:            /**
100:             * Returns the number of strips created by the stripifier.
101:             * @since Java 3D 1.2.1
102:             */
103:            public int getNumStrips() {
104:                return numStrips;
105:            }
106:
107:            /**
108:             * Returns the number of vertices in the stripified data.
109:             * @since Java 3D 1.2.1
110:             */
111:            public int getNumVerts() {
112:                return numVerts;
113:            }
114:
115:            /**
116:             * Returns the number of triangles in the stripified data.
117:             * @since Java 3D 1.2.1
118:             */
119:            public int getTotalTris() {
120:                return totalTris;
121:            }
122:
123:            /**
124:             * Returns the length in triangles of the shortest strip
125:             * created by the stripifier.
126:             * @since Java 3D 1.2.1
127:             */
128:            public int getMinStripLength() {
129:                return minStripLen;
130:            }
131:
132:            /**
133:             * Returns the length in triangles of the longest strip
134:             * created by the stripifier.
135:             * @since Java 3D 1.2.1
136:             */
137:            public int getMaxStripLength() {
138:                return maxStripLen;
139:            }
140:
141:            /**
142:             * Return the average length of the strips created by the stripifier
143:             * @since Java 3D 1.2.1
144:             */
145:            public double getAvgStripLength() {
146:                return ((double) totalTris / (double) numStrips);
147:            }
148:
149:            /**
150:             * Returns the average number of vertices per triangle in the stripified
151:             * data
152:             * @since Java 3D 1.2.1
153:             */
154:            public double getAvgNumVertsPerTri() {
155:                return ((double) numVerts / (double) totalTris);
156:            }
157:
158:            /**
159:             * Returns the total time spent in the stripify() method
160:             * @since Java 3D 1.2.1
161:             */
162:            public long getTotalTime() {
163:                return time;
164:            }
165:
166:            /**
167:             * Returns an array of length 14 that contains the number of strips of
168:             * a given length created by the stripifier.  Spots 0-8 of the array
169:             * represent lengths 1-9, 9 is lengths 10-19, 10 is lengths 20-49,
170:             * 11 is lengths 50-99, 12 is lengths 100-999 and 13 is lengths 1000
171:             * or more.
172:             * @since Java 3D 1.2.1
173:             */
174:            public int[] getStripLengthCounts() {
175:                return counts;
176:            }
177:
178:            /**
179:             * Returns a formated String that can be used to print out
180:             * the Stripifier stats.
181:             * @since Java 3D 1.2.1
182:             */
183:
184:            public String toString() {
185:                StringBuffer str = new StringBuffer("num orig tris:        "
186:                        + numFaces + "\n" + "num orig vertices:    "
187:                        + (numFaces * 3) + "\n" + "number of strips:     "
188:                        + numStrips + "\n" + "number of vertices:   "
189:                        + numVerts + "\n" + "total tris:           "
190:                        + totalTris + "\n" + "min strip length:     "
191:                        + minStripLen + "\n" + "max strip length:     "
192:                        + maxStripLen + "\n" + "avg strip length:     "
193:                        + ((double) totalTris / (double) numStrips) + "\n"
194:                        + "avg num verts/tri:    "
195:                        + ((double) numVerts / (double) totalTris) + "\n"
196:                        + "total time:           " + time + "\n"
197:                        + "strip length distribution:\n");
198:                for (int i = 0; i < 9; i++) {
199:                    str.append("  " + (i + 1) + "=" + counts[i]);
200:                }
201:                str.append("  10-19=" + counts[9]);
202:                str.append("  20-49=" + counts[10]);
203:                str.append("  50-99=" + counts[11]);
204:                str.append("  100-999=" + counts[12]);
205:                str.append("  1000 or more=" + counts[13] + "\n");
206:
207:                return str.toString();
208:            }
209:
210:            /**
211:             * Clears the statistical data
212:             */
213:            public void clearData() {
214:                noData = true;
215:
216:                numStrips = 0;
217:                numVerts = 0;
218:                minStripLen = 10000;
219:                maxStripLen = 0;
220:                totalTris = 0;
221:                numFaces = 0;
222:                time = 0;
223:                counts = new int[14];
224:            }
225:
226:            void updateInfo(long ntime, ArrayList strips, int nNumFaces) {
227:                noData = false;
228:
229:                time += ntime;
230:                numStrips += strips.size();
231:                int nv = 0;
232:                int mnsl = 10000;
233:                int mxsl = 0;
234:                int tt = 0;
235:                for (int i = 0; i < strips.size(); i++) {
236:                    Stripifier.Istream strm = (Stripifier.Istream) strips
237:                            .get(i);
238:                    int len = strm.length;
239:                    int trilen = (len - 2);
240:                    nv += len;
241:                    if (trilen < mnsl)
242:                        mnsl = trilen;
243:                    if (trilen > mxsl)
244:                        mxsl = trilen;
245:                    tt += trilen;
246:
247:                    // add to counts
248:                    // how many strips are length 1-9
249:                    if (trilen <= 9)
250:                        counts[trilen - 1] += 1;
251:                    // how many strips are length 10-19
252:                    else if (trilen < 20)
253:                        counts[9] += 1;
254:                    // how many strips are length 20-49
255:                    else if (trilen < 50)
256:                        counts[10] += 1;
257:                    // how many strips are length 50-99
258:                    else if (trilen < 100)
259:                        counts[11] += 1;
260:                    // how many strips are length 100-1000
261:                    else if (trilen < 1000)
262:                        counts[12] += 1;
263:                    // how many strips are length > 1000
264:                    else
265:                        counts[13] += 1;
266:                }
267:                numVerts += nv;
268:                if (mnsl < minStripLen)
269:                    minStripLen = mnsl;
270:                if (mxsl > maxStripLen)
271:                    maxStripLen = mxsl;
272:                totalTris += tt;
273:                numFaces += nNumFaces;
274:            }
275:
276:            void updateInfo(long ntime, int scLen, int sc[], int nNumFaces) {
277:
278:                noData = false;
279:
280:                time += ntime;
281:                numStrips += scLen;
282:                int nv = 0;
283:                int mnsl = 10000;
284:                int mxsl = 0;
285:                int tt = 0;
286:                for (int i = 0; i < scLen; i++) {
287:                    int len = sc[i];
288:                    int trilen = (len - 2);
289:                    numVerts += len;
290:                    if (trilen < mnsl)
291:                        mnsl = trilen;
292:                    if (trilen > mxsl)
293:                        mxsl = trilen;
294:                    totalTris += trilen;
295:
296:                    // add to counts
297:                    // how many strips are length 1-9
298:                    if (trilen <= 9)
299:                        counts[trilen - 1] += 1;
300:                    // how many strips are length 10-19
301:                    else if (trilen < 20)
302:                        counts[9] += 1;
303:                    // how many strips are length 20-49
304:                    else if (trilen < 50)
305:                        counts[10] += 1;
306:                    // how many strips are length 50-99
307:                    else if (trilen < 100)
308:                        counts[11] += 1;
309:                    // how many strips are length 100-1000
310:                    else if (trilen < 1000)
311:                        counts[12] += 1;
312:                    // how many strips are length > 1000
313:                    else
314:                        counts[13] += 1;
315:                }
316:                numVerts += nv;
317:                if (mnsl < minStripLen)
318:                    minStripLen = mnsl;
319:                if (mxsl > maxStripLen)
320:                    maxStripLen = mxsl;
321:                totalTris += tt;
322:                numFaces += nNumFaces;
323:            }
324:
325:            //     void printInfo() {
326:            // 	System.out.println("num orig tris:        " + numFaces);
327:            // 	System.out.println("num orig vertices:    " + (numFaces*3));
328:            // 	System.out.println("number of strips:     " + numStrips);
329:            // 	System.out.println("number of vertices:   " + numVerts);
330:            // 	System.out.println("total tris:           " + totalTris);
331:            // 	System.out.println("min strip length:     " + minStripLen);
332:            // 	System.out.println("max strip length:     " + maxStripLen);
333:            // 	System.out.println("avg strip length:     " + ((double)totalTris/
334:            // 						       (double)numStrips));
335:            // 	System.out.println("avg num verts/tri:    " + ((double)numVerts/
336:            // 						       (double)totalTris));
337:            // 	System.out.println("total time:           " + time);
338:            // 	System.out.println("strip length distribution:");
339:            // 	for (int i = 0; i < 9; i++){
340:            // 	    System.out.print("  " + (i+1) + "=" + counts[i]);
341:            // 	}
342:            // 	System.out.print("  10-19=" + counts[9]);
343:            // 	System.out.print("  20-49=" + counts[10]);
344:            // 	System.out.print("  50-99=" + counts[11]);
345:            // 	System.out.print("  100-999=" + counts[12]);
346:            // 	System.out.println("  1000 or more=" + counts[13]);
347:
348:            // 	// reset info after printing data
349:            // 	numStrips = 0;
350:            // 	numVerts = 0;
351:            // 	minStripLen = 10000;
352:            // 	maxStripLen = 0;
353:            // 	totalTris = 0;
354:            // 	numFaces = 0;
355:            // 	time = 0;
356:            // 	counts = new int[14];
357:            //     }
358:
359:            StripifierStats() {
360:            }
361:
362:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.