001/* 002 * Entity410_View -- This class represents the position of the model in a drawing entity. 003 * 004 * Copyright (C) 2010-2016, Joseph A. Huwaldt. 005 * All rights reserved. 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * You should have received a copy of the GNU Lesser General Public License 018 * along with this program; if not, write to the Free Software 019 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 020 * Or visit: http://www.gnu.org/licenses/lgpl.html 021 * 022 * Based on, but heavily modified from, IGESView ( http://ts.nist.gov/Standards/IGES/igesTools.cfm ) 023 */ 024package geomss.geom.reader.iges; 025 026import java.io.IOException; 027import java.io.RandomAccessFile; 028import java.text.MessageFormat; 029 030/** 031 * <b><i>VIEW ENTITY</i></b> - This entity specifies the position of the model entities 032 * when referenced from a Drawing Entity. 033 * 034 * <p> Modified by: Joseph A. Huwaldt </p> 035 * 036 * @author JDN, Version 1.0 037 * @version September 13, 2016 038 */ 039public class Entity410_View extends Entity { 040 041 private int vno; // View number 042 private double scale; // Scale factor (default = 1.0) 043 private int xvminp; // DE number to left side of view volume (XVMIN plane) or zero 044 private int yvmaxp; // DE number to top of view volume (YVMAX plane) or zero 045 private int xvmaxp; // DE number to right side of view volume (XVMAX plane) or zero 046 private int yvminp; // DE number to bottom of view volume (YVMIN plane) or zero 047 private int zvminp; // DE number to back of view volume (ZVMIN plane) or zero 048 private int zvmaxp; // DE number to front of view volume (ZVMAX plane) or zero 049 050 /** 051 * Default constructor. 052 * 053 * @param p part to which this entity is contained 054 * @param de Directory Entry for this entity 055 */ 056 public Entity410_View(Part p, DirEntry de) { 057 super(p, de); 058 059 if (Constants.DEBUG) { 060 System.out.println("Entity410 constructor called"); 061 } 062 } 063 064 /** 065 * Checks to see if the entity should be drawn. The following restrictions are 066 * imposed: 067 * 068 * - The Transformation Matrix shall be 0 - The view volume pointers shall all be 0 069 */ 070 @Override 071 public void check() { 072 DirEntry DE = getDirectoryEntry(); 073 074 // DE Matrix shall be 0 075 if (DE.getMatrix() != 0) { 076 String msg = MessageFormat.format(RESOURCES.getString("matrixNotZero"), DE.getMatrix()); 077 addErrorMessage(getWarningString(msg)); 078 } 079 080 // View volume pointers shall all be 0 081 if ((xvminp != 0) || (yvminp != 0) || (zvminp != 0) 082 || (xvmaxp != 0) || (yvmaxp != 0) || (zvmaxp != 0)) { 083 String msg = RESOURCES.getString("viewVolPointersNotZero"); 084 addErrorMessage(getWarningString(msg)); 085 } 086 } 087 088 /** 089 * Read the Parameter Data from the String read in by the superclass. 090 * 091 * @param in input file 092 * @throws java.io.IOException 093 */ 094 @Override 095 public void read(RandomAccessFile in) throws IOException { 096 if (Constants.DEBUG) { 097 System.out.println("Entity410.read() called"); 098 } 099 100 super.read(in); 101 String s = getPDString(); 102 103 if (Constants.DEBUG) { 104 System.out.println("PD String = \"" + s + "\""); 105 } 106 107 vno = getInt(s); 108 scale = getReal(s, 1.0); 109 xvminp = getInt(s); 110 yvmaxp = getInt(s); 111 xvmaxp = getInt(s); 112 yvminp = getInt(s); 113 zvminp = getInt(s); 114 zvmaxp = getInt(s); 115 116 super.read_additional(); 117 } 118 119 /** 120 * Returns a short String describing this Entity object's type. 121 * 122 * @return A short String describing this Entity object's type. 123 */ 124 @Override 125 public String getTypeString() { 126 return "Entity410 - View"; 127 } 128 129 /** 130 * Dump to String. 131 * 132 * @return String containing the resulting text. 133 */ 134 @Override 135 public String toString() { 136 StringBuilder outStr = new StringBuilder(super.toString()); 137 outStr.append("\n"); 138 139 outStr.append("vno = "); outStr.append(vno); outStr.append("\n"); 140 outStr.append("scale = "); outStr.append(scale); outStr.append("\n"); 141 outStr.append("xvminp = "); outStr.append(xvminp); outStr.append("\n"); 142 outStr.append("yvmaxp = "); outStr.append(yvmaxp); outStr.append("\n"); 143 outStr.append("xvmaxp = "); outStr.append(xvmaxp); outStr.append("\n"); 144 outStr.append("yvminp = "); outStr.append(yvminp); outStr.append("\n"); 145 outStr.append("zvminp = "); outStr.append(zvminp); outStr.append("\n"); 146 outStr.append("zvmaxp = "); outStr.append(zvmaxp); 147 148 return outStr.toString(); 149 } 150 151}