//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 fuzzyobjects.basic; import java.util.Vector; /** * this class manage a serie of connected BasicPoints * the SimplePath has no selfcuts but can build a circle */ public class SimplePath extends Path{ /** creates a new empty SimplePath */ public SimplePath(){ super(); } /** extend the SimplePath with P * the first Point of P must be equals to the last Point of * this SimplePath, this SimplePath can not be a circle * this SimplePath and P can not have cuts * @return true if sucessfull */ public boolean extend(SimplePath P){ int length = Points.size(); int Plength = P.Points.size(); if( Plength==0) return true; // no change this SimplePath if (length>1 && // a circle? ((BasicPoint)Points.get(0)).equals( (BasicPoint)Points.get(length-1))) return false; BasicPoint OldLast = (BasicPoint)(Points.get(length-1)); BasicPoint NewFirst = (BasicPoint)(P.Points.get(0)); if( !OldLast.equals(NewFirst)) // connected ? return false; boolean cut = false; BasicPoint Current; BasicPoint PCurrent; for(int i=0;i0) || (j<(Plength-1))) cut = cut || Current.equals(PCurrent); } } if(cut) return false; // extend the SimplePath for(int j=1;jmaxX) maxX = P.maxX; if(P.minXmaxY) maxY=P.maxY; if(P.minY can not extended if(size>1 && Points.get(0).equals(Points.get(size-1))) return false; boolean cut = false; for(int i=1;imaxX) maxX = x; if(ymaxY) maxY=y; return true; } /** check: first Point is equal to the last Point */ public boolean isACircle(){ int s = Points.size(); // min 3 points and first point is equal to the last point return ( s>2) && ( (BasicPoint) Points.get(0)).equals((BasicPoint) Points.get(s-1)); } /** * returns a BasicTriangle in the set of enclosed Triangles */ public BasicTriangle getAInnerTriangle(){ if(! isACircle()) return null; BasicSegment[] S = computeSegments(); BasicSegment Smallest = S[0]; BasicTriangle First; BasicTriangle[] N = Smallest.getTriangles(); if( N[0].compareTo(N[1])<0) First = N[1]; else First = N[0]; return First; } /** returns the ordered segments of this path */ private BasicSegment[] computeSegments(){ Vector Segments = new Vector(Points.size()); int nOS = getNumberOfSegments(); BasicSegment BS; BasicSegment MidBS; int min,max,mid,comp,pos; for(int i=0;i0){ min = mid+1; } } // while pos = min; MidBS = (BasicSegment) Segments.get(pos); if(MidBS.compareTo(BS)<0) pos++; Segments.add(pos,getSegment(i)); } // else (not empty Vector) }// for all Segments BasicSegment[] result = new BasicSegment[Segments.size()]; for(int i=0;i-1 && used[pos1]) | // current in exterior ( pos2>-1 && used[pos2]) | ( pos3>-1 && used[pos3]) ) { return; } // set all used Segments if( pos1>-1) used[pos1] = true; if( pos2>-1) used[pos2] = true; if( pos3>-1) used[pos3] = true; // add to result result.add(Current); BasicTriangle[] Neightboors = Current.getRealNeightboors(); for(int i=0;i