Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* JGrass - Free Open Source Java GIS http://www.jgrass.org
* (C) HydroloGIS - www.hydrologis.com
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Library General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option) any
* later version.
*
* This library 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 Library General Public License for more
* details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; if not, write to the Free Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.hortonmachine.gears.io.dxfdwg.libs.dwg.objects;
import java.util.Vector;
import org.hortonmachine.gears.io.dxfdwg.libs.dwg.DwgObject;
import org.hortonmachine.gears.io.dxfdwg.libs.dwg.DwgUtil;
/**
* The DwgSpline class represents a DWG Spline
*
* @author jmorell
*/
public class DwgSpline extends DwgObject {
private int scenario;
private int degree;
private double fitTolerance;
private double[] beginTanVector;
private double[] endTanVector;
private boolean rational;
private boolean closed;
private boolean periodic;
private double knotTolerance;
private double controlTolerance;
private double[] knotPoints;
private double[][] controlPoints;
private double[] weights;
private double[][] fitPoints;
/**
* Read a Spline in the DWG format Version 15
*
* @param data Array of unsigned bytes obtained from the DWG binary file
* @param offset The current bit offset where the value begins
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs
* when we are looking for LwPolylines.
*/
public void readDwgSplineV15(int[] data, int offset) throws Exception {
int bitPos = offset;
bitPos = readObjectHeaderV15(data, bitPos);
Vector v = DwgUtil.getBitShort(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int sc = ((Integer)v.get(1)).intValue();
scenario = sc;
v = DwgUtil.getBitShort(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int deg = ((Integer)v.get(1)).intValue();
degree = deg;
int knotsNumber = 0;
int controlPointsNumber = 0;
int fitPointsNumber = 0;
boolean weight = false;
if (sc==2) {
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double ft = ((Double)v.get(1)).doubleValue();
fitTolerance = ft;
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double x = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double y = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double z = ((Double)v.get(1)).doubleValue();
double[] coord = new double[]{x, y, z};
beginTanVector = coord;
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
x = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
y = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
z = ((Double)v.get(1)).doubleValue();
coord = new double[]{x, y, z};
endTanVector = coord;
v = DwgUtil.getBitShort(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
fitPointsNumber = ((Integer)v.get(1)).intValue();
} else if (sc==1) {
v = DwgUtil.testBit(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
boolean rat = ((Boolean)v.get(1)).booleanValue();
rational = rat;
v = DwgUtil.testBit(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
boolean closed = ((Boolean)v.get(1)).booleanValue();
this.closed = closed;
v = DwgUtil.testBit(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
boolean per = ((Boolean)v.get(1)).booleanValue();
periodic = per;
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double ktol = ((Double)v.get(1)).doubleValue();
knotTolerance = ktol;
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double ctol = ((Double)v.get(1)).doubleValue();
controlTolerance = ctol;
v = DwgUtil.getBitLong(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
knotsNumber = ((Integer)v.get(1)).intValue();
v = DwgUtil.getBitLong(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
controlPointsNumber = ((Integer)v.get(1)).intValue();
v = DwgUtil.testBit(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
weight = ((Boolean)v.get(1)).booleanValue();
} else {
System.out.println("ERROR: Escenario desconocido");
}
if (knotsNumber>0) {
double[] knotpts = new double[knotsNumber];
for (int i=0;i0) {
// Si el n?mero de weights no coincide con el de ctrlpts habr? problemas ...
double[][] ctrlpts = new double[controlPointsNumber][3];
double[] weights = new double[controlPointsNumber];
for (int i=0;i0) {
double[][] fitpts = new double[fitPointsNumber][3];
for (int i=0;i