//This file is part of SECONDO. //Copyright (C) 2004, University in Hagen, Department of Computer Science, //Database Systems for New Applications. //SECONDO is free software; you can redistribute it and/or modify //it under the terms of the GNU General Public License as published by //the Free Software Foundation; either version 2 of the License, or //(at your option) any later version. //SECONDO is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. //You should have received a copy of the GNU General Public License //along with SECONDO; if not, write to the Free Software //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA package viewer.viewer3d.objects; import sj.lang.ListExpr; import viewer.viewer3d.graphic3d.*; import java.util.Vector; import gui.idmanager.*; import gui.SecondoObject; import java.awt.*; public class FPoint3D implements Object3D{ public Triangle3DVector getTriangles(){ return null;} public Line3DVector getLines(){ return null;} public Point3DVector getPoints(){return Points;} /** check if the type from SO is a FPoint */ public boolean checkType(SecondoObject SO){ ListExpr LE = SO.toListExpr(); if(LE.listLength()!=2) return false; return (LE.first().isAtom() && LE.first().atomType()==ListExpr.SYMBOL_ATOM && ( LE.first().symbolValue().equals("fpoint") || LE.first().symbolValue().equals("pointcloud"))); } /** read the value of this Fpoint from SO */ public boolean readFromSecondoObject(SecondoObject SO){ ListExpr LE = SO.toListExpr(); if(LE.listLength()!=2) return false; if (!checkType(SO)) return false; Name = SO.getName(); myID = SO.getID(); if(LE.first().symbolValue().equals("pointcloud")){ isPointCloud = true; return readPointCloud(LE.second()); } isPointCloud = false; return readFromListExpr(LE.second()); } public String toString(){return Name;} /** read this FPoint from a non typed ListExpr */ private boolean readFromListExpr(ListExpr LE){ double SF = 1.0; Points = new Point3DVector(); SingleFPoints = new Vector(); if(LE==null) return false; if(LE.listLength()!=2) return false; ListExpr SFList = LE.first(); if( !( SFList.isAtom() && (SFList.atomType()==ListExpr.INT_ATOM || SFList.atomType()==ListExpr.REAL_ATOM))) return false; double z= SFList.atomType()==ListExpr.INT_ATOM ? SFList.intValue() : SFList.realValue(); if(z<=0) return false; this.ScaleFactor = z; // read the single Points ListExpr points_le = LE.second(); SingleFPoint P; boolean ok = true; while( !points_le.isEmpty() & ok) { P = new SingleFPoint(); if(P.readFromListExpr(points_le.first(),false)){ SingleFPoints.add(P); points_le=points_le.rest(); } else ok = false; } computePoints3D(); return ok; } private boolean readPointCloud(ListExpr LE){ if(LE.isEmpty()){ return false; } ScaleFactor = 1.0; LE = LE.rest(); // ignore bounding box while(!LE.isEmpty()){ SingleFPoint p = new SingleFPoint(); if(!p.readFromListExpr(LE.first(),true)){ return false; } SingleFPoints.add(p); LE = LE.rest(); } computePoints3D(); return true; } private void computePoints3D(){ // compute the 3DPointVector Points = new Point3DVector(); Point3D P3D; SingleFPoint P; BB.set(0,0,0,0,0,0); BoundingBox3D BB2= new BoundingBox3D(); double minZ = Double.MAX_VALUE; double maxZ = Double.MIN_VALUE; if(isPointCloud){ for(int i=0;imaxZ) maxZ = z; } } for(int i=0;i