001/* 002 * Entity408_SingularSubfigure -- Entity that represents a singular subfigure. 003 * 004 * Copyright (C) 2012-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 */ 021package geomss.geom.reader.iges; 022 023import geomss.geom.*; 024import java.io.IOException; 025import java.io.RandomAccessFile; 026 027/** 028 * <b><i>SINGULAR SUBFIGURE INSTANCE ENTITY</i></b> - This entity defines the occurrence 029 * of a single instance of the defined subfigure. 030 * 031 * <p> 032 * This entity, when read from an IGES file, is converted to a list of geometry objects. 033 * This entity type can not be written out to an IGES file. 034 * </p> 035 * 036 * <p> Modified by: Joseph A. Huwaldt </p> 037 * 038 * @author Joseph A. Huwaldt, Date: January 31, 2012 039 * @version February 22, 2025 040 */ 041public class Entity408_SingularSubfigure extends GeomSSEntity { 042 043 protected int deNum; // Entity DE number of subfigure. 044 protected GeometryList geom = GeomList.newInstance(); // List of GeomSS geometry objects. 045 046 /** 047 * Default constructor. 048 * 049 * @param p part to which this entity is contained 050 * @param de Directory Entry for this entity 051 */ 052 public Entity408_SingularSubfigure(Part p, DirEntry de) { 053 super(p, de); 054 055 if (Constants.DEBUG) { 056 System.out.println("Entity408 constructor called"); 057 } 058 } 059 060 /** 061 * Checks to see if the entity is correct. No restrictions are imposed. 062 */ 063 @Override 064 public void check() { 065 } 066 067 /** 068 * Read the Parameter Data from the String read in by the superclass. 069 * 070 * @param in input file 071 * @throws java.io.IOException if the parameter data could not be read in. 072 */ 073 @Override 074 public void read(RandomAccessFile in) throws IOException { 075 super.read(in); 076 String s = getPDString(); 077 078 if (Constants.DEBUG) { 079 System.out.println("PD String = \"" + s + "\""); 080 } 081 082 deNum = getInt(s); // Get pointer to the subfigure DE number. 083 084 super.read_additional(); 085 } 086 087 /** 088 * The GeomSS geometry element is created from the IGES parameters when this method is 089 * called. 090 */ 091 @Override 092 void createGeometry() { 093 Part part = getPart(); 094 095 Entity entity = part.getEntity(deNum); 096 097 if (entity instanceof GeomSSEntity) { 098 // Found a GeomSS geometry Entity. 099 GeomSSEntity geomEntity = (GeomSSEntity)entity; 100 geomEntity.setUsedInList(true); // Indicate that the entity is used by this association. 101 GeomElement element = geomEntity.getGeomElement(GTransform.IDENTITY); 102 geom.add(element); 103 } 104 } 105 106 /** 107 * Return a reference to the Transformable GeomElement contained in this IGES Entity. 108 * 109 * @return A reference to the Transformable GeomElement contained in this IGES Entity. 110 */ 111 @Override 112 protected Transformable getGeomElement() { 113 return geom; 114 } 115 116 /** 117 * Dump to String. 118 * 119 * @return String containing the resulting text. 120 */ 121 @Override 122 public String toString() { 123 StringBuilder outStr = new StringBuilder(super.toString()); 124 outStr.append("\n"); 125 126 outStr.append("subfigure = "); outStr.append(deNum); outStr.append("\n"); 127 128 return outStr.toString(); 129 } 130 131 /** 132 * Returns a short String describing this Entity object's type. 133 * 134 * @return A short String describing this Entity object's type. 135 */ 136 @Override 137 public String getTypeString() { 138 return "Entity408 - Singular Subfigure Definition"; 139 } 140 141}