001/* 002 * Entity108_0_UnboundedPlane -- Entity that represents an unbounded plane. 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 */ 021package geomss.geom.reader.iges; 022 023import geomss.geom.GeomPlane; 024import geomss.geom.GeomPoint; 025import geomss.geom.GeomVector; 026import java.io.IOException; 027import java.io.PrintWriter; 028 029/** 030 * <b><i>PLANE ENTITY - UNBOUNDED</i></b> - This entity represents an unbounded plane. 031 * 032 * <p> 033 * This entity type <b>can</b> 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: September 6, 2010 039 * @version February 22, 2025 040 * @see Entity108_Plane 041 */ 042public class Entity108_0_UnboundedPlane extends Entity108_Plane { 043 044 /** 045 * Default constructor. 046 * 047 * @param p part to which this entity is contained 048 * @param de Directory Entry for this entity 049 */ 050 public Entity108_0_UnboundedPlane(Part p, DirEntry de) { 051 super(p, de); 052 053 if (Constants.DEBUG) { 054 System.out.println("Entity108_0 constructor called"); 055 } 056 } 057 058 /** 059 * Create this entity from the specified GeomSS geometry element. 060 * 061 * @param part The Part in which this entity is contained. 062 * @param DEnum The line count from the start of the Directory Entry Section for this 063 * entry (odd number). 064 * @param geom The GeomSS PointString geometry to return an Entity for. 065 */ 066 public Entity108_0_UnboundedPlane(Part part, int DEnum, GeomPlane geom) { 067 super(part, new DirEntry(108, 0, DEnum, 0, geom.getName())); 068 plane = geom; 069 070 // Extract the data we are writing out. 071 GeomVector n = geom.getNormal(); 072 A = n.getValue(0); 073 B = n.getValue(1); 074 C = n.getValue(2); 075 D = geom.getConstant().getValue(Constants.unit); 076 077 ptr = 0; 078 079 GeomPoint refPnt = geom.getRefPoint().to(Constants.unit); 080 xt = refPnt.getValue(0); 081 yt = refPnt.getValue(1); 082 zt = refPnt.getValue(2); 083 084 } 085 086 /** 087 * Returns <code>true</code> if the Entity can be written to an exchange file. 088 * 089 * @return true if the Entity can be written to an exchange file. 090 */ 091 @Override 092 public boolean canWrite() { 093 return true; 094 } 095 096 /** 097 * Write this entities parameter data to the specified PrintWriter. 098 * 099 * @param writer The PrintWriter to write the parameter data for this entity to. 100 * @param PDnum The starting Parameter Data row index number. 101 * @return The Parameter Data row index number for the next row. 102 * @throws java.io.IOException if the parameter data could not be written out. 103 */ 104 @Override 105 public int write(PrintWriter writer, int PDnum) throws IOException { 106 107 // Build up the parameter data string. 108 StringBuilder buffer = new StringBuilder(); 109 buffer.append(108); buffer.append(Constants.Delim); 110 buffer.append(A); buffer.append(Constants.Delim); 111 buffer.append(B); buffer.append(Constants.Delim); 112 buffer.append(C); buffer.append(Constants.Delim); 113 buffer.append(D); buffer.append(Constants.Delim); 114 buffer.append(ptr); buffer.append(Constants.Delim); 115 buffer.append(xt); buffer.append(Constants.Delim); 116 buffer.append(yt); buffer.append(Constants.Delim); 117 buffer.append(zt); buffer.append(Constants.Delim); 118 buffer.append(symbolSize); buffer.append(Constants.Term); 119 120 // Write it out. 121 int oldPDnum = PDnum; 122 PDnum = Constants.writeSection(writer, PDnum, Constants.makeSequenceNumber(getDENum()), 123 'P', buffer); 124 125 // Store the PD line number and line count in the directory entry. 126 getDirectoryEntry().setPDNumber(oldPDnum, PDnum - oldPDnum); 127 128 return PDnum; 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 "Entity108_0 - Unbounded Plane"; 139 } 140 141}