Source code: com/trapezium/chisel/mutators/IFS_FaceToLineSet.java
1 /*
2 * @(#)IFS_FaceToLineSet.java
3 *
4 * Copyright (c) 1998 by Trapezium Development LLC. All Rights Reserved.
5 *
6 * The information in this file is the property of Trapezium Development LLC
7 * and may be used only in accordance with the terms of the license granted
8 * by Trapezium.
9 *
10 */
11 package com.trapezium.chisel.mutators;
12
13 import com.trapezium.chisel.*;
14
15 import com.trapezium.vrml.node.Node;
16 import com.trapezium.vrml.VrmlElement;
17 import com.trapezium.vrml.fields.Field;
18
19 /**
20 * This chisel turns IndexedFaceSets into IndexedLineSets.
21 */
22 public class IFS_FaceToLineSet extends IFS_Converter {
23 /** Constructor, convert IndexedFaceSet to IndexedLineSet */
24 public IFS_FaceToLineSet() {
25 super( "IndexedLineSet" );
26 }
27
28 /** IndexedLineSet color controls similar to IndexedFaceSet color controls */
29 public void convertColorInfo( Node n, TokenPrinter tp,
30 int colorStart, VrmlElement color,
31 int colorPerVertexStart, VrmlElement colorPerVertex,
32 int colorIndexStart, VrmlElement colorIndex ) {
33 if ( colorStart != -1 ) {
34 tp.printRange( colorStart, color.getLastTokenOffset(), false );
35 }
36 if ( colorPerVertexStart != -1 ) {
37 tp.printRange( colorPerVertexStart, colorPerVertex.getLastTokenOffset(), false );
38 }
39 if ( colorIndexStart != -1 ) {
40 tp.printRange( colorIndexStart, colorIndex.getLastTokenOffset(), false );
41 }
42 }
43
44 void printCoordIndex( TokenPrinter tp, Field coordIndex ) {
45 int endTokenOffset = coordIndex.getLastTokenOffset();
46 int scanner = coordIndex.getFirstTokenOffset();
47 dataSource.setState( scanner );
48 while ( true ) {
49 scanner = tp.printNonNumbers( scanner, endTokenOffset );
50 if ( scanner >= endTokenOffset ) {
51 break;
52 }
53 scanner = convertFace( tp, scanner, endTokenOffset );
54 }
55 }
56
57 int convertFace( TokenPrinter tp, int scanner, int endTokenOffset ) {
58 int firstValue = dataSource.getIntValue( scanner );
59 int value = firstValue;
60 while ( true ) {
61 if ( value == -1 ) {
62 tp.print( firstValue );
63 tp.print( value );
64 break;
65 }
66 tp.print( dataSource, scanner );
67 scanner = dataSource.getNextToken();
68 value = dataSource.getIntValue( scanner );
69 }
70 scanner = dataSource.getNextToken();
71 return( scanner );
72 }
73 }
74
75