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