org.bimserver.serializers.binarygeometry.clipping.PolygonClipping Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of binaryserializers Show documentation
Show all versions of binaryserializers Show documentation
BIMserver plugins that provides binary serializers
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;
}
}