All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bimserver.serializers.binarygeometry.clipping.PolygonClipping Maven / Gradle / Ivy

There is a newer version: 0.0.96
Show newest version
package org.bimserver.serializers.binarygeometry.clipping;

/******************************************************************************
 * Copyright (C) 2009-2019  BIMserver.org
 * 
 * This program 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 3 of the License, or
 * (at your option) any later version.
 * 
 * This program 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 this program.  If not, see {@literal}.
 *****************************************************************************/

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Color;
import java.awt.Polygon;
import javax.swing.JPanel;
import java.util.ArrayList;
import java.util.Random;

public class PolygonClipping extends JPanel{

//main class, does the 'work'
public PolygonClipping(){
 //create input and window polygons and fill array lists
// input = generateInput();
// window = generateWindow();
//
// //generate output from S.H.-clipping algorithm
// output = clippingAlg(input,window);
// System.out.print("Clipped polygon from "+input.size());
// System.out.println(" to "+output.size()+" points.");
}


//creates the input polygon, random 3-300 vertices

//creates the window to clip the input polygon, random quadrilateral

//conducts the Sutherland-Hodgman clipping algorithm
//returns array list of points, points of the output polygon
public ArrayList clippingAlg(ArrayList subjectP,ArrayList clippingP){
 ArrayList edges = clippingP;
 ArrayList in = subjectP;
 ArrayList out = new ArrayList();

 //begin looping through edges and points
 int casenum = 0;
 for(int i=0;i)out.clone(); 
   if (in.size() == 0) {
	   return in;
   }
   out.clear();
 }
// for(Point pt:in){
//   q.addPoint((int)pt.getX(),(int)pt.getY());
// }  
 return in;
}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy